@tangle-network/agent-app 0.26.0 → 0.28.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.
- package/dist/DesignCanvas-AOIVN3SJ.js +12 -0
- package/dist/DesignCanvasEditor-TN7CWUJW.js +13 -0
- package/dist/{TimelineEditor-JDG54OBP.js → TimelineEditor-Z7C6BFP5.js} +2 -2
- package/dist/{apply-Cp8c3K9D.d.ts → apply-Gk4raT2j.d.ts} +3 -1
- package/dist/brand-extraction/index.d.ts +212 -0
- package/dist/brand-extraction/index.js +446 -0
- package/dist/brand-extraction/index.js.map +1 -0
- package/dist/{chunk-AFDROJ64.js → chunk-2QI7XV2T.js} +1 -1
- package/dist/chunk-2QI7XV2T.js.map +1 -0
- package/dist/{chunk-LUE4HO5C.js → chunk-4IQMTTNE.js} +10 -10
- package/dist/chunk-4IQMTTNE.js.map +1 -0
- package/dist/{chunk-FSUR2752.js → chunk-7I37CO5D.js} +274 -388
- package/dist/chunk-7I37CO5D.js.map +1 -0
- package/dist/{chunk-5RT6KY4G.js → chunk-GQRL6VNU.js} +1 -1
- package/dist/chunk-GQRL6VNU.js.map +1 -0
- package/dist/{chunk-SCG5JJ4C.js → chunk-HFC4BTWJ.js} +32 -4
- package/dist/chunk-HFC4BTWJ.js.map +1 -0
- package/dist/{chunk-7QCIYDGC.js → chunk-IOREXWLM.js} +2 -2
- package/dist/chunk-J7JNV5BH.js +14 -0
- package/dist/chunk-J7JNV5BH.js.map +1 -0
- package/dist/{chunk-6UOE5CTA.js → chunk-JT6HHO5P.js} +5 -10
- package/dist/chunk-JT6HHO5P.js.map +1 -0
- package/dist/{chunk-JZAJE3JL.js → chunk-M2EBUDZ7.js} +19 -5
- package/dist/chunk-M2EBUDZ7.js.map +1 -0
- package/dist/{chunk-RJ2ZHK5D.js → chunk-S6WS2B32.js} +132 -7
- package/dist/chunk-S6WS2B32.js.map +1 -0
- package/dist/chunk-SQV7NUEM.js +136 -0
- package/dist/chunk-SQV7NUEM.js.map +1 -0
- package/dist/chunk-UAKFCMWK.js +1 -0
- package/dist/chunk-UAKFCMWK.js.map +1 -0
- package/dist/chunk-V5XZKHCL.js +296 -0
- package/dist/chunk-V5XZKHCL.js.map +1 -0
- package/dist/chunk-XWJXZ6WE.js +604 -0
- package/dist/chunk-XWJXZ6WE.js.map +1 -0
- package/dist/chunk-Y2SZVW35.js +125 -0
- package/dist/chunk-Y2SZVW35.js.map +1 -0
- package/dist/{chunk-LPAVBGVY.js → chunk-YEWTVDDT.js} +399 -860
- package/dist/chunk-YEWTVDDT.js.map +1 -0
- package/dist/{chunk-UDXMR3AD.js → chunk-YNALYIQ3.js} +56 -18
- package/dist/chunk-YNALYIQ3.js.map +1 -0
- package/dist/command-stack-CkjelfK_.d.ts +267 -0
- package/dist/design-canvas/drizzle.d.ts +2 -2
- package/dist/design-canvas/index.d.ts +7 -6
- package/dist/design-canvas/index.js +3 -2
- package/dist/design-canvas-react/engine.d.ts +349 -0
- package/dist/design-canvas-react/engine.js +86 -0
- package/dist/design-canvas-react/engine.js.map +1 -0
- package/dist/design-canvas-react/index.d.ts +80 -618
- package/dist/design-canvas-react/index.js +85 -172
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.d.ts +6 -0
- package/dist/design-canvas-react/lazy.js +9 -0
- package/dist/design-canvas-react/lazy.js.map +1 -0
- package/dist/{export-presets-Dl5Aa5xj.d.ts → export-presets-DAsU5Wal.d.ts} +2 -143
- package/dist/flow-types-Cb_AblZs.d.ts +25 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.js +21 -8
- package/dist/lazy-BHHqS8-j.d.ts +72 -0
- package/dist/missions/index.d.ts +12 -0
- package/dist/missions/index.js +1 -1
- package/dist/{model-BHLN208Z.d.ts → model-BBwyOuWG.d.ts} +3 -1
- package/dist/operations-DLIvvD00.d.ts +144 -0
- package/dist/platform/index.js +1 -1
- package/dist/runtime/index.d.ts +33 -33
- package/dist/runtime/index.js +1 -1
- package/dist/sequences/index.d.ts +1 -1
- package/dist/sequences/index.js +2 -1
- package/dist/sequences-react/index.d.ts +15 -1
- package/dist/sequences-react/index.js +2 -2
- package/dist/{store-CUStmtdH.d.ts → store-CFyxgTlD.d.ts} +1 -1
- package/dist/theme/index.d.ts +80 -0
- package/dist/theme/index.js +14 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/tailwind-preset.d.ts +65 -0
- package/dist/theme/tailwind-preset.js +33 -0
- package/dist/theme/tailwind-preset.js.map +1 -0
- package/dist/theme/tokens.css +95 -0
- package/dist/trace/index.d.ts +2 -18
- package/dist/trace/index.js +2 -2
- package/dist/web/index.d.ts +25 -2
- package/dist/web/index.js +3 -1
- package/dist/web-react/index.d.ts +71 -31
- package/dist/web-react/index.js +625 -486
- package/dist/web-react/index.js.map +1 -1
- package/package.json +33 -3
- package/dist/DesignCanvas-MA5EH324.js +0 -10
- package/dist/DesignCanvasEditor-YLCO7I5I.js +0 -9
- package/dist/chunk-5RT6KY4G.js.map +0 -1
- package/dist/chunk-6UOE5CTA.js.map +0 -1
- package/dist/chunk-AFDROJ64.js.map +0 -1
- package/dist/chunk-FSUR2752.js.map +0 -1
- package/dist/chunk-JZAJE3JL.js.map +0 -1
- package/dist/chunk-LPAVBGVY.js.map +0 -1
- package/dist/chunk-LUE4HO5C.js.map +0 -1
- package/dist/chunk-RJ2ZHK5D.js.map +0 -1
- package/dist/chunk-SCG5JJ4C.js.map +0 -1
- package/dist/chunk-UDXMR3AD.js.map +0 -1
- /package/dist/{DesignCanvas-MA5EH324.js.map → DesignCanvas-AOIVN3SJ.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-YLCO7I5I.js.map → DesignCanvasEditor-TN7CWUJW.js.map} +0 -0
- /package/dist/{TimelineEditor-JDG54OBP.js.map → TimelineEditor-Z7C6BFP5.js.map} +0 -0
- /package/dist/{chunk-7QCIYDGC.js.map → chunk-IOREXWLM.js.map} +0 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { d as SceneCommand, i as SnapTarget, g as SnapEngine, Z as ZoomPanMath } from '../command-stack-CkjelfK_.js';
|
|
2
|
+
export { A as ApplySceneResult, a as DesignCanvasMode, D as DesignCanvasProps, b as EditorSceneState, E as ExportTriggerOptions, S as SCENE_COMMAND_HISTORY_LIMIT, e as SceneCommandStack, f as SceneCommandStackWithReapply, h as SnapResult, j as SnapTargetKind, k as SnapTargets, c as createSceneCommandStack } from '../command-stack-CkjelfK_.js';
|
|
3
|
+
import { d as SceneElement, N as NewPageOptions, c as SceneDocument, a as PageGuides, P as PageBleed, B as Bounds, g as ScenePage } from '../model-BBwyOuWG.js';
|
|
4
|
+
import { f as SceneAttrsPatch, g as SceneOperation } from '../operations-DLIvvD00.js';
|
|
5
|
+
import { d as ExportCropRect, f as ExportPreset } from '../export-presets-DAsU5Wal.js';
|
|
6
|
+
export { h as bleedAwareExportBounds, s as scaleForPreset } from '../export-presets-DAsU5Wal.js';
|
|
7
|
+
import '../theme/index.js';
|
|
8
|
+
|
|
9
|
+
interface AddElementInput {
|
|
10
|
+
pageId: string;
|
|
11
|
+
element: SceneElement;
|
|
12
|
+
/** Insertion z-index within owner; omitted → top. */
|
|
13
|
+
index?: number;
|
|
14
|
+
/** Parent group id; omitted → page root. */
|
|
15
|
+
parentGroupId?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function addElementCommand(input: AddElementInput): SceneCommand;
|
|
18
|
+
interface SetAttrsInput {
|
|
19
|
+
pageId: string;
|
|
20
|
+
elementId: string;
|
|
21
|
+
/** Final attribute values after the gesture. */
|
|
22
|
+
attrs: SceneAttrsPatch;
|
|
23
|
+
/** Attribute values BEFORE the gesture began — inverse is built from these. */
|
|
24
|
+
priorAttrs: SceneAttrsPatch;
|
|
25
|
+
}
|
|
26
|
+
declare function setAttrsCommand(input: SetAttrsInput): SceneCommand;
|
|
27
|
+
interface MultiSetAttrsEntry {
|
|
28
|
+
pageId: string;
|
|
29
|
+
elementId: string;
|
|
30
|
+
attrs: SceneAttrsPatch;
|
|
31
|
+
priorAttrs: SceneAttrsPatch;
|
|
32
|
+
}
|
|
33
|
+
declare function multiSetAttrsCommand(entries: MultiSetAttrsEntry[]): SceneCommand;
|
|
34
|
+
interface ReorderElementInput {
|
|
35
|
+
pageId: string;
|
|
36
|
+
elementId: string;
|
|
37
|
+
toIndex: number;
|
|
38
|
+
}
|
|
39
|
+
declare function reorderElementCommand(input: ReorderElementInput): SceneCommand;
|
|
40
|
+
interface DeleteElementInput {
|
|
41
|
+
document: SceneDocument;
|
|
42
|
+
pageId: string;
|
|
43
|
+
elementId: string;
|
|
44
|
+
}
|
|
45
|
+
declare function deleteElementCommand(input: DeleteElementInput): SceneCommand;
|
|
46
|
+
interface GroupElementsInput {
|
|
47
|
+
document: SceneDocument;
|
|
48
|
+
pageId: string;
|
|
49
|
+
elementIds: string[];
|
|
50
|
+
groupId: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
}
|
|
53
|
+
declare function groupElementsCommand(input: GroupElementsInput): SceneCommand;
|
|
54
|
+
interface UngroupElementInput {
|
|
55
|
+
document: SceneDocument;
|
|
56
|
+
pageId: string;
|
|
57
|
+
groupId: string;
|
|
58
|
+
}
|
|
59
|
+
declare function ungroupElementCommand(input: UngroupElementInput): SceneCommand;
|
|
60
|
+
interface AddPageInput {
|
|
61
|
+
pageId: string;
|
|
62
|
+
options?: NewPageOptions;
|
|
63
|
+
index?: number;
|
|
64
|
+
}
|
|
65
|
+
declare function addPageCommand(input: AddPageInput): SceneCommand;
|
|
66
|
+
interface DuplicatePageInput {
|
|
67
|
+
document: SceneDocument;
|
|
68
|
+
sourcePageId: string;
|
|
69
|
+
/** Caller-minted id for the copy. */
|
|
70
|
+
pageId: string;
|
|
71
|
+
}
|
|
72
|
+
declare function duplicatePageCommand(input: DuplicatePageInput): SceneCommand;
|
|
73
|
+
interface DeletePageInput {
|
|
74
|
+
document: SceneDocument;
|
|
75
|
+
pageId: string;
|
|
76
|
+
}
|
|
77
|
+
declare function deletePageCommand(input: DeletePageInput): SceneCommand;
|
|
78
|
+
interface ReorderPageInput {
|
|
79
|
+
pageId: string;
|
|
80
|
+
toIndex: number;
|
|
81
|
+
}
|
|
82
|
+
declare function reorderPageCommand(input: ReorderPageInput): SceneCommand;
|
|
83
|
+
interface SetPagePropsInput {
|
|
84
|
+
document: SceneDocument;
|
|
85
|
+
pageId: string;
|
|
86
|
+
props: {
|
|
87
|
+
name?: string;
|
|
88
|
+
width?: number;
|
|
89
|
+
height?: number;
|
|
90
|
+
background?: string;
|
|
91
|
+
bleed?: PageBleed | null;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
declare function setPagePropsCommand(input: SetPagePropsInput): SceneCommand;
|
|
95
|
+
interface SetPageGuidesInput {
|
|
96
|
+
document: SceneDocument;
|
|
97
|
+
pageId: string;
|
|
98
|
+
guides: PageGuides;
|
|
99
|
+
}
|
|
100
|
+
declare function setPageGuidesCommand(input: SetPageGuidesInput): SceneCommand;
|
|
101
|
+
interface BindSlotInput {
|
|
102
|
+
document: SceneDocument;
|
|
103
|
+
pageId: string;
|
|
104
|
+
elementId: string;
|
|
105
|
+
slot: string | null;
|
|
106
|
+
}
|
|
107
|
+
declare function bindSlotCommand(input: BindSlotInput): SceneCommand;
|
|
108
|
+
interface SetDocumentTitleInput {
|
|
109
|
+
document: SceneDocument;
|
|
110
|
+
title: string;
|
|
111
|
+
}
|
|
112
|
+
declare function setDocumentTitleCommand(input: SetDocumentTitleInput): SceneCommand;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 2-axis snap engine for the design-canvas editor. Targets come from element
|
|
116
|
+
* AABBs (edges + centers), page edges + center, saved guides, and grid lines
|
|
117
|
+
* near the moving bounds. Grid lines are generated lazily in the neighborhood
|
|
118
|
+
* of the moving element, not the full page — avoids allocating thousands of
|
|
119
|
+
* targets on large pages with fine grids.
|
|
120
|
+
*
|
|
121
|
+
* Threshold is a SCREEN distance (pixels), divided by zoom to convert to
|
|
122
|
+
* document units — what "feels close" is a screen distance.
|
|
123
|
+
*
|
|
124
|
+
* Tie-breaking: non-grid kinds beat grid on equal distance; among equals of
|
|
125
|
+
* the same priority the first in iteration order wins.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
declare function createSnapEngine(): SnapEngine;
|
|
129
|
+
/** Generate grid line targets within a neighborhood around the moving bounds.
|
|
130
|
+
* Call this and append to `SnapTargets.vertical`/`horizontal` before
|
|
131
|
+
* passing to `apply()` when `state.gridEnabled`. */
|
|
132
|
+
declare function collectGridTargets(bounds: Bounds, gridSize: number, page: ScenePage, thresholdDocPx: number): {
|
|
133
|
+
vertical: SnapTarget[];
|
|
134
|
+
horizontal: SnapTarget[];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Selection math for the design-canvas editor: marquee hit-tests, keyboard
|
|
139
|
+
* nudge deltas, and the duplicate offset constant. Pure functions — no DOM, no
|
|
140
|
+
* Konva, no React.
|
|
141
|
+
*
|
|
142
|
+
* Marquee inclusion: by default any element whose AABB intersects the marquee
|
|
143
|
+
* rect is included (the "touch" model). Pass `requireFullContainment: true` for
|
|
144
|
+
* the "surround" model where the marquee must fully contain the element. Locked
|
|
145
|
+
* and invisible elements are never selected regardless.
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Top-most selectable element whose AABB contains the document-space point, or
|
|
150
|
+
* null when the point is over empty space.
|
|
151
|
+
*
|
|
152
|
+
* This is the authoritative "is the pointer over an element?" test for the
|
|
153
|
+
* pointer-down gesture router. It runs against the scene model in document
|
|
154
|
+
* coordinates rather than Konva's hit-graph canvas, so it is independent of
|
|
155
|
+
* clip groups, listening flags, and hit-canvas redraw timing — all of which
|
|
156
|
+
* could make `stage.getIntersection` misclassify a press as empty space and
|
|
157
|
+
* silently start a marquee instead of an element drag.
|
|
158
|
+
*
|
|
159
|
+
* Z-order: later elements paint on top, so we scan the array in reverse and
|
|
160
|
+
* return the first hit. Groups descend into children (top child wins); a hit on
|
|
161
|
+
* a group child resolves to the group itself, matching drag/selection which
|
|
162
|
+
* operate on the group as a unit. Locked and invisible elements never hit.
|
|
163
|
+
*/
|
|
164
|
+
declare function hitTestPoint(page: ScenePage, x: number, y: number): string | null;
|
|
165
|
+
interface MarqueeSelectOptions {
|
|
166
|
+
/** When true, the element's AABB must be fully inside the marquee; default is
|
|
167
|
+
* intersection (any overlap selects). */
|
|
168
|
+
requireFullContainment?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** Returns the ids of selectable elements on `page` whose AABB intersects (or
|
|
171
|
+
* is contained by) `rect`. Locked and invisible elements are excluded. */
|
|
172
|
+
declare function marqueeSelect(page: ScenePage, rect: Bounds, opts?: MarqueeSelectOptions): string[];
|
|
173
|
+
interface NudgeDelta {
|
|
174
|
+
dx: number;
|
|
175
|
+
dy: number;
|
|
176
|
+
}
|
|
177
|
+
/** Map an arrow key to a document-px delta. `shift` engages the 10× step.
|
|
178
|
+
* Throws on unknown keys so callers handle only real nudge keys. */
|
|
179
|
+
declare function nudgeDelta(key: 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown', shift: boolean): NudgeDelta;
|
|
180
|
+
/** Document-px offset applied to duplicated elements so the copy is visually
|
|
181
|
+
* separated from the original (matching common design-tool convention). */
|
|
182
|
+
declare const DUPLICATE_OFFSET: NudgeDelta;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Zoom + pan coordinate math for the design-canvas editor. Zoom is pixels-per-
|
|
186
|
+
* document-px (e.g. 2 = 200% magnification). The key invariant for wheel-zoom
|
|
187
|
+
* is that the document point under the cursor stays fixed in screen space:
|
|
188
|
+
*
|
|
189
|
+
* docPoint = (screenPoint - pan) / zoom
|
|
190
|
+
* newPan = screenPoint - docPoint * newZoom
|
|
191
|
+
*
|
|
192
|
+
* This module is pure math — no DOM, no Konva, no React.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
interface ZoomPanConfig {
|
|
196
|
+
minZoom: number;
|
|
197
|
+
maxZoom: number;
|
|
198
|
+
}
|
|
199
|
+
declare function createZoomPanMath(config: ZoomPanConfig): ZoomPanMath;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Pure export math for the design-canvas surface — no Konva, no DOM, no React.
|
|
203
|
+
*
|
|
204
|
+
* All stage-interaction code (save/restore, node visibility, toDataURL) lives
|
|
205
|
+
* in export.ts and delegates the decision math here so it can be tested
|
|
206
|
+
* without a canvas environment.
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
/** Returns true for any Konva node that must be hidden during export. Nodes
|
|
210
|
+
* whose names start with 'overlay:' are editor-only chrome (snap lines,
|
|
211
|
+
* selection indicators, rulers, bleed guides). The transformer node is
|
|
212
|
+
* identified by its canonical name 'Transformer'. */
|
|
213
|
+
declare function isExportHiddenNodeName(name: string): boolean;
|
|
214
|
+
interface ResolvedExportParams {
|
|
215
|
+
cropRect: ExportCropRect;
|
|
216
|
+
pixelRatio: number;
|
|
217
|
+
mimeType: 'image/png' | 'image/jpeg';
|
|
218
|
+
quality: number | undefined;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Resolve the full set of toDataURL params from a page, format, pixel ratio,
|
|
222
|
+
* bleed flag, and optional preset. When a preset is supplied it overrides
|
|
223
|
+
* `pixelRatio` and `includeBleed` — the explicit args are ignored for those
|
|
224
|
+
* two values so the preset is the single source of truth.
|
|
225
|
+
*
|
|
226
|
+
* `quality` is set to 0.92 for jpeg, undefined for png (Konva ignores it).
|
|
227
|
+
*/
|
|
228
|
+
declare function resolveExportParams(page: ScenePage, opts: {
|
|
229
|
+
format: 'png' | 'jpeg';
|
|
230
|
+
pixelRatio?: number;
|
|
231
|
+
includeBleed?: boolean;
|
|
232
|
+
preset?: ExportPreset;
|
|
233
|
+
}): ResolvedExportParams;
|
|
234
|
+
/**
|
|
235
|
+
* Walk image nodes to find the src of any that may have caused a SecurityError
|
|
236
|
+
* when the stage called toDataURL. Returns the first offending src found, or
|
|
237
|
+
* null if none can be identified.
|
|
238
|
+
*
|
|
239
|
+
* `imageSrcs` is a flat list of { name, src } records collected from all image
|
|
240
|
+
* nodes on the stage before calling toDataURL — export.ts builds it before
|
|
241
|
+
* attempting the export so that if the SecurityError fires we have the data.
|
|
242
|
+
*/
|
|
243
|
+
declare function identifyTaintedSrc(imageSrcs: ReadonlyArray<{
|
|
244
|
+
name: string;
|
|
245
|
+
src: string;
|
|
246
|
+
}>): string | null;
|
|
247
|
+
/**
|
|
248
|
+
* Heuristic: a src is potentially cross-origin when it is an absolute http(s)
|
|
249
|
+
* URL. Same-origin relative paths (/api/...) and data: blobs are safe.
|
|
250
|
+
* This is intentionally conservative — the taint check runs only after a
|
|
251
|
+
* SecurityError fires, so a false positive is "blamed" without being silently
|
|
252
|
+
* ignored. NOTE: same-origin https:// assets will also match; if a
|
|
253
|
+
* SecurityError fires, the cross-origin culprit may be a different image than
|
|
254
|
+
* the one this function flags first.
|
|
255
|
+
*/
|
|
256
|
+
declare function isCrossOriginSrc(src: string): boolean;
|
|
257
|
+
/** Minimal snapshot of stage view state that export.ts saves before mutating
|
|
258
|
+
* zoom/pan/visibility and restores afterward. */
|
|
259
|
+
interface ExportViewSnapshot {
|
|
260
|
+
/** Stage scale factor before export. */
|
|
261
|
+
scaleX: number;
|
|
262
|
+
scaleY: number;
|
|
263
|
+
/** Stage translation before export. */
|
|
264
|
+
x: number;
|
|
265
|
+
y: number;
|
|
266
|
+
/** node name → prior visibility, for the nodes that were hidden. */
|
|
267
|
+
hiddenNodeNames: string[];
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Build the toDataURL crop rect translated to stage output coordinates.
|
|
271
|
+
* Konva's `stage.toDataURL({ x, y, width, height })` takes STAGE OUTPUT
|
|
272
|
+
* coordinates, not document coordinates. When the stage has been scaled to fit
|
|
273
|
+
* (zoom × stageScale), the crop rect in document px must be multiplied by the
|
|
274
|
+
* combined scale to land on the right pixels.
|
|
275
|
+
*
|
|
276
|
+
* `stageScale` is the stage's current uniform scale (scaleX == scaleY);
|
|
277
|
+
* `pixelRatio` is separate and handed directly to toDataURL — Konva multiplies
|
|
278
|
+
* it internally when rendering to the backing canvas, so we must NOT include
|
|
279
|
+
* it in the stage-coordinate rect.
|
|
280
|
+
*/
|
|
281
|
+
declare function documentCropToStageCoords(cropRect: ExportCropRect, stageScale: number, stageX: number, stageY: number): {
|
|
282
|
+
x: number;
|
|
283
|
+
y: number;
|
|
284
|
+
width: number;
|
|
285
|
+
height: number;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Pure builders for the human "add element to the canvas" path — the math and
|
|
290
|
+
* `SceneOperation` construction behind {@link CanvasInsertPanel}, separated from
|
|
291
|
+
* the React/DOM layer so every insert is unit-testable without Konva or a
|
|
292
|
+
* browser. The panel calls these to produce `add_element` operations and hands
|
|
293
|
+
* them to the host's `onApplyOperations` (server-validated, undoable) — the same
|
|
294
|
+
* pipeline every other edit flows through.
|
|
295
|
+
*
|
|
296
|
+
* Media boundary: image inserts must pass {@link assertSceneMediaSrc} (remote
|
|
297
|
+
* http(s) or a rooted `/api/` path — never `data:` blobs or sandbox-local
|
|
298
|
+
* files). Builders that take a src assert it up front so a bad url fails here,
|
|
299
|
+
* not deep in the apply layer.
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
/** Largest dimension (document px) a freshly inserted element is fitted to,
|
|
303
|
+
* before the page-size cap applies. Keeps a huge upload from filling the page. */
|
|
304
|
+
declare const MAX_INSERT_DIMENSION = 600;
|
|
305
|
+
/** Active page geometry an insert lands into — drives centering and fitting. */
|
|
306
|
+
interface InsertPageGeometry {
|
|
307
|
+
pageId: string;
|
|
308
|
+
width: number;
|
|
309
|
+
height: number;
|
|
310
|
+
}
|
|
311
|
+
/** Mint a DOM-safe element id. Prefers `crypto.randomUUID`; falls back to a
|
|
312
|
+
* time+random id where crypto is unavailable (older runtimes, some test envs). */
|
|
313
|
+
declare function mintElementId(): string;
|
|
314
|
+
/** Fit (naturalW, naturalH) under a max-dimension cap (further bounded by the
|
|
315
|
+
* page), preserving aspect ratio. Never upscales past natural size. */
|
|
316
|
+
declare function fittedSize(naturalW: number, naturalH: number, pageWidth: number, pageHeight: number): {
|
|
317
|
+
width: number;
|
|
318
|
+
height: number;
|
|
319
|
+
};
|
|
320
|
+
/** Top-left position that centers a (width, height) box on the page. */
|
|
321
|
+
declare function centeredPosition(width: number, height: number, pageWidth: number, pageHeight: number): {
|
|
322
|
+
x: number;
|
|
323
|
+
y: number;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Build an `add_element` op placing an image, fitted and centered on the page.
|
|
327
|
+
* `naturalSize` is the probed image dimensions (the panel reads them in the
|
|
328
|
+
* browser); pass `{ width: 0, height: 0 }` when unknown to fall back to the cap.
|
|
329
|
+
*
|
|
330
|
+
* Throws (via `assertSceneMediaSrc`) when `src` is not http(s) or a rooted
|
|
331
|
+
* `/api/` path — callers should surface the error, never insert a `data:` src.
|
|
332
|
+
*/
|
|
333
|
+
declare function buildInsertImageOp(src: string, naturalSize: {
|
|
334
|
+
width: number;
|
|
335
|
+
height: number;
|
|
336
|
+
}, page: InsertPageGeometry): SceneOperation;
|
|
337
|
+
/** A template the insert panel can drop without the agent. `build` is pure and
|
|
338
|
+
* produces the operations for the active page geometry. */
|
|
339
|
+
interface InsertTemplate {
|
|
340
|
+
id: string;
|
|
341
|
+
label: string;
|
|
342
|
+
build(page: InsertPageGeometry): SceneOperation[];
|
|
343
|
+
}
|
|
344
|
+
/** The built-in starter templates (heading, body text, rectangle, ellipse).
|
|
345
|
+
* Consumers can pass their own list to {@link CanvasInsertPanel}; this is the
|
|
346
|
+
* default so every canvas gets a usable set out of the box. */
|
|
347
|
+
declare const DEFAULT_INSERT_TEMPLATES: readonly InsertTemplate[];
|
|
348
|
+
|
|
349
|
+
export { type AddElementInput, type AddPageInput, type BindSlotInput, DEFAULT_INSERT_TEMPLATES, DUPLICATE_OFFSET, type DeleteElementInput, type DeletePageInput, type DuplicatePageInput, ExportCropRect, ExportPreset, type ExportViewSnapshot, type GroupElementsInput, type InsertPageGeometry, type InsertTemplate, MAX_INSERT_DIMENSION, type MarqueeSelectOptions, type MultiSetAttrsEntry, type NudgeDelta, type ReorderElementInput, type ReorderPageInput, type ResolvedExportParams, SceneCommand, type SetAttrsInput, type SetDocumentTitleInput, type SetPageGuidesInput, type SetPagePropsInput, SnapEngine, SnapTarget, type UngroupElementInput, type ZoomPanConfig, ZoomPanMath, addElementCommand, addPageCommand, bindSlotCommand, buildInsertImageOp, centeredPosition, collectGridTargets, createSnapEngine, createZoomPanMath, deleteElementCommand, deletePageCommand, documentCropToStageCoords, duplicatePageCommand, fittedSize, groupElementsCommand, hitTestPoint, identifyTaintedSrc, isCrossOriginSrc, isExportHiddenNodeName, marqueeSelect, mintElementId, multiSetAttrsCommand, nudgeDelta, reorderElementCommand, reorderPageCommand, resolveExportParams, setAttrsCommand, setDocumentTitleCommand, setPageGuidesCommand, setPagePropsCommand, ungroupElementCommand };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_INSERT_TEMPLATES,
|
|
3
|
+
MAX_INSERT_DIMENSION,
|
|
4
|
+
buildInsertImageOp,
|
|
5
|
+
centeredPosition,
|
|
6
|
+
fittedSize,
|
|
7
|
+
mintElementId
|
|
8
|
+
} from "../chunk-SQV7NUEM.js";
|
|
9
|
+
import {
|
|
10
|
+
DUPLICATE_OFFSET,
|
|
11
|
+
collectGridTargets,
|
|
12
|
+
createSnapEngine,
|
|
13
|
+
createZoomPanMath,
|
|
14
|
+
documentCropToStageCoords,
|
|
15
|
+
hitTestPoint,
|
|
16
|
+
identifyTaintedSrc,
|
|
17
|
+
isCrossOriginSrc,
|
|
18
|
+
isExportHiddenNodeName,
|
|
19
|
+
marqueeSelect,
|
|
20
|
+
nudgeDelta,
|
|
21
|
+
resolveExportParams
|
|
22
|
+
} from "../chunk-V5XZKHCL.js";
|
|
23
|
+
import {
|
|
24
|
+
SCENE_COMMAND_HISTORY_LIMIT,
|
|
25
|
+
addElementCommand,
|
|
26
|
+
addPageCommand,
|
|
27
|
+
bindSlotCommand,
|
|
28
|
+
createSceneCommandStack,
|
|
29
|
+
deleteElementCommand,
|
|
30
|
+
deletePageCommand,
|
|
31
|
+
duplicatePageCommand,
|
|
32
|
+
groupElementsCommand,
|
|
33
|
+
multiSetAttrsCommand,
|
|
34
|
+
reorderElementCommand,
|
|
35
|
+
reorderPageCommand,
|
|
36
|
+
setAttrsCommand,
|
|
37
|
+
setDocumentTitleCommand,
|
|
38
|
+
setPageGuidesCommand,
|
|
39
|
+
setPagePropsCommand,
|
|
40
|
+
ungroupElementCommand
|
|
41
|
+
} from "../chunk-XWJXZ6WE.js";
|
|
42
|
+
import {
|
|
43
|
+
bleedAwareExportBounds,
|
|
44
|
+
scaleForPreset
|
|
45
|
+
} from "../chunk-M2EBUDZ7.js";
|
|
46
|
+
import "../chunk-HFC4BTWJ.js";
|
|
47
|
+
export {
|
|
48
|
+
DEFAULT_INSERT_TEMPLATES,
|
|
49
|
+
DUPLICATE_OFFSET,
|
|
50
|
+
MAX_INSERT_DIMENSION,
|
|
51
|
+
SCENE_COMMAND_HISTORY_LIMIT,
|
|
52
|
+
addElementCommand,
|
|
53
|
+
addPageCommand,
|
|
54
|
+
bindSlotCommand,
|
|
55
|
+
bleedAwareExportBounds,
|
|
56
|
+
buildInsertImageOp,
|
|
57
|
+
centeredPosition,
|
|
58
|
+
collectGridTargets,
|
|
59
|
+
createSceneCommandStack,
|
|
60
|
+
createSnapEngine,
|
|
61
|
+
createZoomPanMath,
|
|
62
|
+
deleteElementCommand,
|
|
63
|
+
deletePageCommand,
|
|
64
|
+
documentCropToStageCoords,
|
|
65
|
+
duplicatePageCommand,
|
|
66
|
+
fittedSize,
|
|
67
|
+
groupElementsCommand,
|
|
68
|
+
hitTestPoint,
|
|
69
|
+
identifyTaintedSrc,
|
|
70
|
+
isCrossOriginSrc,
|
|
71
|
+
isExportHiddenNodeName,
|
|
72
|
+
marqueeSelect,
|
|
73
|
+
mintElementId,
|
|
74
|
+
multiSetAttrsCommand,
|
|
75
|
+
nudgeDelta,
|
|
76
|
+
reorderElementCommand,
|
|
77
|
+
reorderPageCommand,
|
|
78
|
+
resolveExportParams,
|
|
79
|
+
scaleForPreset,
|
|
80
|
+
setAttrsCommand,
|
|
81
|
+
setDocumentTitleCommand,
|
|
82
|
+
setPageGuidesCommand,
|
|
83
|
+
setPagePropsCommand,
|
|
84
|
+
ungroupElementCommand
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|