@snowcone-app/canvas 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/ERROR_CONTRACT.md +13 -0
  2. package/dist/{CanvasRenderer-B_3GISlW.js → CanvasRenderer-BEf0hXeF.js} +1083 -1071
  3. package/dist/CanvasRenderer-BEf0hXeF.js.map +1 -0
  4. package/dist/{CanvasStateV1-kL09wsAn.js → CanvasStateV1-BDSyYo4A.js} +872 -844
  5. package/dist/{CanvasStateV1-kL09wsAn.js.map → CanvasStateV1-BDSyYo4A.js.map} +1 -1
  6. package/dist/ContextualToolbars-C3D_6sep.js +5960 -0
  7. package/dist/ContextualToolbars-C3D_6sep.js.map +1 -0
  8. package/dist/{EditorCanvasImpl-CrI9C_xM.js → EditorCanvasImpl-DXeBz2CX.js} +8 -8
  9. package/dist/{EditorCanvasImpl-CrI9C_xM.js.map → EditorCanvasImpl-DXeBz2CX.js.map} +1 -1
  10. package/dist/{ExportManager-J2xK86uq.js → ExportManager-DUdis6se.js} +1307 -970
  11. package/dist/ExportManager-DUdis6se.js.map +1 -0
  12. package/dist/{FontAnalyzer-PE6nysqE.js → FontAnalyzer-DKG5JK0x.js} +1419 -1342
  13. package/dist/FontAnalyzer-DKG5JK0x.js.map +1 -0
  14. package/dist/{ImagePanel-CmQCxBGm.js → ImagePanel-CBgGqmVV.js} +53 -53
  15. package/dist/{ImagePanel-CmQCxBGm.js.map → ImagePanel-CBgGqmVV.js.map} +1 -1
  16. package/dist/SnowconeCanvas-BWPBngvI.js +1192 -0
  17. package/dist/SnowconeCanvas-BWPBngvI.js.map +1 -0
  18. package/dist/{UnifiedFontService-BJzoqfBF.js → UnifiedFontService-Co9tQ59z.js} +869 -826
  19. package/dist/UnifiedFontService-Co9tQ59z.js.map +1 -0
  20. package/dist/advanced.mjs +14 -14
  21. package/dist/api/embed.d.ts +2 -0
  22. package/dist/api/stable.d.ts +2 -0
  23. package/dist/components/CanvasContextMenu.d.ts +15 -0
  24. package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +27 -0
  25. package/dist/components/CanvasEditor.d.ts +8 -0
  26. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  27. package/dist/components/embed/kernel.d.ts +8 -0
  28. package/dist/components/toolbars/SecondaryPanels.d.ts +11 -0
  29. package/dist/components/ui/icons.d.ts +2 -0
  30. package/dist/contexts/CanvasServicesContext.d.ts +17 -0
  31. package/dist/contexts/EditorContext.d.ts +7 -0
  32. package/dist/core/TextElement.d.ts +13 -0
  33. package/dist/core/TextMetrics.d.ts +17 -3
  34. package/dist/core/rich-text-layout.d.ts +2 -0
  35. package/dist/core/text-spacing.d.ts +74 -0
  36. package/dist/{custom-icons-BWiUGqD6.js → custom-icons-BIaRovwG.js} +2 -2
  37. package/dist/{custom-icons-BWiUGqD6.js.map → custom-icons-BIaRovwG.js.map} +1 -1
  38. package/dist/{design-builder-bquxIHct.js → design-builder-JYLO_Hyi.js} +2 -2
  39. package/dist/{design-builder-bquxIHct.js.map → design-builder-JYLO_Hyi.js.map} +1 -1
  40. package/dist/{editorErrors-8uDRMhow.js → editorErrors-WzaNxU1Y.js} +181 -194
  41. package/dist/editorErrors-WzaNxU1Y.js.map +1 -0
  42. package/dist/{embed-L3oRIgsj.js → embed-Csez1hui.js} +113 -112
  43. package/dist/{embed-L3oRIgsj.js.map → embed-Csez1hui.js.map} +1 -1
  44. package/dist/embed.mjs +51 -45
  45. package/dist/embed.mjs.map +1 -1
  46. package/dist/errors/editorError.d.ts +8 -0
  47. package/dist/{guards-BlbhM5MX.js → guards-BSoX73yg.js} +2 -2
  48. package/dist/{guards-BlbhM5MX.js.map → guards-BSoX73yg.js.map} +1 -1
  49. package/dist/hooks/useKeyboardShortcuts.d.ts +15 -2
  50. package/dist/hooks/useLayers.d.ts +2 -0
  51. package/dist/hooks/useTextToolbar.d.ts +8 -0
  52. package/dist/index.mjs +42 -37
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/internals.mjs +47 -47
  55. package/dist/rendering/renderer-types.d.ts +4 -0
  56. package/dist/rendering/rich-text-renderer.d.ts +4 -0
  57. package/dist/rendering/text-renderer.d.ts +4 -1
  58. package/dist/state/CanvasStateV1.d.ts +34 -3
  59. package/dist/state/index.d.ts +2 -2
  60. package/dist/{template-fields-ai7vnW8g.js → template-fields-DYPW7bVU.js} +40 -40
  61. package/dist/{template-fields-ai7vnW8g.js.map → template-fields-DYPW7bVU.js.map} +1 -1
  62. package/dist/testing.mjs +13 -13
  63. package/dist/types/index.d.ts +26 -0
  64. package/dist/{usePieceGuideBundle-CMe5br2a.js → usePieceGuideBundle-CRLY2iQa.js} +2 -2
  65. package/dist/{usePieceGuideBundle-CMe5br2a.js.map → usePieceGuideBundle-CRLY2iQa.js.map} +1 -1
  66. package/dist/utils/custom-fonts.d.ts +99 -0
  67. package/dist/utils/featureApplied.d.ts +6 -0
  68. package/dist/validation-BGEl9rrE.js +8686 -0
  69. package/dist/validation-BGEl9rrE.js.map +1 -0
  70. package/dist/workers/export-protocol.d.ts +13 -0
  71. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  72. package/example/package.json +1 -1
  73. package/package.json +1 -1
  74. package/dist/CanvasRenderer-B_3GISlW.js.map +0 -1
  75. package/dist/ContextualToolbars-C69oYLdw.js +0 -5771
  76. package/dist/ContextualToolbars-C69oYLdw.js.map +0 -1
  77. package/dist/ExportManager-J2xK86uq.js.map +0 -1
  78. package/dist/FontAnalyzer-PE6nysqE.js.map +0 -1
  79. package/dist/SnowconeCanvas-CQiFVR0X.js +0 -1173
  80. package/dist/SnowconeCanvas-CQiFVR0X.js.map +0 -1
  81. package/dist/UnifiedFontService-BJzoqfBF.js.map +0 -1
  82. package/dist/editorErrors-8uDRMhow.js.map +0 -1
  83. package/dist/validation-B8kIYutI.js +0 -8397
  84. package/dist/validation-B8kIYutI.js.map +0 -1
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { ArtboardManager } from '../core/ArtboardManager.js';
3
3
  import { ArtboardElement } from '../core/ArtboardElement.js';
