@popcraft/kit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +74 -0
  4. package/dist/index.js +160558 -0
  5. package/package.json +40 -0
  6. package/types/design-script.d.ts +39 -0
  7. package/types/lib/agent/design-script/build.d.ts +35 -0
  8. package/types/lib/agent/design-script/check.d.ts +11 -0
  9. package/types/lib/agent/design-script/helper-names.d.ts +1 -0
  10. package/types/lib/agent/design-script/kit-modules.d.ts +43 -0
  11. package/types/lib/agent/design-script/recorder.d.ts +52 -0
  12. package/types/lib/agent/design-script/replay.d.ts +13 -0
  13. package/types/lib/agent/design-script/run-node.d.ts +2 -0
  14. package/types/lib/ai/audio-models.d.ts +66 -0
  15. package/types/lib/ai/content.d.ts +27 -0
  16. package/types/lib/ai/limits.d.ts +42 -0
  17. package/types/lib/audio/presentation/loudness.d.ts +80 -0
  18. package/types/lib/audio/presentation/types.d.ts +112 -0
  19. package/types/lib/brand/apply.d.ts +25 -0
  20. package/types/lib/brand/review-kits.d.ts +10 -0
  21. package/types/lib/brand/types.d.ts +20 -0
  22. package/types/lib/code/hash.d.ts +2 -0
  23. package/types/lib/document/auto-layout.d.ts +10 -0
  24. package/types/lib/document/breakpoints.d.ts +45 -0
  25. package/types/lib/document/clone.d.ts +6 -0
  26. package/types/lib/document/color.d.ts +52 -0
  27. package/types/lib/document/detach.d.ts +12 -0
  28. package/types/lib/document/effects.d.ts +60 -0
  29. package/types/lib/document/expressions.d.ts +78 -0
  30. package/types/lib/document/instance-layout.d.ts +94 -0
  31. package/types/lib/document/instances.d.ts +63 -0
  32. package/types/lib/document/libraries.d.ts +97 -0
  33. package/types/lib/document/node-delta.d.ts +21 -0
  34. package/types/lib/document/page-tokens.d.ts +16 -0
  35. package/types/lib/document/photo-frames.d.ts +14 -0
  36. package/types/lib/document/print-pages.d.ts +85 -0
  37. package/types/lib/document/scene-graph.d.ts +194 -0
  38. package/types/lib/document/scene3d.d.ts +76 -0
  39. package/types/lib/document/shader-graph-effects.d.ts +8 -0
  40. package/types/lib/document/shader-graph.d.ts +134 -0
  41. package/types/lib/document/shader-params.d.ts +65 -0
  42. package/types/lib/document/shape-to-path.d.ts +20 -0
  43. package/types/lib/document/text-styles.d.ts +28 -0
  44. package/types/lib/document/text-tokens.d.ts +6 -0
  45. package/types/lib/document/transform.d.ts +79 -0
  46. package/types/lib/document/transform3d.d.ts +99 -0
  47. package/types/lib/document/trim.d.ts +35 -0
  48. package/types/lib/document/types.d.ts +2560 -0
  49. package/types/lib/document/variables.d.ts +14 -0
  50. package/types/lib/editor/easing.d.ts +46 -0
  51. package/types/lib/editor/modes/types.d.ts +131 -0
  52. package/types/lib/editor/prototype-connect.d.ts +49 -0
  53. package/types/lib/editor/smart-animate.d.ts +37 -0
  54. package/types/lib/engine/geometry/flatten.d.ts +2 -0
  55. package/types/lib/engine/geometry/shape-outline.d.ts +24 -0
  56. package/types/lib/engine/pixel/cells.d.ts +12 -0
  57. package/types/lib/engine/pixel/palettes.d.ts +25 -0
  58. package/types/lib/engine/readiness.d.ts +20 -0
  59. package/types/lib/engine/routing.d.ts +41 -0
  60. package/types/lib/engine/shader-graph-presets.d.ts +22 -0
  61. package/types/lib/engine/shader-presets-legacy.d.ts +7 -0
  62. package/types/lib/engine/shader-presets.d.ts +43 -0
  63. package/types/lib/engine/text/atlas.d.ts +120 -0
  64. package/types/lib/engine/text/emoji/segment.d.ts +15 -0
  65. package/types/lib/engine/text/fallback-fonts.d.ts +47 -0
  66. package/types/lib/engine/text/fontkit-lazy.d.ts +8 -0
  67. package/types/lib/engine/text/fonts.d.ts +33 -0
  68. package/types/lib/engine/text/glyph-linear.d.ts +22 -0
  69. package/types/lib/engine/text/google-fonts.d.ts +17 -0
  70. package/types/lib/engine/text/hyphenate/en-us.d.ts +6 -0
  71. package/types/lib/engine/text/hyphenate/liang.d.ts +21 -0
  72. package/types/lib/engine/text/layout-access.d.ts +16 -0
  73. package/types/lib/engine/text/layout.d.ts +168 -0
  74. package/types/lib/engine/text/lists.d.ts +16 -0
  75. package/types/lib/engine/text/measure.d.ts +58 -0
  76. package/types/lib/engine/text/outline-sdf.d.ts +34 -0
  77. package/types/lib/engine/text/shaper.d.ts +88 -0
  78. package/types/lib/engine/text/text-area.d.ts +16 -0
  79. package/types/lib/engine/text/text-fit.d.ts +51 -0
  80. package/types/lib/engine/text/text-path.d.ts +134 -0
  81. package/types/lib/engine/text/text-rings.d.ts +17 -0
  82. package/types/lib/engine/text/wrap-obstacles.d.ts +20 -0
  83. package/types/lib/i18n/catalogs.d.ts +10 -0
  84. package/types/lib/i18n/format.d.ts +27 -0
  85. package/types/lib/i18n/locales.d.ts +25 -0
  86. package/types/lib/i18n/pseudo.d.ts +10 -0
  87. package/types/lib/i18n/runtime.d.ts +27 -0
  88. package/types/lib/io/codecs/wav.d.ts +7 -0
  89. package/types/lib/io/codecs/webp.d.ts +7 -0
  90. package/types/lib/io/export-ir/children.d.ts +2 -0
  91. package/types/lib/io/json-export.d.ts +11 -0
  92. package/types/lib/media-library/types.d.ts +39 -0
  93. package/types/lib/motion/audio-analysis.d.ts +44 -0
  94. package/types/lib/motion/audio-clips.d.ts +92 -0
  95. package/types/lib/motion/audio-onsets.d.ts +13 -0
  96. package/types/lib/motion/audio-signals.d.ts +59 -0
  97. package/types/lib/motion/author.d.ts +80 -0
  98. package/types/lib/motion/composition.d.ts +99 -0
  99. package/types/lib/motion/instances.d.ts +95 -0
  100. package/types/lib/motion/key-selection.d.ts +100 -0
  101. package/types/lib/motion/keys.d.ts +41 -0
  102. package/types/lib/motion/layer-time-edit.d.ts +40 -0
  103. package/types/lib/motion/markers.d.ts +31 -0
  104. package/types/lib/motion/modifier-edit.d.ts +84 -0
  105. package/types/lib/motion/modifiers.d.ts +44 -0
  106. package/types/lib/motion/morph.d.ts +14 -0
  107. package/types/lib/motion/pose-layout.d.ts +6 -0
  108. package/types/lib/motion/pose.d.ts +115 -0
  109. package/types/lib/motion/presets.d.ts +148 -0
  110. package/types/lib/motion/properties.d.ts +74 -0
  111. package/types/lib/motion/sample-keys.d.ts +8 -0
  112. package/types/lib/motion/sample.d.ts +51 -0
  113. package/types/lib/motion/sound.d.ts +25 -0
  114. package/types/lib/motion/spatial-curve.d.ts +15 -0
  115. package/types/lib/motion/spatial.d.ts +38 -0
  116. package/types/lib/motion/text-animators.d.ts +79 -0
  117. package/types/lib/motion/text-units.d.ts +47 -0
  118. package/types/lib/motion/time.d.ts +58 -0
  119. package/types/lib/motion/transitions.d.ts +99 -0
  120. package/types/lib/motion/values.d.ts +12 -0
  121. package/types/lib/motion/video-clip.d.ts +63 -0
  122. package/types/lib/presets/page-presets.d.ts +50 -0
  123. package/types/lib/storage/media-hash.d.ts +4 -0
  124. package/types/lib/storage/media-refs.d.ts +2 -0
  125. package/types/lib/storage/media-store.d.ts +70 -0
  126. package/types/lib/templates/apply.d.ts +38 -0
  127. package/types/lib/templates/capture.d.ts +25 -0
  128. package/types/lib/templates/groups.d.ts +82 -0
  129. package/types/lib/templates/layout.d.ts +20 -0
  130. package/types/lib/templates/quality.d.ts +59 -0
  131. package/types/lib/templates/resize.d.ts +34 -0
  132. package/types/lib/templates/safe-areas.d.ts +42 -0
  133. package/types/lib/templates/text-measurer.d.ts +10 -0
  134. package/types/lib/templates/thumbnail.d.ts +134 -0
  135. package/types/lib/templates/types.d.ts +95 -0
  136. package/types/lib/templates/vocabulary.d.ts +50 -0
  137. package/types/lib/units/units.d.ts +23 -0
  138. package/types/packages/kit/src/index.d.ts +59 -0
  139. package/types/packages/runtime/src/expressions.d.ts +41 -0
  140. package/types/templates/src/app/shared.d.ts +29 -0
  141. package/types/templates/src/audio/beat-loop.d.ts +9 -0
  142. package/types/templates/src/audio/media.d.ts +42 -0
  143. package/types/templates/src/audio/music-synth.d.ts +57 -0
  144. package/types/templates/src/audio/music-worlds.d.ts +8 -0
  145. package/types/templates/src/audio/music.d.ts +19 -0
  146. package/types/templates/src/audio/studio/deck.d.ts +340 -0
  147. package/types/templates/src/audio/studio/dsp.d.ts +151 -0
  148. package/types/templates/src/audio/studio/fx.d.ts +96 -0
  149. package/types/templates/src/audio/studio/mix.d.ts +84 -0
  150. package/types/templates/src/audio/studio/voices.d.ts +120 -0
  151. package/types/templates/src/data/geometry.d.ts +16 -0
  152. package/types/templates/src/effects/shared.d.ts +17 -0
  153. package/types/templates/src/kit.d.ts +582 -0
  154. package/types/templates/src/motion3d/devices.d.ts +42 -0
  155. package/types/templates/src/motion3d/ui.d.ts +48 -0
  156. package/types/templates/src/saas/video-shared.d.ts +114 -0
  157. package/types/templates/src/saas/web-shared.d.ts +74 -0
  158. package/types/templates/src/shared/beat.d.ts +24 -0
  159. package/types/templates/src/shared/captions.d.ts +24 -0
  160. package/types/templates/src/shared/devices.d.ts +188 -0
  161. package/types/templates/src/shared/draw.d.ts +43 -0
  162. package/types/templates/src/shared/fit.d.ts +73 -0
  163. package/types/templates/src/shared/marks.d.ts +51 -0
  164. package/types/templates/src/shared/motion.d.ts +15 -0
  165. package/types/templates/src/shared/overlays.d.ts +80 -0
  166. package/types/templates/src/shared/pointer.d.ts +46 -0
  167. package/types/templates/src/shared/texture.d.ts +41 -0
  168. package/types/templates/src/shared/type.d.ts +6 -0
  169. package/types/templates/src/shared/window.d.ts +50 -0
  170. package/types/templates/src/social/shared.d.ts +66 -0
  171. package/types/templates/src/web/shared.d.ts +64 -0
