@wireweave/core 4.0.0-beta.12 → 4.0.0-beta.14

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 (53) hide show
  1. package/dist/app.cjs +51 -31
  2. package/dist/app.d.cts +5 -145
  3. package/dist/app.d.ts +5 -145
  4. package/dist/app.js +2 -31
  5. package/dist/{chunk-QOS4IC75.js → chunk-2Y3GKARZ.js} +16 -1354
  6. package/dist/chunk-3RWGG5EC.js +296 -342
  7. package/dist/chunk-4DDV6Z2X.js +389 -0
  8. package/dist/chunk-ETV4XYOV.cjs +4 -6
  9. package/dist/chunk-IMUVIIJR.cjs +317 -354
  10. package/dist/chunk-LA5LKIEL.cjs +396 -0
  11. package/dist/chunk-MD6MNOEQ.cjs +121 -142
  12. package/dist/chunk-NV6UV5ID.cjs +2145 -0
  13. package/dist/chunk-PKBMQBKP.js +1 -3
  14. package/dist/{chunk-7VTK6LHL.cjs → chunk-SAN6CJEE.cjs} +96 -1421
  15. package/dist/chunk-TQSOLTMZ.js +2132 -0
  16. package/dist/chunk-V3HVWC7C.js +1 -32
  17. package/dist/chunk-XYACLXXF.js +4 -132
  18. package/dist/chunk-ZPHNXJRY.cjs +158 -180
  19. package/dist/index-BD_4rXH-.d.cts +1031 -0
  20. package/dist/{index-Br7pNaf3.d.cts → index-BEnsO2kE.d.ts} +144 -2
  21. package/dist/{index-G906GEtg.d.cts → index-BlNYFaZd.d.cts} +2 -2
  22. package/dist/{index-CghCKUPx.d.ts → index-Cx4-VXVS.d.ts} +2 -2
  23. package/dist/{index-Da_B3eoM.d.ts → index-YSIzfhOd.d.cts} +144 -2
  24. package/dist/index-g9yV20xb.d.ts +1031 -0
  25. package/dist/index.cjs +939 -429
  26. package/dist/index.d.cts +16 -193
  27. package/dist/index.d.ts +16 -193
  28. package/dist/index.js +210 -396
  29. package/dist/interaction.cjs +26 -17
  30. package/dist/interaction.d.cts +2 -2
  31. package/dist/interaction.d.ts +2 -2
  32. package/dist/interaction.js +1 -17
  33. package/dist/parser.cjs +38 -21
  34. package/dist/parser.d.cts +3 -3
  35. package/dist/parser.d.ts +3 -3
  36. package/dist/parser.js +1 -21
  37. package/dist/renderer.cjs +124 -68
  38. package/dist/renderer.d.cts +4 -756
  39. package/dist/renderer.d.ts +4 -756
  40. package/dist/renderer.js +3 -68
  41. package/dist/spec.cjs +94 -49
  42. package/dist/spec.js +1 -49
  43. package/dist/{types-vhPCZpAW.d.cts → types-CGRi1k2N.d.cts} +1 -1
  44. package/dist/{types-vhPCZpAW.d.ts → types-CGRi1k2N.d.ts} +1 -1
  45. package/dist/{v4-types-Baz9yqAS.d.cts → v4-types-2ORUg6To.d.cts} +1 -1
  46. package/dist/{v4-types-Baz9yqAS.d.ts → v4-types-2ORUg6To.d.ts} +1 -1
  47. package/package.json +21 -23
  48. package/dist/chunk-4TMDPWPR.cjs +0 -196
  49. package/dist/chunk-5DGRIQDU.cjs +0 -842
  50. package/dist/chunk-JJWAFHSV.js +0 -842
  51. package/dist/chunk-R5WBZWBC.js +0 -196
  52. package/dist/chunk-WV724EAW.js +0 -0
  53. package/dist/chunk-XENFKHRC.cjs +0 -1