4
4
  import { BaseElement } from '../core/BaseElement.js';
5
+ import { CustomFont } from '../utils/custom-fonts.js';
5
6
  declare const StrokeConfigSchema: z.ZodObject<{
6
7
  enabled: z.ZodBoolean;
7
8
  color: z.ZodString;
@@ -74,6 +75,7 @@ declare const CharacterStyleSchema: z.ZodObject<{
74
75
  italic: z.ZodOptional<z.ZodBoolean>;
75
76
  underline: z.ZodOptional<z.ZodBoolean>;
76
77
  strikethrough: z.ZodOptional<z.ZodBoolean>;
78
+ letterSpacing: z.ZodOptional<z.ZodNumber>;
77
79
  }, z.core.$strip>;
78
80
  declare const TextSpanSchema: z.ZodObject<{
79
81
  text: z.ZodString;
@@ -85,6 +87,7 @@ declare const TextSpanSchema: z.ZodObject<{
85
87
  italic: z.ZodOptional<z.ZodBoolean>;
86
88
  underline: z.ZodOptional<z.ZodBoolean>;
87
89
  strikethrough: z.ZodOptional<z.ZodBoolean>;
90
+ letterSpacing: z.ZodOptional<z.ZodNumber>;
88
91
  }, z.core.$strip>;
89
92
  }, z.core.$strip>;
90
93
  declare const RichTextSchema: z.ZodObject<{
@@ -98,6 +101,7 @@ declare const RichTextSchema: z.ZodObject<{
98
101
  italic: z.ZodOptional<z.ZodBoolean>;
99
102
  underline: z.ZodOptional<z.ZodBoolean>;
100
103
  strikethrough: z.ZodOptional<z.ZodBoolean>;
104
+ letterSpacing: z.ZodOptional<z.ZodNumber>;
101
105
  }, z.core.$strip>;
102
106
  }, z.core.$strip>>;
103
107
  }, z.core.$strip>;
