lucid-extension-sdk 0.0.5 → 0.0.6
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
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const enum CommandName {
|
|
|
11
11
|
AddMenuItem = "ami",
|
|
12
12
|
AddShapeData = "asd",
|
|
13
13
|
AnimateViewport = "av",
|
|
14
|
+
Bootstrap = "b",
|
|
14
15
|
CreateBlock = "cb",
|
|
15
16
|
CreateCollection = "cc",
|
|
16
17
|
CreateDataSource = "cds",
|
|
@@ -58,7 +59,8 @@ export declare const enum CommandName {
|
|
|
58
59
|
SetProperty = "sp",
|
|
59
60
|
SetReferenceKey = "srk",
|
|
60
61
|
SetShapeData = "ssd",
|
|
61
|
-
ShowModal = "sm"
|
|
62
|
+
ShowModal = "sm",
|
|
63
|
+
SleepForTestCase = "sleep"
|
|
62
64
|
}
|
|
63
65
|
export declare type CommandArgs = {
|
|
64
66
|
[CommandName.AnimateViewport]: {
|
|
@@ -73,6 +75,10 @@ export declare type CommandArgs = {
|
|
|
73
75
|
query: AddShapeDataQuery;
|
|
74
76
|
result: AddShapeDataResult;
|
|
75
77
|
};
|
|
78
|
+
[CommandName.Bootstrap]: {
|
|
79
|
+
query: BootstrapQuery;
|
|
80
|
+
result: BootstrapResult;
|
|
81
|
+
};
|
|
76
82
|
[CommandName.CreateBlock]: {
|
|
77
83
|
query: CreateBlockQuery;
|
|
78
84
|
result: CreateBlockResult;
|
|
@@ -265,6 +271,10 @@ export declare type CommandArgs = {
|
|
|
265
271
|
query: ShowModalQuery;
|
|
266
272
|
result: ShowModalResult;
|
|
267
273
|
};
|
|
274
|
+
[CommandName.SleepForTestCase]: {
|
|
275
|
+
query: SleepForTestCaseQuery;
|
|
276
|
+
result: SleepForTestCaseResult;
|
|
277
|
+
};
|
|
268
278
|
};
|
|
269
279
|
export declare type UnionToIntersection<T> = (T extends any ? (x: T) => unknown : never) extends (x: infer R) => unknown ? R : never;
|
|
270
280
|
export declare type AddMenuItemQuery = {
|
|
@@ -283,6 +293,14 @@ export declare type AddShapeDataQuery = {
|
|
|
283
293
|
'v'?: SerializedFieldType;
|
|
284
294
|
};
|
|
285
295
|
export declare type AddShapeDataResult = undefined;
|
|
296
|
+
export declare type BootstrapQuery = {
|
|
297
|
+
/**
|
|
298
|
+
* Named action that accepts the bootstrap data, and which may return a Promise or void. After awaiting\
|
|
299
|
+
* the result of the callback, the bootstrap data is cleared.
|
|
300
|
+
*/
|
|
301
|
+
'c': string;
|
|
302
|
+
};
|
|
303
|
+
export declare type BootstrapResult = Promise<void>;
|
|
286
304
|
export declare type CreateBlockQuery = {
|
|
287
305
|
'p'?: string;
|
|
288
306
|
'c': string;
|
|
@@ -511,3 +529,5 @@ export declare type ShowModalQuery = {
|
|
|
511
529
|
'c': string;
|
|
512
530
|
};
|
|
513
531
|
export declare type ShowModalResult = undefined;
|
|
532
|
+
export declare type SleepForTestCaseQuery = number;
|
|
533
|
+
export declare type SleepForTestCaseResult = Promise<void>;
|
|
@@ -18,4 +18,13 @@ export declare class DocumentProxy extends ElementProxy {
|
|
|
18
18
|
* @returns the created page
|
|
19
19
|
*/
|
|
20
20
|
addPage(def: PageDefinition): PageProxy;
|
|
21
|
+
/**
|
|
22
|
+
* Updates the title of this document
|
|
23
|
+
* @param title The new title for this document
|
|
24
|
+
*/
|
|
25
|
+
setTitle(title: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* @returns the title of this document
|
|
28
|
+
*/
|
|
29
|
+
getTitle(): string;
|
|
21
30
|
}
|
|
@@ -26,5 +26,18 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
|
|
|
26
26
|
page.setTitle(def.title);
|
|
27
27
|
return page;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Updates the title of this document
|
|
31
|
+
* @param title The new title for this document
|
|
32
|
+
*/
|
|
33
|
+
setTitle(title) {
|
|
34
|
+
this.properties.set('Title', title);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @returns the title of this document
|
|
38
|
+
*/
|
|
39
|
+
getTitle() {
|
|
40
|
+
return this.properties.get('Title');
|
|
41
|
+
}
|
|
29
42
|
}
|
|
30
43
|
exports.DocumentProxy = DocumentProxy;
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface XHRResponse {
|
|
|
36
36
|
export declare class EditorClient {
|
|
37
37
|
private nextId;
|
|
38
38
|
private readonly callbacks;
|
|
39
|
+
private getUniqueActionName;
|
|
39
40
|
/**
|
|
40
41
|
* Unload this extension immediately, removing any custom menu items etc., until the user refreshes the browser tab.
|
|
41
42
|
*/
|
|
@@ -142,6 +143,17 @@ export declare class EditorClient {
|
|
|
142
143
|
* @returns
|
|
143
144
|
*/
|
|
144
145
|
getCustomShapeDefinition(library: string, shape: string): Promise<BlockDefinition | undefined>;
|
|
146
|
+
/**
|
|
147
|
+
* @param callback A callback that processes the bootstrap data, if any, stored on the document and
|
|
148
|
+
* associated with this editor extension. If this callback is async (returns a promise), then the
|
|
149
|
+
* bootstrap data is not cleared off of the document until that promise resolves.
|
|
150
|
+
*
|
|
151
|
+
* @return a promise that resolves immediately if there is no available bootstrap data, or else after
|
|
152
|
+
* the callback successfully completes. This promise will reject/throw if the callback throws or
|
|
153
|
+
* returns a promise that rejects, or if there is another editor session processing the same bootstrap
|
|
154
|
+
* data at the same time.
|
|
155
|
+
*/
|
|
156
|
+
processAndClearBootstrapData(callback: (data: JsonSerializable) => void | Promise<void>): Promise<void>;
|
|
145
157
|
/**
|
|
146
158
|
* @param id ID of the line to create a proxy for
|
|
147
159
|
* @returns the given line
|
package/sdk/editorclient.js
CHANGED
|
@@ -15,6 +15,12 @@ class EditorClient {
|
|
|
15
15
|
this.callbacks = new Map();
|
|
16
16
|
this.listenToEditor();
|
|
17
17
|
}
|
|
18
|
+
getUniqueActionName() {
|
|
19
|
+
while (this.actionExists('a' + this.nextId)) {
|
|
20
|
+
this.nextId++;
|
|
21
|
+
}
|
|
22
|
+
return 'a' + this.nextId;
|
|
23
|
+
}
|
|
18
24
|
/**
|
|
19
25
|
* Unload this extension immediately, removing any custom menu items etc., until the user refreshes the browser tab.
|
|
20
26
|
*/
|
|
@@ -196,6 +202,24 @@ class EditorClient {
|
|
|
196
202
|
}
|
|
197
203
|
return undefined;
|
|
198
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* @param callback A callback that processes the bootstrap data, if any, stored on the document and
|
|
207
|
+
* associated with this editor extension. If this callback is async (returns a promise), then the
|
|
208
|
+
* bootstrap data is not cleared off of the document until that promise resolves.
|
|
209
|
+
*
|
|
210
|
+
* @return a promise that resolves immediately if there is no available bootstrap data, or else after
|
|
211
|
+
* the callback successfully completes. This promise will reject/throw if the callback throws or
|
|
212
|
+
* returns a promise that rejects, or if there is another editor session processing the same bootstrap
|
|
213
|
+
* data at the same time.
|
|
214
|
+
*/
|
|
215
|
+
async processAndClearBootstrapData(callback) {
|
|
216
|
+
const name = this.getUniqueActionName();
|
|
217
|
+
this.registerAction(name, (msg) => {
|
|
218
|
+
return callback(msg['d']);
|
|
219
|
+
});
|
|
220
|
+
await this.sendCommand("b" /* Bootstrap */, { 'c': name });
|
|
221
|
+
this.deleteAction(name);
|
|
222
|
+
}
|
|
199
223
|
/**
|
|
200
224
|
* @param id ID of the line to create a proxy for
|
|
201
225
|
* @returns the given line
|