@usethrottle/builder-react 0.3.0 → 0.4.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.
- package/CLAUDE.md +31 -0
- package/dist/{chunk-65KZ5CIP.js → chunk-4EGFSBVT.js} +1418 -515
- package/dist/{chunk-ZCXPIZU7.cjs → chunk-54BG5PPM.cjs} +1383 -480
- package/dist/index.cjs +1710 -752
- package/dist/index.d.cts +200 -38
- package/dist/index.d.ts +200 -38
- package/dist/index.js +1678 -716
- package/dist/interactions-runtime.cjs +207 -0
- package/dist/interactions-runtime.js +186 -0
- package/dist/next.cjs +6 -6
- package/dist/next.d.cts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +1 -1
- package/dist/{seo-Dz439Jlk.d.cts → seo-CNZ9DrlU.d.cts} +16 -1
- package/dist/{seo-Dz439Jlk.d.ts → seo-CNZ9DrlU.d.ts} +16 -1
- package/dist/server.cjs +26 -22
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +9 -5
- package/package.json +4 -3
|
@@ -38,7 +38,9 @@ function bindingsOf(node, registry) {
|
|
|
38
38
|
function collectBindings(doc, registry) {
|
|
39
39
|
const found = /* @__PURE__ */ new Map();
|
|
40
40
|
walkNodes(doc, (node) => {
|
|
41
|
-
if (node.type === "section" || node.type === "inner-section" || node.type === "column")
|
|
41
|
+
if (node.type === "section" || node.type === "inner-section" || node.type === "column" || node.type === "saved-section") {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
42
44
|
for (const binding of Object.values(bindingsOf(node, registry))) {
|
|
43
45
|
const key = bindingKey(binding);
|
|
44
46
|
if (!found.has(key)) found.set(key, binding);
|
|
@@ -69,25 +71,197 @@ async function resolveBindings(bindings, registry, ctx, options) {
|
|
|
69
71
|
return Object.fromEntries(settled.filter((entry) => entry !== null));
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
// src/saved-section.tsx
|
|
75
|
+
import { ANCHOR_RE as ANCHOR_RE2, anyCustomWidgetSnapshotSchema, sectionNodeSchema, walkNodes as walkNodes2 } from "@usethrottle/builder-schema";
|
|
76
|
+
|
|
77
|
+
// src/node-wrapper.tsx
|
|
78
|
+
import { ANCHOR_RE } from "@usethrottle/builder-schema";
|
|
79
|
+
import { jsx } from "react/jsx-runtime";
|
|
80
|
+
var CUSTOM_WIDGET_CONTAINMENT = {
|
|
81
|
+
contain: "layout paint",
|
|
82
|
+
isolation: "isolate",
|
|
83
|
+
overflow: "clip"
|
|
84
|
+
};
|
|
85
|
+
var PART_NAME = {
|
|
86
|
+
section: "builder-section",
|
|
87
|
+
column: "builder-column",
|
|
88
|
+
widget: "builder-widget"
|
|
89
|
+
};
|
|
90
|
+
function NodeWrapper(props) {
|
|
91
|
+
const { id, part, type, className, anchor, copyAnchor, custom, missing, attributes, edit, entrance, children } = props;
|
|
92
|
+
const Tag = props.as ?? "div";
|
|
93
|
+
const handlers = edit === void 0 ? {} : {
|
|
94
|
+
onClickCapture: (event) => {
|
|
95
|
+
const target = event.target;
|
|
96
|
+
if (target?.closest?.("a[href]") != null) event.preventDefault();
|
|
97
|
+
},
|
|
98
|
+
onClick: (event) => {
|
|
99
|
+
event.stopPropagation();
|
|
100
|
+
edit.onSelect(id);
|
|
101
|
+
},
|
|
102
|
+
onMouseOver: (event) => {
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
edit.onHover(id);
|
|
105
|
+
},
|
|
106
|
+
onMouseLeave: () => edit.onHover(null)
|
|
107
|
+
};
|
|
108
|
+
const style = custom === true || entrance !== void 0 ? {
|
|
109
|
+
...custom === true ? CUSTOM_WIDGET_CONTAINMENT : {},
|
|
110
|
+
...entrance !== void 0 && entrance.delayMs > 0 ? { "--tb-ed": `${String(entrance.delayMs)}ms` } : {}
|
|
111
|
+
} : void 0;
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
Tag,
|
|
114
|
+
{
|
|
115
|
+
className,
|
|
116
|
+
"data-b-id": id,
|
|
117
|
+
"data-throttle-part": PART_NAME[part],
|
|
118
|
+
...type === void 0 ? {} : { "data-b-type": type },
|
|
119
|
+
...custom === true && type !== void 0 ? { "data-b-w": type } : {},
|
|
120
|
+
...missing === true ? { "data-b-missing": "" } : {},
|
|
121
|
+
...attributes,
|
|
122
|
+
...typeof anchor === "string" && ANCHOR_RE.test(anchor) ? { id: anchor } : {},
|
|
123
|
+
...typeof copyAnchor === "string" && ANCHOR_RE.test(copyAnchor) ? { "data-b-anchor": copyAnchor } : {},
|
|
124
|
+
...entrance === void 0 ? {} : { "data-b-entrance": entrance.name },
|
|
125
|
+
...style === void 0 || Object.keys(style).length === 0 ? {} : { style },
|
|
126
|
+
...handlers,
|
|
127
|
+
children
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/saved-section.tsx
|
|
133
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
134
|
+
var pid = (refId, id) => `${refId}-${id}`;
|
|
135
|
+
var MAX_EXPANDED_NODES = 2e4;
|
|
136
|
+
function prefixAnchor(refId, props) {
|
|
137
|
+
const anchor = props.anchor;
|
|
138
|
+
if (typeof anchor !== "string") return props;
|
|
139
|
+
const prefixed = pid(refId, anchor);
|
|
140
|
+
const { anchor: _drop, ...rest } = props;
|
|
141
|
+
void _drop;
|
|
142
|
+
return ANCHOR_RE2.test(prefixed) ? { ...rest, anchor: prefixed } : rest;
|
|
143
|
+
}
|
|
144
|
+
function prefixColumn(refId, column) {
|
|
145
|
+
return {
|
|
146
|
+
...column,
|
|
147
|
+
id: pid(refId, column.id),
|
|
148
|
+
props: prefixAnchor(refId, column.props),
|
|
149
|
+
children: column.children.map(
|
|
150
|
+
(child) => child.type === "inner-section" ? prefixSection(refId, child) : { ...child, id: pid(refId, child.id), props: prefixAnchor(refId, child.props) }
|
|
151
|
+
)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function prefixSection(refId, section) {
|
|
155
|
+
return {
|
|
156
|
+
...section,
|
|
157
|
+
id: pid(refId, section.id),
|
|
158
|
+
props: prefixAnchor(refId, section.props),
|
|
159
|
+
columns: section.columns.map((column) => prefixColumn(refId, column))
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
var parsed = /* @__PURE__ */ new WeakMap();
|
|
163
|
+
function sectionOf(entry) {
|
|
164
|
+
const cached = parsed.get(entry);
|
|
165
|
+
if (cached !== void 0) return cached;
|
|
166
|
+
const result = sectionNodeSchema.safeParse(entry.section);
|
|
167
|
+
const section = result.success ? result.data : null;
|
|
168
|
+
parsed.set(entry, section);
|
|
169
|
+
return section;
|
|
170
|
+
}
|
|
171
|
+
var sized = /* @__PURE__ */ new WeakMap();
|
|
172
|
+
function sizeOf(section) {
|
|
173
|
+
const known = sized.get(section);
|
|
174
|
+
if (known !== void 0) return known;
|
|
175
|
+
let size = 0;
|
|
176
|
+
walkNodes2({ sections: [section] }, () => {
|
|
177
|
+
size += 1;
|
|
178
|
+
});
|
|
179
|
+
sized.set(section, size);
|
|
180
|
+
return size;
|
|
181
|
+
}
|
|
182
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
183
|
+
var NONE = {};
|
|
184
|
+
function expandSavedSections(source, answer) {
|
|
185
|
+
if (!source.sections.some((root) => root.type === "saved-section")) return { doc: source, roots: null };
|
|
186
|
+
let perAnswer = cache.get(source);
|
|
187
|
+
if (perAnswer === void 0) {
|
|
188
|
+
perAnswer = /* @__PURE__ */ new WeakMap();
|
|
189
|
+
cache.set(source, perAnswer);
|
|
190
|
+
}
|
|
191
|
+
const key = answer ?? NONE;
|
|
192
|
+
const known = perAnswer.get(key);
|
|
193
|
+
if (known !== void 0) return known;
|
|
194
|
+
const made = expand(source, answer);
|
|
195
|
+
perAnswer.set(key, made);
|
|
196
|
+
return made;
|
|
197
|
+
}
|
|
198
|
+
function expand(source, answer) {
|
|
199
|
+
const sections = [];
|
|
200
|
+
const roots = [];
|
|
201
|
+
const snapshots = {};
|
|
202
|
+
let nodes = 0;
|
|
203
|
+
walkNodes2({ sections: source.sections.filter((root) => root.type === "section") }, () => {
|
|
204
|
+
nodes += 1;
|
|
205
|
+
});
|
|
206
|
+
for (const root of source.sections) {
|
|
207
|
+
if (root.type === "section") {
|
|
208
|
+
sections.push(root);
|
|
209
|
+
roots.push({ kind: "section", id: root.id });
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const entry = answer !== void 0 && Object.hasOwn(answer, root.ref) ? answer[root.ref] : void 0;
|
|
213
|
+
const section = entry === void 0 ? null : sectionOf(entry);
|
|
214
|
+
if (entry !== void 0 && section !== null && nodes + sizeOf(section) > MAX_EXPANDED_NODES) {
|
|
215
|
+
warnOnce("saved-section-cap", `A page holds more than ${String(MAX_EXPANDED_NODES)} nodes with its saved sections; the rest are left out`);
|
|
216
|
+
roots.push({ kind: "ref", ref: root, sectionId: null });
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (entry === void 0 || section === null) {
|
|
220
|
+
roots.push({ kind: "ref", ref: root, sectionId: null });
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
nodes += sizeOf(section);
|
|
224
|
+
const prefixed = prefixSection(root.id, section);
|
|
225
|
+
const anchor = root.props.anchor;
|
|
226
|
+
const placed = anchor !== void 0 ? { ...prefixed, props: { ...prefixed.props, anchor } } : prefixed;
|
|
227
|
+
sections.push(placed);
|
|
228
|
+
roots.push({ kind: "ref", ref: root, sectionId: placed.id });
|
|
229
|
+
for (const [snapshotKey, snapshot] of Object.entries(entry.customWidgets ?? {})) {
|
|
230
|
+
if (anyCustomWidgetSnapshotSchema.safeParse(snapshot).success) snapshots[snapshotKey] = snapshot;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const customWidgets = { ...snapshots, ...source.customWidgets };
|
|
234
|
+
return {
|
|
235
|
+
doc: { ...source, sections, ...Object.keys(customWidgets).length === 0 ? {} : { customWidgets } },
|
|
236
|
+
roots
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function MissingSavedSection({ node }) {
|
|
240
|
+
warnOnce(`saved-section:${node.ref}`, `Saved section ${node.ref} has no published section; rendering nothing for it`);
|
|
241
|
+
return /* @__PURE__ */ jsx2(NodeWrapper, { id: node.id, part: "section", as: "section", className: "tb-section", missing: true });
|
|
242
|
+
}
|
|
243
|
+
|
|
72
244
|
// src/load.ts
|
|
73
245
|
function pageOf(raw, initialData) {
|
|
74
|
-
const { document, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, ...meta } = raw;
|
|
246
|
+
const { document: document2, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
75
247
|
return {
|
|
76
248
|
kind: "page",
|
|
77
249
|
slug,
|
|
78
250
|
title,
|
|
79
251
|
path,
|
|
80
252
|
generation,
|
|
81
|
-
document,
|
|
82
|
-
assets:
|
|
253
|
+
document: document2,
|
|
254
|
+
assets: document2.assets ?? {},
|
|
83
255
|
initialData,
|
|
84
|
-
meta
|
|
256
|
+
meta,
|
|
257
|
+
...savedSections === void 0 ? {} : { savedSections },
|
|
258
|
+
...code === void 0 ? {} : { code }
|
|
85
259
|
};
|
|
86
260
|
}
|
|
87
261
|
async function staticDataFor(documents, registry, locale, currency) {
|
|
88
262
|
const bindings = /* @__PURE__ */ new Map();
|
|
89
|
-
for (const document of documents) {
|
|
90
|
-
for (const [key, binding] of collectBindings(
|
|
263
|
+
for (const { document: document2, savedSections } of documents) {
|
|
264
|
+
for (const [key, binding] of collectBindings(expandSavedSections(document2, savedSections).doc, registry)) bindings.set(key, binding);
|
|
91
265
|
}
|
|
92
266
|
if (bindings.size === 0) return {};
|
|
93
267
|
return resolveBindings(
|
|
@@ -97,16 +271,24 @@ async function staticDataFor(documents, registry, locale, currency) {
|
|
|
97
271
|
{ include: "static" }
|
|
98
272
|
);
|
|
99
273
|
}
|
|
100
|
-
function partOf(loaded, initialData) {
|
|
101
|
-
|
|
274
|
+
function partOf(loaded, initialData, shared = {}) {
|
|
275
|
+
const savedSections = loaded.savedSections ?? shared.savedSections;
|
|
276
|
+
const code = loaded.code ?? shared.code;
|
|
277
|
+
return {
|
|
278
|
+
document: loaded.document,
|
|
279
|
+
assets: loaded.document.assets ?? {},
|
|
280
|
+
initialData,
|
|
281
|
+
...savedSections === void 0 ? {} : { savedSections },
|
|
282
|
+
...code === void 0 ? {} : { code }
|
|
283
|
+
};
|
|
102
284
|
}
|
|
103
285
|
var isRedirect = (raw) => typeof raw.redirectTo === "string";
|
|
104
286
|
|
|
105
287
|
// src/server/bundle.ts
|
|
106
288
|
import * as React from "react";
|
|
107
289
|
import { createBuilderClient } from "@usethrottle/builder";
|
|
108
|
-
var
|
|
109
|
-
var requestBatches =
|
|
290
|
+
var cache3 = React.cache ?? ((fn) => fn);
|
|
291
|
+
var requestBatches = cache3(() => []);
|
|
110
292
|
function getBundle(ask) {
|
|
111
293
|
const batches = requestBatches();
|
|
112
294
|
const slots = new Set(ask.slots ?? []);
|
|
@@ -231,9 +413,9 @@ var BASICS_CSS = `@layer throttle{
|
|
|
231
413
|
}`;
|
|
232
414
|
|
|
233
415
|
// src/basics/util.tsx
|
|
234
|
-
import { jsx } from "react/jsx-runtime";
|
|
416
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
235
417
|
function BasicStyles() {
|
|
236
|
-
return /* @__PURE__ */
|
|
418
|
+
return /* @__PURE__ */ jsx3("style", { href: "tb-basics", precedence: "throttle", children: BASICS_CSS });
|
|
237
419
|
}
|
|
238
420
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
239
421
|
var str = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
@@ -245,9 +427,9 @@ function hrefOf(link, mediaOrigin) {
|
|
|
245
427
|
return safeUrl(link.href, "href", { mediaOrigin });
|
|
246
428
|
}
|
|
247
429
|
function Placeholder({ editMode, children }) {
|
|
248
|
-
return editMode ? /* @__PURE__ */
|
|
430
|
+
return editMode ? /* @__PURE__ */ jsx3("div", { className: "tb-b-empty", children }) : null;
|
|
249
431
|
}
|
|
250
|
-
var ID_RE = /^[a-z0-9]{8,24}
|
|
432
|
+
var ID_RE = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
|
|
251
433
|
var DEVICES = ["desktop", "tablet", "phone"];
|
|
252
434
|
function defaultOf(type, key) {
|
|
253
435
|
const def = BASIC_WIDGET_DEFINITIONS.find((d) => d.type === type);
|
|
@@ -275,7 +457,7 @@ function enumCss(node, rules) {
|
|
|
275
457
|
}
|
|
276
458
|
|
|
277
459
|
// src/basics/announcement.tsx
|
|
278
|
-
import { Fragment, jsx as
|
|
460
|
+
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
279
461
|
var KEY = "tb-announcement-dismissed";
|
|
280
462
|
function read(message) {
|
|
281
463
|
try {
|
|
@@ -299,8 +481,8 @@ function Announcement({ props, mediaOrigin, editMode }) {
|
|
|
299
481
|
}, [message]);
|
|
300
482
|
if (message === void 0) {
|
|
301
483
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
/* @__PURE__ */
|
|
484
|
+
/* @__PURE__ */ jsx4(BasicStyles, {}),
|
|
485
|
+
/* @__PURE__ */ jsx4(Placeholder, { editMode, children: "No announcement: turn one on in Site settings" })
|
|
304
486
|
] });
|
|
305
487
|
}
|
|
306
488
|
if (dismissed && !editMode) return null;
|
|
@@ -308,10 +490,10 @@ function Announcement({ props, mediaOrigin, editMode }) {
|
|
|
308
490
|
const strings = design?.strings;
|
|
309
491
|
const dismissLabel = (strings !== void 0 && Object.hasOwn(strings, "announcement.dismiss") ? str(strings["announcement.dismiss"]) : void 0) ?? SITE_STRING_DEFAULTS["announcement.dismiss"];
|
|
310
492
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
311
|
-
/* @__PURE__ */
|
|
493
|
+
/* @__PURE__ */ jsx4(BasicStyles, {}),
|
|
312
494
|
/* @__PURE__ */ jsxs("div", { className: "tb-b-announcement", role: "region", "aria-label": message, children: [
|
|
313
|
-
/* @__PURE__ */
|
|
314
|
-
props.dismissible === true && /* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ jsx4("span", { className: "tb-b-announcement-text", children: href === null ? message : /* @__PURE__ */ jsx4("a", { href, children: message }) }),
|
|
496
|
+
props.dismissible === true && /* @__PURE__ */ jsx4(
|
|
315
497
|
"button",
|
|
316
498
|
{
|
|
317
499
|
type: "button",
|
|
@@ -320,7 +502,7 @@ function Announcement({ props, mediaOrigin, editMode }) {
|
|
|
320
502
|
write(message);
|
|
321
503
|
setDismissed(true);
|
|
322
504
|
},
|
|
323
|
-
children: /* @__PURE__ */
|
|
505
|
+
children: /* @__PURE__ */ jsx4(Icon, { name: "close", size: 16, label: dismissLabel })
|
|
324
506
|
}
|
|
325
507
|
)
|
|
326
508
|
] })
|
|
@@ -328,7 +510,7 @@ function Announcement({ props, mediaOrigin, editMode }) {
|
|
|
328
510
|
}
|
|
329
511
|
|
|
330
512
|
// src/basics/button.tsx
|
|
331
|
-
import { Fragment as Fragment2, jsx as
|
|
513
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
332
514
|
var STYLES = ["primary", "secondary", "outline", "link"];
|
|
333
515
|
var SIZES = ["s", "m", "l"];
|
|
334
516
|
function Button({ props, mediaOrigin, inlineEdit }) {
|
|
@@ -336,52 +518,353 @@ function Button({ props, mediaOrigin, inlineEdit }) {
|
|
|
336
518
|
const className = `tb-b-button tb-b-button--${oneOf(props.style, STYLES, "primary")} tb-b-button--${oneOf(props.size, SIZES, "m")}`;
|
|
337
519
|
const label = inlineEdit?.("label") ?? str(props.label) ?? "";
|
|
338
520
|
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
521
|
+
/* @__PURE__ */ jsx5(BasicStyles, {}),
|
|
522
|
+
/* @__PURE__ */ jsx5("div", { className: "tb-b-button-wrap", children: /* @__PURE__ */ jsx5("a", { className, ...href === null ? {} : { href }, children: label }) })
|
|
341
523
|
] });
|
|
342
524
|
}
|
|
343
525
|
|
|
344
526
|
// src/basics/copyright.tsx
|
|
345
527
|
import { useSiteDesign as useSiteDesign2 } from "@usethrottle/ui";
|
|
346
528
|
import { SITE_STRING_DEFAULTS as SITE_STRING_DEFAULTS2 } from "@usethrottle/builder-schema";
|
|
347
|
-
import { Fragment as Fragment3, jsx as
|
|
529
|
+
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
348
530
|
function Copyright(_) {
|
|
349
531
|
const design = useSiteDesign2();
|
|
350
532
|
const strings = design?.strings;
|
|
351
533
|
const template = strings !== void 0 && Object.hasOwn(strings, "footer.copyright") ? str(strings["footer.copyright"]) : void 0;
|
|
352
534
|
const line = (template ?? SITE_STRING_DEFAULTS2["footer.copyright"]).replace("{year}", () => String((/* @__PURE__ */ new Date()).getFullYear())).replace("{store}", () => str(design?.brand?.storeName) ?? "").replace(/\s{2,}/g, " ").replace(/\s+([.,])/g, "$1");
|
|
353
535
|
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
536
|
+
/* @__PURE__ */ jsx6(BasicStyles, {}),
|
|
537
|
+
/* @__PURE__ */ jsx6("p", { className: "tb-b-copyright", children: line })
|
|
538
|
+
] });
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// src/interactions/entrance.tsx
|
|
542
|
+
import { useEffect as useEffect2 } from "react";
|
|
543
|
+
import { ENTRANCES } from "@usethrottle/builder-schema";
|
|
544
|
+
|
|
545
|
+
// src/interactions/styles.ts
|
|
546
|
+
var INTERACTIONS_CSS = `@layer throttle{
|
|
547
|
+
.tb-panel>.tb-col,.tb-acc-body>.tb-col,.tb-slide>.tb-col{inline-size:100%}
|
|
548
|
+
.tb-tablist{display:none;flex-wrap:wrap;gap:var(--tb-space-xs);border-block-end:1px solid var(--tb-color-border,currentColor);margin-block-end:var(--tb-space-m)}
|
|
549
|
+
html[data-b-js] .tb-tablist{display:flex}
|
|
550
|
+
html[data-b-js] .tb-panel-title{display:none}
|
|
551
|
+
.tb-panel-title{margin:0 0 var(--tb-space-s);font-weight:600}
|
|
552
|
+
.tb-panel[hidden]{display:none}
|
|
553
|
+
.tb-tab{appearance:none;cursor:pointer;font:inherit;color:inherit;background:none;border:0;border-block-end:2px solid transparent;padding:var(--tb-space-s) var(--tb-space-m)}
|
|
554
|
+
.tb-tab[aria-selected=true]{border-block-end-color:var(--tb-color-primary,currentColor);font-weight:600}
|
|
555
|
+
.tb-tab:focus-visible,.tb-car-btn:focus-visible,.tb-acc-sum:focus-visible,.tb-toggle-sum:focus-visible,.tb-car-track:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
556
|
+
.tb-acc-item{border-block-end:1px solid var(--tb-color-border,currentColor)}
|
|
557
|
+
.tb-acc-sum,.tb-toggle-sum{cursor:pointer;padding:var(--tb-space-s) 0;font-weight:600}
|
|
558
|
+
.tb-acc-body{padding-block-end:var(--tb-space-m)}
|
|
559
|
+
.tb-toggle-open,.tb-toggle[open] .tb-toggle-closed{display:none}
|
|
560
|
+
.tb-toggle[open] .tb-toggle-open{display:inline}
|
|
561
|
+
.tb-toggle .tb-row{margin-block-start:var(--tb-space-m)}
|
|
562
|
+
.tb-car{position:relative}
|
|
563
|
+
.tb-car-track{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:thin}
|
|
564
|
+
.tb-slide{flex:0 0 100%;min-inline-size:0;scroll-snap-align:start}
|
|
565
|
+
.tb-car-ctrl{display:none;justify-content:center;gap:var(--tb-space-s);margin-block-start:var(--tb-space-s)}
|
|
566
|
+
html[data-b-js] .tb-car-ctrl{display:flex}
|
|
567
|
+
.tb-car-btn{appearance:none;cursor:pointer;font:inherit;color:inherit;background:var(--tb-color-surface,transparent);border:1px solid var(--tb-color-border-control,currentColor);border-radius:999px;min-inline-size:2.5rem;min-block-size:2.5rem;padding:0 var(--tb-space-m)}
|
|
568
|
+
.tb-car-btn[hidden]{display:none}
|
|
569
|
+
@media (prefers-reduced-motion:no-preference){
|
|
570
|
+
html[data-b-js] [data-b-entrance]{transition:opacity .6s ease var(--tb-ed,0ms),transform .6s ease var(--tb-ed,0ms)}
|
|
571
|
+
html[data-b-js] [data-b-entrance]:not([data-b-in]){opacity:0}
|
|
572
|
+
html[data-b-js] [data-b-entrance=slide-up]:not([data-b-in]){transform:translateY(1.5rem)}
|
|
573
|
+
html[data-b-js] [data-b-entrance=slide-left]:not([data-b-in]){transform:translateX(-1.5rem)}
|
|
574
|
+
html[data-b-js] [data-b-entrance=zoom]:not([data-b-in]){transform:scale(.94)}
|
|
575
|
+
}
|
|
576
|
+
@media (prefers-reduced-motion:reduce){.tb-car-track{scroll-behavior:auto}}
|
|
577
|
+
}`;
|
|
578
|
+
|
|
579
|
+
// src/interactions/runtime.ts
|
|
580
|
+
var UNITS = [86400, 3600, 60, 1];
|
|
581
|
+
var KEYS = ["d", "h", "m", "s"];
|
|
582
|
+
var NAMES = ["days", "hours", "minutes", "seconds"];
|
|
583
|
+
var holds = 0;
|
|
584
|
+
var stop;
|
|
585
|
+
var seen2 = /* @__PURE__ */ new WeakSet();
|
|
586
|
+
var autoplay = /* @__PURE__ */ new Map();
|
|
587
|
+
var all = (selector) => Array.from(document.querySelectorAll(selector));
|
|
588
|
+
var reduced = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
|
|
589
|
+
function selectTab(list, index, focus = false) {
|
|
590
|
+
const tabs = Array.from(list.querySelectorAll("[role=tab]"));
|
|
591
|
+
tabs.forEach((tab, i) => {
|
|
592
|
+
const on = i === index;
|
|
593
|
+
tab.setAttribute("aria-selected", String(on));
|
|
594
|
+
tab.tabIndex = on ? 0 : -1;
|
|
595
|
+
const panel = document.getElementById(tab.getAttribute("aria-controls") ?? "");
|
|
596
|
+
if (panel !== null) panel.hidden = !on;
|
|
597
|
+
if (on && focus) tab.focus();
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function slideTo(root, step2) {
|
|
601
|
+
const track = root.querySelector(".tb-car-track");
|
|
602
|
+
if (track === null || track.clientWidth === 0) return;
|
|
603
|
+
const count = track.children.length;
|
|
604
|
+
const at = Math.round(track.scrollLeft / track.clientWidth) + step2;
|
|
605
|
+
const loop = root.hasAttribute("data-b-loop");
|
|
606
|
+
const to = at >= count ? loop ? 0 : count - 1 : at < 0 ? loop ? count - 1 : 0 : at;
|
|
607
|
+
track.scrollTo?.({ left: to * track.clientWidth, behavior: reduced() ? "auto" : "smooth" });
|
|
608
|
+
}
|
|
609
|
+
var carousels = /* @__PURE__ */ new WeakMap();
|
|
610
|
+
function setupCarousel(root) {
|
|
611
|
+
const every = Number(root.getAttribute("data-b-autoplay"));
|
|
612
|
+
const pause = root.querySelector("[data-b-act=pause]");
|
|
613
|
+
if (!(every > 0) || reduced() || pause === null) return;
|
|
614
|
+
pause.hidden = false;
|
|
615
|
+
let state = carousels.get(root);
|
|
616
|
+
if (state === void 0) {
|
|
617
|
+
const own = state = { hold: 0 };
|
|
618
|
+
carousels.set(root, own);
|
|
619
|
+
const set = (bit, on) => void (own.hold = on ? own.hold | bit : own.hold & ~bit);
|
|
620
|
+
root.addEventListener("mouseenter", () => set(1, true));
|
|
621
|
+
root.addEventListener("mouseleave", () => set(1, false));
|
|
622
|
+
root.addEventListener("focusin", () => set(2, true));
|
|
623
|
+
root.addEventListener("focusout", () => set(2, false));
|
|
624
|
+
pause.addEventListener("click", () => {
|
|
625
|
+
set(4, (own.hold & 4) === 0);
|
|
626
|
+
pause.textContent = own.hold & 4 ? "Play" : "Pause";
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
const shared = state;
|
|
630
|
+
autoplay.set(root, window.setInterval(() => shared.hold === 0 && slideTo(root, 1), every));
|
|
631
|
+
}
|
|
632
|
+
function remaining(el) {
|
|
633
|
+
return Math.max(0, Math.floor((Number(el.getAttribute("data-b-cd")) - Date.now()) / 1e3));
|
|
634
|
+
}
|
|
635
|
+
function tick(el, minute) {
|
|
636
|
+
let left = remaining(el);
|
|
637
|
+
const parts = [];
|
|
638
|
+
KEYS.forEach((key, i) => {
|
|
639
|
+
const out = el.querySelector(`[data-u=${key}]`);
|
|
640
|
+
if (out === null) return;
|
|
641
|
+
const value = Math.floor(left / UNITS[i]);
|
|
642
|
+
left -= value * UNITS[i];
|
|
643
|
+
out.textContent = String(value).padStart(2, "0");
|
|
644
|
+
parts.push(`${String(value)} ${out.nextElementSibling?.textContent || NAMES[i]}`);
|
|
645
|
+
});
|
|
646
|
+
const live = el.querySelector("[data-b-live]");
|
|
647
|
+
if (live !== null && minute) live.textContent = parts.join(", ");
|
|
648
|
+
if (remaining(el) === 0) {
|
|
649
|
+
el.setAttribute("data-b-ended", "");
|
|
650
|
+
const text2 = el.querySelector(".tb-b-cd-ended");
|
|
651
|
+
if (text2 !== null) text2.hidden = false;
|
|
652
|
+
if (el.getAttribute("data-b-expired") === "hide") el.hidden = true;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function scan() {
|
|
656
|
+
autoplay.forEach((id, root) => {
|
|
657
|
+
if (!root.isConnected) {
|
|
658
|
+
window.clearInterval(id);
|
|
659
|
+
autoplay.delete(root);
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
document.documentElement.setAttribute("data-b-js", "");
|
|
663
|
+
const fresh = (selector) => all(selector).filter((el) => !seen2.has(el) && seen2.add(el));
|
|
664
|
+
fresh("[data-b-tabs]").forEach((list) => selectTab(list, 0));
|
|
665
|
+
fresh("[data-b-car]").forEach((root) => setupCarousel(root));
|
|
666
|
+
const counts = fresh("[data-b-cd]");
|
|
667
|
+
counts.forEach((el) => tick(el, true));
|
|
668
|
+
const targets = fresh("[data-b-entrance]");
|
|
669
|
+
if (targets.length === 0) return;
|
|
670
|
+
if (typeof IntersectionObserver === "undefined") targets.forEach((el) => el.setAttribute("data-b-in", ""));
|
|
671
|
+
else {
|
|
672
|
+
const watch = new IntersectionObserver(
|
|
673
|
+
(entries) => entries.forEach((entry) => {
|
|
674
|
+
if (!entry.isIntersecting) return;
|
|
675
|
+
entry.target.setAttribute("data-b-in", "");
|
|
676
|
+
watch.unobserve(entry.target);
|
|
677
|
+
})
|
|
678
|
+
);
|
|
679
|
+
targets.forEach((el) => watch.observe(el));
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
var shown = (el) => el !== null && el.getClientRects().length > 0;
|
|
683
|
+
function goAnchor(name) {
|
|
684
|
+
if (name === "" || shown(document.getElementById(name))) return false;
|
|
685
|
+
const copy = all("[data-b-anchor]").find((el) => el.getAttribute("data-b-anchor") === name && shown(el));
|
|
686
|
+
copy?.scrollIntoView();
|
|
687
|
+
return copy !== void 0;
|
|
688
|
+
}
|
|
689
|
+
var decoded = (hash) => {
|
|
690
|
+
try {
|
|
691
|
+
return decodeURIComponent(hash.slice(1));
|
|
692
|
+
} catch {
|
|
693
|
+
return "";
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
var onHash = () => void goAnchor(decoded(location.hash));
|
|
697
|
+
function onClick(event) {
|
|
698
|
+
const target = event.target;
|
|
699
|
+
const href = target?.closest('a[href^="#"]')?.getAttribute("href");
|
|
700
|
+
if (href && !event.defaultPrevented && !event.button && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) && goAnchor(decoded(href))) {
|
|
701
|
+
event.preventDefault();
|
|
702
|
+
history.pushState(null, "", href);
|
|
703
|
+
}
|
|
704
|
+
const tab = target?.closest("[role=tab]");
|
|
705
|
+
const list = tab?.closest("[data-b-tabs]");
|
|
706
|
+
if (tab && list) return selectTab(list, Array.from(list.querySelectorAll("[role=tab]")).indexOf(tab));
|
|
707
|
+
const button = target?.closest("[data-b-act]");
|
|
708
|
+
const act = button?.getAttribute("data-b-act");
|
|
709
|
+
const root = button?.closest("[data-b-car]");
|
|
710
|
+
if (root && (act === "prev" || act === "next")) slideTo(root, act === "next" ? 1 : -1);
|
|
711
|
+
}
|
|
712
|
+
function onKey(event) {
|
|
713
|
+
const tab = event.target?.closest("[role=tab]");
|
|
714
|
+
const list = tab?.closest("[data-b-tabs]");
|
|
715
|
+
if (!tab || !list) return;
|
|
716
|
+
const count = list.querySelectorAll("[role=tab]").length;
|
|
717
|
+
const at = Array.from(list.querySelectorAll("[role=tab]")).indexOf(tab);
|
|
718
|
+
const to = event.key === "ArrowRight" ? (at + 1) % count : event.key === "ArrowLeft" ? (at + count - 1) % count : event.key === "Home" ? 0 : event.key === "End" ? count - 1 : -1;
|
|
719
|
+
if (to < 0) return;
|
|
720
|
+
event.preventDefault();
|
|
721
|
+
selectTab(list, to, true);
|
|
722
|
+
}
|
|
723
|
+
function startRuntime() {
|
|
724
|
+
if (typeof document === "undefined") return () => void 0;
|
|
725
|
+
const first = holds++ === 0;
|
|
726
|
+
if (first) {
|
|
727
|
+
document.addEventListener("click", onClick);
|
|
728
|
+
document.addEventListener("keydown", onKey);
|
|
729
|
+
window.addEventListener("hashchange", onHash);
|
|
730
|
+
let beat = 0;
|
|
731
|
+
const clock = window.setInterval(() => {
|
|
732
|
+
const minute = ++beat % 60 === 0;
|
|
733
|
+
all("[data-b-cd]:not([data-b-ended])").forEach((el) => tick(el, minute));
|
|
734
|
+
}, 1e3);
|
|
735
|
+
let queued = false;
|
|
736
|
+
const watcher = new MutationObserver(() => {
|
|
737
|
+
if (queued) return;
|
|
738
|
+
queued = true;
|
|
739
|
+
void Promise.resolve().then(() => {
|
|
740
|
+
queued = false;
|
|
741
|
+
if (holds > 0) scan();
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
watcher.observe(document.documentElement, { childList: true, subtree: true });
|
|
745
|
+
stop = () => {
|
|
746
|
+
document.removeEventListener("click", onClick);
|
|
747
|
+
document.removeEventListener("keydown", onKey);
|
|
748
|
+
window.removeEventListener("hashchange", onHash);
|
|
749
|
+
window.clearInterval(clock);
|
|
750
|
+
watcher.disconnect();
|
|
751
|
+
autoplay.forEach((id) => window.clearInterval(id));
|
|
752
|
+
autoplay.clear();
|
|
753
|
+
seen2 = /* @__PURE__ */ new WeakSet();
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
scan();
|
|
757
|
+
if (first) onHash();
|
|
758
|
+
return () => {
|
|
759
|
+
if (--holds === 0) stop?.();
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/interactions/entrance.tsx
|
|
764
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
765
|
+
function entranceOf(entrance, delayMs, interactive) {
|
|
766
|
+
if (!interactive || typeof entrance !== "string" || entrance === "none") return void 0;
|
|
767
|
+
if (!ENTRANCES.includes(entrance)) return void 0;
|
|
768
|
+
const delay = typeof delayMs === "number" && Number.isFinite(delayMs) ? Math.min(2e3, Math.max(0, Math.round(delayMs))) : 0;
|
|
769
|
+
return { name: entrance, delayMs: delay };
|
|
770
|
+
}
|
|
771
|
+
function InteractionRuntime() {
|
|
772
|
+
useEffect2(() => startRuntime(), []);
|
|
773
|
+
return /* @__PURE__ */ jsx7("style", { href: "tb-interactions", precedence: "throttle", children: INTERACTIONS_CSS });
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// src/basics/countdown.tsx
|
|
777
|
+
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
778
|
+
var UNITS2 = [
|
|
779
|
+
{ key: "d", show: "showDays", label: "labelDays", seconds: 86400 },
|
|
780
|
+
{ key: "h", show: "showHours", label: "labelHours", seconds: 3600 },
|
|
781
|
+
{ key: "m", show: "showMinutes", label: "labelMinutes", seconds: 60 },
|
|
782
|
+
{ key: "s", show: "showSeconds", label: "labelSeconds", seconds: 1 }
|
|
783
|
+
];
|
|
784
|
+
var COUNTDOWN_CSS = `@layer throttle{
|
|
785
|
+
.tb-b-cd{text-align:var(--b-align,center);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l))}
|
|
786
|
+
.tb-b-cd-date{margin:0}
|
|
787
|
+
.tb-b-cd-units{display:none;justify-content:var(--b-align,center);gap:var(--tb-space-m);flex-wrap:wrap}
|
|
788
|
+
html[data-b-js] .tb-b-cd-units{display:flex}
|
|
789
|
+
html[data-b-js] .tb-b-cd-date{font-size:.5em;opacity:.7}
|
|
790
|
+
.tb-b-cd-unit{display:flex;flex-direction:column;align-items:center;min-inline-size:3ch}
|
|
791
|
+
.tb-b-cd-num{font-variant-numeric:tabular-nums;font-weight:700;line-height:1.1}
|
|
792
|
+
.tb-b-cd-label{font-size:.45em;opacity:.8}
|
|
793
|
+
.tb-b-cd-ended{margin:0}
|
|
794
|
+
.tb-b-cd[data-b-ended] .tb-b-cd-units,.tb-b-cd[data-b-ended] .tb-b-cd-date{display:none}
|
|
795
|
+
.tb-b-sr{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
796
|
+
}`;
|
|
797
|
+
var two = (n) => String(n).padStart(2, "0");
|
|
798
|
+
function targetText(date) {
|
|
799
|
+
return `${date.toISOString().slice(0, 10)} ${date.toISOString().slice(11, 16)} UTC`;
|
|
800
|
+
}
|
|
801
|
+
function Countdown({ props, editMode, interactive, locale }) {
|
|
802
|
+
void locale;
|
|
803
|
+
const target = str(props.target);
|
|
804
|
+
const when = target === void 0 ? null : new Date(target);
|
|
805
|
+
if (when === null || Number.isNaN(when.getTime())) {
|
|
806
|
+
return /* @__PURE__ */ jsx8(Placeholder, { editMode, children: "Set the date and time the countdown ends" });
|
|
807
|
+
}
|
|
808
|
+
const live = interactive !== false;
|
|
809
|
+
const behavior = oneOf(props.expiredBehavior, ["text", "hide"], "text");
|
|
810
|
+
const shown2 = UNITS2.filter((unit) => props[unit.show] !== false);
|
|
811
|
+
let left = live ? 0 : Math.max(0, Math.floor((when.getTime() - Date.now()) / 1e3));
|
|
812
|
+
const units = shown2.map((unit) => {
|
|
813
|
+
const value = live ? null : Math.floor(left / unit.seconds);
|
|
814
|
+
if (value !== null) left -= value * unit.seconds;
|
|
815
|
+
return { ...unit, text: value === null ? "--" : two(value), name: str(props[unit.label]) ?? "" };
|
|
816
|
+
});
|
|
817
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
818
|
+
/* @__PURE__ */ jsx8(BasicStyles, {}),
|
|
819
|
+
/* @__PURE__ */ jsx8("style", { href: "tb-countdown", precedence: "throttle", children: COUNTDOWN_CSS }),
|
|
820
|
+
live ? /* @__PURE__ */ jsx8(InteractionRuntime, {}) : null,
|
|
821
|
+
/* @__PURE__ */ jsxs4(
|
|
822
|
+
"div",
|
|
823
|
+
{
|
|
824
|
+
className: "tb-b-cd",
|
|
825
|
+
role: "timer",
|
|
826
|
+
"aria-live": "off",
|
|
827
|
+
...live ? { "data-b-cd": String(when.getTime()), "data-b-expired": behavior } : {},
|
|
828
|
+
children: [
|
|
829
|
+
/* @__PURE__ */ jsx8("p", { className: "tb-b-cd-date", children: /* @__PURE__ */ jsx8("time", { dateTime: when.toISOString(), children: targetText(when) }) }),
|
|
830
|
+
units.length === 0 ? null : /* @__PURE__ */ jsx8("div", { className: "tb-b-cd-units", children: units.map((unit) => /* @__PURE__ */ jsxs4("div", { className: "tb-b-cd-unit", children: [
|
|
831
|
+
/* @__PURE__ */ jsx8("span", { className: "tb-b-cd-num", "data-u": unit.key, "aria-hidden": "true", children: unit.text }),
|
|
832
|
+
/* @__PURE__ */ jsx8("span", { className: "tb-b-cd-label", children: unit.name })
|
|
833
|
+
] }, unit.key)) }),
|
|
834
|
+
/* @__PURE__ */ jsx8("p", { className: "tb-b-cd-ended", hidden: live || when.getTime() > Date.now(), children: str(props.expiredText) ?? "" }),
|
|
835
|
+
/* @__PURE__ */ jsx8("span", { className: "tb-b-sr", "data-b-live": "", "aria-live": "polite" })
|
|
836
|
+
]
|
|
837
|
+
}
|
|
838
|
+
)
|
|
356
839
|
] });
|
|
357
840
|
}
|
|
358
841
|
|
|
359
842
|
// src/widget-style.tsx
|
|
360
|
-
import { jsx as
|
|
843
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
361
844
|
function WidgetStyle({ css }) {
|
|
362
845
|
if (css === "" || css.includes("<")) return null;
|
|
363
|
-
return /* @__PURE__ */
|
|
846
|
+
return /* @__PURE__ */ jsx9("style", { children: css });
|
|
364
847
|
}
|
|
365
848
|
|
|
366
849
|
// src/basics/divider.tsx
|
|
367
|
-
import { Fragment as
|
|
850
|
+
import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
368
851
|
var RULES = [{ key: "style", property: "--bx-style", values: { solid: "solid", dashed: "dashed", dotted: "dotted" } }];
|
|
369
852
|
function Divider({ node }) {
|
|
370
|
-
return /* @__PURE__ */
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
853
|
+
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
854
|
+
/* @__PURE__ */ jsx10(BasicStyles, {}),
|
|
855
|
+
/* @__PURE__ */ jsx10(WidgetStyle, { css: enumCss(node, RULES) }),
|
|
856
|
+
/* @__PURE__ */ jsx10("hr", { className: "tb-b-divider" })
|
|
374
857
|
] });
|
|
375
858
|
}
|
|
376
859
|
|
|
377
860
|
// src/basics/heading.tsx
|
|
378
|
-
import { Fragment as
|
|
861
|
+
import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
379
862
|
var LEVELS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
380
863
|
function Heading({ props, inlineEdit }) {
|
|
381
864
|
const Tag = oneOf(props.level, LEVELS, "h2");
|
|
382
|
-
return /* @__PURE__ */
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
865
|
+
return /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
866
|
+
/* @__PURE__ */ jsx11(BasicStyles, {}),
|
|
867
|
+
/* @__PURE__ */ jsx11(Tag, { className: "tb-b-heading", children: inlineEdit?.("text") ?? str(props.text) ?? "" })
|
|
385
868
|
] });
|
|
386
869
|
}
|
|
387
870
|
|
|
@@ -390,7 +873,7 @@ import { safeUrl as safeUrl4 } from "@usethrottle/builder-schema";
|
|
|
390
873
|
|
|
391
874
|
// src/asset-image.tsx
|
|
392
875
|
import { safeUrl as safeUrl3 } from "@usethrottle/builder-schema";
|
|
393
|
-
import { jsx as
|
|
876
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
394
877
|
function isFrozenAsset(value) {
|
|
395
878
|
if (typeof value !== "object" || value === null) return false;
|
|
396
879
|
const v = value;
|
|
@@ -406,7 +889,7 @@ function AssetImage(props) {
|
|
|
406
889
|
const url = href(variant.url);
|
|
407
890
|
return url === null || url.includes(",") ? [] : [`${url} ${String(variant.width)}w`];
|
|
408
891
|
}).join(", ");
|
|
409
|
-
return /* @__PURE__ */
|
|
892
|
+
return /* @__PURE__ */ jsx12(
|
|
410
893
|
"img",
|
|
411
894
|
{
|
|
412
895
|
src,
|
|
@@ -423,7 +906,7 @@ function AssetImage(props) {
|
|
|
423
906
|
}
|
|
424
907
|
|
|
425
908
|
// src/basics/image.tsx
|
|
426
|
-
import { Fragment as
|
|
909
|
+
import { Fragment as Fragment7, jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
427
910
|
var RULES2 = [
|
|
428
911
|
{ key: "radius", property: "--bx-radius", values: { none: "0", s: "4px", m: "8px", l: "16px", full: "9999px" } },
|
|
429
912
|
{ key: "fit", property: "--bx-fit", values: { cover: "cover", contain: "contain" } }
|
|
@@ -433,19 +916,19 @@ function Image({ node, props, mediaOrigin, editMode }) {
|
|
|
433
916
|
const decorative = props.decorative === true;
|
|
434
917
|
const alt = decorative ? "" : typeof props.alt === "string" ? props.alt : "";
|
|
435
918
|
const asset = isFrozenAsset(props.image) ? props.image : void 0;
|
|
436
|
-
const image = /* @__PURE__ */
|
|
437
|
-
const
|
|
438
|
-
return /* @__PURE__ */
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
441
|
-
|
|
919
|
+
const image = /* @__PURE__ */ jsx13(AssetImage, { asset, mediaOrigin, alt, className: "tb-b-img", sizes: "(max-width: 767px) 100vw, 50vw" });
|
|
920
|
+
const shown2 = asset !== void 0 && safeUrl4(asset.url, "src", { mediaOrigin }) !== null;
|
|
921
|
+
return /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
922
|
+
/* @__PURE__ */ jsx13(BasicStyles, {}),
|
|
923
|
+
/* @__PURE__ */ jsx13(WidgetStyle, { css: enumCss(node, RULES2) }),
|
|
924
|
+
shown2 ? /* @__PURE__ */ jsx13("div", { className: "tb-b-image", children: /* @__PURE__ */ jsx13("div", { className: "tb-b-image-box", children: href === null ? image : /* @__PURE__ */ jsx13("a", { href, children: image }) }) }) : /* @__PURE__ */ jsx13(Placeholder, { editMode, children: asset === void 0 ? "Choose an image" : "Image unavailable" })
|
|
442
925
|
] });
|
|
443
926
|
}
|
|
444
927
|
|
|
445
928
|
// src/basics/logo.tsx
|
|
446
929
|
import { useSiteDesign as useSiteDesign3 } from "@usethrottle/ui";
|
|
447
930
|
import { safeUrl as safeUrl5 } from "@usethrottle/builder-schema";
|
|
448
|
-
import { Fragment as
|
|
931
|
+
import { Fragment as Fragment8, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
449
932
|
function Logo({ props, mediaOrigin, editMode }) {
|
|
450
933
|
const design = useSiteDesign3();
|
|
451
934
|
const scheme = design?.theme?.colorScheme ?? "auto";
|
|
@@ -458,17 +941,17 @@ function Logo({ props, mediaOrigin, editMode }) {
|
|
|
458
941
|
const alt = name ?? "";
|
|
459
942
|
let content = null;
|
|
460
943
|
if (main !== void 0) {
|
|
461
|
-
const img = /* @__PURE__ */
|
|
462
|
-
content = scheme === "auto" && light !== void 0 && dark !== void 0 ? /* @__PURE__ */
|
|
463
|
-
/* @__PURE__ */
|
|
944
|
+
const img = /* @__PURE__ */ jsx14("img", { src: main, alt, decoding: "async" });
|
|
945
|
+
content = scheme === "auto" && light !== void 0 && dark !== void 0 ? /* @__PURE__ */ jsxs8("picture", { children: [
|
|
946
|
+
/* @__PURE__ */ jsx14("source", { media: "(prefers-color-scheme: dark)", srcSet: dark }),
|
|
464
947
|
img
|
|
465
948
|
] }) : img;
|
|
466
949
|
} else if (name !== void 0) {
|
|
467
|
-
content = /* @__PURE__ */
|
|
950
|
+
content = /* @__PURE__ */ jsx14("span", { className: "tb-b-logo-name", children: name });
|
|
468
951
|
}
|
|
469
|
-
return /* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */
|
|
471
|
-
content === null ? /* @__PURE__ */
|
|
952
|
+
return /* @__PURE__ */ jsxs8(Fragment8, { children: [
|
|
953
|
+
/* @__PURE__ */ jsx14(BasicStyles, {}),
|
|
954
|
+
content === null ? /* @__PURE__ */ jsx14(Placeholder, { editMode, children: "Logo: add one in Site settings" }) : /* @__PURE__ */ jsx14("div", { className: "tb-b-logo", children: /* @__PURE__ */ jsx14("a", { href, children: content }) })
|
|
472
955
|
] });
|
|
473
956
|
}
|
|
474
957
|
|
|
@@ -476,18 +959,18 @@ function Logo({ props, mediaOrigin, editMode }) {
|
|
|
476
959
|
import { useId, useRef, useState as useState2 } from "react";
|
|
477
960
|
import { Icon as Icon2, useSiteDesign as useSiteDesign4 } from "@usethrottle/ui";
|
|
478
961
|
import { SITE_STRING_DEFAULTS as SITE_STRING_DEFAULTS3, safeUrl as safeUrl6 } from "@usethrottle/builder-schema";
|
|
479
|
-
import { Fragment as
|
|
962
|
+
import { Fragment as Fragment9, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
480
963
|
var LAYOUTS = ["horizontal", "vertical", "drawer-on-phone"];
|
|
481
964
|
var MAX_DEPTH = 3;
|
|
482
965
|
function List({ items, mediaOrigin, depth = 0, id, onNavigate }) {
|
|
483
|
-
const
|
|
966
|
+
const shown2 = items.flatMap((item) => {
|
|
484
967
|
const href = safeUrl6(item.href, "href", { mediaOrigin });
|
|
485
968
|
return href === null ? [] : [{ item, href }];
|
|
486
969
|
});
|
|
487
|
-
if (
|
|
488
|
-
return /* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
-
depth + 1 < MAX_DEPTH && item.children !== void 0 && /* @__PURE__ */
|
|
970
|
+
if (shown2.length === 0) return null;
|
|
971
|
+
return /* @__PURE__ */ jsx15("ul", { ...id === void 0 ? {} : { id }, ...onNavigate === void 0 ? {} : { onClick: onNavigate }, children: shown2.map(({ item, href }, index) => /* @__PURE__ */ jsxs9("li", { children: [
|
|
972
|
+
/* @__PURE__ */ jsx15("a", { href, children: item.label }),
|
|
973
|
+
depth + 1 < MAX_DEPTH && item.children !== void 0 && /* @__PURE__ */ jsx15(List, { items: item.children, mediaOrigin, depth: depth + 1 })
|
|
491
974
|
] }, `${String(index)}:${href}`)) });
|
|
492
975
|
}
|
|
493
976
|
function Menu({ props, mediaOrigin, editMode }) {
|
|
@@ -502,9 +985,9 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
502
985
|
const strings = design?.strings;
|
|
503
986
|
const label = (strings !== void 0 && Object.hasOwn(strings, "nav.menu") ? str(strings["nav.menu"]) : void 0) ?? SITE_STRING_DEFAULTS3["nav.menu"];
|
|
504
987
|
if (items === void 0 || items.length === 0) {
|
|
505
|
-
return /* @__PURE__ */
|
|
506
|
-
/* @__PURE__ */
|
|
507
|
-
/* @__PURE__ */
|
|
988
|
+
return /* @__PURE__ */ jsxs9(Fragment9, { children: [
|
|
989
|
+
/* @__PURE__ */ jsx15(BasicStyles, {}),
|
|
990
|
+
/* @__PURE__ */ jsx15(Placeholder, { editMode, children: `Menu "${name}" is empty: add links in Site settings` })
|
|
508
991
|
] });
|
|
509
992
|
}
|
|
510
993
|
const drawer = layout === "drawer-on-phone";
|
|
@@ -514,9 +997,9 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
514
997
|
toggle.current?.focus();
|
|
515
998
|
}
|
|
516
999
|
};
|
|
517
|
-
return /* @__PURE__ */
|
|
518
|
-
/* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */
|
|
1000
|
+
return /* @__PURE__ */ jsxs9(Fragment9, { children: [
|
|
1001
|
+
/* @__PURE__ */ jsx15(BasicStyles, {}),
|
|
1002
|
+
/* @__PURE__ */ jsxs9(
|
|
520
1003
|
"nav",
|
|
521
1004
|
{
|
|
522
1005
|
className: `tb-b-menu tb-b-menu--${layout}${layout === "vertical" ? "" : " tb-b-menu--h"}`,
|
|
@@ -524,7 +1007,7 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
524
1007
|
"data-open": drawer ? String(open) : void 0,
|
|
525
1008
|
onKeyDown: drawer ? onKeyDown : void 0,
|
|
526
1009
|
children: [
|
|
527
|
-
drawer && /* @__PURE__ */
|
|
1010
|
+
drawer && /* @__PURE__ */ jsx15(
|
|
528
1011
|
"button",
|
|
529
1012
|
{
|
|
530
1013
|
ref: toggle,
|
|
@@ -533,10 +1016,10 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
533
1016
|
"aria-expanded": open,
|
|
534
1017
|
"aria-controls": listId,
|
|
535
1018
|
onClick: () => setOpen((value) => !value),
|
|
536
|
-
children: /* @__PURE__ */
|
|
1019
|
+
children: /* @__PURE__ */ jsx15(Icon2, { name: open ? "close" : "menu", size: 24, label })
|
|
537
1020
|
}
|
|
538
1021
|
),
|
|
539
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ jsx15(List, { items, mediaOrigin, id: listId, ...drawer ? { onNavigate: () => setOpen(false) } : {} })
|
|
540
1023
|
]
|
|
541
1024
|
}
|
|
542
1025
|
)
|
|
@@ -544,18 +1027,18 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
544
1027
|
}
|
|
545
1028
|
|
|
546
1029
|
// src/basics/spacer.tsx
|
|
547
|
-
import { Fragment as
|
|
1030
|
+
import { Fragment as Fragment10, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
548
1031
|
function Spacer() {
|
|
549
|
-
return /* @__PURE__ */
|
|
550
|
-
/* @__PURE__ */
|
|
551
|
-
/* @__PURE__ */
|
|
1032
|
+
return /* @__PURE__ */ jsxs10(Fragment10, { children: [
|
|
1033
|
+
/* @__PURE__ */ jsx16(BasicStyles, {}),
|
|
1034
|
+
/* @__PURE__ */ jsx16("div", { className: "tb-b-spacer", "aria-hidden": "true" })
|
|
552
1035
|
] });
|
|
553
1036
|
}
|
|
554
1037
|
|
|
555
1038
|
// src/basics/rich-text.tsx
|
|
556
|
-
import { Fragment as
|
|
1039
|
+
import { Fragment as Fragment11, createElement } from "react";
|
|
557
1040
|
import { safeUrl as safeUrl7 } from "@usethrottle/builder-schema";
|
|
558
|
-
import { jsx as
|
|
1041
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
559
1042
|
var ALLOWED = /* @__PURE__ */ new Set(["p", "br", "strong", "em", "u", "s", "a", "ul", "ol", "li", "h2", "h3", "h4", "blockquote", "code"]);
|
|
560
1043
|
var ALIAS = { b: "strong", i: "em", strike: "s", del: "s" };
|
|
561
1044
|
var DROP_WITH_CONTENT = /* @__PURE__ */ new Set([
|
|
@@ -735,10 +1218,10 @@ function parseRichText(source, mediaOrigin) {
|
|
|
735
1218
|
}
|
|
736
1219
|
function toReact(el, key) {
|
|
737
1220
|
const children = el.children.map((child, index) => typeof child === "string" ? child : toReact(child, index));
|
|
738
|
-
if (el.tag === "br") return /* @__PURE__ */
|
|
1221
|
+
if (el.tag === "br") return /* @__PURE__ */ jsx17("br", {}, key);
|
|
739
1222
|
if (el.tag === "a") {
|
|
740
|
-
if (el.href === null || el.href === void 0) return /* @__PURE__ */
|
|
741
|
-
return /* @__PURE__ */
|
|
1223
|
+
if (el.href === null || el.href === void 0) return /* @__PURE__ */ jsx17(Fragment11, { children }, key);
|
|
1224
|
+
return /* @__PURE__ */ jsx17("a", { href: el.href, rel: "noopener noreferrer", className: "tb-b-link", children }, key);
|
|
742
1225
|
}
|
|
743
1226
|
return createElement(el.tag, { key }, ...children);
|
|
744
1227
|
}
|
|
@@ -749,26 +1232,26 @@ function RichText({
|
|
|
749
1232
|
editMode = false
|
|
750
1233
|
}) {
|
|
751
1234
|
const tree = parseRichText(html, mediaOrigin);
|
|
752
|
-
return /* @__PURE__ */
|
|
1235
|
+
return /* @__PURE__ */ jsxs11("div", { className, children: [
|
|
753
1236
|
tree.children.map((child, index) => typeof child === "string" ? child : toReact(child, index)),
|
|
754
|
-
editMode && tree.truncated === true && /* @__PURE__ */
|
|
1237
|
+
editMode && tree.truncated === true && /* @__PURE__ */ jsx17("div", { className: "tb-b-empty", role: "alert", children: "Part of this text was not shown: a tag is not closed (check the quotes in links), or the text is too long." })
|
|
755
1238
|
] });
|
|
756
1239
|
}
|
|
757
1240
|
|
|
758
1241
|
// src/basics/text.tsx
|
|
759
|
-
import { Fragment as
|
|
1242
|
+
import { Fragment as Fragment12, jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
760
1243
|
function Text({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
761
1244
|
const editor = inlineEdit?.("html") ?? null;
|
|
762
|
-
return /* @__PURE__ */
|
|
763
|
-
/* @__PURE__ */
|
|
764
|
-
editor === null ? /* @__PURE__ */
|
|
1245
|
+
return /* @__PURE__ */ jsxs12(Fragment12, { children: [
|
|
1246
|
+
/* @__PURE__ */ jsx18(BasicStyles, {}),
|
|
1247
|
+
editor === null ? /* @__PURE__ */ jsx18(RichText, { html: str(props.html) ?? "", mediaOrigin, className: "tb-b-text", editMode }) : /* @__PURE__ */ jsx18("div", { className: "tb-b-text", children: editor })
|
|
765
1248
|
] });
|
|
766
1249
|
}
|
|
767
1250
|
|
|
768
1251
|
// src/basics/video.tsx
|
|
769
1252
|
import { useState as useState3 } from "react";
|
|
770
1253
|
import { Icon as Icon3 } from "@usethrottle/ui";
|
|
771
|
-
import { Fragment as
|
|
1254
|
+
import { Fragment as Fragment13, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
772
1255
|
var RULES3 = [
|
|
773
1256
|
{ key: "ratio", property: "--bx-ratio", values: { "16:9": "16 / 9", "4:3": "4 / 3", "1:1": "1 / 1", "9:16": "9 / 16" } }
|
|
774
1257
|
];
|
|
@@ -810,10 +1293,10 @@ function embedSrc(video, muted) {
|
|
|
810
1293
|
function Video({ node, props, editMode }) {
|
|
811
1294
|
const [loaded, setLoaded] = useState3(false);
|
|
812
1295
|
const video = parseVideoUrl(str(props.url) ?? "");
|
|
813
|
-
return /* @__PURE__ */
|
|
814
|
-
/* @__PURE__ */
|
|
815
|
-
/* @__PURE__ */
|
|
816
|
-
video === null ? /* @__PURE__ */
|
|
1296
|
+
return /* @__PURE__ */ jsxs13(Fragment13, { children: [
|
|
1297
|
+
/* @__PURE__ */ jsx19(BasicStyles, {}),
|
|
1298
|
+
/* @__PURE__ */ jsx19(WidgetStyle, { css: enumCss(node, RULES3) }),
|
|
1299
|
+
video === null ? /* @__PURE__ */ jsx19(Placeholder, { editMode, children: "Paste a YouTube or Vimeo link" }) : /* @__PURE__ */ jsx19("div", { className: "tb-b-video", "data-provider": video.provider, children: loaded && !editMode ? /* @__PURE__ */ jsx19(
|
|
817
1300
|
"iframe",
|
|
818
1301
|
{
|
|
819
1302
|
src: embedSrc(video, props.autoplayMuted === true),
|
|
@@ -822,7 +1305,7 @@ function Video({ node, props, editMode }) {
|
|
|
822
1305
|
referrerPolicy: "strict-origin-when-cross-origin",
|
|
823
1306
|
sandbox: "allow-scripts allow-same-origin allow-presentation allow-popups"
|
|
824
1307
|
}
|
|
825
|
-
) : /* @__PURE__ */
|
|
1308
|
+
) : /* @__PURE__ */ jsx19("button", { type: "button", className: "tb-b-play", "aria-label": "Play video", onClick: () => setLoaded(true), children: /* @__PURE__ */ jsx19("span", { children: /* @__PURE__ */ jsx19(Icon3, { name: "play", size: 28 }) }) }) })
|
|
826
1309
|
] });
|
|
827
1310
|
}
|
|
828
1311
|
|
|
@@ -838,7 +1321,8 @@ var BASIC_COMPONENTS = {
|
|
|
838
1321
|
"basic.logo": Logo,
|
|
839
1322
|
"basic.menu": Menu,
|
|
840
1323
|
"basic.announcement": Announcement,
|
|
841
|
-
"basic.copyright": Copyright
|
|
1324
|
+
"basic.copyright": Copyright,
|
|
1325
|
+
"basic.countdown": Countdown
|
|
842
1326
|
};
|
|
843
1327
|
var widgets = BASIC_WIDGET_DEFINITIONS2.flatMap(
|
|
844
1328
|
(definition) => Object.hasOwn(BASIC_COMPONENTS, definition.type) ? [{ ...definition, Component: BASIC_COMPONENTS[definition.type] }] : []
|
|
@@ -849,7 +1333,7 @@ var basicPack = { id: "basic", version: "0.0.0", widgets, dataSources: [] };
|
|
|
849
1333
|
import { createElement as createElement3 } from "react";
|
|
850
1334
|
|
|
851
1335
|
// src/custom/composite-widget.tsx
|
|
852
|
-
import { Suspense as
|
|
1336
|
+
import { Suspense as Suspense3 } from "react";
|
|
853
1337
|
import { pageDocumentSchema, validateSettingValue as validateSettingValue3 } from "@usethrottle/builder-schema";
|
|
854
1338
|
|
|
855
1339
|
// src/budget.ts
|
|
@@ -879,71 +1363,528 @@ var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => templateWeight(ast) <= lim
|
|
|
879
1363
|
import { Component } from "react";
|
|
880
1364
|
|
|
881
1365
|
// src/renderer.tsx
|
|
882
|
-
import { Fragment as
|
|
1366
|
+
import { Fragment as Fragment16 } from "react";
|
|
883
1367
|
import {
|
|
1368
|
+
ANCHOR_RE as ANCHOR_RE3,
|
|
884
1369
|
COMMON_WIDGET_SETTINGS as COMMON_WIDGET_SETTINGS2,
|
|
1370
|
+
resolveEntrance,
|
|
1371
|
+
resolveInteraction,
|
|
1372
|
+
codeWidgetSnapshotSchema,
|
|
885
1373
|
resolveResponsive as resolveResponsive3,
|
|
886
|
-
safeUrl as
|
|
1374
|
+
safeUrl as safeUrl10,
|
|
887
1375
|
upgradeNodes,
|
|
888
1376
|
validateSettingValue as validateSettingValue2,
|
|
889
|
-
walkNodes as
|
|
1377
|
+
walkNodes as walkNodes3
|
|
890
1378
|
} from "@usethrottle/builder-schema";
|
|
891
1379
|
|
|
892
|
-
// src/
|
|
1380
|
+
// src/code/code-widget.tsx
|
|
1381
|
+
import { Suspense as Suspense2 } from "react";
|
|
1382
|
+
import { LIMITS } from "@usethrottle/builder-schema";
|
|
1383
|
+
|
|
1384
|
+
// src/custom/custom-css.tsx
|
|
1385
|
+
import { sanitizeWidgetCss } from "@usethrottle/builder-schema";
|
|
1386
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1387
|
+
function scopedCss(source, type) {
|
|
1388
|
+
if (source === void 0 || source === "") return "";
|
|
1389
|
+
if (typeof source !== "string") return null;
|
|
1390
|
+
const result = sanitizeWidgetCss(source, type);
|
|
1391
|
+
return result.ok ? result.css : null;
|
|
1392
|
+
}
|
|
1393
|
+
function CustomCss({ css }) {
|
|
1394
|
+
return /* @__PURE__ */ jsx20(WidgetStyle, { css });
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
// src/custom/interpreter.tsx
|
|
1398
|
+
import { Fragment as Fragment14, createElement as createElement2 } from "react";
|
|
893
1399
|
import {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1400
|
+
ALLOWED_ATTRS,
|
|
1401
|
+
ALLOWED_ELEMENTS,
|
|
1402
|
+
ALLOWED_ROLES,
|
|
1403
|
+
CLASS_TOKEN_RE,
|
|
1404
|
+
DATA_ATTR_RE,
|
|
1405
|
+
EACH_ITERATION_CAP,
|
|
1406
|
+
RESERVED_DATA_PREFIX,
|
|
1407
|
+
VOID_ELEMENTS,
|
|
1408
|
+
isReservedClass,
|
|
1409
|
+
safeUrl as safeUrl8
|
|
901
1410
|
} from "@usethrottle/builder-schema";
|
|
902
|
-
|
|
903
|
-
var
|
|
904
|
-
var
|
|
905
|
-
var
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
"
|
|
911
|
-
"
|
|
912
|
-
"
|
|
913
|
-
|
|
914
|
-
"muted",
|
|
915
|
-
"muted-foreground",
|
|
916
|
-
"border",
|
|
917
|
-
"border-control",
|
|
918
|
-
"accent",
|
|
919
|
-
"sale",
|
|
920
|
-
"success",
|
|
921
|
-
"warning",
|
|
922
|
-
"danger"
|
|
1411
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1412
|
+
var MAX_OUTPUT_CHARS = 1e6;
|
|
1413
|
+
var MAX_ATTR_CHARS = 2e3;
|
|
1414
|
+
var MAX_DEPTH3 = 24;
|
|
1415
|
+
function newEnv(env) {
|
|
1416
|
+
return { ...env, charsLeft: MAX_OUTPUT_CHARS, stopped: false };
|
|
1417
|
+
}
|
|
1418
|
+
var BLOCKED = /* @__PURE__ */ new Set([
|
|
1419
|
+
"__proto__",
|
|
1420
|
+
"constructor",
|
|
1421
|
+
"prototype",
|
|
1422
|
+
...Object.getOwnPropertyNames(Object.prototype)
|
|
923
1423
|
]);
|
|
924
|
-
var
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
function
|
|
930
|
-
|
|
931
|
-
if (
|
|
932
|
-
|
|
933
|
-
|
|
1424
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1425
|
+
function step(value, key) {
|
|
1426
|
+
if (BLOCKED.has(key) || !isPlainObject(value) || !Object.hasOwn(value, key)) return void 0;
|
|
1427
|
+
return value[key];
|
|
1428
|
+
}
|
|
1429
|
+
function lookup(path, env, scope) {
|
|
1430
|
+
const [root, ...rest] = path;
|
|
1431
|
+
if (root === void 0) return void 0;
|
|
1432
|
+
if (root === "locale") return rest.length === 0 ? env.locale : void 0;
|
|
1433
|
+
let value;
|
|
1434
|
+
if (root === "settings") value = rest.length === 0 ? void 0 : env.settings;
|
|
1435
|
+
else if (root === "data") value = rest.length === 0 ? void 0 : env.data;
|
|
1436
|
+
else if (scope.has(root)) value = scope.get(root);
|
|
1437
|
+
else return void 0;
|
|
1438
|
+
for (const key of rest) {
|
|
1439
|
+
value = step(value, key);
|
|
1440
|
+
if (value === void 0) return void 0;
|
|
934
1441
|
}
|
|
935
|
-
return
|
|
1442
|
+
return value;
|
|
936
1443
|
}
|
|
937
|
-
function
|
|
938
|
-
if (value === "
|
|
939
|
-
if (typeof value === "
|
|
940
|
-
|
|
1444
|
+
function truthy(value) {
|
|
1445
|
+
if (value === null || value === void 0 || value === false || value === "") return false;
|
|
1446
|
+
if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
|
|
1447
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
1448
|
+
return true;
|
|
941
1449
|
}
|
|
942
|
-
function
|
|
943
|
-
if (typeof value === "string") return
|
|
944
|
-
|
|
1450
|
+
function asText(value) {
|
|
1451
|
+
if (typeof value === "string") return value;
|
|
1452
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
1453
|
+
return "";
|
|
945
1454
|
}
|
|
946
|
-
function
|
|
1455
|
+
function filtered(value, filters) {
|
|
1456
|
+
let text2 = asText(value);
|
|
1457
|
+
for (const filter of filters) {
|
|
1458
|
+
switch (filter.name) {
|
|
1459
|
+
case "upper":
|
|
1460
|
+
text2 = text2.toUpperCase();
|
|
1461
|
+
break;
|
|
1462
|
+
case "lower":
|
|
1463
|
+
text2 = text2.toLowerCase();
|
|
1464
|
+
break;
|
|
1465
|
+
case "truncate": {
|
|
1466
|
+
const chars = Array.from(text2);
|
|
1467
|
+
if (chars.length > filter.n) text2 = `${chars.slice(0, filter.n).join("")}\u2026`;
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
case "default":
|
|
1471
|
+
if (text2 === "") text2 = filter.text;
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
return text2;
|
|
1476
|
+
}
|
|
1477
|
+
function spend(env, count) {
|
|
1478
|
+
if (count > env.charsLeft) {
|
|
1479
|
+
env.stopped = true;
|
|
1480
|
+
return false;
|
|
1481
|
+
}
|
|
1482
|
+
env.charsLeft -= count;
|
|
1483
|
+
return true;
|
|
1484
|
+
}
|
|
1485
|
+
var ELEMENTS = new Set(ALLOWED_ELEMENTS);
|
|
1486
|
+
var VOIDS = new Set(VOID_ELEMENTS);
|
|
1487
|
+
var ROLES = new Set(ALLOWED_ROLES);
|
|
1488
|
+
function attrAllowed(tag, name) {
|
|
1489
|
+
if (DATA_ATTR_RE.test(name)) return !name.startsWith(RESERVED_DATA_PREFIX);
|
|
1490
|
+
const own = Object.hasOwn(ALLOWED_ATTRS, tag) ? ALLOWED_ATTRS[tag] : void 0;
|
|
1491
|
+
return (ALLOWED_ATTRS["*"]?.includes(name) ?? false) || (own?.includes(name) ?? false);
|
|
1492
|
+
}
|
|
1493
|
+
function attrText(attr, env, scope) {
|
|
1494
|
+
return attr.value.map((part) => part.type === "text" ? part.value : filtered(lookup(part.path, env, scope), part.filters)).join("");
|
|
1495
|
+
}
|
|
1496
|
+
function urlSource(attr, env, scope) {
|
|
1497
|
+
const [only] = attr.value;
|
|
1498
|
+
if (attr.value.length !== 1 || only === void 0 || only.type !== "output") return attrText(attr, env, scope);
|
|
1499
|
+
const value = lookup(only.path, env, scope);
|
|
1500
|
+
if (isPlainObject(value)) {
|
|
1501
|
+
if (typeof value.href === "string") return value.href;
|
|
1502
|
+
if (typeof value.url === "string") return value.url;
|
|
1503
|
+
return null;
|
|
1504
|
+
}
|
|
1505
|
+
return value;
|
|
1506
|
+
}
|
|
1507
|
+
function attrProp(tag, attr, env, scope) {
|
|
1508
|
+
const { name } = attr;
|
|
1509
|
+
if (!attrAllowed(tag, name)) return null;
|
|
1510
|
+
if (name === "href" || name === "src") {
|
|
1511
|
+
const safe = safeUrl8(urlSource(attr, env, scope), name, { mediaOrigin: env.mediaOrigin });
|
|
1512
|
+
return safe === null || !spend(env, safe.length) ? null : [name, safe];
|
|
1513
|
+
}
|
|
1514
|
+
const text2 = attrText(attr, env, scope);
|
|
1515
|
+
if (text2 === "" || text2.length > MAX_ATTR_CHARS) return null;
|
|
1516
|
+
let value = text2;
|
|
1517
|
+
if (name === "class") {
|
|
1518
|
+
const tokens = text2.split(/\s+/).filter((token) => CLASS_TOKEN_RE.test(token) && !isReservedClass(token));
|
|
1519
|
+
if (tokens.length === 0) return null;
|
|
1520
|
+
value = tokens.join(" ");
|
|
1521
|
+
} else if (name === "role") {
|
|
1522
|
+
if (!ROLES.has(text2)) return null;
|
|
1523
|
+
} else if (name === "aria-hidden") {
|
|
1524
|
+
if (text2 !== "true" && text2 !== "false") return null;
|
|
1525
|
+
}
|
|
1526
|
+
if (!spend(env, value.length)) return null;
|
|
1527
|
+
return [name === "class" ? "className" : name, value];
|
|
1528
|
+
}
|
|
1529
|
+
function renderElement(node, env, scope, depth, key) {
|
|
1530
|
+
const tag = node.tag;
|
|
1531
|
+
if (!ELEMENTS.has(tag)) return null;
|
|
1532
|
+
const props = { key };
|
|
1533
|
+
for (const attr of node.attrs) {
|
|
1534
|
+
const prop = attrProp(tag, attr, env, scope);
|
|
1535
|
+
if (prop !== null) props[prop[0]] = prop[1];
|
|
1536
|
+
}
|
|
1537
|
+
if (VOIDS.has(tag)) return createElement2(tag, props);
|
|
1538
|
+
return createElement2(tag, props, renderNodes(node.children, env, scope, depth + 1));
|
|
1539
|
+
}
|
|
1540
|
+
function renderNodes(nodes, env, scope, depth) {
|
|
1541
|
+
const out = [];
|
|
1542
|
+
if (depth > MAX_DEPTH3) return out;
|
|
1543
|
+
for (const node of nodes) {
|
|
1544
|
+
if (env.stopped) break;
|
|
1545
|
+
if (!env.budget.take(1) || node.type === "element" && !env.budget.take(node.attrs.reduce((n, a) => n + a.value.length, 0))) {
|
|
1546
|
+
env.stopped = true;
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
switch (node.type) {
|
|
1550
|
+
case "text":
|
|
1551
|
+
if (spend(env, node.value.length)) out.push(node.value);
|
|
1552
|
+
break;
|
|
1553
|
+
case "output": {
|
|
1554
|
+
const text2 = filtered(lookup(node.path, env, scope), node.filters);
|
|
1555
|
+
if (text2 !== "" && spend(env, text2.length)) out.push(text2);
|
|
1556
|
+
break;
|
|
1557
|
+
}
|
|
1558
|
+
case "if": {
|
|
1559
|
+
const branch = truthy(lookup(node.path, env, scope)) ? node.then : node.else;
|
|
1560
|
+
out.push(/* @__PURE__ */ jsx21(Fragment14, { children: renderNodes(branch, env, scope, depth + 1) }, out.length));
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
case "unless":
|
|
1564
|
+
if (!truthy(lookup(node.path, env, scope))) {
|
|
1565
|
+
out.push(/* @__PURE__ */ jsx21(Fragment14, { children: renderNodes(node.body, env, scope, depth + 1) }, out.length));
|
|
1566
|
+
}
|
|
1567
|
+
break;
|
|
1568
|
+
case "each": {
|
|
1569
|
+
const list = lookup(node.path, env, scope);
|
|
1570
|
+
if (!Array.isArray(list)) break;
|
|
1571
|
+
const count = Math.min(list.length, EACH_ITERATION_CAP);
|
|
1572
|
+
for (let i = 0; i < count && !env.stopped; i += 1) {
|
|
1573
|
+
const inner = new Map(scope).set(node.as, list[i]);
|
|
1574
|
+
out.push(/* @__PURE__ */ jsx21(Fragment14, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
|
|
1575
|
+
}
|
|
1576
|
+
break;
|
|
1577
|
+
}
|
|
1578
|
+
case "element":
|
|
1579
|
+
out.push(renderElement(node, env, scope, depth, out.length));
|
|
1580
|
+
break;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
return out;
|
|
1584
|
+
}
|
|
1585
|
+
function renderTemplate(ast, env) {
|
|
1586
|
+
return renderNodes(ast, env, /* @__PURE__ */ new Map(), 0);
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// src/custom/template-widget.tsx
|
|
1590
|
+
import { Suspense } from "react";
|
|
1591
|
+
import { MAX_TEMPLATE_WEIGHT as MAX_TEMPLATE_WEIGHT2, parseTemplate, templateWeight as templateWeight2, validateTemplate } from "@usethrottle/builder-schema";
|
|
1592
|
+
import { Fragment as Fragment15, jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1593
|
+
var componentWeights = /* @__PURE__ */ new WeakMap();
|
|
1594
|
+
var compiled = /* @__PURE__ */ new WeakMap();
|
|
1595
|
+
function compileTemplate(snapshot, registry) {
|
|
1596
|
+
let perRegistry = compiled.get(snapshot);
|
|
1597
|
+
if (perRegistry === void 0) {
|
|
1598
|
+
perRegistry = /* @__PURE__ */ new WeakMap();
|
|
1599
|
+
compiled.set(snapshot, perRegistry);
|
|
1600
|
+
}
|
|
1601
|
+
if (perRegistry.has(registry)) return perRegistry.get(registry) ?? null;
|
|
1602
|
+
const result = compile(snapshot, registry);
|
|
1603
|
+
perRegistry.set(registry, result);
|
|
1604
|
+
return result;
|
|
1605
|
+
}
|
|
1606
|
+
function compile(snapshot, registry) {
|
|
1607
|
+
const label = `${snapshot.type}@${String(snapshot.v)}`;
|
|
1608
|
+
const refuse = (why) => {
|
|
1609
|
+
warnOnce(`template:${label}`, `${label} was refused (${why}); rendering nothing for it`);
|
|
1610
|
+
return null;
|
|
1611
|
+
};
|
|
1612
|
+
if (snapshot.kind !== "template") return refuse("not a template widget");
|
|
1613
|
+
const source = snapshot.template;
|
|
1614
|
+
if (typeof source !== "string") return refuse("no template source");
|
|
1615
|
+
const parsed2 = parseTemplate(source);
|
|
1616
|
+
if (!parsed2.ok) return refuse(`template does not parse: ${parsed2.issues[0]?.message ?? "invalid"}`);
|
|
1617
|
+
const data = snapshot.data;
|
|
1618
|
+
const issues = validateTemplate(parsed2.ast, {
|
|
1619
|
+
settings: snapshot.settings,
|
|
1620
|
+
data: typeof data === "object" && data !== null ? data : {},
|
|
1621
|
+
sources: registry.sources()
|
|
1622
|
+
});
|
|
1623
|
+
if (issues.length > 0) return refuse(`template does not validate: ${issues[0]?.message ?? "invalid"}`);
|
|
1624
|
+
if (!fitsBudget(parsed2.ast)) return refuse(`it can render more than ${String(MAX_TEMPLATE_WEIGHT2)} nodes`);
|
|
1625
|
+
const css = scopedCss(snapshot.css, snapshot.type);
|
|
1626
|
+
if (css === null) return refuse("its css does not pass the sanitiser");
|
|
1627
|
+
return { ast: parsed2.ast, css, weight: templateWeight2(parsed2.ast) };
|
|
1628
|
+
}
|
|
1629
|
+
function TemplateBody({ snapshot, registry, props, data, locale, mediaOrigin, budget }) {
|
|
1630
|
+
const template = compileTemplate(snapshot, registry);
|
|
1631
|
+
if (template === null) return null;
|
|
1632
|
+
const env = newEnv({ settings: props, data, locale, mediaOrigin, budget: budget ?? new RenderBudget() });
|
|
1633
|
+
return /* @__PURE__ */ jsxs14(Fragment15, { children: [
|
|
1634
|
+
template.css === "" ? null : /* @__PURE__ */ jsx22(CustomCss, { css: template.css }),
|
|
1635
|
+
renderTemplate(template.ast, env)
|
|
1636
|
+
] });
|
|
1637
|
+
}
|
|
1638
|
+
function TemplateWidget(props) {
|
|
1639
|
+
return /* @__PURE__ */ jsx22(PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ jsx22(Suspense, { fallback: null, children: /* @__PURE__ */ jsx22(TemplateBody, { ...props }) }) });
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
// src/code/leave.ts
|
|
1643
|
+
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
1644
|
+
|
|
1645
|
+
// src/code/routes.ts
|
|
1646
|
+
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$/i;
|
|
1647
|
+
var DEFAULT_CATALOG_ROUTES = [
|
|
1648
|
+
"/p/{handle}",
|
|
1649
|
+
"/c/{handle}",
|
|
1650
|
+
"/collections/{handle}",
|
|
1651
|
+
"/tags/{tag}",
|
|
1652
|
+
"/search",
|
|
1653
|
+
"/shop"
|
|
1654
|
+
];
|
|
1655
|
+
function normalizePath(pathname) {
|
|
1656
|
+
const bare = pathname.split(/[?#]/, 1)[0] ?? "";
|
|
1657
|
+
let decoded2 = bare;
|
|
1658
|
+
try {
|
|
1659
|
+
for (let i = 0; i < 3; i++) {
|
|
1660
|
+
let next;
|
|
1661
|
+
try {
|
|
1662
|
+
next = decodeURIComponent(decoded2);
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
if (i === 0) throw error;
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1667
|
+
if (next === decoded2) break;
|
|
1668
|
+
decoded2 = next;
|
|
1669
|
+
}
|
|
1670
|
+
} catch {
|
|
1671
|
+
return null;
|
|
1672
|
+
}
|
|
1673
|
+
if (decoded2.includes("\0")) return null;
|
|
1674
|
+
const flat = decoded2.replace(/\\/g, "/");
|
|
1675
|
+
if (!flat.startsWith("/")) return null;
|
|
1676
|
+
const out = [];
|
|
1677
|
+
for (const segment of flat.split("/")) {
|
|
1678
|
+
if (segment === "" || segment === ".") continue;
|
|
1679
|
+
if (segment === "..") out.pop();
|
|
1680
|
+
else out.push(segment);
|
|
1681
|
+
}
|
|
1682
|
+
return `/${out.join("/")}`;
|
|
1683
|
+
}
|
|
1684
|
+
var escapeRegExp = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1685
|
+
var compiled2 = /* @__PURE__ */ new Map();
|
|
1686
|
+
var MAX_COMPILED = 64;
|
|
1687
|
+
function matcherOf(template) {
|
|
1688
|
+
const known = compiled2.get(template);
|
|
1689
|
+
if (known !== void 0) return known;
|
|
1690
|
+
let regex = null;
|
|
1691
|
+
if (template.startsWith("/")) {
|
|
1692
|
+
const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((part) => /^\{[A-Za-z][A-Za-z0-9]*\}$/.test(part) ? "[^/]+" : escapeRegExp(part)).join("").replace(/\/+$/, "");
|
|
1693
|
+
regex = new RegExp(`^${pattern === "" ? "/" : pattern}$`);
|
|
1694
|
+
}
|
|
1695
|
+
if (compiled2.size >= MAX_COMPILED) compiled2.clear();
|
|
1696
|
+
compiled2.set(template, regex);
|
|
1697
|
+
return regex;
|
|
1698
|
+
}
|
|
1699
|
+
var matchesTemplate = (path, template) => matcherOf(template)?.test(path) ?? false;
|
|
1700
|
+
function isCodeRoute(pathname, routes) {
|
|
1701
|
+
if (pathname === void 0) return false;
|
|
1702
|
+
const path = normalizePath(pathname);
|
|
1703
|
+
if (path === null) return false;
|
|
1704
|
+
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
1705
|
+
if (path === "/") return true;
|
|
1706
|
+
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some((template) => matchesTemplate(path, template));
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
// src/code/leave.ts
|
|
1710
|
+
var emitted = false;
|
|
1711
|
+
function markCodeEmitted() {
|
|
1712
|
+
emitted = true;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// src/code/code-widget.tsx
|
|
1716
|
+
import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1717
|
+
var SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
1718
|
+
var CUSTOM_TYPE = /^custom\.[a-z][a-z0-9-]{0,63}$/;
|
|
1719
|
+
var SCRIPT_ORIGIN = /^https:\/\/[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]{1,5})?$/i;
|
|
1720
|
+
var SITE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1721
|
+
var MAX_INPUT_CHARS = 2e5;
|
|
1722
|
+
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1723
|
+
var checked = /* @__PURE__ */ new WeakMap();
|
|
1724
|
+
function check(raw, registry) {
|
|
1725
|
+
let perRegistry = checked.get(raw);
|
|
1726
|
+
if (perRegistry === void 0) {
|
|
1727
|
+
perRegistry = /* @__PURE__ */ new WeakMap();
|
|
1728
|
+
checked.set(raw, perRegistry);
|
|
1729
|
+
}
|
|
1730
|
+
const known = perRegistry.get(registry);
|
|
1731
|
+
if (known !== void 0) return known;
|
|
1732
|
+
const result = verify(raw, registry);
|
|
1733
|
+
perRegistry.set(registry, result);
|
|
1734
|
+
return result;
|
|
1735
|
+
}
|
|
1736
|
+
function verify(raw, registry) {
|
|
1737
|
+
const snapshot = raw;
|
|
1738
|
+
const label = `${String(snapshot.type)}@${String(snapshot.v)}`;
|
|
1739
|
+
if (snapshot.disabled === true) return { status: "disabled" };
|
|
1740
|
+
const refuse = (why) => {
|
|
1741
|
+
warnOnce(`code:${label}`, `Code widget ${label} was refused (${why}); rendering nothing for it`);
|
|
1742
|
+
return { status: "invalid" };
|
|
1743
|
+
};
|
|
1744
|
+
if (snapshot.kind !== "code") return refuse("not a code widget");
|
|
1745
|
+
if (typeof snapshot.type !== "string" || !CUSTOM_TYPE.test(snapshot.type)) return refuse("bad type");
|
|
1746
|
+
if (snapshot.disabled !== void 0) return refuse("bad disabled flag");
|
|
1747
|
+
if ("js" in snapshot) return refuse("it carries a script");
|
|
1748
|
+
if (typeof snapshot.jsHash !== "string" || !SHA256_HEX.test(snapshot.jsHash)) return refuse("bad script hash");
|
|
1749
|
+
if (typeof snapshot.html !== "string" || snapshot.html.length > LIMITS.codeHtmlBytes) return refuse("bad html");
|
|
1750
|
+
if (typeof snapshot.css !== "string" || snapshot.css.length > LIMITS.codeCssBytes) return refuse("bad css");
|
|
1751
|
+
const template = { ...snapshot, kind: "template", template: snapshot.html };
|
|
1752
|
+
if (compileTemplate(template, registry) === null) return refuse("its markup or css does not validate");
|
|
1753
|
+
return { status: "ok", snapshot: raw, template };
|
|
1754
|
+
}
|
|
1755
|
+
function codeScriptUrl(runtime, jsHash) {
|
|
1756
|
+
if (!isRecord2(runtime) || runtime.enabled !== true) return null;
|
|
1757
|
+
const { scriptOrigin, codeSiteId } = runtime;
|
|
1758
|
+
if (typeof scriptOrigin !== "string" || !SCRIPT_ORIGIN.test(scriptOrigin)) return null;
|
|
1759
|
+
if (typeof codeSiteId !== "string" || !SITE_ID.test(codeSiteId)) return null;
|
|
1760
|
+
if (!SHA256_HEX.test(jsHash)) return null;
|
|
1761
|
+
return `${scriptOrigin}/v1/code/${codeSiteId}/${jsHash}.js`;
|
|
1762
|
+
}
|
|
1763
|
+
function jsonForScript(value) {
|
|
1764
|
+
return JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
1765
|
+
}
|
|
1766
|
+
var BADGE = {
|
|
1767
|
+
display: "inline-block",
|
|
1768
|
+
margin: 4,
|
|
1769
|
+
padding: "2px 8px",
|
|
1770
|
+
borderRadius: 4,
|
|
1771
|
+
font: "600 11px/1.5 system-ui, sans-serif",
|
|
1772
|
+
letterSpacing: "0.02em",
|
|
1773
|
+
background: "#1f2937",
|
|
1774
|
+
color: "#fff"
|
|
1775
|
+
};
|
|
1776
|
+
function runs(props, jsHash) {
|
|
1777
|
+
const { code, edit, interactive } = props;
|
|
1778
|
+
if (edit !== void 0 || interactive === false || code === void 0 || code.preview === true) return null;
|
|
1779
|
+
if (!isCodeRoute(code.pathname, code.routes)) return null;
|
|
1780
|
+
return codeScriptUrl(code.runtime, jsHash);
|
|
1781
|
+
}
|
|
1782
|
+
function CodeWidget(props) {
|
|
1783
|
+
const { node, snapshot, registry, edit, anchor, copyAnchor, entrance } = props;
|
|
1784
|
+
const result = check(snapshot, registry);
|
|
1785
|
+
if (result.status !== "ok") {
|
|
1786
|
+
return result.status === "disabled" && edit !== void 0 ? /* @__PURE__ */ jsx23(NodeWrapper, { id: node.id, part: "widget", type: node.type, className: "tb-w", edit, children: /* @__PURE__ */ jsx23("div", { className: "tb-missing", children: "This code widget is disabled" }) }) : null;
|
|
1787
|
+
}
|
|
1788
|
+
const template = compileTemplate(result.template, registry);
|
|
1789
|
+
const src = runs(props, result.snapshot.jsHash);
|
|
1790
|
+
if (src !== null) markCodeEmitted();
|
|
1791
|
+
const env = newEnv({ settings: props.props, data: props.data, locale: props.locale, mediaOrigin: props.mediaOrigin, budget: new RenderBudget() });
|
|
1792
|
+
const label = `${node.type}@${String(node.v)}`;
|
|
1793
|
+
return /* @__PURE__ */ jsxs15(
|
|
1794
|
+
NodeWrapper,
|
|
1795
|
+
{
|
|
1796
|
+
id: node.id,
|
|
1797
|
+
part: "widget",
|
|
1798
|
+
type: node.type,
|
|
1799
|
+
custom: true,
|
|
1800
|
+
edit,
|
|
1801
|
+
className: "tb-w",
|
|
1802
|
+
anchor,
|
|
1803
|
+
copyAnchor,
|
|
1804
|
+
entrance,
|
|
1805
|
+
attributes: src === null ? { "data-b-code-inert": "" } : { "data-b-code": result.snapshot.jsHash },
|
|
1806
|
+
children: [
|
|
1807
|
+
/* @__PURE__ */ jsx23(PartBoundary, { label, children: /* @__PURE__ */ jsxs15(Suspense2, { fallback: null, children: [
|
|
1808
|
+
template.css === "" ? null : /* @__PURE__ */ jsx23(CustomCss, { css: template.css }),
|
|
1809
|
+
renderTemplate(template.ast, env)
|
|
1810
|
+
] }) }),
|
|
1811
|
+
src === null && (edit !== void 0 || props.code?.preview === true) ? /* @__PURE__ */ jsx23("div", { "data-b-code-badge": "", style: BADGE, children: "Runs on your store" }) : null,
|
|
1812
|
+
src === null ? null : /* @__PURE__ */ jsx23(CodeInput, { props: props.props, data: props.data, label }),
|
|
1813
|
+
src === null ? null : /* @__PURE__ */ jsx23("script", { async: true, src })
|
|
1814
|
+
]
|
|
1815
|
+
}
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
function CodeInput({ props, data, label }) {
|
|
1819
|
+
let json = "";
|
|
1820
|
+
try {
|
|
1821
|
+
json = jsonForScript({ props, data });
|
|
1822
|
+
if (json.length > MAX_INPUT_CHARS) {
|
|
1823
|
+
warnOnce(`code-input:${label}`, `The data of ${label} is too large for its code input; it gets its props only`);
|
|
1824
|
+
json = jsonForScript({ props, data: {} });
|
|
1825
|
+
}
|
|
1826
|
+
} catch {
|
|
1827
|
+
warnOnce(`code-input:${label}`, `The input of ${label} cannot be written as JSON; it gets none`);
|
|
1828
|
+
json = jsonForScript({ props: {}, data: {} });
|
|
1829
|
+
}
|
|
1830
|
+
return /* @__PURE__ */ jsx23("script", { type: "application/json", "data-b-code-input": "", children: json });
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
// src/css-compiler.ts
|
|
1834
|
+
import {
|
|
1835
|
+
COMMON_WIDGET_SETTINGS,
|
|
1836
|
+
resolveColumnProps,
|
|
1837
|
+
resolveColumnWidths,
|
|
1838
|
+
resolveResponsive as resolveResponsive2,
|
|
1839
|
+
safeUrl as safeUrl9,
|
|
1840
|
+
validateSettingValue,
|
|
1841
|
+
wrapColumnRows
|
|
1842
|
+
} from "@usethrottle/builder-schema";
|
|
1843
|
+
var TABLET_QUERY = "(max-width:1024px)";
|
|
1844
|
+
var PHONE_QUERY = "(max-width:767px)";
|
|
1845
|
+
var SAFE_VALUE = /^[A-Za-z0-9#%.,()\-+*/_: ]{1,200}$/;
|
|
1846
|
+
var URL_QUOTE_SAFE = /^[^\s"'\\()<>{};]+$/;
|
|
1847
|
+
var ID_RE2 = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
|
|
1848
|
+
var PROPERTY_RE = /^--(?:b|w|tb)-[A-Za-z][A-Za-z0-9-]{0,39}$/;
|
|
1849
|
+
var COLOR_TOKEN = /* @__PURE__ */ new Set([
|
|
1850
|
+
"primary",
|
|
1851
|
+
"primary-foreground",
|
|
1852
|
+
"background",
|
|
1853
|
+
"surface",
|
|
1854
|
+
"foreground",
|
|
1855
|
+
"muted",
|
|
1856
|
+
"muted-foreground",
|
|
1857
|
+
"border",
|
|
1858
|
+
"border-control",
|
|
1859
|
+
"accent",
|
|
1860
|
+
"sale",
|
|
1861
|
+
"success",
|
|
1862
|
+
"warning",
|
|
1863
|
+
"danger"
|
|
1864
|
+
]);
|
|
1865
|
+
var SPACING_TOKEN = /* @__PURE__ */ new Set(["xs", "s", "m", "l", "xl", "2xl"]);
|
|
1866
|
+
var SIZE_TOKEN = /* @__PURE__ */ new Set(["xs", "s", "m", "l", "xl", "2xl", "3xl"]);
|
|
1867
|
+
var ALIGN = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]);
|
|
1868
|
+
var SELECT_OPTION = /^[a-z0-9][a-z0-9:-]{0,39}$/;
|
|
1869
|
+
var px = (value) => `${String(Math.round(value * 100) / 100)}px`;
|
|
1870
|
+
function colour(value) {
|
|
1871
|
+
if (typeof value !== "string") return null;
|
|
1872
|
+
if (value.startsWith("token:")) {
|
|
1873
|
+
const name = value.slice(6);
|
|
1874
|
+
return COLOR_TOKEN.has(name) ? `var(--tb-color-${name})` : null;
|
|
1875
|
+
}
|
|
1876
|
+
return /^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/.test(value) ? value : null;
|
|
1877
|
+
}
|
|
1878
|
+
function spacing(value) {
|
|
1879
|
+
if (value === "none") return "0px";
|
|
1880
|
+
if (typeof value === "string") return SPACING_TOKEN.has(value) ? `var(--tb-space-${value})` : null;
|
|
1881
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 400 ? px(value) : null;
|
|
1882
|
+
}
|
|
1883
|
+
function fontSize(value) {
|
|
1884
|
+
if (typeof value === "string") return SIZE_TOKEN.has(value) ? `var(--tb-text-${value})` : null;
|
|
1885
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 8 && value <= 200 ? px(value) : null;
|
|
1886
|
+
}
|
|
1887
|
+
function cssValue(control, value) {
|
|
947
1888
|
switch (control) {
|
|
948
1889
|
case "color":
|
|
949
1890
|
return colour(value);
|
|
@@ -1004,7 +1945,7 @@ function backgroundDecls(out, bg, assets, mediaOrigin) {
|
|
|
1004
1945
|
if (bg.position !== void 0 && BG_POSITION.has(bg.position)) put(out, "--tb-bgpos", bg.position);
|
|
1005
1946
|
if (bg.size !== void 0 && BG_SIZE.has(bg.size)) put(out, "--tb-bgsize", bg.size);
|
|
1006
1947
|
const asset = bg.image === void 0 || assets === void 0 || !Object.hasOwn(assets, bg.image) ? void 0 : assets[bg.image];
|
|
1007
|
-
if (asset !== void 0 &&
|
|
1948
|
+
if (asset !== void 0 && safeUrl9(asset.url, "src", { mediaOrigin }) !== null && URL_QUOTE_SAFE.test(asset.url)) {
|
|
1008
1949
|
out.set("--tb-bgimg", `url("${asset.url}")`);
|
|
1009
1950
|
}
|
|
1010
1951
|
}
|
|
@@ -1089,7 +2030,9 @@ function collect(doc, registry, assets, mediaOrigin) {
|
|
|
1089
2030
|
}
|
|
1090
2031
|
});
|
|
1091
2032
|
};
|
|
1092
|
-
doc.sections
|
|
2033
|
+
for (const root of doc.sections) {
|
|
2034
|
+
if (root.type === "section") section(root);
|
|
2035
|
+
}
|
|
1093
2036
|
return nodes;
|
|
1094
2037
|
}
|
|
1095
2038
|
var block = (id, decls) => {
|
|
@@ -1109,54 +2052,121 @@ function compileResponsiveCss(doc, registry, assets = doc.assets, mediaOrigin =
|
|
|
1109
2052
|
return base + (tablet === "" ? "" : `@media ${TABLET_QUERY}{${tablet}}`) + (phone === "" ? "" : `@media ${PHONE_QUERY}{${phone}}`);
|
|
1110
2053
|
}
|
|
1111
2054
|
|
|
1112
|
-
// src/
|
|
1113
|
-
import {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
const target = event.target;
|
|
1131
|
-
if (target?.closest?.("a[href]") != null) event.preventDefault();
|
|
1132
|
-
},
|
|
1133
|
-
onClick: (event) => {
|
|
1134
|
-
event.stopPropagation();
|
|
1135
|
-
edit.onSelect(id);
|
|
1136
|
-
},
|
|
1137
|
-
onMouseOver: (event) => {
|
|
1138
|
-
event.stopPropagation();
|
|
1139
|
-
edit.onHover(id);
|
|
2055
|
+
// src/interactions/accordion.tsx
|
|
2056
|
+
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2057
|
+
function Accordion({
|
|
2058
|
+
id,
|
|
2059
|
+
panels,
|
|
2060
|
+
multiple,
|
|
2061
|
+
openFirst
|
|
2062
|
+
}) {
|
|
2063
|
+
return /* @__PURE__ */ jsx24("div", { className: "tb-accordion", children: panels.map((panel, i) => /* @__PURE__ */ jsxs16(
|
|
2064
|
+
"details",
|
|
2065
|
+
{
|
|
2066
|
+
className: "tb-acc-item",
|
|
2067
|
+
...multiple ? {} : { name: `${id}-acc` },
|
|
2068
|
+
...openFirst && i === 0 ? { open: true } : {},
|
|
2069
|
+
children: [
|
|
2070
|
+
/* @__PURE__ */ jsx24("summary", { className: "tb-acc-sum", children: panel.title }),
|
|
2071
|
+
/* @__PURE__ */ jsx24("div", { className: "tb-acc-body", children: panel.node })
|
|
2072
|
+
]
|
|
1140
2073
|
},
|
|
1141
|
-
|
|
1142
|
-
};
|
|
1143
|
-
|
|
1144
|
-
|
|
2074
|
+
panel.key
|
|
2075
|
+
)) });
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
// src/interactions/carousel.tsx
|
|
2079
|
+
import { jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2080
|
+
function Carousel({
|
|
2081
|
+
panels,
|
|
2082
|
+
autoplayMs,
|
|
2083
|
+
loop
|
|
2084
|
+
}) {
|
|
2085
|
+
return /* @__PURE__ */ jsxs17(
|
|
2086
|
+
"div",
|
|
1145
2087
|
{
|
|
1146
|
-
className,
|
|
1147
|
-
"
|
|
1148
|
-
"
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
...
|
|
1152
|
-
...
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
2088
|
+
className: "tb-car",
|
|
2089
|
+
role: "region",
|
|
2090
|
+
"aria-roledescription": "carousel",
|
|
2091
|
+
"aria-label": "Carousel",
|
|
2092
|
+
"data-b-car": "",
|
|
2093
|
+
...loop ? { "data-b-loop": "" } : {},
|
|
2094
|
+
...autoplayMs === null ? {} : { "data-b-autoplay": String(autoplayMs) },
|
|
2095
|
+
children: [
|
|
2096
|
+
/* @__PURE__ */ jsx25("div", { className: "tb-car-track", tabIndex: 0, children: panels.map((panel, i) => /* @__PURE__ */ jsx25(
|
|
2097
|
+
"div",
|
|
2098
|
+
{
|
|
2099
|
+
className: "tb-slide",
|
|
2100
|
+
role: "group",
|
|
2101
|
+
"aria-roledescription": "slide",
|
|
2102
|
+
"aria-label": panel.title === "" ? `${String(i + 1)} of ${String(panels.length)}` : panel.title,
|
|
2103
|
+
children: panel.node
|
|
2104
|
+
},
|
|
2105
|
+
panel.key
|
|
2106
|
+
)) }),
|
|
2107
|
+
/* @__PURE__ */ jsxs17("div", { className: "tb-car-ctrl", children: [
|
|
2108
|
+
/* @__PURE__ */ jsx25("button", { type: "button", className: "tb-car-btn", "data-b-act": "prev", "aria-label": "Previous slide", children: "\u2039" }),
|
|
2109
|
+
autoplayMs === null ? null : /* @__PURE__ */ jsx25("button", { type: "button", className: "tb-car-btn tb-car-pause", "data-b-act": "pause", hidden: true, children: "Pause" }),
|
|
2110
|
+
/* @__PURE__ */ jsx25("button", { type: "button", className: "tb-car-btn", "data-b-act": "next", "aria-label": "Next slide", children: "\u203A" })
|
|
2111
|
+
] })
|
|
2112
|
+
]
|
|
1156
2113
|
}
|
|
1157
2114
|
);
|
|
1158
2115
|
}
|
|
1159
2116
|
|
|
2117
|
+
// src/interactions/tabs.tsx
|
|
2118
|
+
import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2119
|
+
function Tabs({ id, panels }) {
|
|
2120
|
+
return /* @__PURE__ */ jsxs18("div", { className: "tb-tabs", children: [
|
|
2121
|
+
/* @__PURE__ */ jsx26("div", { role: "tablist", className: "tb-tablist", "data-b-tabs": "", children: panels.map((panel, i) => /* @__PURE__ */ jsx26(
|
|
2122
|
+
"button",
|
|
2123
|
+
{
|
|
2124
|
+
type: "button",
|
|
2125
|
+
role: "tab",
|
|
2126
|
+
className: "tb-tab",
|
|
2127
|
+
id: `${id}-t${String(i)}`,
|
|
2128
|
+
"aria-controls": `${id}-p${String(i)}`,
|
|
2129
|
+
"aria-selected": i === 0,
|
|
2130
|
+
tabIndex: i === 0 ? 0 : -1,
|
|
2131
|
+
children: panel.title
|
|
2132
|
+
},
|
|
2133
|
+
panel.key
|
|
2134
|
+
)) }),
|
|
2135
|
+
panels.map((panel, i) => /* @__PURE__ */ jsxs18(
|
|
2136
|
+
"div",
|
|
2137
|
+
{
|
|
2138
|
+
role: "tabpanel",
|
|
2139
|
+
className: "tb-panel",
|
|
2140
|
+
id: `${id}-p${String(i)}`,
|
|
2141
|
+
"aria-labelledby": `${id}-t${String(i)}`,
|
|
2142
|
+
tabIndex: 0,
|
|
2143
|
+
children: [
|
|
2144
|
+
/* @__PURE__ */ jsx26("p", { className: "tb-panel-title", children: panel.title }),
|
|
2145
|
+
panel.node
|
|
2146
|
+
]
|
|
2147
|
+
},
|
|
2148
|
+
panel.key
|
|
2149
|
+
))
|
|
2150
|
+
] });
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
// src/interactions/toggle.tsx
|
|
2154
|
+
import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2155
|
+
function Toggle({
|
|
2156
|
+
labelOpen,
|
|
2157
|
+
labelClosed,
|
|
2158
|
+
startOpen,
|
|
2159
|
+
children
|
|
2160
|
+
}) {
|
|
2161
|
+
return /* @__PURE__ */ jsxs19("details", { className: "tb-toggle", ...startOpen ? { open: true } : {}, children: [
|
|
2162
|
+
/* @__PURE__ */ jsxs19("summary", { className: "tb-toggle-sum", children: [
|
|
2163
|
+
/* @__PURE__ */ jsx27("span", { className: "tb-toggle-closed", children: labelClosed }),
|
|
2164
|
+
/* @__PURE__ */ jsx27("span", { className: "tb-toggle-open", children: labelOpen })
|
|
2165
|
+
] }),
|
|
2166
|
+
/* @__PURE__ */ jsx27("div", { className: "tb-row", children })
|
|
2167
|
+
] });
|
|
2168
|
+
}
|
|
2169
|
+
|
|
1160
2170
|
// src/styles.ts
|
|
1161
2171
|
var BASE_CSS = `@layer throttle{
|
|
1162
2172
|
:root{--tb-scale:1;--tb-space-xs:calc(.25rem*var(--tb-scale));--tb-space-s:calc(.5rem*var(--tb-scale));--tb-space-m:calc(1rem*var(--tb-scale));--tb-space-l:calc(1.5rem*var(--tb-scale));--tb-space-xl:calc(2.5rem*var(--tb-scale));--tb-space-2xl:calc(4rem*var(--tb-scale));
|
|
@@ -1179,7 +2189,7 @@ var BASE_CSS = `@layer throttle{
|
|
|
1179
2189
|
}`;
|
|
1180
2190
|
|
|
1181
2191
|
// src/renderer.tsx
|
|
1182
|
-
import { jsx as
|
|
2192
|
+
import { jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1183
2193
|
var DEVICES2 = ["desktop", "tablet", "phone"];
|
|
1184
2194
|
var COMMON_BY_KEY2 = new Map(COMMON_WIDGET_SETTINGS2.map((f) => [f.key, f]));
|
|
1185
2195
|
var withCustomCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -1194,7 +2204,11 @@ function registryFor(doc, base) {
|
|
|
1194
2204
|
let registry = perDocument.get(snapshots);
|
|
1195
2205
|
if (registry === void 0) {
|
|
1196
2206
|
try {
|
|
1197
|
-
registry = base.withCustom(
|
|
2207
|
+
registry = base.withCustom(
|
|
2208
|
+
Object.values(snapshots).filter(
|
|
2209
|
+
(snapshot) => snapshot.kind !== "code" || codeWidgetSnapshotSchema.safeParse(snapshot).success
|
|
2210
|
+
)
|
|
2211
|
+
);
|
|
1198
2212
|
} catch (error) {
|
|
1199
2213
|
warnOnce("custom-registry", `Could not register the document's custom widgets: ${String(error)}`);
|
|
1200
2214
|
registry = base;
|
|
@@ -1203,7 +2217,7 @@ function registryFor(doc, base) {
|
|
|
1203
2217
|
}
|
|
1204
2218
|
return registry;
|
|
1205
2219
|
}
|
|
1206
|
-
var
|
|
2220
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1207
2221
|
function pickLocale(value, locale) {
|
|
1208
2222
|
const lang = locale.split("-")[0] ?? locale;
|
|
1209
2223
|
for (const key of [locale, lang, "en"]) {
|
|
@@ -1214,25 +2228,25 @@ function pickLocale(value, locale) {
|
|
|
1214
2228
|
return "";
|
|
1215
2229
|
}
|
|
1216
2230
|
function onOrigin(asset, mediaOrigin) {
|
|
1217
|
-
if (
|
|
1218
|
-
return { ...asset, variants: asset.variants.filter((v) =>
|
|
2231
|
+
if (safeUrl10(asset.url, "src", { mediaOrigin }) === null) return null;
|
|
2232
|
+
return { ...asset, variants: asset.variants.filter((v) => safeUrl10(v.url, "src", { mediaOrigin }) !== null) };
|
|
1219
2233
|
}
|
|
1220
2234
|
function prepare(field, value, ctx) {
|
|
1221
2235
|
if (field === void 0 || value === null) return value;
|
|
1222
|
-
if (field.translatable === true &&
|
|
2236
|
+
if (field.translatable === true && isRecord3(value)) return pickLocale(value, ctx.locale);
|
|
1223
2237
|
if (field.control === "image" && typeof value === "string") {
|
|
1224
2238
|
const asset = Object.hasOwn(ctx.assets, value) ? ctx.assets[value] : void 0;
|
|
1225
2239
|
return asset === void 0 ? null : onOrigin(asset, ctx.mediaOrigin);
|
|
1226
2240
|
}
|
|
1227
|
-
if (field.control === "link" &&
|
|
2241
|
+
if (field.control === "link" && isRecord3(value) && typeof value.kind === "string") {
|
|
1228
2242
|
const target = value;
|
|
1229
2243
|
const raw = ctx.resolveLink?.(target) ?? (target.kind === "url" ? target.href : null);
|
|
1230
|
-
return { ...value, href:
|
|
2244
|
+
return { ...value, href: safeUrl10(raw, "href", { mediaOrigin: ctx.mediaOrigin }) };
|
|
1231
2245
|
}
|
|
1232
2246
|
return value;
|
|
1233
2247
|
}
|
|
1234
2248
|
function storedLinkPart(value) {
|
|
1235
|
-
if (!
|
|
2249
|
+
if (!isRecord3(value) || value.kind !== "page") return value;
|
|
1236
2250
|
const { slug: _slug, href: _href, ...stored } = value;
|
|
1237
2251
|
void _slug;
|
|
1238
2252
|
void _href;
|
|
@@ -1246,8 +2260,8 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
1246
2260
|
for (const [key, value] of Object.entries(resolved)) {
|
|
1247
2261
|
const field = fields.get(key);
|
|
1248
2262
|
const freeText = field?.control === "text" || field?.control === "richtext";
|
|
1249
|
-
const
|
|
1250
|
-
const usable = field === void 0 || (freeText ? value !== null : validateSettingValue2(field,
|
|
2263
|
+
const checked2 = field?.control === "link" ? storedLinkPart(value) : value;
|
|
2264
|
+
const usable = field === void 0 || (freeText ? value !== null : validateSettingValue2(field, checked2) === null) ? value : field.default;
|
|
1251
2265
|
out[key] = prepare(field, usable, ctx);
|
|
1252
2266
|
}
|
|
1253
2267
|
return out;
|
|
@@ -1271,29 +2285,63 @@ function hiddenEverywhere(props, responsive) {
|
|
|
1271
2285
|
);
|
|
1272
2286
|
}
|
|
1273
2287
|
var variantClass = (variant) => `tb-v ${variant.devices.map((d) => `tb-only-${d}`).join(" ")}`;
|
|
2288
|
+
function renderCodeWidget(node, snapshot, ctx, registry) {
|
|
2289
|
+
if (ctx.edit === void 0 && hiddenEverywhere(node.props, node.responsive)) return null;
|
|
2290
|
+
const def = registry.widget(node.type, node.v);
|
|
2291
|
+
const fields = new Map([...COMMON_BY_KEY2, ...(def?.settings ?? []).map((f) => [f.key, f])]);
|
|
2292
|
+
const data = {};
|
|
2293
|
+
for (const [name, binding] of Object.entries(bindingsOf(node, registry))) {
|
|
2294
|
+
const key = bindingKey(binding);
|
|
2295
|
+
const value = Object.hasOwn(ctx.data, key) ? ctx.data[key] : void 0;
|
|
2296
|
+
if (value !== void 0) data[name] = value;
|
|
2297
|
+
}
|
|
2298
|
+
const props = settingsAt(node, fields, "desktop", ctx);
|
|
2299
|
+
const anchor = props.anchor;
|
|
2300
|
+
return /* @__PURE__ */ jsx28(
|
|
2301
|
+
CodeWidget,
|
|
2302
|
+
{
|
|
2303
|
+
node,
|
|
2304
|
+
snapshot,
|
|
2305
|
+
registry,
|
|
2306
|
+
props,
|
|
2307
|
+
data,
|
|
2308
|
+
locale: ctx.locale,
|
|
2309
|
+
mediaOrigin: ctx.mediaOrigin,
|
|
2310
|
+
edit: ctx.edit,
|
|
2311
|
+
code: ctx.code,
|
|
2312
|
+
interactive: ctx.interactive,
|
|
2313
|
+
anchor: !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
2314
|
+
copyAnchor: ctx.vpath !== "" && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
2315
|
+
entrance: entranceOf(props.entrance, props.entranceDelayMs, ctx.interactive)
|
|
2316
|
+
}
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
1274
2319
|
function renderWidget(node, ctx, registry) {
|
|
2320
|
+
const key = `${node.type}@${String(node.v)}`;
|
|
2321
|
+
const frozen = ctx.snapshots !== void 0 && Object.hasOwn(ctx.snapshots, key) ? ctx.snapshots[key] : void 0;
|
|
2322
|
+
if (frozen?.kind === "code") return renderCodeWidget(node, frozen, ctx, registry);
|
|
1275
2323
|
const def = registry.widget(node.type, node.v);
|
|
1276
2324
|
const Component2 = def === void 0 ? void 0 : registry.component(node);
|
|
1277
2325
|
if (def === void 0 || Component2 === void 0) {
|
|
1278
2326
|
if (isDevelopment()) {
|
|
1279
2327
|
warnOnce(`missing:${node.type}@${String(node.v)}`, `Unknown widget ${node.type} v${String(node.v)}; rendering nothing for it`);
|
|
1280
2328
|
}
|
|
1281
|
-
return /* @__PURE__ */
|
|
2329
|
+
return /* @__PURE__ */ jsx28(NodeWrapper, { id: node.id, part: "widget", type: node.type, className: "tb-w", missing: true, children: ctx.edit !== void 0 && /* @__PURE__ */ jsx28("div", { className: "tb-missing", children: "Widget unavailable: update @usethrottle/storefront-react" }) });
|
|
1282
2330
|
}
|
|
1283
2331
|
if (ctx.edit === void 0 && hiddenEverywhere(node.props, node.responsive)) return null;
|
|
1284
2332
|
const fields = new Map([...COMMON_BY_KEY2, ...def.settings.map((f) => [f.key, f])]);
|
|
1285
2333
|
const variants = variantsOf(node, def, fields, ctx);
|
|
1286
2334
|
const data = {};
|
|
1287
2335
|
for (const [name, binding] of Object.entries(bindingsOf(node, registry))) {
|
|
1288
|
-
const
|
|
1289
|
-
const value = Object.hasOwn(ctx.data,
|
|
2336
|
+
const key2 = bindingKey(binding);
|
|
2337
|
+
const value = Object.hasOwn(ctx.data, key2) ? ctx.data[key2] : void 0;
|
|
1290
2338
|
if (value !== void 0) data[name] = value;
|
|
1291
2339
|
}
|
|
1292
2340
|
const custom = node.type.startsWith("custom.");
|
|
1293
2341
|
const edit = ctx.edit;
|
|
1294
2342
|
return variants.map((variant, index) => {
|
|
1295
2343
|
const anchor = variant.props.anchor;
|
|
1296
|
-
return /* @__PURE__ */
|
|
2344
|
+
return /* @__PURE__ */ jsx28(
|
|
1297
2345
|
NodeWrapper,
|
|
1298
2346
|
{
|
|
1299
2347
|
id: node.id,
|
|
@@ -1302,18 +2350,22 @@ function renderWidget(node, ctx, registry) {
|
|
|
1302
2350
|
custom,
|
|
1303
2351
|
edit,
|
|
1304
2352
|
className: variants.length > 1 ? `tb-w ${variantClass(variant)}` : "tb-w",
|
|
1305
|
-
anchor: index === 0 && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
1306
|
-
|
|
2353
|
+
anchor: index === 0 && !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
2354
|
+
copyAnchor: ctx.vpath !== "" && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
2355
|
+
entrance: entranceOf(variant.props.entrance, variant.props.entranceDelayMs, ctx.interactive),
|
|
2356
|
+
children: /* @__PURE__ */ jsx28(
|
|
1307
2357
|
Component2,
|
|
1308
2358
|
{
|
|
1309
2359
|
node,
|
|
1310
2360
|
props: variant.props,
|
|
1311
2361
|
data,
|
|
1312
2362
|
editMode: edit !== void 0,
|
|
2363
|
+
interactive: ctx.interactive,
|
|
2364
|
+
idScope: ctx.vpath === "" && !ctx.dupe ? void 0 : { vpath: ctx.vpath, dupe: ctx.dupe },
|
|
1313
2365
|
locale: ctx.locale,
|
|
1314
2366
|
mediaOrigin: ctx.mediaOrigin,
|
|
1315
2367
|
resolveLink: ctx.resolveLink,
|
|
1316
|
-
inlineEdit: edit === void 0 ? void 0 : (
|
|
2368
|
+
inlineEdit: edit === void 0 ? void 0 : (key2) => edit.inlineEdit(node.id, key2),
|
|
1317
2369
|
budget: custom ? new RenderBudget() : void 0
|
|
1318
2370
|
}
|
|
1319
2371
|
)
|
|
@@ -1324,47 +2376,154 @@ function renderWidget(node, ctx, registry) {
|
|
|
1324
2376
|
}
|
|
1325
2377
|
function renderColumn(column, ctx, registry) {
|
|
1326
2378
|
if (ctx.edit === void 0 && hiddenEverywhere(column.props, column.responsive)) return null;
|
|
1327
|
-
return /* @__PURE__ */
|
|
2379
|
+
return /* @__PURE__ */ jsx28(
|
|
1328
2380
|
NodeWrapper,
|
|
1329
2381
|
{
|
|
1330
2382
|
id: column.id,
|
|
1331
2383
|
part: "column",
|
|
1332
2384
|
className: "tb-col",
|
|
1333
|
-
anchor: column.props.anchor,
|
|
2385
|
+
anchor: ctx.dupe ? void 0 : column.props.anchor,
|
|
2386
|
+
copyAnchor: ctx.vpath === "" ? void 0 : column.props.anchor,
|
|
1334
2387
|
edit: ctx.edit,
|
|
2388
|
+
entrance: entranceOf(
|
|
2389
|
+
resolveEntrance(column, "desktop").entrance,
|
|
2390
|
+
resolveEntrance(column, "desktop").entranceDelayMs,
|
|
2391
|
+
ctx.interactive
|
|
2392
|
+
),
|
|
1335
2393
|
children: column.children.map(
|
|
1336
|
-
(child) => child.type === "inner-section" ? /* @__PURE__ */
|
|
2394
|
+
(child) => child.type === "inner-section" ? /* @__PURE__ */ jsx28(Fragment16, { children: renderSection(child, ctx, registry, true) }, child.id) : /* @__PURE__ */ jsx28(Fragment16, { children: renderWidget(child, ctx, registry) }, child.id)
|
|
1337
2395
|
)
|
|
1338
2396
|
},
|
|
1339
2397
|
column.id
|
|
1340
2398
|
);
|
|
1341
2399
|
}
|
|
2400
|
+
var PLAIN = resolveInteraction({ props: {}, responsive: void 0 }, "desktop");
|
|
2401
|
+
function sectionVariants(section, ctx) {
|
|
2402
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2403
|
+
for (const device of DEVICES2) {
|
|
2404
|
+
const interaction = ctx.interactive ? resolveInteraction(section, device) : PLAIN;
|
|
2405
|
+
const entrance = ctx.interactive ? resolveEntrance(section, device) : { entrance: "none", entranceDelayMs: 0 };
|
|
2406
|
+
const signature = stable([interaction, entrance]);
|
|
2407
|
+
const group = groups.get(signature);
|
|
2408
|
+
if (group === void 0) groups.set(signature, { devices: [device], interaction, entrance });
|
|
2409
|
+
else group.devices.push(device);
|
|
2410
|
+
}
|
|
2411
|
+
return [...groups.values()];
|
|
2412
|
+
}
|
|
2413
|
+
function panelsOf(section, ctx, registry, fallback) {
|
|
2414
|
+
const rendered = section.columns.map((column) => ({ column, node: renderColumn(column, ctx, registry) })).filter((entry) => entry.node !== null);
|
|
2415
|
+
return rendered.map(({ column, node }, i) => {
|
|
2416
|
+
const title = pickLocale(column.props.panelTitle ?? {}, ctx.locale).trim();
|
|
2417
|
+
return { key: column.id, title: title === "" ? fallback(i + 1, rendered.length) : title, node };
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
1342
2420
|
function renderSection(section, ctx, registry, nested = false) {
|
|
1343
2421
|
if (ctx.edit === void 0 && hiddenEverywhere(section.props, section.responsive)) return null;
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
2422
|
+
const variants = sectionVariants(section, ctx);
|
|
2423
|
+
const marker = variants.length > 1 && !ctx.dupe && section.props.anchor !== void 0 && ANCHOR_RE3.test(section.props.anchor) ? /* @__PURE__ */ jsx28("div", { id: section.props.anchor, className: "tb-anchor" }, "anchor") : null;
|
|
2424
|
+
const copies = variants.map((variant, index) => {
|
|
2425
|
+
const { interaction } = variant;
|
|
2426
|
+
const id = `ix-${section.id}-${ctx.vpath}${String(index)}`;
|
|
2427
|
+
const own = variants.length > 1 ? { ...ctx, vpath: `${ctx.vpath}${String(index)}-`, dupe: ctx.dupe || index > 0 } : ctx;
|
|
2428
|
+
const columns = () => section.columns.map((column) => renderColumn(column, own, registry));
|
|
2429
|
+
let body;
|
|
2430
|
+
if (interaction.interaction === "tabs") {
|
|
2431
|
+
body = /* @__PURE__ */ jsx28(Tabs, { id, panels: panelsOf(section, own, registry, (n) => `Tab ${String(n)}`) });
|
|
2432
|
+
} else if (interaction.interaction === "accordion") {
|
|
2433
|
+
body = /* @__PURE__ */ jsx28(
|
|
2434
|
+
Accordion,
|
|
2435
|
+
{
|
|
2436
|
+
id,
|
|
2437
|
+
panels: panelsOf(section, own, registry, (n) => `Section ${String(n)}`),
|
|
2438
|
+
multiple: interaction.accordionMultiple,
|
|
2439
|
+
openFirst: interaction.accordionOpenFirst
|
|
2440
|
+
}
|
|
2441
|
+
);
|
|
2442
|
+
} else if (interaction.interaction === "carousel") {
|
|
2443
|
+
body = /* @__PURE__ */ jsx28(
|
|
2444
|
+
Carousel,
|
|
2445
|
+
{
|
|
2446
|
+
panels: panelsOf(section, own, registry, () => ""),
|
|
2447
|
+
autoplayMs: interaction.carouselAutoplay ? interaction.carouselIntervalMs : null,
|
|
2448
|
+
loop: interaction.carouselLoop
|
|
2449
|
+
}
|
|
2450
|
+
);
|
|
2451
|
+
} else if (interaction.interaction === "toggle") {
|
|
2452
|
+
body = /* @__PURE__ */ jsx28(
|
|
2453
|
+
Toggle,
|
|
2454
|
+
{
|
|
2455
|
+
labelOpen: pickLocale(interaction.toggleLabelOpen, ctx.locale),
|
|
2456
|
+
labelClosed: pickLocale(interaction.toggleLabelClosed, ctx.locale),
|
|
2457
|
+
startOpen: interaction.toggleStartOpen,
|
|
2458
|
+
children: columns()
|
|
2459
|
+
}
|
|
2460
|
+
);
|
|
2461
|
+
} else {
|
|
2462
|
+
body = /* @__PURE__ */ jsx28("div", { className: "tb-row", children: columns() });
|
|
2463
|
+
}
|
|
2464
|
+
return /* @__PURE__ */ jsx28(
|
|
2465
|
+
NodeWrapper,
|
|
2466
|
+
{
|
|
2467
|
+
id: section.id,
|
|
2468
|
+
part: "section",
|
|
2469
|
+
as: nested ? "div" : "section",
|
|
2470
|
+
className: `${nested ? "tb-section tb-nested" : "tb-section"}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
2471
|
+
anchor: variants.length === 1 && !ctx.dupe ? section.props.anchor : void 0,
|
|
2472
|
+
copyAnchor: variants.length > 1 || ctx.vpath !== "" ? section.props.anchor : void 0,
|
|
2473
|
+
edit: ctx.edit,
|
|
2474
|
+
entrance: entranceOf(variant.entrance.entrance, variant.entrance.entranceDelayMs, ctx.interactive),
|
|
2475
|
+
children: /* @__PURE__ */ jsx28("div", { className: "tb-inner", children: body })
|
|
2476
|
+
},
|
|
2477
|
+
variant.devices.join("-")
|
|
2478
|
+
);
|
|
2479
|
+
});
|
|
2480
|
+
return marker === null ? copies : [marker, ...copies];
|
|
2481
|
+
}
|
|
2482
|
+
function needsRuntime(doc) {
|
|
2483
|
+
let found = false;
|
|
2484
|
+
walkNodes3(doc, (node) => {
|
|
2485
|
+
if (found || node.type === "saved-section") return;
|
|
2486
|
+
if (node.type === "section" || node.type === "inner-section") {
|
|
2487
|
+
found = DEVICES2.some(
|
|
2488
|
+
(device) => resolveInteraction(node, device).interaction !== "none" || resolveEntrance(node, device).entrance !== "none"
|
|
2489
|
+
);
|
|
2490
|
+
} else if (node.type === "column") {
|
|
2491
|
+
found = DEVICES2.some((device) => resolveEntrance(node, device).entrance !== "none");
|
|
2492
|
+
} else {
|
|
2493
|
+
found = DEVICES2.some((device) => {
|
|
2494
|
+
const entrance = resolveResponsive3(node.props, node.responsive, device).entrance;
|
|
2495
|
+
return entrance !== void 0 && entrance !== "none";
|
|
2496
|
+
});
|
|
1354
2497
|
}
|
|
1355
|
-
);
|
|
2498
|
+
});
|
|
2499
|
+
return found;
|
|
1356
2500
|
}
|
|
1357
2501
|
function BuilderRenderer(props) {
|
|
1358
|
-
const { document:
|
|
2502
|
+
const { document: raw, registry: base, data, editMode, locale, assets, resolveLink, code } = props;
|
|
2503
|
+
const expansion = expandSavedSections(raw, props.savedSections);
|
|
2504
|
+
const source = expansion.doc;
|
|
1359
2505
|
const registry = registryFor(source, base);
|
|
1360
2506
|
const { doc } = upgradeNodes(source, registry);
|
|
1361
2507
|
const mediaOrigin = props.mediaOrigin ?? "";
|
|
1362
|
-
const
|
|
2508
|
+
const interactive = props.interactive !== false;
|
|
2509
|
+
const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, code, edit: editMode, interactive, vpath: props.idScope?.vpath ?? "", dupe: props.idScope?.dupe ?? false, snapshots: source.customWidgets };
|
|
1363
2510
|
const css = compileResponsiveCss(doc, registry, assets, mediaOrigin);
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
2511
|
+
const upgraded = new Map(doc.sections.map((section) => [section.id, section]));
|
|
2512
|
+
return /* @__PURE__ */ jsxs20("div", { className: "tb-root", "data-throttle-part": "builder-root", ...props.scopeCustomCss === true ? { "data-b-root": "" } : {}, children: [
|
|
2513
|
+
interactive && needsRuntime(doc) ? /* @__PURE__ */ jsx28(InteractionRuntime, {}) : null,
|
|
2514
|
+
/* @__PURE__ */ jsx28("style", { href: "tb-base", precedence: "throttle", children: BASE_CSS }),
|
|
2515
|
+
css === "" ? null : /* @__PURE__ */ jsx28("style", { children: css }),
|
|
2516
|
+
(expansion.roots ?? doc.sections.map((section) => ({ kind: "section", id: section.id }))).map((root) => {
|
|
2517
|
+
if (root.kind === "section") {
|
|
2518
|
+
const section2 = upgraded.get(root.id);
|
|
2519
|
+
return section2?.type === "section" ? /* @__PURE__ */ jsx28(Fragment16, { children: renderSection(section2, ctx, registry) }, root.id) : null;
|
|
2520
|
+
}
|
|
2521
|
+
const section = root.sectionId === null ? void 0 : upgraded.get(root.sectionId);
|
|
2522
|
+
if (section?.type === "section") {
|
|
2523
|
+
return root.ref.props.hidden === true && ctx.edit === void 0 ? null : /* @__PURE__ */ jsx28(Fragment16, { children: renderSection(section, ctx, registry) }, root.ref.id);
|
|
2524
|
+
}
|
|
2525
|
+
return /* @__PURE__ */ jsx28(MissingSavedSection, { node: root.ref }, root.ref.id);
|
|
2526
|
+
})
|
|
1368
2527
|
] });
|
|
1369
2528
|
}
|
|
1370
2529
|
|
|
@@ -1374,7 +2533,7 @@ var BuilderContext = typeof createContext === "function" ? createContext(null) :
|
|
|
1374
2533
|
var useBuilder = () => useContext(BuilderContext);
|
|
1375
2534
|
|
|
1376
2535
|
// src/part-view.tsx
|
|
1377
|
-
import { jsx as
|
|
2536
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
1378
2537
|
var BoundaryBase = Component ?? class {
|
|
1379
2538
|
};
|
|
1380
2539
|
var Boundary = class extends BoundaryBase {
|
|
@@ -1406,289 +2565,30 @@ function PartBoundary({
|
|
|
1406
2565
|
children
|
|
1407
2566
|
}) {
|
|
1408
2567
|
const builder = useBuilder();
|
|
1409
|
-
return /* @__PURE__ */
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
// src/custom/template-widget.tsx
|
|
1413
|
-
import { Suspense } from "react";
|
|
1414
|
-
import { MAX_TEMPLATE_WEIGHT as MAX_TEMPLATE_WEIGHT2, parseTemplate, templateWeight as templateWeight2, validateTemplate } from "@usethrottle/builder-schema";
|
|
1415
|
-
|
|
1416
|
-
// src/custom/custom-css.tsx
|
|
1417
|
-
import { sanitizeWidgetCss } from "@usethrottle/builder-schema";
|
|
1418
|
-
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1419
|
-
function scopedCss(source, type) {
|
|
1420
|
-
if (source === void 0 || source === "") return "";
|
|
1421
|
-
if (typeof source !== "string") return null;
|
|
1422
|
-
const result = sanitizeWidgetCss(source, type);
|
|
1423
|
-
return result.ok ? result.css : null;
|
|
1424
|
-
}
|
|
1425
|
-
function CustomCss({ css }) {
|
|
1426
|
-
return /* @__PURE__ */ jsx19(WidgetStyle, { css });
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
// src/custom/interpreter.tsx
|
|
1430
|
-
import { Fragment as Fragment14, createElement as createElement2 } from "react";
|
|
1431
|
-
import {
|
|
1432
|
-
ALLOWED_ATTRS,
|
|
1433
|
-
ALLOWED_ELEMENTS,
|
|
1434
|
-
ALLOWED_ROLES,
|
|
1435
|
-
CLASS_TOKEN_RE,
|
|
1436
|
-
DATA_ATTR_RE,
|
|
1437
|
-
EACH_ITERATION_CAP,
|
|
1438
|
-
RESERVED_DATA_PREFIX,
|
|
1439
|
-
VOID_ELEMENTS,
|
|
1440
|
-
isReservedClass,
|
|
1441
|
-
safeUrl as safeUrl10
|
|
1442
|
-
} from "@usethrottle/builder-schema";
|
|
1443
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1444
|
-
var MAX_OUTPUT_CHARS = 1e6;
|
|
1445
|
-
var MAX_ATTR_CHARS = 2e3;
|
|
1446
|
-
var MAX_DEPTH3 = 24;
|
|
1447
|
-
function newEnv(env) {
|
|
1448
|
-
return { ...env, charsLeft: MAX_OUTPUT_CHARS, stopped: false };
|
|
1449
|
-
}
|
|
1450
|
-
var BLOCKED = /* @__PURE__ */ new Set([
|
|
1451
|
-
"__proto__",
|
|
1452
|
-
"constructor",
|
|
1453
|
-
"prototype",
|
|
1454
|
-
...Object.getOwnPropertyNames(Object.prototype)
|
|
1455
|
-
]);
|
|
1456
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1457
|
-
function step(value, key) {
|
|
1458
|
-
if (BLOCKED.has(key) || !isPlainObject(value) || !Object.hasOwn(value, key)) return void 0;
|
|
1459
|
-
return value[key];
|
|
1460
|
-
}
|
|
1461
|
-
function lookup(path, env, scope) {
|
|
1462
|
-
const [root, ...rest] = path;
|
|
1463
|
-
if (root === void 0) return void 0;
|
|
1464
|
-
if (root === "locale") return rest.length === 0 ? env.locale : void 0;
|
|
1465
|
-
let value;
|
|
1466
|
-
if (root === "settings") value = rest.length === 0 ? void 0 : env.settings;
|
|
1467
|
-
else if (root === "data") value = rest.length === 0 ? void 0 : env.data;
|
|
1468
|
-
else if (scope.has(root)) value = scope.get(root);
|
|
1469
|
-
else return void 0;
|
|
1470
|
-
for (const key of rest) {
|
|
1471
|
-
value = step(value, key);
|
|
1472
|
-
if (value === void 0) return void 0;
|
|
1473
|
-
}
|
|
1474
|
-
return value;
|
|
1475
|
-
}
|
|
1476
|
-
function truthy(value) {
|
|
1477
|
-
if (value === null || value === void 0 || value === false || value === "") return false;
|
|
1478
|
-
if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
|
|
1479
|
-
if (Array.isArray(value)) return value.length > 0;
|
|
1480
|
-
return true;
|
|
1481
|
-
}
|
|
1482
|
-
function asText(value) {
|
|
1483
|
-
if (typeof value === "string") return value;
|
|
1484
|
-
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
1485
|
-
return "";
|
|
1486
|
-
}
|
|
1487
|
-
function filtered(value, filters) {
|
|
1488
|
-
let text2 = asText(value);
|
|
1489
|
-
for (const filter of filters) {
|
|
1490
|
-
switch (filter.name) {
|
|
1491
|
-
case "upper":
|
|
1492
|
-
text2 = text2.toUpperCase();
|
|
1493
|
-
break;
|
|
1494
|
-
case "lower":
|
|
1495
|
-
text2 = text2.toLowerCase();
|
|
1496
|
-
break;
|
|
1497
|
-
case "truncate": {
|
|
1498
|
-
const chars = Array.from(text2);
|
|
1499
|
-
if (chars.length > filter.n) text2 = `${chars.slice(0, filter.n).join("")}\u2026`;
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
case "default":
|
|
1503
|
-
if (text2 === "") text2 = filter.text;
|
|
1504
|
-
break;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
return text2;
|
|
1508
|
-
}
|
|
1509
|
-
function spend(env, count) {
|
|
1510
|
-
if (count > env.charsLeft) {
|
|
1511
|
-
env.stopped = true;
|
|
1512
|
-
return false;
|
|
1513
|
-
}
|
|
1514
|
-
env.charsLeft -= count;
|
|
1515
|
-
return true;
|
|
1516
|
-
}
|
|
1517
|
-
var ELEMENTS = new Set(ALLOWED_ELEMENTS);
|
|
1518
|
-
var VOIDS = new Set(VOID_ELEMENTS);
|
|
1519
|
-
var ROLES = new Set(ALLOWED_ROLES);
|
|
1520
|
-
function attrAllowed(tag, name) {
|
|
1521
|
-
if (DATA_ATTR_RE.test(name)) return !name.startsWith(RESERVED_DATA_PREFIX);
|
|
1522
|
-
const own = Object.hasOwn(ALLOWED_ATTRS, tag) ? ALLOWED_ATTRS[tag] : void 0;
|
|
1523
|
-
return (ALLOWED_ATTRS["*"]?.includes(name) ?? false) || (own?.includes(name) ?? false);
|
|
1524
|
-
}
|
|
1525
|
-
function attrText(attr, env, scope) {
|
|
1526
|
-
return attr.value.map((part) => part.type === "text" ? part.value : filtered(lookup(part.path, env, scope), part.filters)).join("");
|
|
1527
|
-
}
|
|
1528
|
-
function urlSource(attr, env, scope) {
|
|
1529
|
-
const [only] = attr.value;
|
|
1530
|
-
if (attr.value.length !== 1 || only === void 0 || only.type !== "output") return attrText(attr, env, scope);
|
|
1531
|
-
const value = lookup(only.path, env, scope);
|
|
1532
|
-
if (isPlainObject(value)) {
|
|
1533
|
-
if (typeof value.href === "string") return value.href;
|
|
1534
|
-
if (typeof value.url === "string") return value.url;
|
|
1535
|
-
return null;
|
|
1536
|
-
}
|
|
1537
|
-
return value;
|
|
1538
|
-
}
|
|
1539
|
-
function attrProp(tag, attr, env, scope) {
|
|
1540
|
-
const { name } = attr;
|
|
1541
|
-
if (!attrAllowed(tag, name)) return null;
|
|
1542
|
-
if (name === "href" || name === "src") {
|
|
1543
|
-
const safe = safeUrl10(urlSource(attr, env, scope), name, { mediaOrigin: env.mediaOrigin });
|
|
1544
|
-
return safe === null || !spend(env, safe.length) ? null : [name, safe];
|
|
1545
|
-
}
|
|
1546
|
-
const text2 = attrText(attr, env, scope);
|
|
1547
|
-
if (text2 === "" || text2.length > MAX_ATTR_CHARS) return null;
|
|
1548
|
-
let value = text2;
|
|
1549
|
-
if (name === "class") {
|
|
1550
|
-
const tokens = text2.split(/\s+/).filter((token) => CLASS_TOKEN_RE.test(token) && !isReservedClass(token));
|
|
1551
|
-
if (tokens.length === 0) return null;
|
|
1552
|
-
value = tokens.join(" ");
|
|
1553
|
-
} else if (name === "role") {
|
|
1554
|
-
if (!ROLES.has(text2)) return null;
|
|
1555
|
-
} else if (name === "aria-hidden") {
|
|
1556
|
-
if (text2 !== "true" && text2 !== "false") return null;
|
|
1557
|
-
}
|
|
1558
|
-
if (!spend(env, value.length)) return null;
|
|
1559
|
-
return [name === "class" ? "className" : name, value];
|
|
1560
|
-
}
|
|
1561
|
-
function renderElement(node, env, scope, depth, key) {
|
|
1562
|
-
const tag = node.tag;
|
|
1563
|
-
if (!ELEMENTS.has(tag)) return null;
|
|
1564
|
-
const props = { key };
|
|
1565
|
-
for (const attr of node.attrs) {
|
|
1566
|
-
const prop = attrProp(tag, attr, env, scope);
|
|
1567
|
-
if (prop !== null) props[prop[0]] = prop[1];
|
|
1568
|
-
}
|
|
1569
|
-
if (VOIDS.has(tag)) return createElement2(tag, props);
|
|
1570
|
-
return createElement2(tag, props, renderNodes(node.children, env, scope, depth + 1));
|
|
1571
|
-
}
|
|
1572
|
-
function renderNodes(nodes, env, scope, depth) {
|
|
1573
|
-
const out = [];
|
|
1574
|
-
if (depth > MAX_DEPTH3) return out;
|
|
1575
|
-
for (const node of nodes) {
|
|
1576
|
-
if (env.stopped) break;
|
|
1577
|
-
if (!env.budget.take(1) || node.type === "element" && !env.budget.take(node.attrs.reduce((n, a) => n + a.value.length, 0))) {
|
|
1578
|
-
env.stopped = true;
|
|
1579
|
-
break;
|
|
1580
|
-
}
|
|
1581
|
-
switch (node.type) {
|
|
1582
|
-
case "text":
|
|
1583
|
-
if (spend(env, node.value.length)) out.push(node.value);
|
|
1584
|
-
break;
|
|
1585
|
-
case "output": {
|
|
1586
|
-
const text2 = filtered(lookup(node.path, env, scope), node.filters);
|
|
1587
|
-
if (text2 !== "" && spend(env, text2.length)) out.push(text2);
|
|
1588
|
-
break;
|
|
1589
|
-
}
|
|
1590
|
-
case "if": {
|
|
1591
|
-
const branch = truthy(lookup(node.path, env, scope)) ? node.then : node.else;
|
|
1592
|
-
out.push(/* @__PURE__ */ jsx20(Fragment14, { children: renderNodes(branch, env, scope, depth + 1) }, out.length));
|
|
1593
|
-
break;
|
|
1594
|
-
}
|
|
1595
|
-
case "unless":
|
|
1596
|
-
if (!truthy(lookup(node.path, env, scope))) {
|
|
1597
|
-
out.push(/* @__PURE__ */ jsx20(Fragment14, { children: renderNodes(node.body, env, scope, depth + 1) }, out.length));
|
|
1598
|
-
}
|
|
1599
|
-
break;
|
|
1600
|
-
case "each": {
|
|
1601
|
-
const list = lookup(node.path, env, scope);
|
|
1602
|
-
if (!Array.isArray(list)) break;
|
|
1603
|
-
const count = Math.min(list.length, EACH_ITERATION_CAP);
|
|
1604
|
-
for (let i = 0; i < count && !env.stopped; i += 1) {
|
|
1605
|
-
const inner = new Map(scope).set(node.as, list[i]);
|
|
1606
|
-
out.push(/* @__PURE__ */ jsx20(Fragment14, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
|
|
1607
|
-
}
|
|
1608
|
-
break;
|
|
1609
|
-
}
|
|
1610
|
-
case "element":
|
|
1611
|
-
out.push(renderElement(node, env, scope, depth, out.length));
|
|
1612
|
-
break;
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
return out;
|
|
1616
|
-
}
|
|
1617
|
-
function renderTemplate(ast, env) {
|
|
1618
|
-
return renderNodes(ast, env, /* @__PURE__ */ new Map(), 0);
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
// src/custom/template-widget.tsx
|
|
1622
|
-
import { Fragment as Fragment15, jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1623
|
-
var componentWeights = /* @__PURE__ */ new WeakMap();
|
|
1624
|
-
var compiled = /* @__PURE__ */ new WeakMap();
|
|
1625
|
-
function compileTemplate(snapshot, registry) {
|
|
1626
|
-
let perRegistry = compiled.get(snapshot);
|
|
1627
|
-
if (perRegistry === void 0) {
|
|
1628
|
-
perRegistry = /* @__PURE__ */ new WeakMap();
|
|
1629
|
-
compiled.set(snapshot, perRegistry);
|
|
1630
|
-
}
|
|
1631
|
-
if (perRegistry.has(registry)) return perRegistry.get(registry) ?? null;
|
|
1632
|
-
const result = compile(snapshot, registry);
|
|
1633
|
-
perRegistry.set(registry, result);
|
|
1634
|
-
return result;
|
|
1635
|
-
}
|
|
1636
|
-
function compile(snapshot, registry) {
|
|
1637
|
-
const label = `${snapshot.type}@${String(snapshot.v)}`;
|
|
1638
|
-
const refuse = (why) => {
|
|
1639
|
-
warnOnce(`template:${label}`, `${label} was refused (${why}); rendering nothing for it`);
|
|
1640
|
-
return null;
|
|
1641
|
-
};
|
|
1642
|
-
if (snapshot.kind !== "template") return refuse("not a template widget");
|
|
1643
|
-
const source = snapshot.template;
|
|
1644
|
-
if (typeof source !== "string") return refuse("no template source");
|
|
1645
|
-
const parsed = parseTemplate(source);
|
|
1646
|
-
if (!parsed.ok) return refuse(`template does not parse: ${parsed.issues[0]?.message ?? "invalid"}`);
|
|
1647
|
-
const data = snapshot.data;
|
|
1648
|
-
const issues = validateTemplate(parsed.ast, {
|
|
1649
|
-
settings: snapshot.settings,
|
|
1650
|
-
data: typeof data === "object" && data !== null ? data : {},
|
|
1651
|
-
sources: registry.sources()
|
|
1652
|
-
});
|
|
1653
|
-
if (issues.length > 0) return refuse(`template does not validate: ${issues[0]?.message ?? "invalid"}`);
|
|
1654
|
-
if (!fitsBudget(parsed.ast)) return refuse(`it can render more than ${String(MAX_TEMPLATE_WEIGHT2)} nodes`);
|
|
1655
|
-
const css = scopedCss(snapshot.css, snapshot.type);
|
|
1656
|
-
if (css === null) return refuse("its css does not pass the sanitiser");
|
|
1657
|
-
return { ast: parsed.ast, css, weight: templateWeight2(parsed.ast) };
|
|
1658
|
-
}
|
|
1659
|
-
function TemplateBody({ snapshot, registry, props, data, locale, mediaOrigin, budget }) {
|
|
1660
|
-
const template = compileTemplate(snapshot, registry);
|
|
1661
|
-
if (template === null) return null;
|
|
1662
|
-
const env = newEnv({ settings: props, data, locale, mediaOrigin, budget: budget ?? new RenderBudget() });
|
|
1663
|
-
return /* @__PURE__ */ jsxs14(Fragment15, { children: [
|
|
1664
|
-
template.css === "" ? null : /* @__PURE__ */ jsx21(CustomCss, { css: template.css }),
|
|
1665
|
-
renderTemplate(template.ast, env)
|
|
1666
|
-
] });
|
|
1667
|
-
}
|
|
1668
|
-
function TemplateWidget(props) {
|
|
1669
|
-
return /* @__PURE__ */ jsx21(PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ jsx21(Suspense, { fallback: null, children: /* @__PURE__ */ jsx21(TemplateBody, { ...props }) }) });
|
|
2568
|
+
return /* @__PURE__ */ jsx29(Boundary, { label, resetKeys: [builder?.site, resetKey], onError: builder?.onError, children });
|
|
1670
2569
|
}
|
|
1671
2570
|
|
|
1672
2571
|
// src/custom/composite-widget.tsx
|
|
1673
|
-
import { jsx as
|
|
2572
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1674
2573
|
var SETTING_KEY_RE = /^[a-z][A-Za-z0-9]{0,39}$/;
|
|
1675
2574
|
var NODE_ID_RE = /^[a-z0-9]{8,24}$/;
|
|
1676
2575
|
var WRAP = { section: "zzcompsec001", column: "zzcompcol001", inner: "zzcompinr001" };
|
|
1677
|
-
var
|
|
1678
|
-
var
|
|
2576
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2577
|
+
var compiled3 = /* @__PURE__ */ new WeakMap();
|
|
1679
2578
|
function parseBody(raw) {
|
|
1680
|
-
if (!
|
|
2579
|
+
if (!isRecord4(raw)) return null;
|
|
1681
2580
|
const columns = Array.isArray(raw.columns) ? raw.columns : void 0;
|
|
1682
2581
|
const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
|
|
1683
2582
|
if (columns === void 0 === (stack === void 0)) return null;
|
|
1684
2583
|
const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : stack ?? [];
|
|
1685
|
-
if (stack?.some((node) =>
|
|
1686
|
-
const
|
|
2584
|
+
if (stack?.some((node) => isRecord4(node) && node.type === "inner-section")) return null;
|
|
2585
|
+
const parsed2 = pageDocumentSchema.safeParse({
|
|
1687
2586
|
schemaVersion: 1,
|
|
1688
2587
|
sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
|
|
1689
2588
|
});
|
|
1690
|
-
if (!
|
|
1691
|
-
const
|
|
2589
|
+
if (!parsed2.success) return null;
|
|
2590
|
+
const wrapper = parsed2.data.sections[0];
|
|
2591
|
+
const first = (wrapper?.type === "section" ? wrapper.columns[0]?.children : void 0) ?? [];
|
|
1692
2592
|
if (columns !== void 0) {
|
|
1693
2593
|
const inner = first[0];
|
|
1694
2594
|
return inner?.type === "inner-section" ? { columns: inner.columns } : null;
|
|
@@ -1696,9 +2596,9 @@ function parseBody(raw) {
|
|
|
1696
2596
|
return { stack: first.filter((node) => node.type !== "inner-section") };
|
|
1697
2597
|
}
|
|
1698
2598
|
function compileComposite(snapshot) {
|
|
1699
|
-
if (
|
|
2599
|
+
if (compiled3.has(snapshot)) return compiled3.get(snapshot) ?? null;
|
|
1700
2600
|
const result = compile2(snapshot);
|
|
1701
|
-
|
|
2601
|
+
compiled3.set(snapshot, result);
|
|
1702
2602
|
return result;
|
|
1703
2603
|
}
|
|
1704
2604
|
function compile2(snapshot) {
|
|
@@ -1714,12 +2614,12 @@ function compile2(snapshot) {
|
|
|
1714
2614
|
const bindings = [];
|
|
1715
2615
|
if (extra.bindings !== void 0 && !Array.isArray(extra.bindings)) return refuse("bindings is not a list");
|
|
1716
2616
|
for (const raw of extra.bindings ?? []) {
|
|
1717
|
-
if (!
|
|
2617
|
+
if (!isRecord4(raw) || typeof raw.setting !== "string" || !SETTING_KEY_RE.test(raw.setting) || !Array.isArray(raw.targets)) {
|
|
1718
2618
|
return refuse("a binding is malformed");
|
|
1719
2619
|
}
|
|
1720
2620
|
const targets = [];
|
|
1721
2621
|
for (const target of raw.targets) {
|
|
1722
|
-
if (!
|
|
2622
|
+
if (!isRecord4(target) || typeof target.node !== "string" || !NODE_ID_RE.test(target.node) || typeof target.prop !== "string" || !SETTING_KEY_RE.test(target.prop)) {
|
|
1723
2623
|
return refuse("a binding target is malformed");
|
|
1724
2624
|
}
|
|
1725
2625
|
targets.push({ node: target.node, prop: target.prop });
|
|
@@ -1727,12 +2627,12 @@ function compile2(snapshot) {
|
|
|
1727
2627
|
bindings.push({ setting: raw.setting, targets });
|
|
1728
2628
|
}
|
|
1729
2629
|
const data = [];
|
|
1730
|
-
if (extra.data !== void 0 && !
|
|
2630
|
+
if (extra.data !== void 0 && !isRecord4(extra.data)) return refuse("data is not a record");
|
|
1731
2631
|
for (const [name, raw] of Object.entries(extra.data ?? {})) {
|
|
1732
|
-
if (!SETTING_KEY_RE.test(name) || !
|
|
2632
|
+
if (!SETTING_KEY_RE.test(name) || !isRecord4(raw) || !Array.isArray(raw.targets)) return refuse("a data input is malformed");
|
|
1733
2633
|
const targets = [];
|
|
1734
2634
|
for (const target of raw.targets) {
|
|
1735
|
-
if (!
|
|
2635
|
+
if (!isRecord4(target) || typeof target.node !== "string" || !NODE_ID_RE.test(target.node) || typeof target.input !== "string" || !SETTING_KEY_RE.test(target.input)) {
|
|
1736
2636
|
return refuse("a data target is malformed");
|
|
1737
2637
|
}
|
|
1738
2638
|
targets.push({ node: target.node, input: target.input });
|
|
@@ -1788,7 +2688,7 @@ function build(input) {
|
|
|
1788
2688
|
return id;
|
|
1789
2689
|
}
|
|
1790
2690
|
if (field.control === "link") {
|
|
1791
|
-
if (!
|
|
2691
|
+
if (!isRecord4(value) || typeof value.kind !== "string") return null;
|
|
1792
2692
|
const { href, ...target } = value;
|
|
1793
2693
|
if (target.kind === "url") return typeof href === "string" ? { kind: "url", href } : null;
|
|
1794
2694
|
hrefs.set(JSON.stringify(target), typeof href === "string" ? href : null);
|
|
@@ -1839,7 +2739,7 @@ function build(input) {
|
|
|
1839
2739
|
props: { width: 100 },
|
|
1840
2740
|
children: columns !== void 0 ? [{ id: ids.inner, type: "inner-section", props: { width: "full" }, columns }] : stack ?? []
|
|
1841
2741
|
};
|
|
1842
|
-
const
|
|
2742
|
+
const document2 = {
|
|
1843
2743
|
schemaVersion: 1,
|
|
1844
2744
|
sections: [{ id: ids.section, type: "section", props: { width: "full" }, columns: [column] }]
|
|
1845
2745
|
};
|
|
@@ -1848,10 +2748,10 @@ function build(input) {
|
|
|
1848
2748
|
const component = registry.component(widget);
|
|
1849
2749
|
weight += 1 + (component === void 0 ? 0 : componentWeights.get(component) ?? 0);
|
|
1850
2750
|
}
|
|
1851
|
-
return { document, assets, data: innerData, hrefs, weight };
|
|
2751
|
+
return { document: document2, assets, data: innerData, hrefs, weight };
|
|
1852
2752
|
}
|
|
1853
2753
|
function CompositeBody(props) {
|
|
1854
|
-
const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink } = props;
|
|
2754
|
+
const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink, interactive, idScope } = props;
|
|
1855
2755
|
const composite = compileComposite(snapshot);
|
|
1856
2756
|
if (composite === null) return null;
|
|
1857
2757
|
const built = build({ snapshot, compiled: composite, registry, node, props: props.props, data });
|
|
@@ -1859,7 +2759,7 @@ function CompositeBody(props) {
|
|
|
1859
2759
|
warnOnce(`composite-weight:${snapshot.type}@${String(snapshot.v)}`, `${snapshot.type} would render too many nodes; rendering nothing for it`);
|
|
1860
2760
|
return null;
|
|
1861
2761
|
}
|
|
1862
|
-
return /* @__PURE__ */
|
|
2762
|
+
return /* @__PURE__ */ jsx30(
|
|
1863
2763
|
BuilderRenderer,
|
|
1864
2764
|
{
|
|
1865
2765
|
document: built.document,
|
|
@@ -1868,12 +2768,14 @@ function CompositeBody(props) {
|
|
|
1868
2768
|
locale,
|
|
1869
2769
|
assets: built.assets,
|
|
1870
2770
|
mediaOrigin,
|
|
2771
|
+
interactive,
|
|
2772
|
+
idScope,
|
|
1871
2773
|
resolveLink: (target) => built.hrefs.get(JSON.stringify(target)) ?? resolveLink?.(target) ?? null
|
|
1872
2774
|
}
|
|
1873
2775
|
);
|
|
1874
2776
|
}
|
|
1875
2777
|
function CompositeWidget(props) {
|
|
1876
|
-
return /* @__PURE__ */
|
|
2778
|
+
return /* @__PURE__ */ jsx30(PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ jsx30(Suspense3, { fallback: null, children: /* @__PURE__ */ jsx30(CompositeBody, { ...props }) }) });
|
|
1877
2779
|
}
|
|
1878
2780
|
|
|
1879
2781
|
// src/custom/factory.ts
|
|
@@ -1897,12 +2799,12 @@ var BUILTIN_PACKS = [basicPack];
|
|
|
1897
2799
|
var DEFAULT_CUSTOM_WIDGET = customWidgetFactory;
|
|
1898
2800
|
var customKey = (type, v) => `${type}@${String(v)}`;
|
|
1899
2801
|
function createRendererRegistry(packs, options = {}) {
|
|
1900
|
-
const
|
|
2802
|
+
const all2 = [...BUILTIN_PACKS, ...packs];
|
|
1901
2803
|
const components = /* @__PURE__ */ new Map();
|
|
1902
2804
|
const definitions = [];
|
|
1903
2805
|
const sources = [];
|
|
1904
2806
|
const resolvers = /* @__PURE__ */ new Map();
|
|
1905
|
-
for (const pack of
|
|
2807
|
+
for (const pack of all2) {
|
|
1906
2808
|
for (const { Component: Component2, ...definition } of pack.widgets) {
|
|
1907
2809
|
const key = customKey(definition.type, definition.v);
|
|
1908
2810
|
if (components.has(key)) continue;
|
|
@@ -1933,7 +2835,7 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
1933
2835
|
if (own !== void 0) return own;
|
|
1934
2836
|
if (!node.type.startsWith("custom.") || factory === void 0) return void 0;
|
|
1935
2837
|
const snapshot = snapshots.get(key);
|
|
1936
|
-
if (snapshot === void 0) return void 0;
|
|
2838
|
+
if (snapshot === void 0 || snapshot.kind === "code") return void 0;
|
|
1937
2839
|
if (!built.has(key)) built.set(key, factory(snapshot, registry));
|
|
1938
2840
|
return built.get(key) ?? void 0;
|
|
1939
2841
|
},
|
|
@@ -1952,8 +2854,9 @@ async function loadBuilderPage(options) {
|
|
|
1952
2854
|
const found = bundle.page;
|
|
1953
2855
|
if (found === void 0) throw new BuilderNotFoundError(slug);
|
|
1954
2856
|
if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
|
|
1955
|
-
const
|
|
1956
|
-
|
|
2857
|
+
const shared = { ...found, savedSections: found.savedSections ?? bundle.savedSections, code: found.code ?? bundle.code };
|
|
2858
|
+
const data = await staticDataFor([shared], createRendererRegistry(packs), locale, currency);
|
|
2859
|
+
return pageOf(shared, data);
|
|
1957
2860
|
}
|
|
1958
2861
|
|
|
1959
2862
|
// src/next/seo.ts
|