lucid-extension-sdk 0.0.155 → 0.0.156
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/commandtypes.d.ts +13 -0
- package/commandtypes.js +1 -0
- package/editorclient.d.ts +10 -0
- package/editorclient.js +19 -0
- package/package.json +1 -1
package/commandtypes.d.ts
CHANGED
|
@@ -119,6 +119,7 @@ export declare const enum CommandName {
|
|
|
119
119
|
UnhookDeleteItems = "udi",
|
|
120
120
|
UnhookSelection = "us",
|
|
121
121
|
UnhookTextEdit = "ute",
|
|
122
|
+
WithMutex = "wm",
|
|
122
123
|
ZOrder = "z"
|
|
123
124
|
}
|
|
124
125
|
/** @ignore */
|
|
@@ -525,6 +526,10 @@ export declare type CommandArgs = {
|
|
|
525
526
|
query: UnhookTextEditQuery;
|
|
526
527
|
result: UnhookTextEditResult;
|
|
527
528
|
};
|
|
529
|
+
[CommandName.WithMutex]: {
|
|
530
|
+
query: WithMutexQuery;
|
|
531
|
+
result: WithMutexResult;
|
|
532
|
+
};
|
|
528
533
|
[CommandName.ZOrder]: {
|
|
529
534
|
query: ZOrderQuery;
|
|
530
535
|
result: ZOrderResult;
|
|
@@ -1281,6 +1286,14 @@ export declare type UnhookTextEditQuery = {
|
|
|
1281
1286
|
'n': string;
|
|
1282
1287
|
};
|
|
1283
1288
|
export declare type UnhookTextEditResult = undefined;
|
|
1289
|
+
export declare type WithMutexQuery = {
|
|
1290
|
+
/** Name of the intra-document mutex to hold for the duration of this action */
|
|
1291
|
+
'n': string;
|
|
1292
|
+
/** Name of the action to run within the given mutex */
|
|
1293
|
+
'a': string;
|
|
1294
|
+
};
|
|
1295
|
+
/** Resolves true if operation succeeded, or false if the mutex was held by someone else */
|
|
1296
|
+
export declare type WithMutexResult = Promise<boolean>;
|
|
1284
1297
|
export declare enum ZOrderOperation {
|
|
1285
1298
|
UP = 1,
|
|
1286
1299
|
TOP = 2,
|
package/commandtypes.js
CHANGED
|
@@ -99,6 +99,7 @@ exports.commandTitles = new Map([
|
|
|
99
99
|
["udi" /* CommandName.UnhookDeleteItems */, 'UnhookDeleteItems'],
|
|
100
100
|
["us" /* CommandName.UnhookSelection */, 'UnhookSelection'],
|
|
101
101
|
["ute" /* CommandName.UnhookTextEdit */, 'UnhookTextEdit'],
|
|
102
|
+
["wm" /* CommandName.WithMutex */, 'WithMutex'],
|
|
102
103
|
["z" /* CommandName.ZOrder */, 'ZOrder'],
|
|
103
104
|
]);
|
|
104
105
|
var GetItemsAtSearchType;
|
package/editorclient.d.ts
CHANGED
|
@@ -315,5 +315,15 @@ export declare class EditorClient {
|
|
|
315
315
|
* @returns a Promise that resolves to a string if a user enters one, or undefined if they cancel
|
|
316
316
|
*/
|
|
317
317
|
prompt(text: string, title?: string): import("./commandtypes").PromptResult;
|
|
318
|
+
/**
|
|
319
|
+
* Executes the given callback within a mutex scoped to the current document, extension, and the given name.
|
|
320
|
+
* If another editor session currently has the given mutex name locked within the same extension package ID
|
|
321
|
+
* on this same document, this function's returned promise will resolve to false. Otherwise, the mutex will
|
|
322
|
+
* be locked for the duration of the callback and the returned promise will resolve to true.
|
|
323
|
+
* @param name Name of the intra-document mutex to attempt to lock
|
|
324
|
+
* @param callback Code to execute while the mutex is locked, if it is successfully locked
|
|
325
|
+
* @returns A promise resolving to a boolean indicating whether the mutex was successfully locked
|
|
326
|
+
*/
|
|
327
|
+
withIntraDocumentMutex(name: string, callback: () => void | Promise<void>): Promise<boolean>;
|
|
318
328
|
constructor();
|
|
319
329
|
}
|
package/editorclient.js
CHANGED
|
@@ -529,5 +529,24 @@ class EditorClient {
|
|
|
529
529
|
prompt(text, title) {
|
|
530
530
|
return this.sendCommand("p" /* CommandName.Prompt */, { 't': title, 'b': text });
|
|
531
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Executes the given callback within a mutex scoped to the current document, extension, and the given name.
|
|
534
|
+
* If another editor session currently has the given mutex name locked within the same extension package ID
|
|
535
|
+
* on this same document, this function's returned promise will resolve to false. Otherwise, the mutex will
|
|
536
|
+
* be locked for the duration of the callback and the returned promise will resolve to true.
|
|
537
|
+
* @param name Name of the intra-document mutex to attempt to lock
|
|
538
|
+
* @param callback Code to execute while the mutex is locked, if it is successfully locked
|
|
539
|
+
* @returns A promise resolving to a boolean indicating whether the mutex was successfully locked
|
|
540
|
+
*/
|
|
541
|
+
async withIntraDocumentMutex(name, callback) {
|
|
542
|
+
const action = this.getUniqueActionName();
|
|
543
|
+
this.registerAction(action, callback);
|
|
544
|
+
try {
|
|
545
|
+
return await this.sendCommand("wm" /* CommandName.WithMutex */, { 'n': name, 'a': action });
|
|
546
|
+
}
|
|
547
|
+
finally {
|
|
548
|
+
this.deleteAction(name);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
532
551
|
}
|
|
533
552
|
exports.EditorClient = EditorClient;
|