@kittl/sdk 1.0.0-alpha.1 → 1.0.0-alpha.2

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.
@@ -56,7 +56,11 @@ declare const ANIMATION_CHANNELS: readonly [
56
56
  "scaleY",
57
57
  "skewX",
58
58
  "skewY",
59
- "opacity"
59
+ "opacity",
60
+ "offsetDistance",
61
+ "translateZ",
62
+ "rotateX",
63
+ "rotateY"
60
64
  ];
61
65
  declare const ANIMATION_EASING_NAMES: readonly [
62
66
  "linear",
@@ -65,6 +69,7 @@ declare const ANIMATION_EASING_NAMES: readonly [
65
69
  "ease-out",
66
70
  "ease-in-out"
67
71
  ];
72
+ declare const ANIMATION_SHAPE_CHANNEL = "d";
68
73
  declare const APP_STATE_SUBSCRIPTION_KEYS: readonly [
69
74
  "selectedObjectsIds",
70
75
  "selectedLayersIds",
@@ -171,9 +176,7 @@ declare const DEFAULT_VALUES$1: {
171
176
  generation?: {
172
177
  meta?: GenerationMeta;
173
178
  generationId?: string;
174
- aiArtId? /**
175
- * Cache key to support local history changes without relying on persistence
176
- */: string;
179
+ aiArtId?: string;
177
180
  generatorKey?: string;
178
181
  };
179
182
  };
@@ -264,6 +267,37 @@ declare const GUIDE_DEFAULT_VALUES: {
264
267
  version: string;
265
268
  type: ObjectType.Guide;
266
269
  };
270
+ declare const GenerateContentActionOrigin: {
271
+ readonly COPILOT: "COPILOT";
272
+ readonly RIGHT_PANEL: "RIGHT_PANEL";
273
+ readonly LEFT_PANEL: "LEFT_PANEL";
274
+ readonly MICRO_APP: "MICRO_APP";
275
+ readonly IMAGE_SETS: "IMAGE_SETS";
276
+ readonly AI_CHAT: "AI_CHAT";
277
+ readonly SMARTBOARD: "SMARTBOARD";
278
+ readonly AI_INPUT_GENERATE_IMAGE: "AI_INPUT_GENERATE_IMAGE";
279
+ readonly AI_INPUT_REMIX_IMAGE: "AI_INPUT_REMIX_IMAGE";
280
+ readonly AI_INPUT_GENERATE_VIDEO: "AI_INPUT_GENERATE_VIDEO";
281
+ readonly AI_INPUT_MICRO_EDITOR_REMIX: "AI_INPUT_MICRO_EDITOR_REMIX";
282
+ readonly AI_INPUT_MICRO_EDITOR_INPAINT: "AI_INPUT_MICRO_EDITOR_INPAINT";
283
+ readonly AI_HUB_GENERATE_IMAGE: "AI_HUB_GENERATE_IMAGE";
284
+ readonly AI_HUB_REMIX_IMAGE: "AI_HUB_REMIX_IMAGE";
285
+ readonly AI_HUB_GENERATE_VIDEO: "AI_HUB_GENERATE_VIDEO";
286
+ readonly VIDEOBOARD: "VIDEOBOARD";
287
+ readonly AGENT: "AGENT";
288
+ readonly WORKFLOW: "WORKFLOW";
289
+ readonly AI_HUB_AGENT: "AI_HUB_AGENT";
290
+ readonly MCP: "MCP";
291
+ readonly MCP_WORKFLOW: "MCP_WORKFLOW";
292
+ readonly AI_AGENT: "AI_AGENT";
293
+ readonly AI_AGENT_CHAT: "AI_AGENT_CHAT";
294
+ readonly AI_AGENT_CHAT_WEBSITE: "AI_AGENT_CHAT_WEBSITE";
295
+ readonly MOBILE_APP_GENERATE_IMAGE: "MOBILE_APP_GENERATE_IMAGE";
296
+ readonly MOBILE_APP_REMIX_IMAGE: "MOBILE_APP_REMIX_IMAGE";
297
+ readonly MOBILE_APP_GENERATE_VIDEO: "MOBILE_APP_GENERATE_VIDEO";
298
+ readonly MOBILE_APP_AGENT: "MOBILE_APP_AGENT";
299
+ readonly AI_AGENT_WORKFLOW: "AI_AGENT_WORKFLOW";
300
+ };
267
301
  declare const GenerationStatus: {
268
302
  readonly CREATED: "CREATED";
269
303
  readonly QUEUED: "QUEUED";
@@ -412,6 +446,7 @@ declare const PendingOperation: {
412
446
  readonly UPSCALE: "upscale";
413
447
  readonly REMOVE_BACKGROUND: "removeBackground";
414
448
  readonly REFRAME: "reframe";
449
+ readonly RASTERIZE: "rasterize";
415
450
  };
416
451
  declare const RICH_TEXT_DEFAULT_VALUES: {
417
452
  opacity?: number | undefined;
@@ -695,6 +730,17 @@ export interface AddFontStyleOptions {
695
730
  /**
696
731
  * API for managing application state including selection, viewport, active tool, and canvas mode.
697
732
  *
733
+ * ## Selection
734
+ *
735
+ * {@link AppState.selectionIds} is the only stored selection list; every
736
+ * selection getter is derived from it and the current design state. Derived results are identity-stable — the very same array instance is
737
+ * returned until the selection or the design state changes — so React
738
+ * subscribers and the extension bridge can diff them by reference.
739
+ *
740
+ * Every selection setter replaces the whole selection: whatever ids it is
741
+ * given are expanded into their closure and committed to
742
+ * {@link AppState.selectionIds}.
743
+ *
698
744
  * @public
699
745
  */
700
746
  export interface AppStateAPI {
@@ -703,7 +749,7 @@ export interface AppStateAPI {
703
749
  */
704
750
  getSelectedObjectsIds(): string[];
705
751
  /**
706
- * Sets the selected object IDs.
752
+ * Replaces the selection with the given objects.
707
753
  *
708
754
  * @param ids - Array of object IDs to select
709
755
  * @param origin - Optional origin tag for loop prevention in bidirectional syncs.
@@ -716,41 +762,51 @@ export interface AppStateAPI {
716
762
  */
717
763
  getSelectedLayersIds(): string[];
718
764
  /**
719
- * Sets the selected layer IDs.
765
+ * Replaces the selection with the given layers.
766
+ *
767
+ * Board sub-layer ids (artboard, background, texture) select the board they
768
+ * belong to.
720
769
  *
721
770
  * @param ids - Array of layer IDs to select
771
+ * @param origin - Optional origin tag for loop prevention in bidirectional syncs
722
772
  */
723
- setSelectedLayersIds(ids: string[]): void;
773
+ setSelectedLayersIds(ids: string[], origin?: Origin): void;
724
774
  /**
725
775
  * Gets the IDs of selected artboards.
726
776
  */
727
777
  getSelectedArtboardIds(): string[];
728
778
  /**
729
- * Sets the selected artboard IDs.
779
+ * Replaces the selection with the given artboards.
730
780
  *
731
781
  * @param ids - Array of artboard IDs to select
782
+ * @param origin - Optional origin tag for loop prevention in bidirectional syncs
732
783
  */
733
- setSelectedArtboardIds(ids: string[]): void;
784
+ setSelectedArtboardIds(ids: string[], origin?: Origin): void;
734
785
  /**
735
786
  * Gets the object IDs within selected artboards.
736
787
  */
737
788
  getSelectedArtboardsObjectIds(): string[];
738
789
  /**
739
- * Sets the object IDs within selected artboards.
790
+ * Replaces the selection with the given objects.
740
791
  *
741
792
  * @param ids - Array of object IDs
793
+ * @param origin - Optional origin tag for loop prevention in bidirectional syncs
742
794
  */
743
- setSelectedArtboardsObjectIds(ids: string[]): void;
795
+ setSelectedArtboardsObjectIds(ids: string[], origin?: Origin): void;
744
796
  /**
745
797
  * Gets all selected object IDs including objects, artboards, and artboard objects.
798
+ *
799
+ * A flat, deduplicated list of ids that exist as boards or objects; it never
800
+ * contains group ids or synthetic (`link__`, `path__`) ids.
746
801
  */
747
802
  getAllSelectedObjectsIds(): string[];
748
803
  /**
749
- * Sets all selected object IDs.
804
+ * Replaces the selection with the given ids.
750
805
  *
751
806
  * @param ids - Array of all object IDs to select
807
+ * @param origin - Optional origin tag for loop prevention in bidirectional syncs
752
808
  */
753
- setAllSelectedObjectsIds(ids: string[]): void;
809
+ setAllSelectedObjectsIds(ids: string[], origin?: Origin): void;
754
810
  /**
755
811
  * Gets the current canvas mode.
756
812
  *
@@ -970,7 +1026,7 @@ export interface AsyncProjectAPI {
970
1026
  createBatch(): Promise<AsyncBatchDesignAPI>;
971
1027
  };
972
1028
  app: {
973
- state: AsyncPublicStateAPI<AppState, PublicAppSelectorState>;
1029
+ state: AsyncPublicStateAPI<PublicAppState, PublicAppSelectorState>;
974
1030
  api: AsyncAppStateAPI;
975
1031
  };
976
1032
  }
@@ -1205,14 +1261,6 @@ export interface CancellableSubmission {
1205
1261
  * first point the backend reports a schedule.
1206
1262
  */
1207
1263
  until?: number;
1208
- /**
1209
- * Drops the work still being done to prepare this submission's generations,
1210
- * for a caller that handed the tracker an abort handle.
1211
- *
1212
- * Cancelling is `cancelGenerations`; this only saves finishing an upload for
1213
- * a generation the user has already stopped.
1214
- */
1215
- abort?: () => void;
1216
1264
  }
1217
1265
  /**
1218
1266
  * Methods for generating preview images and exports from the canvas.
@@ -2237,6 +2285,27 @@ export interface ImageAPI {
2237
2285
  * @throws When the specified image ID doesn't exist in the design
2238
2286
  */
2239
2287
  resetImageBackgroundRemoval(params: ResetImageBackgroundRemovalParams, opts?: DesignApiOptions): SdkResultAsync<NormalizedIllustrationImageObject, SdkError>;
2288
+ /**
2289
+ * Crops an image to its non-transparent pixels, for example after its
2290
+ * background was removed.
2291
+ *
2292
+ * Loads the image source, finds the transparent rows and columns along its
2293
+ * edges, and crops them away. The image is moved so its visible content
2294
+ * stays in place on the canvas, respecting rotation, scale, and flip.
2295
+ *
2296
+ * Leaves the image unchanged when it:
2297
+ * - is already cropped,
2298
+ * - has no transparent edges,
2299
+ * - is fully transparent, or
2300
+ * - had its source replaced while the image was loading.
2301
+ *
2302
+ * @param params - Configuration parameters identifying the image to trim
2303
+ * @param opts - Additional options for the design API operation
2304
+ * @returns Promise that resolves to the trimmed image object
2305
+ * @throws When the specified image ID doesn't exist in the design, or the
2306
+ * image source cannot be loaded or read
2307
+ */
2308
+ trimTransparentEdges(params: TrimTransparentEdgesParams, opts?: UpdateObjectApiOptions): SdkResultAsync<NormalizedIllustrationImageObject, SdkError>;
2240
2309
  }
2241
2310
  /** @public */
2242
2311
  export interface ImageGenerationResult {
@@ -2645,8 +2714,15 @@ export interface MockupDataAPI {
2645
2714
  getOverview(options?: Pick<PaginationOptions, "sort">): SdkResultAsync<MockupOverviewDto>;
2646
2715
  /** Fetches a paginated list of mockups within a specific group. */
2647
2716
  getGroup(groupId: string, options?: PaginationOptions): SdkResultAsync<MockupGroupDto>;
2648
- /** Searches mockups by a text query. */
2649
- search(query: string, options?: PaginationOptions): SdkResultAsync<PaginatedResult<CatalogItem>>;
2717
+ /**
2718
+ * Searches mockups by text. OpenSearch uses relevance ordering and ignores sort.
2719
+ *
2720
+ * @param query - Search text.
2721
+ * @param options - Pagination, database sort, and optional OpenSearch mode.
2722
+ *
2723
+ * @returns Lightweight catalog summaries or an SDK error.
2724
+ */
2725
+ search(query: string, options?: MockupSearchOptions): SdkResultAsync<PaginatedResult<CatalogItem>>;
2650
2726
  /** Fetches suggested tags and groups for mockup discovery. */
2651
2727
  getSuggestions(): SdkResultAsync<MockupSuggestions>;
2652
2728
  }
@@ -2684,6 +2760,14 @@ export interface MockupOverviewGroupDto {
2684
2760
  /** Total number of mockups in this group */
2685
2761
  total: number;
2686
2762
  }
2763
+ /** Pagination and search source options for the mockup catalog. */
2764
+ export interface MockupSearchOptions extends PaginationOptions {
2765
+ /**
2766
+ * Uses OpenSearch relevance ordering instead of database sorting when true.
2767
+ * OpenSearch currently ignores `sort`. Defaults to false.
2768
+ */
2769
+ useOpenSearch?: boolean;
2770
+ }
2687
2771
  /**
2688
2772
  * Suggested tags and groups for mockup discovery.
2689
2773
  */
@@ -2810,7 +2894,7 @@ export interface ObjectAPI {
2810
2894
  *
2811
2895
  * @example
2812
2896
  * ```typescript
2813
- * const objectApi = new ObjectAPI(projectManager, store);
2897
+ * const objectApi = new ObjectAPI(projectCapability, store);
2814
2898
  *
2815
2899
  * // Lock a background image to prevent accidental modification
2816
2900
  * const result = await objectApi.setLockedState({
@@ -2850,7 +2934,7 @@ export interface ObjectAPI {
2850
2934
  *
2851
2935
  * @example
2852
2936
  * ```typescript
2853
- * const objectApi = new ObjectAPI(projectManager, store);
2937
+ * const objectApi = new ObjectAPI(projectCapability, store);
2854
2938
  *
2855
2939
  * // Hide an object
2856
2940
  * const result = await objectApi.setHiddenState({
@@ -2901,7 +2985,7 @@ export interface ObjectAPI {
2901
2985
 
2902
2986
  * @example
2903
2987
  * ```typescript
2904
- * const objectApi = new ObjectAPI(projectManager, store);
2988
+ * const objectApi = new ObjectAPI(projectCapability, store);
2905
2989
  *
2906
2990
  * // Rotate a text element 90 degrees clockwise around its center (default)
2907
2991
  * await objectApi.rotateObject({
@@ -3703,26 +3787,6 @@ export interface StructureObjectMeta {
3703
3787
  */
3704
3788
  maskBackgroundColor?: string | null;
3705
3789
  }
3706
- /**
3707
- * What a generation's caller knows about the submission it belongs to.
3708
- *
3709
- * One submission is one Stop, so every generation of a group shares these.
3710
- *
3711
- * @public
3712
- */
3713
- export interface SubmissionOptions {
3714
- /**
3715
- * Abandons the work of preparing this generation - rasterizing and uploading
3716
- * its reference images - when the caller stops the submission it belongs to.
3717
- *
3718
- * An optimization, not the way to cancel: stopping a generation is
3719
- * {@link AIGeneratorAPI.cancelGenerations}, which works the same with or
3720
- * without this, and aborting once the create request has been sent does
3721
- * nothing. Pass it to avoid finishing an upload whose generation the user
3722
- * has already taken back.
3723
- */
3724
- signal?: AbortSignal;
3725
- }
3726
3790
  /**
3727
3791
  * API for creating and managing text elements in the design.
3728
3792
  *
@@ -4149,7 +4213,8 @@ export interface WithObjectLayout {
4149
4213
  flipX: boolean;
4150
4214
  flipY: boolean;
4151
4215
  }
4152
- 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_INPUT_MICRO_EDITOR_REMIX" | "AI_INPUT_MICRO_EDITOR_INPAINT" | "AI_HUB_GENERATE_IMAGE" | "AI_HUB_REMIX_IMAGE" | "AI_HUB_GENERATE_VIDEO" | "VIDEOBOARD" | "AGENT" | "AI_HUB_AGENT" | "WORKFLOW" | "MCP" | "MCP_WORKFLOW" | "AI_AGENT" | "AI_AGENT_CHAT" | "AI_AGENT_CHAT_WEBSITE" | "MOBILE_APP_GENERATE_IMAGE" | "MOBILE_APP_REMIX_IMAGE" | "MOBILE_APP_GENERATE_VIDEO" | "MOBILE_APP_AGENT";
4216
+ /** Where generation started, using the API's action-origin contract. */
4217
+ export type AIGenerationActionOrigin = GenerateContentActionOrigin;
4153
4218
  export type AIGenerationContentType = "image" | "video";
4154
4219
  export type AIGenerationModelTaskType = "IMAGE_TO_IMAGE" | "IMAGE_INPAINT" | "IMAGE_OUTPAINT" | "TEXT_TO_IMAGE" | "IMAGE_TO_VIDEO";
4155
4220
  /**
@@ -4224,11 +4289,9 @@ export type AIGeneratorAPI = {
4224
4289
  * @param generatorId - Unique identifier for the generator type
4225
4290
  * @param inputSettings - Generator-specific input parameters matching the API schema
4226
4291
  * @param output - Requested output settings for the generation
4227
- * @param options - What the caller knows about the submission this
4228
- * generation belongs to, see {@link SubmissionOptions}
4229
4292
  * @returns Object containing the generation ID
4230
4293
  */
4231
- generate: (generatorId: string, inputSettings: GenerationInputSettings, output: GenerationOutputSettings, options?: SubmissionOptions) => {
4294
+ generate: (generatorId: string, inputSettings: GenerationInputSettings, output: GenerationOutputSettings) => {
4232
4295
  generationId: string;
4233
4296
  };
4234
4297
  /**
@@ -4272,10 +4335,6 @@ export type AIGeneratorAPI = {
4272
4335
  * generation whose create request has not been sent is taken back without the
4273
4336
  * backend ever hearing about it.
4274
4337
  *
4275
- * Takes the submission rather than bare ids so this is also where the
4276
- * preparation still running for it is dropped - callers never do that
4277
- * themselves, and so cannot forget to.
4278
- *
4279
4338
  * @param submission - The submission to stop, from `createSubmissionTracker`.
4280
4339
  * A caller without a tracker can pass `{ generationIds }`.
4281
4340
  * @returns Promise resolving once every cancellation settled, listing the
@@ -4582,7 +4641,7 @@ export type AddSmartboardParams = {
4582
4641
  } & {
4583
4642
  position: AbsolutePosition | RelativePosition;
4584
4643
  size: Dimensions;
4585
- };
4644
+ } & Pick<SmartboardOptions, "generationSettings">;
4586
4645
  /**
4587
4646
  * Comprehensive font and styling properties for text customization and typography control.
4588
4647
  *
@@ -4660,6 +4719,11 @@ export type AddTextParams = {
4660
4719
  * **Default dimensions**: 200x50 pixels if not specified
4661
4720
  */
4662
4721
  size: Dimensions;
4722
+ /**
4723
+ * When set, assigns the new text to this board instead of resolving the board
4724
+ * id via `getObjectBoardId`.
4725
+ */
4726
+ boardId?: string;
4663
4727
  };
4664
4728
  /**
4665
4729
  * Parameters for adding a new video to the design.
@@ -4747,6 +4811,11 @@ export type AnimateViewportToBoundsParams = ViewportAnimationSettings & ObjectPo
4747
4811
  */
4748
4812
  export type AnimateViewportToCenterParams = ViewportAnimationSettings & ObjectPositionRect;
4749
4813
  export type AnimationChannel = (typeof ANIMATION_CHANNELS)[number];
4814
+ /**
4815
+ * How a track combines with the object's own property: `add` is
4816
+ * `property + value`, `replace` sets it.
4817
+ */
4818
+ export type AnimationComposite = "add" | "replace";
4750
4819
  /**
4751
4820
  * `cubic-bezier(x1, y1, x2, y2)`; x values within `[0, 1]`, y values may
4752
4821
  * overshoot. A mutable tuple on purpose: `Normalized<>` cannot map `readonly`
@@ -4761,13 +4830,39 @@ export type AnimationCubicBezierEasing = {
4761
4830
  y2: number
4762
4831
  ];
4763
4832
  };
4764
- export type AnimationEasing = AnimationEasingName | AnimationCubicBezierEasing;
4833
+ export type AnimationEasing = AnimationEasingName | AnimationCubicBezierEasing | AnimationStepsEasing | AnimationHoldEasing;
4765
4834
  export type AnimationEasingName = (typeof ANIMATION_EASING_NAMES)[number];
4835
+ /** Keeps the keyframe value until the next keyframe. */
4836
+ export type AnimationHoldEasing = {
4837
+ type: "hold";
4838
+ };
4766
4839
  /**
4767
4840
  * Key of an animation in the design state, built from its
4768
4841
  * {@link AnimationTarget}: `objectId` or `objectId/pathItemId`.
4769
4842
  */
4770
4843
  export type AnimationKey = string;
4844
+ /**
4845
+ * Curve the target travels along, driven by the `offsetDistance` channel.
4846
+ * Offsets are added to the position, so the curve is relative to where the
4847
+ * target rests (usually ending at `0,0`), in its parent's units.
4848
+ */
4849
+ export type AnimationMotionPath = {
4850
+ /**
4851
+ * SVG path data made of one absolute `M` followed by absolute `L` / `C`
4852
+ * commands, e.g. `'M -200 300 C -150 100 -50 0 0 0'`. A string rather than
4853
+ * points keeps it one atomic value in the design state.
4854
+ */
4855
+ path: string;
4856
+ /** Rotates the target along the curve's tangent, on top of `rotate`. */
4857
+ autoRotate?: boolean;
4858
+ };
4859
+ export type AnimationShapeChannel = typeof ANIMATION_SHAPE_CHANNEL;
4860
+ /** `steps(count, position)`: jumps in `count` equal steps. */
4861
+ export type AnimationStepsEasing = {
4862
+ type: "steps";
4863
+ count: number;
4864
+ position: "start" | "end";
4865
+ };
4771
4866
  export type Animations = Record<AnimationKey, NormalizedAnimation>;
4772
4867
  /**
4773
4868
  * Application state interface containing selection, viewport, active tool, and other UI state.
@@ -4779,25 +4874,27 @@ export type Animations = Record<AnimationKey, NormalizedAnimation>;
4779
4874
  */
4780
4875
  export type AppState = {
4781
4876
  /**
4782
- * Array of selected objects' ids.
4783
- * Note: unlike `selectedLayersIds`, this includes all selected objects regardless group structure; there won't be ids of groups.
4784
- */
4785
- selectedObjectsIds: string[];
4786
- /**
4787
- * Array of selected layers' ids.
4788
- * Note: all items in the list are on the same level in the group structure; there might be ids of groups.
4789
- */
4790
- selectedLayersIds: string[];
4791
- /**
4792
- * Array of selected artboards' ids.
4793
- */
4794
- selectedArtboardIds: string[];
4795
- /**
4796
- * Array of selected artboards' object ids.
4877
+ * Every selected id, in selection order — the single stored selection list
4878
+ * every selection getter of {@link AppStateAPI} (including
4879
+ * `getAllSelectedObjectsIds`) is derived from.
4880
+ *
4881
+ * The list holds the full closure of the selection: selecting a board or a
4882
+ * group also lists everything nested inside it, in canvas render order. It
4883
+ * mixes all the kinds of things that can be selected:
4884
+ *
4885
+ * - board ids
4886
+ * - object ids
4887
+ * - group ids (structure nodes that are not objects themselves)
4888
+ * - `link__<inputBoardId>_<targetBoardId>` ids for the connection between a
4889
+ * smartboard input and its target
4890
+ * - `path__<childObjectId>` ids for a single sub-path of an illustration
4891
+ * - ids the design state does not know yet, passed through untouched
4892
+ *
4893
+ * A board's texture and background are not selectable on their own: they
4894
+ * exist only as layer ids, which {@link AppStateAPI.getSelectedLayersIds}
4895
+ * derives from the selected board.
4797
4896
  */
4798
- selectedArtboardsObjectIds: string[];
4799
- /** All selected objects including: objects, artboards and artboards' objects */
4800
- allSelectedObjectsIds: string[];
4897
+ selectionIds: string[];
4801
4898
  /**
4802
4899
  * Active canvas mode after its mode-specific entry succeeds.
4803
4900
  *
@@ -4819,6 +4916,12 @@ export type AppState = {
4819
4916
  isViewOnlyMode: boolean;
4820
4917
  /** Whether the loaded design contains objects outside the supported viewport bounds. */
4821
4918
  hasLegacyOutOfBoundsObjects: boolean;
4919
+ /**
4920
+ * Canvas-owned: true when recoverable content exists but none is in view.
4921
+ * Excludes helpers and hidden/transparent objects; false in runtimes without
4922
+ * the renderer's content visibility stage and outside the default working mode.
4923
+ */
4924
+ isContentOutOfView: boolean;
4822
4925
  canvasSettings: SettingsType;
4823
4926
  /** Last-used pen tool stroke/fill settings, applied to newly drawn paths. */
4824
4927
  penToolSetting: {
@@ -4984,6 +5087,16 @@ export type CanvasMode = {
4984
5087
  } | {
4985
5088
  mode: "inpaint";
4986
5089
  targetId: string;
5090
+ }
5091
+ /**
5092
+ * A rich text object is being edited. Set by the canvas while the text is in
5093
+ * editing mode; it is not a `CanvasModeManager` mode. `range` holds the
5094
+ * selected characters and is absent until the canvas reports it.
5095
+ */
5096
+ | {
5097
+ mode: "text-editing";
5098
+ targetId: string;
5099
+ range?: TextRange;
4987
5100
  } | {
4988
5101
  mode: "custom";
4989
5102
  id: string;
@@ -4996,7 +5109,7 @@ export type CanvasMode = {
4996
5109
  *
4997
5110
  * @public
4998
5111
  */
4999
- export type CanvasModeKind = "erase" | "erase-and-fill" | "crop" | "reframe" | "inpaint" | null;
5112
+ export type CanvasModeKind = "erase" | "erase-and-fill" | "crop" | "reframe" | "inpaint" | "text-editing" | null;
5000
5113
  /**
5001
5114
  * The index of a character in the rich text object.
5002
5115
  */
@@ -5074,6 +5187,10 @@ export type CreateBasicShapeInput = CreateElementWithPositionAndSize & {
5074
5187
  */
5075
5188
  export type CreateBoardParams = Omit<CreateElementWithPositionAndSize, "size" | "boardId"> & {
5076
5189
  title?: string;
5190
+ /**
5191
+ * Layout of the new artboard. Defaults to the standard layout.
5192
+ */
5193
+ activeLayout?: ArtboardOptions["activeLayout"];
5077
5194
  /**
5078
5195
  * size required on artboard
5079
5196
  */
@@ -5494,6 +5611,7 @@ export type FullColor = {
5494
5611
  visible: boolean;
5495
5612
  };
5496
5613
  export type FunctionType = (...args: never) => unknown;
5614
+ export type GenerateContentActionOrigin = (typeof GenerateContentActionOrigin)[keyof typeof GenerateContentActionOrigin];
5497
5615
  /** Alias: capability name for AIGenerationInputSettings. @public */
5498
5616
  export type GenerationInputSettings = AIGenerationInputSettings;
5499
5617
  /** Alias: capability name for AIGenerationOutputSettings. @public */
@@ -5737,6 +5855,14 @@ export type JSONObject = {
5737
5855
  [key: string]: JSONValue;
5738
5856
  };
5739
5857
  export type JSONValue = null | boolean | number | string | Array<JSONValue> | JSONObject;
5858
+ export type KeyframeBase = {
5859
+ id: string;
5860
+ /**
5861
+ * Easing of the segment that starts at this keyframe. Defaults to
5862
+ * {@link DEFAULT_KEYFRAME_EASING}, ignored on the last keyframe.
5863
+ */
5864
+ easing?: AnimationEasing;
5865
+ };
5740
5866
  /**
5741
5867
  * The predefined OpenType variation axes. However, a font can define custom
5742
5868
  * axes using a four-character string.
@@ -5757,6 +5883,15 @@ export type LeftTopPosition = {
5757
5883
  left: number;
5758
5884
  top: number;
5759
5885
  };
5886
+ /**
5887
+ * The derived selection lists readable through the `appState` subscribe
5888
+ * channel. None of them is stored in {@link AppState} (only the selection
5889
+ * closure `selectionIds` is); they are derived by the app state API, and the host bridge merges
5890
+ * them in before delivering updates (see `createExtensionAppStateStore` in
5891
+ * `@repo/sandbox-wrapper`), so published extensions can keep subscribing to
5892
+ * them by their legacy names.
5893
+ */
5894
+ export type LegacySelectionKey = "selectedObjectsIds" | "selectedLayersIds" | "selectedArtboardIds" | "selectedArtboardsObjectIds" | "allSelectedObjectsIds";
5760
5895
  /**
5761
5896
  * The line height of the text.
5762
5897
  */
@@ -5912,10 +6047,20 @@ export type NormalizeValue<T> = T extends null | undefined ? T : NonNullable<T>
5912
6047
  * instead of trying to normalize the union as a whole.
5913
6048
  */
5914
6049
  export type Normalized<T> = T extends null | undefined ? T : T extends Builtin ? T : T extends unknown[] | readonly unknown[] ? NormalizeArray<T> : T extends object ? NormalizeObject<T> : T;
5915
- /** `keyframes` becomes a record plus `keyframesIndices` for ordering. */
5916
- export type NormalizedAnimation = Normalized<SerializedAnimation>;
6050
+ /** `tracks` becomes a record plus `tracksIndices` for ordering. */
6051
+ export type NormalizedAnimation = Normalized<Omit<SerializedAnimation, "tracks">> & {
6052
+ tracks: Record<string, NormalizedTrack>;
6053
+ tracksIndices: Record<string, string>;
6054
+ };
5917
6055
  export type NormalizedBasicShapeObject = Normalized<BasicShapeSerializedObject>;
5918
6056
  export type NormalizedBoard = NormalizedStandardBoard | NormalizedFloatingBoard;
6057
+ /**
6058
+ * `keyframes` becomes a record plus `keyframesIndices` for ordering. A record
6059
+ * has no first entry, so it holds any {@link SerializedKeyframe}.
6060
+ */
6061
+ export type NormalizedChannelTrack = Normalized<Omit<SerializedChannelTrack, "keyframes"> & {
6062
+ keyframes: SerializedKeyframe[];
6063
+ }>;
5919
6064
  export type NormalizedCombinedShapeObject = Normalized<CombinedShapeSerializedObject>;
5920
6065
  export type NormalizedDesignState = {
5921
6066
  boards: Record<ID, NormalizedBoard>;
@@ -5949,11 +6094,14 @@ export type NormalizedPathTextObject = Normalized<PathTextSerializedObject>;
5949
6094
  * In the normalized form all object references are replaced by their ids.
5950
6095
  */
5951
6096
  export type NormalizedRichTextObject = Normalized<RichTextSerializedObject>;
6097
+ /** `keyframes` becomes a record plus `keyframesIndices` for ordering. */
6098
+ export type NormalizedShapeTrack = Normalized<SerializedShapeTrack>;
5952
6099
  /**
5953
6100
  * The normalized version of a StandardBoard
5954
6101
  */
5955
6102
  export type NormalizedStandardBoard<T extends ArtboardOptions = ArtboardOptions> = Normalized<BaseStandardBoard<T>>;
5956
6103
  export type NormalizedStandardObject = NormalizedBasicShapeObject | NormalizedCombinedShapeObject | NormalizedIllustrationImageObject | NormalizedIllustrationObject | NormalizedLoadingCardObject | NormalizedMaskObject | NormalizedMockupDesignObject | NormalizedPathTextObject | NormalizedRichTextObject | NormalizedVideoObject;
6104
+ export type NormalizedTrack = NormalizedChannelTrack | NormalizedShapeTrack;
5957
6105
  export type NormalizedVideoObject = Normalized<VideoSerializedObject>;
5958
6106
  export type NullablePathTextShadowOptions = PathTextShadowOptions | {
5959
6107
  type: null;
@@ -6127,6 +6275,8 @@ export type PlainInputSetting = {
6127
6275
  isPremium?: boolean;
6128
6276
  name: "combineBoards" | (string & {});
6129
6277
  label?: string;
6278
+ /** Help text shown when hovering a boolean setting. */
6279
+ tooltip?: string;
6130
6280
  disabled?: true;
6131
6281
  } & ({
6132
6282
  type: "selection";
@@ -6169,18 +6319,16 @@ export type PrintMargins = {
6169
6319
  bottom: number;
6170
6320
  left: number;
6171
6321
  };
6322
+ /** Generator API exposed to iframe clients. Same as {@link AIGeneratorAPI}. */
6323
+ export type PublicAIGeneratorAPI = AIGeneratorAPI;
6324
+ /** App selectors cover the approved subscription fields within the full snapshot. */
6325
+ export type PublicAppSelectorState = Pick<PublicAppState, (typeof APP_STATE_SUBSCRIPTION_KEYS)[number]>;
6172
6326
  /**
6173
- * Generator API exposed to iframe clients. Local AbortSignals and abort callbacks
6174
- * cannot cross postMessage; cancellation uses the host's generation IDs instead.
6327
+ * The shape of the state extensions can subscribe to over the `appState`
6328
+ * channel: the current {@link AppState} plus the five derived, read-only
6329
+ * {@link LegacySelectionKey} lists.
6175
6330
  */
6176
- export type PublicAIGeneratorAPI = Omit<AIGeneratorAPI, "generate" | "cancelGenerations"> & {
6177
- /** Starts a generation without accepting a caller-local AbortSignal. */
6178
- generate: (generatorId: string, inputSettings: GenerationInputSettings, output: GenerationOutputSettings) => ReturnType<AIGeneratorAPI["generate"]>;
6179
- /** Cancels a submission using only its serializable fields. */
6180
- cancelGenerations: (submission: Pick<CancellableSubmission, "generationIds" | "until">) => ReturnType<AIGeneratorAPI["cancelGenerations"]>;
6181
- };
6182
- /** App selectors cover the approved subscription fields within the full snapshot. */
6183
- export type PublicAppSelectorState = Pick<AppState, (typeof APP_STATE_SUBSCRIPTION_KEYS)[number]>;
6331
+ export type PublicAppState = AppState & Record<LegacySelectionKey, string[]>;
6184
6332
  /** Design domain methods; whole-state reads belong to the state surface. */
6185
6333
  export type PublicDesignAPI = PublicDesignMethods<Omit<DesignAPI, "state"> & {
6186
6334
  state: Omit<DesignAPI["state"], "getState">;
@@ -6823,8 +6971,9 @@ export type SerialisedPhotoFilter = ({
6823
6971
  export type SerializableCornerRadii = Record<string, Record<string, number>>;
6824
6972
  export type SerializableObjectType = ObjectType.IllustrationImage | ObjectType.Illustration | ObjectType.Artboard | ObjectType.Smartboard | ObjectType.Videoboard | ObjectType.MockupBoard | ObjectType.PathText | ObjectType.RichText | ObjectType.MockupDesign | ObjectType.OverlayTexture | ObjectType.Mask | ObjectType.BasicShape | ObjectType.VectorPath | ObjectType.Guide | ObjectType.CombinedShape | ObjectType.LoadingCard | ObjectType.Video;
6825
6973
  /**
6826
- * Keyframes of one target. The animation lasts until its last keyframe (see
6827
- * `getAnimationDuration`), so there is no separate duration to keep in sync.
6974
+ * Tracks of one target, at most one per channel. The animation lasts until
6975
+ * its last keyframe (see `getAnimationDuration`), so there is no separate
6976
+ * duration to keep in sync.
6828
6977
  */
6829
6978
  export type SerializedAnimation = {
6830
6979
  /**
@@ -6835,20 +6984,75 @@ export type SerializedAnimation = {
6835
6984
  x: number;
6836
6985
  y: number;
6837
6986
  };
6838
- keyframes: SerializedKeyframe[];
6987
+ motionPath?: AnimationMotionPath;
6988
+ /**
6989
+ * Distance from the viewer to the canvas plane for the 3D channels, in
6990
+ * canvas px, like CSS `perspective()`; positive. Defaults to `1000`. When
6991
+ * several animations apply to one object, the most specific one that sets
6992
+ * it wins.
6993
+ */
6994
+ perspective?: number;
6995
+ tracks: SerializedTrack[];
6839
6996
  };
6840
- export type SerializedKeyframe = {
6997
+ /** Keyframes of one channel. */
6998
+ export type SerializedChannelTrack = {
6999
+ id: string;
7000
+ channel: AnimationChannel;
7001
+ composite: AnimationComposite;
7002
+ /** Unique times; the fractional-index order only breaks ties. */
7003
+ keyframes: SerializedKeyframes;
7004
+ };
7005
+ /** Any keyframe of a track, see {@link SerializedKeyframes} for their order. */
7006
+ export type SerializedKeyframe<TValue = number> = SerializedStartKeyframe<TValue> | SerializedTimedKeyframe<TValue>;
7007
+ /**
7008
+ * Keyframes of a track. Only the first one may be a start keyframe without
7009
+ * `value`; every later keyframe has one. A track whose first keyframe comes
7010
+ * after `0` starts from the target's own value with
7011
+ * {@link DEFAULT_KEYFRAME_EASING}, as if it had a start keyframe without
7012
+ * value and easing.
7013
+ */
7014
+ export type SerializedKeyframes<TValue = number> = [
7015
+ ] | [
7016
+ SerializedKeyframe<TValue>,
7017
+ ...SerializedTimedKeyframe<TValue>[]
7018
+ ];
7019
+ export type SerializedObject = StandardSerializedObject | GuideSerializedObject;
7020
+ /**
7021
+ * Keyframe of the shape track: `value` is absolute SVG path data (`M L C Q
7022
+ * Z`). Lines, quadratics and cubics may morph into each other as long as the
7023
+ * structure (subpaths, segment count per subpath, closed flags) matches the
7024
+ * path's own; only positions interpolate. Every shape keyframe has a value,
7025
+ * since playback cannot read the path's own shape, and the track holds its
7026
+ * first shape before its first keyframe.
7027
+ */
7028
+ export type SerializedShapeKeyframe = SerializedTimedKeyframe<string>;
7029
+ /** Keyframes of the path shape; it replaces the shape, so has no composite. */
7030
+ export type SerializedShapeTrack = {
6841
7031
  id: string;
7032
+ channel: AnimationShapeChannel;
7033
+ /** Unique times; the fractional-index order only breaks ties. */
7034
+ keyframes: SerializedShapeKeyframe[];
7035
+ };
7036
+ /**
7037
+ * Keyframe at the animation start. Without `value` it starts from the
7038
+ * target's own value, like a CSS animation without a `0%` keyframe, so it
7039
+ * can set only the easing of the first segment.
7040
+ */
7041
+ export type SerializedStartKeyframe<TValue = number> = KeyframeBase & {
7042
+ time: 0;
7043
+ value?: TValue;
7044
+ };
7045
+ export type SerializedTimedKeyframe<TValue = number> = KeyframeBase & {
6842
7046
  /** Offset from the animation start, integer milliseconds. */
6843
7047
  time: number;
6844
- /** Easing of the segment that ends at this keyframe. Defaults to `linear`. */
6845
- easing?: AnimationEasing;
6846
- /** A channel that is omitted keeps its previous value. */
6847
- values: Partial<Record<AnimationChannel, number>>;
6848
- /** Channels not listed here use `add`. */
6849
- composites?: Partial<Record<AnimationChannel, "replace">>;
7048
+ /**
7049
+ * Relative to the object, not to the previous keyframe: with `add` an
7050
+ * offset from the object's own property (e.g. `translateX: 10` is 10px right
7051
+ * of the object), with `replace` the absolute property value.
7052
+ */
7053
+ value: TValue;
6850
7054
  };
6851
- export type SerializedObject = StandardSerializedObject | GuideSerializedObject;
7055
+ export type SerializedTrack = SerializedChannelTrack | SerializedShapeTrack;
6852
7056
  export type SetCanvasModeWithTargetOptions = {
6853
7057
  /**
6854
7058
  * Optional origin metadata for state propagation.
@@ -6858,6 +7062,11 @@ export type SetCanvasModeWithTargetOptions = {
6858
7062
  * Optional id of the object that should enter the mode.
6859
7063
  */
6860
7064
  targetId?: string | null;
7065
+ /**
7066
+ * Optional selected character range of the edited text. Only used by
7067
+ * `'text-editing'`.
7068
+ */
7069
+ range?: TextRange;
6861
7070
  };
6862
7071
  /** Color updates to apply to one object. */
6863
7072
  export type SetColorsParams = {
@@ -6937,6 +7146,7 @@ export type ShapeProperties = {
6937
7146
  skewY?: BasicShapeSerializedObject["skewY"];
6938
7147
  cornerRadii?: BasicShapeSerializedObject["cornerRadii"];
6939
7148
  name?: BasicShapeSerializedObject["name"];
7149
+ defaultName?: BasicShapeSerializedObject["defaultName"];
6940
7150
  shadowOptions?: BasicShapeSerializedObject["shadowOptions"];
6941
7151
  fill?: NonNullable<BasicShapeSerializedObject["fill"]>;
6942
7152
  fillColor?: NonNullable<BasicShapeSerializedObject["fill"]>[number]["value"];
@@ -7230,6 +7440,15 @@ export type TextProperties = {
7230
7440
  */
7231
7441
  strokeWidth?: number;
7232
7442
  };
7443
+ /**
7444
+ * Character range of the text being edited, in Fabric character indices.
7445
+ * A line break (`'\n'`) counts as one character, and `start === end` is a
7446
+ * caret without a selection.
7447
+ */
7448
+ export type TextRange = {
7449
+ start: number;
7450
+ end: number;
7451
+ };
7233
7452
  /**
7234
7453
  * Parameters for changing the hidden state of an illustration path.
7235
7454
  *
@@ -7250,6 +7469,9 @@ export type ToggleLockIllustrationPathParams = {
7250
7469
  pathId: string;
7251
7470
  locked: boolean;
7252
7471
  };
7472
+ export type TrimTransparentEdgesParams = {
7473
+ id: IllustrationImageSerializedObject["id"];
7474
+ };
7253
7475
  /** Preserves variant-specific object fields in design selectors. */
7254
7476
  export type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends (value: infer I) => void ? I : never;
7255
7477
  /**
@@ -7317,6 +7539,9 @@ export type UpdateIllustrationParams = {
7317
7539
  stroke?: IllustrationSerializedObject["stroke"];
7318
7540
  strokeWidth?: IllustrationSerializedObject["strokeWidth"];
7319
7541
  fill?: IllustrationSerializedObject["fill"];
7542
+ opacity?: IllustrationSerializedObject["opacity"];
7543
+ flipX?: IllustrationSerializedObject["flipX"];
7544
+ flipY?: IllustrationSerializedObject["flipY"];
7320
7545
  };
7321
7546
  /**
7322
7547
  * Parameters for updating an existing image.
@@ -7338,6 +7563,23 @@ export type UpdateImageParams = {
7338
7563
  strokeWidth?: IllustrationImageSerializedObject["strokeWidth"];
7339
7564
  inpaintingStrokeWidth?: IllustrationImageSerializedObject["inpaintingStrokeWidth"];
7340
7565
  inpaintingSelectionMode?: IllustrationImageSerializedObject["inpaintingSelectionMode"];
7566
+ opacity?: IllustrationImageSerializedObject["opacity"];
7567
+ flipX?: IllustrationImageSerializedObject["flipX"];
7568
+ flipY?: IllustrationImageSerializedObject["flipY"];
7569
+ /**
7570
+ * Photo filters to add or replace, keyed by filter id; `null` removes one.
7571
+ * Merged into the current filters. Every filter must end up with an index
7572
+ * in `filtersIndices`, and an image has at most one filter of each type.
7573
+ */
7574
+ filters?: Record<string, NonNullable<NormalizedIllustrationImageObject["filters"]>[string] | null>;
7575
+ /**
7576
+ * Fractional index of each filter id, which sets the order the filters
7577
+ * apply in; `null` removes one. Merged into the current indices, so the
7578
+ * filters can be reordered without sending them.
7579
+ */
7580
+ filtersIndices?: Record<string, string | null>;
7581
+ globalCompositeOperation?: IllustrationImageSerializedObject["globalCompositeOperation"];
7582
+ backgroundRestorePathBoundary?: IllustrationImageSerializedObject["backgroundRestorePathBoundary"];
7341
7583
  } & GeneratableObject;
7342
7584
  export type UpdateImageSourceParams = {
7343
7585
  id: IllustrationImageSerializedObject["id"];
@@ -7477,6 +7719,36 @@ export type UpdateTextParams = {
7477
7719
  left?: number;
7478
7720
  top?: number;
7479
7721
  angle?: number;
7722
+ /**
7723
+ * Opacity of the whole text element, from 0 (transparent) to 1 (opaque)
7724
+ */
7725
+ opacity?: number;
7726
+ /**
7727
+ * Mirror the text horizontally
7728
+ */
7729
+ flipX?: boolean;
7730
+ /**
7731
+ * Mirror the text vertically
7732
+ */
7733
+ flipY?: boolean;
7734
+ /**
7735
+ * Width of the text box in pixels
7736
+ */
7737
+ width?: number;
7738
+ /**
7739
+ * Height of the text box in pixels
7740
+ */
7741
+ height?: number;
7742
+ /**
7743
+ * Per-character style overrides, in the compressed format the text
7744
+ * object stores. Replaces the stored overrides as a whole.
7745
+ */
7746
+ styles?: RichTextCompressedStyles;
7747
+ /**
7748
+ * Transform (warp, circle, free form or free line) shaping the text, with
7749
+ * its points. Replaces the stored transform as a whole.
7750
+ */
7751
+ activeTransformPlugin?: RichTextSerializedTransformPluginObject;
7480
7752
  } & Partial<TextProperties>;
7481
7753
  /**
7482
7754
  * Parameters for updating texture properties.
@@ -7640,6 +7912,13 @@ export type VideoboardOptions = ConnectedArtboardOptions<ObjectType.Videoboard>
7640
7912
  * @public
7641
7913
  */
7642
7914
  export type Viewport = {
7915
+ /**
7916
+ * Viewport size in screen pixels, measured from the canvas container.
7917
+ */
7918
+ pixelSize: {
7919
+ width: number;
7920
+ height: number;
7921
+ };
7643
7922
  /**
7644
7923
  * Viewport corners in canvas coordinates (derived from transform + canvas size).
7645
7924
  * - tl: top-left
@@ -7732,12 +8011,15 @@ export type ViewportAPI = {
7732
8011
  */
7733
8012
  setTransform(transform: Viewport["transform"], origin?: Origin): void;
7734
8013
  /**
7735
- * Returns the current viewport size in screen pixels.
8014
+ * Returns the current viewport size in screen pixels, measured from the
8015
+ * canvas container.
7736
8016
  */
7737
8017
  getPixelSize(): {
7738
8018
  width: number;
7739
8019
  height: number;
7740
8020
  };
8021
+ /** Reads the canvas-owned {@link AppState.isContentOutOfView} flag. */
8022
+ isContentOutOfView(): boolean;
7741
8023
  /**
7742
8024
  * Returns the current viewport zoom level.
7743
8025
  */
@@ -7767,7 +8049,8 @@ export type ViewportAPI = {
7767
8049
  */
7768
8050
  getCoords(): Viewport["coords"];
7769
8051
  /**
7770
- * Sets the viewport corner coordinates.
8052
+ * Sets the viewport corner coordinates and, when supplied, its measured
8053
+ * screen-space size.
7771
8054
  *
7772
8055
  * This is primarily for internal synchronization. In normal usage, prefer
7773
8056
  * updating the viewport via {@link set}, {@link setZoom}, or
@@ -7775,8 +8058,19 @@ export type ViewportAPI = {
7775
8058
  *
7776
8059
  * @param coords - The viewport corner coordinates to set
7777
8060
  * @param origin - Optional origin metadata for state propagation
8061
+ * @param pixelSize - Canvas-container size measured with these coordinates
8062
+ * (legacy callers that omit it derive a size from coordinates and zoom)
8063
+ */
8064
+ setCoords(coords: Viewport["coords"], origin?: Origin, pixelSize?: Viewport["pixelSize"]): void;
8065
+ /**
8066
+ * Publishes a viewport snapshot from the canvas renderer.
8067
+ *
8068
+ * Internal only — callers must obtain all fields from the same Fabric state.
8069
+ *
8070
+ * @param viewport - Transform, coordinates, and measured canvas size
8071
+ * @param origin - Optional origin metadata for state propagation
7778
8072
  */
7779
- setCoords(coords: Viewport["coords"], origin?: Origin): void;
8073
+ setSnapshot(viewport: Viewport, origin?: Origin): void;
7780
8074
  /**
7781
8075
  * Returns the current viewport center in world space.
7782
8076
  */