@@ -263,6 +267,15 @@ declare const SerializedArtboardSchema: z.ZodObject<{
263
267
  }>>;
264
268
  elementIds: z.ZodArray<z.ZodString>;
265
269
  }, z.core.$strip>;
270
+ /**
271
+ * A custom (brand) font dependency of the design — `{ family, url }` of a
272
+ * host-stored font binary plus optional weight/style descriptors. Saved
273
+ * designs carry these so every consumer (live editor, export worker, server
274
+ * render) can load the exact file. Families are stored as-is; a family that
275
+ * collides with a Google Fonts family deterministically SHADOWS it (see
276
+ * `utils/custom-fonts.ts` for the resolution contract).
277
+ */
278
+ declare const CustomFontSchema: z.ZodType<CustomFont>;
266
279
  /**
267
280
  * Top-level CanvasStateV1 schema.
268
281
  *
@@ -270,6 +283,7 @@ declare const SerializedArtboardSchema: z.ZodObject<{
270
283
  * - `artboards` contains serialized artboard configs with `elementIds`.
271
284
  * - `elements` is a flat array of all elements across all artboards.
272
285
  * - `activeArtboardId` identifies which artboard is currently active.
286
+ * - `customFonts` (optional) lists the design's custom-font dependencies.
273
287
  */
274
288
  declare const CanvasStateV1Schema: z.ZodObject<{
275
289
  version: z.ZodLiteral<1>;
@@ -321,6 +335,7 @@ declare const CanvasStateV1Schema: z.ZodObject<{
321
335
  }, z.core.$strip>>;
322
336
  elements: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
323
337
  activeArtboardId: z.ZodString;
338
+ customFonts: z.ZodOptional<z.ZodArray<z.ZodType<CustomFont, unknown, z.core.$ZodTypeInternals<CustomFont, unknown>>>>;
324
339
  }, z.core.$strip>;
325
340
  /** A serialized artboard (artboard config + elementIds, no nested elements). */
326
341
  type SerializedArtboard = z.infer<typeof SerializedArtboardSchema>;
@@ -328,19 +343,35 @@ type SerializedArtboard = z.infer<typeof SerializedArtboardSchema>;
328
343
  type SerializedElement = z.infer<typeof AnyElementConfigSchema>;
329
344
  /** The full versioned state document. */
330
345
  type CanvasStateV1 = z.infer<typeof CanvasStateV1Schema>;
346
+ /** Options for {@link serializeState}. */
347
+ interface SerializeStateOptions {
348
+ /**
349
+ * Custom-font dependencies to embed in the document. When omitted, the
350
+ * default is CORRECT, not empty: the registered custom fonts whose family
351
+ * is actually used by the serialized elements are included automatically,
352
+ * so a host that uploaded a brand font cannot forget to persist it.
353
+ * Pass `[]` explicitly to serialize without custom fonts.
354
+ */
355
+ customFonts?: readonly CustomFont[];
356
+ }
331
357
  /**
332
358
  * Serialize the current editor state into a `CanvasStateV1` document.
333
359
  *
334
360
  * @param artboardManager - The ArtboardManager instance (provides artboard list + active ID).
335
361
  * @param elements - All elements currently in the editor (across all artboards).
362
+ * @param options - See {@link SerializeStateOptions} (`customFonts` defaults to
363
+ * the registered custom fonts the elements actually use).
336
364
  * @returns A validated CanvasStateV1 object ready for JSON.stringify().
337
365
  */
