@kittl/sdk 0.0.1 → 0.0.3

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.
@@ -9,6 +9,15 @@ var isSDKResponseMessage = (data) => {
9
9
  var isStatelessPushMessage = (data) => {
10
10
  return typeof data === "object" && data !== null && "command" in data && data.command === "stateless-message" && "type" in data && typeof data.type === "string" && "payload" in data && typeof data.payload === "object" && data.payload !== null;
11
11
  };
12
+ var isAIGenerationUpdatePushMessage = (data) => {
13
+ return typeof data === "object" && data !== null && "command" in data && data.command === "ai-generation-update" && "subscriptionId" in data && typeof data.subscriptionId === "string" && "update" in data && typeof data.update === "object" && data.update !== null;
14
+ };
15
+ var isDesignStateUpdatePushMessage = (data) => {
16
+ return typeof data === "object" && data !== null && "command" in data && data.command === "design-state-update" && "updates" in data && Array.isArray(data.updates);
17
+ };
18
+ var isAppStateUpdatePushMessage = (data) => {
19
+ return typeof data === "object" && data !== null && "command" in data && data.command === "app-state-update" && "updates" in data && Array.isArray(data.updates);
20
+ };
12
21
 
13
22
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/shared/createApiProxyCore.js
14
23
  var buildMethodPath = (rootPrefix, pathSegments) => {
@@ -117,8 +126,11 @@ var generateMessageId = () => {
117
126
  }
118
127
  return Math.random().toString(36).substring(7);
119
128
  };
120
- var sendMessage = (message) => {
129
+ var postMessageToParent = (message) => {
121
130
  window.parent.postMessage(message, getParentDomain());
131
+ };
132
+ var sendMessage = (message) => {
133
+ postMessageToParent(message);
122
134
  return new Promise((resolve, reject) => {
123
135
  pendingRequests.set(message.messageId, {
124
136
  resolve: (value) => {
@@ -134,7 +146,7 @@ var sendLoaded = () => {
134
146
  return;
135
147
  }
136
148
  const message = { command: "loaded" };
137
- parent.postMessage(message, getParentDomain());
149
+ postMessageToParent(message);
138
150
  };
139
151
 
140
152
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/index.js
@@ -197,6 +209,14 @@ function createApiProxy(apiType) {
197
209
  }
198
210
 
199
211
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/aiApiProxy.js
212
+ var generationHandlers = /* @__PURE__ */ new Map();
213
+ var dispatchAIGenerationUpdate = (subscriptionId, update) => {
214
+ const handler = generationHandlers.get(subscriptionId);
215
+ if (!handler) {
216
+ return;
217
+ }
218
+ void handler(update);
219
+ };
200
220
  function createAIApiProxy() {
201
221
  return {
202
222
  spendCredits: async (options) => {
@@ -215,10 +235,120 @@ function createAIApiProxy() {
215
235
  onDecline?.();
216
236
  }
217
237
  return response;
238
+ },
239
+ startGeneration: (generatorId, inputSettings, output) => {
240
+ const message = {
241
+ command: "sdk-call",
242
+ dots: ["startGeneration"],
243
+ args: [generatorId, inputSettings, output],
244
+ messageId: generateMessageId(),
245
+ apiType: "ai"
246
+ };
247
+ return sendMessage(message);
248
+ },
249
+ registerHandler: async (generatorId, onStatusUpdate) => {
250
+ const subscriptionId = generateMessageId();
251
+ const unregister = () => {
252
+ generationHandlers.delete(subscriptionId);
253
+ const unregisterMessage = {
254
+ command: "ai-unregister-handler",
255
+ subscriptionId
256
+ };
257
+ postMessageToParent(unregisterMessage);
258
+ };
259
+ generationHandlers.set(subscriptionId, onStatusUpdate);
260
+ const registerMessage = {
261
+ command: "ai-register-handler",
262
+ messageId: generateMessageId(),
263
+ generatorId,
264
+ subscriptionId
265
+ };
266
+ try {
267
+ const response = await sendMessage(registerMessage);
268
+ if (!response.isOk) {
269
+ generationHandlers.delete(subscriptionId);
270
+ return response;
271
+ }
272
+ return { isOk: true, result: unregister };
273
+ } catch {
274
+ generationHandlers.delete(subscriptionId);
275
+ return {
276
+ isOk: false,
277
+ error: {
278
+ message: "Failed to register AI handler",
279
+ name: "SdkInternalError"
280
+ }
281
+ };
282
+ }
218
283
  }
219
284
  };
220
285
  }
221
286
 
287
+ // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/appState/index.js
288
+ var sendUnsubscribe = (selectorIds) => {
289
+ const message = {
290
+ command: "app-state-unsubscribe",
291
+ selectorIds
292
+ };
293
+ postMessageToParent(message);
294
+ };
295
+ var createAppStateBridgeApi = () => {
296
+ const localSubscriptions = /* @__PURE__ */ new Map();
297
+ async function subscribe(paths, callback) {
298
+ if (paths.length === 0) {
299
+ return () => {
300
+ };
301
+ }
302
+ const values = new Array(paths.length).fill(void 0);
303
+ const selectorIds = [];
304
+ const pathArrays = [];
305
+ for (const dotPath of paths) {
306
+ const segments = dotPath.split(".");
307
+ if (segments.some((s) => s === "")) {
308
+ throw new Error(
309
+ `Invalid app state path: '${dotPath}'. Path must be a non-empty dot-separated string.`
310
+ );
311
+ }
312
+ selectorIds.push(generateMessageId());
313
+ pathArrays.push(segments);
314
+ }
315
+ const messageId = generateMessageId();
316
+ const subscribeMessage = {
317
+ command: "app-state-subscribe",
318
+ messageId,
319
+ selectorIds,
320
+ paths: pathArrays
321
+ };
322
+ const response = await sendMessage(subscribeMessage);
323
+ if (!response.isOk) {
324
+ throw new Error(`app-state-subscribe failed: ${response.error.message}`);
325
+ }
326
+ for (let i = 0; i < selectorIds.length; i++) {
327
+ localSubscriptions.set(selectorIds[i], {
328
+ callback: (value) => {
329
+ values[i] = value;
330
+ callback(...values);
331
+ }
332
+ });
333
+ }
334
+ return () => {
335
+ for (const selectorId of selectorIds) {
336
+ localSubscriptions.delete(selectorId);
337
+ }
338
+ sendUnsubscribe(selectorIds);
339
+ };
340
+ }
341
+ const dispatch = (updates) => {
342
+ for (const { selectorId, value } of updates) {
343
+ const entry = localSubscriptions.get(selectorId);
344
+ if (entry) {
345
+ entry.callback(value);
346
+ }
347
+ }
348
+ };
349
+ return { subscribe, dispatch };
350
+ };
351
+
222
352
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/authBridge/index.js
223
353
  var hashPKCECode = async (input) => {
224
354
  const textAsBuffer = new TextEncoder().encode(input);
@@ -311,6 +441,118 @@ var createAuthBridgeApi = () => {
311
441
  };
312
442
  };
313
443
 
444
+ // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/batch/index.js
445
+ var createBatch = async () => {
446
+ const response = await sendMessage({
447
+ command: "batch-create",
448
+ messageId: generateMessageId()
449
+ });
450
+ if (!response.isOk) {
451
+ throw response.error;
452
+ }
453
+ const { batchKey } = response.result;
454
+ const sendDesignCall = (dots, args) => sendMessage({
455
+ command: "sdk-call",
456
+ dots,
457
+ args,
458
+ messageId: generateMessageId(),
459
+ apiType: "design",
460
+ batchKey
461
+ });
462
+ const commit = async () => {
463
+ const res = await sendMessage({
464
+ command: "batch-commit",
465
+ messageId: generateMessageId(),
466
+ batchKey
467
+ });
468
+ if (!res.isOk) {
469
+ throw res.error;
470
+ }
471
+ };
472
+ const buildNode = (pathSegments) => {
473
+ const target = () => {
474
+ };
475
+ return new Proxy(target, {
476
+ get: (_t, prop) => {
477
+ if (typeof prop === "symbol" || prop === "then") return void 0;
478
+ if (prop === "commit") return commit;
479
+ return buildNode([...pathSegments, prop]);
480
+ },
481
+ apply: (_t, _this, args) => {
482
+ return sendDesignCall(pathSegments, args);
483
+ }
484
+ });
485
+ };
486
+ return buildNode([]);
487
+ };
488
+
489
+ // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/designState/index.js
490
+ var sendUnsubscribe2 = (selectorIds) => {
491
+ const message = {
492
+ command: "design-state-unsubscribe",
493
+ selectorIds
494
+ };
495
+ postMessageToParent(message);
496
+ };
497
+ var createDesignStateBridgeApi = () => {
498
+ const localSubscriptions = /* @__PURE__ */ new Map();
499
+ async function subscribe(paths, callback) {
500
+ if (paths.length === 0) {
501
+ return () => {
502
+ };
503
+ }
504
+ const values = new Array(paths.length).fill(void 0);
505
+ const selectorIds = [];
506
+ const pathArrays = [];
507
+ for (const dotPath of paths) {
508
+ const segments = dotPath.split(".");
509
+ if (segments.some((s) => s === "")) {
510
+ throw new Error(
511
+ `Invalid design state path: '${dotPath}'. Path must be a non-empty dot-separated string.`
512
+ );
513
+ }
514
+ selectorIds.push(generateMessageId());
515
+ pathArrays.push(segments);
516
+ }
517
+ const messageId = generateMessageId();
518
+ const subscribeMessage = {
519
+ command: "design-state-subscribe",
520
+ messageId,
521
+ selectorIds,
522
+ paths: pathArrays
523
+ };
524
+ const response = await sendMessage(subscribeMessage);
525
+ if (!response.isOk) {
526
+ throw new Error(
527
+ `design-state-subscribe failed: ${response.error.message}`
528
+ );
529
+ }
530
+ for (let i = 0; i < selectorIds.length; i++) {
531
+ localSubscriptions.set(selectorIds[i], {
532
+ callback: (value) => {
533
+ values[i] = value;
534
+ callback(...values);
535
+ }
536
+ });
537
+ }
538
+ return () => {
539
+ for (const selectorId of selectorIds) {
540
+ localSubscriptions.delete(selectorId);
541
+ }
542
+ sendUnsubscribe2(selectorIds);
543
+ };
544
+ }
545
+ const dispatch = (updates) => {
546
+ for (const { selectorId, value } of updates) {
547
+ const entry = localSubscriptions.get(selectorId);
548
+ if (entry) {
549
+ entry.callback(value);
550
+ }
551
+ }
552
+ };
553
+ return { subscribe, dispatch };
554
+ };
555
+
314
556
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/stateless/index.js
315
557
  var createStatelessBridgeApi = () => {
316
558
  const subscribers = /* @__PURE__ */ new Map();
@@ -363,6 +605,8 @@ var createStatelessBridgeApi = () => {
363
605
 
364
606
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers.js
365
607
  var statelessApi = createStatelessBridgeApi();
608
+ var designStateApi = createDesignStateBridgeApi();
609
+ var appStateApi = createAppStateBridgeApi();
366
610
  var handleIncomingMessage = (event) => {
367
611
  const parent = window.parent;
368
612
  if (!parent || parent === window) {
@@ -385,16 +629,31 @@ var handleIncomingMessage = (event) => {
385
629
  statelessApi.dispatch(data.type, data.payload);
386
630
  return;
387
631
  }
632
+ if (isAIGenerationUpdatePushMessage(data)) {
633
+ dispatchAIGenerationUpdate(data.subscriptionId, data.update);
634
+ return;
635
+ }
636
+ if (isDesignStateUpdatePushMessage(data)) {
637
+ designStateApi.dispatch(data.updates);
638
+ return;
639
+ }
640
+ if (isAppStateUpdatePushMessage(data)) {
641
+ appStateApi.dispatch(data.updates);
642
+ return;
643
+ }
388
644
  };
389
645
  var bridgeHandlers = {
390
646
  ai: createAIApiProxy(),
391
647
  context: createApiProxy("context"),
392
648
  design: createApiProxy("design"),
649
+ designStore: designStateApi,
650
+ appStore: appStateApi,
393
651
  font: createApiProxy("font"),
394
652
  state: createApiProxy("state"),
395
653
  upload: createApiProxy("upload"),
396
654
  auth: createAuthBridgeApi(),
397
- stateless: statelessApi
655
+ stateless: statelessApi,
656
+ createBatch
398
657
  };
399
658
 
400
659
  // src/api/utils.ts
package/dist/kittl-sdk.js CHANGED
@@ -10,6 +10,15 @@
10
10
  var isStatelessPushMessage = (data) => {
11
11
  return typeof data === "object" && data !== null && "command" in data && data.command === "stateless-message" && "type" in data && typeof data.type === "string" && "payload" in data && typeof data.payload === "object" && data.payload !== null;
12
12
  };
13
+ var isAIGenerationUpdatePushMessage = (data) => {
14
+ return typeof data === "object" && data !== null && "command" in data && data.command === "ai-generation-update" && "subscriptionId" in data && typeof data.subscriptionId === "string" && "update" in data && typeof data.update === "object" && data.update !== null;
15
+ };
16
+ var isDesignStateUpdatePushMessage = (data) => {
17
+ return typeof data === "object" && data !== null && "command" in data && data.command === "design-state-update" && "updates" in data && Array.isArray(data.updates);
18
+ };
19
+ var isAppStateUpdatePushMessage = (data) => {
20
+ return typeof data === "object" && data !== null && "command" in data && data.command === "app-state-update" && "updates" in data && Array.isArray(data.updates);
21
+ };
13
22
 
14
23
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/shared/createApiProxyCore.js
15
24
  var buildMethodPath = (rootPrefix, pathSegments) => {
@@ -118,8 +127,11 @@
118
127
  }
119
128
  return Math.random().toString(36).substring(7);
120
129
  };
121
- var sendMessage = (message) => {
130
+ var postMessageToParent = (message) => {
122
131
  window.parent.postMessage(message, getParentDomain());
132
+ };
133
+ var sendMessage = (message) => {
134
+ postMessageToParent(message);
123
135
  return new Promise((resolve, reject) => {
124
136
  pendingRequests.set(message.messageId, {
125
137
  resolve: (value) => {
@@ -135,7 +147,7 @@
135
147
  return;
136
148
  }
137
149
  const message = { command: "loaded" };
138
- parent.postMessage(message, getParentDomain());
150
+ postMessageToParent(message);
139
151
  };
140
152
 
141
153
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/index.js
@@ -198,6 +210,14 @@
198
210
  }
199
211
 
200
212
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/apiProxy/aiApiProxy.js
213
+ var generationHandlers = /* @__PURE__ */ new Map();
214
+ var dispatchAIGenerationUpdate = (subscriptionId, update) => {
215
+ const handler = generationHandlers.get(subscriptionId);
216
+ if (!handler) {
217
+ return;
218
+ }
219
+ void handler(update);
220
+ };
201
221
  function createAIApiProxy() {
202
222
  return {
203
223
  spendCredits: async (options) => {
@@ -216,10 +236,120 @@
216
236
  onDecline?.();
217
237
  }
218
238
  return response;
239
+ },
240
+ startGeneration: (generatorId, inputSettings, output) => {
241
+ const message = {
242
+ command: "sdk-call",
243
+ dots: ["startGeneration"],
244
+ args: [generatorId, inputSettings, output],
245
+ messageId: generateMessageId(),
246
+ apiType: "ai"
247
+ };
248
+ return sendMessage(message);
249
+ },
250
+ registerHandler: async (generatorId, onStatusUpdate) => {
251
+ const subscriptionId = generateMessageId();
252
+ const unregister = () => {
253
+ generationHandlers.delete(subscriptionId);
254
+ const unregisterMessage = {
255
+ command: "ai-unregister-handler",
256
+ subscriptionId
257
+ };
258
+ postMessageToParent(unregisterMessage);
259
+ };
260
+ generationHandlers.set(subscriptionId, onStatusUpdate);
261
+ const registerMessage = {
262
+ command: "ai-register-handler",
263
+ messageId: generateMessageId(),
264
+ generatorId,
265
+ subscriptionId
266
+ };
267
+ try {
268
+ const response = await sendMessage(registerMessage);
269
+ if (!response.isOk) {
270
+ generationHandlers.delete(subscriptionId);
271
+ return response;
272
+ }
273
+ return { isOk: true, result: unregister };
274
+ } catch {
275
+ generationHandlers.delete(subscriptionId);
276
+ return {
277
+ isOk: false,
278
+ error: {
279
+ message: "Failed to register AI handler",
280
+ name: "SdkInternalError"
281
+ }
282
+ };
283
+ }
219
284
  }
220
285
  };
221
286
  }
222
287
 
288
+ // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/appState/index.js
289
+ var sendUnsubscribe = (selectorIds) => {
290
+ const message = {
291
+ command: "app-state-unsubscribe",
292
+ selectorIds
293
+ };
294
+ postMessageToParent(message);
295
+ };
296
+ var createAppStateBridgeApi = () => {
297
+ const localSubscriptions = /* @__PURE__ */ new Map();
298
+ async function subscribe(paths, callback) {
299
+ if (paths.length === 0) {
300
+ return () => {
301
+ };
302
+ }
303
+ const values = new Array(paths.length).fill(void 0);
304
+ const selectorIds = [];
305
+ const pathArrays = [];
306
+ for (const dotPath of paths) {
307
+ const segments = dotPath.split(".");
308
+ if (segments.some((s) => s === "")) {
309
+ throw new Error(
310
+ `Invalid app state path: '${dotPath}'. Path must be a non-empty dot-separated string.`
311
+ );
312
+ }
313
+ selectorIds.push(generateMessageId());
314
+ pathArrays.push(segments);
315
+ }
316
+ const messageId = generateMessageId();
317
+ const subscribeMessage = {
318
+ command: "app-state-subscribe",
319
+ messageId,
320
+ selectorIds,
321
+ paths: pathArrays
322
+ };
323
+ const response = await sendMessage(subscribeMessage);
324
+ if (!response.isOk) {
325
+ throw new Error(`app-state-subscribe failed: ${response.error.message}`);
326
+ }
327
+ for (let i = 0; i < selectorIds.length; i++) {
328
+ localSubscriptions.set(selectorIds[i], {
329
+ callback: (value) => {
330
+ values[i] = value;
331
+ callback(...values);
332
+ }
333
+ });
334
+ }
335
+ return () => {
336
+ for (const selectorId of selectorIds) {
337
+ localSubscriptions.delete(selectorId);
338
+ }
339
+ sendUnsubscribe(selectorIds);
340
+ };
341
+ }
342
+ const dispatch = (updates) => {
343
+ for (const { selectorId, value } of updates) {
344
+ const entry = localSubscriptions.get(selectorId);
345
+ if (entry) {
346
+ entry.callback(value);
347
+ }
348
+ }
349
+ };
350
+ return { subscribe, dispatch };
351
+ };
352
+
223
353
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/authBridge/index.js
224
354
  var hashPKCECode = async (input) => {
225
355
  const textAsBuffer = new TextEncoder().encode(input);
@@ -312,6 +442,118 @@
312
442
  };
313
443
  };
314
444
 
445
+ // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/batch/index.js
446
+ var createBatch = async () => {
447
+ const response = await sendMessage({
448
+ command: "batch-create",
449
+ messageId: generateMessageId()
450
+ });
451
+ if (!response.isOk) {
452
+ throw response.error;
453
+ }
454
+ const { batchKey } = response.result;
455
+ const sendDesignCall = (dots, args) => sendMessage({
456
+ command: "sdk-call",
457
+ dots,
458
+ args,
459
+ messageId: generateMessageId(),
460
+ apiType: "design",
461
+ batchKey
462
+ });
463
+ const commit = async () => {
464
+ const res = await sendMessage({
465
+ command: "batch-commit",
466
+ messageId: generateMessageId(),
467
+ batchKey
468
+ });
469
+ if (!res.isOk) {
470
+ throw res.error;
471
+ }
472
+ };
473
+ const buildNode = (pathSegments) => {
474
+ const target = () => {
475
+ };
476
+ return new Proxy(target, {
477
+ get: (_t, prop) => {
478
+ if (typeof prop === "symbol" || prop === "then") return void 0;
479
+ if (prop === "commit") return commit;
480
+ return buildNode([...pathSegments, prop]);
481
+ },
482
+ apply: (_t, _this, args) => {
483
+ return sendDesignCall(pathSegments, args);
484
+ }
485
+ });
486
+ };
487
+ return buildNode([]);
488
+ };
489
+
490
+ // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/designState/index.js
491
+ var sendUnsubscribe2 = (selectorIds) => {
492
+ const message = {
493
+ command: "design-state-unsubscribe",
494
+ selectorIds
495
+ };
496
+ postMessageToParent(message);
497
+ };
498
+ var createDesignStateBridgeApi = () => {
499
+ const localSubscriptions = /* @__PURE__ */ new Map();
500
+ async function subscribe(paths, callback) {
501
+ if (paths.length === 0) {
502
+ return () => {
503
+ };
504
+ }
505
+ const values = new Array(paths.length).fill(void 0);
506
+ const selectorIds = [];
507
+ const pathArrays = [];
508
+ for (const dotPath of paths) {
509
+ const segments = dotPath.split(".");
510
+ if (segments.some((s) => s === "")) {
511
+ throw new Error(
512
+ `Invalid design state path: '${dotPath}'. Path must be a non-empty dot-separated string.`
513
+ );
514
+ }
515
+ selectorIds.push(generateMessageId());
516
+ pathArrays.push(segments);
517
+ }
518
+ const messageId = generateMessageId();
519
+ const subscribeMessage = {
520
+ command: "design-state-subscribe",
521
+ messageId,
522
+ selectorIds,
523
+ paths: pathArrays
524
+ };
525
+ const response = await sendMessage(subscribeMessage);
526
+ if (!response.isOk) {
527
+ throw new Error(
528
+ `design-state-subscribe failed: ${response.error.message}`
529
+ );
530
+ }
531
+ for (let i = 0; i < selectorIds.length; i++) {
532
+ localSubscriptions.set(selectorIds[i], {
533
+ callback: (value) => {
534
+ values[i] = value;
535
+ callback(...values);
536
+ }
537
+ });
538
+ }
539
+ return () => {
540
+ for (const selectorId of selectorIds) {
541
+ localSubscriptions.delete(selectorId);
542
+ }
543
+ sendUnsubscribe2(selectorIds);
544
+ };
545
+ }
546
+ const dispatch = (updates) => {
547
+ for (const { selectorId, value } of updates) {
548
+ const entry = localSubscriptions.get(selectorId);
549
+ if (entry) {
550
+ entry.callback(value);
551
+ }
552
+ }
553
+ };
554
+ return { subscribe, dispatch };
555
+ };
556
+
315
557
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers/stateless/index.js
316
558
  var createStatelessBridgeApi = () => {
317
559
  const subscribers = /* @__PURE__ */ new Map();
@@ -364,6 +606,8 @@
364
606
 
365
607
  // ../../packages/editor-core/sdk/sdk-bridge/dist/bridge/sandboxed/handlers.js
366
608
  var statelessApi = createStatelessBridgeApi();
609
+ var designStateApi = createDesignStateBridgeApi();
610
+ var appStateApi = createAppStateBridgeApi();
367
611
  var handleIncomingMessage = (event) => {
368
612
  const parent = window.parent;
369
613
  if (!parent || parent === window) {
@@ -386,16 +630,31 @@
386
630
  statelessApi.dispatch(data.type, data.payload);
387
631
  return;
388
632
  }
633
+ if (isAIGenerationUpdatePushMessage(data)) {
634
+ dispatchAIGenerationUpdate(data.subscriptionId, data.update);
635
+ return;
636
+ }
637
+ if (isDesignStateUpdatePushMessage(data)) {
638
+ designStateApi.dispatch(data.updates);
639
+ return;
640
+ }
641
+ if (isAppStateUpdatePushMessage(data)) {
642
+ appStateApi.dispatch(data.updates);
643
+ return;
644
+ }
389
645
  };
390
646
  var bridgeHandlers = {
391
647
  ai: createAIApiProxy(),
392
648
  context: createApiProxy("context"),
393
649
  design: createApiProxy("design"),
650
+ designStore: designStateApi,
651
+ appStore: appStateApi,
394
652
  font: createApiProxy("font"),
395
653
  state: createApiProxy("state"),
396
654
  upload: createApiProxy("upload"),
397
655
  auth: createAuthBridgeApi(),
398
- stateless: statelessApi
656
+ stateless: statelessApi,
657
+ createBatch
399
658
  };
400
659
 
401
660
  // src/api/utils.ts
package/dist/sdk.d.ts CHANGED
@@ -51,7 +51,7 @@ declare const BASIC_SHAPE_DEFAULT_VALUES: {
51
51
  locked?: boolean | undefined;
52
52
  hidden?: boolean | undefined;
53
53
  opacity?: number | undefined;
54
- stroke?: string;
54
+ stroke?: string | null;
55
55
  strokeWidth?: number;
56
56
  fill?: ColorInfo[] | undefined;
57
57
  scalingCorners?: boolean | undefined;
@@ -68,7 +68,7 @@ declare const BasicShapeType: {
68
68
  };
69
69
  declare const DEFAULT_VALUES$1: {
70
70
  globalCompositeOperation: BlendMode;
71
- stroke?: string;
71
+ stroke?: string | null;
72
72
  strokeWidth?: number;
73
73
  shadowOptions?: {
74
74
  color?: string | undefined | null;
@@ -123,7 +123,7 @@ declare const DEFAULT_VALUES$2: {
123
123
  offset?: number;
124
124
  angle?: number;
125
125
  };
126
- stroke?: string;
126
+ stroke?: string | null;
127
127
  strokeWidth?: number;
128
128
  opacity?: number | undefined;
129
129
  width: number;
@@ -166,7 +166,7 @@ declare const DEFAULT_VALUES: {
166
166
  presets?: LinkedPreset[] | undefined;
167
167
  opacity?: number | undefined;
168
168
  hiddenColors?: Record<string, NonNullable<Color>> | undefined;
169
- stroke?: string;
169
+ stroke?: string | null;
170
170
  strokeWidth?: number;
171
171
  fill?: ColorInfo[] | undefined;
172
172
  locked?: boolean | undefined;
@@ -193,6 +193,12 @@ declare const GUIDE_DEFAULT_VALUES: {
193
193
  version: string;
194
194
  type: ObjectType.Guide;
195
195
  };
196
+ declare const GenerationStatus: {
197
+ readonly CREATED: "CREATED";
198
+ readonly STARTED: "STARTED";
199
+ readonly COMPLETE: "COMPLETE";
200
+ readonly FAILED: "FAILED";
201
+ };
196
202
  declare const ILLUSTRATION_DEFAULT_VALUES: {
197
203
  hiddenColors?: Record<string, NonNullable<Color>> | undefined;
198
204
  clipPathMaskId?: string | undefined | null;
@@ -220,7 +226,7 @@ declare const ILLUSTRATION_DEFAULT_VALUES: {
220
226
  gradients?: StateGradientInfo | undefined;
221
227
  presets?: LinkedPreset[] | undefined;
222
228
  opacity?: number | undefined;
223
- stroke?: string;
229
+ stroke?: string | null;
224
230
  strokeWidth?: number;
225
231
  fill?: ColorInfo[] | undefined;
226
232
  inLoadingStage?: boolean | undefined;
@@ -326,10 +332,9 @@ declare const PATH_TEXT_DEFAULT_VALUES: {
326
332
  type: ObjectType.PathText;
327
333
  };
328
334
  declare const RICH_TEXT_DEFAULT_VALUES: {
329
- activeTransformPlugin?: object | undefined;
330
335
  presets?: LinkedPreset[] | undefined;
331
336
  opacity?: number | undefined;
332
- stroke?: string;
337
+ stroke?: string | null;
333
338
  strokeWidth?: number;
334
339
  fill?: Color | undefined;
335
340
  locked?: boolean | undefined;
@@ -349,6 +354,11 @@ declare const RICH_TEXT_DEFAULT_VALUES: {
349
354
  version: string;
350
355
  type: ObjectType.RichText;
351
356
  };
357
+ declare const ResultType: {
358
+ readonly VIDEO: "video";
359
+ readonly IMAGE: "image";
360
+ readonly ERROR: "error";
361
+ };
352
362
  declare const backgroundType = "background";
353
363
  declare const clippingMaskType = "clippingMask";
354
364
  declare const pathType = "path";
@@ -503,7 +513,8 @@ declare enum Origin {
503
513
  CANVAS = 2,
504
514
  UI = 4,
505
515
  VOLATILE = 8,
506
- EVENTS_SYNC = 16
516
+ EVENTS_SYNC = 16,
517
+ API = 32
507
518
  }
508
519
  declare enum TextAlignment {
509
520
  right = "right",
@@ -523,8 +534,23 @@ declare global {
523
534
  }
524
535
  }
525
536
  export declare const kittl: KittlSDK;
526
- export interface AIAPI {
527
- spendCredits: (options: SpendCreditsOptions) => SdkResultAsync<SpendCreditsResult, Error>;
537
+ export interface AIGenerationInputSettings {
538
+ prompt: string;
539
+ taskType?: AIGenerationModelTaskType;
540
+ promptStyleId?: number;
541
+ model: {
542
+ id: string;
543
+ };
544
+ additionalParams?: Record<string, unknown>;
545
+ actionOrigin?: AIGenerationActionOrigin;
546
+ type: AIGenerationContentType;
547
+ }
548
+ export interface AIGenerationOutputSettings {
549
+ id?: string;
550
+ dimensions: {
551
+ width: number;
552
+ height: number;
553
+ };
528
554
  }
529
555
  export interface AppStateAPI {
530
556
  getSelectedObjectsIds(): string[];
@@ -546,10 +572,41 @@ export interface AppStateAPI {
546
572
  setHighlightedObjectId(id: string | null): void;
547
573
  setMany(fields: Partial<AppState>, origin?: Origin): void;
548
574
  }
549
- export interface AsyncAIAPI extends WithAsync<AIAPI> {
575
+ export interface AsyncAIAPI {
576
+ spendCredits: (options: SpendCreditsOptions) => SdkResultAsync<SpendCreditsResult, Error>;
577
+ startGeneration: (generatorId: string, inputSettings: AIGenerationInputSettings, output: AIGenerationOutputSettings) => SdkResultAsync<StartGenerationResult, Error>;
578
+ registerHandler: (generatorId: string, onStatusUpdate: OnGenerationStatusUpdate) => SdkResultAsync<() => void, Error>;
550
579
  }
551
580
  export interface AsyncAppStateAPI extends WithAsync<AppStateAPI> {
552
581
  }
582
+ export interface AsyncAppStateSubscriptionAPI {
583
+ /**
584
+ * Subscribe to one or more paths in the app state.
585
+ * Each path is a dot-separated string like `'selectedObjectsIds'`.
586
+ * The callback receives the current value at each path as positional
587
+ * arguments whenever any subscribed value changes.
588
+ * Returns a single unsubscribe function that tears down all subscriptions.
589
+ *
590
+ * @example
591
+ * // Single path
592
+ * const unsub = await kittl.appStore.subscribe(
593
+ * ['selectedObjectsIds'],
594
+ * (ids) => console.log('selection changed:', ids)
595
+ * );
596
+ *
597
+ * // Multiple paths
598
+ * const unsub = await kittl.appStore.subscribe(
599
+ * ['selectedObjectsIds', 'activeTool'],
600
+ * (ids, tool) => console.log('changed:', ids, tool)
601
+ * );
602
+ * unsub();
603
+ */
604
+ subscribe<T extends readonly AppStateSelectorPath[]>(paths: [
605
+ ...T
606
+ ], callback: (...values: {
607
+ [K in keyof T]: T[K] extends string ? DeepValue<AppState, T[K]> | undefined : unknown;
608
+ }) => void): Promise<() => void>;
609
+ }
553
610
  export interface AsyncAuthAPI {
554
611
  startAuth: (request: AuthStartRequest) => Promise<SdkResult<AuthStartResult>>;
555
612
  exchangeCode: (request: AuthExchangeRequest) => Promise<SdkResult<AuthTokenResponse>>;
@@ -557,10 +614,41 @@ export interface AsyncAuthAPI {
557
614
  refreshToken: (request: AuthRefreshRequest) => Promise<SdkResult<AuthTokenResponse>>;
558
615
  logout: (request: AuthLogoutRequest) => Promise<SdkResult<void>>;
559
616
  }
617
+ export interface AsyncBatchDesignAPI extends AsyncDesignAPI {
618
+ commit: () => Promise<void>;
619
+ }
560
620
  export interface AsyncContextAPI extends WithAsync<ContextAPI> {
561
621
  }
562
622
  export interface AsyncDesignAPI extends WithAsync<WithOptsRemoved<DesignAPI>> {
563
623
  }
624
+ export interface AsyncDesignStateAPI {
625
+ /**
626
+ * Subscribe to one or more paths in the design state.
627
+ * Each path is a dot-separated string like `'objects.id1.width'`.
628
+ * The callback receives the current value at each path as positional
629
+ * arguments whenever any subscribed value changes.
630
+ * Returns a single unsubscribe function that tears down all subscriptions.
631
+ *
632
+ * @example
633
+ * // Single path
634
+ * const unsub = await kittl.designStore.subscribe(
635
+ * ['objects.id1.width'],
636
+ * (width) => console.log('width changed:', width)
637
+ * );
638
+ *
639
+ * // Multiple paths
640
+ * const unsub = await kittl.designStore.subscribe(
641
+ * ['objects.id1.width', 'objects.id1.height'],
642
+ * (width, height) => console.log('changed:', width, height)
643
+ * );
644
+ * unsub();
645
+ */
646
+ subscribe<T extends readonly DesignStateSelectorPath[]>(paths: [
647
+ ...T
648
+ ], callback: (...values: {
649
+ [K in keyof T]: T[K] extends string ? DeepValue<SelectorState, T[K]> | undefined : unknown;
650
+ }) => void): Promise<() => void>;
651
+ }
564
652
  export interface AsyncFontAPI extends WithAsync<FontAPI> {
565
653
  }
566
654
  export interface AsyncStatelessAPI {
@@ -746,6 +834,11 @@ export interface DragAndDropStartDragImageEventInput {
746
834
  img: HTMLImageElement;
747
835
  persistImage?: boolean;
748
836
  }
837
+ export interface ErrorGenerationResult {
838
+ type: typeof ResultType.ERROR;
839
+ message: string;
840
+ code?: string;
841
+ }
749
842
  export interface FontAPI {
750
843
  createFont: (params: {
751
844
  name: string;
@@ -771,10 +864,22 @@ export interface GeneratableObject {
771
864
  generatorKey: string;
772
865
  };
773
866
  }
867
+ export interface GenerationInputData {
868
+ prompt?: string;
869
+ style?: {
870
+ id: number;
871
+ };
872
+ model?: {
873
+ id: string;
874
+ };
875
+ }
774
876
  export interface GenerationMeta {
775
877
  generationEndsAt?: number;
776
878
  pendingGenerationId: string;
777
879
  }
880
+ export interface GenerationStartedResultCommonProps {
881
+ generationEndsAt?: number;
882
+ }
778
883
  export interface GetExportOptions {
779
884
  format: "png" | "jpg" | "pdf" | "svg" | "mp4";
780
885
  target: {
@@ -792,6 +897,7 @@ export interface GetExportOptions {
792
897
  height: number;
793
898
  };
794
899
  };
900
+ removeArtboardBackground?: boolean;
795
901
  }
796
902
  export interface GetObjectParams {
797
903
  id: string;
@@ -853,7 +959,15 @@ export interface ImageAPI {
853
959
  addImage(params: AddImageParams, opts?: DesignApiOptions): SdkResultAsync<NormalizedIllustrationImageObject, SdkError>;
854
960
  updateImage(params: UpdateImageParams, opts?: DesignApiOptions): NormalizedIllustrationImageObject;
855
961
  }
962
+ export interface ImageGenerationResult {
963
+ type: typeof ResultType.IMAGE;
964
+ objectName: string;
965
+ }
966
+ export interface ImageGenerationStartedResult extends GenerationStartedResultCommonProps {
967
+ type: typeof ResultType.IMAGE;
968
+ }
856
969
  export interface KittlContext {
970
+ colorScheme: EditorColorScheme;
857
971
  dragAndDrop: {
858
972
  offset: DragAndDropOffset;
859
973
  };
@@ -864,6 +978,8 @@ export interface KittlSDK {
864
978
  onReady: (cb: () => void) => void;
865
979
  ai: AsyncAIAPI;
866
980
  design: AsyncDesignAPI;
981
+ designStore: AsyncDesignStateAPI;
982
+ appStore: AsyncAppStateSubscriptionAPI;
867
983
  context: AsyncContextAPI;
868
984
  dragAndDrop: PublicDragAndDropAPI;
869
985
  state: AsyncAppStateAPI;
@@ -871,6 +987,7 @@ export interface KittlSDK {
871
987
  upload: AsyncUploadAPI;
872
988
  stateless: AsyncStatelessAPI;
873
989
  font: AsyncFontAPI;
990
+ createBatch: () => Promise<AsyncBatchDesignAPI>;
874
991
  }
875
992
  export interface LayersAPI {
876
993
  moveTo(input: MoveToParams, opts?: DesignApiOptions): void;
@@ -950,6 +1067,24 @@ export interface RemoveObjectParams {
950
1067
  export interface RemoveObjectResult {
951
1068
  removedObject: NormalizedObject;
952
1069
  }
1070
+ export interface RichTextCompressedStylesV1 {
1071
+ version: "v1";
1072
+ [lineIndex: LineIndex]: {
1073
+ charsAt: CharacterIndex[];
1074
+ styles: Partial<RichTextSerializedCharacterStyle>;
1075
+ }[];
1076
+ }
1077
+ export interface RichTextCompressedStylesV2 {
1078
+ version: "v2";
1079
+ customStyles: Record<string, Partial<RichTextSerializedCharacterStyle>>;
1080
+ [lineIndex: LineIndex]: {
1081
+ charsAt: [
1082
+ CharacterIndex,
1083
+ SequenceLength
1084
+ ][];
1085
+ styleId: string;
1086
+ }[];
1087
+ }
953
1088
  export interface RotateObjectParams {
954
1089
  id: string;
955
1090
  angle: number;
@@ -1003,8 +1138,12 @@ export interface SpendCreditsResult {
1003
1138
  }
1004
1139
  export interface StandardArtboardOptions extends BaseStandardArtboardOptions<ObjectType.Artboard> {
1005
1140
  }
1141
+ export interface StartGenerationResult {
1142
+ generationId: string;
1143
+ }
1006
1144
  export interface StateAPI {
1007
1145
  implementSubState(params: Partial<NormalizedDesignState>, opts?: DesignApiOptions): Partial<NormalizedDesignState>;
1146
+ getState(): NormalizedDesignState;
1008
1147
  }
1009
1148
  export interface StructureObjectMeta {
1010
1149
  name?: string;
@@ -1077,6 +1216,17 @@ export interface VideoAPI {
1077
1216
  removePlaylistItem(params: RemoveVideoPlaylistItemParams, opts?: DesignApiOptions): NormalizedVideoObject;
1078
1217
  updatePlaylistItem(params: UpdateVideoPlaylistItemParams, opts?: DesignApiOptions): Promise<NormalizedVideoObject>;
1079
1218
  }
1219
+ export interface VideoGenerationResult {
1220
+ type: typeof ResultType.VIDEO;
1221
+ status: "PROCESSING" | "READY" | "FAILED";
1222
+ playbackId?: string;
1223
+ duration?: number;
1224
+ aspectRatio?: string;
1225
+ hostingProvider?: "MUX";
1226
+ }
1227
+ export interface VideoGenerationStartedResult extends GenerationStartedResultCommonProps {
1228
+ type: typeof ResultType.VIDEO;
1229
+ }
1080
1230
  export interface VideoboardAPI {
1081
1231
  addVideoboard(params: AddVideoboardParams, opts?: DesignApiOptions): Promise<NormalizedStandardBoard<VideoboardOptions>>;
1082
1232
  setVideoOnVideoboard(params: SetVideoOnVideoboardParams, opts?: DesignApiOptions): Promise<NormalizedStandardBoard<VideoboardOptions>>;
@@ -1101,6 +1251,9 @@ export interface WithObjectLayout {
1101
1251
  flipX: boolean;
1102
1252
  flipY: boolean;
1103
1253
  }
1254
+ 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";
1255
+ export type AIGenerationContentType = "image" | "video";
1256
+ export type AIGenerationModelTaskType = "IMAGE_TO_IMAGE" | "IMAGE_INPAINT" | "TEXT_TO_IMAGE" | "IMAGE_TO_VIDEO";
1104
1257
  export type APIOptions<T extends Record<string, unknown>> = {
1105
1258
  batchClient?: BatchClient<T>;
1106
1259
  } | {
@@ -1198,6 +1351,20 @@ export type AppState = {
1198
1351
  viewport: Viewport;
1199
1352
  highlightedObjectId: string | null;
1200
1353
  };
1354
+ /**
1355
+ * A dot-separated string path into the app state.
1356
+ * The first segment must be a valid top-level key of AppState.
1357
+ *
1358
+ * @example
1359
+ * 'selectedObjectsIds'
1360
+ * 'viewport.coords.tl.x'
1361
+ * 'activeTool.type'
1362
+ */
1363
+ export type AppStateSelectorPath = AppStateTopLevelKey | `${AppStateTopLevelKey}.${string}`;
1364
+ /**
1365
+ * Top-level keys of AppState that extensions can subscribe to.
1366
+ */
1367
+ export type AppStateTopLevelKey = keyof AppState;
1201
1368
  export type ArtboardLikeType = ObjectType.Artboard | ObjectType.MockupBoard | ObjectType.Smartboard | ObjectType.Videoboard;
1202
1369
  export type ArtboardOptions = StandardArtboardOptions | SmartboardOptions | MockupBoardOptions | VideoboardOptions;
1203
1370
  export type AvailableShadowOptions = Partial<Pick<ShadowOptions, "blur">> & Omit<ShadowOptions, "blur">;
@@ -1229,6 +1396,7 @@ export type BasicShapeType = (typeof BasicShapeType)[keyof typeof BasicShapeType
1229
1396
  export type BridgedSdkResult<T> = T extends SdkResult<infer _R, infer _E> ? T : SdkResult<T, Error>;
1230
1397
  export type Builtin = Date | Function | Uint8Array | RegExp | Map<unknown, unknown> | Set<unknown>;
1231
1398
  export type CanvasMode = "erase" | "crop" | "reframe" | "inpaint" | null;
1399
+ export type CharacterIndex = number;
1232
1400
  export type CloneArtboardParams = {
1233
1401
  boardId: string;
1234
1402
  position: CreateElementWithPositionAndSize["position"];
@@ -1275,8 +1443,34 @@ export type CreateShapeInput = CreateElementWithPositionAndSize & {
1275
1443
  export type DeepPartial<T> = {
1276
1444
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
1277
1445
  };
1446
+ /**
1447
+ * Resolves a dot-separated string path against a type `T`.
1448
+ *
1449
+ * For `Record<string, V>` intermediaries (e.g. `objects`), any string
1450
+ * key is accepted and the type continues into `V`.
1451
+ *
1452
+ * @example
1453
+ * DeepValue<SelectorState, 'objects.id1.width'> // number | undefined
1454
+ * DeepValue<SelectorState, 'config'> // DesignConfig
1455
+ * DeepValue<AppState, 'viewport.coords.tl.x'> // number
1456
+ */
1457
+ export type DeepValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? DeepValue<NonNullable<T[K]>, Rest> : T extends Record<string, infer V> ? DeepValue<NonNullable<V>, Rest> : undefined : P extends keyof T ? T[P] : T extends Record<string, infer V> ? V : undefined;
1278
1458
  export type DesignApiOptions = APIOptions<NormalizedDesignState>;
1279
1459
  export type DesignObjectId = string;
1460
+ /**
1461
+ * A dot-separated string path into the design state.
1462
+ * The first segment must be a valid top-level key of NormalizedDesignState.
1463
+ *
1464
+ * @example
1465
+ * 'objects.id1.width'
1466
+ * 'config.title'
1467
+ * 'boards.board1.backgroundColor'
1468
+ */
1469
+ export type DesignStateSelectorPath = DesignStateTopLevelKey | `${DesignStateTopLevelKey}.${string}`;
1470
+ /**
1471
+ * Top-level keys of NormalizedDesignState that extensions can subscribe to.
1472
+ */
1473
+ export type DesignStateTopLevelKey = keyof NormalizedDesignState;
1280
1474
  export type DesignStructureObject = {
1281
1475
  id?: StructureObjectId | null;
1282
1476
  meta?: StructureObjectMeta;
@@ -1286,21 +1480,50 @@ export type Dimensions = {
1286
1480
  width: number;
1287
1481
  height: number;
1288
1482
  };
1483
+ export type EditorColorScheme = "light" | "dark";
1289
1484
  export type ElementLocation = "origin" | "center";
1290
1485
  export type Expand<T> = T extends infer O ? {
1291
1486
  [K in keyof O]: O[K];
1292
1487
  } : never;
1293
1488
  export type FillMetaTarget = "border" | "fill";
1489
+ export type FlattenUnion<T> = UnionToIntersection<T extends unknown ? Partial<T> : never>;
1490
+ export type FontVariationAxis = OrAnyString<"wght" | "wdth" | "slnt" | "ital" | "opsz" | "GRAD">;
1491
+ export type FontVariationSettings = Partial<Record<FontVariationAxis, number>>;
1492
+ export type FontWeight = OrAnyString<"Regular" | "Bold" | "Light" | "Medium" | "Black" | "SemiBold" | "Italic" | "ExtraLight" | "Thin" | "ExtraBold" | "LightItalic" | "MediumItalic" | "SemiBoldItalic" | "BlackItalic" | "ExtraBoldItalic" | "ThinItalic" | "ExtraLightItalic" | "BoldItalic">;
1294
1493
  export type FullColor = {
1295
1494
  key: "fill" | (Exclude<string, StringColorKeysType> & {});
1296
1495
  value: Color;
1297
1496
  visible: boolean;
1298
1497
  };
1299
1498
  export type FunctionType = (...args: never) => unknown;
1499
+ export type GenerationStatus = (typeof GenerationStatus)[keyof typeof GenerationStatus];
1500
+ export type GenerationStatusUpdate = {
1501
+ generationId: string;
1502
+ status: typeof GenerationStatus.CREATED;
1503
+ inputData: undefined;
1504
+ result: undefined;
1505
+ } | {
1506
+ generationId: string;
1507
+ status: typeof GenerationStatus.STARTED;
1508
+ inputData: GenerationInputData;
1509
+ result: StartedGenerationResult;
1510
+ } | {
1511
+ generationId: string;
1512
+ status: typeof GenerationStatus.COMPLETE;
1513
+ inputData: GenerationInputData;
1514
+ result: SuccessGenerationResult;
1515
+ } | {
1516
+ generationId: string;
1517
+ status: typeof GenerationStatus.FAILED;
1518
+ inputData: GenerationInputData | undefined;
1519
+ result: ErrorGenerationResult;
1520
+ };
1300
1521
  export type GuideSerializedObject = typeof GUIDE_DEFAULT_VALUES & OrientationDir;
1301
1522
  export type ID = string;
1302
1523
  export type IllustrationImageSerializedObject = typeof DEFAULT_VALUES$1 & {
1303
1524
  backgroundRemoved?: boolean | undefined;
1525
+ objectNameWithBackground?: string;
1526
+ backgroundRestorePathBoundary?: number | undefined;
1304
1527
  realWidth?: number | undefined;
1305
1528
  realHeight?: number | undefined;
1306
1529
  erasePaths?: {
@@ -1338,6 +1561,7 @@ export type InternalPatchArgs<T> = {
1338
1561
  patch: PatchTree<T> | PatchTree<T>[];
1339
1562
  origin: Origin;
1340
1563
  historyOrigin?: HistoryOrigins;
1564
+ transactionMeta?: TransactionMeta;
1341
1565
  };
1342
1566
  export type LayerIconType = "drawIcon";
1343
1567
  export type LayerType = Exclude<SerializableObjectType, ObjectType.Guide> | typeof structuralGroupType | typeof clippingMaskType | typeof backgroundType | typeof pathType;
@@ -1346,6 +1570,12 @@ export type LeftTopPosition = {
1346
1570
  left: number;
1347
1571
  top: number;
1348
1572
  };
1573
+ export type LineHeight = {
1574
+ value: number;
1575
+ unit: LineHeightUnit;
1576
+ };
1577
+ export type LineHeightUnit = "px" | "%";
1578
+ export type LineIndex = number;
1349
1579
  export type LinkedPreset = {
1350
1580
  id: string;
1351
1581
  libraryId: string;
@@ -1439,6 +1669,8 @@ export type NormalizedVideoObject = Normalized<VideoSerializedObject>;
1439
1669
  export type NullablePathTextShadowOptions = PathTextShadowOptions | {
1440
1670
  type: null;
1441
1671
  };
1672
+ export type OnGenerationStatusUpdate = (update: GenerationStatusUpdate) => void | Promise<void>;
1673
+ export type OrAnyString<T extends string> = T | (string & {});
1442
1674
  export type OrientationConditional = {
1443
1675
  orientation: Orientation.HORIZONTAL;
1444
1676
  top: number;
@@ -1541,26 +1773,84 @@ export type RenameParams = {
1541
1773
  objectId: string;
1542
1774
  newName: string;
1543
1775
  };
1776
+ export type ResultType = (typeof ResultType)[keyof typeof ResultType];
1544
1777
  export type RichTextBasePluginSerializedObject = {
1545
1778
  id: string;
1546
1779
  name: string;
1547
1780
  version: string;
1548
1781
  };
1782
+ export type RichTextCompressedColor = string | GradientObject | null;
1783
+ export type RichTextCompressedStyles = RichTextCompressedStylesV1 | RichTextCompressedStylesV2;
1549
1784
  export type RichTextDecorationPluginSerializedObject = RichTextBasePluginSerializedObject & {
1550
1785
  fillStyle: string;
1551
1786
  [key: string]: string | number;
1552
1787
  };
1788
+ export type RichTextHyperlinkSerializedObject = {
1789
+ id: string;
1790
+ url: string;
1791
+ };
1553
1792
  export type RichTextRenderPluginSerializedObject = RichTextBasePluginSerializedObject & {
1554
1793
  color: string;
1555
1794
  angle: number;
1556
1795
  offset: number;
1557
1796
  [key: string]: string | number;
1558
1797
  };
1798
+ export type RichTextResizeBehavior = "hug" | "none" | "hug-height";
1799
+ export type RichTextSerializedCharacterStyle = Partial<{
1800
+ fontFamily: string;
1801
+ fontWeight: FontWeight;
1802
+ fontSize: number;
1803
+ fill: RichTextCompressedColor;
1804
+ underline: boolean;
1805
+ linethrough: boolean;
1806
+ charSpacing: number;
1807
+ textCase: TextCase;
1808
+ lineHeightValue: LineHeight;
1809
+ hyperlinkId: string | null;
1810
+ preLinkFill: RichTextCompressedColor;
1811
+ fontVariationSettings: FontVariationSettings;
1812
+ fontFeatureSettings: Record<string, boolean | number>;
1813
+ }>;
1559
1814
  export type RichTextSerializedObject = typeof RICH_TEXT_DEFAULT_VALUES & {
1560
1815
  text: string;
1816
+ fontFamily: string;
1817
+ styles?: RichTextCompressedStyles;
1561
1818
  activeRenderPlugins?: RichTextRenderPluginSerializedObject[];
1562
1819
  activeDecorationPlugins?: RichTextDecorationPluginSerializedObject[];
1563
- [key: string]: unknown;
1820
+ activeTransformPlugin?: RichTextSerializedTransformPluginObject;
1821
+ fontSize?: number;
1822
+ fontWeight?: FontWeight;
1823
+ textAlign?: TextAlign;
1824
+ charSpacing?: number;
1825
+ underline?: boolean;
1826
+ linethrough?: boolean;
1827
+ fontVariationSettings?: FontVariationSettings;
1828
+ textCase?: TextCase;
1829
+ lineHeightValue?: LineHeight;
1830
+ untransformedWidth?: number;
1831
+ widthBeforeTransform?: number;
1832
+ resizeBehavior?: RichTextResizeBehavior;
1833
+ hyperlinkId?: string;
1834
+ preLinkFill?: string | GradientObject | null;
1835
+ fontFeatureSettings?: Record<string, boolean | number>;
1836
+ links?: RichTextHyperlinkSerializedObject[];
1837
+ volatileData?: {
1838
+ top: number;
1839
+ left: number;
1840
+ width: number;
1841
+ height: number;
1842
+ activeTransformPlugin: RichTextSerializedTransformPluginObject;
1843
+ key: string;
1844
+ };
1845
+ };
1846
+ export type RichTextSerializedTransformPluginObject = RichTextBasePluginSerializedObject & {
1847
+ type?: string;
1848
+ points: {
1849
+ x: number;
1850
+ y: number;
1851
+ }[];
1852
+ curveHeight?: number;
1853
+ directionInverted?: boolean;
1564
1854
  };
1565
1855
  export type ScreenCoordinates = {
1566
1856
  x: number;
@@ -1586,9 +1876,18 @@ export type SdkResultAsync<T, E = SdkError> = Promise<{
1586
1876
  error: E;
1587
1877
  }>;
1588
1878
  export type Selector<T, U = unknown> = (state: T) => U;
1879
+ /**
1880
+ * The design state shape exposed to string path selectors.
1881
+ * `objects` values are flattened so that variant-specific properties
1882
+ * (e.g. `width`, `fill`) are accessible without manual narrowing.
1883
+ */
1884
+ export type SelectorState = Omit<NormalizedDesignState, "objects"> & {
1885
+ objects: Record<string, FlattenUnion<NormalizedObject>>;
1886
+ };
1589
1887
  export type SendToParams = {
1590
1888
  boardOrObjectIds: string[];
1591
1889
  };
1890
+ export type SequenceLength = number;
1592
1891
  export type SerialisedPhotoFilter = ({
1593
1892
  type: ImageFilterType;
1594
1893
  } & PhotoFilterOptions[ImageFilterType]) | {
@@ -1666,6 +1965,7 @@ export type SmartboardOptions = ConnectedArtboardOptions<ObjectType.Smartboard>
1666
1965
  } & GeneratableBoard<SmartboardGenerationSettings>;
1667
1966
  export type SmartboardQuality = "auto" | "high" | "medium" | "low";
1668
1967
  export type StandardSerializedObject = BasicShapeSerializedObject | CombinedShapeSerializedObject | IllustrationImageSerializedObject | IllustrationSerializedObject | LoadingCardSerializedObject | MaskSerializedObject | MockupDesignSerializedObject | PathTextSerializedObject | RichTextSerializedObject | VideoSerializedObject;
1968
+ export type StartedGenerationResult = VideoGenerationStartedResult | ImageGenerationStartedResult;
1669
1969
  export type StateGradientInfo = {
1670
1970
  [key: string]: GradientInfo;
1671
1971
  };
@@ -1676,17 +1976,20 @@ export type StringColor = {
1676
1976
  };
1677
1977
  export type StringColorKeysType = (typeof stringColorKeys)[number];
1678
1978
  export type StructureObjectId = string;
1979
+ export type SuccessGenerationResult = VideoGenerationResult | ImageGenerationResult;
1679
1980
  export type TempUserImageUpload = {
1680
1981
  objectId: string;
1681
1982
  mimeType: string;
1682
1983
  };
1984
+ export type TextAlign = "left" | "center" | "right" | "justify" | "justify-left" | "justify-center" | "justify-right" | "justify-legacy";
1985
+ export type TextCase = "none" | "uppercase";
1683
1986
  export type TextProperties = {
1684
1987
  fontFamily?: string;
1685
1988
  fontSize?: number;
1686
- fontWeight?: string | number;
1989
+ fontWeight?: string;
1687
1990
  fill?: Color;
1688
1991
  textAlign?: "left" | "center" | "right" | "justify";
1689
- lineHeight?: number;
1992
+ lineHeightValue?: LineHeight;
1690
1993
  resizeBehavior?: "none" | "hug" | "hug-height";
1691
1994
  charSpacing?: number;
1692
1995
  underline?: boolean;
@@ -1698,6 +2001,16 @@ export type TextProperties = {
1698
2001
  stroke?: string;
1699
2002
  strokeWidth?: number;
1700
2003
  };
2004
+ export type TransactionMeta = {
2005
+ isLocal: boolean;
2006
+ isUndoRedo: boolean;
2007
+ };
2008
+ /**
2009
+ * Collapses a union type into a single object type where:
2010
+ * - Properties shared by all members keep their original type.
2011
+ * - Properties that exist only on some members become optional.
2012
+ */
2013
+ export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
1701
2014
  export type UpdateArtboardBackgroundParams = {
1702
2015
  id: string;
1703
2016
  objectName: string;
@@ -1787,6 +2100,7 @@ export type UpdateVideoPlaylistItemParams = {
1787
2100
  videoId: string;
1788
2101
  playlistItemId: string;
1789
2102
  playlistItem: Omit<VideoPlaylistItem, "id">;
2103
+ allowAspectRatioMismatch?: boolean;
1790
2104
  };
1791
2105
  export type UpdateVideoboardParams = {
1792
2106
  videoBoardId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kittl/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "license": "Apache-2.0",
5
5
  "private": false,
6
6
  "type": "module",
@@ -22,5 +22,8 @@
22
22
  "dist",
23
23
  "README.md",
24
24
  "LICENSE"
25
- ]
25
+ ],
26
+ "scripts": {
27
+ "deploy": "bash ../../scripts/npm-publish.sh"
28
+ }
26
29
  }