designmockdown 0.0.0-stage → 0.2.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 (304) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -2
  3. package/dist/app/assets/index-CmugGtLS.js +15 -0
  4. package/dist/app/assets/index-CwhgxL4e.css +1 -0
  5. package/dist/app/index.html +13 -0
  6. package/dist/lib/cli.d.ts +11 -0
  7. package/dist/lib/cli.d.ts.map +1 -0
  8. package/dist/lib/cli.js +968 -0
  9. package/dist/lib/cli.js.map +1 -0
  10. package/dist/lib/collab/client.d.ts +20 -0
  11. package/dist/lib/collab/client.d.ts.map +1 -0
  12. package/dist/lib/collab/client.js +126 -0
  13. package/dist/lib/collab/client.js.map +1 -0
  14. package/dist/lib/collab/index.d.ts +40 -0
  15. package/dist/lib/collab/index.d.ts.map +1 -0
  16. package/dist/lib/collab/index.js +154 -0
  17. package/dist/lib/collab/index.js.map +1 -0
  18. package/dist/lib/collab/room.d.ts +111 -0
  19. package/dist/lib/collab/room.d.ts.map +1 -0
  20. package/dist/lib/collab/room.js +120 -0
  21. package/dist/lib/collab/room.js.map +1 -0
  22. package/dist/lib/collab/ws.d.ts +33 -0
  23. package/dist/lib/collab/ws.d.ts.map +1 -0
  24. package/dist/lib/collab/ws.js +191 -0
  25. package/dist/lib/collab/ws.js.map +1 -0
  26. package/dist/lib/components/basic.d.ts +8 -0
  27. package/dist/lib/components/basic.d.ts.map +1 -0
  28. package/dist/lib/components/basic.js +181 -0
  29. package/dist/lib/components/basic.js.map +1 -0
  30. package/dist/lib/components/config.d.ts +26 -0
  31. package/dist/lib/components/config.d.ts.map +1 -0
  32. package/dist/lib/components/config.js +94 -0
  33. package/dist/lib/components/config.js.map +1 -0
  34. package/dist/lib/components/containers.d.ts +9 -0
  35. package/dist/lib/components/containers.d.ts.map +1 -0
  36. package/dist/lib/components/containers.js +102 -0
  37. package/dist/lib/components/containers.js.map +1 -0
  38. package/dist/lib/components/controls.d.ts +8 -0
  39. package/dist/lib/components/controls.d.ts.map +1 -0
  40. package/dist/lib/components/controls.js +376 -0
  41. package/dist/lib/components/controls.js.map +1 -0
  42. package/dist/lib/components/data.d.ts +8 -0
  43. package/dist/lib/components/data.d.ts.map +1 -0
  44. package/dist/lib/components/data.js +494 -0
  45. package/dist/lib/components/data.js.map +1 -0
  46. package/dist/lib/components/feedback.d.ts +8 -0
  47. package/dist/lib/components/feedback.d.ts.map +1 -0
  48. package/dist/lib/components/feedback.js +151 -0
  49. package/dist/lib/components/feedback.js.map +1 -0
  50. package/dist/lib/components/icons.d.ts +28 -0
  51. package/dist/lib/components/icons.d.ts.map +1 -0
  52. package/dist/lib/components/icons.js +85 -0
  53. package/dist/lib/components/icons.js.map +1 -0
  54. package/dist/lib/components/layout.d.ts +10 -0
  55. package/dist/lib/components/layout.d.ts.map +1 -0
  56. package/dist/lib/components/layout.js +82 -0
  57. package/dist/lib/components/layout.js.map +1 -0
  58. package/dist/lib/components/nav.d.ts +8 -0
  59. package/dist/lib/components/nav.d.ts.map +1 -0
  60. package/dist/lib/components/nav.js +216 -0
  61. package/dist/lib/components/nav.js.map +1 -0
  62. package/dist/lib/components/plugin.d.ts +27 -0
  63. package/dist/lib/components/plugin.d.ts.map +1 -0
  64. package/dist/lib/components/plugin.js +152 -0
  65. package/dist/lib/components/plugin.js.map +1 -0
  66. package/dist/lib/components/registry.d.ts +111 -0
  67. package/dist/lib/components/registry.d.ts.map +1 -0
  68. package/dist/lib/components/registry.js +375 -0
  69. package/dist/lib/components/registry.js.map +1 -0
  70. package/dist/lib/components/types.d.ts +111 -0
  71. package/dist/lib/components/types.d.ts.map +1 -0
  72. package/dist/lib/components/types.js +6 -0
  73. package/dist/lib/components/types.js.map +1 -0
  74. package/dist/lib/core/anim.d.ts +31 -0
  75. package/dist/lib/core/anim.d.ts.map +1 -0
  76. package/dist/lib/core/anim.js +95 -0
  77. package/dist/lib/core/anim.js.map +1 -0
  78. package/dist/lib/core/ast.d.ts +174 -0
  79. package/dist/lib/core/ast.d.ts.map +1 -0
  80. package/dist/lib/core/ast.js +42 -0
  81. package/dist/lib/core/ast.js.map +1 -0
  82. package/dist/lib/core/chart-source.d.ts +37 -0
  83. package/dist/lib/core/chart-source.d.ts.map +1 -0
  84. package/dist/lib/core/chart-source.js +125 -0
  85. package/dist/lib/core/chart-source.js.map +1 -0
  86. package/dist/lib/core/data.d.ts +32 -0
  87. package/dist/lib/core/data.d.ts.map +1 -0
  88. package/dist/lib/core/data.js +150 -0
  89. package/dist/lib/core/data.js.map +1 -0
  90. package/dist/lib/core/define.d.ts +16 -0
  91. package/dist/lib/core/define.d.ts.map +1 -0
  92. package/dist/lib/core/define.js +232 -0
  93. package/dist/lib/core/define.js.map +1 -0
  94. package/dist/lib/core/diagnostics.d.ts +64 -0
  95. package/dist/lib/core/diagnostics.d.ts.map +1 -0
  96. package/dist/lib/core/diagnostics.js +62 -0
  97. package/dist/lib/core/diagnostics.js.map +1 -0
  98. package/dist/lib/core/errors.d.ts +27 -0
  99. package/dist/lib/core/errors.d.ts.map +1 -0
  100. package/dist/lib/core/errors.js +70 -0
  101. package/dist/lib/core/errors.js.map +1 -0
  102. package/dist/lib/core/expand.d.ts +21 -0
  103. package/dist/lib/core/expand.d.ts.map +1 -0
  104. package/dist/lib/core/expand.js +226 -0
  105. package/dist/lib/core/expand.js.map +1 -0
  106. package/dist/lib/core/expr.d.ts +29 -0
  107. package/dist/lib/core/expr.d.ts.map +1 -0
  108. package/dist/lib/core/expr.js +313 -0
  109. package/dist/lib/core/expr.js.map +1 -0
  110. package/dist/lib/core/format.d.ts +30 -0
  111. package/dist/lib/core/format.d.ts.map +1 -0
  112. package/dist/lib/core/format.js +106 -0
  113. package/dist/lib/core/format.js.map +1 -0
  114. package/dist/lib/core/lexer.d.ts +54 -0
  115. package/dist/lib/core/lexer.d.ts.map +1 -0
  116. package/dist/lib/core/lexer.js +311 -0
  117. package/dist/lib/core/lexer.js.map +1 -0
  118. package/dist/lib/core/parser.d.ts +29 -0
  119. package/dist/lib/core/parser.d.ts.map +1 -0
  120. package/dist/lib/core/parser.js +674 -0
  121. package/dist/lib/core/parser.js.map +1 -0
  122. package/dist/lib/core/resolver.d.ts +37 -0
  123. package/dist/lib/core/resolver.d.ts.map +1 -0
  124. package/dist/lib/core/resolver.js +240 -0
  125. package/dist/lib/core/resolver.js.map +1 -0
  126. package/dist/lib/core/spec.d.ts +87 -0
  127. package/dist/lib/core/spec.d.ts.map +1 -0
  128. package/dist/lib/core/spec.js +207 -0
  129. package/dist/lib/core/spec.js.map +1 -0
  130. package/dist/lib/core/state.d.ts +19 -0
  131. package/dist/lib/core/state.d.ts.map +1 -0
  132. package/dist/lib/core/state.js +64 -0
  133. package/dist/lib/core/state.js.map +1 -0
  134. package/dist/lib/core/tokens.d.ts +36 -0
  135. package/dist/lib/core/tokens.d.ts.map +1 -0
  136. package/dist/lib/core/tokens.js +198 -0
  137. package/dist/lib/core/tokens.js.map +1 -0
  138. package/dist/lib/export/pages.d.ts +39 -0
  139. package/dist/lib/export/pages.d.ts.map +1 -0
  140. package/dist/lib/export/pages.js +95 -0
  141. package/dist/lib/export/pages.js.map +1 -0
  142. package/dist/lib/export/raster.d.ts +39 -0
  143. package/dist/lib/export/raster.d.ts.map +1 -0
  144. package/dist/lib/export/raster.js +152 -0
  145. package/dist/lib/export/raster.js.map +1 -0
  146. package/dist/lib/index.d.ts +33 -0
  147. package/dist/lib/index.d.ts.map +1 -0
  148. package/dist/lib/index.js +30 -0
  149. package/dist/lib/index.js.map +1 -0
  150. package/dist/lib/layout/engine.d.ts +32 -0
  151. package/dist/lib/layout/engine.d.ts.map +1 -0
  152. package/dist/lib/layout/engine.js +1063 -0
  153. package/dist/lib/layout/engine.js.map +1 -0
  154. package/dist/lib/layout/measure.d.ts +30 -0
  155. package/dist/lib/layout/measure.d.ts.map +1 -0
  156. package/dist/lib/layout/measure.js +148 -0
  157. package/dist/lib/layout/measure.js.map +1 -0
  158. package/dist/lib/layout/types.d.ts +94 -0
  159. package/dist/lib/layout/types.d.ts.map +1 -0
  160. package/dist/lib/layout/types.js +16 -0
  161. package/dist/lib/layout/types.js.map +1 -0
  162. package/dist/lib/lsp/server.d.ts +76 -0
  163. package/dist/lib/lsp/server.d.ts.map +1 -0
  164. package/dist/lib/lsp/server.js +264 -0
  165. package/dist/lib/lsp/server.js.map +1 -0
  166. package/dist/lib/output/docs.d.ts +26 -0
  167. package/dist/lib/output/docs.d.ts.map +1 -0
  168. package/dist/lib/output/docs.js +231 -0
  169. package/dist/lib/output/docs.js.map +1 -0
  170. package/dist/lib/output/ir.d.ts +105 -0
  171. package/dist/lib/output/ir.d.ts.map +1 -0
  172. package/dist/lib/output/ir.js +89 -0
  173. package/dist/lib/output/ir.js.map +1 -0
  174. package/dist/lib/output/schema.d.ts +69 -0
  175. package/dist/lib/output/schema.d.ts.map +1 -0
  176. package/dist/lib/output/schema.js +84 -0
  177. package/dist/lib/output/schema.js.map +1 -0
  178. package/dist/lib/paths.d.ts +12 -0
  179. package/dist/lib/paths.d.ts.map +1 -0
  180. package/dist/lib/paths.js +27 -0
  181. package/dist/lib/paths.js.map +1 -0
  182. package/dist/lib/playground/examples.d.ts +16 -0
  183. package/dist/lib/playground/examples.d.ts.map +1 -0
  184. package/dist/lib/playground/examples.js +515 -0
  185. package/dist/lib/playground/examples.js.map +1 -0
  186. package/dist/lib/playground/index.d.ts +51 -0
  187. package/dist/lib/playground/index.d.ts.map +1 -0
  188. package/dist/lib/playground/index.js +598 -0
  189. package/dist/lib/playground/index.js.map +1 -0
  190. package/dist/lib/render/assets.d.ts +35 -0
  191. package/dist/lib/render/assets.d.ts.map +1 -0
  192. package/dist/lib/render/assets.js +114 -0
  193. package/dist/lib/render/assets.js.map +1 -0
  194. package/dist/lib/render/backends.d.ts +31 -0
  195. package/dist/lib/render/backends.d.ts.map +1 -0
  196. package/dist/lib/render/backends.js +57 -0
  197. package/dist/lib/render/backends.js.map +1 -0
  198. package/dist/lib/render/css.d.ts +24 -0
  199. package/dist/lib/render/css.d.ts.map +1 -0
  200. package/dist/lib/render/css.js +148 -0
  201. package/dist/lib/render/css.js.map +1 -0
  202. package/dist/lib/render/document-html.d.ts +28 -0
  203. package/dist/lib/render/document-html.d.ts.map +1 -0
  204. package/dist/lib/render/document-html.js +214 -0
  205. package/dist/lib/render/document-html.js.map +1 -0
  206. package/dist/lib/render/dom.d.ts +32 -0
  207. package/dist/lib/render/dom.d.ts.map +1 -0
  208. package/dist/lib/render/dom.js +531 -0
  209. package/dist/lib/render/dom.js.map +1 -0
  210. package/dist/lib/render/primitives.d.ts +81 -0
  211. package/dist/lib/render/primitives.d.ts.map +1 -0
  212. package/dist/lib/render/primitives.js +172 -0
  213. package/dist/lib/render/primitives.js.map +1 -0
  214. package/dist/lib/render/react.d.ts +23 -0
  215. package/dist/lib/render/react.d.ts.map +1 -0
  216. package/dist/lib/render/react.js +447 -0
  217. package/dist/lib/render/react.js.map +1 -0
  218. package/dist/lib/render/svg.d.ts +45 -0
  219. package/dist/lib/render/svg.d.ts.map +1 -0
  220. package/dist/lib/render/svg.js +179 -0
  221. package/dist/lib/render/svg.js.map +1 -0
  222. package/dist/lib/runtime/proto.d.ts +19 -0
  223. package/dist/lib/runtime/proto.d.ts.map +1 -0
  224. package/dist/lib/runtime/proto.js +81 -0
  225. package/dist/lib/runtime/proto.js.map +1 -0
  226. package/dist/lib/skill/install.d.ts +28 -0
  227. package/dist/lib/skill/install.d.ts.map +1 -0
  228. package/dist/lib/skill/install.js +89 -0
  229. package/dist/lib/skill/install.js.map +1 -0
  230. package/dist/lib/workbench/app.d.ts +24 -0
  231. package/dist/lib/workbench/app.d.ts.map +1 -0
  232. package/dist/lib/workbench/app.js +45 -0
  233. package/dist/lib/workbench/app.js.map +1 -0
  234. package/dist/lib/workbench/assets.d.ts +21 -0
  235. package/dist/lib/workbench/assets.d.ts.map +1 -0
  236. package/dist/lib/workbench/assets.js +44 -0
  237. package/dist/lib/workbench/assets.js.map +1 -0
  238. package/dist/lib/workbench/client.d.ts +18 -0
  239. package/dist/lib/workbench/client.d.ts.map +1 -0
  240. package/dist/lib/workbench/client.js +736 -0
  241. package/dist/lib/workbench/client.js.map +1 -0
  242. package/dist/lib/workbench/drag.d.ts +90 -0
  243. package/dist/lib/workbench/drag.d.ts.map +1 -0
  244. package/dist/lib/workbench/drag.js +109 -0
  245. package/dist/lib/workbench/drag.js.map +1 -0
  246. package/dist/lib/workbench/geometry.d.ts +28 -0
  247. package/dist/lib/workbench/geometry.d.ts.map +1 -0
  248. package/dist/lib/workbench/geometry.js +28 -0
  249. package/dist/lib/workbench/geometry.js.map +1 -0
  250. package/dist/lib/workbench/select.d.ts +56 -0
  251. package/dist/lib/workbench/select.d.ts.map +1 -0
  252. package/dist/lib/workbench/select.js +111 -0
  253. package/dist/lib/workbench/select.js.map +1 -0
  254. package/dist/lib/workbench/server.d.ts +223 -0
  255. package/dist/lib/workbench/server.d.ts.map +1 -0
  256. package/dist/lib/workbench/server.js +576 -0
  257. package/dist/lib/workbench/server.js.map +1 -0
  258. package/dist/lib/workbench/source.d.ts +124 -0
  259. package/dist/lib/workbench/source.d.ts.map +1 -0
  260. package/dist/lib/workbench/source.js +405 -0
  261. package/dist/lib/workbench/source.js.map +1 -0
  262. package/docs/README.md +49 -0
  263. package/docs/cheatsheet.md +243 -0
  264. package/docs/cli.md +95 -0
  265. package/docs/data.md +112 -0
  266. package/docs/export.md +106 -0
  267. package/docs/getting-started.md +105 -0
  268. package/docs/language.md +136 -0
  269. package/docs/layout.md +159 -0
  270. package/docs/plugins.md +82 -0
  271. package/docs/reference.md +1156 -0
  272. package/docs/roadmap.md +54 -0
  273. package/docs/syntax.md +312 -0
  274. package/docs/workbench.md +125 -0
  275. package/examples/app.dm +76 -0
  276. package/examples/assets/avatar.png +0 -0
  277. package/examples/assets/cover.png +0 -0
  278. package/examples/assets/logo.svg +4 -0
  279. package/examples/assets.dm +49 -0
  280. package/examples/dashboard.dm +64 -0
  281. package/examples/data.dm +107 -0
  282. package/examples/layout.dm +93 -0
  283. package/examples/login.dm +43 -0
  284. package/examples/login.html +61 -0
  285. package/examples/plugins/rating/README.md +67 -0
  286. package/examples/plugins/rating/example.dm +29 -0
  287. package/examples/plugins/rating/index.ts +122 -0
  288. package/examples/plugins/rating/package.json +22 -0
  289. package/examples/recipe/assets/broccoli.jpg +0 -0
  290. package/examples/recipe/assets/cheesecake.jpg +0 -0
  291. package/examples/recipe/assets/chicken-pot.jpg +0 -0
  292. package/examples/recipe/assets/noodles.jpg +0 -0
  293. package/examples/recipe/assets/shrimp.jpg +0 -0
  294. package/examples/recipe/assets/tomato-beef.jpg +0 -0
  295. package/examples/recipe/detail.dm +105 -0
  296. package/examples/recipe/discover.dm +116 -0
  297. package/examples/recipe/favorites.dm +115 -0
  298. package/examples/recipe/index.dm +124 -0
  299. package/examples/recipe/profile.dm +134 -0
  300. package/examples/recipe/steps.dm +89 -0
  301. package/examples/settings.dm +108 -0
  302. package/package.json +84 -4
  303. package/skills/designmockdown/REFERENCE.md +373 -0
  304. package/skills/designmockdown/SKILL.md +179 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * SVG renderer: turns a LayoutBox tree into an SVG string.
