@pixerate/editor 0.137.0 → 0.138.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/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +3 -3
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +1 -1
- package/dist/animation-editor/index.cjs +57 -57
- package/dist/animation-editor/index.d.cts +3 -3
- package/dist/animation-editor/index.d.ts +3 -3
- package/dist/animation-editor/index.js +4 -4
- package/dist/{arrange-CKXK_hf7.d.cts → arrange-j_mLiFMO.d.cts} +1 -1
- package/dist/{arrange-BUREmgD9.d.ts → arrange-q5HQvnnB.d.ts} +1 -1
- package/dist/{bezier-CZ2AhjID.d.cts → bezier-CUaH8hcK.d.cts} +1 -1
- package/dist/{bezier-Dywv3Bw8.d.ts → bezier-DPmdGwgR.d.ts} +1 -1
- package/dist/{brushTypes-C7N3EBK7.d.cts → brushTypes-MX5UVs_m.d.cts} +27 -2
- package/dist/{brushTypes-C7N3EBK7.d.ts → brushTypes-MX5UVs_m.d.ts} +27 -2
- package/dist/{brushes-DJmUbIgz.d.ts → brushes-B1ABdDAs.d.ts} +2 -108
- package/dist/{brushes-CnvZSYYU.d.cts → brushes-DnIdJYxN.d.cts} +2 -108
- package/dist/{brushstrokeRender-IMFY3FF6.cjs → brushstrokeRender-PP6NTF6M.cjs} +52 -24
- package/dist/brushstrokeRender-PP6NTF6M.cjs.map +1 -0
- package/dist/{brushstrokeRender-2FAXA3XC.js → brushstrokeRender-QGEYJ4OZ.js} +40 -12
- package/dist/brushstrokeRender-QGEYJ4OZ.js.map +1 -0
- package/dist/{builtins-Cc-bH-3U.d.cts → builtins-BakDiKWf.d.cts} +3 -2
- package/dist/{builtins-ZU1GJnUA.d.ts → builtins-CE33vyv2.d.ts} +3 -2
- package/dist/canvas/index.cjs +16 -9
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +56 -11
- package/dist/canvas/index.d.ts +56 -11
- package/dist/canvas/index.js +10 -3
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-QBWEH3IM.cjs → chunk-3T5O225T.cjs} +391 -76
- package/dist/chunk-3T5O225T.cjs.map +1 -0
- package/dist/{chunk-PRSRYHQD.cjs → chunk-7MN75BXI.cjs} +36 -36
- package/dist/{chunk-PRSRYHQD.cjs.map → chunk-7MN75BXI.cjs.map} +1 -1
- package/dist/{chunk-EQQMGO42.js → chunk-C2J7GOMJ.js} +18 -5
- package/dist/chunk-C2J7GOMJ.js.map +1 -0
- package/dist/{chunk-2XS6LTUP.cjs → chunk-C46AZEBE.cjs} +104 -339
- package/dist/chunk-C46AZEBE.cjs.map +1 -0
- package/dist/{chunk-XN2NBLV5.cjs → chunk-CM3LJPR3.cjs} +82 -82
- package/dist/{chunk-XN2NBLV5.cjs.map → chunk-CM3LJPR3.cjs.map} +1 -1
- package/dist/{chunk-HUO3TI4C.js → chunk-CPSMARTX.js} +6 -241
- package/dist/chunk-CPSMARTX.js.map +1 -0
- package/dist/{chunk-KEENUAFN.cjs → chunk-DLLUOVQX.cjs} +18 -5
- package/dist/chunk-DLLUOVQX.cjs.map +1 -0
- package/dist/{chunk-LSXXAJG3.js → chunk-J7DSKTKB.js} +5 -4
- package/dist/chunk-J7DSKTKB.js.map +1 -0
- package/dist/{chunk-6S6362D2.js → chunk-OV7253FC.js} +2 -2
- package/dist/{chunk-5FSRTP6E.js → chunk-PQFVLOMR.js} +319 -4
- package/dist/chunk-PQFVLOMR.js.map +1 -0
- package/dist/{chunk-OIBIRXRG.js → chunk-PSPLRQL6.js} +2 -2
- package/dist/{chunk-SYT2TLQF.js → chunk-QBARQGSG.js} +2 -2
- package/dist/{chunk-5OOIUXNJ.cjs → chunk-SXOTFV3V.cjs} +6 -6
- package/dist/{chunk-5OOIUXNJ.cjs.map → chunk-SXOTFV3V.cjs.map} +1 -1
- package/dist/{chunk-DFSZO2B5.cjs → chunk-UFL5N4DK.cjs} +5 -4
- package/dist/chunk-UFL5N4DK.cjs.map +1 -0
- package/dist/{chunk-3D77LOBM.js → chunk-V45ZTW4R.js} +3 -3
- package/dist/{chunk-TLCTTQFF.cjs → chunk-VEHVXRJU.cjs} +17 -17
- package/dist/{chunk-TLCTTQFF.cjs.map → chunk-VEHVXRJU.cjs.map} +1 -1
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +3 -3
- package/dist/commands/index.d.ts +3 -3
- package/dist/commands/index.js +1 -1
- package/dist/{export-DwnZ_hvQ.d.ts → export-BwFRiItd.d.ts} +4 -4
- package/dist/{export-CyJdfP_Z.d.cts → export-DuN3dpCg.d.cts} +4 -4
- package/dist/{blending-NgF3qo3d.d.ts → grain-COgYMMHv.d.ts} +58 -1
- package/dist/{blending-D7jCmjO6.d.cts → grain-GCt_O2kv.d.cts} +58 -1
- package/dist/image-editor/index.cjs +695 -677
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +11 -11
- package/dist/image-editor/index.d.ts +11 -11
- package/dist/image-editor/index.js +23 -5
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{opentype-a1KAW-qs.d.ts → opentype-T7bkbR2D.d.ts} +1 -1
- package/dist/{opentype-KR_jj6b_.d.cts → opentype-n99lqxEZ.d.cts} +1 -1
- package/dist/paint/index.cjs +21 -3
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +72 -7
- package/dist/paint/index.d.ts +72 -7
- package/dist/paint/index.js +20 -2
- package/dist/paint-editor/index.cjs +171 -171
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +75 -29
- package/dist/paint-editor/index.d.ts +75 -29
- package/dist/paint-editor/index.js +12 -12
- package/dist/{pathfinder-BHS4vQNm.d.cts → pathfinder-CQlldanv.d.cts} +2 -2
- package/dist/{pathfinder-BVvTIBMo.d.ts → pathfinder-D-V6JLSw.d.ts} +2 -2
- package/dist/{rand-Cw9VLrVC.d.cts → rand-D7nfeD1p.d.cts} +18 -2
- package/dist/{rand-8xbUb6ur.d.ts → rand-DJGxSq9d.d.ts} +18 -2
- package/dist/{svg-CSz3mzkw.d.ts → svg-CnDCpIy9.d.ts} +1 -1
- package/dist/{svg-DTb40ICU.d.cts → svg-DPJMUSNt.d.cts} +1 -1
- package/dist/vector/index.cjs +944 -944
- package/dist/vector/index.d.cts +10 -10
- package/dist/vector/index.d.ts +10 -10
- package/dist/vector/index.js +4 -4
- package/dist/{warp-DTOp0lON.d.cts → warp-C7rMWUgW.d.cts} +1 -1
- package/dist/{warp-pd7hrH4T.d.ts → warp-Doasjpyr.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-canvas/SKILL.md +12 -5
- package/dist/brushstrokeRender-2FAXA3XC.js.map +0 -1
- package/dist/brushstrokeRender-IMFY3FF6.cjs.map +0 -1
- package/dist/chunk-2XS6LTUP.cjs.map +0 -1
- package/dist/chunk-5FSRTP6E.js.map +0 -1
- package/dist/chunk-DFSZO2B5.cjs.map +0 -1
- package/dist/chunk-EQQMGO42.js.map +0 -1
- package/dist/chunk-HUO3TI4C.js.map +0 -1
- package/dist/chunk-KEENUAFN.cjs.map +0 -1
- package/dist/chunk-LSXXAJG3.js.map +0 -1
- package/dist/chunk-QBWEH3IM.cjs.map +0 -1
- /package/dist/{chunk-6S6362D2.js.map → chunk-OV7253FC.js.map} +0 -0
- /package/dist/{chunk-OIBIRXRG.js.map → chunk-PSPLRQL6.js.map} +0 -0
- /package/dist/{chunk-SYT2TLQF.js.map → chunk-QBARQGSG.js.map} +0 -0
- /package/dist/{chunk-3D77LOBM.js.map → chunk-V45ZTW4R.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/builtins.ts"],"sourcesContent":["import type { HistoryState } from '../history/types.js';\nimport type { CanvasArrangeAction } from '../canvas/arrangeShortcuts.js';\nimport type { AlignEdge, DistributeAxis, DistributeMode, ZOrderOperation } from '../canvas/arrange.js';\nimport { DEFAULT_ARRANGE_SHORTCUTS } from '../canvas/arrangeShortcuts.js';\nimport type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset } from '../canvas/brushTypes.js';\nimport type { CommandParamsSchema, CommandSpec } from './registry.js';\nimport { ShortcutMap, type ShortcutBinding } from './shortcuts.js';\nimport type { KeyboardEventLike, Platform } from './chords.js';\n\n// ---------------------------------------------------------------------------\n// History\n// ---------------------------------------------------------------------------\n\n/** Minimal history surface (`HistoryManager` satisfies it). */\nexport interface HistoryCommandTarget {\n\tundo(): boolean | void;\n\tredo(): boolean | void;\n\tgetState(): Pick<HistoryState, 'canUndo' | 'canRedo'> & Partial<Pick<HistoryState, 'undoName' | 'redoName'>>;\n}\n\n/** Default history bindings: `Mod+Z` undo; `Mod+Shift+Z` redo, plus `Mod+Y` off macOS. */\nexport const DEFAULT_HISTORY_SHORTCUTS: readonly ShortcutBinding[] = [\n\t{ command: 'undo', chord: 'Mod+Z' },\n\t{ command: 'redo', chord: 'Mod+Shift+Z' },\n\t{ command: 'redo', chord: 'Mod+Y', platforms: ['windows', 'linux'] }\n];\n\nexport interface HistoryCommandOptions {\n\t/** Id prefix (default `history.`). */\n\tprefix?: string;\n\tgroup?: string;\n\tscope?: string;\n}\n\n/** `history.undo` / `history.redo` commands for a `HistoryManager` (disabled with a reason when empty). */\nexport function createHistoryCommands(history: HistoryCommandTarget, options: HistoryCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'history.';\n\tconst group = options.group ?? 'Edit';\n\tconst shortcutsOf = (command: 'undo' | 'redo') =>\n\t\tDEFAULT_HISTORY_SHORTCUTS.filter((b) => b.command === command).map(({ command: _c, ...rest }) => rest);\n\treturn [\n\t\t{\n\t\t\tid: `${prefix}undo`,\n\t\t\tlabel: 'Undo',\n\t\t\tgroup,\n\t\t\tkeywords: ['revert', 'back'],\n\t\t\tdescription: 'Reverts the last change.',\n\t\t\tshortcut: shortcutsOf('undo'),\n\t\t\t...(options.scope ? { scope: options.scope } : {}),\n\t\t\tenabled: () => (history.getState().canUndo ? true : 'Nothing to undo.'),\n\t\t\trun: () => {\n\t\t\t\thistory.undo();\n\t\t\t\treturn { undone: true, state: history.getState() };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: `${prefix}redo`,\n\t\t\tlabel: 'Redo',\n\t\t\tgroup,\n\t\t\tkeywords: ['repeat', 'forward'],\n\t\t\tdescription: 'Re-applies the last undone change.',\n\t\t\tshortcut: shortcutsOf('redo'),\n\t\t\t...(options.scope ? { scope: options.scope } : {}),\n\t\t\tenabled: () => (history.getState().canRedo ? true : 'Nothing to redo.'),\n\t\t\trun: () => {\n\t\t\t\thistory.redo();\n\t\t\t\treturn { redone: true, state: history.getState() };\n\t\t\t}\n\t\t}\n\t];\n}\n\nlet historyShortcutMap: ShortcutMap | null = null;\n\n/**\n * Resolves a keydown event to `undo` / `redo` with the default history bindings\n * (`Mod` is ⌘ on macOS and Ctrl elsewhere). Events from text inputs and\n * contenteditable elements are ignored unless `allowInEditable`.\n */\nexport function matchHistoryShortcut(\n\tevent: KeyboardEventLike,\n\toptions: { platform?: Platform; allowInEditable?: boolean } = {}\n): 'undo' | 'redo' | null {\n\thistoryShortcutMap ??= new ShortcutMap(DEFAULT_HISTORY_SHORTCUTS);\n\treturn (historyShortcutMap.resolve(event, options)?.command as 'undo' | 'redo' | undefined) ?? null;\n}\n\n// ---------------------------------------------------------------------------\n// Canvas arrange\n// ---------------------------------------------------------------------------\n\n/** Minimal arrange controller surface (`createCanvasArrangeController` satisfies it). */\nexport interface ArrangeCommandTarget {\n\talign(edge: AlignEdge, ids?: Iterable<string>): unknown;\n\tdistribute(axis: DistributeAxis, mode?: DistributeMode, ids?: Iterable<string>): unknown;\n\treorder(operation: ZOrderOperation, ids?: Iterable<string>): unknown;\n\tlock(ids?: Iterable<string>): unknown;\n\tunlock(ids?: Iterable<string>): unknown;\n}\n\nexport interface ArrangeCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope of the commands and their shortcuts (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n\t/** Current selection, used for enablement (\"Select at least two nodes\"). */\n\tgetSelectedIds?: () => string[];\n\t/** Scene navigation (`nextScene` / `previousScene`); those commands are only added when given. */\n\tscenes?: { next(): unknown; previous(): unknown };\n\t/** Use these bindings instead of `DEFAULT_ARRANGE_SHORTCUTS`. */\n\tbindings?: readonly { action: CanvasArrangeAction; label: string }[];\n}\n\nconst ARRANGE_LABELS: Record<CanvasArrangeAction, string> = {\n\talignLeft: 'Align Left',\n\talignCenter: 'Align Horizontal Centers',\n\talignRight: 'Align Right',\n\talignTop: 'Align Top',\n\talignMiddle: 'Align Vertical Centers',\n\talignBottom: 'Align Bottom',\n\tdistributeHorizontal: 'Distribute Horizontally',\n\tdistributeVertical: 'Distribute Vertically',\n\tlock: 'Lock',\n\tunlock: 'Unlock',\n\tbringForward: 'Bring Forward',\n\tsendBackward: 'Send Backward',\n\tbringToFront: 'Bring to Front',\n\tsendToBack: 'Send to Back',\n\tnextScene: 'Next Scene',\n\tpreviousScene: 'Previous Scene'\n};\n\nconst IDS_PARAMS: CommandParamsSchema = {\n\ttype: 'object',\n\tproperties: {\n\t\tids: {\n\t\t\ttype: 'array',\n\t\t\titems: { type: 'string' },\n\t\t\tdescription: 'Node ids to act on (default: the selection).'\n\t\t}\n\t}\n};\n\n/**\n * Commands for the canvas arrange actions (`canvas.alignLeft`, `canvas.bringToFront`, …)\n * with the default arrange shortcuts. Each accepts `{ ids? }`; enablement checks the\n * named ids, or the selection when none are named.\n */\nexport function createArrangeCommands(controller: ArrangeCommandTarget, options: ArrangeCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Arrange';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst bindings = options.bindings ?? DEFAULT_ARRANGE_SHORTCUTS;\n\tconst count = (params?: { ids?: string[] }) => params?.ids?.length ?? options.getSelectedIds?.().length;\n\tconst needs = (min: number, what: string) => (_: unknown, params?: { ids?: string[] }) => {\n\t\tconst n = count(params);\n\t\tif (n === undefined || n >= min) return true;\n\t\treturn min === 1 ? `Select a ${what} first.` : `Select at least ${min} ${what}s.`;\n\t};\n\n\tconst run: Record<CanvasArrangeAction, (ids?: string[]) => unknown> = {\n\t\talignLeft: (ids) => controller.align('left', ids),\n\t\talignCenter: (ids) => controller.align('center', ids),\n\t\talignRight: (ids) => controller.align('right', ids),\n\t\talignTop: (ids) => controller.align('top', ids),\n\t\talignMiddle: (ids) => controller.align('middle', ids),\n\t\talignBottom: (ids) => controller.align('bottom', ids),\n\t\tdistributeHorizontal: (ids) => controller.distribute('horizontal', 'gaps', ids),\n\t\tdistributeVertical: (ids) => controller.distribute('vertical', 'gaps', ids),\n\t\tlock: (ids) => controller.lock(ids),\n\t\tunlock: (ids) => controller.unlock(ids),\n\t\tbringForward: (ids) => controller.reorder('bringForward', ids),\n\t\tsendBackward: (ids) => controller.reorder('sendBackward', ids),\n\t\tbringToFront: (ids) => controller.reorder('bringToFront', ids),\n\t\tsendToBack: (ids) => controller.reorder('sendToBack', ids),\n\t\tnextScene: () => options.scenes?.next(),\n\t\tpreviousScene: () => options.scenes?.previous()\n\t};\n\n\tconst actions = Object.keys(ARRANGE_LABELS) as CanvasArrangeAction[];\n\treturn actions\n\t\t.filter((action) => options.scenes || (action !== 'nextScene' && action !== 'previousScene'))\n\t\t.map((action): CommandSpec => {\n\t\t\tconst isScene = action === 'nextScene' || action === 'previousScene';\n\t\t\tconst enabled = isScene\n\t\t\t\t? undefined\n\t\t\t\t: action.startsWith('align')\n\t\t\t\t\t? needs(2, 'node')\n\t\t\t\t\t: action.startsWith('distribute')\n\t\t\t\t\t\t? needs(3, 'node')\n\t\t\t\t\t\t: needs(1, 'node');\n\t\t\treturn {\n\t\t\t\tid: `${prefix}${action}`,\n\t\t\t\tlabel: ARRANGE_LABELS[action],\n\t\t\t\tgroup: isScene ? 'Scenes' : group,\n\t\t\t\tkeywords: isScene ? ['scene', 'slide', 'page'] : action.startsWith('align') ? ['align'] : ['arrange', 'layer', 'order'],\n\t\t\t\t...(scope ? { scope } : {}),\n\t\t\t\tshortcut: bindings.filter((b) => b.action === action).map((b) => b.label),\n\t\t\t\t...(isScene ? {} : { params: IDS_PARAMS }),\n\t\t\t\t...(enabled ? { enabled } : {}),\n\t\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => run[action](params?.ids)\n\t\t\t};\n\t\t});\n}\n\n// ---------------------------------------------------------------------------\n// Canvas shape operations\n// ---------------------------------------------------------------------------\n\n/** Shape operations surface of the arrange controller (`createCanvasArrangeController` satisfies it). */\nexport interface ShapeCommandTarget {\n\tcombineShapes(operation: 'unite' | 'intersect' | 'subtract' | 'exclude' | 'divide', ids?: Iterable<string>): unknown;\n\tcanCombineShapes(ids?: Iterable<string>): boolean;\n\toffsetShapes(distance: number, ids?: Iterable<string>, options?: { join?: 'miter' | 'round' | 'bevel'; miterLimit?: number }): unknown;\n\tcanOffsetShapes(ids?: Iterable<string>): boolean;\n\toutlineStroke(\n\t\tids?: Iterable<string>,\n\t\toptions?: { join?: 'miter' | 'round' | 'bevel'; cap?: 'butt' | 'round' | 'square'; miterLimit?: number }\n\t): unknown;\n\tcanOutlineStroke(ids?: Iterable<string>): boolean;\n}\n\nexport interface ShapeCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n\t/** Offset distance used when `canvas.offsetPath` is run without one (default 10). */\n\tdefaultOffset?: number;\n}\n\nconst SHAPE_COMMANDS = [\n\t{ op: 'unite', label: 'Unite Shapes', keywords: ['union', 'merge', 'boolean', 'combine'] },\n\t{ op: 'intersect', label: 'Intersect Shapes', keywords: ['intersection', 'boolean', 'combine'] },\n\t{ op: 'subtract', label: 'Subtract Shapes', keywords: ['difference', 'minus front', 'boolean', 'combine'] },\n\t{ op: 'exclude', label: 'Exclude Shapes', keywords: ['xor', 'boolean', 'combine'] },\n\t{ op: 'divide', label: 'Divide Shapes', keywords: ['split', 'pathfinder', 'boolean'] }\n] as const;\n\nconst JOIN_PARAM = { type: 'string', enum: ['miter', 'round', 'bevel'], description: 'Corner style (default miter).' } as const;\n\n/**\n * Palette / context-menu / agent commands for the shape operations: `canvas.unite`,\n * `canvas.intersect`, `canvas.subtract`, `canvas.exclude`, `canvas.divide`,\n * `canvas.offsetPath` (`{ distance, join?, miterLimit?, ids? }`) and `canvas.outlineStroke`\n * (`{ join?, cap?, miterLimit?, ids? }`). Each is one undoable step when the controller has a\n * history; enablement explains why a command cannot run.\n */\nexport function createShapeCommands(controller: ShapeCommandTarget, options: ShapeCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Shape';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\tconst combine = SHAPE_COMMANDS.map(\n\t\t({ op, label, keywords }): CommandSpec => ({\n\t\t\t...base,\n\t\t\tid: `${prefix}${op}`,\n\t\t\tlabel,\n\t\t\tkeywords: [...keywords],\n\t\t\tdescription: `${label.split(' ')[0]}s the selected shapes into a new path (curves are kept).`,\n\t\t\tparams: IDS_PARAMS,\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) =>\n\t\t\t\tcontroller.canCombineShapes(params?.ids) ? true : 'Select at least two unlocked shapes.',\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => controller.combineShapes(op, params?.ids)\n\t\t})\n\t);\n\treturn [\n\t\t...combine,\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}offsetPath`,\n\t\t\tlabel: 'Offset Path…',\n\t\t\tkeywords: ['inset', 'outset', 'grow', 'shrink', 'expand', 'contract'],\n\t\t\tdescription: 'Grows (positive distance) or shrinks (negative) the selected shapes.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tdistance: { type: 'number', description: `Offset in canvas units (default ${options.defaultOffset ?? 10}).` },\n\t\t\t\t\tjoin: JOIN_PARAM,\n\t\t\t\t\tmiterLimit: { type: 'number', description: 'Miter limit (default 4).' },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) =>\n\t\t\t\tcontroller.canOffsetShapes(params?.ids) ? true : 'Select an unlocked shape.',\n\t\t\trun: (_ctx: unknown, params: { distance?: number; join?: 'miter' | 'round' | 'bevel'; miterLimit?: number; ids?: string[] }) =>\n\t\t\t\tcontroller.offsetShapes(params?.distance ?? options.defaultOffset ?? 10, params?.ids, {\n\t\t\t\t\t...(params?.join ? { join: params.join } : {}),\n\t\t\t\t\t...(params?.miterLimit !== undefined ? { miterLimit: params.miterLimit } : {})\n\t\t\t\t})\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}outlineStroke`,\n\t\t\tlabel: 'Outline Stroke',\n\t\t\tkeywords: ['expand stroke', 'stroke to path', 'convert stroke'],\n\t\t\tdescription: 'Converts the strokes of the selected shapes to filled shapes.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tjoin: JOIN_PARAM,\n\t\t\t\t\tcap: { type: 'string', enum: ['butt', 'round', 'square'], description: 'Line cap (default butt).' },\n\t\t\t\t\tmiterLimit: { type: 'number', description: 'Miter limit (default 4).' },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) =>\n\t\t\t\tcontroller.canOutlineStroke(params?.ids) ? true : 'Select an unlocked shape with a stroke.',\n\t\t\trun: (\n\t\t\t\t_ctx: unknown,\n\t\t\t\tparams: { join?: 'miter' | 'round' | 'bevel'; cap?: 'butt' | 'round' | 'square'; miterLimit?: number; ids?: string[] }\n\t\t\t) =>\n\t\t\t\tcontroller.outlineStroke(params?.ids, {\n\t\t\t\t\t...(params?.join ? { join: params.join } : {}),\n\t\t\t\t\t...(params?.cap ? { cap: params.cap } : {}),\n\t\t\t\t\t...(params?.miterLimit !== undefined ? { miterLimit: params.miterLimit } : {})\n\t\t\t\t})\n\t\t}\n\t];\n}\n\n// ---------------------------------------------------------------------------\n// Canvas freehand drawing\n// ---------------------------------------------------------------------------\n\n/** Draw surface of the freehand draw controller (`createCanvasDrawController` satisfies it). */\nexport interface DrawCommandTarget {\n\tdrawStroke(input: {\n\t\tpoints: readonly (readonly [number, number])[];\n\t\ttool?: 'pen' | 'highlighter';\n\t\tstyle?: { color?: string; width?: number; opacity?: number; brush?: CanvasBrush; brushSize?: number; paint?: CanvasBrushPaint };\n\t\tpressure?: readonly number[];\n\t\ttiltX?: readonly number[];\n\t\ttiltY?: readonly number[];\n\t\tstreamline?: boolean;\n\t}): Promise<{ id: string; bounds: { x: number; y: number; width: number; height: number }; brush?: unknown }>;\n\t/** The dry paint presets a stroke can be brushed with (loads the paint engine). */\n\tlistBrushes(): Promise<CanvasBrushPreset[]>;\n}\n\nexport interface DrawCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope of the commands (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n\t/** Refuse drawing with this reason (e.g. a read-only canvas); `canvas.listBrushes` still runs. */\n\treadOnlyReason?: () => string | null | undefined;\n}\n\nconst PROFILE_PARAM = (what: string, lo: number, hi: number) =>\n\t({\n\t\ttype: 'array',\n\t\tminItems: 1,\n\t\tmaxItems: 256,\n\t\titems: { type: 'number', minimum: lo, maximum: hi },\n\t\tdescription: `${what} spread evenly along the stroke's length: the first value at the start, the last at the end, linearly in between; one value is constant. Only with a brush.`\n\t}) as const;\n\nconst BRUSH_SETTINGS_PARAM = {\n\ttype: 'object',\n\tadditionalProperties: false,\n\tdescription: 'Tip settings instead of a preset.',\n\tproperties: {\n\t\tsize: { type: 'number', minimum: 1, maximum: 2500, description: 'Brush diameter in canvas units (default: `width` when given, else 3).' },\n\t\thardness: { type: 'number', minimum: 0, maximum: 1, description: 'Edge hardness, 0 soft to 1 hard (default 1).' },\n\t\tspacing: { type: 'number', minimum: 0.01, maximum: 10, description: 'Dab spacing as a fraction of the diameter (default 0.1).' },\n\t\tangle: { type: 'number', minimum: -360, maximum: 360, description: 'Tip angle in degrees (default 0).' },\n\t\troundness: { type: 'number', minimum: 0.01, maximum: 1, description: 'Tip roundness, 1 round to 0.01 flat (default 1).' },\n\t\topacity: { type: 'number', minimum: 0, maximum: 1, description: 'Opacity ceiling of the stroke 0..1 (default 1).' },\n\t\tflow: { type: 'number', minimum: 0, maximum: 1, description: 'Build-up per dab 0..1 (default 1).' },\n\t\tpressureSize: { type: 'boolean', description: 'Pressure scales the size (default true).' },\n\t\tpressureOpacity: { type: 'boolean', description: 'Pressure scales the opacity (default false).' }\n\t}\n} as const;\n\nconst HEX_PARAM = '^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$';\n\n/**\n * Gradient paint for a brushed stroke: the paint engine's `PaintSource` described structurally,\n * so commands never import the paint module (see GOTCHAS: the DTS build runs out of memory).\n * The canvas renderer validates it again (sorted stops, defaults) before anything is drawn.\n */\nconst BRUSH_PAINT_PARAM = {\n\tdescription:\n\t\t'Paint the brushed stroke with gradient paint (or one colour) instead of `color`, sampled dab by dab along the path; `color` still gives the alpha and fills \"paint\" stops. Only with `brush`. Example (blue to yellow over 200 canvas units, and back): { \"type\": \"gradient\", \"stops\": [{ \"offset\": 0, \"color\": \"#1d4ed8\" }, { \"offset\": 1, \"color\": \"#facc15\" }], \"map\": { \"by\": \"distance\", \"length\": 200, \"repeat\": \"mirror\" } }.',\n\toneOf: [\n\t\t{\n\t\t\ttype: 'object',\n\t\t\tadditionalProperties: false,\n\t\t\trequired: ['type', 'color'],\n\t\t\tdescription: 'One colour.',\n\t\t\tproperties: {\n\t\t\t\ttype: { type: 'string', enum: ['color'], description: 'Always \"color\".' },\n\t\t\t\tcolor: { type: 'string', pattern: HEX_PARAM, description: 'The colour as #rrggbb (or #rgb).' }\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\ttype: 'object',\n\t\t\tadditionalProperties: false,\n\t\t\trequired: ['type', 'stops'],\n\t\t\tdescription: 'Gradient paint: the brush samples it dab by dab as the stroke goes.',\n\t\t\tproperties: {\n\t\t\t\ttype: { type: 'string', enum: ['gradient'], description: 'Always \"gradient\".' },\n\t\t\t\tstops: {\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tminItems: 2,\n\t\t\t\t\tmaxItems: 16,\n\t\t\t\t\tdescription: '2..16 stops sorted by offset.',\n\t\t\t\t\titems: {\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t\trequired: ['offset', 'color'],\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\toffset: { type: 'number', minimum: 0, maximum: 1, description: 'Position 0..1 along the gradient.' },\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\tdescription: 'The stop colour as #rrggbb, or \"paint\" (the stroke colour) or \"secondary\" (white).',\n\t\t\t\t\t\t\t\tanyOf: [{ pattern: HEX_PARAM }, { enum: ['paint', 'secondary'] }]\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\topacity: { type: 'number', minimum: 0, maximum: 1, description: 'Multiplies the brush flow where this colour is laid, 0..1 (default 1).' },\n\t\t\t\t\t\t\tmidpoint: { type: 'number', minimum: 0.05, maximum: 0.95, description: 'Where between this stop and the next the colours are half mixed, 0.05..0.95 (default 0.5).' }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tspace: { type: 'string', enum: ['pigment', 'oklab', 'srgb'], description: 'How neighbouring stops mix: pigment (default; like paint, blue to yellow passes green), oklab (perceptual) or srgb (plain numbers).' },\n\t\t\t\tmap: {\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\trequired: ['by'],\n\t\t\t\t\tdescription: 'What moves the stroke along the gradient (default distance, 300 canvas units, mirror).',\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tby: {\n\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\tenum: ['distance', 'pressure', 'tilt', 'direction', 'across-tip', 'random'],\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t'distance: canvas units (or dabs) travelled along the path; pressure: the pressure profile 0..1; tilt: pen lean from the tilt profiles, upright 0 .. flat 1; direction: direction of travel, once round per 360°; across-tip: left to right across the tip (a brush loaded with several colours); random: a seeded random point per dab. Canvas strokes carry no timing, so velocity and time are not available.'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlength: { type: 'number', minimum: 1, maximum: 100000, description: 'distance: canvas units (or dabs, with unit \"dabs\") per run through the gradient (default 300).' },\n\t\t\t\t\t\trepeat: { type: 'string', enum: ['clamp', 'repeat', 'mirror'], description: 'distance: past the end, clamp (hold the last colour), repeat (start again) or mirror (run back; default).' },\n\t\t\t\t\t\tunit: { type: 'string', enum: ['px', 'dabs'], description: 'distance: canvas units (\"px\", default) or dabs.' },\n\t\t\t\t\t\tevery: { type: 'integer', minimum: 1, maximum: 500, description: 'random: dabs per random pick (default 1).' }\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsoftness: { type: 'number', minimum: 0, maximum: 1, description: 'How softly neighbouring stops blend: 1 smooth (default) .. 0 hard steps.' }\n\t\t\t}\n\t\t}\n\t]\n} as const;\n\n/**\n * Agent / palette commands for freehand drawing: `canvas.drawFreehand` (a pen or highlighter\n * stroke through given points, optionally brushed with a dry paint preset and a pressure / tilt\n * profile; one undo step) and the read-only `canvas.listBrushes` (the dry presets it accepts).\n */\nexport function createDrawCommands(target: DrawCommandTarget, options: DrawCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Draw';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\treturn [\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}drawFreehand`,\n\t\t\tlabel: 'Draw Freehand Stroke',\n\t\t\tkeywords: ['pen', 'highlighter', 'brush', 'sketch', 'draw', 'stroke', 'pencil', 'ink'],\n\t\t\tdescription:\n\t\t\t\t'Draws a freehand pen or highlighter stroke through points (canvas coordinates) as one path shape node, in one undo step. With `brush` it is painted with a dry paint brush (a preset id from canvas.listBrushes, or tip settings) and `pressure` / `tiltX` / `tiltY` profiles shape it along its length; `paint` gives it gradient paint that changes colour along the stroke. Wet brushes are refused. Returns the new node `id`, its `bounds` and the stored `brush`.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tadditionalProperties: false,\n\t\t\t\trequired: ['points'],\n\t\t\t\tproperties: {\n\t\t\t\t\tpoints: {\n\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\tmaxItems: 5000,\n\t\t\t\t\t\titems: { type: 'array', minItems: 2, maxItems: 2, items: { type: 'number' } },\n\t\t\t\t\t\tdescription: 'Stroke points as [x, y] pairs in canvas (flow) units, in drawing order. Use a point every few units along curves.'\n\t\t\t\t\t},\n\t\t\t\t\ttool: { type: 'string', enum: ['pen', 'highlighter'], description: 'Pen (default: blue, width 3) or highlighter (yellow, width 24, opacity 0.35); sets the defaults below.' },\n\t\t\t\t\tcolor: { type: 'string', description: 'Stroke colour, any CSS colour (default from the tool).' },\n\t\t\t\t\twidth: { type: 'number', exclusiveMinimum: 0, maximum: 2500, description: 'Stroke width in canvas units (default from the tool). For brushed strokes it is the brush diameter; leave it out to use the preset\\'s own size (canvas.listBrushes gives it).' },\n\t\t\t\t\topacity: { type: 'number', minimum: 0, maximum: 1, description: 'Stroke opacity 0..1 (default from the tool).' },\n\t\t\t\t\tbrush: {\n\t\t\t\t\t\tdescription: 'Paint the stroke with a dry paint brush: a preset id such as \"ink-pen\", \"pencil-hb\", \"brush-pen\", \"charcoal-stick\", \"soft-pastel\", \"marker\" or \"airbrush\" (all ids: canvas.listBrushes), or tip settings. Omit for a plain vector stroke.',\n\t\t\t\t\t\toneOf: [{ type: 'string', minLength: 1 }, BRUSH_SETTINGS_PARAM]\n\t\t\t\t\t},\n\t\t\t\t\tpaint: BRUSH_PAINT_PARAM,\n\t\t\t\t\tpressure: PROFILE_PARAM('Pen pressure 0..1', 0, 1),\n\t\t\t\t\ttiltX: PROFILE_PARAM('Pen tilt along x in degrees (−90..90)', -90, 90),\n\t\t\t\t\ttiltY: PROFILE_PARAM('Pen tilt along y in degrees (−90..90)', -90, 90),\n\t\t\t\t\tstreamline: { type: 'boolean', description: 'Smooth jittery points before fitting the path (default false).' }\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: () => options.readOnlyReason?.() || true,\n\t\t\trun: (\n\t\t\t\t_ctx: unknown,\n\t\t\t\tparams: {\n\t\t\t\t\tpoints: [number, number][];\n\t\t\t\t\ttool?: 'pen' | 'highlighter';\n\t\t\t\t\tcolor?: string;\n\t\t\t\t\twidth?: number;\n\t\t\t\t\topacity?: number;\n\t\t\t\t\tbrush?: CanvasBrush;\n\t\t\t\t\tpaint?: CanvasBrushPaint;\n\t\t\t\t\tpressure?: number[];\n\t\t\t\t\ttiltX?: number[];\n\t\t\t\t\ttiltY?: number[];\n\t\t\t\t\tstreamline?: boolean;\n\t\t\t\t}\n\t\t\t) =>\n\t\t\t\ttarget.drawStroke({\n\t\t\t\t\tpoints: params.points,\n\t\t\t\t\t...(params.tool ? { tool: params.tool } : {}),\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\t...(params.color !== undefined ? { color: params.color } : {}),\n\t\t\t\t\t\t...(params.width !== undefined ? { width: params.width } : {}),\n\t\t\t\t\t\t...(params.width !== undefined && params.brush !== undefined ? { brushSize: params.width } : {}),\n\t\t\t\t\t\t...(params.opacity !== undefined ? { opacity: params.opacity } : {}),\n\t\t\t\t\t\t...(params.brush !== undefined ? { brush: params.brush } : {}),\n\t\t\t\t\t\t...(params.paint !== undefined ? { paint: params.paint } : {})\n\t\t\t\t\t},\n\t\t\t\t\t...(params.pressure ? { pressure: params.pressure } : {}),\n\t\t\t\t\t...(params.tiltX ? { tiltX: params.tiltX } : {}),\n\t\t\t\t\t...(params.tiltY ? { tiltY: params.tiltY } : {}),\n\t\t\t\t\t...(params.streamline ? { streamline: true } : {})\n\t\t\t\t})\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}listBrushes`,\n\t\t\tlabel: 'List Freehand Brushes',\n\t\t\tkeywords: ['brushes', 'presets', 'paint', 'pencil', 'ink'],\n\t\t\tdescription: 'Read-only: the dry paint presets canvas.drawFreehand accepts as `brush`, as { id, name, category, size } (size is the preset\\'s own diameter, which a brushed stroke uses unless `width` is given).',\n\t\t\tparams: { type: 'object', additionalProperties: false, properties: {} },\n\t\t\treadOnly: true,\n\t\t\trun: async () => ({ brushes: await target.listBrushes() })\n\t\t}\n\t];\n}\n\n// ---------------------------------------------------------------------------\n// Canvas components and instances\n// ---------------------------------------------------------------------------\n\ntype ComponentActionResult = { ok: true; ids: string[] } | { ok: false; reason: string };\n\n/** Components surface of the components controller (`createCanvasComponentsController` satisfies it). */\nexport interface ComponentCommandTarget {\n\tcreateComponent(ids?: Iterable<string>): ComponentActionResult;\n\tcanCreateComponent(ids?: Iterable<string>): true | string;\n\tcombineAsVariants(ids?: Iterable<string>): ComponentActionResult;\n\tcanCombineAsVariants(ids?: Iterable<string>): true | string;\n\tcreateInstance(componentId: string, options?: { parentId?: string; position?: { x: number; y: number }; properties?: Record<string, boolean | string> }): ComponentActionResult;\n\tcanCreateInstance(componentId?: string, parentId?: string): true | string;\n\tdetachInstance(ids?: Iterable<string>): ComponentActionResult;\n\tcanDetachInstance(ids?: Iterable<string>): true | string;\n\tresetOverrides(id?: string, group?: string): ComponentActionResult;\n\tcanResetOverrides(id?: string): true | string;\n\tpushOverrides(id?: string): ComponentActionResult;\n\tcanPushOverrides(id?: string): true | string;\n\tswapInstance(componentId: string, ids?: Iterable<string>): ComponentActionResult;\n\tcanSwapInstance(componentId?: string, ids?: Iterable<string>): true | string;\n\tsetInstanceProperties(properties: Record<string, unknown>, ids?: Iterable<string>): ComponentActionResult;\n\tcanSetInstanceProperties(ids?: Iterable<string>): true | string;\n\trestoreMainComponent(id?: string): ComponentActionResult;\n\tcanRestoreMainComponent(id?: string): true | string;\n\tgoToMainComponent(id?: string): string | undefined;\n\tcanGoToMainComponent(id?: string): true | string;\n\tlist(): unknown;\n\tinspect(id?: string): unknown;\n\t// Variant editing (optional so older targets keep type-checking; the controller has them all).\n\taddVariant?(\n\t\tsetId?: string,\n\t\toptions?: { from?: string; variant?: Record<string, string>; position?: { x: number; y: number }; defaultValue?: string }\n\t): ComponentActionResult;\n\tcanAddVariant?(setId?: string, options?: { from?: string; variant?: Record<string, string> }): true | string;\n\tremoveVariant?(variantId?: string): ComponentActionResult;\n\tcanRemoveVariant?(variantId?: string): true | string;\n\tsetVariantProperties?(values: Record<string, string>, variantId?: string, options?: { defaultValue?: string }): ComponentActionResult;\n\tcanSetVariantProperties?(values?: Record<string, string>, variantId?: string): true | string;\n\trenameVariantProperty?(name: string, newName: string, setId?: string): ComponentActionResult;\n\tcanRenameVariantProperty?(name?: string, newName?: string, setId?: string): true | string;\n\trenameVariantValue?(property: string, value: string, newValue: string, setId?: string): ComponentActionResult;\n\tcanRenameVariantValue?(property?: string, value?: string, newValue?: string, setId?: string): true | string;\n}\n\n/** The variant-editing part of a `ComponentCommandTarget` (present on the components controller). */\ntype VariantCommandTarget = Required<\n\tPick<\n\t\tComponentCommandTarget,\n\t\t| 'addVariant'\n\t\t| 'canAddVariant'\n\t\t| 'removeVariant'\n\t\t| 'canRemoveVariant'\n\t\t| 'setVariantProperties'\n\t\t| 'canSetVariantProperties'\n\t\t| 'renameVariantProperty'\n\t\t| 'canRenameVariantProperty'\n\t\t| 'renameVariantValue'\n\t\t| 'canRenameVariantValue'\n\t>\n>;\n\n/** Whether a command target can edit variants. */\nexport function hasVariantCommands(controller: ComponentCommandTarget): controller is ComponentCommandTarget & VariantCommandTarget {\n\treturn typeof controller.addVariant === 'function' && typeof controller.removeVariant === 'function';\n}\n\nconst SET_ID_PARAM = { type: 'string', description: 'Component set (or one of its variants) to act on (default: the selection’s set).' } as const;\nconst VARIANT_ID_PARAM = { type: 'string', description: 'Variant to act on (default: the first selected variant).' } as const;\nconst VARIANT_VALUES_PARAM = {\n\ttype: 'object',\n\tdescription: 'Variant property → value, e.g. { \"Size\": \"Medium\" }. New property names are added to every variant.',\n\tadditionalProperties: { type: 'string' }\n} as const;\n\nfunction variantCommands(controller: ComponentCommandTarget & VariantCommandTarget, prefix: string, base: Partial<CommandSpec>): CommandSpec[] {\n\treturn [\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}addVariant`,\n\t\t\tlabel: 'Add Variant',\n\t\t\tkeywords: ['variant', 'new variant', 'duplicate variant', 'component set'],\n\t\t\tdescription: 'Adds a variant to a component set by duplicating one (default: the selected or default variant) with new property values.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tsetId: SET_ID_PARAM,\n\t\t\t\t\tfrom: { type: 'string', description: 'Variant to duplicate (default: the selected variant, else the default one).' },\n\t\t\t\t\tvariant: VARIANT_VALUES_PARAM,\n\t\t\t\t\tx: { type: 'number', description: 'X in the set’s space (default: next to the source).' },\n\t\t\t\t\ty: { type: 'number', description: 'Y in the set’s space.' }\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { setId?: string; from?: string; variant?: Record<string, string> }) =>\n\t\t\t\tcontroller.canAddVariant(params?.setId, {\n\t\t\t\t\t...(params?.from !== undefined ? { from: params.from } : {}),\n\t\t\t\t\t...(params?.variant ? { variant: params.variant } : {})\n\t\t\t\t}),\n\t\t\trun: (_ctx: unknown, params?: { setId?: string; from?: string; variant?: Record<string, string>; x?: number; y?: number }) =>\n\t\t\t\toutcome(\n\t\t\t\t\tcontroller.addVariant(params?.setId, {\n\t\t\t\t\t\t...(params?.from !== undefined ? { from: params.from } : {}),\n\t\t\t\t\t\t...(params?.variant ? { variant: params.variant } : {}),\n\t\t\t\t\t\t...(params?.x !== undefined || params?.y !== undefined ? { position: { x: params?.x ?? 0, y: params?.y ?? 0 } } : {})\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t} as CommandSpec,\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}removeVariant`,\n\t\t\tlabel: 'Remove Variant',\n\t\t\tkeywords: ['delete variant', 'variant'],\n\t\t\tdescription: 'Removes a variant; its instances switch to the closest remaining variant, keeping overrides.',\n\t\t\tparams: { type: 'object', properties: { id: VARIANT_ID_PARAM } },\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canRemoveVariant(params?.id),\n\t\t\trun: (_ctx: unknown, params?: { id?: string }) => outcome(controller.removeVariant(params?.id))\n\t\t} as CommandSpec,\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}setVariantProperties`,\n\t\t\tlabel: 'Edit Variant Properties…',\n\t\t\tkeywords: ['rename variant', 'variant values', 'variant'],\n\t\t\tdescription: 'Sets a variant’s property values (refusing a combination another variant has).',\n\t\t\tparams: { type: 'object', properties: { values: VARIANT_VALUES_PARAM, id: VARIANT_ID_PARAM }, required: ['values'] },\n\t\t\tenabled: (_ctx: unknown, params?: { values?: Record<string, string>; id?: string }) => controller.canSetVariantProperties(params?.values, params?.id),\n\t\t\trun: (_ctx: unknown, params: { values: Record<string, string>; id?: string }) => outcome(controller.setVariantProperties(params.values, params?.id))\n\t\t} as CommandSpec,\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}renameVariantProperty`,\n\t\t\tlabel: 'Rename Variant Property…',\n\t\t\tkeywords: ['rename property', 'variant property'],\n\t\t\tdescription: 'Renames a variant property across a component set.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { name: { type: 'string' }, newName: { type: 'string' }, setId: SET_ID_PARAM },\n\t\t\t\trequired: ['name', 'newName']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { name?: string; newName?: string; setId?: string }) =>\n\t\t\t\tcontroller.canRenameVariantProperty(params?.name, params?.newName, params?.setId),\n\t\t\trun: (_ctx: unknown, params: { name: string; newName: string; setId?: string }) =>\n\t\t\t\toutcome(controller.renameVariantProperty(params.name, params.newName, params?.setId))\n\t\t} as CommandSpec,\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}renameVariantValue`,\n\t\t\tlabel: 'Rename Variant Value…',\n\t\t\tkeywords: ['rename value', 'variant value'],\n\t\t\tdescription: 'Renames a value of a variant property across a component set.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { property: { type: 'string' }, value: { type: 'string' }, newValue: { type: 'string' }, setId: SET_ID_PARAM },\n\t\t\t\trequired: ['property', 'value', 'newValue']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { property?: string; value?: string; newValue?: string; setId?: string }) =>\n\t\t\t\tcontroller.canRenameVariantValue(params?.property, params?.value, params?.newValue, params?.setId),\n\t\t\trun: (_ctx: unknown, params: { property: string; value: string; newValue: string; setId?: string }) =>\n\t\t\t\toutcome(controller.renameVariantValue(params.property, params.value, params.newValue, params?.setId))\n\t\t} as CommandSpec\n\t];\n}\n\nexport interface ComponentCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n}\n\nconst outcome = (result: ComponentActionResult) => {\n\tif (!result.ok) throw new Error(result.reason);\n\treturn { ids: result.ids };\n};\n\nconst ID_PARAM = { type: 'string', description: 'Instance (or layer inside one) to act on (default: the first selected node).' } as const;\n\n/**\n * Palette / context-menu / agent commands for components and instances:\n * `canvas.createComponent`, `canvas.combineAsVariants`, `canvas.createInstance`\n * (`{ componentId, parentId?, x?, y?, properties? }`), `canvas.detachInstance`,\n * `canvas.resetOverrides` (`{ id?, group? }`), `canvas.pushOverrides`, `canvas.goToMainComponent`,\n * `canvas.swapInstance` (`{ componentId, ids? }`), `canvas.setInstanceProperties`\n * (`{ properties, ids? }`: variant and component property values), `canvas.restoreMainComponent`,\n * the variant editors `canvas.addVariant` (`{ setId?, from?, variant?, x?, y? }`),\n * `canvas.removeVariant` (`{ id? }`), `canvas.setVariantProperties` (`{ values, id? }`),\n * `canvas.renameVariantProperty` (`{ name, newName, setId? }`) and `canvas.renameVariantValue`\n * (`{ property, value, newValue, setId? }`) when the target has them, and the read-only `canvas.listComponents` / `canvas.inspectInstance`. Each action is one\n * undoable step when the controller has a history; enablement explains why it cannot run.\n */\nexport function createComponentCommands(controller: ComponentCommandTarget, options: ComponentCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Components';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\tconst idParams: CommandParamsSchema = { type: 'object', properties: { id: ID_PARAM } };\n\treturn [\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}createComponent`,\n\t\t\tlabel: 'Create Component',\n\t\t\tkeywords: ['component', 'symbol', 'main component', 'reusable'],\n\t\t\tdescription: 'Turns the selected frame into a main component, or wraps the selection in one.',\n\t\t\tparams: IDS_PARAMS,\n\t\t\tshortcut: 'Mod+Alt+K',\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canCreateComponent(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => outcome(controller.createComponent(params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}combineAsVariants`,\n\t\t\tlabel: 'Combine as Variants',\n\t\t\tkeywords: ['component set', 'variant', 'variants'],\n\t\t\tdescription: 'Wraps the selected components in a component set.',\n\t\t\tparams: IDS_PARAMS,\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canCombineAsVariants(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => outcome(controller.combineAsVariants(params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}createInstance`,\n\t\t\tlabel: 'Create Instance',\n\t\t\tkeywords: ['instance', 'insert component', 'use component'],\n\t\t\tdescription: 'Places an instance of a component (or a component set’s default variant).',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tcomponentId: { type: 'string', description: 'Component or component set id.' },\n\t\t\t\t\tparentId: { type: 'string', description: 'Frame to place it in (default: the canvas).' },\n\t\t\t\t\tx: { type: 'number', description: 'X in the parent’s space (default: next to the main).' },\n\t\t\t\t\ty: { type: 'number', description: 'Y in the parent’s space.' },\n\t\t\t\t\tproperties: { type: 'object', description: 'Variant and component property values.', additionalProperties: true }\n\t\t\t\t},\n\t\t\t\trequired: ['componentId']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { componentId?: string; parentId?: string }) =>\n\t\t\t\tparams?.componentId === undefined ? true : controller.canCreateInstance(params.componentId, params.parentId),\n\t\t\trun: (_ctx: unknown, params: { componentId: string; parentId?: string; x?: number; y?: number; properties?: Record<string, boolean | string> }) =>\n\t\t\t\toutcome(\n\t\t\t\t\tcontroller.createInstance(params.componentId, {\n\t\t\t\t\t\t...(params.parentId !== undefined ? { parentId: params.parentId } : {}),\n\t\t\t\t\t\t...(params.x !== undefined || params.y !== undefined ? { position: { x: params.x ?? 0, y: params.y ?? 0 } } : {}),\n\t\t\t\t\t\t...(params.properties ? { properties: params.properties } : {})\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}detachInstance`,\n\t\t\tlabel: 'Detach Instance',\n\t\t\tkeywords: ['unlink', 'break instance'],\n\t\t\tdescription: 'Turns the selected instances into plain frames that keep their look.',\n\t\t\tparams: IDS_PARAMS,\n\t\t\tshortcut: 'Mod+Alt+B',\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canDetachInstance(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => outcome(controller.detachInstance(params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}resetOverrides`,\n\t\t\tlabel: 'Reset All Changes',\n\t\t\tkeywords: ['reset instance', 'reset overrides', 'revert'],\n\t\t\tdescription: 'Resets the overrides of an instance (or of a layer, or one override group) to its main.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tid: ID_PARAM,\n\t\t\t\t\tgroup: { type: 'string', description: 'One override group to reset, e.g. \"data.label\" or \"shape.fill\" (default: all).' }\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canResetOverrides(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string; group?: string }) => outcome(controller.resetOverrides(params?.id, params?.group))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}pushOverrides`,\n\t\t\tlabel: 'Push Changes to Main Component',\n\t\t\tkeywords: ['push overrides', 'update main component'],\n\t\t\tdescription: 'Copies the instance’s overrides to its main component and every other instance.',\n\t\t\tparams: idParams,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canPushOverrides(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => outcome(controller.pushOverrides(params?.id))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}goToMainComponent`,\n\t\t\tlabel: 'Go to Main Component',\n\t\t\tkeywords: ['main component', 'find main', 'reveal'],\n\t\t\tdescription: 'Selects the main component of the selected instance.',\n\t\t\tparams: idParams,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canGoToMainComponent(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => {\n\t\t\t\tconst main = controller.goToMainComponent(params?.id);\n\t\t\t\tif (!main) throw new Error('The main component was not found.');\n\t\t\t\treturn { id: main };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}swapInstance`,\n\t\t\tlabel: 'Swap Instance…',\n\t\t\tkeywords: ['replace instance', 'swap component'],\n\t\t\tdescription: 'Makes the selected instances show another component, keeping matching overrides.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tcomponentId: { type: 'string', description: 'Component or component set to swap to.' },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t},\n\t\t\t\trequired: ['componentId']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { componentId?: string; ids?: string[] }) => controller.canSwapInstance(params?.componentId, params?.ids),\n\t\t\trun: (_ctx: unknown, params: { componentId: string; ids?: string[] }) => outcome(controller.swapInstance(params.componentId, params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}setInstanceProperties`,\n\t\t\tlabel: 'Set Instance Properties…',\n\t\t\tkeywords: ['variant', 'switch variant', 'component property', 'toggle'],\n\t\t\tdescription: 'Sets variant properties (switching variants) and component property values of the selected instances.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tproperties: { type: 'object', description: 'Property name → value (variant value, boolean, text or component id).', additionalProperties: true },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t},\n\t\t\t\trequired: ['properties']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canSetInstanceProperties(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { properties: Record<string, unknown>; ids?: string[] }) =>\n\t\t\t\toutcome(controller.setInstanceProperties(params.properties, params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}restoreMainComponent`,\n\t\t\tlabel: 'Restore Main Component',\n\t\t\tkeywords: ['missing main', 'recover component'],\n\t\t\tdescription: 'Turns an instance whose main was deleted back into the main component.',\n\t\t\tparams: idParams,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canRestoreMainComponent(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => outcome(controller.restoreMainComponent(params?.id))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}listComponents`,\n\t\t\tlabel: 'List Components',\n\t\t\tkeywords: ['components', 'variants', 'assets'],\n\t\t\tdescription: 'Lists the components and component sets (with their variant options).',\n\t\t\treadOnly: true,\n\t\t\trun: () => controller.list()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}inspectInstance`,\n\t\t\tlabel: 'Inspect Instance',\n\t\t\tkeywords: ['instance', 'overrides', 'properties'],\n\t\t\tdescription: 'Describes an instance: its main, variant, property values and overrides.',\n\t\t\tparams: idParams,\n\t\t\treadOnly: true,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => (controller.inspect(params?.id) ? true : 'Select an instance.'),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => controller.inspect(params?.id) ?? null\n\t\t},\n\t\t...(hasVariantCommands(controller) ? variantCommands(controller, prefix, base) : [])\n\t];\n}\n\n// ---------------------------------------------------------------------------\n// Spreadsheet table actions\n// ---------------------------------------------------------------------------\n\n/** Spreadsheet controller surface used by `createSpreadsheetCommands`. */\nexport interface SpreadsheetCommandTarget {\n\tselectedRange: unknown;\n\tgetFilterState(): { enabled: boolean; rules: readonly unknown[] };\n\ttoggleFilters(): void;\n\tclearFilters(): void;\n\tunhideAll(): void;\n\tmergeCells(): boolean;\n\tunmergeCells(): boolean;\n\ttransposeRange(): boolean;\n}\n\nexport interface SpreadsheetCommandOptions {\n\t/** Id prefix (default `spreadsheet.`). */\n\tprefix?: string;\n\t/** Scope (default `spreadsheet`). Pass `null` for global. */\n\tscope?: string | null;\n}\n\n/** Turns a controller's `false` (nothing changed) into a failure the palette and agents see. */\nfunction orFail(changed: boolean, message: string): true {\n\tif (!changed) throw new Error(message);\n\treturn true;\n}\n\n/**\n * Palette / agent commands for common spreadsheet table actions (no default shortcuts).\n * Merge, unmerge and transpose act on the user's selection; agents should use the\n * `merge_cells` / `unmerge_cells` / `transpose_range` tools, which take a range.\n */\nexport function createSpreadsheetCommands(\n\tcontroller: SpreadsheetCommandTarget,\n\toptions: SpreadsheetCommandOptions = {}\n): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'spreadsheet.';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'spreadsheet';\n\tconst hasRange = () => (controller.selectedRange ? true : 'Select a range first.');\n\tconst base = { group: 'Table', ...(scope ? { scope } : {}) };\n\treturn [\n\t\t{ ...base, id: `${prefix}toggleFilters`, label: 'Toggle Filters', keywords: ['filter'], run: () => controller.toggleFilters() },\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}clearFilters`,\n\t\t\tlabel: 'Clear Filters',\n\t\t\tkeywords: ['filter', 'reset'],\n\t\t\tenabled: () => (controller.getFilterState().rules.length > 0 ? true : 'No filters to clear.'),\n\t\t\trun: () => controller.clearFilters()\n\t\t},\n\t\t{ ...base, id: `${prefix}unhideAll`, label: 'Unhide All Rows and Columns', keywords: ['show', 'hidden'], run: () => controller.unhideAll() },\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}mergeCells`,\n\t\t\tlabel: 'Merge Cells',\n\t\t\tkeywords: ['combine'],\n\t\t\tenabled: hasRange,\n\t\t\trun: () =>\n\t\t\t\torFail(controller.mergeCells(), 'Cannot merge the selection: it is a single cell, or it partly overlaps a merge or a spill range.')\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}unmergeCells`,\n\t\t\tlabel: 'Unmerge Cells',\n\t\t\tkeywords: ['split'],\n\t\t\tenabled: hasRange,\n\t\t\trun: () => orFail(controller.unmergeCells(), 'There are no merged cells in the selection.')\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}transposeRange`,\n\t\t\tlabel: 'Transpose Range',\n\t\t\tkeywords: ['rotate', 'swap rows columns'],\n\t\t\tenabled: hasRange,\n\t\t\trun: () =>\n\t\t\t\torFail(controller.transposeRange(), 'Cannot transpose the selection: it is a single cell, or a merge or a spill range is in the way.')\n\t\t}\n\t];\n}\n"],"mappings":";;;;;;AAqBO,IAAM,4BAAwD;AAAA,EACpE,EAAE,SAAS,QAAQ,OAAO,QAAQ;AAAA,EAClC,EAAE,SAAS,QAAQ,OAAO,cAAc;AAAA,EACxC,EAAE,SAAS,QAAQ,OAAO,SAAS,WAAW,CAAC,WAAW,OAAO,EAAE;AACpE;AAUO,SAAS,sBAAsB,SAA+B,UAAiC,CAAC,GAAkB;AACxH,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,cAAc,CAAC,YACpB,0BAA0B,OAAO,CAAC,MAAM,EAAE,YAAY,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,IAAI,GAAG,KAAK,MAAM,IAAI;AACtG,SAAO;AAAA,IACN;AAAA,MACC,IAAI,GAAG,MAAM;AAAA,MACb,OAAO;AAAA,MACP;AAAA,MACA,UAAU,CAAC,UAAU,MAAM;AAAA,MAC3B,aAAa;AAAA,MACb,UAAU,YAAY,MAAM;AAAA,MAC5B,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,MAChD,SAAS,MAAO,QAAQ,SAAS,EAAE,UAAU,OAAO;AAAA,MACpD,KAAK,MAAM;AACV,gBAAQ,KAAK;AACb,eAAO,EAAE,QAAQ,MAAM,OAAO,QAAQ,SAAS,EAAE;AAAA,MAClD;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,GAAG,MAAM;AAAA,MACb,OAAO;AA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MACb,OAAO;AAAA,MACP,UAAU,CAAC,UAAU,OAAO;AAAA,MAC5B,SAAS,MAAO,WAAW,eAAe,EAAE,MAAM,SAAS,IAAI,OAAO;AAAA,MACtE,KAAK,MAAM,WAAW,aAAa;AAAA,IACpC;AAAA,IACA,EAAE,GAAG,MAAM,IAAI,GAAG,MAAM,aAAa,OAAO,+BAA+B,UAAU,CAAC,QAAQ,QAAQ,GAAG,KAAK,MAAM,WAAW,UAAU,EAAE;AAAA,IAC3I;AAAA,MACC,GAAG;AAAA,MACH,IAAI,GAAG,MAAM;AAAA,MACb,OAAO;AAAA,MACP,UAAU,CAAC,SAAS;AAAA,MACpB,SAAS;AAAA,MACT,KAAK,MACJ,OAAO,WAAW,WAAW,GAAG,kGAAkG;AAAA,IACpI;AAAA,IACA;AAAA,MACC,GAAG;AAAA,MACH,IAAI,GAAG,MAAM;AAAA,MACb,OAAO;AAAA,MACP,UAAU,CAAC,OAAO;AAAA,MAClB,SAAS;AAAA,MACT,KAAK,MAAM,OAAO,WAAW,aAAa,GAAG,6CAA6C;AAAA,IAC3F;AAAA,IACA;AAAA,MACC,GAAG;AAAA,MACH,IAAI,GAAG,MAAM;AAAA,MACb,OAAO;AAAA,MACP,UAAU,CAAC,UAAU,mBAAmB;AAAA,MACxC,SAAS;AAAA,MACT,KAAK,MACJ,OAAO,WAAW,eAAe,GAAG,iGAAiG;AAAA,IACvI;AAAA,EACD;AACD;","names":[]}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
unionBounds,
|
|
19
19
|
vectorGradientPoints,
|
|
20
20
|
widthProfileAt
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-V45ZTW4R.js";
|
|
22
22
|
import {
|
|
23
23
|
segmentLength,
|
|
24
24
|
segmentParamAtLength,
|
|
@@ -750,4 +750,4 @@ export {
|
|
|
750
750
|
interpolateVectorPaths,
|
|
751
751
|
evaluateVectorPathKeyframes
|
|
752
752
|
};
|
|
753
|
-
//# sourceMappingURL=chunk-
|
|
753
|
+
//# sourceMappingURL=chunk-OV7253FC.js.map
|
|
@@ -40,6 +40,73 @@ function hash2(x, y, salt) {
|
|
|
40
40
|
function rand01(seed, index, stream) {
|
|
41
41
|
return hash2(index, stream, seed);
|
|
42
42
|
}
|
|
43
|
+
function randSigned(seed, index, stream) {
|
|
44
|
+
return rand01(seed, index, stream) * 2 - 1;
|
|
45
|
+
}
|
|
46
|
+
function seedFromString(text) {
|
|
47
|
+
let h = 2166136261;
|
|
48
|
+
for (let i = 0; i < text.length; i++) {
|
|
49
|
+
h ^= text.charCodeAt(i);
|
|
50
|
+
h = Math.imul(h, 16777619);
|
|
51
|
+
}
|
|
52
|
+
return mix32(h >>> 0);
|
|
53
|
+
}
|
|
54
|
+
var smooth = (t) => t * t * (3 - 2 * t);
|
|
55
|
+
var Lattice = class {
|
|
56
|
+
constructor(px, py, salt) {
|
|
57
|
+
this.px = px;
|
|
58
|
+
this.py = py;
|
|
59
|
+
this.values = new Float32Array(px * py);
|
|
60
|
+
for (let j = 0; j < py; j++) for (let i = 0; i < px; i++) this.values[j * px + i] = hash2(i, j, salt);
|
|
61
|
+
}
|
|
62
|
+
px;
|
|
63
|
+
py;
|
|
64
|
+
values;
|
|
65
|
+
/** Value noise at (x, y) in lattice cells; wraps every `px` / `py` cells. */
|
|
66
|
+
at(x, y) {
|
|
67
|
+
const { px, py } = this;
|
|
68
|
+
const x0 = Math.floor(x);
|
|
69
|
+
const y0 = Math.floor(y);
|
|
70
|
+
const tx = smooth(x - x0);
|
|
71
|
+
const ty = smooth(y - y0);
|
|
72
|
+
const i0 = (x0 % px + px) % px;
|
|
73
|
+
const j0 = (y0 % py + py) % py;
|
|
74
|
+
const i1 = (i0 + 1) % px;
|
|
75
|
+
const j1 = (j0 + 1) % py;
|
|
76
|
+
const v = this.values;
|
|
77
|
+
const a = v[j0 * px + i0] + (v[j0 * px + i1] - v[j0 * px + i0]) * tx;
|
|
78
|
+
const b = v[j1 * px + i0] + (v[j1 * px + i1] - v[j1 * px + i0]) * tx;
|
|
79
|
+
return a + (b - a) * ty;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var TileableNoise = class {
|
|
83
|
+
constructor(size, cellsX, cellsY, octaves, salt) {
|
|
84
|
+
this.size = size;
|
|
85
|
+
let cx = Math.max(1, Math.round(cellsX));
|
|
86
|
+
let cy = Math.max(1, Math.round(cellsY));
|
|
87
|
+
for (let o = 0; o < octaves; o++) {
|
|
88
|
+
this.octaves.push(new Lattice(cx, cy, salt + o * 7919 | 0));
|
|
89
|
+
cx *= 2;
|
|
90
|
+
cy *= 2;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
size;
|
|
94
|
+
octaves = [];
|
|
95
|
+
/** Fractal noise at pixel (x, y). */
|
|
96
|
+
at(x, y) {
|
|
97
|
+
let sum = 0;
|
|
98
|
+
let amp = 1;
|
|
99
|
+
let norm = 0;
|
|
100
|
+
const u = x / this.size;
|
|
101
|
+
const v = y / this.size;
|
|
102
|
+
for (const l of this.octaves) {
|
|
103
|
+
sum += l.at(u * l.px, v * l.py) * amp;
|
|
104
|
+
norm += amp;
|
|
105
|
+
amp *= 0.5;
|
|
106
|
+
}
|
|
107
|
+
return norm > 0 ? sum / norm : 0.5;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
43
110
|
|
|
44
111
|
// src/paint/gradient-paint.ts
|
|
45
112
|
var PAINT_GRADIENT_SPACES = ["pigment", "oklab", "srgb"];
|
|
@@ -1100,7 +1167,181 @@ function coverageTileCoord(key) {
|
|
|
1100
1167
|
return tileCoord(key);
|
|
1101
1168
|
}
|
|
1102
1169
|
|
|
1170
|
+
// src/paint/grain.ts
|
|
1171
|
+
var GRAIN_PATTERNS = ["smooth", "cold-pressed", "hot-pressed", "rough", "vellum", "laid", "ingres", "sanded", "canvas", "linen", "gesso"];
|
|
1172
|
+
var GRAIN_TILE = 256;
|
|
1173
|
+
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
1174
|
+
function patternHeights(pattern, n, seed) {
|
|
1175
|
+
const out = new Float32Array(n * n);
|
|
1176
|
+
const salt = Math.imul(seed | 0, 2654435761) + 17;
|
|
1177
|
+
if (pattern === "smooth") return out.fill(1);
|
|
1178
|
+
const noise = (cx, cy, oct, s = 0) => new TileableNoise(n, cx, cy, oct, salt + s);
|
|
1179
|
+
const k = n / GRAIN_TILE;
|
|
1180
|
+
switch (pattern) {
|
|
1181
|
+
case "cold-pressed": {
|
|
1182
|
+
const base = noise(20 * k, 20 * k, 4);
|
|
1183
|
+
const fine = noise(64 * k, 64 * k, 2, 3);
|
|
1184
|
+
for (let y = 0; y < n; y++)
|
|
1185
|
+
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.8 + 0.5 + (fine.at(x, y) - 0.5) * 0.5 + (hash2(x, y, salt) - 0.5) * 0.12);
|
|
1186
|
+
break;
|
|
1187
|
+
}
|
|
1188
|
+
case "hot-pressed": {
|
|
1189
|
+
const base = noise(40 * k, 40 * k, 3);
|
|
1190
|
+
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.1 + 0.6 + (hash2(x, y, salt) - 0.5) * 0.08);
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
case "rough": {
|
|
1194
|
+
const base = noise(10 * k, 10 * k, 5);
|
|
1195
|
+
const blot = noise(28 * k, 28 * k, 2, 5);
|
|
1196
|
+
for (let y = 0; y < n; y++)
|
|
1197
|
+
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 2.4 + 0.5 + (blot.at(x, y) - 0.5) * 0.7 + (hash2(x, y, salt) - 0.5) * 0.15);
|
|
1198
|
+
break;
|
|
1199
|
+
}
|
|
1200
|
+
case "vellum": {
|
|
1201
|
+
const base = noise(40 * k, 40 * k, 3);
|
|
1202
|
+
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.6 + 0.55 + (hash2(x, y, salt) - 0.5) * 0.2);
|
|
1203
|
+
break;
|
|
1204
|
+
}
|
|
1205
|
+
case "laid": {
|
|
1206
|
+
const pulp = noise(32 * k, 32 * k, 3);
|
|
1207
|
+
const chain = n / 8;
|
|
1208
|
+
for (let y = 0; y < n; y++) {
|
|
1209
|
+
const laid = 0.5 + 0.5 * Math.cos(2 * Math.PI * y / 4);
|
|
1210
|
+
for (let x = 0; x < n; x++) {
|
|
1211
|
+
const c = Math.abs((x + 0.5) % chain - chain / 2) / (chain / 2);
|
|
1212
|
+
const chainLine = c > 0.94 ? -0.35 : 0;
|
|
1213
|
+
out[y * n + x] = clamp01(0.3 + 0.5 * laid + chainLine + (pulp.at(x, y) - 0.5) * 0.6);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
case "ingres": {
|
|
1219
|
+
const fibres = noise(64 * k, 12 * k, 3);
|
|
1220
|
+
const base = noise(16 * k, 16 * k, 3, 7);
|
|
1221
|
+
for (let y = 0; y < n; y++)
|
|
1222
|
+
for (let x = 0; x < n; x++) {
|
|
1223
|
+
const g = hash2(x, y, salt ^ 85);
|
|
1224
|
+
out[y * n + x] = clamp01((fibres.at(x, y) - 0.5) * 1.5 + (base.at(x, y) - 0.5) * 0.7 + 0.55 + (g < 0.1 ? -0.3 : 0));
|
|
1225
|
+
}
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
case "sanded": {
|
|
1229
|
+
const grit = noise(96 * k, 96 * k, 2);
|
|
1230
|
+
for (let y = 0; y < n; y++)
|
|
1231
|
+
for (let x = 0; x < n; x++) {
|
|
1232
|
+
const h = hash2(x, y, salt);
|
|
1233
|
+
out[y * n + x] = clamp01((grit.at(x, y) - 0.5) * 2.4 + 0.5 + (h - 0.5) * 0.7);
|
|
1234
|
+
}
|
|
1235
|
+
break;
|
|
1236
|
+
}
|
|
1237
|
+
case "canvas":
|
|
1238
|
+
case "linen": {
|
|
1239
|
+
const period = (pattern === "canvas" ? 8 : 5) * k;
|
|
1240
|
+
const threads = Math.max(2, 2 * Math.round(n / period / 2));
|
|
1241
|
+
const p = n / threads;
|
|
1242
|
+
const slub = noise(threads, threads, 2, 11);
|
|
1243
|
+
for (let y = 0; y < n; y++)
|
|
1244
|
+
for (let x = 0; x < n; x++) {
|
|
1245
|
+
const fx = (x + 0.5) / p;
|
|
1246
|
+
const fy = (y + 0.5) / p;
|
|
1247
|
+
const cx = Math.floor(fx);
|
|
1248
|
+
const cy = Math.floor(fy);
|
|
1249
|
+
const warp = Math.sin(Math.PI * (fx - cx));
|
|
1250
|
+
const weft = Math.sin(Math.PI * (fy - cy));
|
|
1251
|
+
const top = (cx + cy) % 2 === 0 ? warp : weft;
|
|
1252
|
+
const irregular = pattern === "linen" ? (slub.at(x, y) - 0.5) * 0.5 : 0;
|
|
1253
|
+
out[y * n + x] = clamp01(0.2 + 0.7 * top + irregular + (hash2(x, y, salt) - 0.5) * 0.15);
|
|
1254
|
+
}
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
case "gesso": {
|
|
1258
|
+
const streaks = noise(2 * k, 28 * k, 3);
|
|
1259
|
+
const tooth = noise(64 * k, 64 * k, 2, 13);
|
|
1260
|
+
for (let y = 0; y < n; y++)
|
|
1261
|
+
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((streaks.at(x, y) - 0.5) * 1.8 + (tooth.at(x, y) - 0.5) * 0.9 + 0.55);
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
return out;
|
|
1266
|
+
}
|
|
1267
|
+
var rawCache = /* @__PURE__ */ new Map();
|
|
1268
|
+
function grainHeights(pattern, seed, size = GRAIN_TILE) {
|
|
1269
|
+
const key = `${pattern}:${seed}:${size}`;
|
|
1270
|
+
let h = rawCache.get(key);
|
|
1271
|
+
if (!h) {
|
|
1272
|
+
h = patternHeights(pattern, size, seed);
|
|
1273
|
+
if (rawCache.size > 32) rawCache.delete(rawCache.keys().next().value);
|
|
1274
|
+
rawCache.set(key, h);
|
|
1275
|
+
}
|
|
1276
|
+
return h;
|
|
1277
|
+
}
|
|
1278
|
+
var PaperGrain = class {
|
|
1279
|
+
size = GRAIN_TILE;
|
|
1280
|
+
heights;
|
|
1281
|
+
scale;
|
|
1282
|
+
mirror;
|
|
1283
|
+
flat;
|
|
1284
|
+
constructor(paper, media = "dry") {
|
|
1285
|
+
const raw = grainHeights(paper.pattern, paper.seed);
|
|
1286
|
+
const t = paper[media];
|
|
1287
|
+
this.flat = paper.pattern === "smooth";
|
|
1288
|
+
if (t.contrast === 1 && !t.invert) this.heights = raw;
|
|
1289
|
+
else {
|
|
1290
|
+
const out = new Float32Array(raw.length);
|
|
1291
|
+
for (let i = 0; i < raw.length; i++) {
|
|
1292
|
+
const v = clamp01((raw[i] - 0.5) * t.contrast + 0.5);
|
|
1293
|
+
out[i] = t.invert ? 1 - v : v;
|
|
1294
|
+
}
|
|
1295
|
+
this.heights = out;
|
|
1296
|
+
}
|
|
1297
|
+
this.scale = paper.scale;
|
|
1298
|
+
this.mirror = paper.tiling === "mirror";
|
|
1299
|
+
}
|
|
1300
|
+
/** Tile cell index for a coordinate in grain pixels (mirrored on odd tiles when mirroring). */
|
|
1301
|
+
wrap(v) {
|
|
1302
|
+
const n = this.size;
|
|
1303
|
+
if (!this.mirror) return (v % n + n) % n;
|
|
1304
|
+
const p = (v % (2 * n) + 2 * n) % (2 * n);
|
|
1305
|
+
return p < n ? p : 2 * n - 1 - p;
|
|
1306
|
+
}
|
|
1307
|
+
/** Height 0..1 at document position (x, y). */
|
|
1308
|
+
at(x, y) {
|
|
1309
|
+
const u = x / this.scale - 0.5;
|
|
1310
|
+
const v = y / this.scale - 0.5;
|
|
1311
|
+
const x0 = Math.floor(u);
|
|
1312
|
+
const y0 = Math.floor(v);
|
|
1313
|
+
const fx = u - x0;
|
|
1314
|
+
const fy = v - y0;
|
|
1315
|
+
const n = this.size;
|
|
1316
|
+
const h = this.heights;
|
|
1317
|
+
const a = this.wrap(x0);
|
|
1318
|
+
const b = this.wrap(x0 + 1);
|
|
1319
|
+
const c = this.wrap(y0) * n;
|
|
1320
|
+
const d = this.wrap(y0 + 1) * n;
|
|
1321
|
+
const top = h[c + a] + (h[c + b] - h[c + a]) * fx;
|
|
1322
|
+
const bot = h[d + a] + (h[d + b] - h[d + a]) * fx;
|
|
1323
|
+
return top + (bot - top) * fy;
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
function grainCatch(h, depth, pressure) {
|
|
1327
|
+
if (depth <= 0) return 1;
|
|
1328
|
+
const t = depth * (0.75 - 0.65 * Math.min(1, Math.max(0, pressure)));
|
|
1329
|
+
const u = clamp01((h - t + 0.18) / 0.36);
|
|
1330
|
+
return 1 - depth + depth * u * u * (3 - 2 * u);
|
|
1331
|
+
}
|
|
1332
|
+
function strokeGrainCatch(h, depth, pressure) {
|
|
1333
|
+
if (depth <= 0) return 1;
|
|
1334
|
+
const p = Math.min(1, Math.max(0, pressure));
|
|
1335
|
+
const amount = Math.min(1, depth * (1.4 - 0.6 * p));
|
|
1336
|
+
const u = clamp01((h - 0.2 - 0.25 * (1 - p)) / 0.5);
|
|
1337
|
+
return 1 - amount + amount * u * u * (3 - 2 * u);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1103
1340
|
// src/paint/path-stroke.ts
|
|
1341
|
+
var JITTER_SIZE = 1;
|
|
1342
|
+
var JITTER_ANGLE = 2;
|
|
1343
|
+
var JITTER_OPACITY = 3;
|
|
1344
|
+
var JITTER_SCATTER = 4;
|
|
1104
1345
|
function lean(s) {
|
|
1105
1346
|
if (typeof s.altitude === "number" && Number.isFinite(s.altitude)) {
|
|
1106
1347
|
return { amount: 1 - Math.min(1, Math.max(0, s.altitude / (Math.PI / 2))), azimuth: s.azimuth ?? 0 };
|
|
@@ -1132,8 +1373,22 @@ function pathStrokeDabs(samples, options) {
|
|
|
1132
1373
|
if (tilt.followAzimuth && l) angle = -l.azimuth;
|
|
1133
1374
|
const roundness = Math.max(0.05, brush.roundness * (1 - 0.85 * (tilt.roundness ?? 0) * lean0));
|
|
1134
1375
|
const op = brush.pressureOpacity ? pr : 1;
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1376
|
+
const i = index++;
|
|
1377
|
+
const params = { travel, index: i, pressure: pr, lean: lean0, speed, direction: dir, time: time === null || t0 === null ? null : time - t0 };
|
|
1378
|
+
let diameter = size;
|
|
1379
|
+
let opacity = brush.opacity * op;
|
|
1380
|
+
const j = options.jitter;
|
|
1381
|
+
if (j) {
|
|
1382
|
+
if (j.size) diameter *= Math.max(0.05, 1 + j.size * randSigned(j.seed, i, JITTER_SIZE));
|
|
1383
|
+
if (j.angle) angle += j.angle * Math.PI * randSigned(j.seed, i, JITTER_ANGLE);
|
|
1384
|
+
if (j.opacity) opacity *= 1 - j.opacity * (randSigned(j.seed, i, JITTER_OPACITY) * 0.5 + 0.5);
|
|
1385
|
+
if (j.scatter) {
|
|
1386
|
+
const off = j.scatter * diameter * randSigned(j.seed, i, JITTER_SCATTER);
|
|
1387
|
+
x += Math.sin(dir) * off;
|
|
1388
|
+
y += Math.cos(dir) * off;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
return { x, y, radius: Math.max(0.5, diameter / 2), alpha: brush.flow, opacity, angle, roundness, params };
|
|
1137
1392
|
};
|
|
1138
1393
|
const out = [];
|
|
1139
1394
|
const pressure = (s) => typeof s.pressure === "number" && Number.isFinite(s.pressure) ? s.pressure : 1;
|
|
@@ -1202,6 +1457,17 @@ function pathStrokeCoverage(samples, options) {
|
|
|
1202
1457
|
bounds = { x, y, width: Math.max(bounds.x + bounds.width, rect.x + rect.width) - x, height: Math.max(bounds.y + bounds.height, rect.y + rect.height) - y };
|
|
1203
1458
|
}
|
|
1204
1459
|
}
|
|
1460
|
+
const grain = options.grain;
|
|
1461
|
+
if (grain && grain.depth > 0 && dabs.length) {
|
|
1462
|
+
const pressure = dabs.reduce((sum, d) => sum + (d.params?.pressure ?? 1), 0) / dabs.length;
|
|
1463
|
+
for (const [key, t] of coverage.tiles) {
|
|
1464
|
+
const { tx, ty } = tileCoord(key);
|
|
1465
|
+
for (let y = 0, k = 0; y < TILE; y++) {
|
|
1466
|
+
const gy = ty * TILE + y + 0.5;
|
|
1467
|
+
for (let x = 0; x < TILE; x++, k++) if (t[k] > 0) t[k] *= strokeGrainCatch(grain.at(tx * TILE + x + 0.5, gy), grain.depth, pressure);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1205
1471
|
return { coverage, bounds, dabs: dabs.length };
|
|
1206
1472
|
}
|
|
1207
1473
|
function paintPathStroke(surface, samples, options) {
|
|
@@ -1296,6 +1562,26 @@ function isBrushstrokeBrush(brush) {
|
|
|
1296
1562
|
return !("tip" in brush) || !brush.tip || (brush.engine ?? "dab") === "dab";
|
|
1297
1563
|
}
|
|
1298
1564
|
var finite2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
1565
|
+
function brushCharacterOf(brush) {
|
|
1566
|
+
if (!("tip" in brush) || !brush.tip) return { grain: 0, size: 0, angle: 0, opacity: 0, scatter: 0 };
|
|
1567
|
+
const d = brush.dynamics ?? {};
|
|
1568
|
+
const u = (v, hi = 1) => finite2(v) ? Math.min(hi, Math.max(0, v)) : 0;
|
|
1569
|
+
return { grain: u(brush.grain), size: u(d.sizeJitter), angle: u(d.angleJitter), opacity: u(d.opacityJitter), scatter: u(d.scatter, 4) };
|
|
1570
|
+
}
|
|
1571
|
+
var papers = /* @__PURE__ */ new Map();
|
|
1572
|
+
function paperGrain(paper) {
|
|
1573
|
+
const pattern = paper.pattern ?? "sanded";
|
|
1574
|
+
const seed = finite2(paper.seed) ? Math.round(Math.abs(paper.seed)) : 1;
|
|
1575
|
+
const scale = finite2(paper.scale) && paper.scale > 0 ? Math.min(8, Math.max(0.25, paper.scale)) : 1;
|
|
1576
|
+
const key = `${pattern}:${seed}:${scale}`;
|
|
1577
|
+
let g = papers.get(key);
|
|
1578
|
+
if (!g) {
|
|
1579
|
+
g = new PaperGrain({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
|
|
1580
|
+
if (papers.size > 16) papers.delete(papers.keys().next().value);
|
|
1581
|
+
papers.set(key, g);
|
|
1582
|
+
}
|
|
1583
|
+
return g;
|
|
1584
|
+
}
|
|
1299
1585
|
function renderBrushstroke(input, brush, options = {}) {
|
|
1300
1586
|
const strokeOptions = brushstrokeStrokeOptions(brush);
|
|
1301
1587
|
const samples = brushstrokeSamples(input);
|
|
@@ -1318,8 +1604,27 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
1318
1604
|
const area = (x1 - x0 + reach) * (y1 - y0 + reach);
|
|
1319
1605
|
if (area * scale * scale > maxPixels) scale = Math.max(BRUSHSTROKE_MIN_SCALE, Math.sqrt(maxPixels / area));
|
|
1320
1606
|
const scaled = samples.map((s) => ({ ...s, x: s.x * scale, y: s.y * scale }));
|
|
1607
|
+
let character = {};
|
|
1608
|
+
if (options.character) {
|
|
1609
|
+
const c = brushCharacterOf(brush);
|
|
1610
|
+
const ch = options.character;
|
|
1611
|
+
const seed = finite2(ch.seed) ? ch.seed | 0 : hashString(JSON.stringify(input));
|
|
1612
|
+
const jitter = c.size || c.angle || c.opacity || c.scatter ? { seed, size: c.size, angle: c.angle, opacity: c.opacity, scatter: c.scatter } : void 0;
|
|
1613
|
+
const paper = ch.paper === null ? null : ch.paper ?? {};
|
|
1614
|
+
const depth = paper ? Math.min(1, Math.max(0, (finite2(paper.depth) ? paper.depth : 0.5) * c.grain)) : 0;
|
|
1615
|
+
let grain;
|
|
1616
|
+
if (paper && depth > 0) {
|
|
1617
|
+
const g = paperGrain(paper);
|
|
1618
|
+
const ox = ch.origin?.x ?? 0;
|
|
1619
|
+
const oy = ch.origin?.y ?? 0;
|
|
1620
|
+
const k = (finite2(ch.unit) && ch.unit > 0 ? ch.unit : 1) / scale;
|
|
1621
|
+
grain = { depth, at: (x, y) => g.at(ox + x * k, oy + y * k) };
|
|
1622
|
+
}
|
|
1623
|
+
character = { ...jitter ? { jitter } : {}, ...grain ? { grain } : {} };
|
|
1624
|
+
}
|
|
1321
1625
|
const { surface, bounds, dabs } = paintPathStroke(emptySurface(4), scaled, {
|
|
1322
1626
|
...strokeOptions,
|
|
1627
|
+
...character,
|
|
1323
1628
|
brush: { ...tip, size: tip.size * scale },
|
|
1324
1629
|
closed: options.closed ?? strokeOptions.closed,
|
|
1325
1630
|
color,
|
|
@@ -1361,7 +1666,8 @@ function hashString(s, h = 2166136261) {
|
|
|
1361
1666
|
function brushstrokeKey(input, brush, options = {}) {
|
|
1362
1667
|
const path = JSON.stringify(input);
|
|
1363
1668
|
const { brush: tip, ...rest } = brushstrokeStrokeOptions(brush);
|
|
1364
|
-
const
|
|
1669
|
+
const character = options.character ? [options.character, brushCharacterOf(brush)] : null;
|
|
1670
|
+
const rest2 = JSON.stringify([tip, rest, options.paint ?? options.color ?? null, options.seed ?? 0, options.closed ?? false, options.maxPixels ?? null, ...character ? [character] : []]);
|
|
1365
1671
|
const scale = finite2(options.scale) ? options.scale : 1;
|
|
1366
1672
|
return `${hashString(path).toString(16)}:${path.length}:${hashString(rest2).toString(16)}:${scale}`;
|
|
1367
1673
|
}
|
|
@@ -2012,6 +2318,9 @@ export {
|
|
|
2012
2318
|
mix32,
|
|
2013
2319
|
hash2,
|
|
2014
2320
|
rand01,
|
|
2321
|
+
randSigned,
|
|
2322
|
+
seedFromString,
|
|
2323
|
+
TileableNoise,
|
|
2015
2324
|
PAINT_GRADIENT_SPACES,
|
|
2016
2325
|
PAINT_GRADIENT_REPEATS,
|
|
2017
2326
|
PAINT_GRADIENT_MAPPINGS,
|
|
@@ -2062,6 +2371,12 @@ export {
|
|
|
2062
2371
|
applyStrokeToTile,
|
|
2063
2372
|
applyStrokeToDeepTile,
|
|
2064
2373
|
coverageTileCoord,
|
|
2374
|
+
GRAIN_PATTERNS,
|
|
2375
|
+
GRAIN_TILE,
|
|
2376
|
+
grainHeights,
|
|
2377
|
+
PaperGrain,
|
|
2378
|
+
grainCatch,
|
|
2379
|
+
strokeGrainCatch,
|
|
2065
2380
|
pathStrokeDabs,
|
|
2066
2381
|
pathStrokeCoverage,
|
|
2067
2382
|
paintPathStroke,
|
|
@@ -2096,4 +2411,4 @@ export {
|
|
|
2096
2411
|
cleanMixer,
|
|
2097
2412
|
MixerStroke
|
|
2098
2413
|
};
|
|
2099
|
-
//# sourceMappingURL=chunk-
|
|
2414
|
+
//# sourceMappingURL=chunk-PQFVLOMR.js.map
|