lucid-extension-sdk 0.0.8 → 0.0.15

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 (59) hide show
  1. package/interop.d.ts +4 -0
  2. package/package.json +3 -3
  3. package/sdk/commandtypes.d.ts +276 -6
  4. package/sdk/commandtypes.js +6 -0
  5. package/sdk/core/base64.d.ts +1 -0
  6. package/sdk/core/base64.js +45 -0
  7. package/sdk/core/data/referencekeys/serializedreferencekey.d.ts +6 -0
  8. package/sdk/core/data/referencekeys/serializedreferencekey.js +17 -1
  9. package/sdk/core/jsonserializable.d.ts +4 -0
  10. package/sdk/data/collectionproxy.d.ts +2 -2
  11. package/sdk/data/collectionproxy.js +2 -2
  12. package/sdk/data/datasourceproxy.d.ts +9 -3
  13. package/sdk/data/datasourceproxy.js +12 -4
  14. package/sdk/data/referencekeydefinition.d.ts +30 -2
  15. package/sdk/data/referencekeydefinition.js +26 -1
  16. package/sdk/data/referencekeyproxy.d.ts +4 -0
  17. package/sdk/data/referencekeyproxy.js +25 -0
  18. package/sdk/data/schemadefinition.d.ts +13 -0
  19. package/sdk/data/schemadefinition.js +21 -5
  20. package/sdk/document/blockclasses/blockproxyregistry.js +2 -1
  21. package/sdk/document/blockclasses/customblockproxy.d.ts +6 -0
  22. package/sdk/document/blockclasses/customblockproxy.js +24 -0
  23. package/sdk/document/blockdefinition.d.ts +4 -2
  24. package/sdk/document/blockproxy.d.ts +20 -4
  25. package/sdk/document/blockproxy.js +31 -4
  26. package/sdk/document/documentproxy.d.ts +22 -2
  27. package/sdk/document/documentproxy.js +33 -2
  28. package/sdk/document/elementproxy.d.ts +26 -18
  29. package/sdk/document/elementproxy.js +26 -29
  30. package/sdk/document/groupproxy.d.ts +1 -1
  31. package/sdk/document/groupproxy.js +1 -1
  32. package/sdk/document/itemproxy.d.ts +5 -5
  33. package/sdk/document/itemproxy.js +5 -5
  34. package/sdk/document/lineproxy.d.ts +32 -6
  35. package/sdk/document/lineproxy.js +52 -6
  36. package/sdk/document/linetextareapositioning.d.ts +31 -0
  37. package/sdk/document/linetextareapositioning.js +30 -0
  38. package/sdk/document/mapproxy.d.ts +7 -1
  39. package/sdk/document/mapproxy.js +8 -0
  40. package/sdk/document/propertystoreproxy.d.ts +21 -0
  41. package/sdk/document/propertystoreproxy.js +37 -0
  42. package/sdk/document/shapedataproxy.d.ts +5 -0
  43. package/sdk/document/shapedataproxy.js +5 -0
  44. package/sdk/editorclient.d.ts +32 -2
  45. package/sdk/editorclient.js +69 -15
  46. package/sdk/index.d.ts +1 -0
  47. package/sdk/index.js +1 -0
  48. package/sdk/ui/alertmodal.d.ts +2 -3
  49. package/sdk/ui/alertmodal.js +2 -3
  50. package/sdk/ui/iframeui.d.ts +57 -0
  51. package/sdk/ui/iframeui.js +82 -0
  52. package/sdk/ui/menu.d.ts +19 -2
  53. package/sdk/ui/menu.js +11 -2
  54. package/sdk/ui/modal.d.ts +11 -33
  55. package/sdk/ui/modal.js +9 -46
  56. package/sdk/ui/panel.d.ts +43 -0
  57. package/sdk/ui/panel.js +50 -0
  58. package/sdk/ui/viewport.d.ts +45 -0
  59. package/sdk/ui/viewport.js +80 -0
package/interop.d.ts CHANGED
@@ -1,8 +1,12 @@
1
+ /** @ignore */
1
2
  declare namespace lucid {
2
3
  export function executeCommand(name: string, params: any): any;
3
4
  export function listen(msg: any): void;
5
+ export function getPackageId(): string;
6
+ export function getVersion(): string;
4
7
  }
5
8
 