@@ -0,0 +1,14 @@
1
+ import { AnyNode, Variable, VariableCollection } from './types.js';
2
+ import { type ExprData, type ExprValue } from './expressions.js';
3
+ export declare function resolveNodeVariables(node: AnyNode, variables?: Record<string, Variable>, collections?: Record<string, VariableCollection>, activeModes?: Record<string, string>,
4
+ /** The file's records, where the place drawing has them (lib/document/collections.ts `exprData`). */
5
+ data?: ExprData): AnyNode;
6
+ /** What an expression's value sets `prop` to: text for a text's words, true / false for visibility, numbers clamped to what the property allows. */
7
+ export declare function boundPropValue(prop: string, val: ExprValue): unknown;
8
+ /**
9
+ * `node` with the item at `path` (`fills[@f1].color`, `strokes[@s1].color`, `effects[@e1].color`) no longer bound to
10
+ * a colour variable: the same node when it was not. Whatever sets that colour itself — an instance's colour input,
11
+ * a keyed colour track in a pose — takes over from the binding with it, or the variable pass (which runs after,
12
+ * on the canvas and in every export) would paint the variable's colour back over it.
13
+ */
14
+ export declare function unbindItemColor(node: AnyNode, path: string): AnyNode;
@@ -0,0 +1,46 @@
1
+ import type { EaseName, EasingType, Interp, PrototypeTransition } from '../document/types.js';
2
+ export type SpringParams = NonNullable<PrototypeTransition['spring']>;
3
+ export declare const SPRING_PRESETS: Record<string, SpringParams>;
4
+ /** Position of a unit spring at `seconds` (starts at 0, rests at 1). */
5
+ export declare function springAt(seconds: number, spring: SpringParams): number;
6
+ /**
7
+ * The curve parameter `s` at which a CSS cubic-bezier's x (control x's `x1`, `x2`) reaches `x` in [0, 1]. Newton steps
8
+ * with a bisection fallback, as browsers do, so a curve here and the same curve in exported CSS agree.
9
+ */
10
+ export declare function bezierParamAt(x: number, x1: number, x2: number): number;
11
+ /** One coordinate of a unit cubic bezier (0 → `c1` → `c2` → 1) at parameter `s`. */
12
+ export declare const bezierCoord: (s: number, c1: number, c2: number) => number;
13
+ /** Its derivative d/ds. */
14
+ export declare const bezierSlope: (s: number, c1: number, c2: number) => number;
15
+ /** CSS `cubic-bezier(x1, y1, x2, y2)`: eased progress for `t` in [0, 1]. */
16
+ export declare function cubicBezier(t: number, x1: number, y1: number, x2: number, y2: number): number;
17
+ /** Back's default overshoot (Penner's 1.70158: a 10% overshoot). */
18
+ export declare const BACK_OVERSHOOT = 1.70158;
19
+ /** Elastic's default period (fraction of the segment). */
20
+ export declare const ELASTIC_PERIOD = 0.3;
21
+ type Ease = (k: number, param?: number) => number;
22
+ /** Penner's easing functions: progress k in [0, 1] → eased progress (back and elastic may leave [0, 1]). */
23
+ export declare const EASINGS: Record<EaseName, Ease>;
24
+ /**
25
+ * Eased progress along a segment: `p` is raw progress in [0, 1] (clamped), `spanMs` the segment's length (springs
26
+ * run in real time over it). Hold stays at 0 until the segment ends.
27
+ */
28
+ export declare function evalInterp(interp: Interp, p: number, spanMs: number): number;
29
+ /** The curve a stored prototype `EasingType` names (SPRING uses `spring`, else the quick preset). */
30
+ export declare function interpOfEasing(easing: EasingType, spring?: SpringParams): Interp;
31
+ /** Eased progress for raw progress `t` in [0, 1] (prototype transitions, builds); springs are evaluated over `durationMs`. */
32
+ export declare function ease(t: number, easing: EasingType, durationMs?: number, spring?: SpringParams): number;
33
+ /** The curve a new key leaves with (Figma's and After Effects' default: ease in and out). */
34
+ export declare const DEFAULT_KEY_INTERP: Interp;
35
+ /**
36
+ * The curves the timeline offers for a key: hold, linear, every Penner curve and the spring presets, all derived
37
+ * from the tables above. `id` is stable (stored nowhere; the key stores the `interp`).
38
+ */
39
+ export declare const MOTION_EASE_PRESETS: {
40
+ id: string;
41
+ label: string;
42
+ interp: Interp;
43
+ }[];
44
+ /** The preset an interp is (by value), or 'custom' for a bezier or a parameterised curve no preset matches. */
45
+ export declare function easePresetId(interp: Interp): string;
46
+ export {};
@@ -0,0 +1,131 @@
1
+ import type { NodeType } from '../../document/types.js';
2
+ /** A lens over the whole document. Exactly one is active. */
3
+ export type ModeId = 'DESIGN' | 'DRAW' | 'ANIMATE' | 'PROTOTYPE' | 'DEV' | 'POPCORN';
4
+ /** Editing inside one object. These stack: entering vector edit from inside pixel edit pushes a frame. */
5
+ export type FocusId = 'TEXT_EDIT' | 'VECTOR_EDIT' | 'SHAPE_BUILDER' | 'PIXEL_EDIT' | 'IMAGE_EDIT' | 'CROP';
6
+ /** Normal editing is suspended entirely. */
7
+ export type SessionId = 'PRESENT' | 'VERSION_HISTORY';
8
+ /**
9
+ * Chrome that is drawn or not drawn, independently of the mode. `prototypeLinks` is what the dead
10
+ * WIREFRAME mode was reaching for: the display of prototype connections, on by default.
11
+ */
12
+ export type ViewFlag = 'rulers' | 'grid' | 'prototypeLinks' | 'outlines' | 'pixelPreview' | 'minimap' | 'webPreview';
13
+ /** Which toolset is in the toolbar. One per mode, one per focus that has tools of its own. */
14
+ export type ToolsetId = 'DESIGN' | 'DRAW' | 'ANIMATE' | 'PROTOTYPE' | 'POPCORN' | 'PIXEL_EDIT' | 'IMAGE_EDIT' | 'VECTOR_EDIT' | 'SHAPE_BUILDER' | 'CROP'
15
+ /** Dev mode and the sessions: select and pan, nothing that writes. */
16
+ | 'READ_ONLY';
17
+ /**
18
+ * Every side-panel tab. Each lives on one side, by default the side named in PANEL_TAB_DEFAULT_SIDE, and people
19
+ * can drag a tab to the other side (lib/editor/panel-tabs.ts). A mode owns a tab it opens; clicking a tab
20
+ * never sets the mode.
21
+ */
22
+ export type BuiltinPanelTab = 'composition' | 'assets' | 'shapes' | 'agent' | 'brushes' | 'design' | 'prototype' | 'inspect' | 'comments' | 'preflight';
23
+ /** A plugin's sidebar panel (`contributes.panels` in its manifest): `plugin:<plugin id>:<panel id>`. */
24
+ export type PluginPanelTab = `plugin:${string}`;
25
+ export type PanelTab = BuiltinPanelTab | PluginPanelTab;
26
+ /** A tab shown in the left or right panel — any tab, since tabs can move between sides. */
27
+ export type LeftTab = PanelTab;
28
+ export type RightTab = PanelTab;
29
+ /**
30
+ * A bespoke chrome component, resolved through components/editor/shell/chrome-map.tsx. Modes and focus
31
+ * contexts whose bar is just their toolset leave it unset and get the generic <ModeToolbar />.
32
+ */
33
+ export type ChromeId = 'popcorn-toolbar' | 'pixel-toolbar' | 'shape-builder-toolbar' | 'draw-options' | 'image-edit-toolbar' | 'crop-toolbar' | 'draw-palette' | 'animate-timeline' | 'present-controls' | 'version-history';
34
+ export interface ToolDef {
35
+ label: string;
36
+ /** lucide-react export name, as NativeExtensionConfig.iconName does it. */
37
+ icon: string;
38
+ /** Canonical binding, e.g. 'V', 'Shift+P'. The keymap is built from these — it is not a second list. */
39
+ shortcut?: string;
40
+ /** The node type a drag creates, when the tool creates one. Replaces CORE_DRAWING_TOOLS. */
41
+ creates?: NodeType;
42
+ /** Extra palette search terms. */
43
+ keywords?: string[];
44
+ }
45
+ /** A divider-separated run of tools in the toolbar; multi-tool groups render as a flyout. */
46
+ export interface ToolGroup {
47
+ id: string;
48
+ tools: string[];
49
+ }
50
+ /**
51
+ * A toolset: which tools are in the bar, grouped, plus the definitions they resolve against.
52
+ *
53
+ * Document toolsets (Design, Draw, PopCorn…) all resolve against the one `TOOLS` table, because they
54
+ * share `activeTool` — that is what makes the six old tool lists collapse into one. A focus context
55
+ * may bring its own id space instead (pixel edit's tools are not document tools and never were); it
56
+ * supplies its own `defs` and stores its selection on its focus frame. Either way the shape is the
57
+ * same, so one <ModeToolbar /> renders both.
58
+ */
59
+ export interface Toolset {
60
+ id: ToolsetId;
61
+ /** 'document' tools set `activeTool`; 'focus' tools set `tool` on the active focus frame. */
62
+ space: 'document' | 'focus';
63
+ defs: Record<string, ToolDef>;
64
+ groups: ToolGroup[];
65
+ }
66
+ export interface ModeProfile {
67
+ id: ModeId;
68
+ label: string;
69
+ icon: string;
70
+ /** Its toolset. Switching mode retires the previous mode's tool rather than carrying it over. */
71
+ toolset: ToolsetId;
72
+ /** The right-panel tab this mode owns. The mode drives the tab; the tab does not drive the mode. */
73
+ rightTab: RightTab;
74
+ /** The left-panel tab it prefers on entry, when it has an opinion (Draw wants the brush library). */
75
+ leftTab?: LeftTab;
76
+ /**
77
+ * The tool the mode opens with. A mode should arrive ready to do its own job — Draw with a brush in
78
+ * hand, not a pointer — and switching modes must not carry the previous mode's tool across, since the
79
+ * new toolset may not even contain it. Defaults to SELECT.
80
+ */
81
+ defaultTool?: string;
82
+ /** False means the canvas refuses edits — Dev is a lens, not an editor. */
83
+ editable: boolean;
84
+ /** A bar of its own, when its toolset alone does not describe it (PopCorn's flyouts). */
85
+ chrome?: ChromeId;
86
+ /** An extra docked row above the toolbar (Draw's brush settings, Animate's timeline). */
87
+ options?: ChromeId;
88
+ shortcut?: string;
89
+ keywords?: string[];
90
+ }
91
+ export interface FocusProfile {
92
+ id: FocusId;
93
+ label: string;
94
+ /**
95
+ * The store field its payload lives on. A context is active exactly when that field is set — which is
96
+ * why there is no stack to keep in step with the fields, and no invariant to police.
97
+ */
98
+ payload: string;
99
+ /** Who wins when two are somehow set at once. Higher is nearer the front. */
100
+ precedence: number;
101
+ /** What you can enter it on. Empty means it is entered from a command, not from a node. */
102
+ nodeTypes: NodeType[];
103
+ toolset: ToolsetId;
104
+ /** Its bar. Focus bars carry their own options row and a Done button, as pixel edit already does. */
105
+ chrome?: ChromeId;
106
+ /** An extra docked row (the pixel timeline). */
107
+ options?: ChromeId;
108
+ /** The right-panel tab it forces while active, when it wants one. */
109
+ rightTab?: RightTab;
110
+ }
111
+ /** What the chrome should render right now — the single answer `resolveChrome` produces. */
112
+ export interface ResolvedChrome {
113
+ mode: ModeId;
114
+ /** Top of the focus stack, if any. */
115
+ focus: FocusId | null;
116
+ session: SessionId | null;
117
+ toolset: ToolsetId;
118
+ toolbar: ChromeId | null;
119
+ options: ChromeId | null;
120
+ rightTab: RightTab;
121
+ leftTab: LeftTab | null;
122
+ /** False in Dev and in every session: the canvas must not accept edits. */
123
+ editable: boolean;
124
+ /** True while a focus context or a session owns the screen — the mode's own chrome stands down. */
125
+ suspended: boolean;
126
+ /**
127
+ * Editor-only chrome floating over the canvas (the minimap, the pencil palette). False while presenting:
128
+ * the screen belongs to the audience then, and only the show's own controls stay.
129
+ */
130
+ canvasChrome: boolean;
131
+ }
@@ -0,0 +1,49 @@
1
+ import type { AnyNode, Document, Interaction, InteractionTrigger, NavigationType, PrototypeAction, PrototypeTransition } from '../document/types.js';
2
+ /** A link being dragged: where it started, and what it is over right now. */
3
+ export interface ConnectDrag {
4
+ /** The layer the link will fire from. */
5
+ sourceId: string;
6
+ /** Where the drag began, in world coordinates — the arrow's tail. */
7
+ from: {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ /** The pointer, in world coordinates — the arrow's head. */
12
+ to: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ /** The frame under the pointer, if it is a valid destination. */
17
+ targetId: string | null;
18
+ }
19
+ /** Can a link start from this layer? Anything you can click — but not a page. */
20
+ export declare function canConnectFrom(node: AnyNode | undefined): boolean;
21
+ /** Can a link land here? Frames and components are the things a prototype navigates TO. */
22
+ export declare function isDestination(node: AnyNode | undefined): boolean;
23
+ /**
24
+ * The frame under `point` that a link should land on: the outermost one, because a flow navigates to a
25
+ * screen, not to a card inside it. Nested frames are containers, and picking the innermost would wire a
26
+ * link to a button's background.
27
+ */
28
+ export declare function destinationAt(doc: Document, point: {
29
+ x: number;
30
+ y: number;
31
+ }, excludeSourceId?: string): string | null;
32
+ /**
33
+ * The link a completed drag creates: click to navigate, with the same smart-animate default the
34
+ * prototype panel's "add interaction" button has always used, so a link made either way behaves alike.
35
+ * `o` makes any other interaction the same way (a hover's variant change, a click that sets a variable):
36
+ * the trigger, a delay, the action's navigation and transition, and the action's own fields.
37
+ */
38
+ export declare function interactionFor(destinationId: string | null, id?: string, o?: {
39
+ trigger?: InteractionTrigger;
40
+ delay?: number;
41
+ navigation?: NavigationType;
42
+ transition?: PrototypeTransition;
43
+ action?: Omit<Partial<PrototypeAction>, 'navigationType' | 'destinationId' | 'transition'>;
44
+ }): Interaction;
45
+ /**
46
+ * Does `sourceId` already navigate to `destinationId`? Dragging the same link twice should not stack two
47
+ * identical interactions on one layer — the second click would be dead weight nobody can see.
48
+ */
49
+ export declare function alreadyLinked(doc: Document, sourceId: string, destinationId: string): boolean;
@@ -0,0 +1,37 @@
1
+ import type { AnyNode } from '../document/types.js';
2
+ /** A number smart animate glides on matched layers: the node field, and what it reads as when unset. */
3
+ export interface GlideProp {
4
+ key: string;
5
+ rest: number;
6
+ }
7
+ /**
8
+ * Every numeric property smart animate glides, in one table: a layer gets a value for a key when either side sets
9
+ * it (the other reading as `rest`). Add a property here and every hand-off glides it.
10
+ */
11
+ export declare const SMART_ANIMATE_PROPS: GlideProp[];
12
+ /** A chained hand-off: the destination's top-level layers start `delay` ms apart over a `duration` ms glide. */
13
+ export interface HandoffStagger {
14
+ /** The transition's linear progress, 0…1. */
15
+ raw: number;
16
+ duration: number;
17
+ delay: number;
18
+ /** The transition's curve, applied to each layer's own progress. */
19
+ ease: (k: number) => number;
20
+ }
21
+ /** Layer `i` of `n`'s eased progress in a staggered hand-off: its own window of the duration, one delay after the one before. */
22
+ export declare function staggeredProgress(s: HandoffStagger, i: number, n: number): number;
23
+ /**
24
+ * Node patches for progress `t` (eased, may overshoot): the destination subtree interpolated from the
25
+ * matching source layers, plus fading copies of source-only layers appended to the destination frame
26
+ * (`ghosts: false` leaves those out — an instance's variant change, whose children come from its component).
27
+ * `stagger` hands the destination's top-level layers over one after another instead of all at once. `via` names the
28
+ * layers the navigation went through on either side: where several layers share a key, those are the ones handed over.
29
+ */
30
+ export declare function smartAnimateNodes(nodes: Record<string, AnyNode>, sourceId: string, destId: string, t: number, opts?: {
31
+ ghosts?: boolean;
32
+ stagger?: HandoffStagger;
33
+ via?: {
34
+ source?: string;
35
+ destination?: string;
36
+ };
37
+ }): Record<string, AnyNode>;
@@ -0,0 +1,2 @@
1
+ import { VectorPath } from '../../document/types.js';
2
+ export declare function flattenPaths(paths: VectorPath[], tolerance?: number): number[][];
@@ -0,0 +1,24 @@
1
+ import { AnyNode } from '../../document/types.js';
2
+ type Ring = [number, number][];
3
+ /**
4
+ * Convert a shape node into closed outline rings, expressed in a target space where
5
+ * the shape's top-left corner sits at (ox, oy). Node rotation is baked in (rotated
6
+ * around the shape's own center). Returns [] for shapes with no fillable area.
7
+ */
8
+ export declare function shapeToRings(node: AnyNode, ox: number, oy: number): Ring[];
9
+ type XY = {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ /** Enumerate a node's connector snap anchors (local, top-left origin) with their
14
+ * position strings. Tables expand to every cell edge; other shapes give the four
15
+ * outline-projected edge midpoints. */
16
+ export declare function getNodeSnapAnchorList(node: AnyNode): {
17
+ pos: string;
18
+ x: number;
19
+ y: number;
20
+ }[];
21
+ export declare function getConnectorAnchorLocal(node: AnyNode, position: string): XY;
22
+ /** Reduce a connector position (incl. table-cell "r,c:EDGE") to a routing Direction. */
23
+ export declare function connectorPositionDir(position: string): string;
24
+ export {};
@@ -0,0 +1,12 @@
1
+ declare const EMPTY_INDEX = 4294967295;
2
+ export declare function encodeCels(cells: Uint32Array): string;
3
+ /** Decode (cached, READ-ONLY — copy before mutating). Wrong-sized data is padded/truncated. */
4
+ export declare function decodeCels(b64: string, count: number): Uint32Array;
5
+ export declare function emptyCels(count: number, indexed?: boolean, transparentIndex?: number): Uint32Array;
6
+ export declare function packRGBA(r: number, g: number, b: number, a: number): number;
7
+ export declare function unpackRGBA(v: number): [number, number, number, number];
8
+ export declare function hexToPacked(hex: string): number;
9
+ export declare function packedToHex(v: number): string;
10
+ /** Resolve a cel array to RGBA-packed colors (indexed → palette lookup). */
11
+ export declare function celsToRGBA(cells: Uint32Array, mode: 'RGBA' | 'INDEXED' | 'GRAYSCALE', palette: string[], transparentIndex: number): Uint32Array;
12
+ export { EMPTY_INDEX };
@@ -0,0 +1,25 @@
1
+ export declare const PALETTE_PRESETS: Record<string, string[]>;
2
+ /** Palette in node form: transparent slot 0 followed by the colors. */
3
+ export declare function presetPalette(name: string): string[];
4
+ /** Parse GIMP .gpl or plain .hex (one RRGGBB per line). Returns '#rrggbbaa' entries. */
5
+ export declare function parsePaletteFile(text: string, fileName?: string): string[];
6
+ export declare function serializeGpl(palette: string[], name?: string): string;
7
+ export declare function serializeHex(palette: string[]): string;
8
+ export interface Rgba255 {
9
+ r: number;
10
+ g: number;
11
+ b: number;
12
+ a: number;
13
+ }
14
+ /** '#rrggbb' / '#rrggbbaa' → { r,g,b 0..255, a 0..1 } */
15
+ export declare function hexToRgba(hex: string): Rgba255;
16
+ /** { r,g,b 0..255, a 0..1 } → '#rrggbbaa' */
17
+ export declare function rgbaToHex8(c: Rgba255): string;
18
+ /**
19
+ * Index of the palette swatch nearest to `hex` (RGB distance, alpha-weighted), or -1 for an empty
20
+ * palette. Fully transparent input maps to a transparent swatch when the palette has one; opaque
21
+ * input never snaps to a transparent swatch.
22
+ */
23
+ export declare function nearestSwatchIndex(hex: string, palette: string[]): number;
24
+ /** `hex` snapped to its nearest palette swatch (unchanged when the palette has no usable swatch). */
25
+ export declare function snapToPalette(hex: string, palette: string[]): string;
@@ -0,0 +1,20 @@
1
+ /** Count `p` as outstanding work until it settles (either way). Returns `p`. */
2
+ export declare function trackLoad<T>(p: Promise<T>): Promise<T>;
3
+ /** Loads that have not settled yet. */
4
+ export declare const loadsPending: () => number;
5
+ /** Something drawn this frame was left for a later one (over a frame's glyph budget, say). */
6
+ export declare function noteDeferred(): void;
7
+ /** A counter that moves whenever work is deferred: compare it before and after a render. */
8
+ export declare const deferredMark: () => number;
9
+ /**
10
+ * Resolves once no load is outstanding (true), or after `timeoutMs` (false). A macrotask later either way, so work
11
+ * that a settled load schedules (a decode, a re-render request) is queued before the caller renders again.
12
+ */
13
+ export declare function loadsSettled(timeoutMs?: number): Promise<boolean>;
14
+ /**
15
+ * `draw`, drawn again until nothing it drew was a placeholder: no load started or outstanding, no glyph deferred.
16
+ * Each pass gets a fresh glyph budget (the atlas resets it per text pass), so deferred glyphs land within a few; after
17
+ * `maxPasses` the last is kept. A pass drawn over is handed to `discard`. Every export draws through this, stills and
18
+ * frames alike: a still drawn once, the moment its file opened, kept the placeholders of letters still on their way.
19
+ */
20
+ export declare function drawSettled<T>(draw: () => T, discard: (drawn: T) => void, maxPasses: number): Promise<T>;
@@ -0,0 +1,41 @@
1
+ export type Direction = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT' | 'CENTER';
2
+ export interface Point {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ /** World-space axis-aligned obstacle rectangle (top-left origin). */
7
+ export interface Rect {
8
+ x: number;
9
+ y: number;
10
+ w: number;
11
+ h: number;
12
+ }
13
+ export interface RouteOptions {
14
+ startPos: Point;
15
+ endPos: Point;
16
+ startDir: Direction;
17
+ endDir: Direction;
18
+ minSegmentLength?: number;
19
+ /** Rectangles the orthogonal route should go around (world space). */
20
+ obstacles?: Rect[];
21
+ /** How far the route keeps clear of each obstacle. */
22
+ obstaclePadding?: number;
23
+ }
24
+ /**
25
+ * Calculates an orthogonal (Manhattan) path between two points.
26
+ *
27
+ * When `obstacles` are supplied, an A* search over an orthogonal visibility
28
+ * grid routes the connector *around* them (draw.io / Lucidchart style). If that
29
+ * search can't find a route (e.g. an endpoint is boxed in), it falls back to the
30
+ * plain elbow path below, so a connector is always produced.
31
+ */
32
+ export declare function calculateOrthogonalPath(options: RouteOptions): Point[];
33
+ /**
34
+ * Trim a polyline by arc length from each end. Routed connectors are flattened
35
+ * into samples much shorter than an arrowhead's shorten distance, so pulling
36
+ * back only the first/last segment leaves capped sample points poking past the
37
+ * arrowhead tip — the trim has to walk the whole path, dropping consumed
38
+ * points. Returns null when the trims consume the entire path.
39
+ */
40
+ export declare function trimPolyline(pts: Point[], startTrim: number, endTrim: number): Point[] | null;
41
+ export declare function calculateBezierPath(options: RouteOptions, steps?: number): Point[];
@@ -0,0 +1,22 @@
1
+ import type { ShaderGraph } from '../document/types.js';
2
+ export type ShaderPresetGroup = 'background' | 'effect' | 'visualizer';
3
+ export interface GraphPreset {
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ group: ShaderPresetGroup;
8
+ graph: ShaderGraph;
9
+ /** The knobs its colours are: background, then low, middle and high (a ramp's, or an effect's own). */
10
+ colors: {
11
+ bg?: string;
12
+ a?: string;
13
+ b?: string;
14
+ c?: string;
15
+ };
16
+ /** The knob field each param of the preset's old hand-written WGSL became, by the param's name. */
17
+ legacyParams?: Record<string, string>;
18
+ /** How far the picker preview zooms into the middle (lib/engine/shader-preview.ts): fine detail sized for a whole frame. */
19
+ previewZoom?: number;
20
+ }
21
+ /** Every preset, in the order the fill picker lists them: backgrounds, effects, visualizers. */
22
+ export declare const GRAPH_PRESETS: readonly GraphPreset[];
@@ -0,0 +1,7 @@
1
+ /** A preset as it was: its name and its code. */
2
+ export interface LegacyShaderPreset {
3
+ name: string;
4
+ code: string;
5
+ }
6
+ /** Every preset as it was, backgrounds then effects. */
7
+ export declare const LEGACY_SHADER_PRESETS: readonly LegacyShaderPreset[];
@@ -0,0 +1,43 @@
1
+ import type { Color, Paint, ShaderParamValue, TextureFillParams } from '../document/types.js';
2
+ import { type GraphPreset } from './shader-graph-presets.js';
3
+ export interface ShaderPreset extends GraphPreset {
4
+ /** The graph compiled: what a fill of the preset draws. */
5
+ code: string;
6
+ /** The preset's hand-written WGSL from before it was a graph, when it had one. */
7
+ legacyCode?: string;
8
+ }
9
+ /** Every built-in preset, in the order the fill picker lists them: backgrounds, effects, visualizers. */
10
+ export declare const SHADER_PRESETS: readonly ShaderPreset[];
11
+ /** The preset with id or name `key`. */
12
+ export declare const shaderPreset: (key: string) => ShaderPreset | undefined;
13
+ /** The preset whose old hand-written code `code` is (a fill from before presets were graphs). */
14
+ export declare const legacyPresetOf: (code: string | undefined) => ShaderPreset | undefined;
15
+ /** The preset a fill shows: its graph's (the same nodes and wires, whatever its knobs are set to), or its old code's. */
16
+ export declare function presetOfFill(fill: Pick<Paint, 'shaderCode' | 'shaderGraph'>): ShaderPreset | undefined;
17
+ /**
18
+ * `params` as `preset`'s knob fields: each named by its field (`mesh_speed`) or by its param's name in the preset's old
19
+ * WGSL (`speed`). Throws on a name that is neither, listing what the preset has.
20
+ */
21
+ export declare function presetParams(preset: ShaderPreset, params: Record<string, ShaderParamValue>): Record<string, ShaderParamValue>;
22
+ /** The knob field param `name` of `fill` is: its preset's field for a plain name (`speed` → `mesh_speed`), else `name`. */
23
+ export declare function presetField(fill: Pick<Paint, 'shaderCode' | 'shaderGraph'> | undefined, name: string): string;
24
+ /** A SHADER paint of `preset` (its graph, compiled) over `paint`, with `params` (see `presetParams`) over its own values. */
25
+ export declare function presetPaint<P extends Partial<Paint>>(paint: P, preset: ShaderPreset, params?: Record<string, ShaderParamValue>): P & {
26
+ shaderParams: Record<string, ShaderParamValue>;
27
+ } & {
28
+ type: "SHADER";
29
+ shaderGraph: import("../document/types.js").ShaderGraph;
30
+ shaderCode: string;
31
+ };
32
+ /** A preset's knob values with its colours set (`bg`, `a`, `b`, `c`: brand colours), over its own starting values. */
33
+ export declare function graphColors(preset: GraphPreset, colors: {
34
+ bg?: Color;
35
+ a?: Color;
36
+ b?: Color;
37
+ c?: Color;
38
+ }): Record<string, ShaderParamValue>;
39
+ /** The preset a new shader fill starts as. */
40
+ export declare const DEFAULT_SHADER_PRESET: ShaderPreset;
41
+ export declare const DEFAULT_TEXTURE_PARAMS: TextureFillParams;
42
+ /** Build the WGSL for a texture fill. Pure — unit-testable. */
43
+ export declare function buildTextureShader(p: TextureFillParams): string;
@@ -0,0 +1,120 @@
1
+ import type { Font } from 'fontkit';
2
+ export interface GlyphMetrics {
3
+ char: string;
4
+ width: number;
5
+ height: number;
6
+ advance: number;
7
+ bearingX: number;
8
+ bearingY: number;
9
+ uv: {
10
+ x: number;
11
+ y: number;
12
+ w: number;
13
+ h: number;
14
+ };
15
+ page?: number;
16
+ extra?: {
17
+ glyph: GlyphMetrics;
18
+ dx: number;
19
+ dy: number;
20
+ }[];
21
+ emoji?: string;
22
+ spread?: number;
23
+ gid?: number;
24
+ font?: Font;
25
+ pending?: boolean;
26
+ }
27
+ /** Per-layout record of which atlas blocks its glyphs live in and whether any glyph was pending. */
28
+ export type AtlasUsage = {
29
+ blocks: Set<number>;
30
+ pending: number;
31
+ };
32
+ export declare class TextAtlasManager {
33
+ private device;
34
+ private queue;
35
+ static readonly PAGE_COUNT = 2;
36
+ private pages;
37
+ private textureSize;
38
+ private maxTextureSize;
39
+ private blocksPerSide;
40
+ private blocks;
41
+ private retired;
42
+ private frame;
43
+ private budgetStart;
44
+ private budgetSpent;
45
+ /**
46
+ * Glyph generation allowed per frame (ms). Something that draws offline and wants the same picture every
47
+ * time lifts it (Infinity): over budget a glyph is drawn a frame late, which order it lands in the atlas
48
+ * then depends on how fast this machine is, and where it lands shades its edge a hair differently
49
+ * (scripts/gen-template-thumbnails.mts).
50
+ */
51
+ glyphBudgetMs: number;
52
+ private renderQueued;
53
+ private recording;
54
+ private unsubscribeFaces;
55
+ private pendingUpdates;
56
+ constructor(device: GPUDevice, queue: GPUQueue);
57
+ private createPages;
58
+ private resetBlocks;
59
+ /** Atlas page texture (page 0 by default). */
60
+ getTexture(page?: number): GPUTexture;
61
+ /** Block id → page and texel origin. */
62
+ private blockOrigin;
63
+ private packInBlock;
64
+ /** Place a w×h rect: a block with room, else an evicted stale block, else grown pages; null if none. */
65
+ private allocate;
66
+ private evictBlock;
67
+ /** Double both pages (keeping their contents). UVs change, so every cached layout is invalidated. */
68
+ private grow;
69
+ /**
70
+ * Cache of outline-rasterized glyphs, by `glyphCacheKey`: face name + variations, gid, atlas size — and the
71
+ * identity of the font object the gid indexes, so two faces filed under one name never share a bitmap.
72
+ */
73
+ private outlineCache;
74
+ /** Sum of block epochs (changes whenever any block is evicted) — a cheap "anything evicted?" check. */
75
+ blockEpochs: number;
76
+ /** Current epoch of a block (layout caches compare the epochs of the blocks they drew from). */
77
+ blockEpoch(block: number): number;
78
+ /** Mark blocks as drawn this frame (layout cache hits don't touch individual glyphs). */
79
+ touchBlocks(blocks: Iterable<number>): void;
80
+ /** Collect block usage / pending glyphs for the glyph lookups until the returned restore is called. */
81
+ record(usage: AtlasUsage): () => void;
82
+ private use;
83
+ private markPending;
84
+ /**
85
+ * SDF metrics for a glyph id, rasterized from the font outline (variation-aware — pass the varied
86
+ * font). bearingX/bearingY place the bitmap's top-left corner from the pen and baseline (atlas-size
87
+ * px): the outline's glyphLeft/glyphTop moved out by the SDF buffer every bitmap is padded with, so
88
+ * the drawn edge lands on the true outline. advance is the glyph's advance width. Over the frame's generation budget the metrics come back `pending`
89
+ * (exact placement, nothing to draw) or as the other size bucket's bitmap scaled to this size.
90
+ */
91
+ getOutlineGlyph(faceKey: string, font: Font, gid: number, fontSize: number, char: string): GlyphMetrics | null;
92
+ /** Over budget: the other size bucket's glyph scaled to this size, else exact metrics marked pending. */
93
+ private deferredGlyph;
94
+ /** Drop every cached glyph whose face key starts with `prefix` (space is reclaimed by eviction). */
95
+ dropFace(prefix: string): void;
96
+ /** Atlas paging state (dev/diagnostics). */
97
+ pageStats(): {
98
+ textureSize: number;
99
+ glyphs: number;
100
+ frame: number;
101
+ blocks: {
102
+ glyphs: number;
103
+ lastUsed: number;
104
+ epoch: number;
105
+ }[];
106
+ };
107
+ /** Upload generated glyphs; called once per text pass, which also ends the atlas frame. */
108
+ flushUpdates(): void;
109
+ /**
110
+ * Bumped whenever something drawn from the atlas may change: UVs invalidated (cleared / pages grown),
111
+ * a block evicted, or glyphs handed out pending. Frame-level instance caches key on it.
112
+ */
113
+ generation: number;
114
+ /** Bumped only when cached glyph UVs become invalid (cleared / pages grown). Text layout caches key on it
115
+ * (evictions are tracked per block, pending glyphs per layout). */
116
+ uvGeneration: number;
117
+ /** Explicit full reset (not used by font loads: glyph keys already identify face, variation, gid and size). */
118
+ clearCache(): void;
119
+ destroy(): void;
120
+ }
@@ -0,0 +1,15 @@
1
+ export type EmojiStyle = 'SYSTEM' | 'COLOR' | 'OUTLINE';
2
+ /** Layout box of a color emoji, in ems: advance, box size, and top of the box above the baseline. */
3
+ export declare const EMOJI_ADVANCE = 1.15;
4
+ export declare const EMOJI_BOX = 1.2;
5
+ export declare const EMOJI_ASCENT = 0.84;
6
+ /** Box offset to the right of the pen, in ems (optical: emoji art is wider than most letters). */
7
+ export declare const EMOJI_BEARING = 0.04;
8
+ /** Is this grapheme an emoji presentation cluster? */
9
+ export declare function isEmojiCluster(g: string): boolean;
10
+ /** UTF-16 ranges of emoji clusters in `text`. */
11
+ export declare function emojiClusters(text: string): {
12
+ start: number;
13
+ end: number;
14
+ cluster: string;
15
+ }[];