3
+ *
4
+ * Coordinate convention: LayoutBox x/y are relative to the parent's content origin,
5
+ * so every box is wrapped in <g transform="translate(x,y)"> and components always
6
+ * work in local coordinates (their own origin is 0,0).
7
+ */
8
+ import { layoutPage } from "../layout/engine.js";
9
+ import { callPlugin, getComponent } from "../components/registry.js";
10
+ import { DesignMockdownError } from "../core/errors.js";
11
+ import { drawChrome, drawImage, drawLines, line, overflowClip, rect, r, textEl } from "./primitives.js";
12
+ import { looksLikeAsset, loadAsset } from "./assets.js";
13
+ import { interactionAttrs } from "../runtime/proto.js";
14
+ // Single quotes inside the stack: the value is emitted inside a double-quoted XML attribute,
15
+ // and unescaped double quotes there make the whole document not well-formed
16
+ const FONT_STACK = "-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif";
17
+ /**
18
+ * How deep component renders may nest inside one another.
19
+ *
20
+ * Ordinary rendering is flat: a component's render() returns before its children are drawn, so the
21
+ * counter sits at 1. Only a render() that re-enters the renderer - typically a plugin rendering a
22
+ * document of its own - drives it up, and that is the loop this catches.
23
+ */
24
+ const MAX_RENDER_DEPTH = 64;
25
+ let renderDepth = 0;
26
+ export function renderSvg(page, theme, canvas, opts = {}) {
27
+ const root = layoutPage(page, theme, canvas);
28
+ opts.onLayout?.(root);
29
+ const defs = [
30
+ '<filter id="fab-shadow" x="-40%" y="-40%" width="180%" height="180%"><feDropShadow dx="0" dy="6" stdDeviation="10" flood-color="#0F172A" flood-opacity="0.18"/></filter>',
31
+ '<filter id="seg-shadow" x="-20%" y="-20%" width="140%" height="140%"><feDropShadow dx="0" dy="1" stdDeviation="2" flood-color="#0F172A" flood-opacity="0.10"/></filter>',
32
+ ];
33
+ let uidCounter = 0;
34
+ const baseDir = opts.baseDir ?? process.cwd();
35
+ const ctx = {
36
+ theme,
37
+ defs,
38
+ uid: (prefix) => `${prefix}-${++uidCounter}`,
39
+ interactive: opts.interactive ?? false,
40
+ baseDir,
41
+ editMode: opts.editMode ?? false,
42
+ };
43
+ const body = [];
44
+ renderBox(root, ctx, body);
45
+ const pad = opts.padding ?? 0;
46
+ const title = opts.withTitle === false ? '' : `<title>${escapeText(page.title)}</title>`;
47
+ // Page background: front-matter bg may be an image path, in which case the image covers the canvas
48
+ const bgSrc = page.meta.bg;
49
+ const bgAsset = bgSrc !== undefined && looksLikeAsset(bgSrc) ? loadAsset(bgSrc, baseDir) : undefined;
50
+ const bgLayer = bgAsset
51
+ ? drawImage({ ...root, style: { ...root.style, radius: 0 } }, bgAsset.href)
52
+ : `<rect width="${canvas.width}" height="${canvas.height}" fill="${opts.pageBg ?? theme.tokens.bg ?? '#FFFFFF'}"/>`;
53
+ // role="img" + <title> is what makes an export readable to a screen reader; without the role the
54
+ // title is announced as stray text instead of naming the image
55
+ return (`<svg xmlns="http://www.w3.org/2000/svg" width="${canvas.width}" height="${canvas.height}" ` +
56
+ `viewBox="0 0 ${canvas.width} ${canvas.height}" font-family="${FONT_STACK}" role="img">` +
57
+ title +
58
+ `<defs>${defs.join('')}</defs>` +
59
+ bgLayer +
60
+ `<g transform="translate(${pad},${pad})">${body.join('')}</g>` +
61
+ `</svg>`);
62
+ }
63
+ function escapeText(s) {
64
+ return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
65
+ }
66
+ /** Escape a value for use inside a double-quoted XML attribute */
67
+ function escapeAttr(s) {
68
+ return escapeText(s).replace(/"/g, '&quot;');
69
+ }
70
+ /** Move a box's origin to (0,0) so components can use local coordinates throughout */
71
+ function localize(box) {
72
+ if (box.x === 0 && box.y === 0)
73
+ return box;
74
+ return { ...box, x: 0, y: 0 };
75
+ }
76
+ function renderBox(box, ctx, out) {
77
+ let b = localize(box);
78
+ const op = b.style.opacity !== 1 ? ` opacity="${b.style.opacity}"` : '';
79
+ // overflow=hidden clips everything the box paints, children included
80
+ const clip = overflowClip(b);
81
+ if (clip)
82
+ ctx.defs.push(clip.def);
83
+ // Interactive mode tags clickable boxes so the prototype runtime can find them. Static exports
84
+ // stay clean: a design draft delivered as SVG should not carry dead event hooks.
85
+ const ia = ctx.interactive ? interactionAttrs(b.style.extra.onclick) : '';
86
+ // Edit mode tags every box with its AST node id so the workbench can map a click back to source
87
+ const nodeAttr = ctx.editMode && box.node ? ` data-mk-node="${escapeAttr(box.node.id)}"` : '';
88
+ out.push(`<g transform="translate(${r(box.x)},${r(box.y)})"${op}${clip?.attr ?? ''}${ia}${nodeAttr}>`);
89
+ // An invisible hit area, edit mode only. A container that paints nothing cannot be clicked at
90
+ // all (SVG hit-tests paint, not boxes), so a card's padding used to swallow the click and the
91
+ // selection simply cleared. Children are drawn later, so they still win over this backdrop.
92
+ if (ctx.editMode && box.kind !== 'page' && box.kind !== 'section') {
93
+ out.push(`<rect width="${r(b.width)}" height="${r(b.height)}" fill="none" pointer-events="all"/>`);
94
+ }
95
+ // When bg points at an image: draw the radius-clipped image inside the box's own translate group,
96
+ // then clear bg so the component only draws the border.
97
+ // This must come after <g transform> - it once came before, so the image used the parent
98
+ // coordinate system and only the first box at x=0 looked right; the rest landed in the top-left.
99
+ const bgSrc = b.style.bg;
100
+ if (bgSrc !== undefined && looksLikeAsset(bgSrc)) {
101
+ const asset = loadAsset(bgSrc, ctx.baseDir);
102
+ if (asset) {
103
+ out.push(drawImage(b, asset.href));
104
+ b = { ...b, style: { ...b.style, bg: undefined } };
105
+ }
106
+ }
107
+ switch (box.kind) {
108
+ case 'page':
109
+ case 'section':
110
+ for (const c of box.children)
111
+ renderBox(c, ctx, out);
112
+ break;
113
+ case 'text':
114
+ out.push(drawLines(b));
115
+ break;
116
+ case 'divider': {
117
+ const s = b.style;
118
+ const color = s.borderColor ?? ctx.theme.tokens.border;
119
+ const label = box.text ?? '';
120
+ const mid = b.height / 2;
121
+ if (label) {
122
+ const labelW = box.lines?.[0]?.reduce((a, t) => a + t.width, 0) ?? 0;
123
+ out.push(line(0, mid, (b.width - labelW) / 2 - 8, mid, { stroke: color, sw: 1 }));
124
+ out.push(line((b.width + labelW) / 2 + 8, mid, b.width, mid, { stroke: color, sw: 1 }));
125
+ out.push(textEl(b.width / 2, mid + s.fontSize * 0.36, label, {
126
+ size: s.fontSize,
127
+ color: ctx.theme.tokens.text3,
128
+ anchor: 'middle',
129
+ }));
130
+ }
131
+ else {
132
+ out.push(line(0, mid, b.width, mid, { stroke: color, sw: 1 }));
133
+ }
134
+ break;
135
+ }
136
+ case 'annotation': {
137
+ const s = b.style;
138
+ const pad = 10;
139
+ const h = Math.max(b.height + pad * 2, 34);
140
+ out.push(rect(0, 0, b.width, h, { rx: 6, fill: '#FFFBEB' }));
141
+ out.push(rect(0, 0, 3, h, { fill: '#F0C24B' }));
142
+ out.push(textEl(pad + 4, pad + s.fontSize * 0.85, box.text ?? '', { size: s.fontSize, color: '#92700F' }));
143
+ break;
144
+ }
145
+ default: {
146
+ const def = getComponent(box.kind);
147
+ if (def) {
148
+ // A plugin's render() that ends up rendering itself again (directly, or by rendering a
149
+ // document that contains it) would recurse until V8 gives up. Legitimate nesting adds one
150
+ // level per box and never comes near this, so the ceiling only catches real loops.
151
+ if (renderDepth >= MAX_RENDER_DEPTH) {
152
+ throw new DesignMockdownError(`@${box.kind} renders itself, ${MAX_RENDER_DEPTH} levels deep`, undefined, 'a render() must not render a document that contains the same component');
153
+ }
154
+ renderDepth++;
155
+ try {
156
+ out.push(callPlugin(box.kind, 'render', () => def.render(b, ctx)));
157
+ }
158
+ finally {
159
+ renderDepth--;
160
+ }
161
+ for (const c of box.children)
162
+ renderBox(c, ctx, out);
163
+ for (const list of Object.values(box.slots))
164
+ for (const c of list)
165
+ renderBox(c, ctx, out);
166
+ }
167
+ else {
168
+ // Unknown component: draw a placeholder frame so content is never silently dropped
169
+ out.push(drawChrome(b, { bg: ctx.theme.tokens['surface-2'], radius: 6 }));
170
+ out.push(textEl(8, b.height / 2 + 4, `@${box.kind}`, { size: 12, color: ctx.theme.tokens.text3 }));
171
+ for (const c of box.children)
172
+ renderBox(c, ctx, out);
173
+ }
174
+ break;
175
+ }
176
+ }
177
+ out.push('</g>');
178
+ }
179
+ //# sourceMappingURL=svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.js","sourceRoot":"","sources":["../../../src/render/svg.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACvG,O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,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ;oBAAE,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YACtD,CAAC;YACD,MAAK;QACP,CAAC;IACH,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAClB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Prototype interaction runtime.
3
+ *
4
+ * M2 turns a static design draft into a clickable prototype. The scope is deliberately narrow:
5
+ * navigation (`onclick=goto:page`) and simple show/hide toggles. Anything that needs real state
6
+ * (`@state`, form values, conditional re-render) is M4 and is NOT handled here.
7
+ *
8
+ * The runtime is a plain script string with no dependencies, injected into the preview shell.
9
+ * It talks to the preview server over two endpoints:
10
+ * GET /?page=<name> render another .dm in the same directory
11
+ * GET /pages.json the list of reachable page names
12
+ */
13
+ /** The client-side script, injected once per preview page */
14
+ export declare function runtimeScript(): string;
15
+ /** Mark interactive boxes so the runtime can find them and keyboard users can reach them */
16
+ export declare function interactionAttrs(onclick: unknown): string;
17
+ /** Resolve a `goto:` target to a .dm file in the same directory */
18
+ export declare function resolvePageTarget(target: string, dir: string): string | null;
19
+ //# sourceMappingURL=proto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../../src/runtime/proto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,6DAA6D;AAC7D,wBAAgB,aAAa,IAAI,MAAM,CA+CtC;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAKzD;AAMD,mEAAmE;AACnE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5E"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Prototype interaction runtime.
3
+ *
4
+ * M2 turns a static design draft into a clickable prototype. The scope is deliberately narrow:
5
+ * navigation (`onclick=goto:page`) and simple show/hide toggles. Anything that needs real state
6
+ * (`@state`, form values, conditional re-render) is M4 and is NOT handled here.
7
+ *
8
+ * The runtime is a plain script string with no dependencies, injected into the preview shell.
9
+ * It talks to the preview server over two endpoints:
10
+ * GET /?page=<name> render another .dm in the same directory
11
+ * GET /pages.json the list of reachable page names
12
+ */
13
+ /** The client-side script, injected once per preview page */
14
+ export function runtimeScript() {
15
+ return `(function () {
16
+ 'use strict';
17
+
18
+ // Elements opt in via data-mk-onclick, emitted by the SVG renderer in interactive mode.
19
+ // Delegation on document means boxes added later (or re-rendered) need no re-wiring.
20
+ document.addEventListener('click', function (e) {
21
+ var el = e.target && e.target.closest ? e.target.closest('[data-mk-onclick]') : null;
22
+ if (!el) return;
23
+ var action = el.getAttribute('data-mk-onclick') || '';
24
+ e.preventDefault();
25
+
26
+ if (action.indexOf('goto:') === 0) {
27
+ var page = action.slice(5);
28
+ if (page) window.location.search = '?page=' + encodeURIComponent(page);
29
+ return;
30
+ }
31
+ if (action === 'back') {
32
+ if (window.history.length > 1) window.history.back();
33
+ return;
34
+ }
35
+ if (action.indexOf('toggle:') === 0) {
36
+ var sel = action.slice(7);
37
+ var targets = document.querySelectorAll('[data-mk-id="' + sel + '"]');
38
+ for (var i = 0; i < targets.length; i++) {
39
+ var t = targets[i];
40
+ var hidden = t.getAttribute('data-mk-hidden') === 'true';
41
+ t.setAttribute('data-mk-hidden', hidden ? 'false' : 'true');
42
+ t.style.display = hidden ? '' : 'none';
43
+ }
44
+ return;
45
+ }
46
+ if (action.indexOf('link:') === 0) {
47
+ window.open(action.slice(5), '_blank', 'noopener');
48
+ }
49
+ });
50
+
51
+ // Keyboard reachability: a prototype is reviewed by people, not only by mouse.
52
+ // Without this, every interactive box is invisible to Tab and to screen readers.
53
+ document.addEventListener('keydown', function (e) {
54
+ if (e.key !== 'Enter' && e.key !== ' ') return;
55
+ var el = document.activeElement;
56
+ if (!el || !el.getAttribute || !el.getAttribute('data-mk-onclick')) return;
57
+ e.preventDefault();
58
+ el.click();
59
+ });
60
+ })();`;
61
+ }
62
+ /** Mark interactive boxes so the runtime can find them and keyboard users can reach them */
63
+ export function interactionAttrs(onclick) {
64
+ if (onclick === undefined || onclick === null || onclick === '')
65
+ return '';
66
+ const action = String(onclick);
67
+ // role/tabindex make the box focusable; without them Enter/Space never reach it
68
+ return ` data-mk-onclick="${escapeAttr(action)}" role="button" tabindex="0"`;
69
+ }
70
+ function escapeAttr(s) {
71
+ return s.replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
72
+ }
73
+ /** Resolve a `goto:` target to a .dm file in the same directory */
74
+ export function resolvePageTarget(target, dir) {
75
+ // Only a bare page name is allowed: a path with separators would let a draft reach outside its
76
+ // own directory, which turns the preview server into a file reader
77
+ if (!/^[A-Za-z0-9_-]+$/.test(target))
78
+ return null;
79
+ return `${dir}/${target}.dm`;
80
+ }
81
+ //# sourceMappingURL=proto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto.js","sourceRoot":"","sources":["../../../src/runtime/proto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,6DAA6D;AAC7D,MAAM,UAAU,aAAa;IAC3B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6CH,CAAA;AACN,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAA;IAC1E,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAC9B,gFAAgF;IAChF,OAAO,qBAAqB,UAAU,CAAC,MAAM,CAAC,8BAA8B,CAAA;AAC9E,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AAC7G,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,GAAW;IAC3D,+FAA+F;IAC/F,mEAAmE;IACnE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IACjD,OAAO,GAAG,GAAG,IAAI,MAAM,KAAK,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The skill ships inside the package (`skills/designmockdown`), and this module moves it into a
3
+ * directory an agent actually watches.
4
+ *
5
+ * Two decisions worth keeping:
6
+ *
7
+ * - **Copy by default, link on request.** A package install is read-only in practice (npm replaces
8
+ * the directory on update), so a link from `~/.LingXi/skills` into `node_modules` would dangle
9
+ * after the next `npm i`. Inside this repository the opposite is true: linking means editing
10
+ * `SKILL.md` takes effect in the next session instead of silently ageing a copy.
11
+ * - **Only remove what looks like ours.** An existing directory is replaced only when it holds a
12
+ * `SKILL.md`; anything else means the user put it there, and the install stops.
13
+ */
14
+ export declare const SKILL_NAME = "designmockdown";
15
+ /** Where the shipped skill lives - inside the package, so `npm i designmockdown` carries it too */
16
+ export declare function skillDir(): string;
17
+ /** NearWork reads `$LINGXI_HOME/skills`; a single repository can keep its own under `.lingxi/skills` */
18
+ export declare function defaultSkillsDir(project: boolean): string;
19
+ export interface InstallResult {
20
+ /** The skill directory an agent reads */
21
+ target: string;
22
+ /** True when a junction/symlink was made, false when the files were copied */
23
+ linked: boolean;
24
+ }
25
+ export declare function installSkill(targetDir: string, opts?: {
26
+ link?: boolean;
27
+ }): InstallResult;
28
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/skill/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,eAAO,MAAM,UAAU,mBAAmB,CAAA;AAK1C,mGAAmG;AACnG,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED,wGAAwG;AACxG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAIzD;AAED,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,8EAA8E;IAC9E,MAAM,EAAE,OAAO,CAAA;CAChB;AAqCD,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,aAAa,CAmB5F"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The skill ships inside the package (`skills/designmockdown`), and this module moves it into a
3
+ * directory an agent actually watches.
4
+ *
5
+ * Two decisions worth keeping:
6
+ *
7
+ * - **Copy by default, link on request.** A package install is read-only in practice (npm replaces
8
+ * the directory on update), so a link from `~/.LingXi/skills` into `node_modules` would dangle
9
+ * after the next `npm i`. Inside this repository the opposite is true: linking means editing
10
+ * `SKILL.md` takes effect in the next session instead of silently ageing a copy.
11
+ * - **Only remove what looks like ours.** An existing directory is replaced only when it holds a
12
+ * `SKILL.md`; anything else means the user put it there, and the install stops.
13
+ */
14
+ import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, rmSync, symlinkSync } from 'node:fs';
15
+ import { execFileSync } from 'node:child_process';
16
+ import { homedir } from 'node:os';
17
+ import { join, resolve } from 'node:path';
18
+ import { packageRootOf } from "../paths.js";
19
+ export const SKILL_NAME = 'designmockdown';
20
+ /** Files the skill needs; anything else in the directory is not part of the contract */
21
+ const FILES = ['SKILL.md', 'REFERENCE.md'];
22
+ /** Where the shipped skill lives - inside the package, so `npm i designmockdown` carries it too */
23
+ export function skillDir() {
24
+ return join(packageRootOf(import.meta.url), 'skills', SKILL_NAME);
25
+ }
26
+ /** NearWork reads `$LINGXI_HOME/skills`; a single repository can keep its own under `.lingxi/skills` */
27
+ export function defaultSkillsDir(project) {
28
+ if (project)
29
+ return resolve(process.cwd(), '.lingxi', 'skills');
30
+ const home = process.env.LINGXI_HOME ?? join(homedir(), '.LingXi');
31
+ return join(home, 'skills');
32
+ }
33
+ function exists(path) {
34
+ try {
35
+ lstatSync(path);
36
+ return true;
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ function clearTarget(target) {
43
+ if (!exists(target))
44
+ return;
45
+ if (lstatSync(target).isSymbolicLink()) {
46
+ rmSync(target, { force: true });
47
+ return;
48
+ }
49
+ if (!lstatSync(target).isDirectory()) {
50
+ throw new Error(`${target} exists and is not a directory; refusing to touch it`);
51
+ }
52
+ if (!existsSync(join(target, 'SKILL.md'))) {
53
+ throw new Error(`${target} exists and does not look like an installed skill; refusing to touch it`);
54
+ }
55
+ rmSync(target, { recursive: true, force: true });
56
+ }
57
+ function link(source, target) {
58
+ try {
59
+ // A junction works without elevation on Windows; a symlink does not
60
+ if (process.platform === 'win32')
61
+ execFileSync('cmd', ['/c', 'mklink', '/J', target, source], { stdio: 'pipe' });
62
+ else
63
+ symlinkSync(source, target, 'dir');
64
+ return true;
65
+ }
66
+ catch {
67
+ return false;
68
+ }
69
+ }
70
+ export function installSkill(targetDir, opts = {}) {
71
+ const source = skillDir();
72
+ if (!existsSync(join(source, 'SKILL.md')))
73
+ throw new Error(`the package is missing its skill at ${source}`);
74
+ mkdirSync(targetDir, { recursive: true });
75
+ const target = join(targetDir, SKILL_NAME);
76
+ clearTarget(target);
77
+ const linked = opts.link === true ? link(source, target) : false;
78
+ if (!linked) {
79
+ mkdirSync(target, { recursive: true });
80
+ for (const file of FILES)
81
+ copyFileSync(join(source, file), join(target, file));
82
+ }
83
+ // Verify through the target path: a link that resolves nowhere would still look installed
84
+ if (!readFileSync(join(target, 'SKILL.md'), 'utf8').startsWith('---')) {
85
+ throw new Error('installed SKILL.md does not look like a skill');
86
+ }
87
+ return { target, linked };
88
+ }
89
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/skill/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC3G,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAE1C,wFAAwF;AACxF,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,cAAc,CAAU,CAAA;AAEnD,mGAAmG;AACnG,MAAM,UAAU,QAAQ;IACtB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;AACnE,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;IAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IAClE,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC;AASD,SAAS,MAAM,CAAC,IAAY;IAC1B,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,CAAA;QACf,OAAO,IAAI,CAAA;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G,QAAQ,EAAE,CAAA;IACzB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAA;IAE3G,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAC1C,WAAW,CAAC,MAAM,CAAC,CAAA;IAEnB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAChE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACtC,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;IAChF,CAAC;IAED,0FAA0F;IAC1F,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Static access to the built canvas app.
3
+ *
4
+ * Vite writes the bundle to dist/app. The server reads it from disk at request time instead of
5
+ * bundling the front-end into the Node process, so rebuilding the app does not require restarting
6
+ * the workbench.
7
+ *
8
+ * The directory is located relative to the package root rather than to this file: the same
9
+ * module runs from `src/workbench/app.ts` (no build step) and from `dist/lib/workbench/app.js`
10
+ * (published package), and a fixed `../../dist/app` would point at `dist/dist/app` once emitted.
11
+ */
12
+ export declare function appDir(): string;
13
+ /**
14
+ * Read a file below dist/app.
15
+ *
16
+ * `requestPath` comes from the URL, so the resolved path is checked against the app root: anything
17
+ * that escapes it (via `..` or an absolute path) is refused, which keeps this from becoming an
18
+ * arbitrary file reader.
19
+ */
20
+ export declare function readAppAsset(requestPath: string): {
21
+ path: string;
22
+ body: Buffer;
23
+ } | null;
24
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/workbench/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAavF"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Static access to the built canvas app.
3
+ *
4
+ * Vite writes the bundle to dist/app. The server reads it from disk at request time instead of
5
+ * bundling the front-end into the Node process, so rebuilding the app does not require restarting
6
+ * the workbench.
7
+ *
8
+ * The directory is located relative to the package root rather than to this file: the same
9
+ * module runs from `src/workbench/app.ts` (no build step) and from `dist/lib/workbench/app.js`
10
+ * (published package), and a fixed `../../dist/app` would point at `dist/dist/app` once emitted.
11
+ */
12
+ import { existsSync, readFileSync, statSync } from 'node:fs';
13
+ import { resolve as pathResolve, sep } from 'node:path';
14
+ import { packageRootOf } from "../paths.js";
15
+ const DIR = pathResolve(packageRootOf(import.meta.url), 'dist', 'app');
16
+ export function appDir() {
17
+ return DIR;
18
+ }
19
+ /**
20
+ * Read a file below dist/app.
21
+ *
22
+ * `requestPath` comes from the URL, so the resolved path is checked against the app root: anything
23
+ * that escapes it (via `..` or an absolute path) is refused, which keeps this from becoming an
24
+ * arbitrary file reader.
25
+ */
26
+ export function readAppAsset(requestPath) {
27
+ const clean = requestPath.replace(/\\/g, '/').replace(/^\/+/, '');
28
+ if (clean === '' || clean.includes('\0'))
29
+ return null;
30
+ const root = DIR.endsWith(sep) ? DIR : DIR + sep;
31
+ const full = pathResolve(DIR, clean);
32
+ if (full !== DIR && !full.startsWith(root))
33
+ return null;
34
+ if (!existsSync(full))
35
+ return null;
36
+ try {
37
+ if (!statSync(full).isFile())
38
+ return null;
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ return { path: clean, body: readFileSync(full) };
44
+ }
45
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/workbench/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,GAAG,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAEtE,MAAM,UAAU,MAAM;IACpB,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACjE,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACrD,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAA;IAChD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACpC,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAClC,IAAI,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;YAAE,OAAO,IAAI,CAAA;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAA;AAClD,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * CodeMirror assets, read from node_modules and served as static files.
3
+ *
4
+ * The project has no build step - `node src/cli.ts` runs the TypeScript directly - so the editor
5
+ * has to be a bundle that works as-is in a browser. CodeMirror 5 ships a UMD build, which is the
6
+ * same shape as bootstrap-icons: a file on disk that gets read and served, with no bundler and no
7
+ * second copy of the code in the repository.
8
+ *
9
+ * CodeMirror 6 would be nicer, but it is pure ESM with bare module specifiers, and using it would
10
+ * mean adding a bundler. That is a much bigger change to the project than the editor is worth.
11
+ */
12
+ export interface EditorAsset {
13
+ path: string;
14
+ body: string;
15
+ contentType: string;
16
+ }
17
+ /** The JS and CSS the shell asks for, or an empty list when the package is missing */
18
+ export declare function editorAssets(): EditorAsset[];
19
+ /** True when the editor package is installed, so the CLI can warn early */
20
+ export declare function hasEditor(): boolean;
21
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/workbench/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkBH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,sFAAsF;AACtF,wBAAgB,YAAY,IAAI,WAAW,EAAE,CAS5C;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,IAAI,OAAO,CAEnC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * CodeMirror assets, read from node_modules and served as static files.
3
+ *
4
+ * The project has no build step - `node src/cli.ts` runs the TypeScript directly - so the editor
5
+ * has to be a bundle that works as-is in a browser. CodeMirror 5 ships a UMD build, which is the
6
+ * same shape as bootstrap-icons: a file on disk that gets read and served, with no bundler and no
7
+ * second copy of the code in the repository.
8
+ *
9
+ * CodeMirror 6 would be nicer, but it is pure ESM with bare module specifiers, and using it would
10
+ * mean adding a bundler. That is a much bigger change to the project than the editor is worth.
11
+ */
12
+ import { existsSync, readFileSync } from 'node:fs';
13
+ import { createRequire } from 'node:module';
14
+ import { join } from 'node:path';
15
+ const require = createRequire(import.meta.url);
16
+ /** Locate the codemirror package, or null when it is not installed */
17
+ function packageDir() {
18
+ try {
19
+ // resolve() returns a native path on Windows, so it must not go through fileURLToPath
20
+ return join(require.resolve('codemirror/package.json'), '..');
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ /** The JS and CSS the shell asks for, or an empty list when the package is missing */
27
+ export function editorAssets() {
28
+ const dir = packageDir();
29
+ if (!dir)
30
+ return [];
31
+ const out = [];
32
+ const js = join(dir, 'lib', 'codemirror.js');
33
+ const css = join(dir, 'lib', 'codemirror.css');
34
+ if (existsSync(js))
35
+ out.push({ path: '/vendor/codemirror.js', body: readFileSync(js, 'utf8'), contentType: 'text/javascript' });
36
+ if (existsSync(css))
37
+ out.push({ path: '/vendor/codemirror.css', body: readFileSync(css, 'utf8'), contentType: 'text/css' });
38
+ return out;
39
+ }
40
+ /** True when the editor package is installed, so the CLI can warn early */
41
+ export function hasEditor() {
42
+ return packageDir() !== null;
43
+ }
44
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["../../../src/workbench/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,sEAAsE;AACtE,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,sFAAsF;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE,IAAI,CAAC,CAAA;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAQD,sFAAsF;AACtF,MAAM,UAAU,YAAY;IAC1B,MAAM,GAAG,GAAG,UAAU,EAAE,CAAA;IACxB,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAA;IACnB,MAAM,GAAG,GAAkB,EAAE,CAAA;IAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,eAAe,CAAC,CAAA;IAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAA;IAC9C,IAAI,UAAU,CAAC,EAAE,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC,CAAA;IAC/H,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;IAC3H,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,EAAE,KAAK,IAAI,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The workbench client script, served as a single string.
3
+ *
4
+ * Plain JavaScript with no framework. It owns three things:
5
+ * - the infinite canvas (pan / zoom / frame placement)
6
+ * - selection (canvas click → property panel → source line)
7
+ * - the edit loop (panel or drag → POST /api/edit → new SVG)
8
+ *
9
+ * The server is the source of truth: this script never parses DesignMockdown and never keeps an AST. It
10
+ * sends an edit, gets back a fresh SVG plus the target list, and redraws. That is why a bad edit
11
+ * costs one round trip instead of a desynchronised canvas.
12
+ *
13
+ * The line-level source helpers at the bottom mirror src/workbench/source.ts. They exist so a panel
14
+ * edit can be expressed as one line replacement in a single round trip; the server re-parses the
15
+ * result and is the authority on what the line means.
16
+ */
17
+ export declare function clientScript(): string;
18
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/workbench/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,YAAY,IAAI,MAAM,CA8sBrC"}