@popclip/types 1.4586.1 → 1.4586.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.
- package/package.json +1 -1
- package/popclip.d.ts +130 -94
package/package.json
CHANGED
package/popclip.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ This is a TypeScript definitions file for PopClip's JavaScript interface.
|
|
|
5
5
|
/**
|
|
6
6
|
* An object giving strings for the different languages PopClip supports. See {@link LocalizableString}.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
interface StringTable {
|
|
9
9
|
/** English (US) language string. */
|
|
10
10
|
en: string;
|
|
11
11
|
/** English (UK) language string. */
|
|
@@ -62,14 +62,14 @@ declare interface StringTable {
|
|
|
62
62
|
* option.label = { en: "Color", "en-GB": "Colour", fr: "Couleur", "zh-Hans": "颜色" }
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
type LocalizableString = string | StringTable;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Represents the state of the four modifier keys. The value is true when the key is held down
|
|
69
69
|
* at the time the action is invoked.
|
|
70
70
|
* See {@link PopClip.modifiers}.
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
interface Modifiers {
|
|
73
73
|
/** Shift (⇧) key state. */
|
|
74
74
|
shift: boolean;
|
|
75
75
|
/** Control (⌃) key state. */
|
|
@@ -88,7 +88,7 @@ declare interface Modifiers {
|
|
|
88
88
|
* ["paste", "!urls", "option-goFishing=1"]
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
type Requirement =
|
|
92
92
|
| "text"
|
|
93
93
|
| "cut"
|
|
94
94
|
| "paste"
|
|
@@ -101,17 +101,17 @@ declare type Requirement =
|
|
|
101
101
|
| `option-${string}=${string}`;
|
|
102
102
|
|
|
103
103
|
/** Negated form of {@link Requirement}. */
|
|
104
|
-
|
|
104
|
+
type NegatedRequirement = `!${Requirement}`;
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Strings which can be used to specify the {@link Action.before} action.
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
type BeforeStep = "cut" | "copy" | "paste" | "paste-plain";
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Strings which can be used to specify the {@link Action.after} action.
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
type AfterStep =
|
|
115
115
|
| BeforeStep
|
|
116
116
|
| "popclip-appear"
|
|
117
117
|
| "show-status"
|
|
@@ -123,7 +123,7 @@ declare type AfterStep =
|
|
|
123
123
|
/**
|
|
124
124
|
* Declares information about an app or website that this extension interacts with.
|
|
125
125
|
*/
|
|
126
|
-
|
|
126
|
+
interface AssociatedApp {
|
|
127
127
|
/**
|
|
128
128
|
* Name of the app. For example "Scrivener"
|
|
129
129
|
*/
|
|
@@ -152,7 +152,7 @@ declare interface AssociatedApp {
|
|
|
152
152
|
* @param context Information about the context surrounding the selection. (Same object as {@link PopClip.context}.)
|
|
153
153
|
* @returns A single action, an array of actions.
|
|
154
154
|
*/
|
|
155
|
-
|
|
155
|
+
type PopulationFunction<CustomOptions extends Options = Options> = (
|
|
156
156
|
input: Input,
|
|
157
157
|
options: CustomOptions,
|
|
158
158
|
context: Context,
|
|
@@ -161,7 +161,7 @@ declare type PopulationFunction<CustomOptions extends Options = Options> = (
|
|
|
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
165
|
url: string,
|
|
166
166
|
params?: { [key: string]: string | undefined },
|
|
167
167
|
expect?: string[],
|
|
@@ -170,7 +170,7 @@ declare type AuthFlowFunction = (
|
|
|
170
170
|
/**
|
|
171
171
|
* Credentials used in auth function
|
|
172
172
|
* */
|
|
173
|
-
|
|
173
|
+
interface AuthInfo {
|
|
174
174
|
/** Value of `username` option (will be empty string if none defined) */
|
|
175
175
|
username: string;
|
|
176
176
|
/** Value of `password` option (will be empty string if none defined) */
|
|
@@ -189,15 +189,12 @@ declare interface AuthInfo {
|
|
|
189
189
|
/**
|
|
190
190
|
* Function signature of the {@link Extension.auth} method.
|
|
191
191
|
*/
|
|
192
|
-
|
|
193
|
-
info: AuthInfo,
|
|
194
|
-
flow: AuthFlowFunction,
|
|
195
|
-
) => Promise<string>;
|
|
192
|
+
type AuthFunction = (info: AuthInfo, flow: AuthFlowFunction) => Promise<string>;
|
|
196
193
|
|
|
197
194
|
/**
|
|
198
195
|
* Properties that define how an icon is interpreted.
|
|
199
196
|
*/
|
|
200
|
-
|
|
197
|
+
interface IconProperties {
|
|
201
198
|
/**
|
|
202
199
|
* If true, the supplied icon will be displayed with its original color instead of being filled in white/black. Default is false.
|
|
203
200
|
*/
|
|
@@ -269,7 +266,7 @@ declare interface IconProperties {
|
|
|
269
266
|
/**
|
|
270
267
|
* Properties common to Action and Extension
|
|
271
268
|
*/
|
|
272
|
-
|
|
269
|
+
interface ActionProperties extends IconProperties {
|
|
273
270
|
/**
|
|
274
271
|
* A unique identifying string. An identifier for an action can be any string of your choosing.
|
|
275
272
|
*/
|
|
@@ -416,7 +413,7 @@ declare interface ActionProperties extends IconProperties {
|
|
|
416
413
|
* @param options Current values of the options for this extension. (Same object as {@link PopClip.options}.)
|
|
417
414
|
* @param context Information about the context surrounding the selection. (Same object as {@link PopClip.context}.)
|
|
418
415
|
*/
|
|
419
|
-
|
|
416
|
+
type ActionFunction<CustomOptions extends Options = Options> = (
|
|
420
417
|
input: Input,
|
|
421
418
|
options: CustomOptions & AuthOptions,
|
|
422
419
|
context: Context,
|
|
@@ -426,18 +423,18 @@ declare type ActionFunction<CustomOptions extends Options = Options> = (
|
|
|
426
423
|
* **Action** represents the properties of a single action.
|
|
427
424
|
* If `code` is omitted, the action displays a disabled title/icon only.
|
|
428
425
|
*/
|
|
429
|
-
|
|
426
|
+
interface Action<CustomOptions extends Options = Options>
|
|
430
427
|
extends ActionProperties {
|
|
431
428
|
code?: ActionFunction<CustomOptions>;
|
|
432
429
|
}
|
|
433
430
|
|
|
434
431
|
// included for JSON Schema
|
|
435
|
-
|
|
432
|
+
type Entitlement = "network" | "dynamic";
|
|
436
433
|
|
|
437
434
|
/**
|
|
438
435
|
* The Extension object defines the PopClip extension.
|
|
439
436
|
*/
|
|
440
|
-
|
|
437
|
+
interface Extension<CustomOptions extends Options = Options>
|
|
441
438
|
extends ActionProperties {
|
|
442
439
|
/**
|
|
443
440
|
* The display name of this extension.
|
|
@@ -483,10 +480,18 @@ declare interface Extension<CustomOptions extends Options = Options>
|
|
|
483
480
|
module?: string;
|
|
484
481
|
}
|
|
485
482
|
|
|
483
|
+
type OptionType =
|
|
484
|
+
| "string"
|
|
485
|
+
| "boolean"
|
|
486
|
+
| "multiple"
|
|
487
|
+
| "password"
|
|
488
|
+
| "heading"
|
|
489
|
+
| "secret";
|
|
490
|
+
|
|
486
491
|
/**
|
|
487
492
|
* Defines a single extension option.
|
|
488
493
|
*/
|
|
489
|
-
|
|
494
|
+
interface OptionBase {
|
|
490
495
|
/**
|
|
491
496
|
* An identifying string for this option.
|
|
492
497
|
*/
|
|
@@ -501,7 +506,7 @@ declare interface Option {
|
|
|
501
506
|
* * `password`: concealed text entry field (not persisted, only passed to auth function),
|
|
502
507
|
* * `heading`: adds a heading in the user interface, but does not actually define an option
|
|
503
508
|
*/
|
|
504
|
-
type:
|
|
509
|
+
type: OptionType;
|
|
505
510
|
|
|
506
511
|
/**
|
|
507
512
|
* A short label for this option.
|
|
@@ -513,10 +518,29 @@ declare interface Option {
|
|
|
513
518
|
*/
|
|
514
519
|
description?: LocalizableString;
|
|
515
520
|
|
|
521
|
+
/*
|
|
522
|
+
* If true, this option will be hidden in the prefs window. Default is false.
|
|
523
|
+
*/
|
|
524
|
+
hidden?: boolean;
|
|
525
|
+
|
|
526
|
+
/*
|
|
527
|
+
* If true, this option will be be inset to the right of its label, instead of below it. Default is false.
|
|
528
|
+
*/
|
|
529
|
+
inset?: boolean;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
interface StringOption extends OptionBase {
|
|
533
|
+
type: "string";
|
|
534
|
+
/**
|
|
535
|
+
* The default value of the option. If omitted, `string` options default to the empty string.
|
|
536
|
+
*/
|
|
537
|
+
defaultValue?: string;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
interface MultipleOption extends OptionBase {
|
|
541
|
+
type: "multiple";
|
|
516
542
|
/**
|
|
517
|
-
* The default value of the option. If
|
|
518
|
-
* `boolean` options default to true, and `multiple` options default to the top item in the list.
|
|
519
|
-
* A `password` field may not have a default value.
|
|
543
|
+
* The default value of the option. If omitted, `multiple` options default to the top item in the list.
|
|
520
544
|
*/
|
|
521
545
|
defaultValue?: string | boolean;
|
|
522
546
|
|
|
@@ -530,27 +554,39 @@ declare interface Option {
|
|
|
530
554
|
* If ommitted, the raw value strings are shown instead.
|
|
531
555
|
*/
|
|
532
556
|
valueLabels?: LocalizableString[];
|
|
557
|
+
}
|
|
533
558
|
|
|
559
|
+
interface BooleanOption extends OptionBase {
|
|
560
|
+
type: "boolean";
|
|
561
|
+
/**
|
|
562
|
+
* The default value of the option. If omitted, `boolean` options default to true.
|
|
563
|
+
*/
|
|
564
|
+
defaultValue?: boolean;
|
|
534
565
|
/**
|
|
535
566
|
* An icon for this option. It is only displayed for boolean options, next to the check box.
|
|
536
567
|
*/
|
|
537
568
|
icon?: string;
|
|
569
|
+
}
|
|
538
570
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
hidden?: boolean;
|
|
571
|
+
interface PasswordOption extends OptionBase {
|
|
572
|
+
type: "password" | "secret";
|
|
573
|
+
}
|
|
543
574
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
*/
|
|
547
|
-
inset?: boolean;
|
|
575
|
+
interface HeadingOption extends OptionBase {
|
|
576
|
+
type: "heading";
|
|
548
577
|
}
|
|
549
578
|
|
|
579
|
+
type Option =
|
|
580
|
+
| StringOption
|
|
581
|
+
| MultipleOption
|
|
582
|
+
| BooleanOption
|
|
583
|
+
| PasswordOption
|
|
584
|
+
| HeadingOption;
|
|
585
|
+
|
|
550
586
|
/**
|
|
551
587
|
* Represents a generic range, as a location and length
|
|
552
588
|
*/
|
|
553
|
-
|
|
589
|
+
interface Range {
|
|
554
590
|
location: number;
|
|
555
591
|
length: number;
|
|
556
592
|
}
|
|
@@ -558,14 +594,14 @@ declare interface Range {
|
|
|
558
594
|
/**
|
|
559
595
|
* An array of strings with an addiontal `ranges` property defining the source of the data in the orignal string.
|
|
560
596
|
*/
|
|
561
|
-
|
|
597
|
+
interface RangedStrings extends Array<string> {
|
|
562
598
|
ranges: Range[];
|
|
563
599
|
}
|
|
564
600
|
|
|
565
601
|
/**
|
|
566
602
|
* Input defines properties to access the input text contents.
|
|
567
603
|
*/
|
|
568
|
-
|
|
604
|
+
interface Input {
|
|
569
605
|
/**
|
|
570
606
|
* The plain text selected by the user. If there is no selected text, this will be the empty string.
|
|
571
607
|
*/
|
|
@@ -654,7 +690,7 @@ declare interface Input {
|
|
|
654
690
|
/**
|
|
655
691
|
* Properties relating the context surrounding the selected text.
|
|
656
692
|
*/
|
|
657
|
-
|
|
693
|
+
interface Context {
|
|
658
694
|
/**
|
|
659
695
|
* Indicates whether the text area supports formatting.
|
|
660
696
|
*/
|
|
@@ -699,7 +735,7 @@ declare interface Context {
|
|
|
699
735
|
/**
|
|
700
736
|
* Represents the current values of the extension's settings.
|
|
701
737
|
*/
|
|
702
|
-
|
|
738
|
+
interface Options {
|
|
703
739
|
readonly [identifier: string]: string | boolean;
|
|
704
740
|
}
|
|
705
741
|
|
|
@@ -707,7 +743,7 @@ declare interface Options {
|
|
|
707
743
|
* The `authsecret` property has the special behaviour of throwing an `Error` with the message 'Not signed in' if it is accessed while either
|
|
708
744
|
* undefined or holding an empty string.
|
|
709
745
|
*/
|
|
710
|
-
|
|
746
|
+
interface AuthOptions {
|
|
711
747
|
/**
|
|
712
748
|
* The stored value that was returned from the `auth()` function.
|
|
713
749
|
*/
|
|
@@ -718,7 +754,7 @@ declare interface AuthOptions {
|
|
|
718
754
|
* This interface describes the methods and properties of the global {@link popclip} object.
|
|
719
755
|
*
|
|
720
756
|
*/
|
|
721
|
-
|
|
757
|
+
interface PopClip {
|
|
722
758
|
/**
|
|
723
759
|
* The state of the modifier keys when the action was invoked in PopClip.
|
|
724
760
|
*
|
|
@@ -930,54 +966,10 @@ declare interface PopClip {
|
|
|
930
966
|
) => void;
|
|
931
967
|
}
|
|
932
968
|
|
|
933
|
-
/**
|
|
934
|
-
* The global `popclip` object encapsulates the user's current interaction with PopClip, and provides methods
|
|
935
|
-
* for performing various actions. It implements {@link PopClip}.
|
|
936
|
-
*/
|
|
937
|
-
declare const popclip: PopClip;
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* Represents a formatted text string. The underlying implementation uses a macOS Attributed String (`NSAttributedString`) object.
|
|
941
|
-
* Can be constructed from a plain string in RTF, HTML, or Markdown format.
|
|
942
|
-
*
|
|
943
|
-
* #### Example
|
|
944
|
-
* ```js
|
|
945
|
-
* // create a RichString object from a html string
|
|
946
|
-
* const item = new RichString("<b>bold</b> and <i>italic</i>.", {format: 'html'});
|
|
947
|
-
* // create a RichString object from a markdown string
|
|
948
|
-
* const item = new RichString("# Title\n\nBody.", {format: 'markdown'});
|
|
949
|
-
* ```
|
|
950
|
-
*/
|
|
951
|
-
declare class RichString {
|
|
952
|
-
/**
|
|
953
|
-
* Create a new RichString object from a string.
|
|
954
|
-
*
|
|
955
|
-
* @param source The string to convert to a RichString object.
|
|
956
|
-
* @param options Options for the conversion.
|
|
957
|
-
*/
|
|
958
|
-
constructor(
|
|
959
|
-
source: string,
|
|
960
|
-
options?: {
|
|
961
|
-
/**
|
|
962
|
-
Format of the source string. Default is 'rtf'.
|
|
963
|
-
*/
|
|
964
|
-
format?: "rtf" | "html" | "markdown";
|
|
965
|
-
},
|
|
966
|
-
);
|
|
967
|
-
/**
|
|
968
|
-
* An RTF representation of the content.
|
|
969
|
-
*/
|
|
970
|
-
readonly rtf: string;
|
|
971
|
-
/**
|
|
972
|
-
* An HTML representation of the content.
|
|
973
|
-
*/
|
|
974
|
-
readonly html: string;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
969
|
/**
|
|
978
970
|
* A container for various utility functions and constants {@link util} object.
|
|
979
971
|
*/
|
|
980
|
-
|
|
972
|
+
interface Util {
|
|
981
973
|
/**
|
|
982
974
|
* Localize an English string into the current user interface language, if possible.
|
|
983
975
|
* This will work for strings which match an existing string in PopClip's user interface.
|
|
@@ -1114,15 +1106,10 @@ declare interface Util {
|
|
|
1114
1106
|
};
|
|
1115
1107
|
}
|
|
1116
1108
|
|
|
1117
|
-
/**
|
|
1118
|
-
* The global `util` object acts as a container for various utility functions and constants. It implements {@link Util}.
|
|
1119
|
-
*/
|
|
1120
|
-
declare const util: Util;
|
|
1121
|
-
|
|
1122
1109
|
/**
|
|
1123
1110
|
* Represents the raw pasteboard content, indexed by UTI. Supports string data only.
|
|
1124
1111
|
*/
|
|
1125
|
-
|
|
1112
|
+
interface PasteboardContent {
|
|
1126
1113
|
"public.utf8-plain-text"?: string;
|
|
1127
1114
|
"public.html"?: string;
|
|
1128
1115
|
"public.rtf"?: string;
|
|
@@ -1132,7 +1119,7 @@ declare interface PasteboardContent {
|
|
|
1132
1119
|
/**
|
|
1133
1120
|
* Options for Paste operations.
|
|
1134
1121
|
*/
|
|
1135
|
-
|
|
1122
|
+
interface PasteOptions {
|
|
1136
1123
|
/**
|
|
1137
1124
|
* Whether to restore the original contents of the pasteboard after the paste
|
|
1138
1125
|
* operation. Default is `false`.
|
|
@@ -1143,7 +1130,7 @@ declare interface PasteOptions {
|
|
|
1143
1130
|
/**
|
|
1144
1131
|
* A simplified interface to the macOS pasteboard. Implemented by the global object, {@link pasteboard}.
|
|
1145
1132
|
*/
|
|
1146
|
-
|
|
1133
|
+
interface Pasteboard {
|
|
1147
1134
|
/**
|
|
1148
1135
|
* Get and set the plain text content of the pasteboard.
|
|
1149
1136
|
*
|
|
@@ -1170,6 +1157,55 @@ declare interface Pasteboard {
|
|
|
1170
1157
|
content: PasteboardContent;
|
|
1171
1158
|
}
|
|
1172
1159
|
|
|
1160
|
+
/**
|
|
1161
|
+
* The global `popclip` object encapsulates the user's current interaction with PopClip, and provides methods
|
|
1162
|
+
* for performing various actions. It implements {@link PopClip}.
|
|
1163
|
+
*/
|
|
1164
|
+
declare const popclip: PopClip;
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Represents a formatted text string. The underlying implementation uses a macOS Attributed String (`NSAttributedString`) object.
|
|
1168
|
+
* Can be constructed from a plain string in RTF, HTML, or Markdown format.
|
|
1169
|
+
*
|
|
1170
|
+
* #### Example
|
|
1171
|
+
* ```js
|
|
1172
|
+
* // create a RichString object from a html string
|
|
1173
|
+
* const item = new RichString("<b>bold</b> and <i>italic</i>.", {format: 'html'});
|
|
1174
|
+
* // create a RichString object from a markdown string
|
|
1175
|
+
* const item = new RichString("# Title\n\nBody.", {format: 'markdown'});
|
|
1176
|
+
* ```
|
|
1177
|
+
*/
|
|
1178
|
+
declare class RichString {
|
|
1179
|
+
/**
|
|
1180
|
+
* Create a new RichString object from a string.
|
|
1181
|
+
*
|
|
1182
|
+
* @param source The string to convert to a RichString object.
|
|
1183
|
+
* @param options Options for the conversion.
|
|
1184
|
+
*/
|
|
1185
|
+
constructor(
|
|
1186
|
+
source: string,
|
|
1187
|
+
options?: {
|
|
1188
|
+
/**
|
|
1189
|
+
Format of the source string. Default is 'rtf'.
|
|
1190
|
+
*/
|
|
1191
|
+
format?: "rtf" | "html" | "markdown";
|
|
1192
|
+
},
|
|
1193
|
+
);
|
|
1194
|
+
/**
|
|
1195
|
+
* An RTF representation of the content.
|
|
1196
|
+
*/
|
|
1197
|
+
readonly rtf: string;
|
|
1198
|
+
/**
|
|
1199
|
+
* An HTML representation of the content.
|
|
1200
|
+
*/
|
|
1201
|
+
readonly html: string;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* The global `util` object acts as a container for various utility functions and constants. It implements {@link Util}.
|
|
1206
|
+
*/
|
|
1207
|
+
declare const util: Util;
|
|
1208
|
+
|
|
1173
1209
|
/**
|
|
1174
1210
|
* The global `pasteboard` object provides access to the contents of the macOS general pasteboard (i.e. the system clipboard). It implements {@link Pasteboard}.
|
|
1175
1211
|
*/
|