@popclip/types 1.4892.0 → 1.5793.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/popclip.d.ts +72 -13
package/package.json
CHANGED
package/popclip.d.ts
CHANGED
|
@@ -184,10 +184,29 @@ interface AuthInfo {
|
|
|
184
184
|
identifier: string;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Object form of the value returned by {@link Extension.auth}, for when the extension has
|
|
189
|
+
* more than just the secret to hand back. Returning a bare string is equivalent to
|
|
190
|
+
* returning `{ secret: theString }`.
|
|
191
|
+
*/
|
|
192
|
+
interface AuthResult {
|
|
193
|
+
/** The secret to store (e.g. an access token). Saved as the extension's `authsecret`. */
|
|
194
|
+
secret: string;
|
|
195
|
+
/** Optional account identifier to display, e.g. an email or username ("Signed in as …"). */
|
|
196
|
+
label?: string;
|
|
197
|
+
/** Optional token lifetime in seconds, as reported by the auth server (its `expires_in`).
|
|
198
|
+
* PopClip records it with the sign-in time; once it elapses the app treats the extension
|
|
199
|
+
* as signed out and prompts the user to sign in again. */
|
|
200
|
+
expiresIn?: number;
|
|
201
|
+
}
|
|
202
|
+
|
|
187
203
|
/**
|
|
188
204
|
* Function signature of the {@link Extension.auth} method.
|
|
189
205
|
*/
|
|
190
|
-
type AuthFunction = (
|
|
206
|
+
type AuthFunction = (
|
|
207
|
+
info: AuthInfo,
|
|
208
|
+
flow: AuthFlowFunction,
|
|
209
|
+
) => Promise<string | AuthResult>;
|
|
191
210
|
|
|
192
211
|
/**
|
|
193
212
|
* Properties that define how an icon is interpreted.
|
|
@@ -427,6 +446,20 @@ type TestFunction = () => Promise<void> | void;
|
|
|
427
446
|
*/
|
|
428
447
|
interface Action<CustomOptions = Options> extends ActionProperties {
|
|
429
448
|
readonly code?: ActionFunction<CustomOptions>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* If set, clicking this action opens a submenu containing these child actions.
|
|
452
|
+
*
|
|
453
|
+
* - If it's an array, the supplied actions are used in the submenu.
|
|
454
|
+
* - If it's a population function, it is called when the submenu opens to generate its
|
|
455
|
+
* actions dynamically. A submenu function requires the `dynamic` entitlement.
|
|
456
|
+
*
|
|
457
|
+
* The action's own title and icon label the submenu. If the action also defines `code`,
|
|
458
|
+
* it stays directly clickable in addition to offering the submenu.
|
|
459
|
+
*/
|
|
460
|
+
readonly submenu?:
|
|
461
|
+
| (Action<CustomOptions> | ActionFunction<CustomOptions>)[]
|
|
462
|
+
| PopulationFunction<CustomOptions>;
|
|
430
463
|
}
|
|
431
464
|
|
|
432
465
|
// included for JSON Schema
|
|
@@ -436,15 +469,10 @@ type Entitlement = "network" | "dynamic";
|
|
|
436
469
|
* The Extension object defines the PopClip extension.
|
|
437
470
|
*/
|
|
438
471
|
interface Extension<CustomOptions = Options> extends ActionProperties {
|
|
439
|
-
/**
|
|
440
|
-
* The display name of this extension.
|
|
441
|
-
*/
|
|
442
|
-
name?: LocalizableString;
|
|
443
|
-
|
|
444
472
|
/**
|
|
445
473
|
* Defines the user-configurable options for this extension.
|
|
446
474
|
*/
|
|
447
|
-
options?: Option[];
|
|
475
|
+
options?: readonly Option[];
|
|
448
476
|
|
|
449
477
|
/**
|
|
450
478
|
* If you define this function then PopClip will display a 'sign in' button in the options UI. When the user clicks the button,
|
|
@@ -473,15 +501,29 @@ interface Extension<CustomOptions = Options> extends ActionProperties {
|
|
|
473
501
|
*/
|
|
474
502
|
action?: Action<CustomOptions> | ActionFunction<CustomOptions>;
|
|
475
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Makes the whole extension a single button that opens a submenu of child actions, as an
|
|
506
|
+
* alternative to `actions`/`action`. Same shape as {@link Action.submenu}: a static array
|
|
507
|
+
* of actions, or a population function (requires the `dynamic` entitlement).
|
|
508
|
+
*/
|
|
509
|
+
submenu?:
|
|
510
|
+
| (Action<CustomOptions> | ActionFunction<CustomOptions>)[]
|
|
511
|
+
| PopulationFunction<CustomOptions>;
|
|
512
|
+
|
|
476
513
|
/**
|
|
477
514
|
* Exported test function for use during development.
|
|
478
515
|
*/
|
|
479
516
|
test?: TestFunction;
|
|
480
517
|
|
|
481
|
-
// the following are static properties, included for the benefit of the JSON
|
|
518
|
+
// the following are static-only properties, included for the benefit of the JSON Schema generation
|
|
519
|
+
name?: LocalizableString;
|
|
520
|
+
entitlements?: Entitlement[];
|
|
482
521
|
popclipVersion?: number;
|
|
483
|
-
|
|
484
|
-
|
|
522
|
+
macosVersion?: string;
|
|
523
|
+
showAs?: "icon" | "text" | "both";
|
|
524
|
+
color?: string,
|
|
525
|
+
authAccountLabel?: string,
|
|
526
|
+
offersMultipleInstances?: boolean,
|
|
485
527
|
module?: string;
|
|
486
528
|
}
|
|
487
529
|
|
|
@@ -919,6 +961,26 @@ interface PopClip {
|
|
|
919
961
|
*/
|
|
920
962
|
showSettings(): void;
|
|
921
963
|
|
|
964
|
+
/**
|
|
965
|
+
* Returns an `Error` to **throw** when the stored sign-in credential is no longer valid
|
|
966
|
+
* (for example the server rejected or revoked the token). PopClip clears the saved secret
|
|
967
|
+
* — so the extension appears signed out — and opens the settings UI to sign in again.
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* if (isAuthError(e)) throw popclip.signInRequiredError();
|
|
971
|
+
*
|
|
972
|
+
* @param message Optional message for logs/diagnostics.
|
|
973
|
+
*/
|
|
974
|
+
signInRequiredError(message?: string): Error;
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Returns an `Error` to **throw** to send the user to the settings UI **without** clearing
|
|
978
|
+
* the sign-in (for example a required option is missing or invalid).
|
|
979
|
+
*
|
|
980
|
+
* @param message Optional message for logs/diagnostics.
|
|
981
|
+
*/
|
|
982
|
+
settingsRequiredError(message?: string): Error;
|
|
983
|
+
|
|
922
984
|
/**
|
|
923
985
|
* Trigger PopClip to appear again with the current selection.
|
|
924
986
|
*/
|
|
@@ -1092,9 +1154,6 @@ interface Util {
|
|
|
1092
1154
|
*/
|
|
1093
1155
|
base64Decode(string: string): string;
|
|
1094
1156
|
|
|
1095
|
-
/* Build a URL from a base URL and additional query parameters */
|
|
1096
|
-
buildQueryUrl: (baseUrl: string, params: { [key: string]: string }) => string;
|
|
1097
|
-
|
|
1098
1157
|
/* Build a query from params object */
|
|
1099
1158
|
buildQuery: (params: { [key: string]: string }) => string;
|
|
1100
1159
|
|