@popclip/types 1.4586.1 → 1.4604.1

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 +142 -102
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popclip/types",
3
- "version": "1.4586.1",
3
+ "version": "1.4604.1",
4
4
  "devDependencies": {
5
5
  "typedoc": "0.25.13",
6
6
  "typescript": "5.4.5"
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
- declare interface StringTable {
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
- declare type LocalizableString = string | StringTable;
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
- declare interface Modifiers {
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
- declare type Requirement =
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
- declare type NegatedRequirement = `!${Requirement}`;
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
- declare type BeforeStep = "cut" | "copy" | "paste" | "paste-plain";
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
- declare type AfterStep =
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
- declare interface AssociatedApp {
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
- declare type PopulationFunction<CustomOptions extends Options = Options> = (
155
+ type PopulationFunction<CustomOptions = 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
- declare type AuthFlowFunction = (
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
- declare interface AuthInfo {
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
- declare type AuthFunction = (
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
- declare interface IconProperties {
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
- declare interface ActionProperties extends IconProperties {
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
- declare type ActionFunction<CustomOptions extends Options = Options> = (
416
+ type ActionFunction<CustomOptions = Options> = (
420
417
  input: Input,
421
418
  options: CustomOptions & AuthOptions,
422
419
  context: Context,
@@ -426,18 +423,17 @@ 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
- declare interface Action<CustomOptions extends Options = Options>
430
- extends ActionProperties {
426
+ interface Action<CustomOptions = Options> extends ActionProperties {
431
427
  code?: ActionFunction<CustomOptions>;
432
428
  }
433
429
 
434
430
  // included for JSON Schema
435
- declare type Entitlement = "network" | "dynamic";
431
+ type Entitlement = "network" | "dynamic";
436
432
 
437
433
  /**
438
434
  * The Extension object defines the PopClip extension.
439
435
  */
440
- declare interface Extension<CustomOptions extends Options = Options>
436
+ interface Extension<CustomOptions extends Options = Options>
441
437
  extends ActionProperties {
442
438
  /**
443
439
  * The display name of this extension.
@@ -483,10 +479,18 @@ declare interface Extension<CustomOptions extends Options = Options>
483
479
  module?: string;
484
480
  }
485
481
 
482
+ type OptionType =
483
+ | "string"
484
+ | "boolean"
485
+ | "multiple"
486
+ | "password"
487
+ | "heading"
488
+ | "secret";
489
+
486
490
  /**
487
491
  * Defines a single extension option.
488
492
  */
489
- declare interface Option {
493
+ interface OptionBase {
490
494
  /**
491
495
  * An identifying string for this option.
492
496
  */
@@ -501,7 +505,7 @@ declare interface Option {
501
505
  * * `password`: concealed text entry field (not persisted, only passed to auth function),
502
506
  * * `heading`: adds a heading in the user interface, but does not actually define an option
503
507
  */
504
- type: "string" | "boolean" | "multiple" | "password" | "heading" | "secret";
508
+ type: OptionType;
505
509
 
506
510
  /**
507
511
  * A short label for this option.
@@ -513,10 +517,29 @@ declare interface Option {
513
517
  */
514
518
  description?: LocalizableString;
515
519
 
520
+ /*
521
+ * If true, this option will be hidden in the prefs window. Default is false.
522
+ */
523
+ hidden?: boolean;
524
+
525
+ /*
526
+ * If true, this option will be be inset to the right of its label, instead of below it. Default is false.
527
+ */
528
+ inset?: boolean;
529
+ }
530
+
531
+ interface StringOption extends OptionBase {
532
+ type: "string";
533
+ /**
534
+ * The default value of the option. If omitted, `string` options default to the empty string.
535
+ */
536
+ defaultValue?: string;
537
+ }
538
+
539
+ interface MultipleOption extends OptionBase {
540
+ type: "multiple";
516
541
  /**
517
- * The default value of the option. If ommitted, `string` options default to the empty string,
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.
542
+ * The default value of the option. If omitted, `multiple` options default to the top item in the list.
520
543
  */
521
544
  defaultValue?: string | boolean;
522
545
 
@@ -530,27 +553,39 @@ declare interface Option {
530
553
  * If ommitted, the raw value strings are shown instead.
531
554
  */
532
555
  valueLabels?: LocalizableString[];
556
+ }
533
557
 
558
+ interface BooleanOption extends OptionBase {
559
+ type: "boolean";
560
+ /**
561
+ * The default value of the option. If omitted, `boolean` options default to true.
562
+ */
563
+ defaultValue?: boolean;
534
564
  /**
535
565
  * An icon for this option. It is only displayed for boolean options, next to the check box.
536
566
  */
537
567
  icon?: string;
568
+ }
538
569
 
539
- /*
540
- * If true, this option will be hidden in the prefs window. Default is false.
541
- */
542
- hidden?: boolean;
570
+ interface PasswordOption extends OptionBase {
571
+ type: "password" | "secret";
572
+ }
543
573
 
544
- /*
545
- * If true, this option will be be inset to the right of its label, instead of below it. Default is false.
546
- */
547
- inset?: boolean;
574
+ interface HeadingOption extends OptionBase {
575
+ type: "heading";
548
576
  }
549
577
 
578
+ type Option =
579
+ | StringOption
580
+ | MultipleOption
581
+ | BooleanOption
582
+ | PasswordOption
583
+ | HeadingOption;
584
+
550
585
  /**
551
586
  * Represents a generic range, as a location and length
552
587
  */
553
- declare interface Range {
588
+ interface Range {
554
589
  location: number;
555
590
  length: number;
556
591
  }
@@ -558,14 +593,14 @@ declare interface Range {
558
593
  /**
559
594
  * An array of strings with an addiontal `ranges` property defining the source of the data in the orignal string.
560
595
  */
561
- declare interface RangedStrings extends Array<string> {
596
+ interface RangedStrings extends Array<string> {
562
597
  ranges: Range[];
563
598
  }
564
599
 
565
600
  /**
566
601
  * Input defines properties to access the input text contents.
567
602
  */
568
- declare interface Input {
603
+ interface Input {
569
604
  /**
570
605
  * The plain text selected by the user. If there is no selected text, this will be the empty string.
571
606
  */
@@ -654,7 +689,7 @@ declare interface Input {
654
689
  /**
655
690
  * Properties relating the context surrounding the selected text.
656
691
  */
657
- declare interface Context {
692
+ interface Context {
658
693
  /**
659
694
  * Indicates whether the text area supports formatting.
660
695
  */
@@ -699,7 +734,7 @@ declare interface Context {
699
734
  /**
700
735
  * Represents the current values of the extension's settings.
701
736
  */
702
- declare interface Options {
737
+ interface Options {
703
738
  readonly [identifier: string]: string | boolean;
704
739
  }
705
740
 
@@ -707,7 +742,7 @@ declare interface Options {
707
742
  * The `authsecret` property has the special behaviour of throwing an `Error` with the message 'Not signed in' if it is accessed while either
708
743
  * undefined or holding an empty string.
709
744
  */
710
- declare interface AuthOptions {
745
+ interface AuthOptions {
711
746
  /**
712
747
  * The stored value that was returned from the `auth()` function.
713
748
  */
@@ -718,7 +753,7 @@ declare interface AuthOptions {
718
753
  * This interface describes the methods and properties of the global {@link popclip} object.
719
754
  *
720
755
  */
721
- declare interface PopClip {
756
+ interface PopClip {
722
757
  /**
723
758
  * The state of the modifier keys when the action was invoked in PopClip.
724
759
  *
@@ -795,17 +830,22 @@ declare interface PopClip {
795
830
  ) => void;
796
831
 
797
832
  /**
798
- * Display text inside PopClip's popup, with option to make the display a clickable button to
799
- * paste the text.
800
- * @param text The text to display. It will be truncated to 160 characters when shown.
801
- * @param options
833
+ * Display text to the user.
834
+ * @param text The text to display.
835
+ * @param options Options.
802
836
  */
803
837
  showText: (
804
838
  text: string,
805
839
  options?: {
806
840
  /**
807
- * If `true`, and the app's Paste command is available, the displayed text will be in a cickable button,
808
- * which clicked, pastes the full text.
841
+ * Display style:
842
+ * - `compact` (default): Show the text inside PopClip's popup. It will be truncated to 160 characters when shown.
843
+ * - `large`: Show as "Large Type" in full screen.
844
+ */
845
+ style?: "compact" | "large";
846
+ /**
847
+ * Applies to `compact` display mode only. If `true`, and the app's Paste command is available,
848
+ * the displayed text will be in a clickable button, which clicked, pastes the full text.
809
849
  */
810
850
  preview?: boolean;
811
851
  },
@@ -930,54 +970,10 @@ declare interface PopClip {
930
970
  ) => void;
931
971
  }
932
972
 
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
973
  /**
978
974
  * A container for various utility functions and constants {@link util} object.
979
975
  */
980
- declare interface Util {
976
+ interface Util {
981
977
  /**
982
978
  * Localize an English string into the current user interface language, if possible.
983
979
  * This will work for strings which match an existing string in PopClip's user interface.
@@ -1114,15 +1110,10 @@ declare interface Util {
1114
1110
  };
1115
1111
  }
1116
1112
 
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
1113
  /**
1123
1114
  * Represents the raw pasteboard content, indexed by UTI. Supports string data only.
1124
1115
  */
1125
- declare interface PasteboardContent {
1116
+ interface PasteboardContent {
1126
1117
  "public.utf8-plain-text"?: string;
1127
1118
  "public.html"?: string;
1128
1119
  "public.rtf"?: string;
@@ -1132,7 +1123,7 @@ declare interface PasteboardContent {
1132
1123
  /**
1133
1124
  * Options for Paste operations.
1134
1125
  */
1135
- declare interface PasteOptions {
1126
+ interface PasteOptions {
1136
1127
  /**
1137
1128
  * Whether to restore the original contents of the pasteboard after the paste
1138
1129
  * operation. Default is `false`.
@@ -1143,7 +1134,7 @@ declare interface PasteOptions {
1143
1134
  /**
1144
1135
  * A simplified interface to the macOS pasteboard. Implemented by the global object, {@link pasteboard}.
1145
1136
  */
1146
- declare interface Pasteboard {
1137
+ interface Pasteboard {
1147
1138
  /**
1148
1139
  * Get and set the plain text content of the pasteboard.
1149
1140
  *
@@ -1170,6 +1161,55 @@ declare interface Pasteboard {
1170
1161
  content: PasteboardContent;
1171
1162
  }
1172
1163
 
1164
+ /**
1165
+ * The global `popclip` object encapsulates the user's current interaction with PopClip, and provides methods
1166
+ * for performing various actions. It implements {@link PopClip}.
1167
+ */
1168
+ declare const popclip: PopClip;
1169
+
1170
+ /**
1171
+ * Represents a formatted text string. The underlying implementation uses a macOS Attributed String (`NSAttributedString`) object.
1172
+ * Can be constructed from a plain string in RTF, HTML, or Markdown format.
1173
+ *
1174
+ * #### Example
1175
+ * ```js
1176
+ * // create a RichString object from a html string
1177
+ * const item = new RichString("<b>bold</b> and <i>italic</i>.", {format: 'html'});
1178
+ * // create a RichString object from a markdown string
1179
+ * const item = new RichString("# Title\n\nBody.", {format: 'markdown'});
1180
+ * ```
1181
+ */
1182
+ declare class RichString {
1183
+ /**
1184
+ * Create a new RichString object from a string.
1185
+ *
1186
+ * @param source The string to convert to a RichString object.
1187
+ * @param options Options for the conversion.
1188
+ */
1189
+ constructor(
1190
+ source: string,
1191
+ options?: {
1192
+ /**
1193
+ Format of the source string. Default is 'rtf'.
1194
+ */
1195
+ format?: "rtf" | "html" | "markdown";
1196
+ },
1197
+ );
1198
+ /**
1199
+ * An RTF representation of the content.
1200
+ */
1201
+ readonly rtf: string;
1202
+ /**
1203
+ * An HTML representation of the content.
1204
+ */
1205
+ readonly html: string;
1206
+ }
1207
+
1208
+ /**
1209
+ * The global `util` object acts as a container for various utility functions and constants. It implements {@link Util}.
1210
+ */
1211
+ declare const util: Util;
1212
+
1173
1213
  /**
1174
1214
  * The global `pasteboard` object provides access to the contents of the macOS general pasteboard (i.e. the system clipboard). It implements {@link Pasteboard}.
1175
1215
  */
@@ -1213,6 +1253,6 @@ declare function sleep(durationMilliseconds: number): Promise<void>;
1213
1253
  *
1214
1254
  * @param extension The extension object to export.
1215
1255
  */
1216
- declare function defineExtension<CustomOptions extends Options = Options>(
1256
+ declare function defineExtension<CustomOptions = Options>(
1217
1257
  extension: Extension<CustomOptions>,
1218
1258
  ): void;