@adobe/ccweb-add-on-sdk-types 1.0.0 → 1.1.1
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 +2 -2
- package/{add-on-script-sdk.d.ts → add-on-sandbox-sdk.d.ts} +6 -6
- package/index.d.ts +1 -1
- package/package.json +10 -2
- package/sandbox/add-on-sdk-document-sandbox.d.ts +236 -0
- package/{script/express.d.ts → sandbox/express-document-sdk.d.ts} +372 -179
- package/{script → sandbox}/global.d.ts +6 -7
- package/{script → sandbox}/index.d.ts +3 -3
- package/ui/ui-sdk.d.ts +241 -11
- package/script/script-sdk.d.ts +0 -101
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
|
|
16
|
-
- [add-on-
|
|
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 "
|
|
28
|
-
import {
|
|
29
|
-
export default
|
|
30
|
-
export * from "@adobe/ccweb-add-on-sdk-types/
|
|
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/
|
|
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
|
|
25
|
+
export * as AddOnDocumentSandboxSdkTypes from "./sandbox/index.js";
|
|
26
26
|
export * as AddOnUISdkTypes from "./ui/index.js";
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/ccweb-add-on-sdk-types",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"author": "Adobe",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Type definitions for Adobe Creative Cloud Web Add-on SDK.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"adobe",
|
|
9
|
+
"creative cloud web",
|
|
10
|
+
"express",
|
|
11
|
+
"add-on",
|
|
12
|
+
"typescript",
|
|
13
|
+
"sdk",
|
|
14
|
+
"typings"
|
|
15
|
+
],
|
|
7
16
|
"main": "",
|
|
8
17
|
"types": "index.d.ts",
|
|
9
18
|
"repository": {
|
|
@@ -18,7 +27,6 @@
|
|
|
18
27
|
},
|
|
19
28
|
"dependencies": {
|
|
20
29
|
"tslib": "2.4.0",
|
|
21
|
-
"comlink": "4.3.1",
|
|
22
30
|
"gl-matrix": "3.3.0"
|
|
23
31
|
},
|
|
24
32
|
"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 {};
|