-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathshortcut.go
More file actions
289 lines (244 loc) Β· 6.61 KB
/
shortcut.go
File metadata and controls
289 lines (244 loc) Β· 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
* Copyright (c) Cherri
*/
package main
/*
Shortcut File Format Data Structures
*/
type ShortcutIcon struct {
WFWorkflowIconGlyphNumber int64
WFWorkflowIconStartColor int
}
type Shortcut struct {
WFWorkflowIcon ShortcutIcon
WFWorkflowActions []ShortcutAction
WFQuickActionSurfaces []string
WFWorkflowInputContentItemClasses []string
WFWorkflowClientVersion string
WFWorkflowMinimumClientVersion int
WFWorkflowMinimumClientVersionString string
WFWorkflowImportQuestions interface{}
WFWorkflowTypes []string
WFWorkflowOutputContentItemClasses []string
WFWorkflowHasShortcutInputVariables bool
WFWorkflowHasOutputFallback bool
WFWorkflowNoInputBehavior map[string]any
}
var shortcut Shortcut
type ShortcutAction struct {
WFWorkflowActionIdentifier string
WFWorkflowActionParameters map[string]any
}
type Value struct {
Type string
VariableName string
OutputUUID string
OutputName string
Value any
Variable any
WFDictionaryFieldValueItems []WFDictionaryFieldValueItem
AttachmentsByRange map[string]Value
String string
Aggrandizements []Aggrandizement
Prompt string
}
type Aggrandizement struct {
Type string
CoercionItemClass string
DictionaryKey string
PropertyName string
PropertyUserInfo any
}
type WFDictionaryFieldValueItem struct {
WFKey any
WFItemType int
WFValue any
}
type WFValue struct {
Value any
String string
WFSerializationType string
}
type WFInput struct {
Value Value
}
type WFContactFieldValue struct {
EntryType int
SerializedEntry map[string]interface{}
}
type SizeValue struct {
Unit string
Magnitude string
}
type WFMeasurementUnit struct {
WFNSUnitSymbol any
Value SizeValue
}
var uuids map[string]string
type dictDataType int
const itemTypeText dictDataType = 0
const itemTypeNumber dictDataType = 3
const itemTypeArray dictDataType = 2
const itemTypeDict dictDataType = 1
const itemTypeBool dictDataType = 4
var noInput map[string]any
var hasShortcutInputVariables = false
// ObjectReplaceChar is a Shortcuts convention to mark the placement of inline variables in a string.
const ObjectReplaceChar = '\uFFFC'
const ObjectReplaceCharStr = "\uFFFC"
var workflowName string
var definitions map[string]any
/* Colors */
var colors = map[string]int{
"red": 4282601983,
"darkorange": 4251333119,
"orange": 4271458815,
"yellow": 4274264319,
"green": 4292093695,
"teal": 431817727,
"lightblue": 1440408063,
"blue": 463140863,
"darkblue": 946986751,
"violet": 2071128575,
"purple": 3679049983,
"pink": 3980825855,
"darkgray": 255,
"gray": 3031607807,
"taupe": 2846468607,
}
var iconColor = 3031607807
var altColors = map[string]int{
"red": -12365313,
"darkorange": -43634177,
"orange": -23508481,
"yellow": -20702977,
"green": -2873601,
"teal": -3863149569,
"lightblue": -2854559233,
"blue": -3831826433,
"darkblue": -3347980545,
"violet": -2223838721,
"purple": -615917313,
"pink": -314141441,
"darkgray": -4294967041,
"gray": -1263359489,
"taupe": -1448498689,
}
/* Inputs */
var contentItems = map[string]string{
"app": "WFAppStoreAppContentItem",
"article": "WFArticleContentItem",
"contact": "WFContactContentItem",
"date": "WFDateContentItem",
"email": "WFEmailAddressContentItem",
"folder": "WFFolderContentItem",
"file": "WFGenericFileContentItem",
"image": "WFImageContentItem",
"itunes": "WFiTunesProductContentItem",
"location": "WFLocationContentItem",
"maplink": "WFDCMapsLinkContentItem",
"media": "WFAVAssetContentItem",
"pdf": "WFPDFContentItem",
"phonenumber": "WFPhoneNumberContentItem",
"richtext": "WFRichTextContentItem",
"webpage": "WFSafariWebPageContentItem",
"text": "WFStringContentItem",
"dictionary": "WFDictionaryContentItem",
"number": "WFNumberContentItem",
"url": "WFURLContentItem",
}
var revContentItems map[string]string
func reversedContentItems() map[string]string {
if len(revContentItems) == 0 {
var revContentItems = make(map[string]string)
for key, item := range contentItems {
revContentItems[item] = key
}
}
return revContentItems
}
var inputs []string
var outputs []string
/* Workflow Types */
var workflowTypes = map[string]string{
"menubar": "MenuBar",
"quickactions": "QuickActions",
"sharesheet": "ActionExtension",
"notifications": "NCWidget",
"sleepmode": "Sleep",
"watch": "Watch",
"onscreen": "ReceivesOnScreenContent",
"search": "WFWorkflowTypeShowInSearch",
"spotlight": "WFWorkflowTypeReceivesInputFromSearch",
}
var definedWorkflowTypes []string
/* Quick Actions */
var quickActions = map[string]string{
"finder": "Finder",
"services": "Services",
}
var definedQuickActions []string
/* Versions */
var versions = map[string]string{
"26": "4033.0.4.3",
"18.4": "3218.0.4.100",
"18": "3036.0.4.2",
"17": "2106.0.3",
"16.5": "900",
"16.4": "900",
"16.3": "900",
"16.2": "900",
"16": "900",
"15.7.2": "800",
"15": "800",
"14": "700",
"13": "600",
"12": "500",
}
var clientVersion = versions["26"]
var iosVersion = 26.0
/* Conditionals */
type WFConditions struct {
conditions []condition
WFActionParameterFilterPrefix int
}
type condition struct {
condition int
arguments []actionArgument
}
var conditions = map[tokenType]int{
Is: 4,
Not: 5,
Any: 100,
Empty: 101,
Contains: 99,
DoesNotContain: 999,
BeginsWith: 8,
EndsWith: 9,
GreaterThan: 2,
GreaterOrEqual: 3,
LessThan: 0,
LessOrEqual: 1,
Between: 1003,
}
var conditionFilterPrefixes = map[tokenType]int{
Or: 0,
And: 1,
}
var allowedConditionalTypes = map[tokenType][]tokenType{
Is: {String, Integer, Bool, Action},
Not: {String, Integer, Bool, Action},
Any: {},
Empty: {},
Contains: {String, Arr},
DoesNotContain: {String, Arr},
BeginsWith: {String},
EndsWith: {String},
GreaterThan: {Integer, Float},
GreaterOrEqual: {Integer, Float},
LessThan: {Integer, Float},
LessOrEqual: {Integer, Float},
Between: {Integer, Float},
}
/* Menus */
var menus map[string][]varValue