@wireweave/core 4.0.0-beta.0 → 4.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -462
- package/dist/app.cjs +50 -0
- package/dist/app.d.cts +488 -0
- package/dist/app.d.ts +488 -0
- package/dist/app.js +1 -0
- package/dist/chunk-3RWGG5EC.js +18042 -0
- package/dist/chunk-4TMDPWPR.cjs +186 -0
- package/dist/chunk-4UZBGIGJ.cjs +4359 -0
- package/dist/chunk-5DGRIQDU.cjs +824 -0
- package/dist/chunk-ETV4XYOV.cjs +5 -0
- package/dist/chunk-FS6A6EJ4.js +4345 -0
- package/dist/chunk-IMUVIIJR.cjs +18051 -0
- package/dist/chunk-JJWAFHSV.js +821 -0
- package/dist/chunk-MD6MNOEQ.cjs +2884 -0
- package/dist/chunk-PKBMQBKP.js +5 -0
- package/dist/chunk-R5WBZWBC.js +180 -0
- package/dist/chunk-V3HVWC7C.js +2874 -0
- package/dist/chunk-XYACLXXF.js +51484 -0
- package/dist/chunk-ZPHNXJRY.cjs +51590 -0
- package/dist/index-BGU_4N4W.d.ts +240 -0
- package/dist/index-BlNYFaZd.d.cts +337 -0
- package/dist/index-Cx4-VXVS.d.ts +337 -0
- package/dist/index-DyXaMSgd.d.cts +240 -0
- package/dist/index.cjs +1844 -58238
- package/dist/index.d.cts +556 -102
- package/dist/index.d.ts +556 -102
- package/dist/index.js +1163 -58104
- package/dist/interaction.cjs +26 -0
- package/dist/interaction.d.cts +3 -0
- package/dist/interaction.d.ts +3 -0
- package/dist/interaction.js +1 -0
- package/dist/parser.cjs +34 -6611
- package/dist/parser.d.cts +11 -2
- package/dist/parser.d.ts +11 -2
- package/dist/parser.js +1 -6585
- package/dist/renderer.cjs +119 -50537
- package/dist/renderer.d.cts +348 -123
- package/dist/renderer.d.ts +348 -123
- package/dist/renderer.js +3 -50499
- package/dist/spec.cjs +94 -0
- package/dist/spec.d.cts +301 -0
- package/dist/spec.d.ts +301 -0
- package/dist/spec.js +1 -0
- package/dist/{types-hEr_afgw.d.cts → types-CGRi1k2N.d.cts} +307 -27
- package/dist/{types-hEr_afgw.d.ts → types-CGRi1k2N.d.ts} +307 -27
- package/dist/types-Dkgr0Wyc.d.cts +75 -0
- package/dist/types-Dkgr0Wyc.d.ts +75 -0
- package/dist/v4-types-2ORUg6To.d.cts +137 -0
- package/dist/v4-types-2ORUg6To.d.ts +137 -0
- package/package.json +112 -35
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import { INTERACTIVE_ATTR_NAMES, filterUnscopedPages, filterVariantScope, expandRepeats, buildSiteModel, collectInteractions, darkTheme, defaultTheme, generateStyles, resolvePageDimensions, HtmlRenderer, VISIBLE_GUARD_ATTR, ENABLED_GUARD_ATTR, VARIANT_SCOPE_ATTR, EXTERNAL_NAVIGATE_ATTR, TYPED_INTERACTION_ATTR, INERT_HREF } from './chunk-XYACLXXF.js';
|
|
2
|
+
|
|
3
|
+
// src/ast/expand-variants.ts
|
|
4
|
+
function cloneNode(value) {
|
|
5
|
+
if (Array.isArray(value)) return value.map(cloneNode);
|
|
6
|
+
if (value === null || typeof value !== "object") return value;
|
|
7
|
+
const source = value;
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const [key, item] of Object.entries(source)) {
|
|
10
|
+
result[key] = key === "loc" ? item : cloneNode(item);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
function variantNames(page) {
|
|
15
|
+
const declared = page.variants;
|
|
16
|
+
if (!Array.isArray(declared)) return [];
|
|
17
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18
|
+
const names = [];
|
|
19
|
+
for (const raw of declared) {
|
|
20
|
+
if (typeof raw !== "string") continue;
|
|
21
|
+
const name = raw.trim();
|
|
22
|
+
if (name.length === 0 || seen.has(name)) continue;
|
|
23
|
+
seen.add(name);
|
|
24
|
+
names.push(name);
|
|
25
|
+
}
|
|
26
|
+
return names;
|
|
27
|
+
}
|
|
28
|
+
function hasVariants(document) {
|
|
29
|
+
return document.children.some((child) => child.type === "Page" && variantNames(child).length > 0);
|
|
30
|
+
}
|
|
31
|
+
function expandVariants(document) {
|
|
32
|
+
if (!hasVariants(document)) return filterUnscopedPages(document);
|
|
33
|
+
return {
|
|
34
|
+
...document,
|
|
35
|
+
children: document.children.flatMap((child) => {
|
|
36
|
+
if (child.type !== "Page") return [child];
|
|
37
|
+
const names = variantNames(child);
|
|
38
|
+
if (names.length === 0) {
|
|
39
|
+
const filtered = filterVariantScope(child.children, void 0);
|
|
40
|
+
return [filtered === child.children ? child : { ...child, children: filtered }];
|
|
41
|
+
}
|
|
42
|
+
return names.map((variant, position) => {
|
|
43
|
+
const clone = cloneNode(child);
|
|
44
|
+
delete clone.variants;
|
|
45
|
+
clone.variant = variant;
|
|
46
|
+
if (position > 0) delete clone.states;
|
|
47
|
+
clone.children = filterVariantScope(clone.children, variant);
|
|
48
|
+
return clone;
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/renderer/site/styles.ts
|
|
55
|
+
function generateSiteStyles(prefix) {
|
|
56
|
+
return `
|
|
57
|
+
/* ===== Site composition (renderSite) ===== */
|
|
58
|
+
|
|
59
|
+
.${prefix}-site {
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
align-items: flex-start;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* A shell and a standalone screen are both top-level frames: exactly one of
|
|
66
|
+
them is on at a time. Screens inside a shell switch within it. */
|
|
67
|
+
.${prefix}-site > .${prefix}-shell,
|
|
68
|
+
.${prefix}-site > .${prefix}-screen {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.${prefix}-site > .${prefix}-shell.${prefix}-on {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.${prefix}-site > .${prefix}-screen.${prefix}-on {
|
|
78
|
+
display: block;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* A site document is a running prototype, not a canvas thumbnail. The page
|
|
82
|
+
renderer sizes a page to its authored viewport and clips what runs past it
|
|
83
|
+
with an inline \`overflow: hidden\` \u2014 right for a thumbnail, where a page is a
|
|
84
|
+
picture, and wrong here, where it is a screen someone is using: a settings
|
|
85
|
+
page authored 14x taller than its viewport would keep 93% of itself
|
|
86
|
+
unreachable. The frame stays exactly as authored and only the overflow
|
|
87
|
+
becomes reachable. \`!important\` is unavoidable and confined to this rule:
|
|
88
|
+
the declaration being overridden is inline. */
|
|
89
|
+
.${prefix}-site .${prefix}-page {
|
|
90
|
+
overflow: auto !important;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* The slot is where a layout hands its frame over to page content, so it takes
|
|
94
|
+
the space a page's own root would have taken. */
|
|
95
|
+
.${prefix}-site .${prefix}-slot {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
flex: 1;
|
|
99
|
+
min-height: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.${prefix}-site .${prefix}-slot > .${prefix}-screen {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.${prefix}-site .${prefix}-slot > .${prefix}-screen.${prefix}-on {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
flex: 1;
|
|
110
|
+
min-height: 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Page-root layout rules key off \`.${prefix}-page > \u2026\`. A screen composed into
|
|
114
|
+
a shell is one level further in, so the same rules are restated for it \u2014
|
|
115
|
+
otherwise a sidebar row would stop filling its frame the moment a page
|
|
116
|
+
started using a layout. */
|
|
117
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-col {
|
|
118
|
+
flex: 1;
|
|
119
|
+
min-height: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-row:has(.${prefix}-sidebar),
|
|
123
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-row:has(.${prefix}-main),
|
|
124
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-col > .${prefix}-row:has(.${prefix}-sidebar),
|
|
125
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-col > .${prefix}-row:has(.${prefix}-main) {
|
|
126
|
+
flex: 1;
|
|
127
|
+
min-height: 0;
|
|
128
|
+
align-items: stretch;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Overlays something opens start closed; overlays nothing opens are part of
|
|
132
|
+
the screen as drawn and never get this class. Two class selectors so the
|
|
133
|
+
rule outranks \`.${prefix}-modal-backdrop\` / \`.${prefix}-drawer\` on
|
|
134
|
+
specificity, not only on order. */
|
|
135
|
+
.${prefix}-site .${prefix}-closed {
|
|
136
|
+
display: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* State guards use the native hidden/disabled semantics. Component display
|
|
140
|
+
rules can be more specific than the browser stylesheet, so hidden is held at
|
|
141
|
+
the site boundary explicitly. */
|
|
142
|
+
.${prefix}-site [hidden] {
|
|
143
|
+
display: none !important;
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/renderer/site/runtime.ts
|
|
149
|
+
var ID_SCOPE_ATTR = "data-id-scope";
|
|
150
|
+
var [NAVIGATE_ATTR, OPENS_ATTR, TOGGLES_ATTR, ACTION_ATTR] = INTERACTIVE_ATTR_NAMES;
|
|
151
|
+
function embedJson(value) {
|
|
152
|
+
return JSON.stringify(value).replace(/</g, "\\u003C");
|
|
153
|
+
}
|
|
154
|
+
function siteRuntime(registry, prefix) {
|
|
155
|
+
return `(function () {
|
|
156
|
+
'use strict';
|
|
157
|
+
var P = ${embedJson(prefix)};
|
|
158
|
+
var R = ${embedJson(registry)};
|
|
159
|
+
var ON = P + '-on';
|
|
160
|
+
var CLOSED = P + '-closed';
|
|
161
|
+
var NAV_ACTIVE = P + '-nav-link-active';
|
|
162
|
+
var site = document.querySelector('.' + P + '-site');
|
|
163
|
+
if (!site) return;
|
|
164
|
+
|
|
165
|
+
var screens = {};
|
|
166
|
+
var order = [];
|
|
167
|
+
var shellOf = {};
|
|
168
|
+
var hosts = site.querySelectorAll('[data-screen]');
|
|
169
|
+
for (var i = 0; i < hosts.length; i++) {
|
|
170
|
+
var key = hosts[i].getAttribute('data-screen');
|
|
171
|
+
// First-wins: two pages can share a name, and the model already decided
|
|
172
|
+
// which one that name resolves to. The DOM must not disagree with it.
|
|
173
|
+
if (!Object.prototype.hasOwnProperty.call(screens, key)) {
|
|
174
|
+
screens[key] = hosts[i];
|
|
175
|
+
order.push(key);
|
|
176
|
+
shellOf[key] = shellFor(hosts[i]);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
var shells = site.querySelectorAll('.' + P + '-shell');
|
|
180
|
+
var state = {};
|
|
181
|
+
var initial = {};
|
|
182
|
+
var stateTypes = {};
|
|
183
|
+
for (var st = 0; st < R.states.length; st++) {
|
|
184
|
+
var declaration = R.states[st];
|
|
185
|
+
state[declaration.name] = declaration.initial;
|
|
186
|
+
initial[declaration.name] = declaration.initial;
|
|
187
|
+
stateTypes[declaration.name] = declaration.valueType;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function diagnostic(code, detail) {
|
|
191
|
+
site.setAttribute('data-wf-runtime-diagnostic', code + ':' + detail);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function hasState(name) {
|
|
195
|
+
return Object.prototype.hasOwnProperty.call(state, name);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function guardPasses(guard) {
|
|
199
|
+
return !guard || (hasState(guard.state) && state[guard.state] === guard.equals);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function valueMatches(name, value) {
|
|
203
|
+
return hasState(name) && typeof value === stateTypes[name];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function parseJson(value, fallback) {
|
|
207
|
+
if (!value) return fallback;
|
|
208
|
+
try {
|
|
209
|
+
return JSON.parse(value);
|
|
210
|
+
} catch (e) {
|
|
211
|
+
return fallback;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function handlerId(signature) {
|
|
216
|
+
for (var i = 0; i < R.handlers.length; i++) {
|
|
217
|
+
if (JSON.stringify(R.handlers[i]) === signature) return i;
|
|
218
|
+
}
|
|
219
|
+
return -1;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function contains(ids, id) {
|
|
223
|
+
for (var i = 0; i < ids.length; i++) if (ids[i] === id) return true;
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function shellHandlersFor(key) {
|
|
228
|
+
var shell = shellOf[key];
|
|
229
|
+
if (!shell) return [];
|
|
230
|
+
return R.shellHandlers[shell.getAttribute('data-layout')] || [];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function interactionFor(key, element, signature) {
|
|
234
|
+
var id = handlerId(signature);
|
|
235
|
+
if (id < 0) return null;
|
|
236
|
+
var ids = isChrome(element) ? shellHandlersFor(key) : R.screenHandlers[String(key)] || [];
|
|
237
|
+
return contains(ids, id) ? R.handlers[id] : null;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function routeAllowed(key, target) {
|
|
241
|
+
var groups = [R.screenHandlers[String(key)] || [], shellHandlersFor(key)];
|
|
242
|
+
for (var i = 0; i < groups.length; i++) {
|
|
243
|
+
for (var j = 0; j < groups[i].length; j++) {
|
|
244
|
+
var handler = R.handlers[groups[i][j]];
|
|
245
|
+
if (!handler || !guardPasses(handler.guard)) continue;
|
|
246
|
+
for (var e = 0; e < handler.effects.length; e++) {
|
|
247
|
+
var effect = handler.effects[e];
|
|
248
|
+
if (effect.kind === 'navigate' && effect.target === target) return true;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** The shell a screen is hosted in, or null when it stands alone. */
|
|
256
|
+
function shellFor(node) {
|
|
257
|
+
var el = node.parentNode;
|
|
258
|
+
while (el && el !== site) {
|
|
259
|
+
if (el.classList && el.classList.contains(P + '-shell')) return el;
|
|
260
|
+
el = el.parentNode;
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** True for an element that belongs to a shell's own chrome, not to a screen. */
|
|
266
|
+
function isChrome(el) {
|
|
267
|
+
return !(el.closest && el.closest('[data-screen]'));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The id prefix a container namespaces its contents under.
|
|
272
|
+
*
|
|
273
|
+
* Read from the document rather than rebuilt from the scheme that produced
|
|
274
|
+
* it: the renderer decides how scopes are spelled, and a second spelling in
|
|
275
|
+
* here could disagree with the first without anything noticing.
|
|
276
|
+
*/
|
|
277
|
+
function scopeOf(el) {
|
|
278
|
+
return (el && el.getAttribute(${embedJson(ID_SCOPE_ATTR)})) || '';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Match one id exactly, whatever characters an author put in it. */
|
|
282
|
+
function idSelector(id) {
|
|
283
|
+
return '[id="' + String(id).replace(/["\\\\]/g, '\\\\$&') + '"]';
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Screen key for a navigate target or a fragment, or null. */
|
|
287
|
+
function resolve(target) {
|
|
288
|
+
if (target === null || target === undefined) return null;
|
|
289
|
+
var name = String(target).trim();
|
|
290
|
+
if (name === '') return null;
|
|
291
|
+
if (Object.prototype.hasOwnProperty.call(R.names, name)) return String(R.names[name]);
|
|
292
|
+
return Object.prototype.hasOwnProperty.call(screens, name) ? name : null;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The overlay an intent addresses, from the point of view of one screen.
|
|
297
|
+
*
|
|
298
|
+
* An overlay id is scoped to the thing that declares it, and composition gives
|
|
299
|
+
* a screen two declaring contexts: the page itself, and the shell it is hosted
|
|
300
|
+
* in. A \`drawer\` written into a layout belongs to every screen that uses that
|
|
301
|
+
* layout, so the screen is searched first and its shell second \u2014 nearest
|
|
302
|
+
* declaration wins, and a page can shadow a shell's overlay with its own.
|
|
303
|
+
*
|
|
304
|
+
* The shell is searched for chrome only. Its hosted screens are descendants of
|
|
305
|
+
* it, so an unfiltered query there would let one screen's trigger reach into
|
|
306
|
+
* another screen that happens to reuse the id.
|
|
307
|
+
*
|
|
308
|
+
* The two searches use two different selectors, because the two contexts
|
|
309
|
+
* namespace their ids separately: the authored name is composed with the
|
|
310
|
+
* scope each container publishes. The trigger's attribute is never rewritten
|
|
311
|
+
* \u2014 \`opens="confirm"\` means the \`confirm\` its author could see, and which
|
|
312
|
+
* element that is depends on where the search is standing.
|
|
313
|
+
*/
|
|
314
|
+
function overlayFor(key, id) {
|
|
315
|
+
if (!id) return null;
|
|
316
|
+
|
|
317
|
+
var screen = screens[key];
|
|
318
|
+
if (screen) {
|
|
319
|
+
var own = screen.querySelector(idSelector(scopeOf(screen) + id));
|
|
320
|
+
if (own) return own;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
var shell = shellOf[key];
|
|
324
|
+
if (shell) {
|
|
325
|
+
var candidates = shell.querySelectorAll(idSelector(scopeOf(shell) + id));
|
|
326
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
327
|
+
if (isChrome(candidates[i])) return candidates[i];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Every element that opens or toggles something, from one screen's view. */
|
|
334
|
+
function triggersFor(key) {
|
|
335
|
+
var selector = '[' + ${embedJson(OPENS_ATTR)} + '],[' + ${embedJson(TOGGLES_ATTR)} + ']';
|
|
336
|
+
var found = [];
|
|
337
|
+
var i;
|
|
338
|
+
|
|
339
|
+
var screen = screens[key];
|
|
340
|
+
if (screen) {
|
|
341
|
+
var own = screen.querySelectorAll(selector);
|
|
342
|
+
for (i = 0; i < own.length; i++) found.push(own[i]);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
var shell = shellOf[key];
|
|
346
|
+
if (shell) {
|
|
347
|
+
var chrome = shell.querySelectorAll(selector);
|
|
348
|
+
for (i = 0; i < chrome.length; i++) {
|
|
349
|
+
if (isChrome(chrome[i])) found.push(chrome[i]);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return found;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Close every overlay something points at, from one screen's point of view.
|
|
357
|
+
*
|
|
358
|
+
* An overlay nothing points at is left visible: a wireframe that draws a
|
|
359
|
+
* modal in order to describe it is not waiting for a click.
|
|
360
|
+
*/
|
|
361
|
+
function closeOverlays(key) {
|
|
362
|
+
var triggers = triggersFor(key);
|
|
363
|
+
for (var i = 0; i < triggers.length; i++) {
|
|
364
|
+
var id =
|
|
365
|
+
triggers[i].getAttribute(${embedJson(OPENS_ATTR)}) ||
|
|
366
|
+
triggers[i].getAttribute(${embedJson(TOGGLES_ATTR)});
|
|
367
|
+
var overlay = overlayFor(key, id);
|
|
368
|
+
if (overlay) overlay.classList.add(CLOSED);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function initOverlays() {
|
|
373
|
+
for (var i = 0; i < order.length; i++) closeOverlays(order[i]);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function applyOutcomes() {
|
|
377
|
+
var visible = site.querySelectorAll('[' + ${embedJson(VISIBLE_GUARD_ATTR)} + ']');
|
|
378
|
+
for (var i = 0; i < visible.length; i++) {
|
|
379
|
+
var visibleGuard = parseJson(visible[i].getAttribute(${embedJson(VISIBLE_GUARD_ATTR)}), null);
|
|
380
|
+
if (guardPasses(visibleGuard)) visible[i].removeAttribute('hidden');
|
|
381
|
+
else visible[i].setAttribute('hidden', 'hidden');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
var enabled = site.querySelectorAll('[' + ${embedJson(ENABLED_GUARD_ATTR)} + ']');
|
|
385
|
+
for (var j = 0; j < enabled.length; j++) {
|
|
386
|
+
var enabledGuard = parseJson(enabled[j].getAttribute(${embedJson(ENABLED_GUARD_ATTR)}), null);
|
|
387
|
+
if (guardPasses(enabledGuard)) {
|
|
388
|
+
enabled[j].removeAttribute('disabled');
|
|
389
|
+
enabled[j].removeAttribute('aria-disabled');
|
|
390
|
+
} else {
|
|
391
|
+
enabled[j].setAttribute('disabled', 'disabled');
|
|
392
|
+
enabled[j].setAttribute('aria-disabled', 'true');
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function applyVariantScopes() {
|
|
398
|
+
var screen = current === null ? null : screens[current];
|
|
399
|
+
var variant = screen ? screen.getAttribute('data-wf-variant') : null;
|
|
400
|
+
var scoped = site.querySelectorAll('[' + ${embedJson(VARIANT_SCOPE_ATTR)} + ']');
|
|
401
|
+
for (var i = 0; i < scoped.length; i++) {
|
|
402
|
+
var names = parseJson(scoped[i].getAttribute(${embedJson(VARIANT_SCOPE_ATTR)}), []);
|
|
403
|
+
var visible = variant !== null && names.indexOf(variant) >= 0;
|
|
404
|
+
if (visible) scoped[i].removeAttribute('hidden');
|
|
405
|
+
else scoped[i].setAttribute('hidden', 'hidden');
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function applyEffects(handler) {
|
|
410
|
+
for (var i = 0; i < handler.effects.length; i++) {
|
|
411
|
+
var effect = handler.effects[i];
|
|
412
|
+
if (effect.kind === 'navigate') {
|
|
413
|
+
var route = resolve(effect.target);
|
|
414
|
+
if (route !== null) show(route, true);
|
|
415
|
+
else diagnostic('unknown-route', effect.target);
|
|
416
|
+
} else if (effect.kind === 'set') {
|
|
417
|
+
if (valueMatches(effect.state, effect.value)) state[effect.state] = effect.value;
|
|
418
|
+
else diagnostic('invalid-set', effect.state);
|
|
419
|
+
} else if (effect.kind === 'reset') {
|
|
420
|
+
if (hasState(effect.state)) state[effect.state] = initial[effect.state];
|
|
421
|
+
else diagnostic('unknown-state', effect.state);
|
|
422
|
+
} else if (effect.kind === 'toggle') {
|
|
423
|
+
if (stateTypes[effect.state] === 'boolean') state[effect.state] = !state[effect.state];
|
|
424
|
+
else diagnostic('invalid-toggle', effect.state);
|
|
425
|
+
} else if (effect.kind === 'open') {
|
|
426
|
+
var opened = overlayFor(current, effect.target);
|
|
427
|
+
if (opened) opened.classList.remove(CLOSED);
|
|
428
|
+
else diagnostic('unknown-overlay', effect.target);
|
|
429
|
+
} else if (effect.kind === 'close') {
|
|
430
|
+
var closed = overlayFor(current, effect.target);
|
|
431
|
+
if (closed) closed.classList.add(CLOSED);
|
|
432
|
+
else diagnostic('unknown-overlay', effect.target);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
applyOutcomes();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
var current = null;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The one place \`active\` is decided.
|
|
442
|
+
*
|
|
443
|
+
* Every shell nav item carries its own \`navigate\` target, including the item
|
|
444
|
+
* for the screen being shown, and the class is applied to whichever of them
|
|
445
|
+
* resolves to the current screen. Authoring it by hand is what produced items
|
|
446
|
+
* marked active while pointing somewhere else; there is nothing to author
|
|
447
|
+
* here, so there is nothing to get wrong.
|
|
448
|
+
*
|
|
449
|
+
* Only the shell's own chrome is derived. Links inside a screen belong to
|
|
450
|
+
* that screen's content, where an authored \`active\` still means what its
|
|
451
|
+
* author meant.
|
|
452
|
+
*/
|
|
453
|
+
function markActive(key) {
|
|
454
|
+
for (var i = 0; i < shells.length; i++) {
|
|
455
|
+
var links = shells[i].querySelectorAll('[' + ${embedJson(NAVIGATE_ATTR)} + ']');
|
|
456
|
+
for (var j = 0; j < links.length; j++) {
|
|
457
|
+
if (!isChrome(links[j])) continue;
|
|
458
|
+
// An external target names no screen, so it can never be the current
|
|
459
|
+
// one. Same marker, same skip: the registry is not consulted.
|
|
460
|
+
if (links[j].hasAttribute(${embedJson(EXTERNAL_NAVIGATE_ATTR)})) continue;
|
|
461
|
+
var target = resolve(links[j].getAttribute(${embedJson(NAVIGATE_ATTR)}));
|
|
462
|
+
if (target === key) links[j].classList.add(NAV_ACTIVE);
|
|
463
|
+
else links[j].classList.remove(NAV_ACTIVE);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function show(key, writeFragment) {
|
|
469
|
+
var screen = screens[key];
|
|
470
|
+
if (!screen) return false;
|
|
471
|
+
if (key === current) return true;
|
|
472
|
+
|
|
473
|
+
for (var i = 0; i < order.length; i++) {
|
|
474
|
+
var k = order[i];
|
|
475
|
+
if (k === key) screens[k].classList.add(ON);
|
|
476
|
+
else screens[k].classList.remove(ON);
|
|
477
|
+
}
|
|
478
|
+
var shell = shellOf[key];
|
|
479
|
+
for (var s = 0; s < shells.length; s++) {
|
|
480
|
+
if (shells[s] === shell) shells[s].classList.add(ON);
|
|
481
|
+
else shells[s].classList.remove(ON);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Which screen is current is *state*; \`data-screen\` is the *identity* of a
|
|
485
|
+
// screen host. Writing the state under the identity attribute makes the site
|
|
486
|
+
// root answer \`[data-screen]\` and shadow every host below it, which is
|
|
487
|
+
// precisely the conflation this feature exists to remove.
|
|
488
|
+
site.setAttribute('data-current-screen', key);
|
|
489
|
+
current = key;
|
|
490
|
+
closeOverlays(key);
|
|
491
|
+
markActive(key);
|
|
492
|
+
applyVariantScopes();
|
|
493
|
+
applyOutcomes();
|
|
494
|
+
|
|
495
|
+
if (writeFragment) {
|
|
496
|
+
var fragment = R.fragments[Number(key)] || key;
|
|
497
|
+
// The resulting hashchange re-enters show() with the key already current,
|
|
498
|
+
// which returns early \u2014 the fragment and the screen cannot fight.
|
|
499
|
+
if (location.hash.slice(1) !== fragment) location.hash = fragment;
|
|
500
|
+
}
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function fromFragment() {
|
|
505
|
+
var raw = location.hash.slice(1);
|
|
506
|
+
if (raw === '') return null;
|
|
507
|
+
var decoded = raw;
|
|
508
|
+
try {
|
|
509
|
+
decoded = decodeURIComponent(raw);
|
|
510
|
+
} catch (e) {
|
|
511
|
+
decoded = raw;
|
|
512
|
+
}
|
|
513
|
+
return resolve(decoded);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
document.addEventListener('click', function (event) {
|
|
517
|
+
var typed = event.target.closest ? event.target.closest('[' + ${embedJson(TYPED_INTERACTION_ATTR)} + ']') : null;
|
|
518
|
+
if (typed) {
|
|
519
|
+
var signatures = parseJson(typed.getAttribute(${embedJson(TYPED_INTERACTION_ATTR)}), []);
|
|
520
|
+
var matched = false;
|
|
521
|
+
for (var typedIndex = 0; typedIndex < signatures.length; typedIndex++) {
|
|
522
|
+
var normalized = interactionFor(current, typed, signatures[typedIndex]);
|
|
523
|
+
if (!normalized) continue;
|
|
524
|
+
matched = true;
|
|
525
|
+
if (guardPasses(normalized.guard)) applyEffects(normalized);
|
|
526
|
+
}
|
|
527
|
+
if (matched) {
|
|
528
|
+
event.preventDefault();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
var mover = event.target.closest ? event.target.closest('[' + ${embedJson(NAVIGATE_ATTR)} + ']') : null;
|
|
534
|
+
// The marker is a decision the renderer already made, not a hint to check.
|
|
535
|
+
// Reading it here \u2014 rather than re-deriving "is this a URL" from the string \u2014
|
|
536
|
+
// is what keeps that rule in one place; a second copy in generated JS is a
|
|
537
|
+
// drift surface, and the two disagreeing is how a runtime ends up hunting
|
|
538
|
+
// for a screen named "https://\u2026". Marked elements skip the registry
|
|
539
|
+
// entirely: the lookup is not attempted, not merely discarded.
|
|
540
|
+
if (mover && !mover.hasAttribute(${embedJson(EXTERNAL_NAVIGATE_ATTR)})) {
|
|
541
|
+
var navigateTarget = mover.getAttribute(${embedJson(NAVIGATE_ATTR)});
|
|
542
|
+
var key = routeAllowed(current, navigateTarget) ? resolve(navigateTarget) : null;
|
|
543
|
+
if (key !== null) {
|
|
544
|
+
event.preventDefault();
|
|
545
|
+
show(key, true);
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
var opener = event.target.closest ? event.target.closest('[' + ${embedJson(OPENS_ATTR)} + ']') : null;
|
|
551
|
+
if (opener) {
|
|
552
|
+
var opened = overlayFor(current, opener.getAttribute(${embedJson(OPENS_ATTR)}));
|
|
553
|
+
if (opened) {
|
|
554
|
+
event.preventDefault();
|
|
555
|
+
opened.classList.remove(CLOSED);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
var toggler = event.target.closest ? event.target.closest('[' + ${embedJson(TOGGLES_ATTR)} + ']') : null;
|
|
561
|
+
if (toggler) {
|
|
562
|
+
var toggled = overlayFor(current, toggler.getAttribute(${embedJson(TOGGLES_ATTR)}));
|
|
563
|
+
if (toggled) {
|
|
564
|
+
event.preventDefault();
|
|
565
|
+
toggled.classList.toggle(CLOSED);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
var actor = event.target.closest ? event.target.closest('[' + ${embedJson(ACTION_ATTR)} + ']') : null;
|
|
571
|
+
if (actor) {
|
|
572
|
+
// Only the two structural actions are the runtime's business. Every other
|
|
573
|
+
// value is an opaque handler id the wireframe never promised to run.
|
|
574
|
+
var action = (actor.getAttribute(${embedJson(ACTION_ATTR)}) || '').trim();
|
|
575
|
+
if (action === 'close' || action === 'back') {
|
|
576
|
+
event.preventDefault();
|
|
577
|
+
closeOverlays(current);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (action !== '') diagnostic('unknown-action', action);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// Clicking a modal's own backdrop dismisses it, the way a real one does.
|
|
584
|
+
var backdrop = event.target;
|
|
585
|
+
if (backdrop && backdrop.classList && backdrop.classList.contains(P + '-modal-backdrop')) {
|
|
586
|
+
backdrop.classList.add(CLOSED);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// Every branch above cancels the default only when it RESOLVES an intent,
|
|
590
|
+
// which is right for them \u2014 an unresolved intent must not silently look
|
|
591
|
+
// handled. But that leaves the anchors the renderer marked as having no
|
|
592
|
+
// destination at all, and a wireframe is mostly those: nav labels, tabs,
|
|
593
|
+
// breadcrumbs, placeholder links. Their default action is a navigation, and
|
|
594
|
+
// in the \`srcdoc\` frame every consumer mounts this output in, the inert
|
|
595
|
+
// \`href\` resolves against the EMBEDDER's URL \u2014 so the click walks the frame
|
|
596
|
+
// out of the wireframe and loads the host app inside itself, refetching its
|
|
597
|
+
// assets. Measured on a 20-screen demo: 44 such anchors, frame URL
|
|
598
|
+
// \`about:srcdoc\` -> \`<host page>#\`.
|
|
599
|
+
//
|
|
600
|
+
// The test is the renderer's own statement (\`INERT_HREF\`), read back, not a
|
|
601
|
+
// guess about what the string means: an authored \`href\`, and a URL-shaped
|
|
602
|
+
// \`navigate\` moved into one, are real destinations and are left alone. An
|
|
603
|
+
// authored fragment link is left alone too \u2014 the hashchange handler below is
|
|
604
|
+
// how that is supposed to work.
|
|
605
|
+
var link = event.target.closest ? event.target.closest('a[href]') : null;
|
|
606
|
+
if (link && link.getAttribute('href') === ${embedJson(INERT_HREF)}) event.preventDefault();
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
document.addEventListener('keydown', function (event) {
|
|
610
|
+
if (event.key === 'Escape' && current !== null) closeOverlays(current);
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
window.addEventListener('hashchange', function () {
|
|
614
|
+
var key = fromFragment();
|
|
615
|
+
if (key !== null) show(key, false);
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
initOverlays();
|
|
619
|
+
var start = fromFragment();
|
|
620
|
+
if (start === null) start = String(R.entry);
|
|
621
|
+
if (!show(start, false)) show(String(R.entry), false);
|
|
622
|
+
})();`;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// src/renderer/site/index.ts
|
|
626
|
+
var DEFAULT_PREFIX = "wf";
|
|
627
|
+
var screenScope = (index) => `s${index}-`;
|
|
628
|
+
var shellScope = (index) => `l${index}-`;
|
|
629
|
+
function escapeAttr(value) {
|
|
630
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
631
|
+
}
|
|
632
|
+
function escapeText(value) {
|
|
633
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
634
|
+
}
|
|
635
|
+
function attrs(pairs) {
|
|
636
|
+
return pairs.filter((pair) => pair[1] !== void 0).map(([name, value]) => ` ${name}="${escapeAttr(value)}"`).join("");
|
|
637
|
+
}
|
|
638
|
+
function renderHostedScreen(screen, shell, make, prefix) {
|
|
639
|
+
const { width, height } = resolvePageDimensions(screen.page);
|
|
640
|
+
const conflict = width !== shell.width || height !== shell.height ? `${width}x${height}` : void 0;
|
|
641
|
+
const scope = screenScope(screen.index);
|
|
642
|
+
const marks = attrs([
|
|
643
|
+
["data-screen", String(screen.index)],
|
|
644
|
+
["data-screen-name", screen.name],
|
|
645
|
+
["data-wf-variant", screen.variant],
|
|
646
|
+
[ID_SCOPE_ATTR, scope],
|
|
647
|
+
["data-wf-viewport-conflict", conflict]
|
|
648
|
+
]);
|
|
649
|
+
const content = make(scope).renderFragment(screen.page.children);
|
|
650
|
+
return `<div class="${prefix}-screen"${marks}>
|
|
651
|
+
${content}
|
|
652
|
+
</div>`;
|
|
653
|
+
}
|
|
654
|
+
function renderStandaloneScreen(screen, make, prefix) {
|
|
655
|
+
var _a, _b;
|
|
656
|
+
const scope = screenScope(screen.index);
|
|
657
|
+
const marks = attrs([
|
|
658
|
+
["data-screen", String(screen.index)],
|
|
659
|
+
["data-screen-name", screen.name],
|
|
660
|
+
["data-wf-variant", screen.variant],
|
|
661
|
+
[ID_SCOPE_ATTR, scope],
|
|
662
|
+
["data-wf-uses-unresolved", (_a = screen.miss) == null ? void 0 : _a.uses],
|
|
663
|
+
["data-wf-uses-reason", (_b = screen.miss) == null ? void 0 : _b.reason]
|
|
664
|
+
]);
|
|
665
|
+
const page = make(scope).render({ type: "Document", children: [screen.page] }).html;
|
|
666
|
+
return `<div class="${prefix}-screen"${marks}>
|
|
667
|
+
${page}
|
|
668
|
+
</div>`;
|
|
669
|
+
}
|
|
670
|
+
function renderShell(shell, index, make, prefix) {
|
|
671
|
+
const hosted = shell.screens.map((screen) => renderHostedScreen(screen, shell, make, prefix)).join("\n");
|
|
672
|
+
const scope = shellScope(index);
|
|
673
|
+
const style = `position: relative; width: ${shell.width}px; height: ${shell.height}px; overflow: hidden`;
|
|
674
|
+
const marks = attrs([
|
|
675
|
+
["data-layout", shell.name],
|
|
676
|
+
[ID_SCOPE_ATTR, scope],
|
|
677
|
+
["data-viewport-width", String(shell.width)],
|
|
678
|
+
["data-viewport-height", String(shell.height)]
|
|
679
|
+
]);
|
|
680
|
+
const body = make(scope).renderFragment(shell.layout.children, hosted);
|
|
681
|
+
return `<div class="${prefix}-page ${prefix}-shell" style="${style}"${marks}>
|
|
682
|
+
${body}
|
|
683
|
+
</div>`;
|
|
684
|
+
}
|
|
685
|
+
function resolveEntry(model, options) {
|
|
686
|
+
var _a;
|
|
687
|
+
const fallback = Math.max(model.entry, 0);
|
|
688
|
+
const requested = (_a = options.entry) == null ? void 0 : _a.trim();
|
|
689
|
+
if (requested === void 0 || requested.length === 0) return { index: fallback };
|
|
690
|
+
const index = model.names.get(requested);
|
|
691
|
+
if (index === void 0) return { index: fallback, unresolved: requested };
|
|
692
|
+
return { index };
|
|
693
|
+
}
|
|
694
|
+
function resolveTitle(model, options, entry) {
|
|
695
|
+
var _a, _b;
|
|
696
|
+
if (options.title !== void 0) return options.title;
|
|
697
|
+
const page = (_a = model.screens[entry]) == null ? void 0 : _a.page;
|
|
698
|
+
const title = (_b = page == null ? void 0 : page.title) == null ? void 0 : _b.trim();
|
|
699
|
+
return title !== void 0 && title.length > 0 ? title : "Wireframe";
|
|
700
|
+
}
|
|
701
|
+
function compactRuntimeInteractions(model, interactions) {
|
|
702
|
+
var _a;
|
|
703
|
+
const handlers = [];
|
|
704
|
+
const handlerIds = /* @__PURE__ */ new Map();
|
|
705
|
+
const screenHandlers = {};
|
|
706
|
+
const shellHandlers = {};
|
|
707
|
+
const intern = (signature, handler) => {
|
|
708
|
+
const existing = handlerIds.get(signature);
|
|
709
|
+
if (existing !== void 0) return existing;
|
|
710
|
+
const id = handlers.length;
|
|
711
|
+
handlerIds.set(signature, id);
|
|
712
|
+
handlers.push(handler);
|
|
713
|
+
return id;
|
|
714
|
+
};
|
|
715
|
+
const add = (owner, key, id) => {
|
|
716
|
+
var _a2;
|
|
717
|
+
const ids = (_a2 = owner[key]) != null ? _a2 : owner[key] = [];
|
|
718
|
+
if (!ids.includes(id)) ids.push(id);
|
|
719
|
+
};
|
|
720
|
+
for (const interaction of interactions) {
|
|
721
|
+
const id = intern(interaction.signature, interaction.handler);
|
|
722
|
+
if (interaction.source === "screen") {
|
|
723
|
+
add(screenHandlers, String(interaction.screenIndex), id);
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
const shell = (_a = model.screens[interaction.screenIndex]) == null ? void 0 : _a.shell;
|
|
727
|
+
if (shell !== void 0) add(shellHandlers, shell, id);
|
|
728
|
+
}
|
|
729
|
+
return { handlers, screenHandlers, shellHandlers };
|
|
730
|
+
}
|
|
731
|
+
function renderSite(document, options = {}) {
|
|
732
|
+
var _a;
|
|
733
|
+
const prefix = (_a = options.classPrefix) != null ? _a : DEFAULT_PREFIX;
|
|
734
|
+
document = expandRepeats(expandVariants(document));
|
|
735
|
+
const model = buildSiteModel(document);
|
|
736
|
+
const interactionModel = collectInteractions(document);
|
|
737
|
+
const make = (idScope) => new HtmlRenderer({
|
|
738
|
+
theme: options.theme,
|
|
739
|
+
classPrefix: prefix,
|
|
740
|
+
background: options.background,
|
|
741
|
+
annotationStyle: options.annotationStyle,
|
|
742
|
+
includeStyles: false,
|
|
743
|
+
idScope
|
|
744
|
+
});
|
|
745
|
+
const shells = model.shells.map((shell, index) => renderShell(shell, index, make, prefix)).join("\n");
|
|
746
|
+
const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
|
|
747
|
+
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
748
|
+
const css = generateStyles(theme, prefix, options.annotationStyle) + generateSiteStyles(prefix);
|
|
749
|
+
const entry = resolveEntry(model, options);
|
|
750
|
+
const fragments = model.screens.map((screen) => {
|
|
751
|
+
var _a2;
|
|
752
|
+
return (_a2 = screen.name) != null ? _a2 : String(screen.index);
|
|
753
|
+
});
|
|
754
|
+
const runtimeInteractions = compactRuntimeInteractions(model, interactionModel.interactions);
|
|
755
|
+
const runtime = siteRuntime(
|
|
756
|
+
{
|
|
757
|
+
names: Object.fromEntries(model.names),
|
|
758
|
+
fragments,
|
|
759
|
+
entry: entry.index,
|
|
760
|
+
states: interactionModel.states,
|
|
761
|
+
...runtimeInteractions,
|
|
762
|
+
diagnostics: interactionModel.diagnostics
|
|
763
|
+
},
|
|
764
|
+
prefix
|
|
765
|
+
);
|
|
766
|
+
const body = [shells, standalone].filter((part) => part.length > 0).join("\n");
|
|
767
|
+
const siteAttrs = attrs([
|
|
768
|
+
["data-screen-count", String(model.screens.length)],
|
|
769
|
+
["data-shell-count", String(model.shells.length)],
|
|
770
|
+
["data-wf-entry-unresolved", entry.unresolved],
|
|
771
|
+
["data-wf-diagnostic-count", String(interactionModel.diagnostics.length)]
|
|
772
|
+
]);
|
|
773
|
+
return `<!DOCTYPE html>
|
|
774
|
+
<html lang="en">
|
|
775
|
+
<head>
|
|
776
|
+
<meta charset="UTF-8">
|
|
777
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
778
|
+
<title>${escapeText(resolveTitle(model, options, entry.index))}</title>
|
|
779
|
+
<style>
|
|
780
|
+
html, body {
|
|
781
|
+
margin: 0;
|
|
782
|
+
padding: 0;
|
|
783
|
+
min-height: 100vh;
|
|
784
|
+
background: #f4f4f5;
|
|
785
|
+
}
|
|
786
|
+
/* The gutter is breathing room *around* a board, so it may never come out of
|
|
787
|
+
the width the board is laid out in.
|
|
788
|
+
|
|
789
|
+
\`body\` is a block box: its \`width: auto\` resolves to the space available in
|
|
790
|
+
the viewport minus its own horizontal padding, so \`padding: 24px\` made the
|
|
791
|
+
containing block 1440 - 24*2 = 1392px. \`box-sizing\` does not undo that \u2014
|
|
792
|
+
it only reinterprets an *explicit* width, and there is none here. A board
|
|
793
|
+
authored at the 1440px desktop viewport is 1440px of \`.wf-page\` that must
|
|
794
|
+
not shrink (\`flex-shrink: 0\`, the fixed-layout invariant), so it overhung
|
|
795
|
+
its 1392px parent by 24px on each side and the document scrolled sideways.
|
|
796
|
+
|
|
797
|
+
The gutter therefore moves off the horizontal axis, where it competes with
|
|
798
|
+
the board for the viewport, and stays only on the vertical one, where it
|
|
799
|
+
costs nothing: a document scrolls down by nature, so leading above and
|
|
800
|
+
below a board is free, while every horizontal pixel it takes is a pixel the
|
|
801
|
+
board must give back. A board authored at exactly the viewport width now
|
|
802
|
+
fills it edge to edge, as authored, and anything wider scrolls by its own
|
|
803
|
+
overflow rather than by the gutter's. */
|
|
804
|
+
body {
|
|
805
|
+
padding: 24px 0;
|
|
806
|
+
}
|
|
807
|
+
${css}
|
|
808
|
+
</style>
|
|
809
|
+
</head>
|
|
810
|
+
<body>
|
|
811
|
+
<div class="${prefix}-site"${siteAttrs}>
|
|
812
|
+
${body}
|
|
813
|
+
</div>
|
|
814
|
+
<script>
|
|
815
|
+
${runtime}
|
|
816
|
+
</script>
|
|
817
|
+
</body>
|
|
818
|
+
</html>`;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
export { expandVariants, renderSite };
|