@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. 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
- /** 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
  /**
@@ -68,14 +68,14 @@ type LocalizableString = string | StringTable;
68
68
  * See {@link PopClip.modifiers}.
69
69
  */
70
70
  interface Modifiers {
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;
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
- | "text"
91
- | "cut"
92
- | "paste"
93
- | "formatting"
94
- | "url"
95
- | "urls"
96
- | "email"
97
- | "emails"
98
- | "path"
99
- | `option-${string}=${string}`;
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
- | BeforeStep
114
- | "popclip-appear"
115
- | "show-status"
116
- | "copy-result"
117
- | "paste-result"
118
- | "show-result"
119
- | "preview-result";
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
- * 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[];
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
- input: Input,
155
- options: CustomOptions,
156
- context: Context,
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
- url: string,
164
- params?: { [key: string]: string | undefined },
165
- expect?: string[],
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
- /** 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;
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
- * 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
- /**
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
- 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;
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
- * 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;
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
- input: Input,
412
- options: CustomOptions & AuthOptions,
413
- context: Context,
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
- readonly code?: ActionFunction<CustomOptions>;
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
- * The display name of this extension.
433
- */
434
- name?: LocalizableString;
435
-
436
- /**
437
- * Defines the user-configurable options for this extension.
438
- */
439
- options?: Option[];
440
-
441
- /**
442
- * If you define this function then PopClip will display a 'sign in' button in the options UI. When the user clicks the button,
443
- * PopClip will call this function with an `info` object and an `flow` callback.
444
- *
445
- * 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
446
- * of those options in the info parameter. */
447
- auth?: AuthFunction;
448
-
449
- /**
450
- * Define the actions to go in PopClip's popup. This can be an array or a function.
451
- *
452
- * - If it's an array, the supplied actions are used in the popup, subject to meeting the
453
- * requirements and regex conditions.
454
- *
455
- * - If it's a population function, it is called by PopClip to dynamically populate the popup with actions from this extension.
456
- * Setting requirements and regex keys has no effect on dynamic actions — the function itself is responsible for deciding what actions to show.
457
- * Population function requires the `dynamic` entitlement.
458
- */
459
- actions?:
460
- | (Action<CustomOptions> | ActionFunction<CustomOptions>)[]
461
- | PopulationFunction<CustomOptions>;
462
-
463
- /**
464
- * Simplified property to define a single action.
465
- */
466
- action?: Action<CustomOptions> | ActionFunction<CustomOptions>;
467
-
468
- // the following are static properties, included for the benefit of the JSON Scheme generation
469
- popclipVersion?: number;
470
- macosVersion?: string;
471
- entitlements?: Entitlement[];
472
- module?: string;
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
- | "string"
480
- | "boolean"
481
- | "multiple"
482
- | "password"
483
- | "heading"
484
- | "secret";
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
- * An identifying string for this option.
492
- */
493
- readonly identifier: string;
494
-
495
- /**
496
- * The kind of option, one of:
497
- * * `string`: a text box for free text entry,
498
- * * `boolean`: a check box,
499
- * * `multiple`: multiple-choice drop-down with predefined options,
500
- * * `secret`: concealed text entry field (persisted in user's keychain),
501
- * * `password`: concealed text entry field (not persisted, only passed to auth function),
502
- * * `heading`: adds a heading in the user interface, but does not actually define an option
503
- */
504
- readonly type: OptionType;
505
-
506
- /**
507
- * A short label for this option.
508
- */
509
- readonly label?: LocalizableString;
510
-
511
- /**
512
- * An optional longer explanantion of this option, to be shown in the UI.
513
- */
514
- readonly description?: LocalizableString;
515
-
516
- /*
517
- * If true, this option will be hidden in the prefs window. Default is false.
518
- */
519
- readonly hidden?: boolean;
520
-
521
- /*
522
- * If true, this option will be be inset to the right of its label, instead of below it. Default is false.
523
- */
524
- readonly inset?: boolean;
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
- readonly type: "string";
532
- /**
533
- * The default value of the option. If omitted, `string` options default to the empty string.
534
- */
535
- readonly defaultValue?: string;
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
- readonly type: "multiple";
543
- /**
544
- * The default value of the option. If omitted, `multiple` options default to the top item in the list.
545
- */
546
- readonly defaultValue?: string;
547
-
548
- /**
549
- * The possible values for a `multiple` option.
550
- */
551
- readonly values?: readonly string[];
552
-
553
- /**
554
- * Display names corresponding to the entries in the {@link values} array. These are shown in the option UI.
555
- * If ommitted, the raw value strings are shown instead.
556
- */
557
- readonly valueLabels?: readonly LocalizableString[];
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
- readonly type: "boolean";
565
- /**
566
- * The default value of the option. If omitted, `boolean` options default to true.
567
- */
568
- readonly defaultValue?: boolean;
569
- /**
570
- * An icon for this option. It is only displayed for boolean options, next to the check box.
571
- */
572
- readonly icon?: string;
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
- readonly type: "password" | "secret";
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
- readonly type: "heading";
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
- | StringOption
594
- | MultipleOption
595
- | BooleanOption
596
- | PasswordOption
597
- | HeadingOption;
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
- string: string;
602
- secret: string;
603
- multiple: string;
604
- boolean: boolean;
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
- ? OptionTypeMapping[T["type"]]
610
- : never;
622
+ ? OptionTypeMapping[T["type"]]
623
+ : never;
611
624
 
612
625
  // Helper type to exclude `never` properties
613
626
  type ExcludeNever<T> = {
614
- [K in keyof T as T[K] extends never ? never : K]: T[K];
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
- readonly [K in T[number]["identifier"]]: ExtractType<
620
- Extract<T[number], { identifier: K }>
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
- location: number;
629
- length: number;
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
- ranges: Range[];
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
- * The plain text selected by the user. If there is no selected text, this will be the empty string.
645
- */
646
- text: string;
647
-
648
- /**
649
- * 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.
650
- * Otherwise, it will be the same string as {@link text}.
651
- */
652
- matchedText: string;
653
-
654
- /**
655
- * If the action specified a {@link Action.regex | regex} to match the input, this will be the result of the the match.
656
- *
657
- * You can use this to access any capture groups from the regex.
658
- *
659
- * If the regex was specified as a JavaScript regex, the value is a return value from JavaScript's
660
- * [RegExp.prototype.exec()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) method.
661
- *
662
- * If the regex was specified as an ICU regex in the static config, the value is the array of capture components.
663
- *
664
- * @example
665
- * ```js
666
- * // text: "apple", regex: /.(.)/
667
- * selection.regexResult[0] // "ap" (full match)
668
- * selection.regexResult[1] // "p" (capture group 1)
669
- * ```
670
- */
671
- regexResult?: RegExpMatchArray | string[] | null;
672
-
673
- /**
674
- * HTML content (if `captureHtml` is true).
675
- */
676
- html: string;
677
-
678
- /**
679
- * XHTML content (if `captureHtml` is true).
680
- */
681
- xhtml: string;
682
-
683
- /**
684
- * Markdown content (if `captureHtml` is true).
685
- */
686
- markdown: string;
687
-
688
- /**
689
- * RTF content (if `captureRtf` is true).
690
- */
691
- rtf: string;
692
-
693
- /**
694
- * Data of various kinds, that PopClip detected in the selected text.
695
- */
696
- data: {
697
- /**
698
- * HTTP ot HTTPS urls.
699
- */
700
- urls: RangedStrings;
701
- /**
702
- * Other protocols or app urls e.g. `ftp:`, `omnifocus:`, `craftdocs:` etc. (PopClip has a pre-defined allowlist
703
- * for custom URL schemes.)
704
- */
705
- nonHttpUrls: RangedStrings;
706
- /**
707
- * Email addresses.
708
- */
709
- emails: RangedStrings;
710
- /**
711
- * Local file paths.
712
- * */
713
- paths: RangedStrings;
714
- };
715
-
716
- /**
717
- * Unprocessed selection contents indexed by UTI.
718
- */
719
- content: PasteboardContent;
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
- isUrl: boolean;
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
- * Indicates whether the text area supports formatting.
734
- */
735
- hasFormatting: boolean;
736
-
737
- /**
738
- * This property is true iff the Paste command is enabled in the current app.
739
- */
740
- canPaste: boolean;
741
-
742
- /**
743
- * This property is true iff text was selected.
744
- */
745
- canCopy: boolean;
746
-
747
- /**
748
- * This property is true iff text was selected and the app's Cut command is enabled.
749
- */
750
- canCut: boolean;
751
-
752
- /**
753
- * If the current app is a compatible browser, this will be the page URL.
754
- */
755
- browserUrl: string;
756
-
757
- /**
758
- * If the current app is a compatible browser, this will be the page title.
759
- */
760
- browserTitle: string;
761
-
762
- /**
763
- * The name of the current app, for example `Drafts`.
764
- */
765
- appName: string;
766
-
767
- /**
768
- * The bundle identitifier of the current app, for example `com.agiletortoise.Drafts-OSX`.
769
- */
770
- appIdentifier: string;
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
- readonly [identifier: string]: string | boolean;
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
- * The stored value that was returned from the `auth()` function.
787
- */
788
- authsecret: string;
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
- * The state of the modifier keys when the action was invoked in PopClip.
798
- *
799
- * During the execution of the population function, all the modifiers will read as false.
800
- */
801
- readonly modifiers: Modifiers;
802
-
803
- /**
804
- * The current selection.
805
- */
806
- readonly input: Input;
807
-
808
- /**
809
- * The current context.
810
- */
811
- readonly context: Context;
812
-
813
- /**
814
- * The current values of the options.
815
- */
816
- readonly options: Options & AuthOptions;
817
-
818
- /**
819
- * If the target app's Paste command is available, this method places the given string on the pasteboard
820
- * and then invokes the target app's Paste comand. If the `restore` flag is set in the options, it will
821
- * then restore the original pasteboard contents.
822
- *
823
- * If the target app's Paste command is not available, it behaves as {@link copyText} instead.
824
- *
825
- * @example
826
- *
827
- * ```js
828
- * // place "Hello" on the clipboard and invoke Paste
829
- * popclip.pasteText("Hello");
830
- * // place "Hello", then restore the original pasteboard contents
831
- * popclip.pasteText("Hello", {restore: true});
832
- * ```
833
- * @param text The plain text string to paste
834
- * @param options
835
- */
836
- pasteText(text: string, options?: PasteOptions): void;
837
-
838
- /**
839
- * Paste mixed pasteboard content.
840
- */
841
- pasteContent(content: PasteboardContent, options?: PasteOptions): void;
842
-
843
- /**
844
- * Place the given string on the pasteboard, optionally showing "Copied" notification to the user.
845
- * @param text The plain text string to copy
846
- */
847
- copyText(text: string, options?: CopyOptions): void;
848
-
849
- /**
850
- * Place mixed content on the pasteboard, optionally showing "Copied" notification to the user.
851
- */
852
- copyContent(content: PasteboardContent, options?: CopyOptions): void;
853
-
854
- /**
855
- * Invokes a command in the target app.
856
- * @param command Either `cut`, `copy` or `paste`.
857
- * @param options Options for the command.
858
- */
859
- performCommand(
860
- command: "cut" | "copy" | "paste",
861
- options?: {
862
- /** Transformation to apply to the pasteboard contents. (Default: `none`)
863
- * - `none`: regular pasteboard operation
864
- * - `plain`: strips away everything but plain text
865
- */
866
- transform?: "none" | "plain";
867
- },
868
- ): void;
869
-
870
- /**
871
- * Display text to the user.
872
- * @param text The text to display.
873
- * @param options Options.
874
- */
875
- showText(
876
- text: string,
877
- options?: {
878
- /**
879
- * Display style:
880
- * - `compact` (default): Show the text inside PopClip's popup. It will be truncated to 160 characters when shown.
881
- * - `large`: Show as "Large Type" in full screen.
882
- */
883
- style?: "compact" | "large";
884
- /**
885
- * Applies to `compact` display mode only. If `true`, and the app's Paste command is available,
886
- * the displayed text will be in a clickable button, which clicked, pastes the full text.
887
- */
888
- preview?: boolean;
889
- },
890
- ): void;
891
-
892
- /**
893
- * PopClip will show a checkmark symbol to indicate success.
894
- */
895
- showSuccess(): void;
896
-
897
- /**
898
- * PopClip will show an "X" symbol to indicate failure.
899
- */
900
- showFailure(): void;
901
-
902
- /**
903
- * PopClip will open the settings UI for this extension.
904
- *
905
- * If the extension has no settings, this method does nothing.
906
- */
907
- showSettings(): void;
908
-
909
- /**
910
- * Trigger PopClip to appear again with the current selection.
911
- */
912
- appear(): void;
913
-
914
- /**
915
- * Simulate a key press by the user.
916
- *
917
- * @examples
918
- *
919
- * ```js
920
- * // press the key combo ⌘B
921
- * popclip.pressKey('command B');
922
- * // press the key combo ⌥⌘H
923
- * popclip.pressKey('option command H');
924
- * // press the return key
925
- * popclip.pressKey('return');
926
- * popclip.pressKey(util.constant.KEY_RETURN); // equivalent
927
- * * // press option and the page down key
928
- * popclip.pressKey('option 0x79');
929
- * popclip.pressKey(0x79, util.constant.MODIFIER_OPTION); // equivalent
930
- * ```
931
- *
932
- * Some key code and modifier constants are available in {@link Util.constant | util.constant}.
933
- *
934
- * @param key The key to press. When this parameter is a string, PopClip will interpret it as in
935
- * [Key Press actions](https://www.popclip.app/dev/key-press-actions).
936
- * When this parameter is a number, PopClip will use that exact key code.
937
- *
938
- * @param modifiers An optional bit mask specifiying additional modifier keys, if any.
939
- */
940
- pressKey(key: string | number, modifiers?: number): void;
941
-
942
- /**
943
- * Open a URL in a browser or other application.
944
- *
945
- * If a target application bundle identifier is specified via the `app` option, PopClip will ask that app to open the URL.
946
- *
947
- * If no target app is specified:
948
- *
949
- * - 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.
950
- * - Otherwise, PopClip asks macOS to open the URL in the default handler for its scheme.
951
- *
952
- * Any parameters etc. in the URL must be appropriately percent-encoded. JavaScript provides the
953
- * [encodeURIComponent()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
954
- * function for this. Alternatively you can use the [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) class,
955
- * which is available as a global in PopClip's JavaScript environment.
956
- *
957
- * @example
958
- * ```js
959
- * // examples using string URLs
960
- * popclip.openUrl("https://xkcd.com"); // open in current/default browser
961
- * popclip.openUrl("https://xkcd.com", {app: "com.brave.Browser"}); // open in Brave browser
962
- *
963
- * // example using URL class
964
- * const mailUrl=new URL("mailto:support@pilotmoon.com");
965
- * mailUrl.searchParams.append("subject", "What's up?");
966
- * popclip.openUrl(mailUrl); // the mailto: link will open in the default mail application
967
- * ```
968
- *
969
- * @param url URL string or a {@link UrlObject} representing the URL to open.
970
- * @param options Options.
971
- */
972
- openUrl(
973
- url: string | UrlObject,
974
- options?: {
975
- /**
976
- * Bundle identifier of the app to open the URL with. For example `"com.google.Chrome"`.
977
- */
978
- app?: string;
979
- /**
980
- * Whether to request that macOS activate the target app. (Default: `true`)
981
- */
982
- activate?: boolean;
983
- /**
984
- * When opening a web URL in a supported browser, whether to open the URL in a background tab. (Default: `false`)
985
- */
986
- backgroundTab?: boolean;
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
- * The list of available sharing services is determined by the user's system configuration.
1005
- *
1006
- * @param serviceName The name of the sharing service to use. Available names can be found by calling {@link util.sharingServicesInfo}.
1007
- * @param items An array of items to share. Each item can be a string, a {@link RichString} object, or a {@link UrlObject}.
1008
- * @throws If the service name is not recognized, or if the service cannot handle the supplied items, an error is thrown.
1009
- */
1010
- share(serviceName: string, items: (string | RichString | UrlObject)[]): void;
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
- * Localize an English string into the current user interface language, if possible.
1019
- * This will work for strings which match an existing string in PopClip's user interface.
1020
- *
1021
- * @param string The string to localize.
1022
- * @return The localized string, or the original string if no localized version was avaiable.
1023
- */
1024
- localize(string: string): string;
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
- localeInfo: {
1030
- localeIdentifier: string;
1031
- regionCode: string;
1032
- languageCode: string;
1033
- decimalSeparator: string;
1034
- groupingSeparator: string;
1035
- currencyCode: string;
1036
- currencySymbol: string;
1037
- };
1038
-
1039
- /**
1040
- * Get information about the current time zone as configured in macOS settings.
1041
- */
1042
- timeZoneInfo: {
1043
- identifier: string;
1044
- abbreviation: string;
1045
- secondsOffset: number;
1046
- daylightSaving: boolean;
1047
- };
1048
-
1049
- /**
1050
- * Get infomation about available sharing services for {@link popclip.share}.
1051
- */
1052
- sharingServicesInfo: string;
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 client identifiers 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
- * Generate a RFC 4122 version 4 UUID using a cryptographically secure random number generator.
1134
- * @returns UUID string such as "e621e1f8-c36c-495a-93fc-0c247a3e6e5f".
1135
- */
1136
- randomUuid(): string;
1137
-
1138
- /**
1139
- * Generate hash-based message authentication code (HMAC) using the supplied data, key and algorithm.
1140
- * Implemented internally by Apple's CommonCrypto.
1141
- */
1142
- hmac(
1143
- data: Uint8Array,
1144
- key: Uint8Array,
1145
- algorithm: "sha1" | "md5" | "sha256" | "sha384" | "sha512" | "sha224",
1146
- ): Uint8Array;
1147
-
1148
- /**
1149
- * The `constant` property is a container for pre-defined constants.
1150
- */
1151
- readonly constant: {
1152
- /**
1153
- * Bit mask for the Shift (⇧) key.
1154
- */
1155
- readonly MODIFIER_SHIFT: 131072;
1156
- /**
1157
- * Bit mask for the Control (⌃) key.
1158
- */
1159
- readonly MODIFIER_CONTROL: 262144;
1160
- /**
1161
- * Bit mask for the Option (⌥) key.
1162
- */
1163
- readonly MODIFIER_OPTION: 524288;
1164
- /**
1165
- * Bit mask for the Command (⌘) key.
1166
- */
1167
- readonly MODIFIER_COMMAND: 1048576;
1168
- /**
1169
- * Key code for the Return (↵) key.
1170
- */
1171
- readonly KEY_RETURN: 0x24;
1172
- /**
1173
- * Key code for the Tab (⇥) key.
1174
- */
1175
- readonly KEY_TAB: 0x30;
1176
- /**
1177
- * Key code for the space bar.
1178
- */
1179
- readonly KEY_SPACE: 0x31;
1180
- /**
1181
- * Key code for the Delete (⌫) key.
1182
- */
1183
- readonly KEY_DELETE: 0x33;
1184
- /**
1185
- * Key code for the Escape key.
1186
- */
1187
- readonly KEY_ESCAPE: 0x35;
1188
- /**
1189
- * Key code for the Left Arrow key.
1190
- */
1191
- readonly KEY_LEFTARROW: 0x7b;
1192
- /**
1193
- * Key code for the Right Arrow key.
1194
- */
1195
- readonly KEY_RIGHTARROW: 0x7c;
1196
- /**
1197
- * Key code for the Down Arrow key.
1198
- */
1199
- readonly KEY_DOWNARROW: 0x7d;
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
- * The UTF-8 plain text content of the pasteboard.
1213
- */
1214
- "public.utf8-plain-text"?: string;
1215
- /**
1216
- * The HTML content of the pasteboard.
1217
- */
1218
- "public.html"?: string;
1219
- /**
1220
- * The RTF content of the pasteboard.
1221
- */
1222
- "public.rtf"?: string;
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
- * Whether to restore the original contents of the pasteboard after the paste
1231
- * operation. Default is `false`.
1232
- */
1233
- restore?: boolean;
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
- * Whether to show the "Copied" notification to the user. (Default: `true`)
1242
- */
1243
- notify?: boolean;
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
- * Get and set the plain text content of the pasteboard.
1252
- *
1253
- * This property corresponds with the pasteboard type `public.utf8-plain-text`.
1254
- *
1255
- * When placing text on the pasteboard this way, PopClip's "Copied" notification will not appear.
1256
- * (Typically, scripts should use {@link PopClip.copyText} instead, so that the user gets the "Copied" notification.)
1257
- *
1258
- * The value of this property will always be a string. If there is no plain text value on the
1259
- * pasteboard, reading this property will give an empty string (`""`).
1260
- *
1261
- * @example
1262
- * ```js
1263
- * let x = pasteboard.text;
1264
- * pasteboard.text = "new text";
1265
- * ```
1266
- */
1267
- text: string;
1268
-
1269
- /**
1270
- * Get and set the content of the pasteboard, of the specified types
1271
- */
1272
- content: PasteboardContent;
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
- * String to be used as-is.
1305
- */
1306
- url: string;
1307
- }
1308
- | {
1309
- /**
1310
- * String in which PopClip will replace `+` characters with `%20` before use.
1311
- */
1312
- href: string;
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
- * Create a new RichString object from a string.
1330
- *
1331
- * @param source The string to convert to a RichString object.
1332
- * @param options Options for the conversion.
1333
- */
1334
- constructor(
1335
- source: string,
1336
- options?: {
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
- format?: "rtf" | "html" | "markdown";
1341
- },
1342
- );
1343
- /**
1344
- * An RTF representation of the content.
1345
- */
1346
- readonly rtf: string;
1347
- /**
1348
- * An HTML representation of the content.
1349
- */
1350
- readonly html: string;
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
- extension: Extension<CustomOptions>,
1410
+ extension: Extension<CustomOptions>,
1403
1411
  ): void;