@popclip/types 1.4670.0 → 1.4688.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/popclip.d.ts +1046 -1038
package/popclip.d.ts
CHANGED
|
@@ -6,44 +6,44 @@ This is a TypeScript definitions file for PopClip's JavaScript interface.
|
|
|
6
6
|
* An object giving strings for the different languages PopClip supports. See {@link LocalizableString}.
|
|
7
7
|
*/
|
|
8
8
|
interface StringTable {
|
|
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
|
-
|
|
9
|
+
/** English (US) language string. */
|
|
10
|
+
en: string;
|
|
11
|
+
/** English (UK) language string. */
|
|
12
|
+
"en-GB"?: string;
|
|
13
|
+
/** Danish language string. */
|
|
14
|
+
da?: string;
|
|
15
|
+
/** German language string. */
|
|
16
|
+
de?: string;
|
|
17
|
+
/** Spanish language string. */
|
|
18
|
+
es?: string;
|
|
19
|
+
/** French language string. */
|
|
20
|
+
fr?: string;
|
|
21
|
+
/** Italian language string. */
|
|
22
|
+
it?: string;
|
|
23
|
+
/** Japanese language string. */
|
|
24
|
+
ja?: string;
|
|
25
|
+
/** Korean language string. */
|
|
26
|
+
ko?: string;
|
|
27
|
+
/** Dutch language string. */
|
|
28
|
+
nl?: string;
|
|
29
|
+
/** Polish language string. */
|
|
30
|
+
pl?: string;
|
|
31
|
+
/** Brazilian Portuguese language string. */
|
|
32
|
+
"pt-BR"?: string;
|
|
33
|
+
/** Russian language string. */
|
|
34
|
+
ru?: string;
|
|
35
|
+
/** Slovak language string. */
|
|
36
|
+
sk?: string;
|
|
37
|
+
/** Turkish language string. */
|
|
38
|
+
tr?: string;
|
|
39
|
+
/** Vietnamese language string. */
|
|
40
|
+
vi?: string;
|
|
41
|
+
/** Simplified Chinese language string. */
|
|
42
|
+
"zh-Hans"?: string;
|
|
43
|
+
/** Traditional Chinese language string. */
|
|
44
|
+
"zh-Hant"?: string;
|
|
45
|
+
/** Any other strings. */
|
|
46
|
+
[code: string]: string | undefined;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -68,14 +68,14 @@ type LocalizableString = string | StringTable;
|
|
|
68
68
|
* See {@link PopClip.modifiers}.
|
|
69
69
|
*/
|
|
70
70
|
interface Modifiers {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
/** Shift (⇧) key state. */
|
|
72
|
+
shift: boolean;
|
|
73
|
+
/** Control (⌃) key state. */
|
|
74
|
+
control: boolean;
|
|
75
|
+
/** Option (⌥) key state. */
|
|
76
|
+
option: boolean;
|
|
77
|
+
/** Command (⌘) key state. */
|
|
78
|
+
command: boolean;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -87,16 +87,16 @@ interface Modifiers {
|
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
89
|
type Requirement =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
| "text"
|
|
91
|
+
| "cut"
|
|
92
|
+
| "paste"
|
|
93
|
+
| "formatting"
|
|
94
|
+
| "url"
|
|
95
|
+
| "urls"
|
|
96
|
+
| "email"
|
|
97
|
+
| "emails"
|
|
98
|
+
| "path"
|
|
99
|
+
| `option-${string}=${string}`;
|
|
100
100
|
|
|
101
101
|
/** Negated form of {@link Requirement}. */
|
|
102
102
|
type NegatedRequirement = `!${Requirement}`;
|
|
@@ -110,37 +110,37 @@ type BeforeStep = "cut" | "copy" | "paste" | "paste-plain";
|
|
|
110
110
|
* Strings which can be used to specify the {@link Action.after} action.
|
|
111
111
|
*/
|
|
112
112
|
type AfterStep =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
| BeforeStep
|
|
114
|
+
| "popclip-appear"
|
|
115
|
+
| "show-status"
|
|
116
|
+
| "copy-result"
|
|
117
|
+
| "paste-result"
|
|
118
|
+
| "show-result"
|
|
119
|
+
| "preview-result";
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Declares information about an app or website that this extension interacts with.
|
|
123
123
|
*/
|
|
124
124
|
interface AssociatedApp {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Name of the app. For example "Scrivener"
|
|
127
|
+
*/
|
|
128
|
+
name: string;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Web page where user can obtain the app, e.g. "https://www.literatureandlatte.com/scrivener".
|
|
132
|
+
*/
|
|
133
|
+
link: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Indicates whether PopClip should check for the presence of the app on the computer. Default is false.
|
|
137
|
+
*/
|
|
138
|
+
checkInstalled?: boolean;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* List of possible bundle identifiers of this app.
|
|
142
|
+
*/
|
|
143
|
+
bundleIdentifiers?: string[];
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
|
@@ -151,37 +151,37 @@ interface AssociatedApp {
|
|
|
151
151
|
* @returns A single action, an array of actions.
|
|
152
152
|
*/
|
|
153
153
|
type PopulationFunction<CustomOptions = Options> = (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
input: Input,
|
|
155
|
+
options: CustomOptions,
|
|
156
|
+
context: Context,
|
|
157
157
|
) => (Action | ActionFunction)[] | Action | ActionFunction | void;
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
160
|
* Object returned by {@link Extension.auth} when there is an authentication flow to kick off
|
|
161
161
|
*/
|
|
162
162
|
type AuthFlowFunction = (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
url: string,
|
|
164
|
+
params?: { [key: string]: string | undefined },
|
|
165
|
+
expect?: string[],
|
|
166
166
|
) => Promise<any>;
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Credentials used in auth function
|
|
170
170
|
* */
|
|
171
171
|
interface AuthInfo {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
172
|
+
/** Value of `username` option (will be empty string if none defined) */
|
|
173
|
+
username: string;
|
|
174
|
+
/** Value of `password` option (will be empty string if none defined) */
|
|
175
|
+
password: string;
|
|
176
|
+
/** An appropriate value to use as the redirection URL in authorization flows for this extension.
|
|
177
|
+
* Example output:
|
|
178
|
+
* `http://localhost:58906/callback/com.pilotmoon.popclip.extension.todoist/auth`
|
|
179
|
+
*/
|
|
180
|
+
redirect: string;
|
|
181
|
+
/** Extension display name */
|
|
182
|
+
name: string;
|
|
183
|
+
/** Extension identifier */
|
|
184
|
+
identifier: string;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
/**
|
|
@@ -193,211 +193,211 @@ type AuthFunction = (info: AuthInfo, flow: AuthFlowFunction) => Promise<string>;
|
|
|
193
193
|
* Properties that define how an icon is interpreted.
|
|
194
194
|
*/
|
|
195
195
|
interface IconProperties {
|
|
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
|
-
|
|
196
|
+
/**
|
|
197
|
+
* If true, the supplied icon will be displayed with its original color instead of being filled in white/black. Default is false.
|
|
198
|
+
*/
|
|
199
|
+
preserveColor?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* If true, the supplied icon will be displayed with its original aspect ratio instead of being scaled to fit a square. Default is false.
|
|
202
|
+
*/
|
|
203
|
+
preserveAspect?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* If true, the supplied icon will be drawn horizontally flipped. Default is false.
|
|
206
|
+
*/
|
|
207
|
+
flipX?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* If true, the supplied icon will be drawn vertically flipped. Default is false.
|
|
210
|
+
*/
|
|
211
|
+
flipY?: boolean;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Move the icon horizontally by the specified distance, expressed as percentage of the icon's width.
|
|
215
|
+
*/
|
|
216
|
+
moveX?: number;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Move the icon vertically by the specified distance, expressed as percentage of the icon's height.
|
|
220
|
+
*/
|
|
221
|
+
moveY?: number;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Scale the icon by the specified factor, expressed as a percentage of the original size.
|
|
225
|
+
*/
|
|
226
|
+
scale?: number;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Rotate the icon anticlockwise by the specified angle, expressed in degrees.
|
|
230
|
+
*/
|
|
231
|
+
rotate?: number;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
234
|
Draw the icon inside a square.
|
|
235
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
|
-
|
|
236
|
+
square?: boolean;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Draw the icon inside a circle.
|
|
240
|
+
*/
|
|
241
|
+
circle?: boolean;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Draw the icon inside a magnifying glass shape.
|
|
245
|
+
*/
|
|
246
|
+
search?: boolean;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Draw a strike-through line over the icon.
|
|
250
|
+
*/
|
|
251
|
+
strike?: boolean;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Draw the enclosing shape as a solid shape.
|
|
255
|
+
*/
|
|
256
|
+
filled?: boolean;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* For text icons only. Draw the text using a monospaced font.
|
|
260
|
+
*/
|
|
261
|
+
monospaced?: boolean;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* Properties common to Action and Extension
|
|
266
266
|
*/
|
|
267
267
|
interface ActionProperties extends IconProperties {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
268
|
+
/**
|
|
269
|
+
* A unique identifying string. An identifier for an action can be any string of your choosing.
|
|
270
|
+
*/
|
|
271
|
+
identifier?: string;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The action's title.
|
|
275
|
+
*
|
|
276
|
+
* If no title is defined here, the extension's [`[name]] will be used, if any.
|
|
277
|
+
*/
|
|
278
|
+
title?: LocalizableString;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* A string to define the action's icon.
|
|
282
|
+
*
|
|
283
|
+
* If no icon is defined here, the extension's {@link Extension.icon | icon} will be used, if any.
|
|
284
|
+
* Setting to `null` explicitly sets the action to have no icon.
|
|
285
|
+
*/
|
|
286
|
+
icon?: string | null;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* An array of conditions which must be met for this action to appear — see {@link Requirement}.
|
|
290
|
+
*
|
|
291
|
+
* * If no array is specified here, the action takes the value of {@link Extension.requirements}.
|
|
292
|
+
* * If no array is specified there either, the action takes the default value `["text"]`.
|
|
293
|
+
*
|
|
294
|
+
* When multiple conditions are specified, all of them must be satisfied.
|
|
295
|
+
*
|
|
296
|
+
* An empty array (`[]`) indicates no requirements at all, meaning the action will always appear.
|
|
297
|
+
*
|
|
298
|
+
* This property has no effect on dynamically generated actions.
|
|
299
|
+
*/
|
|
300
|
+
requirements?: Array<Requirement | NegatedRequirement>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Array of bundle identifiers for which the extension should appear. The action will only
|
|
304
|
+
* appear if PopCLip is used in one of the specified apps.
|
|
305
|
+
*
|
|
306
|
+
* This property has no effect on dynamically generated actions.
|
|
307
|
+
*/
|
|
308
|
+
requiredApps?: string[];
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Array of bundle identifiers for which the extension should not appear. The action will not
|
|
312
|
+
* appear if PopClip is used in any of the specified apps.
|
|
313
|
+
*
|
|
314
|
+
* This property has no effect on dynamically generated actions.
|
|
315
|
+
*/
|
|
316
|
+
excludedApps?: string[];
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A regular expression to decide whether this action appears in the popup.
|
|
320
|
+
*
|
|
321
|
+
* * If no regex is specified here, the action takes the value of {@link Extension.regex}.
|
|
322
|
+
* * If no regex is specified there either, the action will match any input.
|
|
323
|
+
*
|
|
324
|
+
* You may express the value either as a
|
|
325
|
+
* [JavaScript regular expression literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
|
|
326
|
+
* (or otherwise constructed `RegExp` object), or as a string.
|
|
327
|
+
*
|
|
328
|
+
* * If you supply a `RegExp` it will be evaluated in the JavaScript engine.
|
|
329
|
+
* * If you supply a string it will be evaluated by macOS natively using the `NSRegularExpression` API (same as for 'classic' PopClip extensions).
|
|
330
|
+
*
|
|
331
|
+
* If the regex matches the selected text, the action will be shown in the popup and
|
|
332
|
+
* the first occurrence of the matched text is accessible later via {@link Input.matchedText | matchedText}.
|
|
333
|
+
*
|
|
334
|
+
* If there is no match, the action is excluded from the popup.
|
|
335
|
+
*
|
|
336
|
+
* The regex's `lastIndex` is reset before and after each invocation, so the `g` (global) and `y` (sticky) flags have no effect.
|
|
337
|
+
*
|
|
338
|
+
* This property has no effect on dynamically generated actions.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```js
|
|
342
|
+
* regex = /abc/i // Example regex 'abc' with 'i' (case insensitive) flag
|
|
343
|
+
* // Matches abc, ABC, Abc, etc.
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
regex?: RegExp | string;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Declares the application or website associated with this action, if any.
|
|
350
|
+
*/
|
|
351
|
+
app?: AssociatedApp;
|
|
352
|
+
apps?: AssociatedApp[];
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* An optional step to peform before the main action.
|
|
356
|
+
*/
|
|
357
|
+
before?: BeforeStep;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* An optional step to peform after the main action.
|
|
361
|
+
*/
|
|
362
|
+
after?: AfterStep;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Whether PopClip will capture HTML and Markdown content for the selection. Default is no.
|
|
366
|
+
*/
|
|
367
|
+
captureHtml?: boolean;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Whether PopClip will capture RTF (Rich Text Format) content for the selection. Default is no.
|
|
371
|
+
*/
|
|
372
|
+
captureRtf?: boolean;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Whether PopClip's popup should stay on screen after clicking this action's button. Default is no.
|
|
376
|
+
*/
|
|
377
|
+
stayVisible?: boolean;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Whether the pasteboard should be restored to its original state after `paste-result`.
|
|
381
|
+
*/
|
|
382
|
+
restorePasteboard?: boolean;
|
|
383
|
+
|
|
384
|
+
// static properties for benefit of JSON Schema
|
|
385
|
+
shortcutName?: string;
|
|
386
|
+
serviceName?: string;
|
|
387
|
+
url?: string;
|
|
388
|
+
keyCombo?: string | number;
|
|
389
|
+
keyCombos?: Array<string | number>;
|
|
390
|
+
applescript?: string;
|
|
391
|
+
applescriptFile?: string;
|
|
392
|
+
applescriptCall?: {
|
|
393
|
+
handler: string;
|
|
394
|
+
parameters?: string[];
|
|
395
|
+
};
|
|
396
|
+
shellScript?: string;
|
|
397
|
+
shellScriptFile?: string;
|
|
398
|
+
interpreter?: string;
|
|
399
|
+
javascript?: string;
|
|
400
|
+
javascriptFile?: string;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
/**
|
|
@@ -408,17 +408,25 @@ interface ActionProperties extends IconProperties {
|
|
|
408
408
|
* @param context Information about the context surrounding the selection. (Same object as {@link PopClip.context}.)
|
|
409
409
|
*/
|
|
410
410
|
type ActionFunction<CustomOptions = Options> = (
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
input: Input,
|
|
412
|
+
options: CustomOptions & AuthOptions,
|
|
413
|
+
context: Context,
|
|
414
414
|
) => Promise<string | void> | string | void;
|
|
415
415
|
|
|
416
|
+
/**
|
|
417
|
+
* A function that can be used to verify the extension's functionality.
|
|
418
|
+
* Test function should throw error if test test fails and exit normally if it succeeds.
|
|
419
|
+
* PopClip doesn't currently call the test function but you can use it to test your extension
|
|
420
|
+
* during development.
|
|
421
|
+
*/
|
|
422
|
+
type TestFunction = () => Promise<void> | void;
|
|
423
|
+
|
|
416
424
|
/**
|
|
417
425
|
* **Action** represents the properties of a single action.
|
|
418
426
|
* If `code` is omitted, the action displays a disabled title/icon only.
|
|
419
427
|
*/
|
|
420
428
|
interface Action<CustomOptions = Options> extends ActionProperties {
|
|
421
|
-
|
|
429
|
+
readonly code?: ActionFunction<CustomOptions>;
|
|
422
430
|
}
|
|
423
431
|
|
|
424
432
|
// included for JSON Schema
|
|
@@ -428,353 +436,358 @@ type Entitlement = "network" | "dynamic";
|
|
|
428
436
|
* The Extension object defines the PopClip extension.
|
|
429
437
|
*/
|
|
430
438
|
interface Extension<CustomOptions = Options> extends ActionProperties {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
439
|
+
/**
|
|
440
|
+
* The display name of this extension.
|
|
441
|
+
*/
|
|
442
|
+
name?: LocalizableString;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Defines the user-configurable options for this extension.
|
|
446
|
+
*/
|
|
447
|
+
options?: Option[];
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* If you define this function then PopClip will display a 'sign in' button in the options UI. When the user clicks the button,
|
|
451
|
+
* PopClip will call this function with an `info` object and an `flow` callback.
|
|
452
|
+
*
|
|
453
|
+
* If the sign in needs a username and password, you'll also need to define `username` and `password` options. PopClip will then pass the values
|
|
454
|
+
* of those options in the info parameter. */
|
|
455
|
+
auth?: AuthFunction;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Define the actions to go in PopClip's popup. This can be an array or a function.
|
|
459
|
+
*
|
|
460
|
+
* - If it's an array, the supplied actions are used in the popup, subject to meeting the
|
|
461
|
+
* requirements and regex conditions.
|
|
462
|
+
*
|
|
463
|
+
* - If it's a population function, it is called by PopClip to dynamically populate the popup with actions from this extension.
|
|
464
|
+
* Setting requirements and regex keys has no effect on dynamic actions — the function itself is responsible for deciding what actions to show.
|
|
465
|
+
* Population function requires the `dynamic` entitlement.
|
|
466
|
+
*/
|
|
467
|
+
actions?:
|
|
468
|
+
| (Action<CustomOptions> | ActionFunction<CustomOptions>)[]
|
|
469
|
+
| PopulationFunction<CustomOptions>;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Simplified property to define a single action.
|
|
473
|
+
*/
|
|
474
|
+
action?: Action<CustomOptions> | ActionFunction<CustomOptions>;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Exported test function for use during development.
|
|
478
|
+
*/
|
|
479
|
+
test: TestFunction;
|
|
480
|
+
|
|
481
|
+
// the following are static properties, included for the benefit of the JSON Scheme generation
|
|
482
|
+
popclipVersion?: number;
|
|
483
|
+
macosVersion?: string;
|
|
484
|
+
entitlements?: Entitlement[];
|
|
485
|
+
module?: string;
|
|
473
486
|
}
|
|
474
487
|
|
|
475
488
|
/**
|
|
476
489
|
* The possible values for `type` of {@link Option}.
|
|
477
490
|
*/
|
|
478
491
|
type OptionType =
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
492
|
+
| "string"
|
|
493
|
+
| "boolean"
|
|
494
|
+
| "multiple"
|
|
495
|
+
| "password"
|
|
496
|
+
| "heading"
|
|
497
|
+
| "secret";
|
|
485
498
|
|
|
486
499
|
/**
|
|
487
500
|
* Defines a single extension option.
|
|
488
501
|
*/
|
|
489
502
|
interface OptionBase {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
503
|
+
/**
|
|
504
|
+
* An identifying string for this option.
|
|
505
|
+
*/
|
|
506
|
+
readonly identifier: string;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* The kind of option, one of:
|
|
510
|
+
* * `string`: a text box for free text entry,
|
|
511
|
+
* * `boolean`: a check box,
|
|
512
|
+
* * `multiple`: multiple-choice drop-down with predefined options,
|
|
513
|
+
* * `secret`: concealed text entry field (persisted in user's keychain),
|
|
514
|
+
* * `password`: concealed text entry field (not persisted, only passed to auth function),
|
|
515
|
+
* * `heading`: adds a heading in the user interface, but does not actually define an option
|
|
516
|
+
*/
|
|
517
|
+
readonly type: OptionType;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* A short label for this option.
|
|
521
|
+
*/
|
|
522
|
+
readonly label?: LocalizableString;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* An optional longer explanantion of this option, to be shown in the UI.
|
|
526
|
+
*/
|
|
527
|
+
readonly description?: LocalizableString;
|
|
528
|
+
|
|
529
|
+
/*
|
|
530
|
+
* If true, this option will be hidden in the prefs window. Default is false.
|
|
531
|
+
*/
|
|
532
|
+
readonly hidden?: boolean;
|
|
533
|
+
|
|
534
|
+
/*
|
|
535
|
+
* If true, this option will be be inset to the right of its label, instead of below it. Default is false.
|
|
536
|
+
*/
|
|
537
|
+
readonly inset?: boolean;
|
|
525
538
|
}
|
|
526
539
|
|
|
527
540
|
/**
|
|
528
541
|
A string-valued option.
|
|
529
542
|
*/
|
|
530
543
|
interface StringOption extends OptionBase {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
544
|
+
readonly type: "string";
|
|
545
|
+
/**
|
|
546
|
+
* The default value of the option. If omitted, `string` options default to the empty string.
|
|
547
|
+
*/
|
|
548
|
+
readonly defaultValue?: string;
|
|
536
549
|
}
|
|
537
550
|
|
|
538
551
|
/**
|
|
539
552
|
* A multiple-choice option.
|
|
540
553
|
*/
|
|
541
554
|
interface MultipleOption extends OptionBase {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
555
|
+
readonly type: "multiple";
|
|
556
|
+
/**
|
|
557
|
+
* The default value of the option. If omitted, `multiple` options default to the top item in the list.
|
|
558
|
+
*/
|
|
559
|
+
readonly defaultValue?: string;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* The possible values for a `multiple` option.
|
|
563
|
+
*/
|
|
564
|
+
readonly values?: readonly string[];
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Display names corresponding to the entries in the {@link values} array. These are shown in the option UI.
|
|
568
|
+
* If ommitted, the raw value strings are shown instead.
|
|
569
|
+
*/
|
|
570
|
+
readonly valueLabels?: readonly LocalizableString[];
|
|
558
571
|
}
|
|
559
572
|
|
|
560
573
|
/**
|
|
561
574
|
* A boolean option.
|
|
562
575
|
*/
|
|
563
576
|
interface BooleanOption extends OptionBase {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
577
|
+
readonly type: "boolean";
|
|
578
|
+
/**
|
|
579
|
+
* The default value of the option. If omitted, `boolean` options default to true.
|
|
580
|
+
*/
|
|
581
|
+
readonly defaultValue?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* An icon for this option. It is only displayed for boolean options, next to the check box.
|
|
584
|
+
*/
|
|
585
|
+
readonly icon?: string;
|
|
573
586
|
}
|
|
574
587
|
|
|
575
588
|
/**
|
|
576
589
|
* A concealed string option.
|
|
577
590
|
*/
|
|
578
591
|
interface PasswordOption extends OptionBase {
|
|
579
|
-
|
|
592
|
+
readonly type: "password" | "secret";
|
|
580
593
|
}
|
|
581
594
|
|
|
582
595
|
/**
|
|
583
596
|
* A heading option, which does not define an actual option, but adds a heading in the preferences window.
|
|
584
597
|
*/
|
|
585
598
|
interface HeadingOption extends OptionBase {
|
|
586
|
-
|
|
599
|
+
readonly type: "heading";
|
|
587
600
|
}
|
|
588
601
|
|
|
589
602
|
/**
|
|
590
603
|
Represents a single option in the extension's preferences.
|
|
591
604
|
*/
|
|
592
605
|
type Option =
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
606
|
+
| StringOption
|
|
607
|
+
| MultipleOption
|
|
608
|
+
| BooleanOption
|
|
609
|
+
| PasswordOption
|
|
610
|
+
| HeadingOption;
|
|
598
611
|
|
|
599
612
|
// Create a type mapping from Option Type to TypeScript types
|
|
600
613
|
type OptionTypeMapping = {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
614
|
+
string: string;
|
|
615
|
+
secret: string;
|
|
616
|
+
multiple: string;
|
|
617
|
+
boolean: boolean;
|
|
605
618
|
};
|
|
606
619
|
|
|
607
620
|
// Helper type to extract the type for each option
|
|
608
621
|
type ExtractType<T extends Option> = T["type"] extends keyof OptionTypeMapping
|
|
609
|
-
|
|
610
|
-
|
|
622
|
+
? OptionTypeMapping[T["type"]]
|
|
623
|
+
: never;
|
|
611
624
|
|
|
612
625
|
// Helper type to exclude `never` properties
|
|
613
626
|
type ExcludeNever<T> = {
|
|
614
|
-
|
|
627
|
+
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
615
628
|
};
|
|
616
629
|
|
|
617
630
|
// Create a utility type to infer the OmnivoreOptions type
|
|
618
631
|
type InferOptions<T extends readonly Option[]> = ExcludeNever<{
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
632
|
+
readonly [K in T[number]["identifier"]]: ExtractType<
|
|
633
|
+
Extract<T[number], { identifier: K }>
|
|
634
|
+
>;
|
|
622
635
|
}>;
|
|
623
636
|
|
|
624
637
|
/**
|
|
625
638
|
* Represents a generic range, as a location and length
|
|
626
639
|
*/
|
|
627
640
|
interface Range {
|
|
628
|
-
|
|
629
|
-
|
|
641
|
+
location: number;
|
|
642
|
+
length: number;
|
|
630
643
|
}
|
|
631
644
|
|
|
632
645
|
/**
|
|
633
646
|
* An array of strings with an addiontal `ranges` property defining the source of the data in the orignal string.
|
|
634
647
|
*/
|
|
635
648
|
interface RangedStrings extends Array<string> {
|
|
636
|
-
|
|
649
|
+
ranges: Range[];
|
|
637
650
|
}
|
|
638
651
|
|
|
639
652
|
/**
|
|
640
653
|
* Input defines properties to access the input text contents.
|
|
641
654
|
*/
|
|
642
655
|
interface Input {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
656
|
+
/**
|
|
657
|
+
* The plain text selected by the user. If there is no selected text, this will be the empty string.
|
|
658
|
+
*/
|
|
659
|
+
text: string;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* If the action specified {@link Action.requirements} or a {@link Action.regex} to match the input, this will be the matching part of the text.
|
|
663
|
+
* Otherwise, it will be the same string as {@link text}.
|
|
664
|
+
*/
|
|
665
|
+
matchedText: string;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* If the action specified a {@link Action.regex | regex} to match the input, this will be the result of the the match.
|
|
669
|
+
*
|
|
670
|
+
* You can use this to access any capture groups from the regex.
|
|
671
|
+
*
|
|
672
|
+
* If the regex was specified as a JavaScript regex, the value is a return value from JavaScript's
|
|
673
|
+
* [RegExp.prototype.exec()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) method.
|
|
674
|
+
*
|
|
675
|
+
* If the regex was specified as an ICU regex in the static config, the value is the array of capture components.
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* ```js
|
|
679
|
+
* // text: "apple", regex: /.(.)/
|
|
680
|
+
* selection.regexResult[0] // "ap" (full match)
|
|
681
|
+
* selection.regexResult[1] // "p" (capture group 1)
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
regexResult?: RegExpMatchArray | string[] | null;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* HTML content (if `captureHtml` is true).
|
|
688
|
+
*/
|
|
689
|
+
html: string;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* XHTML content (if `captureHtml` is true).
|
|
693
|
+
*/
|
|
694
|
+
xhtml: string;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Markdown content (if `captureHtml` is true).
|
|
698
|
+
*/
|
|
699
|
+
markdown: string;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* RTF content (if `captureRtf` is true).
|
|
703
|
+
*/
|
|
704
|
+
rtf: string;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Data of various kinds, that PopClip detected in the selected text.
|
|
708
|
+
*/
|
|
709
|
+
data: {
|
|
710
|
+
/**
|
|
711
|
+
* HTTP ot HTTPS urls.
|
|
712
|
+
*/
|
|
713
|
+
urls: RangedStrings;
|
|
714
|
+
/**
|
|
715
|
+
* Other protocols or app urls e.g. `ftp:`, `omnifocus:`, `craftdocs:` etc. (PopClip has a pre-defined allowlist
|
|
716
|
+
* for custom URL schemes.)
|
|
717
|
+
*/
|
|
718
|
+
nonHttpUrls: RangedStrings;
|
|
719
|
+
/**
|
|
720
|
+
* Email addresses.
|
|
721
|
+
*/
|
|
722
|
+
emails: RangedStrings;
|
|
723
|
+
/**
|
|
724
|
+
* Local file paths.
|
|
725
|
+
* */
|
|
726
|
+
paths: RangedStrings;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Unprocessed selection contents indexed by UTI.
|
|
731
|
+
*/
|
|
732
|
+
content: PasteboardContent;
|
|
733
|
+
|
|
734
|
+
/**
|
|
722
735
|
Indicate if the text content is *just* a web URL (or URL-like string
|
|
723
736
|
such as `popclip.app`), allowing for leading and trailing whitespace.
|
|
724
737
|
*/
|
|
725
|
-
|
|
738
|
+
isUrl: boolean;
|
|
726
739
|
}
|
|
727
740
|
|
|
728
741
|
/**
|
|
729
742
|
* Properties relating the context surrounding the selected text.
|
|
730
743
|
*/
|
|
731
744
|
interface Context {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
745
|
+
/**
|
|
746
|
+
* Indicates whether the text area supports formatting.
|
|
747
|
+
*/
|
|
748
|
+
hasFormatting: boolean;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* This property is true iff the Paste command is enabled in the current app.
|
|
752
|
+
*/
|
|
753
|
+
canPaste: boolean;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* This property is true iff text was selected.
|
|
757
|
+
*/
|
|
758
|
+
canCopy: boolean;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* This property is true iff text was selected and the app's Cut command is enabled.
|
|
762
|
+
*/
|
|
763
|
+
canCut: boolean;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* If the current app is a compatible browser, this will be the page URL.
|
|
767
|
+
*/
|
|
768
|
+
browserUrl: string;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* If the current app is a compatible browser, this will be the page title.
|
|
772
|
+
*/
|
|
773
|
+
browserTitle: string;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* The name of the current app, for example `Drafts`.
|
|
777
|
+
*/
|
|
778
|
+
appName: string;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* The bundle identitifier of the current app, for example `com.agiletortoise.Drafts-OSX`.
|
|
782
|
+
*/
|
|
783
|
+
appIdentifier: string;
|
|
771
784
|
}
|
|
772
785
|
|
|
773
786
|
/**
|
|
774
787
|
* Represents the current values of the extension's settings.
|
|
775
788
|
*/
|
|
776
789
|
interface Options {
|
|
777
|
-
|
|
790
|
+
readonly [identifier: string]: string | boolean;
|
|
778
791
|
}
|
|
779
792
|
|
|
780
793
|
/**
|
|
@@ -782,10 +795,10 @@ interface Options {
|
|
|
782
795
|
* undefined or holding an empty string.
|
|
783
796
|
*/
|
|
784
797
|
interface AuthOptions {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
798
|
+
/**
|
|
799
|
+
* The stored value that was returned from the `auth()` function.
|
|
800
|
+
*/
|
|
801
|
+
authsecret: string;
|
|
789
802
|
}
|
|
790
803
|
|
|
791
804
|
/**
|
|
@@ -793,483 +806,478 @@ interface AuthOptions {
|
|
|
793
806
|
*
|
|
794
807
|
*/
|
|
795
808
|
interface PopClip {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
809
|
+
/**
|
|
810
|
+
* The state of the modifier keys when the action was invoked in PopClip.
|
|
811
|
+
*
|
|
812
|
+
* During the execution of the population function, all the modifiers will read as false.
|
|
813
|
+
*/
|
|
814
|
+
readonly modifiers: Modifiers;
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* The current selection.
|
|
818
|
+
*/
|
|
819
|
+
readonly input: Input;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* The current context.
|
|
823
|
+
*/
|
|
824
|
+
readonly context: Context;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* The current values of the options.
|
|
828
|
+
*/
|
|
829
|
+
readonly options: Options & AuthOptions;
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* If the target app's Paste command is available, this method places the given string on the pasteboard
|
|
833
|
+
* and then invokes the target app's Paste comand. If the `restore` flag is set in the options, it will
|
|
834
|
+
* then restore the original pasteboard contents.
|
|
835
|
+
*
|
|
836
|
+
* If the target app's Paste command is not available, it behaves as {@link copyText} instead.
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
*
|
|
840
|
+
* ```js
|
|
841
|
+
* // place "Hello" on the clipboard and invoke Paste
|
|
842
|
+
* popclip.pasteText("Hello");
|
|
843
|
+
* // place "Hello", then restore the original pasteboard contents
|
|
844
|
+
* popclip.pasteText("Hello", {restore: true});
|
|
845
|
+
* ```
|
|
846
|
+
* @param text The plain text string to paste
|
|
847
|
+
* @param options
|
|
848
|
+
*/
|
|
849
|
+
pasteText(text: string, options?: PasteOptions): void;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Paste mixed pasteboard content.
|
|
853
|
+
*/
|
|
854
|
+
pasteContent(content: PasteboardContent, options?: PasteOptions): void;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Place the given string on the pasteboard, optionally showing "Copied" notification to the user.
|
|
858
|
+
* @param text The plain text string to copy
|
|
859
|
+
*/
|
|
860
|
+
copyText(text: string, options?: CopyOptions): void;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Place mixed content on the pasteboard, optionally showing "Copied" notification to the user.
|
|
864
|
+
*/
|
|
865
|
+
copyContent(content: PasteboardContent, options?: CopyOptions): void;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Invokes a command in the target app.
|
|
869
|
+
* @param command Either `cut`, `copy` or `paste`.
|
|
870
|
+
* @param options Options for the command.
|
|
871
|
+
*/
|
|
872
|
+
performCommand(
|
|
873
|
+
command: "cut" | "copy" | "paste",
|
|
874
|
+
options?: {
|
|
875
|
+
/** Transformation to apply to the pasteboard contents. (Default: `none`)
|
|
876
|
+
* - `none`: regular pasteboard operation
|
|
877
|
+
* - `plain`: strips away everything but plain text
|
|
878
|
+
*/
|
|
879
|
+
transform?: "none" | "plain";
|
|
880
|
+
},
|
|
881
|
+
): void;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Display text to the user.
|
|
885
|
+
* @param text The text to display.
|
|
886
|
+
* @param options Options.
|
|
887
|
+
*/
|
|
888
|
+
showText(
|
|
889
|
+
text: string,
|
|
890
|
+
options?: {
|
|
891
|
+
/**
|
|
892
|
+
* Display style:
|
|
893
|
+
* - `compact` (default): Show the text inside PopClip's popup. It will be truncated to 160 characters when shown.
|
|
894
|
+
* - `large`: Show as "Large Type" in full screen.
|
|
895
|
+
*/
|
|
896
|
+
style?: "compact" | "large";
|
|
897
|
+
/**
|
|
898
|
+
* Applies to `compact` display mode only. If `true`, and the app's Paste command is available,
|
|
899
|
+
* the displayed text will be in a clickable button, which clicked, pastes the full text.
|
|
900
|
+
*/
|
|
901
|
+
preview?: boolean;
|
|
902
|
+
},
|
|
903
|
+
): void;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* PopClip will show a checkmark symbol to indicate success.
|
|
907
|
+
*/
|
|
908
|
+
showSuccess(): void;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* PopClip will show an "X" symbol to indicate failure.
|
|
912
|
+
*/
|
|
913
|
+
showFailure(): void;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* PopClip will open the settings UI for this extension.
|
|
917
|
+
*
|
|
918
|
+
* If the extension has no settings, this method does nothing.
|
|
919
|
+
*/
|
|
920
|
+
showSettings(): void;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Trigger PopClip to appear again with the current selection.
|
|
924
|
+
*/
|
|
925
|
+
appear(): void;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Simulate a key press by the user.
|
|
929
|
+
*
|
|
930
|
+
* @examples
|
|
931
|
+
*
|
|
932
|
+
* ```js
|
|
933
|
+
* // press the key combo ⌘B
|
|
934
|
+
* popclip.pressKey('command B');
|
|
935
|
+
* // press the key combo ⌥⌘H
|
|
936
|
+
* popclip.pressKey('option command H');
|
|
937
|
+
* // press the return key
|
|
938
|
+
* popclip.pressKey('return');
|
|
939
|
+
* popclip.pressKey(util.constant.KEY_RETURN); // equivalent
|
|
940
|
+
* * // press option and the page down key
|
|
941
|
+
* popclip.pressKey('option 0x79');
|
|
942
|
+
* popclip.pressKey(0x79, util.constant.MODIFIER_OPTION); // equivalent
|
|
943
|
+
* ```
|
|
944
|
+
*
|
|
945
|
+
* Some key code and modifier constants are available in {@link Util.constant | util.constant}.
|
|
946
|
+
*
|
|
947
|
+
* @param key The key to press. When this parameter is a string, PopClip will interpret it as in
|
|
948
|
+
* [Key Press actions](https://www.popclip.app/dev/key-press-actions).
|
|
949
|
+
* When this parameter is a number, PopClip will use that exact key code.
|
|
950
|
+
*
|
|
951
|
+
* @param modifiers An optional bit mask specifiying additional modifier keys, if any.
|
|
952
|
+
*/
|
|
953
|
+
pressKey(key: string | number, modifiers?: number): void;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Open a URL in a browser or other application.
|
|
957
|
+
*
|
|
958
|
+
* If a target application bundle identifier is specified via the `app` option, PopClip will ask that app to open the URL.
|
|
959
|
+
*
|
|
960
|
+
* If no target app is specified:
|
|
961
|
+
*
|
|
962
|
+
* - If the URL is a web URL (http or https scheme) and the current app is a browser, the URL is opened in the current app.
|
|
963
|
+
* - Otherwise, PopClip asks macOS to open the URL in the default handler for its scheme.
|
|
964
|
+
*
|
|
965
|
+
* Any parameters etc. in the URL must be appropriately percent-encoded. JavaScript provides the
|
|
966
|
+
* [encodeURIComponent()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
|
|
967
|
+
* function for this. Alternatively you can use the [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) class,
|
|
968
|
+
* which is available as a global in PopClip's JavaScript environment.
|
|
969
|
+
*
|
|
970
|
+
* @example
|
|
971
|
+
* ```js
|
|
972
|
+
* // examples using string URLs
|
|
973
|
+
* popclip.openUrl("https://xkcd.com"); // open in current/default browser
|
|
974
|
+
* popclip.openUrl("https://xkcd.com", {app: "com.brave.Browser"}); // open in Brave browser
|
|
975
|
+
*
|
|
976
|
+
* // example using URL class
|
|
977
|
+
* const mailUrl=new URL("mailto:support@pilotmoon.com");
|
|
978
|
+
* mailUrl.searchParams.append("subject", "What's up?");
|
|
979
|
+
* popclip.openUrl(mailUrl); // the mailto: link will open in the default mail application
|
|
980
|
+
* ```
|
|
981
|
+
*
|
|
982
|
+
* @param url URL string or a {@link UrlObject} representing the URL to open.
|
|
983
|
+
* @param options Options.
|
|
984
|
+
*/
|
|
985
|
+
openUrl(
|
|
986
|
+
url: string | UrlObject,
|
|
987
|
+
options?: {
|
|
988
|
+
/**
|
|
989
|
+
* Bundle identifier of the app to open the URL with. For example `"com.google.Chrome"`.
|
|
990
|
+
*/
|
|
991
|
+
app?: string;
|
|
992
|
+
/**
|
|
993
|
+
* Whether to request that macOS activate the target app. (Default: `true`)
|
|
994
|
+
*/
|
|
995
|
+
activate?: boolean;
|
|
996
|
+
/**
|
|
997
|
+
* When opening a web URL in a supported browser, whether to open the URL in a background tab. (Default: `false`)
|
|
998
|
+
*/
|
|
999
|
+
backgroundTab?: boolean;
|
|
1000
|
+
},
|
|
1001
|
+
): void;
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Share items with a named macOS sharing service.
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```js
|
|
1008
|
+
* // share a string with the Messages service
|
|
1009
|
+
* popclip.share("com.apple.share.Messages.window", ["Hello, world!"]);
|
|
1010
|
+
* // share a URL with the Safari Reading List service
|
|
1011
|
+
* popclip.share("com.apple.share.System.add-to-safari-reading-list", [{ url: "https://example.com" }]);
|
|
1012
|
+
* // share a an html string with the Notes service
|
|
1013
|
+
* const item = new RichString("Some <b>simple</b> html", { format: html })
|
|
1014
|
+
* popclip.share("com.apple.Notes.SharingExtension", [item]);
|
|
1015
|
+
* ```
|
|
1016
|
+
*
|
|
1017
|
+
* The list of available sharing services is determined by the user's system configuration.
|
|
1018
|
+
*
|
|
1019
|
+
* @param serviceName The name of the sharing service to use.
|
|
1020
|
+
* @param items An array of items to share. Each item can be a string, a {@link RichString} object, or a {@link UrlObject}.
|
|
1021
|
+
* @throws If the service name is not recognized, or if the service cannot handle the supplied items, an error is thrown.
|
|
1022
|
+
*/
|
|
1023
|
+
share(serviceName: string, items: (string | RichString | UrlObject)[]): void;
|
|
1011
1024
|
}
|
|
1012
1025
|
|
|
1013
1026
|
/**
|
|
1014
1027
|
* A container for various utility functions and constants {@link util} object.
|
|
1015
1028
|
*/
|
|
1016
1029
|
interface Util {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1030
|
+
/**
|
|
1031
|
+
* Localize an English string into the current user interface language, if possible.
|
|
1032
|
+
* This will work for strings which match an existing string in PopClip's user interface.
|
|
1033
|
+
*
|
|
1034
|
+
* @param string The string to localize.
|
|
1035
|
+
* @return The localized string, or the original string if no localized version was avaiable.
|
|
1036
|
+
*/
|
|
1037
|
+
localize(string: string): string;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1027
1040
|
Get information about the current locale as configures in macOS settings.
|
|
1028
1041
|
*/
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* Key code for the Up Arrow key.
|
|
1202
|
-
*/
|
|
1203
|
-
readonly KEY_UPARROW: 0x7e;
|
|
1204
|
-
};
|
|
1042
|
+
localeInfo: {
|
|
1043
|
+
localeIdentifier: string;
|
|
1044
|
+
regionCode: string;
|
|
1045
|
+
languageCode: string;
|
|
1046
|
+
decimalSeparator: string;
|
|
1047
|
+
groupingSeparator: string;
|
|
1048
|
+
currencyCode: string;
|
|
1049
|
+
currencySymbol: string;
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Get information about the current time zone as configured in macOS settings.
|
|
1054
|
+
*/
|
|
1055
|
+
timeZoneInfo: {
|
|
1056
|
+
identifier: string;
|
|
1057
|
+
abbreviation: string;
|
|
1058
|
+
secondsOffset: number;
|
|
1059
|
+
daylightSaving: boolean;
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
htmlToRtf(html: string): string | undefined;
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Encode a string as UTF-8 then Base-64 encode the result.
|
|
1066
|
+
*
|
|
1067
|
+
* @param string The string to encode.
|
|
1068
|
+
* @param options
|
|
1069
|
+
*/
|
|
1070
|
+
base64Encode(
|
|
1071
|
+
string: string,
|
|
1072
|
+
options?: {
|
|
1073
|
+
/**
|
|
1074
|
+
* Whether to encode using the URL-safe variant, with `-` and `_` substituted for `+` and `/`. Default is no.
|
|
1075
|
+
*/
|
|
1076
|
+
urlSafe?: boolean;
|
|
1077
|
+
/**
|
|
1078
|
+
* Whether to trim the `=`/`==` padding from the string. Default is no.
|
|
1079
|
+
*/
|
|
1080
|
+
trimmed?: boolean;
|
|
1081
|
+
},
|
|
1082
|
+
): string;
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Decode a Base-64 string and interpret the result as a UTF-8 string.
|
|
1086
|
+
*
|
|
1087
|
+
* Accepts both standard and URL-safe variants as input. Also accepts input with or without the `=`/`==` end padding.
|
|
1088
|
+
* Throws an error if the input cannot be decoded as a UTF-8 string.
|
|
1089
|
+
*
|
|
1090
|
+
* @param string
|
|
1091
|
+
* @returns The decoded string
|
|
1092
|
+
*/
|
|
1093
|
+
base64Decode(string: string): string;
|
|
1094
|
+
|
|
1095
|
+
/* Build a URL from a base URL and additional query parameters */
|
|
1096
|
+
buildQueryUrl: (baseUrl: string, params: { [key: string]: string }) => string;
|
|
1097
|
+
|
|
1098
|
+
/* Build a query from params object */
|
|
1099
|
+
buildQuery: (params: { [key: string]: string }) => string;
|
|
1100
|
+
|
|
1101
|
+
/* Parse a query into params object */
|
|
1102
|
+
parseQuery: (query: string) => any;
|
|
1103
|
+
|
|
1104
|
+
/** Decipher a JSON object that has been lightly obscured to prevent constants such as
|
|
1105
|
+
* API client identifiers appearing in plaintext in the source files.
|
|
1106
|
+
*
|
|
1107
|
+
* This function will ROT13 decipher the text, apply Base64 decoding, and parse the result as JSON. */
|
|
1108
|
+
clarify(obscuredString: string): any;
|
|
1109
|
+
|
|
1110
|
+
// same as global sleep()
|
|
1111
|
+
sleep(durationMilliseconds: number): Promise<void>;
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Fill the provided `TypedArray` with cryptographically secure random values.
|
|
1115
|
+
* This aims work like `crypto.getRandomValues()` from Web Crypto API.
|
|
1116
|
+
* Internally, it is implemented using Apple's `SecRandomCopyBytes`.
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
*
|
|
1120
|
+
* ```js
|
|
1121
|
+
* const array = new Uint8Array(16); // array of 16 bytes
|
|
1122
|
+
* util.getRandomValues(array); // array is now filled with random bytes
|
|
1123
|
+
* ```
|
|
1124
|
+
*
|
|
1125
|
+
* @param typedArray The array to fill with random values. This will be modified in place.
|
|
1126
|
+
*/
|
|
1127
|
+
getRandomValues(
|
|
1128
|
+
typedArray:
|
|
1129
|
+
| Int8Array
|
|
1130
|
+
| Uint8Array
|
|
1131
|
+
| Uint8ClampedArray
|
|
1132
|
+
| Int16Array
|
|
1133
|
+
| Uint16Array
|
|
1134
|
+
| Int32Array
|
|
1135
|
+
| Uint32Array
|
|
1136
|
+
| BigInt64Array
|
|
1137
|
+
| BigUint64Array,
|
|
1138
|
+
): void;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Generate a RFC 4122 version 4 UUID using a cryptographically secure random number generator.
|
|
1142
|
+
* @returns UUID string such as "e621e1f8-c36c-495a-93fc-0c247a3e6e5f".
|
|
1143
|
+
*/
|
|
1144
|
+
randomUuid(): string;
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* Generate hash-based message authentication code (HMAC) using the supplied data, key and algorithm.
|
|
1148
|
+
* Implemented internally by Apple's CommonCrypto.
|
|
1149
|
+
*/
|
|
1150
|
+
hmac(
|
|
1151
|
+
data: Uint8Array,
|
|
1152
|
+
key: Uint8Array,
|
|
1153
|
+
algorithm: "sha1" | "md5" | "sha256" | "sha384" | "sha512" | "sha224",
|
|
1154
|
+
): Uint8Array;
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* The `constant` property is a container for pre-defined constants.
|
|
1158
|
+
*/
|
|
1159
|
+
readonly constant: {
|
|
1160
|
+
/**
|
|
1161
|
+
* Bit mask for the Shift (⇧) key.
|
|
1162
|
+
*/
|
|
1163
|
+
readonly MODIFIER_SHIFT: 131072;
|
|
1164
|
+
/**
|
|
1165
|
+
* Bit mask for the Control (⌃) key.
|
|
1166
|
+
*/
|
|
1167
|
+
readonly MODIFIER_CONTROL: 262144;
|
|
1168
|
+
/**
|
|
1169
|
+
* Bit mask for the Option (⌥) key.
|
|
1170
|
+
*/
|
|
1171
|
+
readonly MODIFIER_OPTION: 524288;
|
|
1172
|
+
/**
|
|
1173
|
+
* Bit mask for the Command (⌘) key.
|
|
1174
|
+
*/
|
|
1175
|
+
readonly MODIFIER_COMMAND: 1048576;
|
|
1176
|
+
/**
|
|
1177
|
+
* Key code for the Return (↵) key.
|
|
1178
|
+
*/
|
|
1179
|
+
readonly KEY_RETURN: 0x24;
|
|
1180
|
+
/**
|
|
1181
|
+
* Key code for the Tab (⇥) key.
|
|
1182
|
+
*/
|
|
1183
|
+
readonly KEY_TAB: 0x30;
|
|
1184
|
+
/**
|
|
1185
|
+
* Key code for the space bar.
|
|
1186
|
+
*/
|
|
1187
|
+
readonly KEY_SPACE: 0x31;
|
|
1188
|
+
/**
|
|
1189
|
+
* Key code for the Delete (⌫) key.
|
|
1190
|
+
*/
|
|
1191
|
+
readonly KEY_DELETE: 0x33;
|
|
1192
|
+
/**
|
|
1193
|
+
* Key code for the Escape key.
|
|
1194
|
+
*/
|
|
1195
|
+
readonly KEY_ESCAPE: 0x35;
|
|
1196
|
+
/**
|
|
1197
|
+
* Key code for the Left Arrow key.
|
|
1198
|
+
*/
|
|
1199
|
+
readonly KEY_LEFTARROW: 0x7b;
|
|
1200
|
+
/**
|
|
1201
|
+
* Key code for the Right Arrow key.
|
|
1202
|
+
*/
|
|
1203
|
+
readonly KEY_RIGHTARROW: 0x7c;
|
|
1204
|
+
/**
|
|
1205
|
+
* Key code for the Down Arrow key.
|
|
1206
|
+
*/
|
|
1207
|
+
readonly KEY_DOWNARROW: 0x7d;
|
|
1208
|
+
/**
|
|
1209
|
+
* Key code for the Up Arrow key.
|
|
1210
|
+
*/
|
|
1211
|
+
readonly KEY_UPARROW: 0x7e;
|
|
1212
|
+
};
|
|
1205
1213
|
}
|
|
1206
1214
|
|
|
1207
1215
|
/**
|
|
1208
1216
|
* Represents the raw pasteboard content, indexed by UTI. Supports string data only.
|
|
1209
1217
|
*/
|
|
1210
1218
|
interface PasteboardContent {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1219
|
+
/**
|
|
1220
|
+
* The UTF-8 plain text content of the pasteboard.
|
|
1221
|
+
*/
|
|
1222
|
+
"public.utf8-plain-text"?: string;
|
|
1223
|
+
/**
|
|
1224
|
+
* The HTML content of the pasteboard.
|
|
1225
|
+
*/
|
|
1226
|
+
"public.html"?: string;
|
|
1227
|
+
/**
|
|
1228
|
+
* The RTF content of the pasteboard.
|
|
1229
|
+
*/
|
|
1230
|
+
"public.rtf"?: string;
|
|
1223
1231
|
}
|
|
1224
1232
|
|
|
1225
1233
|
/**
|
|
1226
1234
|
* Options for Paste operations.
|
|
1227
1235
|
*/
|
|
1228
1236
|
interface PasteOptions {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1237
|
+
/**
|
|
1238
|
+
* Whether to restore the original contents of the pasteboard after the paste
|
|
1239
|
+
* operation. Default is `false`.
|
|
1240
|
+
*/
|
|
1241
|
+
restore?: boolean;
|
|
1234
1242
|
}
|
|
1235
1243
|
|
|
1236
1244
|
/**
|
|
1237
1245
|
* Options for Copy operations.
|
|
1238
1246
|
*/
|
|
1239
1247
|
interface CopyOptions {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1248
|
+
/**
|
|
1249
|
+
* Whether to show the "Copied" notification to the user. (Default: `true`)
|
|
1250
|
+
*/
|
|
1251
|
+
notify?: boolean;
|
|
1244
1252
|
}
|
|
1245
1253
|
|
|
1246
1254
|
/**
|
|
1247
1255
|
* A simplified interface to the macOS pasteboard. Implemented by the global object, {@link pasteboard}.
|
|
1248
1256
|
*/
|
|
1249
1257
|
interface Pasteboard {
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1258
|
+
/**
|
|
1259
|
+
* Get and set the plain text content of the pasteboard.
|
|
1260
|
+
*
|
|
1261
|
+
* This property corresponds with the pasteboard type `public.utf8-plain-text`.
|
|
1262
|
+
*
|
|
1263
|
+
* When placing text on the pasteboard this way, PopClip's "Copied" notification will not appear.
|
|
1264
|
+
* (Typically, scripts should use {@link PopClip.copyText} instead, so that the user gets the "Copied" notification.)
|
|
1265
|
+
*
|
|
1266
|
+
* The value of this property will always be a string. If there is no plain text value on the
|
|
1267
|
+
* pasteboard, reading this property will give an empty string (`""`).
|
|
1268
|
+
*
|
|
1269
|
+
* @example
|
|
1270
|
+
* ```js
|
|
1271
|
+
* let x = pasteboard.text;
|
|
1272
|
+
* pasteboard.text = "new text";
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
text: string;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Get and set the content of the pasteboard, of the specified types
|
|
1279
|
+
*/
|
|
1280
|
+
content: PasteboardContent;
|
|
1273
1281
|
}
|
|
1274
1282
|
|
|
1275
1283
|
/**
|
|
@@ -1299,18 +1307,18 @@ declare const popclip: PopClip;
|
|
|
1299
1307
|
* ```
|
|
1300
1308
|
*/
|
|
1301
1309
|
declare type UrlObject =
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1310
|
+
| {
|
|
1311
|
+
/**
|
|
1312
|
+
* String to be used as-is.
|
|
1313
|
+
*/
|
|
1314
|
+
url: string;
|
|
1315
|
+
}
|
|
1316
|
+
| {
|
|
1317
|
+
/**
|
|
1318
|
+
* String in which PopClip will replace `+` characters with `%20` before use.
|
|
1319
|
+
*/
|
|
1320
|
+
href: string;
|
|
1321
|
+
};
|
|
1314
1322
|
|
|
1315
1323
|
/**
|
|
1316
1324
|
* Represents a formatted text string. The underlying implementation uses a macOS Attributed String (`NSAttributedString`) object.
|
|
@@ -1325,29 +1333,29 @@ declare type UrlObject =
|
|
|
1325
1333
|
* ```
|
|
1326
1334
|
*/
|
|
1327
1335
|
declare class RichString {
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1336
|
+
/**
|
|
1337
|
+
* Create a new RichString object from a string.
|
|
1338
|
+
*
|
|
1339
|
+
* @param source The string to convert to a RichString object.
|
|
1340
|
+
* @param options Options for the conversion.
|
|
1341
|
+
*/
|
|
1342
|
+
constructor(
|
|
1343
|
+
source: string,
|
|
1344
|
+
options?: {
|
|
1345
|
+
/**
|
|
1338
1346
|
Format of the source string. Default is 'rtf'.
|
|
1339
1347
|
*/
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1348
|
+
format?: "rtf" | "html" | "markdown";
|
|
1349
|
+
},
|
|
1350
|
+
);
|
|
1351
|
+
/**
|
|
1352
|
+
* An RTF representation of the content.
|
|
1353
|
+
*/
|
|
1354
|
+
readonly rtf: string;
|
|
1355
|
+
/**
|
|
1356
|
+
* An HTML representation of the content.
|
|
1357
|
+
*/
|
|
1358
|
+
readonly html: string;
|
|
1351
1359
|
}
|
|
1352
1360
|
|
|
1353
1361
|
/**
|
|
@@ -1399,5 +1407,5 @@ declare function sleep(durationMilliseconds: number): Promise<void>;
|
|
|
1399
1407
|
* @param extension The extension object to export.
|
|
1400
1408
|
*/
|
|
1401
1409
|
declare function defineExtension<CustomOptions = Options>(
|
|
1402
|
-
|
|
1410
|
+
extension: Extension<CustomOptions>,
|
|
1403
1411
|
): void;
|