@classytic/stage 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 (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/assets/index.d.mts +3 -0
  4. package/dist/assets/index.mjs +5 -0
  5. package/dist/assets/kit/glyphs.d.mts +61 -0
  6. package/dist/assets/kit/glyphs.mjs +256 -0
  7. package/dist/assets/kit/index.d.mts +2 -0
  8. package/dist/assets/kit/index.mjs +4 -0
  9. package/dist/assets/kit/svg-defs.d.mts +6 -0
  10. package/dist/assets/kit/svg-defs.mjs +137 -0
  11. package/dist/builder/Palette.d.mts +30 -0
  12. package/dist/builder/Palette.mjs +100 -0
  13. package/dist/builder/SceneBuilder.d.mts +26 -0
  14. package/dist/builder/SceneBuilder.mjs +340 -0
  15. package/dist/builder/controls.d.mts +18 -0
  16. package/dist/builder/controls.mjs +29 -0
  17. package/dist/builder/editor.d.mts +46 -0
  18. package/dist/builder/editor.mjs +130 -0
  19. package/dist/builder/icons.d.mts +14 -0
  20. package/dist/builder/icons.mjs +143 -0
  21. package/dist/builder/index.d.mts +6 -0
  22. package/dist/builder/index.mjs +7 -0
  23. package/dist/builder/tools.d.mts +47 -0
  24. package/dist/builder/tools.mjs +303 -0
  25. package/dist/chem/index.d.mts +118 -0
  26. package/dist/chem/index.mjs +131 -0
  27. package/dist/core/clock.d.mts +41 -0
  28. package/dist/core/clock.mjs +62 -0
  29. package/dist/core/context.d.mts +13 -0
  30. package/dist/core/context.mjs +29 -0
  31. package/dist/core/control.d.mts +58 -0
  32. package/dist/core/control.mjs +113 -0
  33. package/dist/core/coords.d.mts +51 -0
  34. package/dist/core/coords.mjs +44 -0
  35. package/dist/core/index.d.mts +8 -0
  36. package/dist/core/index.mjs +9 -0
  37. package/dist/core/learner.d.mts +44 -0
  38. package/dist/core/learner.mjs +23 -0
  39. package/dist/core/motion.d.mts +73 -0
  40. package/dist/core/motion.mjs +103 -0
  41. package/dist/core/richText.d.mts +28 -0
  42. package/dist/core/richText.mjs +52 -0
  43. package/dist/core/vec.d.mts +47 -0
  44. package/dist/core/vec.mjs +144 -0
  45. package/dist/field/index.d.mts +58 -0
  46. package/dist/field/index.mjs +156 -0
  47. package/dist/index.d.mts +54 -0
  48. package/dist/index.mjs +55 -0
  49. package/dist/interaction/MovableDot.d.mts +33 -0
  50. package/dist/interaction/MovableDot.mjs +66 -0
  51. package/dist/interaction/hitTest.d.mts +16 -0
  52. package/dist/interaction/hitTest.mjs +39 -0
  53. package/dist/interaction/index.d.mts +5 -0
  54. package/dist/interaction/index.mjs +6 -0
  55. package/dist/interaction/useDraggable.d.mts +51 -0
  56. package/dist/interaction/useDraggable.mjs +116 -0
  57. package/dist/interaction/useScreenToMath.d.mts +12 -0
  58. package/dist/interaction/useScreenToMath.mjs +25 -0
  59. package/dist/logic/ast.d.mts +29 -0
  60. package/dist/logic/ast.mjs +37 -0
  61. package/dist/logic/index.d.mts +25 -0
  62. package/dist/logic/index.mjs +36 -0
  63. package/dist/logic/latex.d.mts +6 -0
  64. package/dist/logic/latex.mjs +33 -0
  65. package/dist/logic/minimize.d.mts +37 -0
  66. package/dist/logic/minimize.mjs +175 -0
  67. package/dist/logic/parse.d.mts +6 -0
  68. package/dist/logic/parse.mjs +68 -0
  69. package/dist/logic/table.d.mts +24 -0
  70. package/dist/logic/table.mjs +65 -0
  71. package/dist/logic/tokenize.mjs +258 -0
  72. package/dist/math/ast.d.mts +35 -0
  73. package/dist/math/ast.mjs +94 -0
  74. package/dist/math/calculus.d.mts +9 -0
  75. package/dist/math/calculus.mjs +188 -0
  76. package/dist/math/defs.mjs +51 -0
  77. package/dist/math/index.d.mts +26 -0
  78. package/dist/math/index.mjs +42 -0
  79. package/dist/math/latex.d.mts +7 -0
  80. package/dist/math/latex.mjs +115 -0
  81. package/dist/math/parse.d.mts +6 -0
  82. package/dist/math/parse.mjs +91 -0
  83. package/dist/math/tokenize.mjs +112 -0
  84. package/dist/primitives/CanvasLayer.d.mts +26 -0
  85. package/dist/primitives/CanvasLayer.mjs +87 -0
  86. package/dist/primitives/Dot.d.mts +27 -0
  87. package/dist/primitives/Dot.mjs +40 -0
  88. package/dist/primitives/Grid.d.mts +30 -0
  89. package/dist/primitives/Grid.mjs +122 -0
  90. package/dist/primitives/Label.d.mts +33 -0
  91. package/dist/primitives/Label.mjs +45 -0
  92. package/dist/primitives/Lines.d.mts +50 -0
  93. package/dist/primitives/Lines.mjs +82 -0
  94. package/dist/primitives/Plot.d.mts +50 -0
  95. package/dist/primitives/Plot.mjs +87 -0
  96. package/dist/primitives/Shapes.d.mts +76 -0
  97. package/dist/primitives/Shapes.mjs +79 -0
  98. package/dist/primitives/Tex.d.mts +27 -0
  99. package/dist/primitives/Tex.mjs +54 -0
  100. package/dist/primitives/index.d.mts +10 -0
  101. package/dist/primitives/index.mjs +10 -0
  102. package/dist/primitives/props.d.mts +15 -0
  103. package/dist/scene/Scene.d.mts +31 -0
  104. package/dist/scene/Scene.mjs +168 -0
  105. package/dist/scene/assets.d.mts +37 -0
  106. package/dist/scene/assets.mjs +31 -0
  107. package/dist/scene/commands.d.mts +47 -0
  108. package/dist/scene/commands.mjs +162 -0
  109. package/dist/scene/evaluators.d.mts +17 -0
  110. package/dist/scene/evaluators.mjs +210 -0
  111. package/dist/scene/index.d.mts +13 -0
  112. package/dist/scene/index.mjs +13 -0
  113. package/dist/scene/migrate.d.mts +11 -0
  114. package/dist/scene/migrate.mjs +35 -0
  115. package/dist/scene/render.d.mts +14 -0
  116. package/dist/scene/render.mjs +126 -0
  117. package/dist/scene/resolve.d.mts +12 -0
  118. package/dist/scene/resolve.mjs +95 -0
  119. package/dist/scene/schema.d.mts +9 -0
  120. package/dist/scene/schema.mjs +51 -0
  121. package/dist/scene/sims.d.mts +18 -0
  122. package/dist/scene/sims.mjs +54 -0
  123. package/dist/scene/store.d.mts +22 -0
  124. package/dist/scene/store.mjs +37 -0
  125. package/dist/scene/types.d.mts +228 -0
  126. package/dist/scene/types.mjs +27 -0
  127. package/dist/sim/equilibrium.d.mts +36 -0
  128. package/dist/sim/equilibrium.mjs +54 -0
  129. package/dist/sim/index.d.mts +9 -0
  130. package/dist/sim/index.mjs +9 -0
  131. package/dist/sim/particles.d.mts +43 -0
  132. package/dist/sim/particles.mjs +136 -0
  133. package/dist/sim/rate.d.mts +36 -0
  134. package/dist/sim/rate.mjs +39 -0
  135. package/dist/sim/registry.d.mts +10 -0
  136. package/dist/sim/registry.mjs +27 -0
  137. package/dist/sim/sampler.d.mts +47 -0
  138. package/dist/sim/sampler.mjs +79 -0
  139. package/dist/sim/thermal.d.mts +78 -0
  140. package/dist/sim/thermal.mjs +172 -0
  141. package/dist/sim/types.d.mts +24 -0
  142. package/dist/sim/wave.d.mts +34 -0
  143. package/dist/sim/wave.mjs +61 -0
  144. package/dist/steps/index.d.mts +62 -0
  145. package/dist/steps/index.mjs +133 -0
  146. package/dist/thermo/index.d.mts +82 -0
  147. package/dist/thermo/index.mjs +133 -0
  148. package/dist/view/Stage.d.mts +39 -0
  149. package/dist/view/Stage.mjs +91 -0
  150. package/dist/view/index.d.mts +4 -0
  151. package/dist/view/index.mjs +5 -0
  152. package/dist/view/useElementSize.d.mts +13 -0
  153. package/dist/view/useElementSize.mjs +40 -0
  154. package/dist/view/useInView.d.mts +9 -0
  155. package/dist/view/useInView.mjs +33 -0
  156. package/package.json +141 -0
  157. package/styles.css +70 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Classytic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @classytic/stage
2
+
3
+ **Domain‑neutral visual primitive engine for the web.** Declarative SVG diagram/math
4
+ primitives, draggable handles, a math↔pixel coordinate system, theming, a parametric
5
+ asset/glyph kit, a serializable `SceneDoc` graph (resolver + command/undo), and a
6
+ `LessonDoc` sequence engine. Reactive, web‑native, SSR‑safe, and agent‑drivable — the
7
+ render foundation under [`@classytic/labs`](https://github.com/classytic/labs).
8
+
9
+ ```bash
10
+ npm i @classytic/stage react react-dom
11
+ ```
12
+
13
+ ## Import deliberately (subpaths)
14
+
15
+ Everything is also re‑exported from the root for convenience, but prefer subpaths so
16
+ your bundle pulls only what it uses (ESM, per‑file emit; `sideEffects` are scoped to
17
+ `**/*.css` + `**/assets/**`, so JS tree‑shakes while styles/assets are preserved):
18
+
19
+ | Subpath | What's in it |
20
+ |---|---|
21
+ | `@classytic/stage` | the curated root barrel (everything) |
22
+ | `@classytic/stage/view` | `<Stage>` SVG root, `useElementSize` |
23
+ | `@classytic/stage/primitives` | `Dot` `Segment` `Line` `Ray` `Vector` `Circle` `Polygon` `Path` `Label` `Tex` `Grid` `Axes` `Plot` `CanvasLayer` |
24
+ | `@classytic/stage/interaction` | `MovableDot`, `useDraggable`, `useScreenToMath`, `hitTest` |
25
+ | `@classytic/stage/core` | `createCoords`/`fmt`, `vec`/`mat`, contexts, `useFrameLoop` clock, control surface, `useLearner` |
26
+ | `@classytic/stage/scene` | `SceneDoc` types, `resolve`, `applyCommand`/`inverse`, `parse`/`serialize`/`migrate`, `SceneStore`, `Scene`, the asset registry |
27
+ | `@classytic/stage/builder` | `Editor`, `SceneBuilder`, `Palette`, construction `*_TOOLS` |
28
+ | `@classytic/stage/assets` | `StageAssetDefs` + the glyph kit (`XBlockGlyph`, `WeightGlyph`, `BucketGlyph`, `HangerHook`) |
29
+ | `@classytic/stage/math` | dependency‑free expression engine (`compileExpr`, `differentiate`, `toLatex`…) |
30
+ | `@classytic/stage/lesson` | `LessonProvider`, `useLessonProgress`, `LessonStepScope` (sequence + gating + progress) |
31
+ | `@classytic/stage/styles.css` | theme tokens + control‑kit CSS (import once in global CSS) |
32
+
33
+ ## Quick start
34
+
35
+ ```tsx
36
+ import { Stage } from '@classytic/stage/view';
37
+ import { Axes, Vector } from '@classytic/stage/primitives';
38
+ import { MovableDot } from '@classytic/stage/interaction';
39
+
40
+ export function Demo() {
41
+ const [tip, setTip] = useState({ x: 3, y: 2 });
42
+ return (
43
+ <Stage view={{ xMin: -1, xMax: 6, yMin: -1, yMax: 5 }} height={320}>
44
+ <Axes labels />
45
+ <Vector tail={{ x: 0, y: 0 }} tip={tip} />
46
+ <MovableDot value={tip} onMove={setTip} />
47
+ </Stage>
48
+ );
49
+ }
50
+ ```
51
+
52
+ ## Design principles
53
+
54
+ - **SVG‑first** for crisp, accessible, themeable teaching figures; `CanvasLayer`
55
+ (zero‑dep Canvas2D) only for particle‑density (rain, heatmaps). No WebGL/Pixi
56
+ dependency until a lab measurably needs shaders.
57
+ - **`fmt()` rounds emitted coordinates** for SSR determinism (server and client agree).
58
+ - **Theming** via `--stage-*` tokens that bind to host shadcn tokens, with a deliberate
59
+ dark canvas surface.
60
+ - **Pure engine** — all domain assets/presets live in `@classytic/labs`, built on this
61
+ kit. Stage ships no domain widgets.
62
+
63
+ ## License
64
+
65
+ MIT
@@ -0,0 +1,3 @@
1
+ import { StageAssetDefs } from "./kit/svg-defs.mjs";
2
+ import { BucketGlyph, GlyphBox, HangerHook, HangerHookProps, WeightGlyph, XBlockGlyph } from "./kit/glyphs.mjs";
3
+ export { BucketGlyph, type GlyphBox, HangerHook, type HangerHookProps, StageAssetDefs, WeightGlyph, XBlockGlyph };
@@ -0,0 +1,5 @@
1
+ import { StageAssetDefs } from "./kit/svg-defs.mjs";
2
+ import { BucketGlyph, HangerHook, WeightGlyph, XBlockGlyph } from "./kit/glyphs.mjs";
3
+ import "./kit/index.mjs";
4
+
5
+ export { BucketGlyph, HangerHook, StageAssetDefs, WeightGlyph, XBlockGlyph };
@@ -0,0 +1,61 @@
1
+ import { ReactNode } from "react";
2
+
3
+ //#region src/assets/kit/glyphs.d.ts
4
+ interface GlyphBox {
5
+ cx: number;
6
+ top: number;
7
+ wpx: number;
8
+ hpx: number;
9
+ label: string;
10
+ }
11
+ /** The UNKNOWN — a crisp rounded tile with an italic label (e.g. "2x"). */
12
+ declare function XBlockGlyph({
13
+ cx,
14
+ top,
15
+ wpx,
16
+ hpx,
17
+ label
18
+ }: GlyphBox): ReactNode;
19
+ /** A container of UNKNOWN amount — a pail, brand-colored (it IS an unknown, like
20
+ * the tile), labelled "?" until revealed. Built with real form: one light
21
+ * direction (top-left), 2-tone shading for volume (gradient body + a soft
22
+ * right-side shadow + a left specular streak), a rim with visible thickness
23
+ * (outer lip + dark opening), and a contrasting handle with pivots. No flat
24
+ * fill, no stray band line. */
25
+ declare function BucketGlyph({
26
+ cx,
27
+ top,
28
+ wpx,
29
+ hpx,
30
+ label
31
+ }: GlyphBox): ReactNode;
32
+ interface HangerHookProps {
33
+ /** Attach point on the beam/arm (pixels). */
34
+ topX: number;
35
+ topY: number;
36
+ /** Attach point on the load — the top-centre of the glyph it carries (pixels). */
37
+ botX: number;
38
+ botY: number;
39
+ }
40
+ /**
41
+ * A suspension: a thin eye on the beam, a taut thread, and an S-hook that grips
42
+ * the load — the realistic way a weight hangs from an arm (replaces the old
43
+ * bare "line + dot"). Pure pixel glyph: callers project math→px first. Layered
44
+ * edge/metal/sheen strokes match the beam's metallic read.
45
+ */
46
+ declare function HangerHook({
47
+ topX,
48
+ topY,
49
+ botX,
50
+ botY
51
+ }: HangerHookProps): ReactNode;
52
+ /** A KNOWN value — a clean flat coin with the number. */
53
+ declare function WeightGlyph({
54
+ cx,
55
+ top,
56
+ wpx,
57
+ hpx,
58
+ label
59
+ }: GlyphBox): ReactNode;
60
+ //#endregion
61
+ export { BucketGlyph, GlyphBox, HangerHook, HangerHookProps, WeightGlyph, XBlockGlyph };
@@ -0,0 +1,256 @@
1
+ 'use client';
2
+
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+
5
+ //#region src/assets/kit/glyphs.tsx
6
+ /** The UNKNOWN — a crisp rounded tile with an italic label (e.g. "2x"). */
7
+ function XBlockGlyph({ cx, top, wpx, hpx, label }) {
8
+ const s = Math.min(wpx, hpx);
9
+ const x0 = cx - s / 2;
10
+ const rx = s * .24;
11
+ return /* @__PURE__ */ jsxs("g", { children: [
12
+ /* @__PURE__ */ jsx("ellipse", {
13
+ cx,
14
+ cy: top + s,
15
+ rx: s * .52,
16
+ ry: s * .08,
17
+ fill: "color-mix(in oklab, black 60%, transparent)",
18
+ opacity: .14
19
+ }),
20
+ /* @__PURE__ */ jsx("rect", {
21
+ x: x0,
22
+ y: top,
23
+ width: s,
24
+ height: s,
25
+ rx,
26
+ fill: "url(#stage-grad-weight)",
27
+ stroke: "color-mix(in oklab, var(--stage-weight) 65%, black)",
28
+ strokeWidth: 1
29
+ }),
30
+ /* @__PURE__ */ jsx("line", {
31
+ x1: x0 + s * .22,
32
+ y1: top + s * .2,
33
+ x2: x0 + s * .78,
34
+ y2: top + s * .2,
35
+ stroke: "color-mix(in oklab, var(--stage-sheen) 40%, transparent)",
36
+ strokeWidth: 1.5,
37
+ strokeLinecap: "round"
38
+ }),
39
+ /* @__PURE__ */ jsx("text", {
40
+ x: cx,
41
+ y: top + s * .56,
42
+ fill: "var(--stage-fg)",
43
+ fontSize: s * .42,
44
+ fontWeight: 700,
45
+ fontStyle: "italic",
46
+ textAnchor: "middle",
47
+ dominantBaseline: "central",
48
+ style: { pointerEvents: "none" },
49
+ children: label
50
+ })
51
+ ] });
52
+ }
53
+ /** A container of UNKNOWN amount — a pail, brand-colored (it IS an unknown, like
54
+ * the tile), labelled "?" until revealed. Built with real form: one light
55
+ * direction (top-left), 2-tone shading for volume (gradient body + a soft
56
+ * right-side shadow + a left specular streak), a rim with visible thickness
57
+ * (outer lip + dark opening), and a contrasting handle with pivots. No flat
58
+ * fill, no stray band line. */
59
+ function BucketGlyph({ cx, top, wpx, hpx, label }) {
60
+ const s = Math.min(wpx, hpx);
61
+ const lipRy = s * .095;
62
+ const topY = top + s * .18;
63
+ const botY = top + s * .99;
64
+ const topHalf = s * .44;
65
+ const botHalf = s * .3;
66
+ const r = s * .06;
67
+ const edge = "color-mix(in oklab, var(--stage-weight) 60%, black)";
68
+ const shadow = "color-mix(in oklab, var(--stage-weight) 55%, black)";
69
+ const dark = "color-mix(in oklab, var(--stage-weight) 42%, black)";
70
+ const body = `M ${cx - topHalf} ${topY} L ${cx + topHalf} ${topY} L ${cx + botHalf} ${botY - r} Q ${cx + botHalf} ${botY} ${cx + botHalf - r} ${botY} L ${cx - botHalf + r} ${botY} Q ${cx - botHalf} ${botY} ${cx - botHalf} ${botY - r} Z`;
71
+ const shade = `M ${cx + topHalf * .2} ${topY} L ${cx + topHalf} ${topY} L ${cx + botHalf} ${botY - r} Q ${cx + botHalf} ${botY} ${cx + botHalf - r} ${botY} L ${cx + botHalf * .28} ${botY} Z`;
72
+ const handleR = s * .42;
73
+ const hx = topHalf * .66;
74
+ return /* @__PURE__ */ jsxs("g", { children: [
75
+ /* @__PURE__ */ jsx("ellipse", {
76
+ cx,
77
+ cy: botY + s * .035,
78
+ rx: botHalf * 1.18,
79
+ ry: s * .05,
80
+ fill: "color-mix(in oklab, black 60%, transparent)",
81
+ opacity: .16
82
+ }),
83
+ /* @__PURE__ */ jsx("path", {
84
+ d: `M ${cx - hx} ${topY} A ${handleR} ${handleR} 0 0 1 ${cx + hx} ${topY}`,
85
+ fill: "none",
86
+ stroke: "color-mix(in oklab, var(--stage-metal) 70%, black)",
87
+ strokeWidth: Math.max(2, s * .05),
88
+ strokeLinecap: "round"
89
+ }),
90
+ /* @__PURE__ */ jsx("path", {
91
+ d: body,
92
+ fill: "url(#stage-grad-weight)",
93
+ stroke: edge,
94
+ strokeWidth: 1.25,
95
+ strokeLinejoin: "round"
96
+ }),
97
+ /* @__PURE__ */ jsx("path", {
98
+ d: shade,
99
+ fill: shadow,
100
+ opacity: .28
101
+ }),
102
+ /* @__PURE__ */ jsx("path", {
103
+ d: `M ${cx - topHalf * .66} ${topY + lipRy * 1.6} L ${cx - botHalf * .62} ${botY - r * 1.4}`,
104
+ fill: "none",
105
+ stroke: "color-mix(in oklab, var(--stage-sheen) 55%, transparent)",
106
+ strokeWidth: s * .05,
107
+ strokeLinecap: "round",
108
+ opacity: .5
109
+ }),
110
+ /* @__PURE__ */ jsx("ellipse", {
111
+ cx,
112
+ cy: topY,
113
+ rx: topHalf,
114
+ ry: lipRy,
115
+ fill: "url(#stage-grad-weight)",
116
+ stroke: edge,
117
+ strokeWidth: 1.25
118
+ }),
119
+ /* @__PURE__ */ jsx("ellipse", {
120
+ cx,
121
+ cy: topY + lipRy * .18,
122
+ rx: topHalf * .82,
123
+ ry: lipRy * .74,
124
+ fill: dark
125
+ }),
126
+ /* @__PURE__ */ jsx("circle", {
127
+ cx: cx - hx,
128
+ cy: topY,
129
+ r: s * .035,
130
+ fill: "color-mix(in oklab, var(--stage-metal) 70%, black)"
131
+ }),
132
+ /* @__PURE__ */ jsx("circle", {
133
+ cx: cx + hx,
134
+ cy: topY,
135
+ r: s * .035,
136
+ fill: "color-mix(in oklab, var(--stage-metal) 70%, black)"
137
+ }),
138
+ /* @__PURE__ */ jsx("text", {
139
+ x: cx,
140
+ y: topY + (botY - topY) * .62,
141
+ fill: "var(--stage-sheen)",
142
+ fontSize: s * .42,
143
+ fontWeight: 800,
144
+ textAnchor: "middle",
145
+ dominantBaseline: "central",
146
+ style: {
147
+ paintOrder: "stroke",
148
+ stroke: dark,
149
+ strokeWidth: s * .03,
150
+ strokeLinejoin: "round",
151
+ pointerEvents: "none"
152
+ },
153
+ children: label
154
+ })
155
+ ] });
156
+ }
157
+ /**
158
+ * A suspension: a thin eye on the beam, a taut thread, and an S-hook that grips
159
+ * the load — the realistic way a weight hangs from an arm (replaces the old
160
+ * bare "line + dot"). Pure pixel glyph: callers project math→px first. Layered
161
+ * edge/metal/sheen strokes match the beam's metallic read.
162
+ */
163
+ function HangerHook({ topX, topY, botX, botY }) {
164
+ const metal = "var(--stage-metal)";
165
+ const edge = "color-mix(in oklab, var(--stage-metal) 55%, black)";
166
+ const sheen = "color-mix(in oklab, var(--stage-sheen) 50%, transparent)";
167
+ const k = 3.2;
168
+ const hookTop = botY - k * 3.4;
169
+ const span = botY - hookTop;
170
+ const s = `M ${botX} ${hookTop} C ${botX - k} ${hookTop + span * .2} ${botX - k} ${hookTop + span * .46} ${botX} ${hookTop + span * .52} C ${botX + k} ${hookTop + span * .6} ${botX + k} ${hookTop + span * .86} ${botX} ${botY}`;
171
+ return /* @__PURE__ */ jsxs("g", { children: [
172
+ /* @__PURE__ */ jsx("circle", {
173
+ cx: topX,
174
+ cy: topY,
175
+ r: 1.7,
176
+ fill: "none",
177
+ stroke: metal,
178
+ strokeWidth: 1.2
179
+ }),
180
+ /* @__PURE__ */ jsx("line", {
181
+ x1: topX,
182
+ y1: topY + 1.7,
183
+ x2: botX,
184
+ y2: hookTop,
185
+ stroke: metal,
186
+ strokeWidth: 1.1,
187
+ opacity: .75
188
+ }),
189
+ /* @__PURE__ */ jsx("path", {
190
+ d: s,
191
+ fill: "none",
192
+ stroke: edge,
193
+ strokeWidth: 2.6,
194
+ strokeLinecap: "round"
195
+ }),
196
+ /* @__PURE__ */ jsx("path", {
197
+ d: s,
198
+ fill: "none",
199
+ stroke: metal,
200
+ strokeWidth: 1.6,
201
+ strokeLinecap: "round"
202
+ }),
203
+ /* @__PURE__ */ jsx("path", {
204
+ d: s,
205
+ fill: "none",
206
+ stroke: sheen,
207
+ strokeWidth: .6,
208
+ strokeLinecap: "round",
209
+ transform: "translate(-0.5,0)"
210
+ })
211
+ ] });
212
+ }
213
+ /** A KNOWN value — a clean flat coin with the number. */
214
+ function WeightGlyph({ cx, top, wpx, hpx, label }) {
215
+ const r = Math.min(wpx, hpx) / 2;
216
+ const cy = top + r;
217
+ return /* @__PURE__ */ jsxs("g", { children: [
218
+ /* @__PURE__ */ jsx("ellipse", {
219
+ cx,
220
+ cy: cy + r * .96,
221
+ rx: r,
222
+ ry: r * .18,
223
+ fill: "color-mix(in oklab, black 60%, transparent)",
224
+ opacity: .14
225
+ }),
226
+ /* @__PURE__ */ jsx("circle", {
227
+ cx,
228
+ cy,
229
+ r,
230
+ fill: "url(#stage-grad-weight-2)",
231
+ stroke: "color-mix(in oklab, var(--stage-weight-2) 62%, black)",
232
+ strokeWidth: 1
233
+ }),
234
+ /* @__PURE__ */ jsx("path", {
235
+ d: `M${cx - r * .6},${cy - r * .42} A${r * .72},${r * .72} 0 0 1 ${cx + r * .6},${cy - r * .42}`,
236
+ fill: "none",
237
+ stroke: "color-mix(in oklab, var(--stage-sheen) 38%, transparent)",
238
+ strokeWidth: 1.5,
239
+ strokeLinecap: "round"
240
+ }),
241
+ /* @__PURE__ */ jsx("text", {
242
+ x: cx,
243
+ y: cy + r * .04,
244
+ fill: "var(--stage-fg)",
245
+ fontSize: r * .8,
246
+ fontWeight: 700,
247
+ textAnchor: "middle",
248
+ dominantBaseline: "central",
249
+ style: { pointerEvents: "none" },
250
+ children: label
251
+ })
252
+ ] });
253
+ }
254
+
255
+ //#endregion
256
+ export { BucketGlyph, HangerHook, WeightGlyph, XBlockGlyph };
@@ -0,0 +1,2 @@
1
+ import { StageAssetDefs } from "./svg-defs.mjs";
2
+ import { BucketGlyph, GlyphBox, HangerHook, HangerHookProps, WeightGlyph, XBlockGlyph } from "./glyphs.mjs";
@@ -0,0 +1,4 @@
1
+ import { StageAssetDefs } from "./svg-defs.mjs";
2
+ import { BucketGlyph, HangerHook, WeightGlyph, XBlockGlyph } from "./glyphs.mjs";
3
+
4
+ export { };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+
3
+ //#region src/assets/kit/svg-defs.d.ts
4
+ declare function StageAssetDefs(): ReactNode;
5
+ //#endregion
6
+ export { StageAssetDefs };
@@ -0,0 +1,137 @@
1
+ 'use client';
2
+
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+
5
+ //#region src/assets/kit/svg-defs.tsx
6
+ function StageAssetDefs() {
7
+ return /* @__PURE__ */ jsxs("defs", { children: [
8
+ /* @__PURE__ */ jsxs("linearGradient", {
9
+ id: "stage-grad-metal",
10
+ x1: "0",
11
+ y1: "0",
12
+ x2: "0",
13
+ y2: "1",
14
+ children: [/* @__PURE__ */ jsx("stop", {
15
+ offset: "0",
16
+ stopColor: "color-mix(in oklab, var(--stage-metal) 85%, white)"
17
+ }), /* @__PURE__ */ jsx("stop", {
18
+ offset: "1",
19
+ stopColor: "var(--stage-metal)"
20
+ })]
21
+ }),
22
+ /* @__PURE__ */ jsxs("linearGradient", {
23
+ id: "stage-grad-weight",
24
+ x1: "0",
25
+ y1: "0",
26
+ x2: "0",
27
+ y2: "1",
28
+ children: [/* @__PURE__ */ jsx("stop", {
29
+ offset: "0",
30
+ stopColor: "color-mix(in oklab, var(--stage-weight) 78%, white)"
31
+ }), /* @__PURE__ */ jsx("stop", {
32
+ offset: "1",
33
+ stopColor: "var(--stage-weight)"
34
+ })]
35
+ }),
36
+ /* @__PURE__ */ jsxs("linearGradient", {
37
+ id: "stage-grad-weight-2",
38
+ x1: "0",
39
+ y1: "0",
40
+ x2: "0",
41
+ y2: "1",
42
+ children: [/* @__PURE__ */ jsx("stop", {
43
+ offset: "0",
44
+ stopColor: "color-mix(in oklab, var(--stage-weight-2) 78%, white)"
45
+ }), /* @__PURE__ */ jsx("stop", {
46
+ offset: "1",
47
+ stopColor: "var(--stage-weight-2)"
48
+ })]
49
+ }),
50
+ /* @__PURE__ */ jsx("filter", {
51
+ id: "stage-soft-shadow",
52
+ x: "-30%",
53
+ y: "-30%",
54
+ width: "160%",
55
+ height: "160%",
56
+ children: /* @__PURE__ */ jsx("feDropShadow", {
57
+ dx: "0",
58
+ dy: "1.5",
59
+ stdDeviation: "1.8",
60
+ floodColor: "#000",
61
+ floodOpacity: "0.28"
62
+ })
63
+ }),
64
+ /* @__PURE__ */ jsxs("filter", {
65
+ id: "stage-glow",
66
+ x: "-60%",
67
+ y: "-60%",
68
+ width: "220%",
69
+ height: "220%",
70
+ children: [/* @__PURE__ */ jsx("feGaussianBlur", {
71
+ in: "SourceGraphic",
72
+ stdDeviation: "2.4",
73
+ result: "b"
74
+ }), /* @__PURE__ */ jsxs("feMerge", { children: [/* @__PURE__ */ jsx("feMergeNode", { in: "b" }), /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })] })]
75
+ }),
76
+ /* @__PURE__ */ jsxs("filter", {
77
+ id: "stage-bloom",
78
+ x: "-120%",
79
+ y: "-120%",
80
+ width: "340%",
81
+ height: "340%",
82
+ children: [
83
+ /* @__PURE__ */ jsx("feGaussianBlur", {
84
+ in: "SourceGraphic",
85
+ stdDeviation: "6",
86
+ result: "b1"
87
+ }),
88
+ /* @__PURE__ */ jsx("feGaussianBlur", {
89
+ in: "SourceGraphic",
90
+ stdDeviation: "2.5",
91
+ result: "b2"
92
+ }),
93
+ /* @__PURE__ */ jsxs("feMerge", { children: [
94
+ /* @__PURE__ */ jsx("feMergeNode", { in: "b1" }),
95
+ /* @__PURE__ */ jsx("feMergeNode", { in: "b2" }),
96
+ /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
97
+ ] })
98
+ ]
99
+ }),
100
+ /* @__PURE__ */ jsxs("radialGradient", {
101
+ id: "stage-grad-thermal",
102
+ cx: "0.5",
103
+ cy: "0.5",
104
+ r: "0.5",
105
+ children: [
106
+ /* @__PURE__ */ jsx("stop", {
107
+ offset: "0",
108
+ stopColor: "color-mix(in oklab, white 70%, var(--stage-warn))"
109
+ }),
110
+ /* @__PURE__ */ jsx("stop", {
111
+ offset: "0.45",
112
+ stopColor: "var(--stage-warn)"
113
+ }),
114
+ /* @__PURE__ */ jsx("stop", {
115
+ offset: "1",
116
+ stopColor: "color-mix(in oklab, var(--stage-warn) 40%, transparent)"
117
+ })
118
+ ]
119
+ }),
120
+ /* @__PURE__ */ jsxs("radialGradient", {
121
+ id: "stage-grad-halo",
122
+ cx: "0.5",
123
+ cy: "0.5",
124
+ r: "0.5",
125
+ children: [/* @__PURE__ */ jsx("stop", {
126
+ offset: "0",
127
+ stopColor: "color-mix(in oklab, var(--stage-accent) 60%, transparent)"
128
+ }), /* @__PURE__ */ jsx("stop", {
129
+ offset: "1",
130
+ stopColor: "color-mix(in oklab, var(--stage-accent) 0%, transparent)"
131
+ })]
132
+ })
133
+ ] });
134
+ }
135
+
136
+ //#endregion
137
+ export { StageAssetDefs };
@@ -0,0 +1,30 @@
1
+ import { Tool } from "./tools.mjs";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/builder/Palette.d.ts
5
+ interface PaletteProps {
6
+ tools: Tool[];
7
+ activeTool: string;
8
+ onSelect: (id: string) => void;
9
+ onUndo: () => void;
10
+ onRedo: () => void;
11
+ canUndo: boolean;
12
+ canRedo: boolean;
13
+ onClear: () => void;
14
+ onSave?: () => void;
15
+ hint: string;
16
+ }
17
+ declare function Palette({
18
+ tools,
19
+ activeTool,
20
+ onSelect,
21
+ onUndo,
22
+ onRedo,
23
+ canUndo,
24
+ canRedo,
25
+ onClear,
26
+ onSave,
27
+ hint
28
+ }: PaletteProps): ReactNode;
29
+ //#endregion
30
+ export { Palette, PaletteProps };