@popclip/types 1.4615.0 → 1.4624.2

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