338
- declare function serializeState(artboardManager: ArtboardManager, elements: BaseElement[]): CanvasStateV1;
366
+ declare function serializeState(artboardManager: ArtboardManager, elements: BaseElement[], options?: SerializeStateOptions): CanvasStateV1;
339
367
  /** Result of deserializing a CanvasStateV1 document. */
340
368
  interface DeserializeResult {
341
369
  artboards: ArtboardElement[];
342
370
  elements: BaseElement[];
343
371
  activeArtboardId: string;
372
+ /** The design's custom-font dependencies (already registered with
373
+ * `customFontRegistry` as a side effect of deserializing). */
374
+ customFonts: CustomFont[];
344
375
  }
345
376
  /**
346
377
  * Deserialize a validated `CanvasStateV1` document back into runtime objects.
@@ -381,5 +412,5 @@ declare function validateState(data: unknown): ValidationResult;
381
412
  * @throws Error if the data cannot be migrated.
382
413
  */
383
414
  declare function migrateState(data: unknown): CanvasStateV1;
384
- export { CanvasStateV1Schema, SerializedArtboardSchema, AnyElementConfigSchema, AnyTransformDataSchema, StrokeConfigSchema, KnockoutConfigSchema, DistressEffectSchema, MaskDefinitionSchema, CharacterStyleSchema, TextSpanSchema, RichTextSchema, ClipShapeSchema, serializeState, deserializeState, validateState, migrateState, };
385
- export type { CanvasStateV1, SerializedArtboard, SerializedElement, DeserializeResult, ValidationResult, };
415
+ export { CanvasStateV1Schema, SerializedArtboardSchema, AnyElementConfigSchema, AnyTransformDataSchema, StrokeConfigSchema, KnockoutConfigSchema, DistressEffectSchema, MaskDefinitionSchema, CharacterStyleSchema, TextSpanSchema, RichTextSchema, ClipShapeSchema, CustomFontSchema, serializeState, deserializeState, validateState, migrateState, };
416
+ export type { CanvasStateV1, SerializedArtboard, SerializedElement, DeserializeResult, ValidationResult, SerializeStateOptions, CustomFont, };
@@ -6,5 +6,5 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- export { CanvasStateV1Schema, SerializedArtboardSchema, AnyElementConfigSchema, AnyTransformDataSchema, StrokeConfigSchema, KnockoutConfigSchema, DistressEffectSchema, MaskDefinitionSchema, CharacterStyleSchema, TextSpanSchema, RichTextSchema, ClipShapeSchema, serializeState, deserializeState, validateState, migrateState, } from './CanvasStateV1.js';
10
- export type { CanvasStateV1, SerializedArtboard, SerializedElement, DeserializeResult, ValidationResult, } from './CanvasStateV1.js';
9
+ export { CanvasStateV1Schema, SerializedArtboardSchema, AnyElementConfigSchema, AnyTransformDataSchema, StrokeConfigSchema, KnockoutConfigSchema, DistressEffectSchema, MaskDefinitionSchema, CharacterStyleSchema, TextSpanSchema, RichTextSchema, ClipShapeSchema, CustomFontSchema, serializeState, deserializeState, validateState, migrateState, } from './CanvasStateV1.js';
10
+ export type { CanvasStateV1, SerializedArtboard, SerializedElement, DeserializeResult, ValidationResult, SerializeStateOptions, CustomFont, } from './CanvasStateV1.js';
@@ -1,10 +1,10 @@
1
- import { g as C, u as ut, c as Y, b as W } from "./editorErrors-8uDRMhow.js";
2
- import { l as it, i as gt, a as Nt } from "./design-builder-bquxIHct.js";
3
- import { toOptionAttributes as St, toCombinations as It, getMissingSelections as wt, validateProductSelection as Ot, findBestCombination as J, computeDisabledChoices as At } from "@snowcone-app/sdk";
4
- import { useRef as E, useCallback as I, useEffect as Tt, useContext as ht, useId as kt, useLayoutEffect as Dt, useMemo as V, useState as ot } from "react";
5
- import { G as Bt, I as z, P as _t, S as Ft, T as K, z as yt, U as st, c as Ut, y as rt } from "./FontAnalyzer-PE6nysqE.js";
6
- import { p as pt, U as Rt } from "./UnifiedFontService-BJzoqfBF.js";
7
- import { a as Lt, o as R, b as d, n as Pt, l as b, u as at, c as Yt } from "./CanvasStateV1-kL09wsAn.js";
1
+ import { E as C, G as Nt, I as W, P as St, S as It, T as Y, C as ut, U as it, c as wt, z as ot } from "./FontAnalyzer-DKG5JK0x.js";
2
+ import { l as st, i as gt, a as Ot } from "./design-builder-JYLO_Hyi.js";
3
+ import { toOptionAttributes as At, toCombinations as Tt, getMissingSelections as kt, validateProductSelection as Dt, findBestCombination as J, computeDisabledChoices as Bt } from "@snowcone-app/sdk";
4
+ import { useRef as E, useCallback as I, useEffect as _t, useContext as ht, useId as Ft, useLayoutEffect as Ut, useMemo as V, useState as rt } from "react";
5
+ import { u as yt, c as K, b as z } from "./editorErrors-WzaNxU1Y.js";
6
+ import { p as pt, U as Rt } from "./UnifiedFontService-Co9tQ59z.js";
7
+ import { a as Lt, o as R, b as d, n as Pt, l as b, u as at, c as Yt } from "./CanvasStateV1-BDSyYo4A.js";
8
8
  function X(e) {
9
9
  return e.text;
10
10
  }