9
+ /** @ignore */
6
10
  declare namespace console {
7
11
  export function log(...args: any[]): void;
8
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.8",
3
+ "version": "0.0.15",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -8,10 +8,10 @@
8
8
  "license": "Apache-2.0",
9
9
  "declaration": true,
10
10
  "devDependencies": {
11
- "@bazel/typescript": "2.0.1",
12
11
  "@types/jasmine": "^3.10.3",
13
12
  "@types/node": "^16.11.11",
14
- "typedoc": "^0.22.11",
13
+ "typedoc": "^0.22.15",
14
+ "typedoc-plugin-markdown": "^3.12.1",
15
15
  "typescript": "4.3.5"
16
16
  }
17
17
  }
@@ -5,13 +5,25 @@ import { JsonObject, JsonSerializable } from './core/jsonserializable';
5
5
  import { LinearOffsetType } from './core/offsettype';
6
6
  import { SerializedDataError } from './core/serializeddataerror';
7
7
  import { ShapeDataInheritance } from './core/shapedatainheritance';
8
+ import { SerializedLineTextAreaPositioning } from './document/linetextareapositioning';
8
9
  import { Box, Point } from './math';
9
10
  import { MenuLocation, MenuType } from './ui/menu';
11
+ import { PanelLocation } from './ui/panel';
12
+ /**
13
+ * The lucid-extension-sdk library interacts with core Lucid products through this set of possible commands.
14
+ * Typically, an extension author will not need to access any of these commands directly, as they are all
15
+ * exposed through appropriate classes and methods elsewhere in this SDK.
16
+ *
17
+ * To use these directly, use [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand).
18
+ */
10
19
  export declare const enum CommandName {
20
+ AddLineTextArea = "alta",
11
21
  AddMenuItem = "ami",
12
22
  AddShapeData = "asd",
23
+ Alert = "a",
13
24
  AnimateViewport = "av",
14
25
  Bootstrap = "b",
26
+ Confirm = "c",
15
27
  CreateBlock = "cb",
16
28
  CreateCollection = "cc",
17
29
  CreateDataSource = "cds",
@@ -35,6 +47,10 @@ export declare const enum CommandName {
35
47
  GetSelection = "gs",
36
48
  GetShapeData = "gsd",
37
49
  HideModal = "hm",
50
+ HidePanel = "hp",
51
+ HookCreateItems = "hci",
52
+ HookSelection = "hs",
53
+ HookTextEdit = "hte",
38
54
  KillExtension = "k",
39
55
  ListBlocks = "lb",
40
56
  ListCollectionFields = "lcf",
@@ -52,6 +68,7 @@ export declare const enum CommandName {
52
68
  LogForTestCase = "log",
53
69
  OffsetItems = "oi",
54
70
  PatchDataItems = "pdi",
71
+ RegisterPanel = "rp",
55
72
  ReloadExtension = "r",
56
73
  SendOAuthRequest = "oauth",
57
74
  SendUIMessage = "suim",
@@ -61,12 +78,21 @@ export declare const enum CommandName {
61
78
  SetReferenceKey = "srk",
62
79
  SetShapeData = "ssd",
63
80
  ShowModal = "sm",
64
- SleepForTestCase = "sleep"
81
+ ShowPanel = "spn",
82
+ SleepForTestCase = "sleep",
83
+ UnhookCreateItems = "uci",
84
+ UnhookSelection = "us",
85
+ UnhookTextEdit = "ute"
65
86
  }
87
+ /**
88
+ * This is a type declaration whose purpose is to allow TypeScript to enforce the correct parameter and
89
+ * return types from [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand) based on
90
+ * which command name you pass in as the first parameter.
91
+ */
66
92
  export declare type CommandArgs = {
67
- [CommandName.AnimateViewport]: {
68
- query: AnimateViewportQuery;
69
- result: AnimateViewportResult;
93
+ [CommandName.AddLineTextArea]: {
94
+ query: AddLineTextAreaQuery;
95
+ result: AddLineTextAreaResult;
70
96
  };
71
97
  [CommandName.AddMenuItem]: {
72
98
  query: AddMenuItemQuery;
@@ -76,10 +102,22 @@ export declare type CommandArgs = {
76
102
  query: AddShapeDataQuery;
77
103
  result: AddShapeDataResult;
78
104
  };
105
+ [CommandName.Alert]: {
106
+ query: AlertQuery;
107
+ result: AlertResult;
108
+ };
109
+ [CommandName.AnimateViewport]: {
110
+ query: AnimateViewportQuery;
111
+ result: AnimateViewportResult;
112
+ };
79
113
  [CommandName.Bootstrap]: {
80
114
  query: BootstrapQuery;
81
115
  result: BootstrapResult;
82
116
  };
117
+ [CommandName.Confirm]: {
118
+ query: ConfirmQuery;
119
+ result: ConfirmResult;
120
+ };
83
121
  [CommandName.CreateBlock]: {
84
122
  query: CreateBlockQuery;
85
123
  result: CreateBlockResult;
@@ -172,6 +210,22 @@ export declare type CommandArgs = {
172
210
  query: HideModalQuery;
173
211
  result: HideModalResult;
174
212
  };
213
+ [CommandName.HidePanel]: {
214
+ query: HidePanelQuery;
215
+ result: HidePanelResult;
216
+ };
217
+ [CommandName.HookCreateItems]: {
218
+ query: HookCreateItemsQuery;
219
+ result: HookCreateItemsResult;
220
+ };
221
+ [CommandName.HookSelection]: {
222
+ query: HookSelectionQuery;
223
+ result: HookSelectionResult;
224
+ };
225
+ [CommandName.HookTextEdit]: {
226
+ query: HookTextEditQuery;
227
+ result: HookTextEditResult;
228
+ };
175
229
  [CommandName.KillExtension]: {
176
230
  query: KillExtensionQuery;
177
231
  result: KillExtensionResult;
@@ -230,7 +284,7 @@ export declare type CommandArgs = {
230
284
  };
231
285
  [CommandName.LogForTestCase]: {
232
286
  query: JsonSerializable;
233
- result: undefined;
287
+ result: JsonSerializable;
234
288
  };
235
289
  [CommandName.OffsetItems]: {
236
290
  query: OffsetItemsQuery;
@@ -240,6 +294,10 @@ export declare type CommandArgs = {
240
294
  query: PatchDataItemsQuery;
241
295
  result: PatchDataItemsResult;
242
296
  };
297
+ [CommandName.RegisterPanel]: {
298
+ query: RegisterPanelQuery;
299
+ result: RegisterPanelResult;
300
+ };
243
301
  [CommandName.ReloadExtension]: {
244
302
  query: ReloadExtensionQuery;
245
303
  result: ReloadExtensionResult;
@@ -276,28 +334,86 @@ export declare type CommandArgs = {
276
334
  query: ShowModalQuery;
277
335
  result: ShowModalResult;
278
336
  };
337
+ [CommandName.ShowPanel]: {
338
+ query: ShowPanelQuery;
339
+ result: ShowPanelResult;
340
+ };
279
341
  [CommandName.SleepForTestCase]: {
280
342
  query: SleepForTestCaseQuery;
281
343
  result: SleepForTestCaseResult;
282
344
  };
345
+ [CommandName.UnhookCreateItems]: {
346
+ query: UnhookCreateItemsQuery;
347
+ result: UnhookCreateItemsResult;
348
+ };
349
+ [CommandName.UnhookSelection]: {
350
+ query: UnhookSelectionQuery;
351
+ result: UnhookSelectionResult;
352
+ };
353
+ [CommandName.UnhookTextEdit]: {
354
+ query: UnhookTextEditQuery;
355
+ result: UnhookTextEditResult;
356
+ };
283
357
  };
358
+ export declare type AddLineTextAreaQuery = {
359
+ /** Which line */
360
+ 'id': string;
361
+ /** Where to place the text along the line */
362
+ 'p': SerializedLineTextAreaPositioning;
363
+ /** Plain text to put at this location (will be styled with document theme) */
364
+ 't': string;
365
+ };
366
+ /** The name of the created text area */
367
+ export declare type AddLineTextAreaResult = string;
368
+ /** @ignore */
284
369
  export declare type UnionToIntersection<T> = (T extends any ? (x: T) => unknown : never) extends (x: infer R) => unknown ? R : never;
285
370
  export declare type AddMenuItemQuery = {
371
+ /** Label to display on the menu item */
286
372
  'l': string;
287
- 'a': string;
373
+ /** Named action to run when the menu item is clicked */
374
+ 'a'?: string;
375
+ /** Named action that returns whether the menu item should be visible */
288
376
  'v'?: string;
377
+ /** Named action that returns whether the menu item should be disabled */
289
378
  'd'?: string;
379
+ /** Which menu to put the item in */
290
380
  't': MenuType;
381
+ /** If specified, where to place the menu item; defaults to MenuLocation.Extension */
291
382
  'loc'?: MenuLocation;
383
+ /** If specified, this menu item should launch a file picker */
384
+ 'f'?: {
385
+ /** Action to call when files are selected */
386
+ 'a': string;
387
+ /** File types to accept */
388
+ 'ac': string;
389
+ /** Single file only */
390
+ 's'?: boolean;
391
+ /** Return content in a binary ArrayBuffer instead of as text */
392
+ 'b'?: boolean;
393
+ };
292
394
  };
293
395
  export declare type AddMenuItemResult = undefined;
294
396
  export declare type AddShapeDataQuery = {
397
+ /** ID of the element to add this shape data to */
295
398
  'id'?: string | undefined;
399
+ /** Name for this shape data */
296
400
  'n': string;
401
+ /** Inheritance setting for the new shape data */
297
402
  'i': ShapeDataInheritance;
403
+ /** Initial value of this shape data; use a string beginning with '=' for a formula */
298
404
  'v'?: SerializedFieldType;
299
405
  };
300
406
  export declare type AddShapeDataResult = undefined;
407
+ export declare type AlertQuery = {
408
+ /** Title; defaults to extension title */
409
+ 't'?: string;
410
+ /** Body text */
411
+ 'b': string;
412
+ /** Button text; defaults to i18n'ed "OK" */
413
+ 'bt'?: string;
414
+ };
415
+ /** True if they click OK, false otherwise */
416
+ export declare type AlertResult = Promise<boolean>;
301
417
  export declare type BootstrapQuery = {
302
418
  /**
303
419
  * Named action that accepts the bootstrap data, and which may return a Promise or void. After awaiting\
@@ -306,31 +422,61 @@ export declare type BootstrapQuery = {
306
422
  'c': string;
307
423
  };
308
424
  export declare type BootstrapResult = Promise<void>;
425
+ export declare type ConfirmQuery = {
426
+ /** Title; defaults to extension title */
427
+ 't'?: string;
428
+ /** Body text */
429
+ 'b': string;
430
+ /** OK button text; defaults to i18n'ed "OK" */
431
+ 'o'?: string;
432
+ /** Cancel button text; defaults to i18n'ed "Cancel" */
433
+ 'c'?: string;
434
+ };
435
+ /** True if they click OK, false otherwise */
436
+ export declare type ConfirmResult = Promise<boolean>;
309
437
  export declare type CreateBlockQuery = {
438
+ /**
439
+ * By default, we add the block to the current page & currently active group. If specified, the
440
+ * block will instead be created as a direct child of the given page.
441
+ */
310
442
  'p'?: string;
443
+ /** Class name of the block to create */
311
444
  'c': string;
445
+ /** If specified, the stencil for a custom shape. Only valid if the class name is 'CustomBlock' */
312
446
  's'?: JsonSerializable | undefined;
313
447
  };
314
448
  export declare type CreateBlockResult = string;
315
449
  export declare type CreateCollectionFieldDefinition = {
450
+ /** Name of the field */
316
451
  'n': string;
452
+ /** Type of the values in this field */
317
453
  't': SerializedFieldTypeDefinition;
318
454
  };
319
455
  export declare type CreateCollectionQuery = {
456
+ /** ID of the data source to add this collection to */
320
457
  's': string;
458
+ /** Name of the collection */
321
459
  'n': string;
460
+ /** Fields that can be set on data items in this collection */
322
461
  'f': CreateCollectionFieldDefinition[];
462
+ /** Field(s) to use as the primary key of this collection */
323
463
  'p': string[];
324
464
  };
325
465
  export declare type CreateCollectionResult = string;
326
466
  export declare type CreateDataSourceQuery = {
467
+ /** Name of the data source */
327
468
  'n': string;
469
+ /** Source configuration for this data source--information about where it came from, or any metadata that might be useful */
328
470
  's': {
329
471
  [key: string]: JsonSerializable;
330
472
  };
331
473
  };
332
474
  export declare type CreateDataSourceResult = string;
333
475
  export declare type CreateLineQuery = {
476
+ /**
477
+ * By default, we add the line to the current page & currently active group. If specified, the
478
+ * line will instead be created as a direct child of the given page.
479
+ */
334
480
  'p'?: string;
335
481
  };
336
482
  export declare type CreateLineResult = string;
@@ -341,14 +487,20 @@ export declare type DeleteItemResult = boolean;
341
487
  export declare type DeletePageQuery = string;
342
488
  export declare type DeletePageResult = boolean;
343
489
  export declare type DeleteShapeDataQuery = {
490
+ /** ID of the element to delete this shape data from */
344
491
  'id'?: string | undefined;
492
+ /** Name for this shape data */
345
493
  'n': string;
346
494
  };
347
495
  export declare type DeleteShapeDataResult = undefined;
348
496
  export declare type DownloadQuery = {
497
+ /** Filename of the download */
349
498
  'f': string;
499
+ /** Data to put in the file */
350
500
  'd': string;
501
+ /** MIME type for the download */
351
502
  'm': string;
503
+ /** If true, data is base64-encoded and should be converted to binary for download */
352
504
  'b64': boolean;
353
505
  };
354
506
  export declare type DownloadResult = undefined;
@@ -357,12 +509,16 @@ export declare type ElementExistsQuery = {
357
509
  };
358
510
  export declare type ElementExistsResult = boolean;
359
511
  export declare type ExecuteFormulaQuery = {
512
+ /** ID of the element to execute a formula on */
360
513
  'id': string;
514
+ /** Formula to execute, e.g. '@a + @b' or 'CONTAINEDBY' */
361
515
  'f': string;
362
516
  };
363
517
  export declare type ExecuteFormulaResult = SerializedFieldType | SerializedDataError;
364
518
  export declare type AnimateViewportQuery = {
519
+ /** ID of the page to view */
365
520
  'p': string;
521
+ /** Bounding box on that page that will fill as much of the viewport as possible */
366
522
  'bb': Box;
367
523
  };
368
524
  export declare type AnimateViewportResult = Promise<void>;
@@ -375,66 +531,109 @@ export declare type GetConnectedLinesResult = string[];
375
531
  export declare type GetCurrentPageQuery = void;
376
532
  export declare type GetCurrentPageResult = string | undefined;
377
533
  export declare type GetCustomShapeQuery = {
534
+ /** Name of the custom shape library in this same extension package */
378
535
  'l': string;
536
+ /** Name of the shape in that library to find */
379
537
  's': string;
380
538
  };
381
539
  export declare type GetCustomShapeResult = Promise<{
540
+ /** Value which can be used as the Stencil property on a dynamic shape */
382
541
  's': JsonSerializable;
542
+ /** Default size (x:0, y:0) of this custom shape */
383
543
  'bb': Box;
544
+ /** Other default property values */
384
545
  'p': JsonObject;
385
546
  } | undefined>;
386
547
  export declare type GetDataItemFieldQuery = {
548
+ /** Collection ID to query */
387
549
  'c': string;
550
+ /** Primary key of the data item to read */
388
551
  'pk': string;
552
+ /** Name of field to read */
389
553
  'f': string;
390
554
  };
391
555
  export declare type GetDataItemFieldResult = SerializedFieldType;
392
556
  export declare type GetItemPageIdQuery = string;
393
557
  export declare type GetItemPageIdResult = string;
394
558
  export declare type GetReferenceKeyQuery = {
559
+ /** ID of the LucidElement to read a reference key from, or undefined to read from the LucidDocument */
395
560
  'id'?: string;
561
+ /** Reference key to get */
396
562
  'k': number | string;
397
563
  };
398
564
  export declare type GetReferenceKeyResult = SerializedReferenceKeyType;
399
565
  export declare type GetPropertyQuery = {
566
+ /** ID of the LucidElement to read a property from, or undefined to read from the LucidDocument */
400
567
  'id'?: string | undefined;
568
+ /** Name of the property to read */
401
569
  'p': string;
402
570
  };
403
571
  export declare type GetPropertyResult = JsonSerializable;
404
572
  export declare type GetRelativeLinePositionQuery = {
573
+ /** Block or line ID to check the connections on */
405
574
  'id': string;
575
+ /** Relative position in range of [0,1] along the line */
406
576
  'p': number;
407
577
  };
408
578
  export declare type GetRelativeLinePositionResult = Point;
409
579
  export declare type GetSelectionQuery = {
580
+ /** If set, additionally return all items inside selected groups */
410
581
  'd'?: boolean;
411
582
  };
412
583
  export declare type GetSelectionResult = string[];
413
584
  export declare type GetShapeDataQuery = {
585
+ /** ID of the element to query shape data from */
414
586
  'id'?: string | undefined;
587
+ /** Name of the shape data to read */
415
588
  'n': string;
416
589
  };
417
590
  export declare type GetShapeDataResult = SerializedFieldType | SerializedDataError;
418
591
  export declare type HideModalQuery = {
592
+ /** Name of the modal's action for receiving events, i.e. ShowModalQuery['n'] */
419
593
  'n': string;
420
594
  };
421
595
  export declare type HideModalResult = undefined;
596
+ export declare type HidePanelQuery = {
597
+ /** Name of the panel's action for receiving events, i.e. RegisterPanelQuery['n'] */
598
+ 'n': string;
599
+ };
600
+ export declare type HidePanelResult = undefined;
601
+ export declare type HookCreateItemsQuery = {
602
+ /** Name of the action for receiving events. Will be called with an array of strings of all recently created item IDs. */
603
+ 'n': string;
604
+ };
605
+ export declare type HookCreateItemsResult = undefined;
606
+ export declare type HookSelectionQuery = {
607
+ /** Name of the action for receiving events. Will be called with an array of strings of all selected item IDs. */
608
+ 'n': string;
609
+ };
610
+ export declare type HookSelectionResult = undefined;
611
+ export declare type HookTextEditQuery = {
612
+ /** Name of the action for receiving these events */
613
+ 'n': string;
614
+ };
615
+ export declare type HookTextEditResult = undefined;
422
616
  export declare type KillExtensionQuery = void;
423
617
  export declare type KillExtensionResult = undefined;
424
618
  export declare type ListChildrenQuery = {
619
+ /** Parent ID to search inside */
425
620
  'id': string;
621
+ /** "deep" - If true, get all children at any level of group nesting; otherwise only immediate children */
426
622
  'd'?: boolean;
427
623
  };
428
624
  export declare type ListChildrenResult = string[];
429
625
  export declare type ListCollectionsQuery = {
626
+ /** ID of the data source to list collections for */
430
627
  'id': string;
431
628
  };
432
629
  export declare type ListCollectionsResult = string[];
433
630
  export declare type ListDataItemsQuery = {
631
+ /** Collection ID to list items from */
434
632
  'id': string;
435
633
  };
436
634
  export declare type ListDataItemsResult = string[];
437
635
  export declare type ListCollectionFieldsQuery = {
636
+ /** Collection ID to query */
438
637
  'id': string;
439
638
  };
440
639
  export declare type ListCollectionFieldsResult = string[];
@@ -443,8 +642,10 @@ export declare type ListDataSourcesResult = string[];
443
642
  export declare type ListPagesQuery = void;
444
643
  export declare type ListPagesResult = string[];
445
644
  export declare type ListReferenceKeysQuery = {
645
+ /** ID of the element to list reference keys for, or undefined for the document */
446
646
  'id'?: string | undefined;
447
647
  };
648
+ /** Reference key IDs */
448
649
  export declare type ListReferenceKeysResult = (string | number)[];
449
650
  export declare type ListPropertiesQuery = {
450
651
  'id'?: string | undefined;
@@ -452,6 +653,7 @@ export declare type ListPropertiesQuery = {
452
653
  export declare type ListPropertiesResult = string[];
453
654
  export declare type ListShapeDataQuery = {
454
655
  'id'?: string | undefined;
656
+ /** True to include inherited shape data from containing groups and/or page */
455
657
  'i'?: boolean | undefined;
456
658
  };
457
659
  export declare type ListShapeDataResult = string[];
@@ -460,31 +662,57 @@ export declare type ListTextAreasResult = string[];
460
662
  export declare type LoadBlockClassesQuery = string[];
461
663
  export declare type LoadBlockClassesResult = Promise<undefined>;
462
664
  export declare type OffsetItemsQuery = {
665
+ /** IDs of the items (blocks, lines, groups) to move */
463
666
  'ids': string[];
667
+ /** What kind of offset to perform */
464
668
  't': LinearOffsetType;
669
+ /** How far to offset */
465
670
  'o': Point;
466
671
  };
467
672
  export declare type OffsetItemsResult = undefined;
468
673
  export declare type PatchDataItemsQuery = {
674
+ /** ID of the data collection to patch */
469
675
  'id': string;
676
+ /** Data items to add to the collection */
470
677
  'a': Record<string, SerializedFieldType>[];
678
+ /** Data items to change field values on, keyed by primary key */
471
679
  'c': Record<string, Record<string, SerializedFieldType>>;
680
+ /** Primary keys of items to delete */
472
681
  'd': string[];
473
682
  };
474
683
  export declare type PatchDataItemsResult = undefined;
684
+ export declare type RegisterPanelQuery = {
685
+ /** Name of the panel's action for receiving events; generated automatically by Panel base class */
686
+ 'n': string;
687
+ /** Title to show on the panel */
688
+ 't': string;
689
+ /** Where to display the panel */
690
+ 'l': PanelLocation;
691
+ /** Named action that returns whether the button to open the panel should be visible */
692
+ 'v'?: string;
693
+ /** Content to display in the panel; full HTML page preferred */
694
+ 'c': string;
695
+ /** Icon URL, preferably a base64-encoded URL */
696
+ 'i': string;
697
+ };
698
+ export declare type RegisterPanelResult = undefined;
475
699
  export declare type ReloadExtensionQuery = void;
476
700
  export declare type ReloadExtensionResult = undefined;
477
701
  export declare type SendOAuthRequestQuery = SendXHRQuery & {
702
+ /** OAuth provider name as specified in the package manifest */
478
703
  'p': string;
479
704
  };
480
705
  export declare type SendOAuthRequestResponse = SendXHRResponse;
481
706
  export declare type SendUIMessageQuery = {
707
+ /** Name of the UI component's action for receiving events, e.g. ShowModalQuery['n'] */
482
708
  'n': string;
709
+ /** Content of the message to send to the custom UI component */
483
710
  'd'?: JsonSerializable;
484
711
  };
485
712
  export declare type SendUIMessageResult = undefined;
486
713
  export declare type SendXHRQuery = {
487
714
  'url': string;
715
+ /** HTTP method, e.g. 'GET', 'FETCH', etc. Defaults to GET */
488
716
  'm'?: string;
489
717
  /**
490
718
  * The data to send with the request.
@@ -495,48 +723,90 @@ export declare type SendXHRQuery = {
495
723
  * no 'Content-Type' header is specified, a 'text/plain; charset=utf-8' content type is sent.
496
724
  */
497
725
  'd'?: string;
726
+ /** Headers to send with the request */
498
727
  'h'?: {
499
728
  [key: string]: string | string[];
500
729
  };
730
+ /** Timeout in milliseconds, if specified */
501
731
  'ms'?: number;
502
732
  };
503
733
  export declare type RawSendXHRResponse = {
734
+ /** URL of the response after any redirects */
504
735
  'url': string;
736
+ /** Plain-text response body */
505
737
  't': string;
738
+ /** Status code of the response */
506
739
  's': number;
740
+ /** Headers sent with the response */
507
741
  'h': {
508
742
  [key: string]: string;
509
743
  };
744
+ /** true if the request timed out */
510
745
  'to'?: boolean;
511
746
  };
512
747
  export declare type SendXHRResponse = Promise<RawSendXHRResponse>;
748
+ export declare function isRawSendXHRResponse(val: any): val is RawSendXHRResponse;
513
749
  export declare type SetCurrentPageQuery = string;
514
750
  export declare type SetCurrentPageResult = Promise<void>;
515
751
  export declare type SetPropertyQuery = {
752
+ /** ID of the element to change */
516
753
  'id'?: string | undefined;
754
+ /** Name of the property to change */
517
755
  'p': string;
756
+ /** New value of the property */
518
757
  'v'?: JsonSerializable;
519
758
  };
520
759
  export declare type SetPropertyResult = undefined;
521
760
  export declare type SetReferenceKeyQuery = {
761
+ /** ID of the element to set the reference key on */
522
762
  'id'?: string | undefined;
763
+ /** ID of the reference key to set */
523
764
  'k': string | number;
765
+ /** New reference key settings, or undefined to remove the reference key */
524
766
  'v'?: SerializedReferenceKeyType;
525
767
  };
526
768
  export declare type SetReferenceKeyResult = undefined;
527
769
  export declare type SetShapeDataQuery = {
770
+ /** ID of the element to set this shape data on */
528
771
  'id'?: string | undefined;
772
+ /** Name for the already-existing shape data to update */
529
773
  'n': string;
774
+ /** Value to set; use a string beginning with '=' for a formula */
530
775
  'v'?: SerializedFieldType;
531
776
  };
532
777
  export declare type SetShapeDataResult = undefined;
533
778
  export declare type ShowModalQuery = {
779
+ /** Name of the modal's action for receiving events; generated automatically by Modal base class */
534
780
  'n': string;
781
+ /** Title to show on the modal */
535
782
  't': string;
783
+ /** Desired modal width */
536
784
  'w': number;
785
+ /** Desired modal height */
537
786
  'h': number;
787
+ /** Content to display in the modal; full HTML page preferred */
538
788
  'c': string;
539
789
  };
540
790
  export declare type ShowModalResult = undefined;
791
+ export declare type ShowPanelQuery = {
792
+ /** Name of the panel's action for receiving events, i.e. RegisterPanelQuery['n'] */
793
+ 'n': string;
794
+ };
795
+ export declare type ShowPanelResult = undefined;
541
796
  export declare type SleepForTestCaseQuery = number;
542
797
  export declare type SleepForTestCaseResult = Promise<void>;
798
+ export declare type UnhookCreateItemsQuery = {
799
+ /** Name of the action passed to HookCreateItems */
800
+ 'n': string;
801
+ };
802
+ export declare type UnhookCreateItemsResult = undefined;
803
+ export declare type UnhookSelectionQuery = {
804
+ /** Name of the action for receiving these events */
805
+ 'n': string;
806
+ };
807
+ export declare type UnhookSelectionResult = undefined;
808
+ export declare type UnhookTextEditQuery = {
809
+ /** Name of the action for receiving these events */
810
+ 'n': string;
811
+ };
812
+ export declare type UnhookTextEditResult = undefined;
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRawSendXHRResponse = void 0;
4
+ const checks_1 = require("./core/checks");
5
+ function isRawSendXHRResponse(val) {
6
+ return (0, checks_1.isString)(val['url']) && (0, checks_1.isString)(val['t']) && (0, checks_1.isNumber)(val['s']) && (0, checks_1.isObject)(val['h']);
7
+ }
8
+ exports.isRawSendXHRResponse = isRawSendXHRResponse;
@@ -0,0 +1 @@
1
+ export declare function decodeBase64(base64String: string): Uint8Array;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeBase64 = void 0;
4
+ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
5
+ //This gives a ~8x speedup vs. using alphabet.indexOf() in the main decode loop.
6
+ const charCodeToEncodedInt = [];
7
+ for (let i = 0; i < alphabet.length; i++) {
8
+ charCodeToEncodedInt[alphabet.charCodeAt(i)] = i;
9
+ }
10
+ function decodeBase64(base64String) {
11
+ //Filter out whitespace, etc
12
+ base64String = base64String.replace(/[^A-Za-z0-9\+\/\=]/g, '');
13
+ if (base64String.length % 4 !== 0) {
14
+ throw new Error('Invalid base64 input; length must be a multiple of 4');
15
+ }
16
+ //4 characters of input turns into 3 bytes of output
17
+ let bytes = (base64String.length / 4) * 3;
18
+ //But each trailing = (up to 2) is one fewer byte of output
19
+ if (base64String.endsWith('==')) {
20
+ bytes -= 2;
21
+ }
22
+ else if (base64String.endsWith('=')) {
23
+ bytes -= 1;
24
+ }
25
+ const output = new Uint8Array(bytes);
26
+ let inputIndex = 0;
27
+ for (let outputIndex = 0; outputIndex < bytes; outputIndex += 3) {
28
+ //Get the 4 numbers 0-63 encoded in the next 4 characters
29
+ const enc1 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
30
+ const enc2 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
31
+ const enc3 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
32
+ const enc4 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
33
+ //Read 8 total bits into each of the output values. Skip one byte
34
+ //for each padding = at the end of the string
35
+ output[outputIndex] = (enc1 << 2) | (enc2 >> 4);
36
+ if (enc3 != 64) {
37
+ output[outputIndex + 1] = ((enc2 & 15) << 4) | (enc3 >> 2);
38
+ }
39
+ if (enc4 != 64) {
40
+ output[outputIndex + 2] = ((enc3 & 3) << 6) | enc4;
41
+ }
42
+ }
43
+ return output;
44
+ }
45
+ exports.decodeBase64 = decodeBase64;