@@ -1,196 +0,0 @@
1
- import {
2
- expandVariants
3
- } from "./chunk-JJWAFHSV.js";
4
- import {
5
- HtmlRenderer,
6
- createHtmlRenderer,
7
- darkTheme,
8
- defaultTheme,
9
- documentPages,
10
- generateStyles,
11
- resolvePageDimensions
12
- } from "./chunk-XYACLXXF.js";
13
-
14
- // src/renderer/canvas-renderer.ts
15
- var DEFAULT_GAP = 64;
16
- var DEFAULT_PREFIX = "wf";
17
- function layoutCanvas(pages, gap = DEFAULT_GAP) {
18
- const placed = [];
19
- let cursorX = 0;
20
- let maxRight = 0;
21
- let maxBottom = 0;
22
- for (const page of pages) {
23
- const { width, height } = resolvePageDimensions(page);
24
- const explicitX = typeof page.x === "number" ? page.x : void 0;
25
- const explicitY = typeof page.y === "number" ? page.y : void 0;
26
- const x = explicitX != null ? explicitX : cursorX;
27
- const y = explicitY != null ? explicitY : 0;
28
- placed.push({ page, x, y, w: width, h: height });
29
- if (explicitX === void 0) {
30
- cursorX = x + width + gap;
31
- }
32
- maxRight = Math.max(maxRight, x + width);
33
- maxBottom = Math.max(maxBottom, y + height);
34
- }
35
- return { placed, width: maxRight, height: maxBottom };
36
- }
37
- function renderCanvas(doc, options = {}) {
38
- var _a, _b;
39
- const gap = (_a = options.gap) != null ? _a : DEFAULT_GAP;
40
- const prefix = (_b = options.classPrefix) != null ? _b : DEFAULT_PREFIX;
41
- const includeStyles = options.includeStyles !== false;
42
- const theme = options.theme === "dark" ? darkTheme : defaultTheme;
43
- const css = includeStyles ? generateStyles(theme, prefix, options.annotationStyle) : "";
44
- const pages = documentPages(doc);
45
- if (pages.length === 0) {
46
- return {
47
- html: `<div class="${prefix}-canvas" data-empty="true"></div>`,
48
- css,
49
- width: 0,
50
- height: 0
51
- };
52
- }
53
- const { placed, width, height } = layoutCanvas(pages, gap);
54
- const boards = placed.map((p, pageIndex) => {
55
- const pageRenderer = new HtmlRenderer({ ...options, includeStyles: false }, pageIndex);
56
- const { html: pageHtml } = pageRenderer.render({
57
- type: "Document",
58
- children: [p.page]
59
- });
60
- return wrapBoard(pageHtml, p, prefix);
61
- }).join("\n");
62
- const canvasStyle = `position: relative; width: ${width}px; height: ${height}px;`;
63
- const html = `<div class="${prefix}-canvas" style="${canvasStyle}" data-page-count="${placed.length}">
64
- ${boards}
65
- </div>`;
66
- return { html, css, width, height };
67
- }
68
- function wrapBoard(pageHtml, placed, prefix) {
69
- const { x, y, w, h, page } = placed;
70
- const positionStyle = `position: absolute; left: ${x}px; top: ${y}px; width: ${w}px; height: ${h}px;`;
71
- const titleAttr = page.title ? ` data-page-title="${escapeAttr(page.title)}"` : "";
72
- const variantAttr = page.variant ? ` data-wf-variant="${escapeAttr(page.variant)}"` : "";
73
- const dataAttrs = ` data-page-x="${x}" data-page-y="${y}" data-page-w="${w}" data-page-h="${h}"${titleAttr}${variantAttr}`;
74
- return `<div class="${prefix}-canvas-board" style="${positionStyle}"${dataAttrs}>
75
- ${pageHtml}
76
- </div>`;
77
- }
78
- function escapeAttr(s) {
79
- return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
80
- }
81
-
82
- // src/renderer/index.ts
83
- function render(document, options = {}) {
84
- document = expandVariants(document);
85
- const isMultiPage = documentPages(document).length > 1;
86
- if (isMultiPage) {
87
- const result = renderCanvas(document, options);
88
- return { html: result.html, css: result.css };
89
- }
90
- const renderer = createHtmlRenderer(options);
91
- return renderer.render(document);
92
- }
93
- function renderToHtml(document, options = {}) {
94
- var _a;
95
- document = expandVariants(document);
96
- const { html, css } = render(document, options);
97
- const prefix = (_a = options.classPrefix) != null ? _a : "wf";
98
- const isMultiPage = documentPages(document).length > 1;
99
- const bodyAlign = isMultiPage ? "justify-content: flex-start;\n align-items: flex-start;" : "justify-content: center;\n align-items: center;";
100
- return `<!DOCTYPE html>
101
- <html lang="en">
102
- <head>
103
- <meta charset="UTF-8">
104
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
105
- <title>Wireframe</title>
106
- <style>
107
- /* Viewport framing: center a single page, anchor a multi-page canvas top-left */
108
- html, body {
109
- margin: 0;
110
- padding: 0;
111
- min-height: 100vh;
112
- background: #f4f4f5;
113
- }
114
- body {
115
- display: flex;
116
- ${bodyAlign}
117
- padding: 24px;
118
- box-sizing: border-box;
119
- }
120
- /* Fixed-layout invariant: the multi-page canvas is a flex item of <body> and
121
- must keep its intrinsic size when the viewport is narrower than the canvas.
122
- Without flex-shrink:0 the flex item shrinks and the boards reflow \u2014 the same
123
- defect class as .wf-page (see no-responsive.md). Single pages already carry
124
- flex-shrink:0 via generateStyles; the canvas wrapper needs it here. */
125
- .${prefix}-canvas {
126
- flex-shrink: 0;
127
- }
128
- ${css}
129
- </style>
130
- </head>
131
- <body>
132
- ${html}
133
- </body>
134
- </html>`;
135
- }
136
- function renderToSvg(document, options = {}) {
137
- var _a, _b, _c, _d, _e;
138
- document = expandVariants(document);
139
- const isMultiPage = documentPages(document).length > 1;
140
- let width = (_a = options.width) != null ? _a : 800;
141
- let height = (_b = options.height) != null ? _b : 600;
142
- let html;
143
- let css;
144
- if (isMultiPage) {
145
- const canvas = renderCanvas(document, {
146
- theme: (_c = options.theme) != null ? _c : "light"
147
- });
148
- if (options.width === void 0 && options.height === void 0) {
149
- width = canvas.width;
150
- height = canvas.height;
151
- }
152
- html = canvas.html;
153
- css = canvas.css;
154
- } else {
155
- const firstPage = documentPages(document)[0];
156
- if (firstPage && options.width === void 0 && options.height === void 0) {
157
- const dims = resolvePageDimensions(firstPage);
158
- width = dims.width;
159
- height = dims.height;
160
- }
161
- const result = render(document, { theme: (_d = options.theme) != null ? _d : "light" });
162
- html = result.html;
163
- css = result.css;
164
- }
165
- const background = (_e = options.background) != null ? _e : "#ffffff";
166
- const svg = `<?xml version="1.0" encoding="UTF-8"?>
167
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
168
- viewBox="0 0 ${width} ${height}" width="${width}" height="${height}">
169
- <rect width="100%" height="100%" fill="${background}"/>
170
- <foreignObject x="0" y="0" width="${width}" height="${height}">
171
- <div xmlns="http://www.w3.org/1999/xhtml" style="
172
- width: ${width}px;
173
- height: ${height}px;
174
- overflow: hidden;
175
- display: flex;
176
- justify-content: center;
177
- align-items: center;
178
- box-sizing: border-box;
179
- ">
180
- <style type="text/css">
181
- ${css}
182
- </style>
183
- ${html}
184
- </div>
185
- </foreignObject>
186
- </svg>`;
187
- return { svg, width, height };
188
- }
189
-
190
- export {
191
- layoutCanvas,
192
- renderCanvas,
193
- render,
194
- renderToHtml,
195
- renderToSvg
196
- };
File without changes
@@ -1 +0,0 @@
1
- "use strict";