@@ -38,11 +38,11 @@ class $e {
38
38
  * for unbindable), or undefined when no layer has the name. */
39
39
  layerKindOf(t) {
40
40
  const n = this.state.elements.find((o) => L(o) === t);
41
- return n ? it(n) : void 0;
41
+ return n ? st(n) : void 0;
42
42
  }
43
43
  /** Names of bindable layers in the current state, for error messages. */
44
44
  bindableLayerNames() {
45
- return this.state.elements.filter((t) => it(t) !== null).map(L).filter((t) => !!t);
45
+ return this.state.elements.filter((t) => st(t) !== null).map(L).filter((t) => !!t);
46
46
  }
47
47
  /**
48
48
  * Direct write path for `Editor.TextField` when NO canvas is mounted (with
@@ -90,7 +90,7 @@ function Kt(e, t) {
90
90
  }
91
91
  class Ce {
92
92
  constructor(t) {
93
- this.quantity = 1, this.version = 0, this.listeners = /* @__PURE__ */ new Set(), this.getVersion = () => this.version, this.subscribe = (n) => (this.listeners.add(n), () => this.listeners.delete(n)), this.product = t, this.attrs = St({ options: t.options }), this.combos = It({ options: t.options }), this.selection = Kt(t, this.combos);
93
+ this.quantity = 1, this.version = 0, this.listeners = /* @__PURE__ */ new Set(), this.getVersion = () => this.version, this.subscribe = (n) => (this.listeners.add(n), () => this.listeners.delete(n)), this.product = t, this.attrs = At({ options: t.options }), this.combos = Tt({ options: t.options }), this.selection = Kt(t, this.combos);
94
94
  }
