@adobe/ccweb-add-on-sdk-types 1.0.0 → 1.1.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/README.md CHANGED
@@ -12,8 +12,8 @@ This package exports type definitions for [@adobe/create-ccweb-add-on](https://w
12
12
 
13
13
  For TypeScript add-on projects created using [@adobe/create-ccweb-add-on](https://www.npmjs.com/package/@adobe/create-ccweb-add-on), this package is pre-installed. Additionally, the below files are included in the add-on project (based on the selected runtime):
14
14
 
15
- - [add-on-ui-sdk.d.ts](https://github.com/adobe/ccweb-add-on-cli/blob/main/packages/wxp-sdk-typings/add-on-script-sdk.d.ts)
16
- - [add-on-script-sdk.d.ts](https://github.com/adobe/ccweb-add-on-cli/blob/main/packages/wxp-sdk-typings/add-on-ui-sdk.d.ts)
15
+ - [add-on-ui-sdk.d.ts](https://github.com/adobe/create-ccweb-add-on/blob/main/packages/wxp-sdk-types/add-on-ui-sdk.d.ts)
16
+ - [add-on-sandbox-sdk.d.ts](https://github.com/adobe/create-ccweb-add-on/blob/main/packages/wxp-sdk-types/add-on-sandbox-sdk.d.ts)
17
17
 
18
18
  However, if you are installing this package on your existing add-on project, ensure to include the above type definition files in your `src` directory.
19
19
 
@@ -24,12 +24,12 @@
24
24
 
25
25
  // DO NOT modify this file.
26
26
 
27
- declare module "AddOnScriptSdk" {
28
- import { AddOnScriptSdkTypes } from "@adobe/ccweb-add-on-sdk-types";
29
- export default AddOnScriptSdkTypes.default;
30
- export * from "@adobe/ccweb-add-on-sdk-types/script/script-sdk";
27
+ declare module "add-on-sdk-document-sandbox" {
28
+ import { AddOnDocumentSandboxSdkTypes } from "@adobe/ccweb-add-on-sdk-types";
29
+ export default AddOnDocumentSandboxSdkTypes.default;
30
+ export * from "@adobe/ccweb-add-on-sdk-types/sandbox/add-on-sdk-document-sandbox";
31
31
  }
32
32
 
33
- declare module "express" {
34
- export * from "@adobe/ccweb-add-on-sdk-types/script/express";
33
+ declare module "express-document-sdk" {
34
+ export * from "@adobe/ccweb-add-on-sdk-types/sandbox/express-document-sdk";
35
35
  }
package/index.d.ts CHANGED
@@ -22,5 +22,5 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- export * as AddOnScriptSdkTypes from "./script/index.js";
25
+ export * as AddOnDocumentSandboxSdkTypes from "./sandbox/index.js";
26
26
  export * as AddOnUISdkTypes from "./ui/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/ccweb-add-on-sdk-types",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "author": "Adobe",
5
5
  "license": "MIT",
6
6
  "description": "Type definitions for Adobe Creative Cloud Web Add-on SDK.",
@@ -18,7 +18,6 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "tslib": "2.4.0",
21
- "comlink": "4.3.1",
22
21
  "gl-matrix": "3.3.0"
23
22
  },
24
23
  "devDependencies": {
@@ -0,0 +1,236 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+
25
+ /**
26
+ * Represents the instance of this AddOn.
27
+ * The instance contains the necessary details like the associated Runtime etc.
28
+ */
29
+ export declare class AddOn {
30
+ /**
31
+ * Get the runtime instance, which represents
32
+ * the execution environment for this AddOn.
33
+ */
34
+ get runtime(): Runtime;
35
+ }
36
+
37
+ /**
38
+ * The APIs provided by AddOn SDK for the document model sandbox.
39
+ * The APIs are exposed as an ES6 module.
40
+ * @public
41
+ */
42
+ export declare class AddOnDocumentSandboxSdk {
43
+ /**
44
+ * Returns the instance of this AddOn.
45
+ * @see AddOn
46
+ */
47
+ get instance(): AddOn;
48
+ }
49
+
50
+ /** @public - This object, exposed as the default, can be used in add-on's document model sandbox code. */
51
+ declare const addOnSandboxSdk: AddOnDocumentSandboxSdk;
52
+ export default addOnSandboxSdk;
53
+
54
+ /**
55
+ * Takes the raw type of a remote object or function as a remote thread would see it through a proxy (e.g. when
56
+ * passed in as a function argument) and returns the type the local thread has to supply.
57
+ * Creation of new class objects is not allowed.
58
+ *
59
+ * This is the inverse of `Remote<T>`. It takes a `Remote<T>` and returns its original input `T`.
60
+ */
61
+ declare type Local<T> = LocalObject<T> &
62
+ (T extends (...args: infer TArguments) => infer TReturn
63
+ ? (
64
+ ...args: {
65
+ [I in keyof TArguments]: ProxyOrClone<TArguments[I]>;
66
+ }
67
+ ) => MaybePromise<UnproxyOrClone<Unpromisify<TReturn>>>
68
+ : unknown) &
69
+ (T extends {
70
+ new (...args: infer TArguments): infer TInstance;
71
+ }
72
+ ? {
73
+ new: never;
74
+ }
75
+ : unknown);
76
+
77
+ /**
78
+ * Takes the type of an object as a remote thread would see it through a proxy (e.g. when passed in as a function
79
+ * argument) and returns the type that the local thread has to supply.
80
+ *
81
+ * This does not handle call signatures, which is handled by the more general `Local<T>` type.
82
+ *
83
+ * This is the inverse of `RemoteObject<T>`.
84
+ *
85
+ * @template T The type of a proxied object.
86
+ */
87
+ declare type LocalObject<T> = {
88
+ [P in keyof T]: LocalProperty<T[P]>;
89
+ };
90
+
91
+ /**
92
+ * Takes the raw type of a property as a remote thread would see it through a proxy (e.g. when passed in as a function
93
+ * argument) and returns the type that the local thread has to supply.
94
+ *
95
+ * This is the inverse of `RemoteProperty<T>`.
96
+ *
97
+ * Note: This needs to be its own type alias, otherwise it will not distribute over unions. See
98
+ * https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
99
+ */
100
+ declare type LocalProperty<T> = T extends Function | ProxyMarked ? Local<T> : Unpromisify<T>;
101
+
102
+ /**
103
+ * Expresses that a type can be either a sync or async.
104
+ */
105
+ declare type MaybePromise<T> = Promise<T> | T;
106
+
107
+ /**
108
+ * Takes a type and wraps it in a Promise, if it not already is one.
109
+ * This is to avoid `Promise<Promise<T>>`.
110
+ *
111
+ * This is the inverse of `Unpromisify<T>`.
112
+ */
113
+ declare type Promisify<T> = T extends Promise<unknown> ? T : Promise<T>;
114
+
115
+ /**
116
+ * Interface of values that were marked to be proxied with `Runtime.apiProxy()`.
117
+ * Can also be implemented by classes.
118
+ */
119
+ declare interface ProxyMarked {
120
+ [proxyMarker]: true;
121
+ }
122
+
123
+ declare const proxyMarker: unique symbol;
124
+
125
+ /**
126
+ * Proxies `T` if it is a `ProxyMarked`, clones it otherwise (as handled by structured cloning and transfer handlers).
127
+ */
128
+ declare type ProxyOrClone<T> = T extends ProxyMarked ? Remote<T> : T;
129
+
130
+ /**
131
+ * Takes the raw type of a remote object or function in the other thread and returns the type as it is visible to
132
+ * the local thread from the proxy return value of `Runtime.apiProxy()`.
133
+ * Creation of new class objects is not allowed.
134
+ */
135
+ declare type Remote<T> = RemoteObject<T> &
136
+ (T extends (...args: infer TArguments) => infer TReturn
137
+ ? (
138
+ ...args: {
139
+ [I in keyof TArguments]: UnproxyOrClone<TArguments[I]>;
140
+ }
141
+ ) => Promisify<ProxyOrClone<Unpromisify<TReturn>>>
142
+ : unknown) &
143
+ (T extends {
144
+ new (...args: infer TArguments): infer TInstance;
145
+ }
146
+ ? {
147
+ new: never;
148
+ }
149
+ : unknown);
150
+
151
+ /**
152
+ * Takes the raw type of a remote object in the other thread and returns the type as it is visible to the local thread
153
+ * when proxied with `Runtime.apiProxy()`.
154
+ *
155
+ * This does not handle call signatures, which is handled by the more general `Remote<T>` type.
156
+ *
157
+ * @template T The raw type of a remote object as seen in the other thread.
158
+ */
159
+ declare type RemoteObject<T> = {
160
+ [P in keyof T]: RemoteProperty<T[P]>;
161
+ };
162
+
163
+ /**
164
+ * Takes the raw type of a remote property and returns the type that is visible to the local thread on the proxy.
165
+ *
166
+ * Note: This needs to be its own type alias, otherwise it will not distribute over unions.
167
+ * See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
168
+ */
169
+ declare type RemoteProperty<T> = T extends Function | ProxyMarked ? Remote<T> : Promisify<T>;
170
+
171
+ /**
172
+ * The instance of Runtime this AddOn is running into.
173
+ * It contains methods to expose APIs from this runtime
174
+ * and getting access to APIs exposed by other runtimes.
175
+ */
176
+ export declare class Runtime {
177
+ /**
178
+ * The runtime-type of this Runtime.
179
+ * Will always be "documentSandbox".
180
+ */
181
+ get type(): RuntimeType.documentSandbox;
182
+ /**
183
+ * Exposes the concrete object/function of type T,
184
+ * which can be accessed into different runtime part of this AddOn e.g., "panel" (iframe) runtime.
185
+ * Note that only concrete objects / class instances are supported. We can't expose entire class
186
+ * from one runtime and create instance of that class in another runtime. Trying to do
187
+ * so may result in undefined behaviour.
188
+ * @param obj - the concrete object to expose to other runtimes
189
+ * Note: This method call is allowed only once. Subsequent calls are ignored.
190
+ */
191
+ exposeApi<T>(obj: T): void;
192
+ /**
193
+ * Requests a promise based proxy object for other runtimes, which will be used
194
+ * by this document model sandbox to directly call the APIs exposed (using exposeApi) from the other runtimes (e.g., iframe UI runtime).
195
+ * await or .then is necessary, since returned object is a promise.
196
+ * @param runtimeType - the runtime, for which proxy object needs to be created.
197
+ * @returns a promise which may resolve to a proxy or reject with rejection reason.
198
+ * The promise resolves to API proxy object exposed by desired runtime, as soon as the other runtime is finished initializing.
199
+ * Note: Calling the method again for same runtime type will return a new proxy object without any behavior difference.
200
+ */
201
+ apiProxy<T>(runtimeType: RuntimeType): Promise<Remote<T>>;
202
+ }
203
+
204
+ /**
205
+ * Supported runtime types for this AddOn.
206
+ */
207
+ export declare enum RuntimeType {
208
+ /**
209
+ * Represents iframe runtime part of this AddOn.
210
+ */
211
+ panel = "panel",
212
+ /**
213
+ * @deprecated Use 'documentSandbox' instead.
214
+ * Represents document model sandbox part of this AddOn.
215
+ */
216
+ script = "script",
217
+ /**
218
+ * Represents document model sandbox part of this AddOn.
219
+ */
220
+ documentSandbox = "documentSandbox"
221
+ }
222
+
223
+ /**
224
+ * Takes a type that may be Promise and unwraps the Promise type.
225
+ * If `P` is not a Promise, it returns `P`.
226
+ *
227
+ * This is the inverse of `Promisify<T>`.
228
+ */
229
+ declare type Unpromisify<P> = P extends Promise<infer T> ? T : P;
230
+
231
+ /**
232
+ * Inverse of `ProxyOrClone<T>`.
233
+ */
234
+ declare type UnproxyOrClone<T> = T extends RemoteObject<ProxyMarked> ? Local<T> : T;
235
+
236
+ export {};
@@ -25,21 +25,13 @@
25
25
  import { mat2d } from "gl-matrix";
26
26
 
27
27
  declare namespace ApiConstants {
28
- export {
29
- SceneNodeTypeValueID,
30
- BlendModeValue,
31
- FillTypeValue,
32
- ArrowHeadType,
33
- TextAlignmentValue,
34
- FillRuleValue,
35
- StrokePositionValue
36
- };
28
+ export { SceneNodeType, BlendMode, FillType, ArrowHeadType, TextAlignment, FillRule, StrokePosition };
37
29
  }
38
30
 
39
31
  declare interface ApiModuleExport {
40
32
  editor: ExpressEditor;
41
33
  utils: ApiUtils;
42
- Constants: unknown;
34
+ constants: unknown;
43
35
  }
44
36
 
45
37
  declare interface ApiUtils {
@@ -76,21 +68,13 @@ declare enum ArrowHeadType {
76
68
  * ArtboardList also provides APIs for adding/removing artboards from the page. ArtboardList is never empty: it is illegal to
77
69
  * remove the last remaining artboard from the list.
78
70
  */
79
- export declare class ArtboardList extends ReadOnlyItemList<ArtboardNode> {
71
+ export declare class ArtboardList extends RestrictedItemList<ArtboardNode> {
80
72
  /**
81
73
  * Create a new artboard and add it to the end of the list. The artboard size is the same as others on this page. The
82
74
  * artboard background is set to default fill color {@link DEFAULT_ARTBOARD_FILL_COLOR}.
83
75
  * @returns the newly added artboard.
84
76
  */
85
77
  addArtboard(): ArtboardNode;
86
- /**
87
- * Remove the items from the list.
88
- *
89
- * @throws An error if any of the items are not in the list or if removing the
90
- * items would cause the list to be empty. If one of these errors occurs, the list
91
- * is not modified.
92
- */
93
- remove(...items: ArtboardNode[]): void;
94
78
  }
95
79
 
96
80
  /**
@@ -146,7 +130,7 @@ export declare interface BitmapImage {
146
130
  * If a node is inside a container whose blend mode anything other than {@link passThrough}, then the node's blend mode only
147
131
  * interacts with other siblings within the same container. See documentation below for details.
148
132
  */
149
- declare enum BlendModeValue {
133
+ declare enum BlendMode {
150
134
  /**
151
135
  * This blend mode only applies to container nodes with children; for leaf nodes, it is treated the same as `normal`.
152
136
  *
@@ -218,7 +202,7 @@ export declare interface ColorFill extends Fill {
218
202
  /**
219
203
  * The fill type.
220
204
  */
221
- readonly type: FillTypeValue.color;
205
+ readonly type: FillType.color;
222
206
  /**
223
207
  * The fill color.
224
208
  */
@@ -232,7 +216,13 @@ export declare enum ColorSpace {
232
216
  sRGB = "sRGB"
233
217
  }
234
218
 
235
- export declare const Constants: typeof ApiConstants;
219
+ /**
220
+ * A ComplexShapeNode is complex prepackaged shape that appears as a leaf node in the UI, even if it is composed
221
+ * of multiple separate paths.
222
+ */
223
+ export declare class ComplexShapeNode extends FillableNode {}
224
+
225
+ export declare const constants: typeof ApiConstants;
236
226
 
237
227
  /**
238
228
  * Base class for a Node that contains an entirely generic collection of children. Some ContainerNode subclasses may host
@@ -254,6 +244,13 @@ export declare class Context {
254
244
  * @returns the current selection. Nodes that are locked or otherwise non-editable are never included in the selection.
255
245
  */
256
246
  get selection(): readonly Node[];
247
+ /**
248
+ * Sets the current selection, automatically ensuring these rules are met:
249
+ * - Nodes must be within the current artboard (others are filtered out).
250
+ * - A node cannot be selected at the same time as its ancestor (descendants are filtered out).
251
+ * - Locked nodes are filtered out (but will still be included in selectionIncludingNonEditable).
252
+ */
253
+ set selection(nodes: Node | readonly Node[] | undefined);
257
254
  /**
258
255
  * @returns the current selection *and* any locked nodes the user has attempted to select at the same time. This can
259
256
  * happen for example if the user clicks on a locked node or if the user drags a selection marquee that overlaps
@@ -343,14 +340,13 @@ export declare class Editor {
343
340
  * See {@link StrokeOptions} for more details on the `options` fields. Defaults:
344
341
  * - `color` has default value {@link DEFAULT_STROKE_COLOR} if none is provided.
345
342
  * - `width` has default value {@link DEFAULT_STROKE_WIDTH} if none is provided.
346
- * - `dashPattern` has default value [] if none is provided. If the dash pattern has
347
- * odd number of elements, the items are copied to double the array. For example,
348
- * [1, 2, 3] becomes [1, 2, 3, 1, 2, 3]. Values cannot be negative.
343
+ * - `dashPattern` has default value [] if none is provided. Array must be
344
+ * of even length. Values cannot be negative.
349
345
  * - `dashOffset` has default value 0 if none is provided. This options field is ignored
350
346
  * if no `dashPattern` was provided.
351
347
  *
352
348
  * The stroke's `position` field cannot be specified via options yet because only
353
- * {@link StrokePositionValue.center} is supported.
349
+ * {@link StrokePosition.center} is supported.
354
350
  *
355
351
  * @returns a stroke configured with the given options.
356
352
  */
@@ -361,6 +357,42 @@ export declare class Editor {
361
357
  * adjust to accommodate whatever text is set.
362
358
  */
363
359
  createText(): TextNode;
360
+ /**
361
+ * Enqueues a function to be run at a later time when edits to the user's document may be performed. You can always edit
362
+ * the document immediately when invoked in response to your add-on's UI code. However, if you delay to await an
363
+ * asynchronous operation such as {@link loadBitmapImage}, any edits following this pause must be scheduled using
364
+ * queueAsyncEdit(). This ensures the edit is properly tracked for saving and undo.
365
+ *
366
+ * The delay before your edit function is executed is typically just a few milliseconds, so it will appear instantaneous
367
+ * to users. However, note that queueAsyncEdit() will return *before* your function has been run.
368
+ * If you need to trigger any code after the edit has been performed, either include this in the lambda you are enqueuing
369
+ * or await the Promise returned by queueAsyncEdit().
370
+ *
371
+ * Generally, calling any setter or method is treated as an edit; but simple getters may be safely called at any time.
372
+ *
373
+ * Example of typical usage:
374
+ * ```javascript
375
+ * // Assume insertImage() is called from your UI code, and given a Blob containing image data
376
+ * async function insertImage(blob) {
377
+ * // This function was invoked from the UI iframe, so we can make any edits we want synchronously here.
378
+ * // Initially load the bitmap - an async operation
379
+ * const bitmapImage = await editor.loadBitmapImage(blob);
380
+ *
381
+ * // Execution doesn't arrive at this line until an async delay, due to the Promise 'await' above
382
+ *
383
+ * // Further edits need to be queued to run at a safe time
384
+ * editor.queueAsyncEdit(() => {
385
+ * // Create scenenode to display the image, and add it to the current artboard
386
+ * const mediaContainer = editor.createImageContainer(bitmapImage);
387
+ * editor.context.insertionParent.children.append(mediaContainer);
388
+ * });
389
+ * }
390
+ * ```
391
+ *
392
+ * @param lambda - a function which edits the document model.
393
+ * @returns a Promise that resolves when the lambda has finished running, or rejects if the lambda throws an error.
394
+ */
395
+ queueAsyncEdit(lambda: () => void): Promise<void>;
364
396
  }
365
397
 
366
398
  export declare const editor: ExpressEditor;
@@ -411,7 +443,7 @@ export declare interface Fill {
411
443
  /**
412
444
  * The fill type.
413
445
  */
414
- readonly type: FillTypeValue;
446
+ readonly type: FillType;
415
447
  }
416
448
 
417
449
  /**
@@ -428,7 +460,7 @@ export declare class FillableNode extends StrokableNode implements IFillableNode
428
460
  * <InlineAlert slots="text" variant="warning"/>
429
461
  * *Do not depend on the literal numeric values of these constants*, as they may change. Always reference the enum identifiers in your code.
430
462
  */
431
- declare enum FillRuleValue {
463
+ declare enum FillRule {
432
464
  nonZero = 0,
433
465
  evenOdd = 1
434
466
  }
@@ -441,11 +473,31 @@ declare enum FillRuleValue {
441
473
  * *Additional fill types may be added in the future.* If your code has different branches or cases depending on fill type,
442
474
  * always have a default/fallback case to handle any unknown values you may encounter.
443
475
  */
444
- declare enum FillTypeValue {
476
+ declare enum FillType {
445
477
  /** A solid color fill. */
446
478
  color = "Color"
447
479
  }
448
480
 
481
+ /**
482
+ * A GridLayoutNode represents a grid layout in the scenegraph. The GridLayoutNode is used to
483
+ * create a layout grid that other content can be placed into.
484
+ */
485
+ export declare class GridLayoutNode extends Node implements IRectangularNode {
486
+ /**
487
+ * The width of the node.
488
+ */
489
+ get width(): number;
490
+ /**
491
+ * The height of the node.
492
+ */
493
+ get height(): number;
494
+ /**
495
+ * The background fill of the GridLayout.
496
+ */
497
+ get fill(): Fill;
498
+ set fill(fill: Fill);
499
+ }
500
+
449
501
  /**
450
502
  * A GroupNode represents a Group object in the scenegraph, which has a collection of generic children as well as a separate,
451
503
  * optional vector mask child.
@@ -463,7 +515,7 @@ export declare class GroupNode extends ContainerNode {
463
515
  */
464
516
  get maskShape(): FillableNode | undefined;
465
517
  /**
466
- * If set to a vector shape, adds a mask or replaces the exsiting mask on this Group.
518
+ * If set to a vector shape, adds a mask or replaces the existing mask on this Group.
467
519
  * If set to undefined, removes any mask that was previously set on this Group.
468
520
  * @throws if the given node type cannot be used as a vector mask.
469
521
  */
@@ -523,17 +575,12 @@ declare interface IStrokableNode {
523
575
  *
524
576
  * This class is used in different places for various types of items, including Nodes, Fills, and Strokes.
525
577
  */
526
- export declare class ItemList<T extends ListItem> extends ReadOnlyItemList<T> {
578
+ export declare class ItemList<T extends ListItem> extends RestrictedItemList<T> {
527
579
  /**
528
580
  * Add one or more items to the end of the list. The last argument will become the last item in this list. Items are
529
581
  * removed from their previous parent, if any – or if an item is already in *this* list, its index is simply changed.
530
582
  */
531
583
  append(...items: T[]): void;
532
- /**
533
- * Remove one or more items from this list. The items need not be contiguous.
534
- * Throws without performing any removals if any item is not a member of this list.
535
- */
536
- remove(...items: T[]): void;
537
584
  /**
538
585
  * Remove all items from this list. No-op if list is already empty.
539
586
  */
@@ -568,8 +615,8 @@ export declare class LineNode extends StrokableNode {
568
615
  static readonly DEFAULT_END_Y = 100;
569
616
  /**
570
617
  * Set the start and end points of the line in its local coordinate space (which may
571
- * differ from its parent's coordinate space based on `relativeTransform`, i.e.
572
- * `relativeRotation` and `translateX`/`Y`). The values passed in may be normalized
618
+ * differ from its parent's coordinate space based on `transformMatrix`, i.e.
619
+ * `rotation` and `translation`). The values passed in may be normalized
573
620
  * by this setter, shifting the node's translation and counter-shifting the start/end
574
621
  * points. Therefore, the start/end getters may return values different from the values
575
622
  * you passed into this setter, even though the line's visual bounds and appearance are
@@ -663,29 +710,56 @@ declare class Node {
663
710
  /**
664
711
  * The node's type.
665
712
  */
666
- get type(): SceneNodeTypeValueID;
667
- /**
668
- * The translation of the node along its parent's x-axis.
669
- */
670
- get translateX(): number;
671
- set translateX(value: number);
672
- /**
673
- * The translation of the node along its parent's y-axis.
674
- */
675
- get translateY(): number;
676
- set translateY(value: number);
677
- /**
678
- * The node's local rotation value in degrees, relative to its parent's axes. Modifying this value will also adjust the
679
- * node's x & y translation such that the node's center is in the same location after the rotation – i.e. this setter
680
- * rotates the node about its bounding box's center, not its origin.
681
- */
682
- get relativeRotation(): number;
683
- set relativeRotation(value: number);
684
- /**
685
- * The node's absolute (global) rotation angle in degrees – includes any cumulative rotation from the node's parent containers.
686
- */
687
- get absoluteRotation(): number;
688
- set absoluteRotation(value: number);
713
+ get type(): SceneNodeType;
714
+ /**
715
+ * The translation of the node along its parent's axes. This is identical to the translation component of
716
+ * `transformMatrix`. It is often simpler to set a node's position using `setPositionInParent` than by
717
+ * setting translation directly.
718
+ */
719
+ get translation(): Readonly<{
720
+ x: number;
721
+ y: number;
722
+ }>;
723
+ set translation(value: { x: number; y: number });
724
+ /**
725
+ * Move the node so the given `localRegistrationPoint` in its local coordinates is placed at the given
726
+ * `parentPoint` in its parent's coordinates (taking into account any rotation on this node, etc.).
727
+ * @param parentPoint - Point in this node's parent's coordinate space to move `localRegistrationPoint` to
728
+ * @param localRegistrationPoint - Point in this node's local coordinate space to align with `parentPoint`
729
+ * @example
730
+ * Center a rectangle within its parent artboard:
731
+ * ```
732
+ * rectangle.setPositionInParent(
733
+ * { x: artboard.width / 2, y: artboard.height / 2 },
734
+ * { x: rectangle.width / 2, y: rectangle.height / 2 }
735
+ * );
736
+ * ```
737
+ */
738
+ setPositionInParent(parentPoint: Point, localRegistrationPoint: Point): void;
739
+ /**
740
+ * The node's local rotation angle in degrees, relative to its parent's axes. Use `setRotationInParent` to
741
+ * change rotation by rotating around a defined centerpoint.
742
+ */
743
+ get rotation(): number;
744
+ /**
745
+ * Set the node’s rotation angle relative to its parent to exactly the given value, keeping the given point in the
746
+ * node’s local coordinate space at a fixed location within the parent. Disregards any rotation the node may already
747
+ * have had. The angle set here may not be the absolute rotation angle seen on screen, if the parent or other
748
+ * ancestors have any rotation of their own.
749
+ * @param angleInDegrees - Angle in degrees.
750
+ * @param localRotationPoint - Point to rotate around, in node's local coordinates.
751
+ * @example
752
+ * Rotate the rectangle 45 degrees clockwise around its centerpoint:
753
+ * ```
754
+ * rectangle.setRotationInParent(45, { x: rectangle.width / 2, y: rectangle.height / 2 });
755
+ * ```
756
+ */
757
+ setRotationInParent(angleInDegrees: number, localRotationPoint: Point): void;
758
+ /**
759
+ * The node's total rotation angle in degrees, relative to the overall global view of the document – including any
760
+ * cumulative rotation from the node's parent containers.
761
+ */
762
+ get rotationInScreen(): number;
689
763
  /**
690
764
  * The node's parent. Undefined if the node is an orphan, or if the node is the artwork root.
691
765
  */
@@ -704,11 +778,7 @@ declare class Node {
704
778
  /**
705
779
  * The node's transform matrix relative to its parent.
706
780
  */
707
- get relativeTransform(): mat2d;
708
- /**
709
- * The node's absolute (global) transform matrix.
710
- */
711
- get absoluteTransform(): mat2d;
781
+ get transformMatrix(): mat2d;
712
782
  /**
713
783
  * The node's lock/unlock state. Locked nodes are excluded from the selection (see {@link Context.selection}), and
714
784
  * cannot be edited by the user unless they are unlocked first.
@@ -717,10 +787,10 @@ declare class Node {
717
787
  set locked(locked: boolean);
718
788
  /**
719
789
  * Blend mode determines how a node is composited onto the content below it. The default value is
720
- * {@link BlendModeValue.normal} for most nodes, and {@link BlendModeValue.passThrough} for GroupNodes.
790
+ * {@link BlendMode.normal} for most nodes, and {@link BlendMode.passThrough} for GroupNodes.
721
791
  */
722
- get blendMode(): BlendModeValue;
723
- set blendMode(value: BlendModeValue);
792
+ get blendMode(): BlendMode;
793
+ set blendMode(value: BlendMode);
724
794
  }
725
795
  export { Node as Node };
726
796
 
@@ -732,7 +802,7 @@ export { Node as Node };
732
802
  * PageList also provides APIs for adding/removing pages from the document. PageList is never empty: it is illegal to
733
803
  * remove the last remaining page from the list.
734
804
  */
735
- export declare class PageList extends ReadOnlyItemList<PageNode> {
805
+ export declare class PageList extends RestrictedItemList<PageNode> {
736
806
  /**
737
807
  * Create a new page containing a single empty artboard, and add it to the end of the list. The artboard is configured
738
808
  * with the same defaults as in {@link ArtboardList.addArtboard}. The page's artboard becomes the default target for
@@ -768,6 +838,32 @@ export declare class PageNode extends Node implements Readonly<IRectangularNode>
768
838
  set name(name: string | undefined);
769
839
  }
770
840
 
841
+ /**
842
+ * A PathNode represents a generic vector path shape in the scenegraph. Paths cannot be created or edited through this API
843
+ * yet, only read.
844
+ */
845
+ export declare class PathNode extends FillableNode {
846
+ /**
847
+ * The path definition as an SVG string. The path data is read-only and cannot be modified via this API yet.
848
+ * Example: "M 0 0 L 10 15".
849
+ */
850
+ get path(): string;
851
+ /**
852
+ * The fill rule specifies how the interior area of a path is determined in cases where the path is self-intersecting or
853
+ * has multiple disjoint parts. This value is read-only and cannot be modified via this API yet.
854
+ */
855
+ get fillRule(): FillRule;
856
+ }
857
+
858
+ /**
859
+ * Represents a 2D position.
860
+ * @public
861
+ */
862
+ export declare interface Point {
863
+ x: number;
864
+ y: number;
865
+ }
866
+
771
867
  /**
772
868
  * ReadOnlyItemList represents an ordered list of API objects, representing items that are all children of the
773
869
  * same parent node. (The reverse is not necessarily true, however: this list might not include all
@@ -788,6 +884,11 @@ export declare class ReadOnlyItemList<T extends ListItem> {
788
884
  * Last item in this list, or undefined if list is empty.
789
885
  */
790
886
  get last(): T | undefined;
887
+ /**
888
+ * Get index of item in list.
889
+ * @returns index number, or -1 if item isn't in this list.
890
+ */
891
+ indexOf(item: T): number;
791
892
  /**
792
893
  * Returns item at the given index, or undefined if index is out of range.
793
894
  * @param index - Zero-based index
@@ -875,6 +976,35 @@ export declare class RectangleNode extends FillableNode implements IRectangularN
875
976
  setUniformCornerRadius(radius: number): void;
876
977
  }
877
978
 
979
+ /**
980
+ * Base for ItemLists that have restricted behavior on how items are added to the list,
981
+ * but allow items to be removed and reordered. Subclasses like ItemList may add more
982
+ * capabilities, however.
983
+ */
984
+ declare class RestrictedItemList<T extends ListItem> extends ReadOnlyItemList<T> {
985
+ /**
986
+ * Remove the items from the list. The items need not be contiguous.
987
+ * @throws If any of the items are not in the list, or if it is illegal to remove any of the items from this parent.
988
+ */
989
+ remove(...items: T[]): void;
990
+ /**
991
+ * Move `item` so it is immediately before `before` in this list: places `item` at the index that `before` used
992
+ * to occupy. Depending on the position in the list `item` originally occupied, some other items in the list may
993
+ * shift to higher or lower indices as a result. No-op if both arguments are the same item.
994
+ *
995
+ * @throws An error if either argument is not contained in this list.
996
+ */
997
+ moveBefore(item: T, before: T): void;
998
+ /**
999
+ * Move `item` so it is immediately after `after` in this list: places `item` at the index one higher than `after`.
1000
+ * Depending on the position in the list `item` originally occupied, some other items in the list may shift to higher
1001
+ * or lower indices as a result. No-op if both arguments are the same item.
1002
+ *
1003
+ * @throws An error if either argument is not contained in this list.
1004
+ */
1005
+ moveAfter(item: T, after: T): void;
1006
+ }
1007
+
878
1008
  /**
879
1009
  * <InlineAlert slots="text" variant="warning"/>
880
1010
  * *Do not depend on the literal string values of these constants*, as they may change. Always reference the enum identifiers in your code.
@@ -883,7 +1013,7 @@ export declare class RectangleNode extends FillableNode implements IRectangularN
883
1013
  * *Additional node types may be added in the future.* If your code has different branches or cases depending on node type,
884
1014
  * always have a default/fallback case to handle any unknown values you may encounter.
885
1015
  */
886
- declare enum SceneNodeTypeValueID {
1016
+ declare enum SceneNodeType {
887
1017
  line = "Line",
888
1018
  rectangle = "Rectangle",
889
1019
  ellipse = "Ellipse",
@@ -899,14 +1029,33 @@ declare enum SceneNodeTypeValueID {
899
1029
  /** Type of MediaContainerNode's "media rectangle" child when it is holding an image */
900
1030
  imageRectangle = "ImageRectangle",
901
1031
  /** Type of PageNode */
902
- page = "Page"
1032
+ page = "Page",
1033
+ /** Type of ComplexShapeNode, representing a complex prepackaged shape with fill and stroke, that appears as a leaf node in the UI */
1034
+ complexShape = "ComplexShape",
1035
+ /** Type of SolidColorShapeNode, representing a solid-color prepackaged shape that appears as a leaf node in the UI */
1036
+ solidColorShape = "SolidColorShape",
1037
+ /** Type of StrokeShapeNode, representing a stroke-only prepackaged shape that appears as a leaf node in the UI */
1038
+ strokeShape = "StrokeShape",
1039
+ /** Type of GridLayoutNode represents a grid layout in the scenegraph used to create a layout grid that other content can be placed into */
1040
+ gridLayout = "GridLayout"
1041
+ }
1042
+
1043
+ /**
1044
+ * A SolidColorShapeNode is a prepackaged shape with a single color property that appears as a leaf node in the UI, even if it
1045
+ * is composed of multiple separate paths.
1046
+ */
1047
+ export declare class SolidColorShapeNode extends Node {
1048
+ /**
1049
+ * The color of the single color shape.
1050
+ */
1051
+ get color(): Color | undefined;
1052
+ set color(color: Color | undefined);
903
1053
  }
904
1054
 
905
1055
  /**
906
1056
  * Base class for a Node that can have its own stroke.
907
1057
  */
908
1058
  export declare class StrokableNode extends Node implements IStrokableNode {
909
- static DEFAULT_STROKE_WIDTH: number;
910
1059
  /**
911
1060
  * Any stroke(s) on the shape. Use the methods on this ItemList object to get, add, and remove strokes.
912
1061
  */
@@ -920,7 +1069,7 @@ export declare interface Stroke extends StrokeOptions {
920
1069
  /**
921
1070
  * The position of the stroke relative to the outline of the shape.
922
1071
  */
923
- readonly position: StrokePositionValue;
1072
+ readonly position: StrokePosition;
924
1073
  }
925
1074
 
926
1075
  /**
@@ -953,17 +1102,29 @@ export declare interface StrokeOptions {
953
1102
  *
954
1103
  * A stroke's {@link Stroke.position} determines how the thickness of the stroke is aligned along a shape's path outline.
955
1104
  */
956
- declare enum StrokePositionValue {
1105
+ declare enum StrokePosition {
957
1106
  center = 0,
958
1107
  inside = 1,
959
1108
  outside = 2
960
1109
  }
961
1110
 
1111
+ /**
1112
+ * A StrokeShapeNode is prepackaged shape that has a single stroke property and appears as a leaf node in the UI, even
1113
+ * if it is composed of multiple separate paths.
1114
+ */
1115
+ export declare class StrokeShapeNode extends Node {
1116
+ /**
1117
+ * Stroke on the shape.
1118
+ */
1119
+ get stroke(): Stroke | undefined;
1120
+ set stroke(stroke: Stroke | undefined);
1121
+ }
1122
+
962
1123
  /**
963
1124
  * <InlineAlert slots="text" variant="warning"/>
964
1125
  * *Do not depend on the literal numeric values of these constants*, as they may change. Always reference the enum identifiers in your code.
965
1126
  */
966
- declare enum TextAlignmentValue {
1127
+ declare enum TextAlignment {
967
1128
  left = 1,
968
1129
  right = 2,
969
1130
  center = 3
@@ -981,10 +1142,15 @@ export declare class TextNode extends Node {
981
1142
  /**
982
1143
  * The horizontal text alignment of the text node. Alignment is always the same across this node's entire text content.
983
1144
  */
984
- get textAlignment(): TextAlignmentValue;
985
- set textAlignment(alignment: TextAlignmentValue);
1145
+ get textAlignment(): TextAlignment;
1146
+ set textAlignment(alignment: TextAlignment);
986
1147
  }
987
1148
 
1149
+ /**
1150
+ * An UnknownNode is a node with limited support and therefore treated as a leaf node.
1151
+ */
1152
+ export declare class UnknownNode extends Node {}
1153
+
988
1154
  export declare const utils: ApiUtils;
989
1155
 
990
1156
  export {};
@@ -23,8 +23,8 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  /**
26
- * Here are various global objects and Web APIs available for use in script code.
27
- * Please note, script runtime exposes only a subset of functionalities
26
+ * Here are various global objects and Web APIs available for use in document sandbox code.
27
+ * Please note, document sandbox runtime exposes only a subset of functionalities
28
28
  * exposed by standard Web APIs.
29
29
  */
30
30
  declare global {
@@ -40,11 +40,6 @@ declare global {
40
40
  assert(assertion?: boolean, msg?: string, ...subst: any[]): void;
41
41
  }
42
42
 
43
- function setTimeout(functionRef: Function, delay: number, ...params: any[]): number;
44
- function clearTimeout(timeoutID: number): void;
45
- function setInterval(functionRef: Function, delay: number, ...params: any[]): number;
46
- function clearInterval(intervalID: number): void;
47
-
48
43
  interface Blob {
49
44
  readonly size: number;
50
45
  readonly type: string;
@@ -53,6 +48,10 @@ declare global {
53
48
  text(): Promise<string>;
54
49
  }
55
50
 
51
+ interface BlobPropertyBag {
52
+ type?: string;
53
+ }
54
+
56
55
  var Blob: {
57
56
  prototype: Blob;
58
57
  new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- export * from "./express.js";
25
+ export * from "./express-document-sdk.js";
26
26
  export * from "./global.js";
27
- export * from "./script-sdk.js";
28
- export { default } from "./script-sdk.js";
27
+ export * from "./add-on-sdk-document-sandbox.js";
28
+ export { default } from "./add-on-sdk-document-sandbox.js";
package/ui/ui-sdk.d.ts CHANGED
@@ -22,8 +22,6 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- import { Remote } from "comlink";
26
-
27
25
  /**
28
26
  * Base interface for all type of add-ons
29
27
  */
@@ -134,7 +132,16 @@ export declare enum AppEvent {
134
132
  /**
135
133
  * triggered when drag is complete on the currently dragged element.
136
134
  */
137
- dragend = "dragend"
135
+ dragend = "dragend",
136
+
137
+ /**
138
+ * triggered when the document id is available in the application.
139
+ */
140
+ documentIdAvailable = "documentIdAvailable",
141
+ /**
142
+ * triggered when the document title is changed in the application.
143
+ */
144
+ documentTitleChange = "documentTitleChange"
138
145
  }
139
146
 
140
147
  export declare type AppEventHandlerType<Event extends AppEventType> = (data: AppEventsTypeMap[Event]) => void;
@@ -147,6 +154,9 @@ declare interface AppEventsTypeMap {
147
154
  [AppEvent.localechange]: AppLocaleChangeEventData;
148
155
  [AppEvent.dragstart]: AppDragStartEventData;
149
156
  [AppEvent.dragend]: AppDragEndEventData;
157
+
158
+ [AppEvent.documentIdAvailable]: DocumentIdAvailableEventData;
159
+ [AppEvent.documentTitleChange]: DocumentTitleChangeEventData;
150
160
  }
151
161
 
152
162
  export declare type AppEventType = keyof AppEventsTypeMap & string;
@@ -552,9 +562,31 @@ declare interface Document_2 {
552
562
  * Create renditions
553
563
  */
554
564
  createRenditions(renditionOptions: RenditionOptions, renditionIntent?: RenditionIntent): Promise<Rendition[]>;
565
+ /**
566
+ * Get document id
567
+ */
568
+ id(): Promise<string | undefined>;
569
+ /**
570
+ * Get document name/title
571
+ */
572
+ title(): Promise<string>;
555
573
  }
556
574
  export { Document_2 as Document };
557
575
 
576
+ /**
577
+ * The payload data sent to the document id available event handler.
578
+ */
579
+ declare interface DocumentIdAvailableEventData {
580
+ documentId: string | undefined;
581
+ }
582
+
583
+ /**
584
+ * The payload data sent to the document title change event handler.
585
+ */
586
+ declare interface DocumentTitleChangeEventData {
587
+ documentTitle: string;
588
+ }
589
+
558
590
  /**
559
591
  * Interface to hold various callbacks which are required to be passed to enableDragToDocument.
560
592
  */
@@ -673,11 +705,64 @@ export declare interface JpgRenditionOptions extends RenditionOptions {
673
705
  };
674
706
  }
675
707
 
708
+ /**
709
+ * Takes the raw type of a remote object or function as a remote thread would see it through a proxy (e.g. when
710
+ * passed in as a function argument) and returns the type the local thread has to supply.
711
+ * Creation of new class objects is not allowed.
712
+ *
713
+ * This is the inverse of `Remote<T>`. It takes a `Remote<T>` and returns its original input `T`.
714
+ */
715
+ declare type Local<T> = LocalObject<T> &
716
+ (T extends (...args: infer TArguments) => infer TReturn
717
+ ? (
718
+ ...args: {
719
+ [I in keyof TArguments]: ProxyOrClone<TArguments[I]>;
720
+ }
721
+ ) => MaybePromise<UnproxyOrClone<Unpromisify<TReturn>>>
722
+ : unknown) &
723
+ (T extends {
724
+ new (...args: infer TArguments): infer TInstance;
725
+ }
726
+ ? {
727
+ new: never;
728
+ }
729
+ : unknown);
730
+
676
731
  /**
677
732
  * Placeholder for future localization support
678
733
  */
679
734
  export declare type LocalizedString = string;
680
735
 
736
+ /**
737
+ * Takes the type of an object as a remote thread would see it through a proxy (e.g. when passed in as a function
738
+ * argument) and returns the type that the local thread has to supply.
739
+ *
740
+ * This does not handle call signatures, which is handled by the more general `Local<T>` type.
741
+ *
742
+ * This is the inverse of `RemoteObject<T>`.
743
+ *
744
+ * @template T The type of a proxied object.
745
+ */
746
+ declare type LocalObject<T> = {
747
+ [P in keyof T]: LocalProperty<T[P]>;
748
+ };
749
+
750
+ /**
751
+ * Takes the raw type of a property as a remote thread would see it through a proxy (e.g. when passed in as a function
752
+ * argument) and returns the type that the local thread has to supply.
753
+ *
754
+ * This is the inverse of `RemoteProperty<T>`.
755
+ *
756
+ * Note: This needs to be its own type alias, otherwise it will not distribute over unions. See
757
+ * https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
758
+ */
759
+ declare type LocalProperty<T> = T extends Function | ProxyMarked ? Local<T> : Unpromisify<T>;
760
+
761
+ /**
762
+ * Expresses that a type can be either a sync or async.
763
+ */
764
+ declare type MaybePromise<T> = Promise<T> | T;
765
+
681
766
  /**
682
767
  * Media Attributes for importing media
683
768
  */
@@ -738,6 +823,29 @@ export declare interface PngRenditionOptions extends RenditionOptions {
738
823
  };
739
824
  }
740
825
 
826
+ /**
827
+ * Takes a type and wraps it in a Promise, if it not already is one.
828
+ * This is to avoid `Promise<Promise<T>>`.
829
+ *
830
+ * This is the inverse of `Unpromisify<T>`.
831
+ */
832
+ declare type Promisify<T> = T extends Promise<unknown> ? T : Promise<T>;
833
+
834
+ /**
835
+ * Interface of values that were marked to be proxied with `Runtime.apiProxy()`.
836
+ * Can also be implemented by classes.
837
+ */
838
+ declare interface ProxyMarked {
839
+ [proxyMarker]: true;
840
+ }
841
+
842
+ declare const proxyMarker: unique symbol;
843
+
844
+ /**
845
+ * Proxies `T` if it is a `ProxyMarked`, clones it otherwise (as handled by structured cloning and transfer handlers).
846
+ */
847
+ declare type ProxyOrClone<T> = T extends ProxyMarked ? Remote<T> : T;
848
+
741
849
  /**
742
850
  * Rendition page range
743
851
  */
@@ -753,6 +861,47 @@ declare enum Range_2 {
753
861
  }
754
862
  export { Range_2 as Range };
755
863
 
864
+ /**
865
+ * Takes the raw type of a remote object or function in the other thread and returns the type as it is visible to
866
+ * the local thread from the proxy return value of `Runtime.apiProxy()`.
867
+ * Creation of new class objects is not allowed.
868
+ */
869
+ declare type Remote<T> = RemoteObject<T> &
870
+ (T extends (...args: infer TArguments) => infer TReturn
871
+ ? (
872
+ ...args: {
873
+ [I in keyof TArguments]: UnproxyOrClone<TArguments[I]>;
874
+ }
875
+ ) => Promisify<ProxyOrClone<Unpromisify<TReturn>>>
876
+ : unknown) &
877
+ (T extends {
878
+ new (...args: infer TArguments): infer TInstance;
879
+ }
880
+ ? {
881
+ new: never;
882
+ }
883
+ : unknown);
884
+
885
+ /**
886
+ * Takes the raw type of a remote object in the other thread and returns the type as it is visible to the local thread
887
+ * when proxied with `Runtime.apiProxy()`.
888
+ *
889
+ * This does not handle call signatures, which is handled by the more general `Remote<T>` type.
890
+ *
891
+ * @template T The raw type of a remote object as seen in the other thread.
892
+ */
893
+ declare type RemoteObject<T> = {
894
+ [P in keyof T]: RemoteProperty<T[P]>;
895
+ };
896
+
897
+ /**
898
+ * Takes the raw type of a remote property and returns the type that is visible to the local thread on the proxy.
899
+ *
900
+ * Note: This needs to be its own type alias, otherwise it will not distribute over unions.
901
+ * See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
902
+ */
903
+ declare type RemoteProperty<T> = T extends Function | ProxyMarked ? Remote<T> : Promisify<T>;
904
+
756
905
  export declare interface Rendition {
757
906
  /**
758
907
  * Type of Rendition
@@ -833,14 +982,15 @@ export declare interface Runtime {
833
982
  /**
834
983
  * @experimental - Experimental API
835
984
  * Exposes the concrete object/function of type T,
836
- * which can be accessed into different runtime part of this AddOn e.g., "script" runtime.
985
+ * which can be accessed into different runtime part of this AddOn e.g., "document model sandbox" runtime.
837
986
  * Note that only concrete objects / class instances are supported. We can't expose entire class
838
987
  * from one runtime and create instance of that class in another runtime. Trying to do
839
988
  * so may result in undefined behaviour.
840
989
  * @param apiObj - the concrete object to expose to other runtimes
841
990
  *
842
991
  * Notes:
843
- * 1. This method is only present if this is a panel runtime and it has an associated script runtime.
992
+ * 1. This method is only present if this UI runtime represents panel UI (not RuntimeType.dialog),
993
+ * and the add-on has an associated document model sandbox. The sandbox runtime provides similar method to expose APIs in the other direction.
844
994
  * 2. This method call is allowed only once. Subsequent calls are ignored.
845
995
  */
846
996
  exposeApi?<T>(apiObj: T): void;
@@ -855,7 +1005,8 @@ export declare interface Runtime {
855
1005
  * @see https://github.com/GoogleChromeLabs/comlink/blob/main/src/comlink.ts#L117
856
1006
  *
857
1007
  * Note:
858
- * 1. This method is only present if this is a panel runtime and it has an associated script runtime.
1008
+ * 1. This method is only present if this UI runtime represents panel UI (not RuntimeType.dialog),
1009
+ * and the add-on has an associated document model sandbox. The sandbox runtime provides similar method to get proxy object in the other direction.
859
1010
  * 2. Calling the method again for same runtime type will return a new proxy object without any behavior difference.
860
1011
  */
861
1012
  apiProxy?<T>(runtimeType: RuntimeType): Promise<Remote<T>>;
@@ -871,9 +1022,14 @@ export declare enum RuntimeType {
871
1022
  */
872
1023
  dialog = "dialog",
873
1024
  /**
874
- * Add-On's script runtime - js runtime that hosts the add-ons script / document authoring logic.
1025
+ * @deprecated Use `documentSandbox` instead.
1026
+ * Add-On's document model sandbox - JS runtime that hosts add-on code that has direct access to the full model.
875
1027
  */
876
- script = "script"
1028
+ script = "script",
1029
+ /**
1030
+ * Add-On's document model sandbox - JS runtime that hosts add-on code that has direct access to the full model.
1031
+ */
1032
+ documentSandbox = "documentSandbox"
877
1033
  }
878
1034
 
879
1035
  export declare type SimpleDialogOptions = AlertDialogOptions | InputDialogOptions;
@@ -898,6 +1054,19 @@ export declare interface UI {
898
1054
 
899
1055
  declare type UiTheme = "light" | "dark" | "lightest" | "darkest";
900
1056
 
1057
+ /**
1058
+ * Takes a type that may be Promise and unwraps the Promise type.
1059
+ * If `P` is not a Promise, it returns `P`.
1060
+ *
1061
+ * This is the inverse of `Promisify<T>`.
1062
+ */
1063
+ declare type Unpromisify<P> = P extends Promise<infer T> ? T : P;
1064
+
1065
+ /**
1066
+ * Inverse of `ProxyOrClone<T>`.
1067
+ */
1068
+ declare type UnproxyOrClone<T> = T extends RemoteObject<ProxyMarked> ? Local<T> : T;
1069
+
901
1070
  /**
902
1071
  * Types of dialog variants supported.
903
1072
  */
@@ -1,101 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 Adobe. All rights reserved.
5
-
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- ********************************************************************************/
24
-
25
- import { Remote } from "comlink";
26
-
27
- /**
28
- * Represents the instance of this AddOn.
29
- * The instance contains the necessary details like the associated Runtime etc.
30
- */
31
- export declare class AddOn {
32
- /**
33
- * Get the runtime instance, which represents
34
- * the execution environment for this AddOn.
35
- */
36
- get runtime(): Runtime;
37
- }
38
-
39
- /**
40
- * The APIs provided by AddOn Script SDK.
41
- * The APIs are exposed as an ES6 module.
42
- */
43
- export declare class AddOnScriptSDK {
44
- /**
45
- * Returns the instance of this AddOn.
46
- * @see AddOn
47
- */
48
- get instance(): AddOn;
49
- }
50
-
51
- declare const addOnScriptSdk: AddOnScriptSDK;
52
- export default addOnScriptSdk;
53
-
54
- /**
55
- * The instance of Runtime this AddOn is running into.
56
- * It contains methods to expose APIs from this runtime
57
- * and getting access to APIs exposed by other runtimes.
58
- */
59
- export declare class Runtime {
60
- /**
61
- * The runtime-type of this Runtime.
62
- * Will always be "script".
63
- */
64
- get type(): RuntimeType.script;
65
- /**
66
- * Exposes the concrete object/function of type T,
67
- * which can be accessed into different runtime part of this AddOn e.g., "panel" (iframe) runtime.
68
- * Note that only concrete objects / class instances are supported. We can't expose entire class
69
- * from one runtime and create instance of that class in another runtime. Trying to do
70
- * so may result in undefined behaviour.
71
- * @param obj - the concrete object to expose to other runtimes
72
- * Note: This method call is allowed only once. Subsequent calls are ignored.
73
- */
74
- exposeApi<T>(obj: T): void;
75
- /**
76
- * Requests a promise based proxy object for other runtimes, which will be used
77
- * by this script runtime to directly call the APIs exposed (using exposeApi) from the other runtimes (e.g., UI runtime).
78
- * await or .then is necessary, since returned object is a promise.
79
- * @param runtimeType - the runtime, for which proxy object needs to be created.
80
- * @returns a promise which may resolve to a proxy or reject with rejection reason.
81
- * The promise resolves to API proxy object exposed by desired runtime, as soon as the other runtime is finished initializing.
82
- * Note: Calling the method again for same runtime type will return a new proxy object without any behavior difference.
83
- */
84
- apiProxy(runtimeType: RuntimeType): Promise<Remote<unknown>>;
85
- }
86
-
87
- /**
88
- * Supported runtime types for this AddOn.
89
- */
90
- export declare enum RuntimeType {
91
- /**
92
- * Represents iframe runtime part of this AddOn.
93
- */
94
- panel = "panel",
95
- /**
96
- * Represents Script runtime part of this AddOn.
97
- */
98
- script = "script"
99
- }
100
-
101
- export {};