@snowcone-app/canvas 0.40.11 → 0.40.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CanvasRenderer-b7W2QOJp.js → CanvasRenderer-COHWEK1r.js} +2 -2
- package/dist/{CanvasRenderer-b7W2QOJp.js.map → CanvasRenderer-COHWEK1r.js.map} +1 -1
- package/dist/{CanvasStateV1-zt4kyHFb.js → CanvasStateV1-DwziqxMO.js} +2 -2
- package/dist/{CanvasStateV1-zt4kyHFb.js.map → CanvasStateV1-DwziqxMO.js.map} +1 -1
- package/dist/{ContextualToolbars-Dx3Qyjkt.js → ContextualToolbars-D-EX9Q9L.js} +4 -4
- package/dist/{ContextualToolbars-Dx3Qyjkt.js.map → ContextualToolbars-D-EX9Q9L.js.map} +1 -1
- package/dist/{EditorCanvasImpl-Ddvyg6Mr.js → EditorCanvasImpl-CP6ipFq_.js} +6 -6
- package/dist/{EditorCanvasImpl-Ddvyg6Mr.js.map → EditorCanvasImpl-CP6ipFq_.js.map} +1 -1
- package/dist/{ExportManager-BQ9BPs1U.js → ExportManager-DLOH2Kzk.js} +68 -67
- package/dist/{ExportManager-BQ9BPs1U.js.map → ExportManager-DLOH2Kzk.js.map} +1 -1
- package/dist/{ImagePanel-CwuttJnt.js → ImagePanel-BIzwlaf5.js} +3 -3
- package/dist/{ImagePanel-CwuttJnt.js.map → ImagePanel-BIzwlaf5.js.map} +1 -1
- package/dist/{SnowconeCanvas-Dlec811f.js → SnowconeCanvas-991f9eds.js} +8 -8
- package/dist/{SnowconeCanvas-Dlec811f.js.map → SnowconeCanvas-991f9eds.js.map} +1 -1
- package/dist/advanced.mjs +9 -9
- package/dist/api/internals.d.ts +1 -1
- package/dist/{custom-icons-C1SbDFU3.js → custom-icons-DHew1GPV.js} +2 -2
- package/dist/{custom-icons-C1SbDFU3.js.map → custom-icons-DHew1GPV.js.map} +1 -1
- package/dist/{embed-CZcJqmA1.js → embed-CcKoxfdW.js} +7 -7
- package/dist/{embed-CZcJqmA1.js.map → embed-CcKoxfdW.js.map} +1 -1
- package/dist/embed.mjs +10 -10
- package/dist/index.mjs +12 -12
- package/dist/internals.mjs +117 -116
- package/dist/internals.mjs.map +1 -1
- package/dist/{template-fields-CCNA9LqM.js → template-fields-BzAlpOEB.js} +3 -3
- package/dist/{template-fields-CCNA9LqM.js.map → template-fields-BzAlpOEB.js.map} +1 -1
- package/dist/{useCommands-Bo1KbIND.js → useCommands-CLnk8kvW.js} +5 -5
- package/dist/{useCommands-Bo1KbIND.js.map → useCommands-CLnk8kvW.js.map} +1 -1
- package/dist/{validation-BRp5aW3B.js → validation-Q1_OcfJ_.js} +9 -9
- package/dist/{validation-BRp5aW3B.js.map → validation-Q1_OcfJ_.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as S, jsxs as O, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as T, useContext as w, useSyncExternalStore as D, useMemo as N, useRef as M, useLayoutEffect as j } from "react";
|
|
3
|
-
import { S as $ } from "./SnowconeCanvas-
|
|
4
|
-
import { C as G } from "./ContextualToolbars-
|
|
3
|
+
import { S as $ } from "./SnowconeCanvas-991f9eds.js";
|
|
4
|
+
import { C as G } from "./ContextualToolbars-D-EX9Q9L.js";
|
|
5
5
|
import { s as I, u as J, a as U } from "./design-builder-CoCtjIwj.js";
|
|
6
|
-
import { u as V } from "./embed-
|
|
6
|
+
import { u as V } from "./embed-CcKoxfdW.js";
|
|
7
7
|
import { A as z, T as L } from "./FontAnalyzer-DWHS41ba.js";
|
|
8
|
-
import { E as P } from "./ExportManager-
|
|
9
|
-
import { E as k } from "./useCommands-
|
|
8
|
+
import { E as P } from "./ExportManager-DLOH2Kzk.js";
|
|
9
|
+
import { E as k } from "./useCommands-CLnk8kvW.js";
|
|
10
10
|
const q = () => () => {
|
|
11
11
|
};
|
|
12
12
|
function K() {
|
|
@@ -141,4 +141,4 @@ const oe = T(
|
|
|
141
141
|
export {
|
|
142
142
|
oe as EditorCanvasImpl
|
|
143
143
|
};
|
|
144
|
-
//# sourceMappingURL=EditorCanvasImpl-
|
|
144
|
+
//# sourceMappingURL=EditorCanvasImpl-CP6ipFq_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorCanvasImpl-Ddvyg6Mr.js","sources":["../src/components/editor/EditorCanvasImpl.tsx"],"sourcesContent":["'use client';\n\n/**\n * The heavy half of `Editor.Canvas` (and of the legacy `<RealtimeCanvas>`),\n * extracted from RealtimeCanvas's body. This module statically imports\n * `SnowconeCanvas` — i.e. the full rendering engine — and is therefore ONLY\n * ever reached through a dynamic `import()` (D9): the embed entry's static\n * import graph stays renderer-free, mechanically enforced by the\n * import-graph CI check.\n *\n * Beyond the original wiring (seed → SnowconeCanvas, edit →\n * `serializeStateForServer` → `pushRender`), this adds the ADR-0085 §3 store\n * wiring: every canvas change lands in the Root's {@link DesignStateStore}\n * (the ONE live design state), and a {@link CanvasBridge} is registered so\n * `Editor.TextField` writes route through the editor command path (undo/redo,\n * repaint) while a canvas is mounted — the editor document stays the single\n * write authority.\n */\n\nimport React, {\n forwardRef,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { SnowconeCanvas } from '../embed/SnowconeCanvas.js';\nimport { ContextualToolbars } from '../ContextualToolbars.js';\nimport type { CanvasState, SnowconeCanvasHandle } from '../embed/SnowconeCanvas.js';\nimport { serializeStateForServer } from '../../rendering/serialize-for-server.js';\nimport type { KitPresetId, KitDefinition } from '../../kits/types.js';\nimport type { CanvasServices } from '../../contexts/CanvasServicesContext.js';\nimport { useEmbedContext } from '../embed-realtime/context.js';\nimport { useElementsContext } from '../../contexts/ElementsContext.js';\nimport { useCommandContext } from '../../contexts/CommandContext.js';\nimport { TextElement } from '../../core/TextElement.js';\nimport { ArtboardElement } from '../../core/ArtboardElement.js';\nimport { ElementFactory } from '../../core/ElementFactory.js';\nimport type { AnyElementConfig } from '../../types/index.js';\nimport { EditorRootInternalsContext } from './RootInternals.js';\n\nexport interface EditorCanvasImplProps {\n /** Your controls (toolbar, inputs). Rendered as an overlay inside the editor\n * context so binding hooks work. */\n children?: ReactNode;\n /** Editor chrome preset. `Editor.Canvas` pins the chrome-less `'embed-only'`;\n * the legacy `<RealtimeCanvas kit>` prop passes richer presets through. */\n kit?: KitPresetId | KitDefinition;\n /** Inherit the host app's theme instead of managing its own (default true). */\n inheritTheme?: boolean;\n /** Cap the canvas height in px. */\n maxHeight?: number;\n /** Privileged-service wiring override (usually inherited from Root). */\n services?: CanvasServices;\n /** Observe the live design state (the same {@link CanvasState} the Root's\n * state store tracks). Safe to pass inline — read through a ref. */\n onChange?: (state: CanvasState) => void;\n /** Whether the wrapping div self-applies `.sc-root`. The legacy\n * `<RealtimeCanvas>` always did (it could be the only Snowcone DOM on the\n * page); under `Editor.Root` the Root applies it once and parts never\n * self-apply (ADR-0085). Re-applying is harmless (same variables), so the\n * legacy wrapper keeps `true` for bit-identical back-compat. */\n selfScope?: boolean;\n /** `data-sc-part` value for the wrapping div (the parts contract). */\n partAttr?: string;\n /** Mount the built-in floating contextual toolbar (ADR-0085 §5: with no\n * `Editor.Controls` mounted, `Editor.Canvas` defaults to the floating\n * toolbar; a registered DOCKED Controls suppresses it). Set by\n * `Editor.Canvas` only — the legacy `<RealtimeCanvas>` wrapper keeps\n * today's chrome-less behavior. @internal */\n builtinControls?: boolean;\n className?: string;\n style?: CSSProperties;\n}\n\nconst noopSubscribe = (): (() => void) => () => {};\n\n/**\n * Runs INSIDE the canvas's editor context (the overlay slot) and registers\n * the imperative bridge sibling parts use to edit by layer name through the\n * command path. Generalizes `useTextBinding`'s write mechanics to a dynamic\n * name (a hook can't take names at call time).\n */\nfunction CanvasBindingBridge(): null {\n const { elementStore, artboardManager, refreshArtboards } = useElementsContext();\n const {\n executeElementUpdate,\n executeAddElement,\n executeRemoveElement,\n executeCreateArtboard,\n executeDeleteArtboard,\n } = useCommandContext();\n // Tolerant on purpose: the legacy <RealtimeCanvas> is supported inside a\n // bare EmbedContext (advanced consumers provide their own); only under an\n // <Editor.Root> is there a registry to bridge into.\n const internals = useContext(EditorRootInternalsContext);\n\n const latest = useRef({\n elementStore,\n artboardManager,\n refreshArtboards,\n executeElementUpdate,\n executeAddElement,\n executeRemoveElement,\n executeCreateArtboard,\n executeDeleteArtboard,\n });\n latest.current = {\n elementStore,\n artboardManager,\n refreshArtboards,\n executeElementUpdate,\n executeAddElement,\n executeRemoveElement,\n executeCreateArtboard,\n executeDeleteArtboard,\n };\n\n const registry = internals?.registry ?? null;\n useLayoutEffect(() => {\n if (!registry) return;\n return registry.registerCanvasBridge({\n setTextByName(name: string, text: string): boolean {\n const { elementStore: store, executeElementUpdate: execute } = latest.current;\n const matches = store.getAllByName(name).filter((el): el is TextElement => el instanceof TextElement);\n if (matches.length === 0) return false;\n for (const el of matches) {\n const cloned = el.clone() as TextElement;\n cloned.setText(text);\n execute(el, cloned);\n }\n return true;\n },\n // ADR-0101: split = clone the BASE artboard (the first one) and every\n // element on it into a new artboard named `label`, through the command\n // path so it is one undoable step per command and lands in the Root\n // store via onChange like any edit.\n splitArtboard(label: string): boolean {\n const { artboardManager: mgr, elementStore: store } = latest.current;\n const all = mgr.getAllArtboards();\n const base = all[0];\n if (!base) return false;\n if (all.some((ab) => ab.name === label)) return true;\n const next = new ArtboardElement({\n name: label,\n x: base.x,\n y: base.y,\n width: base.width,\n height: base.height,\n backgroundColor: base.backgroundColor,\n });\n latest.current.executeCreateArtboard(next);\n // CreateArtboardCommand re-creates from a clone of the basic config;\n // carry the fields it doesn't (export flag, clip, role) directly.\n const created = mgr.getArtboard(next.id);\n if (created) {\n created.exportBackground = base.exportBackground;\n created.clipShape = base.clipShape;\n created.role = base.role;\n }\n for (const id of mgr.getElementsOnArtboard(base.id)) {\n const el = store.get(id);\n if (!el) continue;\n const json = { ...(el.toJSON() as AnyElementConfig) } as AnyElementConfig & { id?: string; artboard?: string };\n delete json.id;\n json.artboard = label;\n latest.current.executeAddElement(ElementFactory.createFromJSON(json) as Parameters<typeof executeAddElement>[0], next.id);\n }\n latest.current.refreshArtboards();\n return true;\n },\n // ADR-0101: link = remove the artboard named `label` and its elements\n // through the command path; the placement inherits the base again.\n removeArtboard(label: string): boolean {\n const { artboardManager: mgr, elementStore: store } = latest.current;\n const target = mgr.getAllArtboards().find((ab) => ab.name === label);\n if (!target) return false;\n for (const id of [...mgr.getElementsOnArtboard(target.id)]) {\n const el = store.get(id);\n if (el) latest.current.executeRemoveElement(el as Parameters<typeof executeRemoveElement>[0]);\n }\n latest.current.executeDeleteArtboard(target);\n latest.current.refreshArtboards();\n return true;\n },\n });\n }, [registry]);\n\n return null;\n}\n\nexport const EditorCanvasImpl = forwardRef<SnowconeCanvasHandle, EditorCanvasImplProps>(\n function EditorCanvasImpl(\n {\n children,\n kit = 'embed-only',\n inheritTheme = true,\n maxHeight,\n services,\n onChange,\n selfScope = false,\n partAttr,\n builtinControls = false,\n className,\n style,\n }: EditorCanvasImplProps,\n ref,\n ): React.ReactElement {\n const { placement, throttleMs, pieceGuides, pushRender, stateStore } = useEmbedContext();\n\n // Under an <Editor.Root> the editor document is mounted by the ROOT (P1\n // provider inversion, D9: state always) — SnowconeCanvas must write into\n // that document instead of mounting its own, and a REMOUNT of this part\n // must rebuild the (surviving) document from the live seed instead of\n // accreting onto the previous mount's artboards/elements. The legacy\n // <RealtimeCanvas> inside a bare EmbedContext (no Root) keeps mounting\n // its own provider, exactly as before.\n const rootInternals = useContext(EditorRootInternalsContext);\n const underRoot = rootInternals !== null;\n\n // ADR-0085 §5 (Controls placement resolution): with no Editor.Controls\n // mounted — or a `placement=\"floating\"` one — the canvas owns the\n // floating contextual toolbar; a registered DOCKED Controls suppresses\n // it. Subscribed to the part registry so the zones swap live when a\n // docked Controls mounts/unmounts.\n const partsRegistry = rootInternals?.registry ?? null;\n useSyncExternalStore(\n partsRegistry ? partsRegistry.subscribe : noopSubscribe,\n partsRegistry ? partsRegistry.getVersion : () => 0,\n partsRegistry ? partsRegistry.getVersion : () => 0,\n );\n const showBuiltinFloatingControls =\n builtinControls && underRoot && !(partsRegistry?.hasDockedControls() ?? false);\n\n // Seed from the LIVE store, not the original design (ADR-0085 §3): the\n // store starts as design.toJSON(), so a fresh mount is identical to the\n // old behavior — but edits made while this chunk was loading (e.g. a\n // TextField keystroke in the first second) survive instead of being\n // clobbered by a stale seed. Captured once per store identity; later\n // store changes flow through the editor document, not re-seeding.\n const seed = useMemo(() => stateStore.getState(), [stateStore]);\n\n // Latest-ref so a host's inline `onChange` identity never matters here\n // (SnowconeCanvas already refs ITS callback; this keeps ours symmetric).\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const rootClass = selfScope ? 'sc-root' : 'sc-canvas-frame';\n\n return (\n <div className={`${rootClass}${className ? ` ${className}` : ''}`} style={style} data-sc-part={partAttr}>\n <SnowconeCanvas\n ref={ref}\n kit={kit}\n inheritTheme={inheritTheme}\n services={services}\n externalProvider={underRoot}\n resetDocumentOnMount={underRoot}\n artboards={seed.artboards}\n activeArtboard={placement}\n initialElements={seed.elements}\n layoutConfig={maxHeight ? { maxHeight } : undefined}\n overlay={\n <>\n <CanvasBindingBridge />\n {showBuiltinFloatingControls ? <ContextualToolbars mode=\"floating\" partAttr=\"controls\" /> : null}\n {children}\n </>\n }\n // #566: the product's printable-area / dead-zone overlay, fetched and\n // dims-gated by the Root — same overlay snowcone.app's editor\n // shows, so a buyer can't unknowingly edit under a camera cutout.\n pieceGuides={pieceGuides ?? undefined}\n onChange={(state) => {\n // ONE store, last-write-wins (ADR-0085 §3): the editor document is\n // the write authority while mounted; the Root store derives from\n // its onChange, then the render follows the store.\n stateStore.setState(state);\n pushRender(serializeStateForServer(state), throttleMs);\n onChangeRef.current?.(state);\n }}\n />\n </div>\n );\n },\n);\n\nexport type { CanvasState, SnowconeCanvasHandle };\n"],"names":["noopSubscribe","CanvasBindingBridge","elementStore","artboardManager","refreshArtboards","useElementsContext","executeElementUpdate","executeAddElement","executeRemoveElement","executeCreateArtboard","executeDeleteArtboard","useCommandContext","internals","useContext","EditorRootInternalsContext","latest","useRef","registry","useLayoutEffect","name","text","store","execute","matches","el","TextElement","cloned","label","mgr","all","base","ab","next","ArtboardElement","created","id","json","ElementFactory","target","EditorCanvasImpl","forwardRef","children","kit","inheritTheme","maxHeight","services","onChange","selfScope","partAttr","builtinControls","className","style","ref","placement","throttleMs","pieceGuides","pushRender","stateStore","useEmbedContext","rootInternals","underRoot","partsRegistry","useSyncExternalStore","showBuiltinFloatingControls","seed","useMemo","onChangeRef","jsx","SnowconeCanvas","jsxs","Fragment","ContextualToolbars","state","serializeStateForServer","_a"],"mappings":";;;;;;;;;AA8EA,MAAMA,IAAgB,MAAoB,MAAM;AAAC;AAQjD,SAASC,IAA4B;AACnC,QAAM,EAAE,cAAAC,GAAc,iBAAAC,GAAiB,kBAAAC,EAAA,IAAqBC,EAAA,GACtD;AAAA,IACJ,sBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA,IACEC,EAAA,GAIEC,IAAYC,EAAWC,CAA0B,GAEjDC,IAASC,EAAO;AAAA,IACpB,cAAAd;AAAA,IACA,iBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,sBAAAE;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA,CACD;AACD,EAAAK,EAAO,UAAU;AAAA,IACf,cAAAb;AAAA,IACA,iBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,sBAAAE;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA;AAGF,QAAMO,KAAWL,KAAA,gBAAAA,EAAW,aAAY;AACxC,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CP6ipFq_.js","sources":["../src/components/editor/EditorCanvasImpl.tsx"],"sourcesContent":["'use client';\n\n/**\n * The heavy half of `Editor.Canvas` (and of the legacy `<RealtimeCanvas>`),\n * extracted from RealtimeCanvas's body. This module statically imports\n * `SnowconeCanvas` — i.e. the full rendering engine — and is therefore ONLY\n * ever reached through a dynamic `import()` (D9): the embed entry's static\n * import graph stays renderer-free, mechanically enforced by the\n * import-graph CI check.\n *\n * Beyond the original wiring (seed → SnowconeCanvas, edit →\n * `serializeStateForServer` → `pushRender`), this adds the ADR-0085 §3 store\n * wiring: every canvas change lands in the Root's {@link DesignStateStore}\n * (the ONE live design state), and a {@link CanvasBridge} is registered so\n * `Editor.TextField` writes route through the editor command path (undo/redo,\n * repaint) while a canvas is mounted — the editor document stays the single\n * write authority.\n */\n\nimport React, {\n forwardRef,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { SnowconeCanvas } from '../embed/SnowconeCanvas.js';\nimport { ContextualToolbars } from '../ContextualToolbars.js';\nimport type { CanvasState, SnowconeCanvasHandle } from '../embed/SnowconeCanvas.js';\nimport { serializeStateForServer } from '../../rendering/serialize-for-server.js';\nimport type { KitPresetId, KitDefinition } from '../../kits/types.js';\nimport type { CanvasServices } from '../../contexts/CanvasServicesContext.js';\nimport { useEmbedContext } from '../embed-realtime/context.js';\nimport { useElementsContext } from '../../contexts/ElementsContext.js';\nimport { useCommandContext } from '../../contexts/CommandContext.js';\nimport { TextElement } from '../../core/TextElement.js';\nimport { ArtboardElement } from '../../core/ArtboardElement.js';\nimport { ElementFactory } from '../../core/ElementFactory.js';\nimport type { AnyElementConfig } from '../../types/index.js';\nimport { EditorRootInternalsContext } from './RootInternals.js';\n\nexport interface EditorCanvasImplProps {\n /** Your controls (toolbar, inputs). Rendered as an overlay inside the editor\n * context so binding hooks work. */\n children?: ReactNode;\n /** Editor chrome preset. `Editor.Canvas` pins the chrome-less `'embed-only'`;\n * the legacy `<RealtimeCanvas kit>` prop passes richer presets through. */\n kit?: KitPresetId | KitDefinition;\n /** Inherit the host app's theme instead of managing its own (default true). */\n inheritTheme?: boolean;\n /** Cap the canvas height in px. */\n maxHeight?: number;\n /** Privileged-service wiring override (usually inherited from Root). */\n services?: CanvasServices;\n /** Observe the live design state (the same {@link CanvasState} the Root's\n * state store tracks). Safe to pass inline — read through a ref. */\n onChange?: (state: CanvasState) => void;\n /** Whether the wrapping div self-applies `.sc-root`. The legacy\n * `<RealtimeCanvas>` always did (it could be the only Snowcone DOM on the\n * page); under `Editor.Root` the Root applies it once and parts never\n * self-apply (ADR-0085). Re-applying is harmless (same variables), so the\n * legacy wrapper keeps `true` for bit-identical back-compat. */\n selfScope?: boolean;\n /** `data-sc-part` value for the wrapping div (the parts contract). */\n partAttr?: string;\n /** Mount the built-in floating contextual toolbar (ADR-0085 §5: with no\n * `Editor.Controls` mounted, `Editor.Canvas` defaults to the floating\n * toolbar; a registered DOCKED Controls suppresses it). Set by\n * `Editor.Canvas` only — the legacy `<RealtimeCanvas>` wrapper keeps\n * today's chrome-less behavior. @internal */\n builtinControls?: boolean;\n className?: string;\n style?: CSSProperties;\n}\n\nconst noopSubscribe = (): (() => void) => () => {};\n\n/**\n * Runs INSIDE the canvas's editor context (the overlay slot) and registers\n * the imperative bridge sibling parts use to edit by layer name through the\n * command path. Generalizes `useTextBinding`'s write mechanics to a dynamic\n * name (a hook can't take names at call time).\n */\nfunction CanvasBindingBridge(): null {\n const { elementStore, artboardManager, refreshArtboards } = useElementsContext();\n const {\n executeElementUpdate,\n executeAddElement,\n executeRemoveElement,\n executeCreateArtboard,\n executeDeleteArtboard,\n } = useCommandContext();\n // Tolerant on purpose: the legacy <RealtimeCanvas> is supported inside a\n // bare EmbedContext (advanced consumers provide their own); only under an\n // <Editor.Root> is there a registry to bridge into.\n const internals = useContext(EditorRootInternalsContext);\n\n const latest = useRef({\n elementStore,\n artboardManager,\n refreshArtboards,\n executeElementUpdate,\n executeAddElement,\n executeRemoveElement,\n executeCreateArtboard,\n executeDeleteArtboard,\n });\n latest.current = {\n elementStore,\n artboardManager,\n refreshArtboards,\n executeElementUpdate,\n executeAddElement,\n executeRemoveElement,\n executeCreateArtboard,\n executeDeleteArtboard,\n };\n\n const registry = internals?.registry ?? null;\n useLayoutEffect(() => {\n if (!registry) return;\n return registry.registerCanvasBridge({\n setTextByName(name: string, text: string): boolean {\n const { elementStore: store, executeElementUpdate: execute } = latest.current;\n const matches = store.getAllByName(name).filter((el): el is TextElement => el instanceof TextElement);\n if (matches.length === 0) return false;\n for (const el of matches) {\n const cloned = el.clone() as TextElement;\n cloned.setText(text);\n execute(el, cloned);\n }\n return true;\n },\n // ADR-0101: split = clone the BASE artboard (the first one) and every\n // element on it into a new artboard named `label`, through the command\n // path so it is one undoable step per command and lands in the Root\n // store via onChange like any edit.\n splitArtboard(label: string): boolean {\n const { artboardManager: mgr, elementStore: store } = latest.current;\n const all = mgr.getAllArtboards();\n const base = all[0];\n if (!base) return false;\n if (all.some((ab) => ab.name === label)) return true;\n const next = new ArtboardElement({\n name: label,\n x: base.x,\n y: base.y,\n width: base.width,\n height: base.height,\n backgroundColor: base.backgroundColor,\n });\n latest.current.executeCreateArtboard(next);\n // CreateArtboardCommand re-creates from a clone of the basic config;\n // carry the fields it doesn't (export flag, clip, role) directly.\n const created = mgr.getArtboard(next.id);\n if (created) {\n created.exportBackground = base.exportBackground;\n created.clipShape = base.clipShape;\n created.role = base.role;\n }\n for (const id of mgr.getElementsOnArtboard(base.id)) {\n const el = store.get(id);\n if (!el) continue;\n const json = { ...(el.toJSON() as AnyElementConfig) } as AnyElementConfig & { id?: string; artboard?: string };\n delete json.id;\n json.artboard = label;\n latest.current.executeAddElement(ElementFactory.createFromJSON(json) as Parameters<typeof executeAddElement>[0], next.id);\n }\n latest.current.refreshArtboards();\n return true;\n },\n // ADR-0101: link = remove the artboard named `label` and its elements\n // through the command path; the placement inherits the base again.\n removeArtboard(label: string): boolean {\n const { artboardManager: mgr, elementStore: store } = latest.current;\n const target = mgr.getAllArtboards().find((ab) => ab.name === label);\n if (!target) return false;\n for (const id of [...mgr.getElementsOnArtboard(target.id)]) {\n const el = store.get(id);\n if (el) latest.current.executeRemoveElement(el as Parameters<typeof executeRemoveElement>[0]);\n }\n latest.current.executeDeleteArtboard(target);\n latest.current.refreshArtboards();\n return true;\n },\n });\n }, [registry]);\n\n return null;\n}\n\nexport const EditorCanvasImpl = forwardRef<SnowconeCanvasHandle, EditorCanvasImplProps>(\n function EditorCanvasImpl(\n {\n children,\n kit = 'embed-only',\n inheritTheme = true,\n maxHeight,\n services,\n onChange,\n selfScope = false,\n partAttr,\n builtinControls = false,\n className,\n style,\n }: EditorCanvasImplProps,\n ref,\n ): React.ReactElement {\n const { placement, throttleMs, pieceGuides, pushRender, stateStore } = useEmbedContext();\n\n // Under an <Editor.Root> the editor document is mounted by the ROOT (P1\n // provider inversion, D9: state always) — SnowconeCanvas must write into\n // that document instead of mounting its own, and a REMOUNT of this part\n // must rebuild the (surviving) document from the live seed instead of\n // accreting onto the previous mount's artboards/elements. The legacy\n // <RealtimeCanvas> inside a bare EmbedContext (no Root) keeps mounting\n // its own provider, exactly as before.\n const rootInternals = useContext(EditorRootInternalsContext);\n const underRoot = rootInternals !== null;\n\n // ADR-0085 §5 (Controls placement resolution): with no Editor.Controls\n // mounted — or a `placement=\"floating\"` one — the canvas owns the\n // floating contextual toolbar; a registered DOCKED Controls suppresses\n // it. Subscribed to the part registry so the zones swap live when a\n // docked Controls mounts/unmounts.\n const partsRegistry = rootInternals?.registry ?? null;\n useSyncExternalStore(\n partsRegistry ? partsRegistry.subscribe : noopSubscribe,\n partsRegistry ? partsRegistry.getVersion : () => 0,\n partsRegistry ? partsRegistry.getVersion : () => 0,\n );\n const showBuiltinFloatingControls =\n builtinControls && underRoot && !(partsRegistry?.hasDockedControls() ?? false);\n\n // Seed from the LIVE store, not the original design (ADR-0085 §3): the\n // store starts as design.toJSON(), so a fresh mount is identical to the\n // old behavior — but edits made while this chunk was loading (e.g. a\n // TextField keystroke in the first second) survive instead of being\n // clobbered by a stale seed. Captured once per store identity; later\n // store changes flow through the editor document, not re-seeding.\n const seed = useMemo(() => stateStore.getState(), [stateStore]);\n\n // Latest-ref so a host's inline `onChange` identity never matters here\n // (SnowconeCanvas already refs ITS callback; this keeps ours symmetric).\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const rootClass = selfScope ? 'sc-root' : 'sc-canvas-frame';\n\n return (\n <div className={`${rootClass}${className ? ` ${className}` : ''}`} style={style} data-sc-part={partAttr}>\n <SnowconeCanvas\n ref={ref}\n kit={kit}\n inheritTheme={inheritTheme}\n services={services}\n externalProvider={underRoot}\n resetDocumentOnMount={underRoot}\n artboards={seed.artboards}\n activeArtboard={placement}\n initialElements={seed.elements}\n layoutConfig={maxHeight ? { maxHeight } : undefined}\n overlay={\n <>\n <CanvasBindingBridge />\n {showBuiltinFloatingControls ? <ContextualToolbars mode=\"floating\" partAttr=\"controls\" /> : null}\n {children}\n </>\n }\n // #566: the product's printable-area / dead-zone overlay, fetched and\n // dims-gated by the Root — same overlay snowcone.app's editor\n // shows, so a buyer can't unknowingly edit under a camera cutout.\n pieceGuides={pieceGuides ?? undefined}\n onChange={(state) => {\n // ONE store, last-write-wins (ADR-0085 §3): the editor document is\n // the write authority while mounted; the Root store derives from\n // its onChange, then the render follows the store.\n stateStore.setState(state);\n pushRender(serializeStateForServer(state), throttleMs);\n onChangeRef.current?.(state);\n }}\n />\n </div>\n );\n },\n);\n\nexport type { CanvasState, SnowconeCanvasHandle };\n"],"names":["noopSubscribe","CanvasBindingBridge","elementStore","artboardManager","refreshArtboards","useElementsContext","executeElementUpdate","executeAddElement","executeRemoveElement","executeCreateArtboard","executeDeleteArtboard","useCommandContext","internals","useContext","EditorRootInternalsContext","latest","useRef","registry","useLayoutEffect","name","text","store","execute","matches","el","TextElement","cloned","label","mgr","all","base","ab","next","ArtboardElement","created","id","json","ElementFactory","target","EditorCanvasImpl","forwardRef","children","kit","inheritTheme","maxHeight","services","onChange","selfScope","partAttr","builtinControls","className","style","ref","placement","throttleMs","pieceGuides","pushRender","stateStore","useEmbedContext","rootInternals","underRoot","partsRegistry","useSyncExternalStore","showBuiltinFloatingControls","seed","useMemo","onChangeRef","jsx","SnowconeCanvas","jsxs","Fragment","ContextualToolbars","state","serializeStateForServer","_a"],"mappings":";;;;;;;;;AA8EA,MAAMA,IAAgB,MAAoB,MAAM;AAAC;AAQjD,SAASC,IAA4B;AACnC,QAAM,EAAE,cAAAC,GAAc,iBAAAC,GAAiB,kBAAAC,EAAA,IAAqBC,EAAA,GACtD;AAAA,IACJ,sBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA,IACEC,EAAA,GAIEC,IAAYC,EAAWC,CAA0B,GAEjDC,IAASC,EAAO;AAAA,IACpB,cAAAd;AAAA,IACA,iBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,sBAAAE;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA,CACD;AACD,EAAAK,EAAO,UAAU;AAAA,IACf,cAAAb;AAAA,IACA,iBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,sBAAAE;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA;AAGF,QAAMO,KAAWL,KAAA,gBAAAA,EAAW,aAAY;AACxC,SAAAM,EAAgB,MAAM;AACpB,QAAKD;AACL,aAAOA,EAAS,qBAAqB;AAAA,QACnC,cAAcE,GAAcC,GAAuB;AACjD,gBAAM,EAAE,cAAcC,GAAO,sBAAsBC,EAAA,IAAYP,EAAO,SAChEQ,IAAUF,EAAM,aAAaF,CAAI,EAAE,OAAO,CAACK,MAA0BA,aAAcC,CAAW;AACpG,cAAI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,CAAC,GAIxDS,IAAclD,EAAO8B,CAAQ;AACnC,WAAAoB,EAAY,UAAUpB,GAKpB,gBAAAqB,EAAC,OAAA,EAAI,WAAW,GAHApB,IAAY,YAAY,iBAGZ,GAAGG,IAAY,IAAIA,CAAS,KAAK,EAAE,IAAI,OAAAC,GAAc,gBAAcH,GAC7F,UAAA,gBAAAmB;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAAhB;AAAA,QACA,KAAAV;AAAA,QACA,cAAAC;AAAA,QACA,UAAAE;AAAA,QACA,kBAAkBe;AAAA,QAClB,sBAAsBA;AAAA,QACtB,WAAWI,EAAK;AAAA,QAChB,gBAAgBX;AAAA,QAChB,iBAAiBW,EAAK;AAAA,QACtB,cAAcpB,IAAY,EAAE,WAAAA,EAAA,IAAc;AAAA,QAC1C,SACE,gBAAAyB,EAAAC,GAAA,EACE,UAAA;AAAA,UAAA,gBAAAH,EAAClE,GAAA,EAAoB;AAAA,UACpB8D,IAA8B,gBAAAI,EAACI,GAAA,EAAmB,MAAK,YAAW,UAAS,YAAW,IAAK;AAAA,UAC3F9B;AAAA,QAAA,GACH;AAAA,QAKF,aAAac,KAAe;AAAA,QAC5B,UAAU,CAACiB,MAAU;;AAInB,UAAAf,EAAW,SAASe,CAAK,GACzBhB,EAAWiB,EAAwBD,CAAK,GAAGlB,CAAU,IACrDoB,IAAAR,EAAY,YAAZ,QAAAQ,EAAA,KAAAR,GAAsBM;AAAA,QACxB;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;"}
|
|
@@ -3,7 +3,7 @@ let Ce = null;
|
|
|
3
3
|
function fr(e) {
|
|
4
4
|
Ce = e;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _n() {
|
|
7
7
|
return Ce;
|
|
8
8
|
}
|
|
9
9
|
const dr = j("TextureManager"), lt = class lt {
|
|
@@ -148,7 +148,7 @@ function yr(e, t, r) {
|
|
|
148
148
|
a + l / 2
|
|
149
149
|
));
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Xn(e, t, r) {
|
|
152
152
|
var c;
|
|
153
153
|
e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180);
|
|
154
154
|
const n = t, o = n.fontSize || 24, i = n.fontFamily || "Arial", s = n.bold || !1, l = n.italic || !1;
|
|
@@ -989,7 +989,7 @@ function Hr(e, t, r, n) {
|
|
|
989
989
|
var s, l;
|
|
990
990
|
if (!t.transformData) return;
|
|
991
991
|
const o = t.transformData, i = ((s = n.renderingContext) == null ? void 0 : s.isKnockout) === !0;
|
|
992
|
-
e.beginPath(), Oe(e, o), (r === "fill" || r === "both") && (e.fillStyle = i ? "#000000" : tr(e, o), e.globalAlpha = i ? 1 : o.fillOpacity ?? 1, e.fill()), (r === "stroke" || r === "both") && ((l = t.stroke) != null && l.enabled) && (e.save(),
|
|
992
|
+
e.beginPath(), Oe(e, o), (r === "fill" || r === "both") && (e.fillStyle = i ? "#000000" : tr(e, o), e.globalAlpha = i ? 1 : o.fillOpacity ?? 1, e.fill()), (r === "stroke" || r === "both") && ((l = t.stroke) != null && l.enabled) && (e.save(), Xr(e, t, n.renderingContext), e.restore());
|
|
993
993
|
}
|
|
994
994
|
function Oe(e, t) {
|
|
995
995
|
const { shapeType: r } = t, n = t.width ?? 100, o = t.height ?? 100;
|
|
@@ -1004,7 +1004,7 @@ function Oe(e, t) {
|
|
|
1004
1004
|
Nr(e, n / 2, o / 2);
|
|
1005
1005
|
break;
|
|
1006
1006
|
case "star":
|
|
1007
|
-
|
|
1007
|
+
_r(e, t, Math.min(n, o) / 2);
|
|
1008
1008
|
break;
|
|
1009
1009
|
default:
|
|
1010
1010
|
oe(e, t, n, o);
|
|
@@ -1024,7 +1024,7 @@ function jr(e, t) {
|
|
|
1024
1024
|
function Nr(e, t, r) {
|
|
1025
1025
|
e.ellipse(0, 0, t, r, 0, 0, Math.PI * 2);
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1027
|
+
function _r(e, t, r) {
|
|
1028
1028
|
const n = Math.max(3, Math.min(20, t.points || 5)), o = Math.max(0.1, Math.min(0.9, t.innerRadius || 0.4)), i = r * o, s = Math.PI / n, l = -Math.PI / 2;
|
|
1029
1029
|
for (let a = 0; a < n * 2; a++) {
|
|
1030
1030
|
const c = l + s * a, h = a % 2 === 0 ? r : i, d = Math.cos(c) * h, u = Math.sin(c) * h;
|
|
@@ -1032,7 +1032,7 @@ function Xr(e, t, r) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
e.closePath();
|
|
1034
1034
|
}
|
|
1035
|
-
function
|
|
1035
|
+
function Xr(e, t, r) {
|
|
1036
1036
|
var o;
|
|
1037
1037
|
if (!((o = t.stroke) != null && o.enabled) || !t.transformData) return;
|
|
1038
1038
|
const n = (r == null ? void 0 : r.isKnockout) === !0;
|
|
@@ -1711,7 +1711,7 @@ function Cn() {
|
|
|
1711
1711
|
}
|
|
1712
1712
|
}
|
|
1713
1713
|
}
|
|
1714
|
-
const
|
|
1714
|
+
const _ = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Map(), mt = /* @__PURE__ */ new Map();
|
|
1715
1715
|
function de(e, t) {
|
|
1716
1716
|
if (typeof OffscreenCanvas < "u")
|
|
1717
1717
|
return new OffscreenCanvas(e, t);
|
|
@@ -1735,27 +1735,27 @@ function ge(e) {
|
|
|
1735
1735
|
return a.putImageData(i, 0, 0), { alphaMask: l, width: t, height: r };
|
|
1736
1736
|
}
|
|
1737
1737
|
function He(e) {
|
|
1738
|
-
const t =
|
|
1738
|
+
const t = X.get(e);
|
|
1739
1739
|
if (t) return t;
|
|
1740
1740
|
if (e.startsWith("builtin:")) {
|
|
1741
1741
|
Cn();
|
|
1742
|
-
const r =
|
|
1742
|
+
const r = X.get(e);
|
|
1743
1743
|
return r || null;
|
|
1744
1744
|
}
|
|
1745
|
-
return
|
|
1745
|
+
return _.has(e) || (_.add(e), je(e)), null;
|
|
1746
1746
|
}
|
|
1747
1747
|
function xn(e) {
|
|
1748
|
-
return
|
|
1749
|
-
if (
|
|
1748
|
+
return X.has(e) ? Promise.resolve() : new Promise((t) => {
|
|
1749
|
+
if (X.has(e)) {
|
|
1750
1750
|
t();
|
|
1751
1751
|
return;
|
|
1752
1752
|
}
|
|
1753
1753
|
const r = mt.get(e) || [];
|
|
1754
|
-
r.push(t), mt.set(e, r),
|
|
1754
|
+
r.push(t), mt.set(e, r), _.has(e) || (_.add(e), je(e));
|
|
1755
1755
|
});
|
|
1756
1756
|
}
|
|
1757
1757
|
function Pn(e, t, r, n) {
|
|
1758
|
-
|
|
1758
|
+
X.has(e) || (X.set(e, { alphaMask: t, width: r, height: n }), st(e));
|
|
1759
1759
|
}
|
|
1760
1760
|
function st(e) {
|
|
1761
1761
|
const t = mt.get(e);
|
|
@@ -1766,16 +1766,16 @@ function je(e) {
|
|
|
1766
1766
|
const t = new Image();
|
|
1767
1767
|
t.crossOrigin = "anonymous", t.onload = () => {
|
|
1768
1768
|
const r = ge(t);
|
|
1769
|
-
|
|
1769
|
+
X.set(e, r), _.delete(e), st(e);
|
|
1770
1770
|
}, t.onerror = () => {
|
|
1771
|
-
|
|
1771
|
+
_.delete(e), st(e);
|
|
1772
1772
|
}, t.src = e;
|
|
1773
1773
|
} else
|
|
1774
1774
|
fetch(e).then((t) => t.blob()).then((t) => createImageBitmap(t)).then((t) => {
|
|
1775
1775
|
const r = ge(t);
|
|
1776
|
-
|
|
1776
|
+
X.set(e, r), _.delete(e), st(e);
|
|
1777
1777
|
}).catch(() => {
|
|
1778
|
-
|
|
1778
|
+
_.delete(e), st(e);
|
|
1779
1779
|
});
|
|
1780
1780
|
}
|
|
1781
1781
|
function Ne(e, t) {
|
|
@@ -2332,7 +2332,7 @@ const me = j("ImportManager"), Zt = class Zt {
|
|
|
2332
2332
|
};
|
|
2333
2333
|
Zt.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
|
|
2334
2334
|
let ye = Zt;
|
|
2335
|
-
const we = j("element-serializer"),
|
|
2335
|
+
const we = j("element-serializer"), _e = 4e3, ft = /* @__PURE__ */ new Set();
|
|
2336
2336
|
function An(e, t) {
|
|
2337
2337
|
const r = t ? Rn(t) : "no-src";
|
|
2338
2338
|
return `${e}:${r}`;
|
|
@@ -2348,7 +2348,7 @@ function Rn(e) {
|
|
|
2348
2348
|
function Ht() {
|
|
2349
2349
|
ft.clear();
|
|
2350
2350
|
}
|
|
2351
|
-
function
|
|
2351
|
+
function Xe(e) {
|
|
2352
2352
|
for (const t of ft)
|
|
2353
2353
|
t.startsWith(`${e}:`) && ft.delete(t);
|
|
2354
2354
|
}
|
|
@@ -2358,7 +2358,7 @@ function Wn(e) {
|
|
|
2358
2358
|
function Fn(e) {
|
|
2359
2359
|
return ft.has(e);
|
|
2360
2360
|
}
|
|
2361
|
-
async function Bn(e, t =
|
|
2361
|
+
async function Bn(e, t = _e) {
|
|
2362
2362
|
const { naturalWidth: r, naturalHeight: n } = e;
|
|
2363
2363
|
if (r <= t && n <= t)
|
|
2364
2364
|
return createImageBitmap(e);
|
|
@@ -2380,7 +2380,7 @@ function to() {
|
|
|
2380
2380
|
Ht(), wt && wt();
|
|
2381
2381
|
}
|
|
2382
2382
|
function eo(e) {
|
|
2383
|
-
|
|
2383
|
+
Xe(e), kt && kt(e);
|
|
2384
2384
|
}
|
|
2385
2385
|
function jt(e, t) {
|
|
2386
2386
|
const r = e;
|
|
@@ -2420,7 +2420,7 @@ function ke(e) {
|
|
|
2420
2420
|
} : r;
|
|
2421
2421
|
});
|
|
2422
2422
|
}
|
|
2423
|
-
async function be(e, t, r =
|
|
2423
|
+
async function be(e, t, r = _e) {
|
|
2424
2424
|
const n = t.filter((a) => e.hasElementId(a.id)), o = [], i = [], s = /* @__PURE__ */ new Set();
|
|
2425
2425
|
for (const a of n) {
|
|
2426
2426
|
const c = a.toJSON();
|
|
@@ -2599,9 +2599,9 @@ async function ro(e, t = {}) {
|
|
|
2599
2599
|
);
|
|
2600
2600
|
}
|
|
2601
2601
|
const O = j("WorkerExport");
|
|
2602
|
-
let
|
|
2602
|
+
let _t = null, It = null;
|
|
2603
2603
|
function jn() {
|
|
2604
|
-
return It ?? (It = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-DXciOLDt.js")).then((e) =>
|
|
2604
|
+
return It ?? (It = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-DXciOLDt.js")).then((e) => _t = e.default).catch((e) => {
|
|
2605
2605
|
throw It = null, e;
|
|
2606
2606
|
})), It;
|
|
2607
2607
|
}
|
|
@@ -2679,7 +2679,7 @@ class dt {
|
|
|
2679
2679
|
* Call this when an element is removed or its image source changes.
|
|
2680
2680
|
*/
|
|
2681
2681
|
clearWorkerBitmap(t) {
|
|
2682
|
-
if (
|
|
2682
|
+
if (Xe(t), this.worker && this.isReady) {
|
|
2683
2683
|
const r = {
|
|
2684
2684
|
type: "clear-bitmap",
|
|
2685
2685
|
elementId: t
|
|
@@ -2707,8 +2707,8 @@ class dt {
|
|
|
2707
2707
|
return this.readyPromise;
|
|
2708
2708
|
if (!dt.supportsWorkerExport())
|
|
2709
2709
|
throw new Error("Browser does not support OffscreenCanvas or Web Workers");
|
|
2710
|
-
if (
|
|
2711
|
-
return this.readyPromise = this.startWorker(
|
|
2710
|
+
if (_t !== null)
|
|
2711
|
+
return this.readyPromise = this.startWorker(_t), this.readyPromise;
|
|
2712
2712
|
const t = this.initGeneration, r = jn().then((n) => {
|
|
2713
2713
|
if (t !== this.initGeneration)
|
|
2714
2714
|
throw new Error("Worker terminated");
|
|
@@ -3016,23 +3016,23 @@ function oo() {
|
|
|
3016
3016
|
}
|
|
3017
3017
|
Jt();
|
|
3018
3018
|
const N = j("Export");
|
|
3019
|
-
function
|
|
3019
|
+
function Xt(e, t) {
|
|
3020
3020
|
var r;
|
|
3021
3021
|
if (!(!e || typeof e != "object")) {
|
|
3022
3022
|
if (typeof e.fontFamily == "string" && e.fontFamily.trim() && t.add(e.fontFamily), e.richText && Array.isArray(e.richText.spans))
|
|
3023
3023
|
for (const n of e.richText.spans)
|
|
3024
3024
|
(r = n == null ? void 0 : n.style) != null && r.fontFamily && typeof n.style.fontFamily == "string" && t.add(n.style.fontFamily);
|
|
3025
3025
|
if (Array.isArray(e.children))
|
|
3026
|
-
for (const n of e.children)
|
|
3026
|
+
for (const n of e.children) Xt(n, t);
|
|
3027
3027
|
if (Array.isArray(e.masks))
|
|
3028
3028
|
for (const n of e.masks)
|
|
3029
|
-
n != null && n.maskElement &&
|
|
3029
|
+
n != null && n.maskElement && Xt(n.maskElement, t);
|
|
3030
3030
|
}
|
|
3031
3031
|
}
|
|
3032
3032
|
async function Te(e) {
|
|
3033
3033
|
if (typeof document > "u" || !document.fonts) return;
|
|
3034
3034
|
const t = /* @__PURE__ */ new Set();
|
|
3035
|
-
for (const n of e)
|
|
3035
|
+
for (const n of e) Xt(n, t);
|
|
3036
3036
|
if (t.size === 0) return;
|
|
3037
3037
|
const r = [];
|
|
3038
3038
|
for (const n of t)
|
|
@@ -3584,32 +3584,33 @@ const so = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3584
3584
|
default: bt
|
|
3585
3585
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3586
3586
|
export {
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3587
|
+
le as A,
|
|
3588
|
+
oo as B,
|
|
3589
|
+
Xe as C,
|
|
3590
|
+
_e as D,
|
|
3591
3591
|
yt as E,
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3592
|
+
Cr as F,
|
|
3593
|
+
Nt as G,
|
|
3594
|
+
ro as H,
|
|
3595
3595
|
ye as I,
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3596
|
+
Hn as J,
|
|
3597
|
+
$n as K,
|
|
3598
|
+
Bt as L,
|
|
3599
|
+
ce as M,
|
|
3600
|
+
In as N,
|
|
3601
|
+
pn as O,
|
|
3602
|
+
Jt as P,
|
|
3603
|
+
pe as Q,
|
|
3604
|
+
_n as R,
|
|
3605
|
+
Cn as S,
|
|
3606
3606
|
D as T,
|
|
3607
|
-
|
|
3608
|
-
|
|
3607
|
+
En as U,
|
|
3608
|
+
xn as V,
|
|
3609
3609
|
dt as W,
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3610
|
+
an as X,
|
|
3611
|
+
sn as Y,
|
|
3612
|
+
pr as Z,
|
|
3613
|
+
so as _,
|
|
3613
3614
|
bt as a,
|
|
3614
3615
|
Jn as b,
|
|
3615
3616
|
Pe as c,
|
|
@@ -3620,21 +3621,21 @@ export {
|
|
|
3620
3621
|
Gn as h,
|
|
3621
3622
|
wr as i,
|
|
3622
3623
|
Yn as j,
|
|
3623
|
-
|
|
3624
|
+
Xn as k,
|
|
3624
3625
|
ht as l,
|
|
3625
3626
|
no as m,
|
|
3626
3627
|
Zn as n,
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3628
|
+
jn as o,
|
|
3629
|
+
re as p,
|
|
3630
|
+
eo as q,
|
|
3630
3631
|
Tr as r,
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3632
|
+
Wt as s,
|
|
3633
|
+
Kn as t,
|
|
3634
|
+
Vn as u,
|
|
3635
|
+
Sr as v,
|
|
3636
|
+
Qn as w,
|
|
3637
|
+
Mr as x,
|
|
3638
|
+
Ie as y,
|
|
3639
|
+
zn as z
|
|
3639
3640
|
};
|
|
3640
|
-
//# sourceMappingURL=ExportManager-
|
|
3641
|
+
//# sourceMappingURL=ExportManager-DLOH2Kzk.js.map
|