95
95
  getAttributes() {
96
96
  return this.attrs;
@@ -130,12 +130,12 @@ class Ce {
130
130
  /** Attribute keys still required (non-optional) but unselected — Buy's
131
131
  * `option:<key>` reason codes. */
132
132
  missingOptionKeys() {
133
- return Object.keys(this.attrs).length === 0 ? [] : wt(this.attrs, this.selection);
133
+ return Object.keys(this.attrs).length === 0 ? [] : kt(this.attrs, this.selection);
134
134
  }
135
135
  /** Full selection resolution (the C1 amendment): true when every required
136
136
  * attribute is selected AND the selection matches a valid combination. */
137
137
  selectionValid() {
138
- return Object.keys(this.attrs).length === 0 ? !0 : Ot(this.attrs, this.selection, this.combos);
138
+ return Object.keys(this.attrs).length === 0 ? !0 : Dt(this.attrs, this.selection, this.combos);
139
139
  }
140
140
  /** The variant (gvid) the current selection resolves to. Falls back to the
141
141
  * product's initial `variantId` while nothing has been selected. */
@@ -176,7 +176,7 @@ class Ce {
176
176
  const t = {};
177
177
  for (const [n, o] of Object.entries(this.attrs))
178
178
  t[n] = { ...o, choices: lt(o) };
179
- return At(this.selection, t, this.combos);
179
+ return Bt(this.selection, t, this.combos);
180
180
  }
181
181
  /** The combinations (for payload assembly via `createCartDetail`). */
182
182
  getCombinations() {
@@ -188,19 +188,19 @@ class Ce {
188
188
  }
189
189
  }
190
190
  function bt(e) {
191
- return e instanceof K;
191
+ return e instanceof Y;
192
192
  }
193
193
  function Mt(e) {
194
- return e instanceof z;
194
+ return e instanceof W;
195
195
  }
196
196
  function Ht(e) {
197
- return e instanceof Ft;
197
+ return e instanceof It;
198
198
  }
199
199
  function jt(e) {
200
- return e instanceof Bt;
200
+ return e instanceof Nt;
201
201
  }
202
202
  function Wt(e) {
203
- return e instanceof _t;
203
+ return e instanceof St;
204
204
  }
205
205
  function Vt(e) {
206
206
  return bt(e) ? "text" : Mt(e) ? "image" : Ht(e) ? "shape" : jt(e) ? "group" : Wt(e) ? "path" : null;
@@ -304,7 +304,7 @@ function Qt(e, t) {
304
304
  function Zt(e, t) {
305
305
  let n = !1;
306
306
  if (t.x !== void 0 && (e.x = t.x), t.y !== void 0 && (e.y = t.y), t.rotation !== void 0 && e.setRotation(t.rotation), t.opacity !== void 0 && (e.opacity = t.opacity), t.name !== void 0 && (e.name = t.name), t.visible !== void 0 && (e.visible = t.visible), t.locked !== void 0 && (e.locked = t.locked), bt(e))
307
- return t.text !== void 0 && e.setText(t.text), t.fontSize !== void 0 && e.setFontSize(t.fontSize), t.color !== void 0 && e.setColor(t.color), t.fontFamily !== void 0 && t.fontFamily !== e.fontFamily && (yt.clearCache(e.fontFamily), e.fontFamily = t.fontFamily), t.bold !== void 0 && (e.bold = t.bold), t.italic !== void 0 && (e.italic = t.italic), t.textAlign !== void 0 && (e.textAlign = t.textAlign), { needsImageLoad: n };
307
+ return t.text !== void 0 && e.setText(t.text), t.fontSize !== void 0 && e.setFontSize(t.fontSize), t.color !== void 0 && e.setColor(t.color), t.fontFamily !== void 0 && t.fontFamily !== e.fontFamily && (ut.clearCache(e.fontFamily), e.fontFamily = t.fontFamily), t.bold !== void 0 && (e.bold = t.bold), t.italic !== void 0 && (e.italic = t.italic), t.textAlign !== void 0 && (e.textAlign = t.textAlign), { needsImageLoad: n };
308
308
  const o = e;
309
309
  if (t.width !== void 0 && (o.transformData.width = t.width), t.height !== void 0 && (o.transformData.height = t.height), t.fillColor !== void 0 && (e.transformData.fillColor = t.fillColor), t.imageUrl !== void 0) {
310
310
  const i = e;
@@ -312,9 +312,9 @@ function Zt(e, t) {
312
312
  }
313
313
  return { needsImageLoad: n };
314
314
  }
315
- const mt = Ut("useCommands");
315
+ const mt = wt("useCommands");
316
316
  function Ne() {
317
- const e = ut(), {
317
+ const e = yt(), {
318
318
  undo: t,
319
319
  redo: n,
320
320
  canUndo: o,
@@ -340,7 +340,7 @@ function Ne() {
340
340
  const Et = _.current;
341
341
  let p = qt(Et, g);
342
342
  const M = O.getArtboardIdForElement(p.id) ?? O.getActiveArtboardId(), F = M ? x.peekArtboard(M) : null;
343
- F instanceof st && F.elementId === p.id && F.newElement && (p = F.newElement), Qt(p, k);
343
+ F instanceof it && F.elementId === p.id && F.newElement && (p = F.newElement), Qt(p, k);
344
344
  const H = p.clone(), { needsImageLoad: $t } = Zt(H, k);
345
345
  if ($t) {
346
346
  const B = H;
@@ -356,7 +356,7 @@ function Ne() {
356
356
  }
357
357
  if (A.current(p, H), D != null && D.coalesce && M) {
358
358
  const B = x.peekArtboard(M);
359
- N.current = B instanceof st ? { elementId: p.id, command: B } : null;
359
+ N.current = B instanceof it ? { elementId: p.id, command: B } : null;
360
360
  } else
361
361
  N.current = null;
362
362
  },
@@ -391,7 +391,7 @@ function Ne() {
391
391
  };
392
392
  }
393
393
  function Se() {
394
- const { selectedElement: e } = ut();
394
+ const { selectedElement: e } = yt();
395
395
  return e ?? null;
396
396
  }
397
397
  const te = 3e3, ft = {
@@ -408,7 +408,7 @@ const te = 3e3, ft = {
408
408
  font: "text"
409
409
  }, Z = /* @__PURE__ */ new Set();
410
410
  function dt(e) {
411
- return e instanceof K ? "text" : e instanceof z ? "image" : "other";
411
+ return e instanceof Y ? "text" : e instanceof W ? "image" : "other";
412
412
  }
413
413
  function ie(e, t, n) {
414
414
  const o = `[${ft[e]}]`, i = `the binding is dead (isConnected: false, ${ee[e]} is a no-op)`, s = ne[e], a = n.getAllByName(t);
@@ -420,9 +420,9 @@ function ie(e, t, n) {
420
420
  return `${o} no ${s} layer named "${t}" exists — ${i}. ${c}`;
421
421
  }
422
422
  function et(e, t, n, o) {
423
- Tt(() => {
423
+ _t(() => {
424
424
  var a;
425
- if (o || typeof rt > "u" || ((a = rt.env) == null ? void 0 : a.NODE_ENV) === "production") return;
425
+ if (o || typeof ot > "u" || ((a = ot.env) == null ? void 0 : a.NODE_ENV) === "production") return;
426
426
  const i = `${e}:${t}`;
427
427
  if (Z.has(i)) return;
428
428
  const s = setTimeout(() => {
@@ -432,14 +432,14 @@ function et(e, t, n, o) {
432
432
  }, [e, t, n, o]);
433
433
  }
434
434
  function G(e) {
435
- const t = ht(pt), n = kt();
436
- Dt(() => {
435
+ const t = ht(pt), n = Ft();
436
+ Ut(() => {
437
437
  if (t)
438
438
  return t.registry.requireCanvas(n, e);
439
439
  }, [t, n, e]);
440
440
  }
441
441
  function tt(e) {
442
- return e instanceof K ? "text" : e instanceof z ? "image" : null;
442
+ return e instanceof Y ? "text" : e instanceof W ? "image" : null;
443
443
  }
444
444
  const oe = {
445
445
  text: "useTextBinding / useFontBinding",
@@ -481,9 +481,9 @@ function nt(e, t, n) {
481
481
  const se = () => {
482
482
  }, re = [];
483
483
  function Ie(e) {
484
- const { elementStore: t } = Y();
484
+ const { elementStore: t } = K();
485
485
  G("useTextBinding()");
486
- const n = nt(e, "text", t), { executeElementUpdate: o } = W(), i = V(() => t.getAllByName(n).filter((r) => r instanceof K), [t, n]), s = I(
486
+ const n = nt(e, "text", t), { executeElementUpdate: o } = z(), i = V(() => t.getAllByName(n).filter((r) => r instanceof Y), [t, n]), s = I(
487
487
  (a) => {
488
488
  for (const r of i) {
489
489
  const c = r.clone();
@@ -528,7 +528,7 @@ function ce(e, t, n) {
528
528
  }
529
529
  function we(e, t) {
530
530
  G("useImageBinding()");
531
- const n = (t == null ? void 0 : t.fit) ?? "cover", { elementStore: o, setElements: i } = Y(), s = nt(e, "image", o), { executeElementUpdate: a } = W(), r = V(() => o.getAllByName(s).filter((h) => h instanceof z), [o, s]), c = E(/* @__PURE__ */ new Map());
531
+ const n = (t == null ? void 0 : t.fit) ?? "cover", { elementStore: o, setElements: i } = K(), s = nt(e, "image", o), { executeElementUpdate: a } = z(), r = V(() => o.getAllByName(s).filter((h) => h instanceof W), [o, s]), c = E(/* @__PURE__ */ new Map());
532
532
  for (const u of r)
533
533
  if (!c.current.has(u.id)) {
534
534
  const h = u.transformData;
@@ -590,9 +590,9 @@ function fe(e, t, n) {
590
590
  return $(i.color, t) && (typeof s.setColor == "function" ? s.setColor(n) : s.color = n), $((a = i.transformData) == null ? void 0 : a.fillColor, t) && (s.transformData = { ...s.transformData, fillColor: n }), $((r = i.transformData) == null ? void 0 : r.strokeColor, t) && (s.transformData = { ...s.transformData, strokeColor: n }), ((c = i.stroke) == null ? void 0 : c.enabled) === !0 && $(i.stroke.color, t) && (s.stroke = { ...s.stroke, color: n }), o;
591
591
  }
592
592
  function Oe(e) {
593
- const t = Nt(e) ? e.value : e, { elementStore: n } = Y(), { executeElementUpdate: o } = W();
593
+ const t = Ot(e) ? e.value : e, { elementStore: n } = K(), { executeElementUpdate: o } = z();
594
594
  G("useColorBinding()");
595
- const [i, s] = ot(() => j(t)), [a, r] = ot(t);
595
+ const [i, s] = rt(() => j(t)), [a, r] = rt(t);
596
596
  t !== a && (r(t), s(j(t)));
597
597
  const c = V(
598
598
  () => n.getAll().filter((m) => vt(m, i)),
@@ -615,14 +615,14 @@ function Oe(e) {
615
615
  const de = () => {
616
616
  }, ue = [];
617
617
  function Ae(e) {
618
- const { elementStore: t } = Y();
618
+ const { elementStore: t } = K();
619
619
  G("useFontBinding()");
620
- const n = nt(e, "text", t), { executeElementUpdate: o } = W(), i = V(() => t.getAllByName(n).filter((r) => r instanceof K), [t, n]), s = I(
620
+ const n = nt(e, "text", t), { executeElementUpdate: o } = z(), i = V(() => t.getAllByName(n).filter((r) => r instanceof Y), [t, n]), s = I(
621
621
  (a) => {
622
622
  Rt.loadGoogleFontByName(a);
623
623
  for (const r of i) {
624
624
  if (r.fontFamily === a) continue;
625
- yt.clearCache(r.fontFamily);
625
+ ut.clearCache(r.fontFamily);
626
626
  const c = r.clone();
627
627
  c.fontFamily = a, o(r, c);
628
628
  }
@@ -638,7 +638,7 @@ function Ae(e) {
638
638
  };
639
639
  }
640
640
  function Te(e) {
641
- const { elementStore: t } = Y();
641
+ const { elementStore: t } = K();
642
642
  return e ? t.getByName(e) ?? null : null;
643
643
  }
644
644
  const xt = "personalization", ge = Lt("type", [
@@ -713,4 +713,4 @@ export {
713
713
  Oe as u,
714
714
  De as w
715
715
  };
716
- //# sourceMappingURL=template-fields-ai7vnW8g.js.map
716
+ //# sourceMappingURL=template-fields-DYPW7bVU.js.map