@kittl/sdk 0.0.6 → 0.0.8
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 +4 -0
- package/dist/kittl-sdk.esm.js +192 -36
- package/dist/kittl-sdk.js +190 -35
- package/dist/sdk.d.ts +59 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@ Official JavaScript SDK for building apps on [Kittl](https://www.kittl.com).
|
|
|
8
8
|
npm install @kittl/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Backend helpers
|
|
12
|
+
|
|
13
|
+
For server-side token verification in your app backend, use [`@kittl/sdk-backend`](https://www.npmjs.com/package/@kittl/sdk-backend). See the [SDK backend guide](https://sdk-docs.kittl.dev/getting-started/sdk-backend) in the docs.
|
|
14
|
+
|
|
11
15
|
## Documentation
|
|
12
16
|
|
|
13
17
|
Guides and API reference are in the [Kittl SDK documentation](https://sdk-docs.kittl.dev/getting-started/sdk).
|
package/dist/kittl-sdk.esm.js
CHANGED
|
@@ -2,24 +2,93 @@
|
|
|
2
2
|
/*! Kittl SDK - https://kittl.com - see license for terms */
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/shared/commands.js
|
|
6
|
+
var FROM_EXTENSION_COMMANDS = {
|
|
7
|
+
/** SDK API call */
|
|
8
|
+
SDK_CALL: "sdk-call",
|
|
9
|
+
/** AI handler registration */
|
|
10
|
+
AI_REGISTER_HANDLER: "ai-register-handler",
|
|
11
|
+
/** AI handler unregistration */
|
|
12
|
+
AI_UNREGISTER_HANDLER: "ai-unregister-handler",
|
|
13
|
+
/** File browser tab registration */
|
|
14
|
+
FILE_BROWSER_REGISTER: "file-browser-register",
|
|
15
|
+
/** File browser fetch content response */
|
|
16
|
+
FILE_BROWSER_FETCH_CONTENT_RESPONSE: "file-browser-fetch-content-response",
|
|
17
|
+
/** Stateless message send */
|
|
18
|
+
STATELESS_SEND: "stateless-send",
|
|
19
|
+
/** Stateless subscription */
|
|
20
|
+
STATELESS_SUBSCRIBE: "stateless-subscribe",
|
|
21
|
+
/** Stateless unsubscription */
|
|
22
|
+
STATELESS_UNSUBSCRIBE: "stateless-unsubscribe",
|
|
23
|
+
/** App state subscription */
|
|
24
|
+
APP_STATE_SUBSCRIBE: "app-state-subscribe",
|
|
25
|
+
/** App state unsubscription */
|
|
26
|
+
APP_STATE_UNSUBSCRIBE: "app-state-unsubscribe",
|
|
27
|
+
/** Batch creation */
|
|
28
|
+
BATCH_CREATE: "batch-create",
|
|
29
|
+
/** Batch commit */
|
|
30
|
+
BATCH_COMMIT: "batch-commit",
|
|
31
|
+
/** OAuth flow start */
|
|
32
|
+
AUTH_START: "auth-start",
|
|
33
|
+
/** OAuth token exchange */
|
|
34
|
+
AUTH_EXCHANGE: "auth-exchange",
|
|
35
|
+
/** Get OAuth token */
|
|
36
|
+
AUTH_GET_TOKEN: "auth-get-token",
|
|
37
|
+
/** Refresh OAuth token */
|
|
38
|
+
AUTH_REFRESH: "auth-refresh",
|
|
39
|
+
/** OAuth logout */
|
|
40
|
+
AUTH_LOGOUT: "auth-logout",
|
|
41
|
+
/** Get user token for authentication */
|
|
42
|
+
AUTH_GET_USER_TOKEN: "auth-get-user-token",
|
|
43
|
+
/** Context subscription */
|
|
44
|
+
CONTEXT_SUBSCRIBE: "context-subscribe",
|
|
45
|
+
/** Context unsubscription */
|
|
46
|
+
CONTEXT_UNSUBSCRIBE: "context-unsubscribe",
|
|
47
|
+
/** Design state subscription */
|
|
48
|
+
DESIGN_STATE_SUBSCRIBE: "design-state-subscribe",
|
|
49
|
+
/** Design state unsubscription */
|
|
50
|
+
DESIGN_STATE_UNSUBSCRIBE: "design-state-unsubscribe",
|
|
51
|
+
/** Extension loaded notification */
|
|
52
|
+
LOADED: "loaded"
|
|
53
|
+
};
|
|
54
|
+
var TO_EXTENSION_COMMANDS = {
|
|
55
|
+
/** SDK API response */
|
|
56
|
+
SDK_RESPONSE: "sdk-response",
|
|
57
|
+
/** File browser fetch content request */
|
|
58
|
+
FILE_BROWSER_FETCH_CONTENT_REQUEST: "file-browser-fetch-content-request",
|
|
59
|
+
/** Stateless message push */
|
|
60
|
+
STATELESS_MESSAGE: "stateless-message",
|
|
61
|
+
/** Context update push */
|
|
62
|
+
CONTEXT_UPDATE: "context-update",
|
|
63
|
+
/** AI generation update push */
|
|
64
|
+
AI_GENERATION_UPDATE: "ai-generation-update",
|
|
65
|
+
/** Design state update push */
|
|
66
|
+
DESIGN_STATE_UPDATE: "design-state-update",
|
|
67
|
+
/** App state update push */
|
|
68
|
+
APP_STATE_UPDATE: "app-state-update"
|
|
69
|
+
};
|
|
70
|
+
|
|
5
71
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/types/toExtensions.js
|
|
6
72
|
var isSDKResponseMessage = (data) => {
|
|
7
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
73
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.SDK_RESPONSE && "messageId" in data && typeof data.messageId === "string";
|
|
8
74
|
};
|
|
9
75
|
var isStatelessPushMessage = (data) => {
|
|
10
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
76
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.STATELESS_MESSAGE && "type" in data && typeof data.type === "string" && "payload" in data && typeof data.payload === "object" && data.payload !== null;
|
|
11
77
|
};
|
|
12
78
|
var isAIGenerationUpdatePushMessage = (data) => {
|
|
13
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
79
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.AI_GENERATION_UPDATE && "subscriptionId" in data && typeof data.subscriptionId === "string" && "update" in data && typeof data.update === "object" && data.update !== null;
|
|
14
80
|
};
|
|
15
81
|
var isDesignStateUpdatePushMessage = (data) => {
|
|
16
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
82
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.DESIGN_STATE_UPDATE && "updates" in data && Array.isArray(data.updates);
|
|
17
83
|
};
|
|
18
84
|
var isAppStateUpdatePushMessage = (data) => {
|
|
19
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
85
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.APP_STATE_UPDATE && "updates" in data && Array.isArray(data.updates);
|
|
20
86
|
};
|
|
21
87
|
var isContextUpdatePushMessage = (data) => {
|
|
22
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
88
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.CONTEXT_UPDATE && "subscriptionId" in data && typeof data.subscriptionId === "string" && "context" in data && typeof data.context === "object" && data.context !== null;
|
|
89
|
+
};
|
|
90
|
+
var isFileBrowserFetchContentRequestMessage = (data) => {
|
|
91
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_REQUEST && "requestId" in data && typeof data.requestId === "string" && "subscriptionId" in data && typeof data.subscriptionId === "string";
|
|
23
92
|
};
|
|
24
93
|
|
|
25
94
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/shared/createApiProxyCore.js
|
|
@@ -148,56 +217,56 @@ var sendLoaded = () => {
|
|
|
148
217
|
if (!parent || parent === window) {
|
|
149
218
|
return;
|
|
150
219
|
}
|
|
151
|
-
const message = { command:
|
|
220
|
+
const message = { command: FROM_EXTENSION_COMMANDS.LOADED };
|
|
152
221
|
postMessageToParent(message);
|
|
153
222
|
};
|
|
154
223
|
|
|
155
224
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/index.js
|
|
156
225
|
var createSDKCallMessage = {
|
|
157
226
|
ai: (dots, args, messageId) => ({
|
|
158
|
-
command:
|
|
227
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
159
228
|
dots,
|
|
160
229
|
args,
|
|
161
230
|
messageId,
|
|
162
231
|
apiType: "ai"
|
|
163
232
|
}),
|
|
164
233
|
context: (dots, args, messageId) => ({
|
|
165
|
-
command:
|
|
234
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
166
235
|
dots,
|
|
167
236
|
args,
|
|
168
237
|
messageId,
|
|
169
238
|
apiType: "context"
|
|
170
239
|
}),
|
|
171
240
|
design: (dots, args, messageId) => ({
|
|
172
|
-
command:
|
|
241
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
173
242
|
dots,
|
|
174
243
|
args,
|
|
175
244
|
messageId,
|
|
176
245
|
apiType: "design"
|
|
177
246
|
}),
|
|
178
247
|
font: (dots, args, messageId) => ({
|
|
179
|
-
command:
|
|
248
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
180
249
|
dots,
|
|
181
250
|
args,
|
|
182
251
|
messageId,
|
|
183
252
|
apiType: "font"
|
|
184
253
|
}),
|
|
185
254
|
state: (dots, args, messageId) => ({
|
|
186
|
-
command:
|
|
255
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
187
256
|
dots,
|
|
188
257
|
args,
|
|
189
258
|
messageId,
|
|
190
259
|
apiType: "state"
|
|
191
260
|
}),
|
|
192
261
|
upload: (dots, args, messageId) => ({
|
|
193
|
-
command:
|
|
262
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
194
263
|
dots,
|
|
195
264
|
args,
|
|
196
265
|
messageId,
|
|
197
266
|
apiType: "upload"
|
|
198
267
|
}),
|
|
199
268
|
data: (dots, args, messageId) => ({
|
|
200
|
-
command:
|
|
269
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
201
270
|
dots,
|
|
202
271
|
args,
|
|
203
272
|
messageId,
|
|
@@ -237,7 +306,7 @@ function createAIApiProxy() {
|
|
|
237
306
|
generationHandlers.delete(subscriptionId);
|
|
238
307
|
generationSubscriptions.delete(generatorId);
|
|
239
308
|
const unregisterMessage = {
|
|
240
|
-
command:
|
|
309
|
+
command: FROM_EXTENSION_COMMANDS.AI_UNREGISTER_HANDLER,
|
|
241
310
|
generatorId,
|
|
242
311
|
subscriptionId
|
|
243
312
|
};
|
|
@@ -247,7 +316,7 @@ function createAIApiProxy() {
|
|
|
247
316
|
spendCredits: async (options) => {
|
|
248
317
|
const { onAccept, onDecline, ...serializable } = options;
|
|
249
318
|
const message = {
|
|
250
|
-
command:
|
|
319
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
251
320
|
dots: ["spendCredits"],
|
|
252
321
|
args: [serializable],
|
|
253
322
|
messageId: generateMessageId(),
|
|
@@ -263,7 +332,7 @@ function createAIApiProxy() {
|
|
|
263
332
|
},
|
|
264
333
|
startGeneration: (generatorId, inputSettings, output) => {
|
|
265
334
|
const message = {
|
|
266
|
-
command:
|
|
335
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
267
336
|
dots: ["startGeneration"],
|
|
268
337
|
args: [generatorId, inputSettings, output],
|
|
269
338
|
messageId: generateMessageId(),
|
|
@@ -285,7 +354,7 @@ function createAIApiProxy() {
|
|
|
285
354
|
generationHandlers.set(subscriptionId, onStatusUpdate);
|
|
286
355
|
generationSubscriptions.set(generatorId, subscriptionId);
|
|
287
356
|
const registerMessage = {
|
|
288
|
-
command:
|
|
357
|
+
command: FROM_EXTENSION_COMMANDS.AI_REGISTER_HANDLER,
|
|
289
358
|
messageId: generateMessageId(),
|
|
290
359
|
generatorId,
|
|
291
360
|
subscriptionId
|
|
@@ -320,10 +389,87 @@ function createAIApiProxy() {
|
|
|
320
389
|
};
|
|
321
390
|
}
|
|
322
391
|
|
|
392
|
+
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/fileBrowserApiProxy.js
|
|
393
|
+
var fetchContentHandlers = /* @__PURE__ */ new Map();
|
|
394
|
+
var tabIdToSubscriptionId = /* @__PURE__ */ new Map();
|
|
395
|
+
var dispatchFileBrowserFetchContentRequest = (requestId, subscriptionId, params) => {
|
|
396
|
+
const handler = fetchContentHandlers.get(subscriptionId);
|
|
397
|
+
if (!handler) {
|
|
398
|
+
const responseMessage = {
|
|
399
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_RESPONSE,
|
|
400
|
+
requestId,
|
|
401
|
+
content: []
|
|
402
|
+
};
|
|
403
|
+
postMessageToParent(responseMessage);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
void handler(params).then((result) => {
|
|
407
|
+
const responseMessage = {
|
|
408
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_RESPONSE,
|
|
409
|
+
requestId,
|
|
410
|
+
content: result.content,
|
|
411
|
+
next: result.next
|
|
412
|
+
};
|
|
413
|
+
postMessageToParent(responseMessage);
|
|
414
|
+
}).catch((e) => {
|
|
415
|
+
const responseMessage = {
|
|
416
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_RESPONSE,
|
|
417
|
+
requestId,
|
|
418
|
+
content: [],
|
|
419
|
+
error: e instanceof Error ? e.message : "Unknown error"
|
|
420
|
+
};
|
|
421
|
+
postMessageToParent(responseMessage);
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
function createFileBrowserApiProxy() {
|
|
425
|
+
return {
|
|
426
|
+
registerUploadBrowser: async (tab) => {
|
|
427
|
+
const subscriptionId = generateMessageId();
|
|
428
|
+
const existingSubscriptionId = tabIdToSubscriptionId.get(tab.id);
|
|
429
|
+
if (existingSubscriptionId) {
|
|
430
|
+
fetchContentHandlers.delete(existingSubscriptionId);
|
|
431
|
+
}
|
|
432
|
+
fetchContentHandlers.set(subscriptionId, tab.fetchContent);
|
|
433
|
+
tabIdToSubscriptionId.set(tab.id, subscriptionId);
|
|
434
|
+
const registerMessage = {
|
|
435
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_REGISTER,
|
|
436
|
+
messageId: generateMessageId(),
|
|
437
|
+
tabId: tab.id,
|
|
438
|
+
label: tab.label,
|
|
439
|
+
subscriptionId
|
|
440
|
+
};
|
|
441
|
+
try {
|
|
442
|
+
const response = await sendMessage(registerMessage);
|
|
443
|
+
if (!response.isOk) {
|
|
444
|
+
fetchContentHandlers.delete(subscriptionId);
|
|
445
|
+
tabIdToSubscriptionId.delete(tab.id);
|
|
446
|
+
return {
|
|
447
|
+
isOk: false,
|
|
448
|
+
error: response.error
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
isOk: true,
|
|
453
|
+
result: void 0
|
|
454
|
+
};
|
|
455
|
+
} catch {
|
|
456
|
+
fetchContentHandlers.delete(subscriptionId);
|
|
457
|
+
return {
|
|
458
|
+
isOk: false,
|
|
459
|
+
error: {
|
|
460
|
+
message: "Failed to register upload browser",
|
|
461
|
+
name: "SdkInternalError"
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
323
469
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/appState/index.js
|
|
324
470
|
var sendUnsubscribe = (selectorIds) => {
|
|
325
471
|
const message = {
|
|
326
|
-
command:
|
|
472
|
+
command: FROM_EXTENSION_COMMANDS.APP_STATE_UNSUBSCRIBE,
|
|
327
473
|
selectorIds
|
|
328
474
|
};
|
|
329
475
|
postMessageToParent(message);
|
|
@@ -350,7 +496,7 @@ var createAppStateBridgeApi = () => {
|
|
|
350
496
|
}
|
|
351
497
|
const messageId = generateMessageId();
|
|
352
498
|
const subscribeMessage = {
|
|
353
|
-
command:
|
|
499
|
+
command: FROM_EXTENSION_COMMANDS.APP_STATE_SUBSCRIBE,
|
|
354
500
|
messageId,
|
|
355
501
|
selectorIds,
|
|
356
502
|
paths: pathArrays
|
|
@@ -413,7 +559,7 @@ var createAuthBridgeApi = () => {
|
|
|
413
559
|
pkceCode = await hashPKCECode(code_verifier);
|
|
414
560
|
}
|
|
415
561
|
const message = {
|
|
416
|
-
command:
|
|
562
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_START,
|
|
417
563
|
messageId: generateMessageId(),
|
|
418
564
|
state,
|
|
419
565
|
provider: request.provider,
|
|
@@ -439,7 +585,7 @@ var createAuthBridgeApi = () => {
|
|
|
439
585
|
},
|
|
440
586
|
exchangeCode: (request) => {
|
|
441
587
|
const message = {
|
|
442
|
-
command:
|
|
588
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_EXCHANGE,
|
|
443
589
|
messageId: generateMessageId(),
|
|
444
590
|
code: request.code,
|
|
445
591
|
code_verifier: request.code_verifier,
|
|
@@ -451,7 +597,7 @@ var createAuthBridgeApi = () => {
|
|
|
451
597
|
},
|
|
452
598
|
getAuthToken: (request) => {
|
|
453
599
|
const message = {
|
|
454
|
-
command:
|
|
600
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_GET_TOKEN,
|
|
455
601
|
messageId: generateMessageId(),
|
|
456
602
|
provider: request.provider
|
|
457
603
|
};
|
|
@@ -459,7 +605,7 @@ var createAuthBridgeApi = () => {
|
|
|
459
605
|
},
|
|
460
606
|
refreshToken: (request) => {
|
|
461
607
|
const message = {
|
|
462
|
-
command:
|
|
608
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_REFRESH,
|
|
463
609
|
messageId: generateMessageId(),
|
|
464
610
|
provider: request.provider
|
|
465
611
|
};
|
|
@@ -467,7 +613,7 @@ var createAuthBridgeApi = () => {
|
|
|
467
613
|
},
|
|
468
614
|
logout: (request) => {
|
|
469
615
|
const message = {
|
|
470
|
-
command:
|
|
616
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_LOGOUT,
|
|
471
617
|
messageId: generateMessageId(),
|
|
472
618
|
provider: request.provider
|
|
473
619
|
};
|
|
@@ -486,7 +632,7 @@ var createAuthBridgeApi = () => {
|
|
|
486
632
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/batch/index.js
|
|
487
633
|
var createBatch = async () => {
|
|
488
634
|
const response = await sendMessage({
|
|
489
|
-
command:
|
|
635
|
+
command: FROM_EXTENSION_COMMANDS.BATCH_CREATE,
|
|
490
636
|
messageId: generateMessageId()
|
|
491
637
|
});
|
|
492
638
|
if (!response.isOk) {
|
|
@@ -494,7 +640,7 @@ var createBatch = async () => {
|
|
|
494
640
|
}
|
|
495
641
|
const { batchKey } = response.result;
|
|
496
642
|
const sendDesignCall = (dots, args) => sendMessage({
|
|
497
|
-
command:
|
|
643
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
498
644
|
dots,
|
|
499
645
|
args,
|
|
500
646
|
messageId: generateMessageId(),
|
|
@@ -503,7 +649,7 @@ var createBatch = async () => {
|
|
|
503
649
|
});
|
|
504
650
|
const commit = async () => {
|
|
505
651
|
const res = await sendMessage({
|
|
506
|
-
command:
|
|
652
|
+
command: FROM_EXTENSION_COMMANDS.BATCH_COMMIT,
|
|
507
653
|
messageId: generateMessageId(),
|
|
508
654
|
batchKey
|
|
509
655
|
});
|
|
@@ -543,7 +689,7 @@ var createContextBridgeApi = () => {
|
|
|
543
689
|
let response;
|
|
544
690
|
try {
|
|
545
691
|
response = await sendMessage({
|
|
546
|
-
command:
|
|
692
|
+
command: FROM_EXTENSION_COMMANDS.CONTEXT_SUBSCRIBE,
|
|
547
693
|
messageId,
|
|
548
694
|
subscriptionId
|
|
549
695
|
});
|
|
@@ -558,7 +704,7 @@ var createContextBridgeApi = () => {
|
|
|
558
704
|
return () => {
|
|
559
705
|
subscriptionCallbacks.delete(subscriptionId);
|
|
560
706
|
const message = {
|
|
561
|
-
command:
|
|
707
|
+
command: FROM_EXTENSION_COMMANDS.CONTEXT_UNSUBSCRIBE,
|
|
562
708
|
subscriptionId
|
|
563
709
|
};
|
|
564
710
|
postMessageToParent(message);
|
|
@@ -578,7 +724,7 @@ var createContextBridgeApi = () => {
|
|
|
578
724
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/designState/index.js
|
|
579
725
|
var sendUnsubscribe2 = (selectorIds) => {
|
|
580
726
|
const message = {
|
|
581
|
-
command:
|
|
727
|
+
command: FROM_EXTENSION_COMMANDS.DESIGN_STATE_UNSUBSCRIBE,
|
|
582
728
|
selectorIds
|
|
583
729
|
};
|
|
584
730
|
postMessageToParent(message);
|
|
@@ -605,7 +751,7 @@ var createDesignStateBridgeApi = () => {
|
|
|
605
751
|
}
|
|
606
752
|
const messageId = generateMessageId();
|
|
607
753
|
const subscribeMessage = {
|
|
608
|
-
command:
|
|
754
|
+
command: FROM_EXTENSION_COMMANDS.DESIGN_STATE_SUBSCRIBE,
|
|
609
755
|
messageId,
|
|
610
756
|
selectorIds,
|
|
611
757
|
paths: pathArrays
|
|
@@ -649,7 +795,7 @@ var createStatelessBridgeApi = () => {
|
|
|
649
795
|
send: (message) => {
|
|
650
796
|
const messageId = generateMessageId();
|
|
651
797
|
const bridgeMessage = {
|
|
652
|
-
command:
|
|
798
|
+
command: FROM_EXTENSION_COMMANDS.STATELESS_SEND,
|
|
653
799
|
messageId,
|
|
654
800
|
type: message.type,
|
|
655
801
|
payload: message.payload
|
|
@@ -665,7 +811,7 @@ var createStatelessBridgeApi = () => {
|
|
|
665
811
|
handlers.add(handler);
|
|
666
812
|
const messageId = generateMessageId();
|
|
667
813
|
const subscribeMessage = {
|
|
668
|
-
command:
|
|
814
|
+
command: FROM_EXTENSION_COMMANDS.STATELESS_SUBSCRIBE,
|
|
669
815
|
messageId,
|
|
670
816
|
key
|
|
671
817
|
};
|
|
@@ -675,7 +821,7 @@ var createStatelessBridgeApi = () => {
|
|
|
675
821
|
subscribers.delete(key);
|
|
676
822
|
const messageId = generateMessageId();
|
|
677
823
|
const unsubscribeMessage = {
|
|
678
|
-
command:
|
|
824
|
+
command: FROM_EXTENSION_COMMANDS.STATELESS_UNSUBSCRIBE,
|
|
679
825
|
messageId,
|
|
680
826
|
key
|
|
681
827
|
};
|
|
@@ -733,6 +879,14 @@ var handleIncomingMessage = (event) => {
|
|
|
733
879
|
}
|
|
734
880
|
if (isContextUpdatePushMessage(data)) {
|
|
735
881
|
dispatchContextUpdate(data);
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
if (isFileBrowserFetchContentRequestMessage(data)) {
|
|
885
|
+
dispatchFileBrowserFetchContentRequest(
|
|
886
|
+
data.requestId,
|
|
887
|
+
data.subscriptionId,
|
|
888
|
+
data.params
|
|
889
|
+
);
|
|
736
890
|
}
|
|
737
891
|
};
|
|
738
892
|
var bridgeHandlers = {
|
|
@@ -745,6 +899,7 @@ var bridgeHandlers = {
|
|
|
745
899
|
font: createApiProxy("font"),
|
|
746
900
|
state: createApiProxy("state"),
|
|
747
901
|
upload: createApiProxy("upload"),
|
|
902
|
+
fileBrowser: createFileBrowserApiProxy(),
|
|
748
903
|
auth: createAuthBridgeApi(),
|
|
749
904
|
stateless: statelessApi,
|
|
750
905
|
createBatch
|
|
@@ -1078,5 +1233,6 @@ if (typeof document !== "undefined" && typeof window !== "undefined") {
|
|
|
1078
1233
|
}
|
|
1079
1234
|
}
|
|
1080
1235
|
export {
|
|
1081
|
-
kittl
|
|
1236
|
+
kittl,
|
|
1237
|
+
unwrapResult
|
|
1082
1238
|
};
|
package/dist/kittl-sdk.js
CHANGED
|
@@ -3,24 +3,93 @@
|
|
|
3
3
|
|
|
4
4
|
"use strict";
|
|
5
5
|
(() => {
|
|
6
|
+
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/shared/commands.js
|
|
7
|
+
var FROM_EXTENSION_COMMANDS = {
|
|
8
|
+
/** SDK API call */
|
|
9
|
+
SDK_CALL: "sdk-call",
|
|
10
|
+
/** AI handler registration */
|
|
11
|
+
AI_REGISTER_HANDLER: "ai-register-handler",
|
|
12
|
+
/** AI handler unregistration */
|
|
13
|
+
AI_UNREGISTER_HANDLER: "ai-unregister-handler",
|
|
14
|
+
/** File browser tab registration */
|
|
15
|
+
FILE_BROWSER_REGISTER: "file-browser-register",
|
|
16
|
+
/** File browser fetch content response */
|
|
17
|
+
FILE_BROWSER_FETCH_CONTENT_RESPONSE: "file-browser-fetch-content-response",
|
|
18
|
+
/** Stateless message send */
|
|
19
|
+
STATELESS_SEND: "stateless-send",
|
|
20
|
+
/** Stateless subscription */
|
|
21
|
+
STATELESS_SUBSCRIBE: "stateless-subscribe",
|
|
22
|
+
/** Stateless unsubscription */
|
|
23
|
+
STATELESS_UNSUBSCRIBE: "stateless-unsubscribe",
|
|
24
|
+
/** App state subscription */
|
|
25
|
+
APP_STATE_SUBSCRIBE: "app-state-subscribe",
|
|
26
|
+
/** App state unsubscription */
|
|
27
|
+
APP_STATE_UNSUBSCRIBE: "app-state-unsubscribe",
|
|
28
|
+
/** Batch creation */
|
|
29
|
+
BATCH_CREATE: "batch-create",
|
|
30
|
+
/** Batch commit */
|
|
31
|
+
BATCH_COMMIT: "batch-commit",
|
|
32
|
+
/** OAuth flow start */
|
|
33
|
+
AUTH_START: "auth-start",
|
|
34
|
+
/** OAuth token exchange */
|
|
35
|
+
AUTH_EXCHANGE: "auth-exchange",
|
|
36
|
+
/** Get OAuth token */
|
|
37
|
+
AUTH_GET_TOKEN: "auth-get-token",
|
|
38
|
+
/** Refresh OAuth token */
|
|
39
|
+
AUTH_REFRESH: "auth-refresh",
|
|
40
|
+
/** OAuth logout */
|
|
41
|
+
AUTH_LOGOUT: "auth-logout",
|
|
42
|
+
/** Get user token for authentication */
|
|
43
|
+
AUTH_GET_USER_TOKEN: "auth-get-user-token",
|
|
44
|
+
/** Context subscription */
|
|
45
|
+
CONTEXT_SUBSCRIBE: "context-subscribe",
|
|
46
|
+
/** Context unsubscription */
|
|
47
|
+
CONTEXT_UNSUBSCRIBE: "context-unsubscribe",
|
|
48
|
+
/** Design state subscription */
|
|
49
|
+
DESIGN_STATE_SUBSCRIBE: "design-state-subscribe",
|
|
50
|
+
/** Design state unsubscription */
|
|
51
|
+
DESIGN_STATE_UNSUBSCRIBE: "design-state-unsubscribe",
|
|
52
|
+
/** Extension loaded notification */
|
|
53
|
+
LOADED: "loaded"
|
|
54
|
+
};
|
|
55
|
+
var TO_EXTENSION_COMMANDS = {
|
|
56
|
+
/** SDK API response */
|
|
57
|
+
SDK_RESPONSE: "sdk-response",
|
|
58
|
+
/** File browser fetch content request */
|
|
59
|
+
FILE_BROWSER_FETCH_CONTENT_REQUEST: "file-browser-fetch-content-request",
|
|
60
|
+
/** Stateless message push */
|
|
61
|
+
STATELESS_MESSAGE: "stateless-message",
|
|
62
|
+
/** Context update push */
|
|
63
|
+
CONTEXT_UPDATE: "context-update",
|
|
64
|
+
/** AI generation update push */
|
|
65
|
+
AI_GENERATION_UPDATE: "ai-generation-update",
|
|
66
|
+
/** Design state update push */
|
|
67
|
+
DESIGN_STATE_UPDATE: "design-state-update",
|
|
68
|
+
/** App state update push */
|
|
69
|
+
APP_STATE_UPDATE: "app-state-update"
|
|
70
|
+
};
|
|
71
|
+
|
|
6
72
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/types/toExtensions.js
|
|
7
73
|
var isSDKResponseMessage = (data) => {
|
|
8
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
74
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.SDK_RESPONSE && "messageId" in data && typeof data.messageId === "string";
|
|
9
75
|
};
|
|
10
76
|
var isStatelessPushMessage = (data) => {
|
|
11
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
77
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.STATELESS_MESSAGE && "type" in data && typeof data.type === "string" && "payload" in data && typeof data.payload === "object" && data.payload !== null;
|
|
12
78
|
};
|
|
13
79
|
var isAIGenerationUpdatePushMessage = (data) => {
|
|
14
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
80
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.AI_GENERATION_UPDATE && "subscriptionId" in data && typeof data.subscriptionId === "string" && "update" in data && typeof data.update === "object" && data.update !== null;
|
|
15
81
|
};
|
|
16
82
|
var isDesignStateUpdatePushMessage = (data) => {
|
|
17
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
83
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.DESIGN_STATE_UPDATE && "updates" in data && Array.isArray(data.updates);
|
|
18
84
|
};
|
|
19
85
|
var isAppStateUpdatePushMessage = (data) => {
|
|
20
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
86
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.APP_STATE_UPDATE && "updates" in data && Array.isArray(data.updates);
|
|
21
87
|
};
|
|
22
88
|
var isContextUpdatePushMessage = (data) => {
|
|
23
|
-
return typeof data === "object" && data !== null && "command" in data && data.command ===
|
|
89
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.CONTEXT_UPDATE && "subscriptionId" in data && typeof data.subscriptionId === "string" && "context" in data && typeof data.context === "object" && data.context !== null;
|
|
90
|
+
};
|
|
91
|
+
var isFileBrowserFetchContentRequestMessage = (data) => {
|
|
92
|
+
return typeof data === "object" && data !== null && "command" in data && data.command === TO_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_REQUEST && "requestId" in data && typeof data.requestId === "string" && "subscriptionId" in data && typeof data.subscriptionId === "string";
|
|
24
93
|
};
|
|
25
94
|
|
|
26
95
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/shared/createApiProxyCore.js
|
|
@@ -149,56 +218,56 @@
|
|
|
149
218
|
if (!parent || parent === window) {
|
|
150
219
|
return;
|
|
151
220
|
}
|
|
152
|
-
const message = { command:
|
|
221
|
+
const message = { command: FROM_EXTENSION_COMMANDS.LOADED };
|
|
153
222
|
postMessageToParent(message);
|
|
154
223
|
};
|
|
155
224
|
|
|
156
225
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/index.js
|
|
157
226
|
var createSDKCallMessage = {
|
|
158
227
|
ai: (dots, args, messageId) => ({
|
|
159
|
-
command:
|
|
228
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
160
229
|
dots,
|
|
161
230
|
args,
|
|
162
231
|
messageId,
|
|
163
232
|
apiType: "ai"
|
|
164
233
|
}),
|
|
165
234
|
context: (dots, args, messageId) => ({
|
|
166
|
-
command:
|
|
235
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
167
236
|
dots,
|
|
168
237
|
args,
|
|
169
238
|
messageId,
|
|
170
239
|
apiType: "context"
|
|
171
240
|
}),
|
|
172
241
|
design: (dots, args, messageId) => ({
|
|
173
|
-
command:
|
|
242
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
174
243
|
dots,
|
|
175
244
|
args,
|
|
176
245
|
messageId,
|
|
177
246
|
apiType: "design"
|
|
178
247
|
}),
|
|
179
248
|
font: (dots, args, messageId) => ({
|
|
180
|
-
command:
|
|
249
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
181
250
|
dots,
|
|
182
251
|
args,
|
|
183
252
|
messageId,
|
|
184
253
|
apiType: "font"
|
|
185
254
|
}),
|
|
186
255
|
state: (dots, args, messageId) => ({
|
|
187
|
-
command:
|
|
256
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
188
257
|
dots,
|
|
189
258
|
args,
|
|
190
259
|
messageId,
|
|
191
260
|
apiType: "state"
|
|
192
261
|
}),
|
|
193
262
|
upload: (dots, args, messageId) => ({
|
|
194
|
-
command:
|
|
263
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
195
264
|
dots,
|
|
196
265
|
args,
|
|
197
266
|
messageId,
|
|
198
267
|
apiType: "upload"
|
|
199
268
|
}),
|
|
200
269
|
data: (dots, args, messageId) => ({
|
|
201
|
-
command:
|
|
270
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
202
271
|
dots,
|
|
203
272
|
args,
|
|
204
273
|
messageId,
|
|
@@ -238,7 +307,7 @@
|
|
|
238
307
|
generationHandlers.delete(subscriptionId);
|
|
239
308
|
generationSubscriptions.delete(generatorId);
|
|
240
309
|
const unregisterMessage = {
|
|
241
|
-
command:
|
|
310
|
+
command: FROM_EXTENSION_COMMANDS.AI_UNREGISTER_HANDLER,
|
|
242
311
|
generatorId,
|
|
243
312
|
subscriptionId
|
|
244
313
|
};
|
|
@@ -248,7 +317,7 @@
|
|
|
248
317
|
spendCredits: async (options) => {
|
|
249
318
|
const { onAccept, onDecline, ...serializable } = options;
|
|
250
319
|
const message = {
|
|
251
|
-
command:
|
|
320
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
252
321
|
dots: ["spendCredits"],
|
|
253
322
|
args: [serializable],
|
|
254
323
|
messageId: generateMessageId(),
|
|
@@ -264,7 +333,7 @@
|
|
|
264
333
|
},
|
|
265
334
|
startGeneration: (generatorId, inputSettings, output) => {
|
|
266
335
|
const message = {
|
|
267
|
-
command:
|
|
336
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
268
337
|
dots: ["startGeneration"],
|
|
269
338
|
args: [generatorId, inputSettings, output],
|
|
270
339
|
messageId: generateMessageId(),
|
|
@@ -286,7 +355,7 @@
|
|
|
286
355
|
generationHandlers.set(subscriptionId, onStatusUpdate);
|
|
287
356
|
generationSubscriptions.set(generatorId, subscriptionId);
|
|
288
357
|
const registerMessage = {
|
|
289
|
-
command:
|
|
358
|
+
command: FROM_EXTENSION_COMMANDS.AI_REGISTER_HANDLER,
|
|
290
359
|
messageId: generateMessageId(),
|
|
291
360
|
generatorId,
|
|
292
361
|
subscriptionId
|
|
@@ -321,10 +390,87 @@
|
|
|
321
390
|
};
|
|
322
391
|
}
|
|
323
392
|
|
|
393
|
+
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/fileBrowserApiProxy.js
|
|
394
|
+
var fetchContentHandlers = /* @__PURE__ */ new Map();
|
|
395
|
+
var tabIdToSubscriptionId = /* @__PURE__ */ new Map();
|
|
396
|
+
var dispatchFileBrowserFetchContentRequest = (requestId, subscriptionId, params) => {
|
|
397
|
+
const handler = fetchContentHandlers.get(subscriptionId);
|
|
398
|
+
if (!handler) {
|
|
399
|
+
const responseMessage = {
|
|
400
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_RESPONSE,
|
|
401
|
+
requestId,
|
|
402
|
+
content: []
|
|
403
|
+
};
|
|
404
|
+
postMessageToParent(responseMessage);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
void handler(params).then((result) => {
|
|
408
|
+
const responseMessage = {
|
|
409
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_RESPONSE,
|
|
410
|
+
requestId,
|
|
411
|
+
content: result.content,
|
|
412
|
+
next: result.next
|
|
413
|
+
};
|
|
414
|
+
postMessageToParent(responseMessage);
|
|
415
|
+
}).catch((e) => {
|
|
416
|
+
const responseMessage = {
|
|
417
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_FETCH_CONTENT_RESPONSE,
|
|
418
|
+
requestId,
|
|
419
|
+
content: [],
|
|
420
|
+
error: e instanceof Error ? e.message : "Unknown error"
|
|
421
|
+
};
|
|
422
|
+
postMessageToParent(responseMessage);
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
function createFileBrowserApiProxy() {
|
|
426
|
+
return {
|
|
427
|
+
registerUploadBrowser: async (tab) => {
|
|
428
|
+
const subscriptionId = generateMessageId();
|
|
429
|
+
const existingSubscriptionId = tabIdToSubscriptionId.get(tab.id);
|
|
430
|
+
if (existingSubscriptionId) {
|
|
431
|
+
fetchContentHandlers.delete(existingSubscriptionId);
|
|
432
|
+
}
|
|
433
|
+
fetchContentHandlers.set(subscriptionId, tab.fetchContent);
|
|
434
|
+
tabIdToSubscriptionId.set(tab.id, subscriptionId);
|
|
435
|
+
const registerMessage = {
|
|
436
|
+
command: FROM_EXTENSION_COMMANDS.FILE_BROWSER_REGISTER,
|
|
437
|
+
messageId: generateMessageId(),
|
|
438
|
+
tabId: tab.id,
|
|
439
|
+
label: tab.label,
|
|
440
|
+
subscriptionId
|
|
441
|
+
};
|
|
442
|
+
try {
|
|
443
|
+
const response = await sendMessage(registerMessage);
|
|
444
|
+
if (!response.isOk) {
|
|
445
|
+
fetchContentHandlers.delete(subscriptionId);
|
|
446
|
+
tabIdToSubscriptionId.delete(tab.id);
|
|
447
|
+
return {
|
|
448
|
+
isOk: false,
|
|
449
|
+
error: response.error
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
isOk: true,
|
|
454
|
+
result: void 0
|
|
455
|
+
};
|
|
456
|
+
} catch {
|
|
457
|
+
fetchContentHandlers.delete(subscriptionId);
|
|
458
|
+
return {
|
|
459
|
+
isOk: false,
|
|
460
|
+
error: {
|
|
461
|
+
message: "Failed to register upload browser",
|
|
462
|
+
name: "SdkInternalError"
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
324
470
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/appState/index.js
|
|
325
471
|
var sendUnsubscribe = (selectorIds) => {
|
|
326
472
|
const message = {
|
|
327
|
-
command:
|
|
473
|
+
command: FROM_EXTENSION_COMMANDS.APP_STATE_UNSUBSCRIBE,
|
|
328
474
|
selectorIds
|
|
329
475
|
};
|
|
330
476
|
postMessageToParent(message);
|
|
@@ -351,7 +497,7 @@
|
|
|
351
497
|
}
|
|
352
498
|
const messageId = generateMessageId();
|
|
353
499
|
const subscribeMessage = {
|
|
354
|
-
command:
|
|
500
|
+
command: FROM_EXTENSION_COMMANDS.APP_STATE_SUBSCRIBE,
|
|
355
501
|
messageId,
|
|
356
502
|
selectorIds,
|
|
357
503
|
paths: pathArrays
|
|
@@ -414,7 +560,7 @@
|
|
|
414
560
|
pkceCode = await hashPKCECode(code_verifier);
|
|
415
561
|
}
|
|
416
562
|
const message = {
|
|
417
|
-
command:
|
|
563
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_START,
|
|
418
564
|
messageId: generateMessageId(),
|
|
419
565
|
state,
|
|
420
566
|
provider: request.provider,
|
|
@@ -440,7 +586,7 @@
|
|
|
440
586
|
},
|
|
441
587
|
exchangeCode: (request) => {
|
|
442
588
|
const message = {
|
|
443
|
-
command:
|
|
589
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_EXCHANGE,
|
|
444
590
|
messageId: generateMessageId(),
|
|
445
591
|
code: request.code,
|
|
446
592
|
code_verifier: request.code_verifier,
|
|
@@ -452,7 +598,7 @@
|
|
|
452
598
|
},
|
|
453
599
|
getAuthToken: (request) => {
|
|
454
600
|
const message = {
|
|
455
|
-
command:
|
|
601
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_GET_TOKEN,
|
|
456
602
|
messageId: generateMessageId(),
|
|
457
603
|
provider: request.provider
|
|
458
604
|
};
|
|
@@ -460,7 +606,7 @@
|
|
|
460
606
|
},
|
|
461
607
|
refreshToken: (request) => {
|
|
462
608
|
const message = {
|
|
463
|
-
command:
|
|
609
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_REFRESH,
|
|
464
610
|
messageId: generateMessageId(),
|
|
465
611
|
provider: request.provider
|
|
466
612
|
};
|
|
@@ -468,7 +614,7 @@
|
|
|
468
614
|
},
|
|
469
615
|
logout: (request) => {
|
|
470
616
|
const message = {
|
|
471
|
-
command:
|
|
617
|
+
command: FROM_EXTENSION_COMMANDS.AUTH_LOGOUT,
|
|
472
618
|
messageId: generateMessageId(),
|
|
473
619
|
provider: request.provider
|
|
474
620
|
};
|
|
@@ -487,7 +633,7 @@
|
|
|
487
633
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/batch/index.js
|
|
488
634
|
var createBatch = async () => {
|
|
489
635
|
const response = await sendMessage({
|
|
490
|
-
command:
|
|
636
|
+
command: FROM_EXTENSION_COMMANDS.BATCH_CREATE,
|
|
491
637
|
messageId: generateMessageId()
|
|
492
638
|
});
|
|
493
639
|
if (!response.isOk) {
|
|
@@ -495,7 +641,7 @@
|
|
|
495
641
|
}
|
|
496
642
|
const { batchKey } = response.result;
|
|
497
643
|
const sendDesignCall = (dots, args) => sendMessage({
|
|
498
|
-
command:
|
|
644
|
+
command: FROM_EXTENSION_COMMANDS.SDK_CALL,
|
|
499
645
|
dots,
|
|
500
646
|
args,
|
|
501
647
|
messageId: generateMessageId(),
|
|
@@ -504,7 +650,7 @@
|
|
|
504
650
|
});
|
|
505
651
|
const commit = async () => {
|
|
506
652
|
const res = await sendMessage({
|
|
507
|
-
command:
|
|
653
|
+
command: FROM_EXTENSION_COMMANDS.BATCH_COMMIT,
|
|
508
654
|
messageId: generateMessageId(),
|
|
509
655
|
batchKey
|
|
510
656
|
});
|
|
@@ -544,7 +690,7 @@
|
|
|
544
690
|
let response;
|
|
545
691
|
try {
|
|
546
692
|
response = await sendMessage({
|
|
547
|
-
command:
|
|
693
|
+
command: FROM_EXTENSION_COMMANDS.CONTEXT_SUBSCRIBE,
|
|
548
694
|
messageId,
|
|
549
695
|
subscriptionId
|
|
550
696
|
});
|
|
@@ -559,7 +705,7 @@
|
|
|
559
705
|
return () => {
|
|
560
706
|
subscriptionCallbacks.delete(subscriptionId);
|
|
561
707
|
const message = {
|
|
562
|
-
command:
|
|
708
|
+
command: FROM_EXTENSION_COMMANDS.CONTEXT_UNSUBSCRIBE,
|
|
563
709
|
subscriptionId
|
|
564
710
|
};
|
|
565
711
|
postMessageToParent(message);
|
|
@@ -579,7 +725,7 @@
|
|
|
579
725
|
// ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/designState/index.js
|
|
580
726
|
var sendUnsubscribe2 = (selectorIds) => {
|
|
581
727
|
const message = {
|
|
582
|
-
command:
|
|
728
|
+
command: FROM_EXTENSION_COMMANDS.DESIGN_STATE_UNSUBSCRIBE,
|
|
583
729
|
selectorIds
|
|
584
730
|
};
|
|
585
731
|
postMessageToParent(message);
|
|
@@ -606,7 +752,7 @@
|
|
|
606
752
|
}
|
|
607
753
|
const messageId = generateMessageId();
|
|
608
754
|
const subscribeMessage = {
|
|
609
|
-
command:
|
|
755
|
+
command: FROM_EXTENSION_COMMANDS.DESIGN_STATE_SUBSCRIBE,
|
|
610
756
|
messageId,
|
|
611
757
|
selectorIds,
|
|
612
758
|
paths: pathArrays
|
|
@@ -650,7 +796,7 @@
|
|
|
650
796
|
send: (message) => {
|
|
651
797
|
const messageId = generateMessageId();
|
|
652
798
|
const bridgeMessage = {
|
|
653
|
-
command:
|
|
799
|
+
command: FROM_EXTENSION_COMMANDS.STATELESS_SEND,
|
|
654
800
|
messageId,
|
|
655
801
|
type: message.type,
|
|
656
802
|
payload: message.payload
|
|
@@ -666,7 +812,7 @@
|
|
|
666
812
|
handlers.add(handler);
|
|
667
813
|
const messageId = generateMessageId();
|
|
668
814
|
const subscribeMessage = {
|
|
669
|
-
command:
|
|
815
|
+
command: FROM_EXTENSION_COMMANDS.STATELESS_SUBSCRIBE,
|
|
670
816
|
messageId,
|
|
671
817
|
key
|
|
672
818
|
};
|
|
@@ -676,7 +822,7 @@
|
|
|
676
822
|
subscribers.delete(key);
|
|
677
823
|
const messageId = generateMessageId();
|
|
678
824
|
const unsubscribeMessage = {
|
|
679
|
-
command:
|
|
825
|
+
command: FROM_EXTENSION_COMMANDS.STATELESS_UNSUBSCRIBE,
|
|
680
826
|
messageId,
|
|
681
827
|
key
|
|
682
828
|
};
|
|
@@ -734,6 +880,14 @@
|
|
|
734
880
|
}
|
|
735
881
|
if (isContextUpdatePushMessage(data)) {
|
|
736
882
|
dispatchContextUpdate(data);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
if (isFileBrowserFetchContentRequestMessage(data)) {
|
|
886
|
+
dispatchFileBrowserFetchContentRequest(
|
|
887
|
+
data.requestId,
|
|
888
|
+
data.subscriptionId,
|
|
889
|
+
data.params
|
|
890
|
+
);
|
|
737
891
|
}
|
|
738
892
|
};
|
|
739
893
|
var bridgeHandlers = {
|
|
@@ -746,6 +900,7 @@
|
|
|
746
900
|
font: createApiProxy("font"),
|
|
747
901
|
state: createApiProxy("state"),
|
|
748
902
|
upload: createApiProxy("upload"),
|
|
903
|
+
fileBrowser: createFileBrowserApiProxy(),
|
|
749
904
|
auth: createAuthBridgeApi(),
|
|
750
905
|
stateless: statelessApi,
|
|
751
906
|
createBatch
|
package/dist/sdk.d.ts
CHANGED
|
@@ -546,6 +546,7 @@ declare global {
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
export declare const kittl: KittlSDK;
|
|
549
|
+
export declare function unwrapResult<T>(result: SdkResult<T, Error>): T;
|
|
549
550
|
export interface AIGenerationInputSettings {
|
|
550
551
|
prompt: string;
|
|
551
552
|
taskType?: AIGenerationModelTaskType;
|
|
@@ -566,7 +567,7 @@ export interface AIGenerationOutputSettings {
|
|
|
566
567
|
}
|
|
567
568
|
export interface AddFontStyleOptions {
|
|
568
569
|
fontFamilyId: string;
|
|
569
|
-
|
|
570
|
+
files: Blob[];
|
|
570
571
|
styles: string[];
|
|
571
572
|
}
|
|
572
573
|
export interface AppStateAPI {
|
|
@@ -818,6 +819,10 @@ export interface DecorationOptions {
|
|
|
818
819
|
distance: number;
|
|
819
820
|
cutDistance: number;
|
|
820
821
|
}
|
|
822
|
+
export interface DeleteFontStyleOptions {
|
|
823
|
+
fontFamilyId: string;
|
|
824
|
+
id: string;
|
|
825
|
+
}
|
|
821
826
|
export interface DesignAPI {
|
|
822
827
|
shape: ShapeAPI;
|
|
823
828
|
board: BoardAPI;
|
|
@@ -878,6 +883,9 @@ export interface ErrorGenerationResult {
|
|
|
878
883
|
subtitle: string;
|
|
879
884
|
status: "warning" | "error";
|
|
880
885
|
}
|
|
886
|
+
export interface FileBrowserAPI {
|
|
887
|
+
registerUploadBrowser: (tab: FileBrowserTab) => Promise<SdkResponse<void>>;
|
|
888
|
+
}
|
|
881
889
|
export interface FontAPI {
|
|
882
890
|
createFont: (params: {
|
|
883
891
|
name: string;
|
|
@@ -897,6 +905,7 @@ export interface FontDataAPI {
|
|
|
897
905
|
destroy(ids: string[]): SdkResultAsync<void>;
|
|
898
906
|
addStyle(options: AddFontStyleOptions): SdkResultAsync<FontFamilyDto>;
|
|
899
907
|
updateStyle(options: UpdateFontStyleOptions): SdkResultAsync<void>;
|
|
908
|
+
deleteStyle(options: DeleteFontStyleOptions): SdkResultAsync<void>;
|
|
900
909
|
}
|
|
901
910
|
export interface FontFamilyDto extends CatalogItem {
|
|
902
911
|
styles: FontStyleDto[];
|
|
@@ -910,6 +919,7 @@ export interface FontStyleDto {
|
|
|
910
919
|
id: string;
|
|
911
920
|
name: string;
|
|
912
921
|
style: string | null;
|
|
922
|
+
deletedAt: string | null;
|
|
913
923
|
}
|
|
914
924
|
export interface FontVariation {
|
|
915
925
|
name: string;
|
|
@@ -927,6 +937,10 @@ export interface GeneratableObject {
|
|
|
927
937
|
generatorKey: string;
|
|
928
938
|
};
|
|
929
939
|
}
|
|
940
|
+
export interface GenerationCreditUse {
|
|
941
|
+
amount: number;
|
|
942
|
+
refunded: number;
|
|
943
|
+
}
|
|
930
944
|
export interface GenerationInputData {
|
|
931
945
|
prompt?: string;
|
|
932
946
|
style?: {
|
|
@@ -1062,6 +1076,7 @@ export interface KittlSDK {
|
|
|
1062
1076
|
state: AsyncAppStateAPI;
|
|
1063
1077
|
auth: AsyncAuthAPI;
|
|
1064
1078
|
upload: AsyncUploadAPI;
|
|
1079
|
+
fileBrowser: FileBrowserAPI;
|
|
1065
1080
|
stateless: AsyncStatelessAPI;
|
|
1066
1081
|
font: AsyncFontAPI;
|
|
1067
1082
|
createBatch: () => Promise<AsyncBatchDesignAPI>;
|
|
@@ -1370,7 +1385,7 @@ export interface WithObjectLayout {
|
|
|
1370
1385
|
}
|
|
1371
1386
|
export type AIGenerationActionOrigin = "COPILOT" | "RIGHT_PANEL" | "LEFT_PANEL" | "MICRO_APP" | "IMAGE_SETS" | "AI_CHAT" | "SMARTBOARD" | "AI_INPUT_GENERATE_IMAGE" | "AI_INPUT_REMIX_IMAGE" | "AI_INPUT_GENERATE_VIDEO" | "AI_HUB_GENERATE_IMAGE" | "AI_HUB_REMIX_IMAGE" | "AI_HUB_GENERATE_VIDEO" | "VIDEOBOARD" | "AGENT" | "WORKFLOW";
|
|
1372
1387
|
export type AIGenerationContentType = "image" | "video";
|
|
1373
|
-
export type AIGenerationModelTaskType = "IMAGE_TO_IMAGE" | "IMAGE_INPAINT" | "TEXT_TO_IMAGE" | "IMAGE_TO_VIDEO";
|
|
1388
|
+
export type AIGenerationModelTaskType = "IMAGE_TO_IMAGE" | "IMAGE_INPAINT" | "IMAGE_OUTPAINT" | "TEXT_TO_IMAGE" | "IMAGE_TO_VIDEO";
|
|
1374
1389
|
export type APIOptions<T extends Record<string, unknown>> = {
|
|
1375
1390
|
batchClient?: BatchClient<T>;
|
|
1376
1391
|
} | {
|
|
@@ -1606,6 +1621,37 @@ export type ElementLocation = "origin" | "center";
|
|
|
1606
1621
|
export type Expand<T> = T extends infer O ? {
|
|
1607
1622
|
[K in keyof O]: O[K];
|
|
1608
1623
|
} : never;
|
|
1624
|
+
export type FileBrowserContent = FileBrowserItem | FileBrowserFolder;
|
|
1625
|
+
export type FileBrowserFetchContentParams = {
|
|
1626
|
+
id?: string;
|
|
1627
|
+
next?: string | number;
|
|
1628
|
+
};
|
|
1629
|
+
export type FileBrowserFetchContentResult = {
|
|
1630
|
+
content: FileBrowserContent[];
|
|
1631
|
+
next?: string | number;
|
|
1632
|
+
error?: string;
|
|
1633
|
+
};
|
|
1634
|
+
export type FileBrowserFolder = {
|
|
1635
|
+
type: "folder";
|
|
1636
|
+
label: string;
|
|
1637
|
+
id: string;
|
|
1638
|
+
preview?: string;
|
|
1639
|
+
content?: Array<FileBrowserContent>;
|
|
1640
|
+
};
|
|
1641
|
+
export type FileBrowserItem = {
|
|
1642
|
+
type: "item";
|
|
1643
|
+
label: string;
|
|
1644
|
+
id: string;
|
|
1645
|
+
preview?: string;
|
|
1646
|
+
content: {
|
|
1647
|
+
data: string;
|
|
1648
|
+
};
|
|
1649
|
+
};
|
|
1650
|
+
export type FileBrowserTab = {
|
|
1651
|
+
id: string;
|
|
1652
|
+
label: string;
|
|
1653
|
+
fetchContent: (params?: FileBrowserFetchContentParams) => Promise<FileBrowserFetchContentResult>;
|
|
1654
|
+
};
|
|
1609
1655
|
export type FillMetaTarget = "border" | "fill";
|
|
1610
1656
|
export type FlattenUnion<T> = UnionToIntersection<T extends unknown ? Partial<T> : never>;
|
|
1611
1657
|
export type FontListDto = PaginatedResult<FontFamilyDto>;
|
|
@@ -1623,21 +1669,25 @@ export type GenerationStatusUpdate = {
|
|
|
1623
1669
|
generationId: string;
|
|
1624
1670
|
status: typeof GenerationStatus.CREATED;
|
|
1625
1671
|
inputData: undefined;
|
|
1672
|
+
creditUse: undefined;
|
|
1626
1673
|
result: undefined;
|
|
1627
1674
|
} | {
|
|
1628
1675
|
generationId: string;
|
|
1629
1676
|
status: typeof GenerationStatus.STARTED;
|
|
1630
1677
|
inputData: GenerationInputData;
|
|
1678
|
+
creditUse?: GenerationCreditUse;
|
|
1631
1679
|
result: StartedGenerationResult;
|
|
1632
1680
|
} | {
|
|
1633
1681
|
generationId: string;
|
|
1634
1682
|
status: typeof GenerationStatus.COMPLETE;
|
|
1635
1683
|
inputData: GenerationInputData;
|
|
1684
|
+
creditUse?: GenerationCreditUse;
|
|
1636
1685
|
result: SuccessGenerationResult;
|
|
1637
1686
|
} | {
|
|
1638
1687
|
generationId: string;
|
|
1639
1688
|
status: typeof GenerationStatus.FAILED;
|
|
1640
1689
|
inputData: GenerationInputData | undefined;
|
|
1690
|
+
creditUse?: GenerationCreditUse;
|
|
1641
1691
|
result: ErrorGenerationResult;
|
|
1642
1692
|
};
|
|
1643
1693
|
export type GuideSerializedObject = typeof GUIDE_DEFAULT_VALUES & OrientationDir;
|
|
@@ -1988,6 +2038,13 @@ export type ScreenCoordinates = {
|
|
|
1988
2038
|
y: number;
|
|
1989
2039
|
};
|
|
1990
2040
|
export type SdkError = SdkBadInputError | SdkInternalError;
|
|
2041
|
+
export type SdkResponse<T> = {
|
|
2042
|
+
isOk: true;
|
|
2043
|
+
result: T;
|
|
2044
|
+
} | {
|
|
2045
|
+
isOk: false;
|
|
2046
|
+
error: Error;
|
|
2047
|
+
};
|
|
1991
2048
|
export type SdkResult<T, E = SdkError> = {
|
|
1992
2049
|
isOk: true;
|
|
1993
2050
|
result: T;
|