1// GENERATED from dc-runtime/src/*.ts â do not edit. Rebuild with `cd dc-runtime && bun run build`. 2"use strict"; 3(() => { 4 var __defProp = Object.defineProperty; 5 var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 6 var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); 7 8
8// src/react.ts 9 function getReact() { 10 const R = window.React; 11 if (!R) throw new Error("dc-runtime: window.React is not available yet"); 12 return R; 13 } 14 function getReactDOM() { 15 const RD = window.ReactDOM; 16 if (!RD) throw new Error("dc-runtime: window.ReactDOM is not available yet"); 17 return RD; 18 } 19 var h = ((...args) => getReact().createElement( 20 ...args 21 )); 22 23
23// src/parse.ts 24 function parseDcDocument(doc) { 25 const dc = doc.querySelector("x-dc"); 26 if (!dc) return null; 27 const scriptEl = doc.querySelector("script[data-dc-script]"); 28 const { props, preview } = parseDataProps( 29 scriptEl?.getAttribute("data-props") ?? null 30 ); 31 return { 32 template: dc.innerHTML, 33 js: scriptEl ? scriptEl.textContent || "" : "", 34 props, 35 preview 36 }; 37 } 38 function parseDcText(src) { 39 const openMatch = /<x-dc(?:\s[^>]*)?>/.exec(src); 40 if (!openMatch) return null; 41 const close = src.lastIndexOf("</x-dc>"); 42 if (close === -1 || close < openMatch.index) return null; 43 const template = src.slice(openMatch.index + openMatch[0].length, close); 44 const doc = new DOMParser().parseFromString(src, "text/html"); 45 const scriptEl = doc.querySelector("script[data-dc-script]"); 46 const { props, preview } = parseDataProps( 47 scriptEl?.getAttribute("data-props") ?? null 48 ); 49 return { 50 template, 51 js: scriptEl ? scriptEl.textContent || "" : "", 52 props, 53 preview 54 }; 55 } 56 function parseDataProps(raw) { 57 if (!raw) return { props: null, preview: null }; 58 let parsed; 59 try { 60 parsed = JSON.parse(raw); 61 } catch { 62 return { props: null, preview: null }; 63 } 64 if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) { 65 return { props: null, preview: null }; 66 } 67 const obj = parsed; 68 const preview = obj.$preview && typeof obj.$preview === "object" ? obj.$preview : null; 69 const rest = {}; 70 for (const k of Object.keys(obj)) { 71 if (k[0] !== "$") rest[k] = obj[k]; 72 } 73 return { props: Object.keys(rest).length ? rest : null, preview }; 74 } 75 function dcNameFromPath(pathname) { 76 let p = pathname || ""; 77 try { 78 p = decodeURIComponent(p); 79 } catch { 80 } 81 const base = p.split("/").pop() || "Root"; 82 return base.replace(/\.dc\.html$/, "").replace(/\.html?$/, "") || "Root"; 83 } 84 85
85// src/boot.ts 86 var BASE_CSS = ` 87 .sc-placeholder{background:color-mix(in srgb,currentColor 8%,transparent); 88 border:1px solid color-mix(in srgb,currentColor 50%,transparent); 89 border-radius:2px;box-sizing:border-box;overflow:hidden} 90 @keyframes sc-shine{0%{background-position:100% 50%}100%{background-position:0% 50%}} 91 html.sc-dc-streaming .sc-placeholder, 92 html.sc-dc-streaming .sc-interp.sc-missing{position:relative; 93 background:color-mix(in srgb,currentColor 5%,transparent); 94 border-color:transparent} 95 html.sc-dc-streaming .sc-placeholder::before, 96 html.sc-dc-streaming .sc-interp.sc-missing::before{content:''; 97 position:absolute;inset:0;pointer-events:none; 98 background:linear-gradient(90deg,rgba(217,119,87,0) 25%,rgba(247,225,211,.95) 37%,rgba(217,119,87,0) 63%); 99 background-size:400% 100%;animation:sc-shine 1.4s ease infinite} 100 html.sc-dc-streaming .sc-placeholder:nth-child(n+9 of .sc-placeholder)::before, 101 html.sc-dc-streaming .sc-interp.sc-missing:nth-child(n+9 of .sc-interp.sc-missing)::before{animation:none; 102 background:color-mix(in srgb,currentColor 8%,transparent)} 103 .sc-placeholder-error{padding:4px 8px;font:11px/1.4 ui-monospace,monospace; 104 color:color-mix(in srgb,currentColor 70%,transparent);word-break:break-word} 105 .sc-interp.sc-missing{display:inline-block;width:2em;height:1em;overflow:hidden; 106 vertical-align:text-bottom;background:rgba(255,255,255,.3);border:1px solid rgba(0,0,0,.5); 107 border-radius:2px;box-sizing:border-box;color:transparent; 108 user-select:none} 109 .sc-interp.sc-unresolved{font-family:ui-monospace,monospace;font-size:.85em; 110 color:color-mix(in srgb,currentColor 50%,transparent); 111 background:color-mix(in srgb,currentColor 10%,transparent);border-radius:3px; 112 padding:0 3px} 113 .sc-host.sc-has-error{position:relative} 114 .sc-logic-error{position:absolute;top:8px;left:8px;z-index:2147483647;max-width:60ch; 115 padding:6px 10px;background:#b00020;color:#fff;font:12px/1.4 ui-monospace,monospace; 116 border-radius:4px;white-space:pre-wrap;pointer-events:none} 117 /* Mirrors PRINT_BASELINE_CSS in apps/web deck-stage-export.ts \u2014 keep both 118 in sync until dc-runtime regains a build step. */ 119 @media print { 120 @page { margin: 0.5cm; } 121 figure, table { break-inside: avoid; } 122 #dc-root, #dc-root > .sc-host { height: auto; } 123 *, *::before, *::after { 124 print-color-adjust: exact; -webkit-print-color-adjust: exact; 125 backdrop-filter: none !important; -webkit-backdrop-filter: none !important; 126 animation-delay: -99s !important; animation-duration: .001s !important; 127 animation-iteration-count: 1 !important; animation-fill-mode: both !important; 128 animation-play-state: running !important; transition-duration: 0s !important; 129 } 130 } 131 `; 132 var FULL_PAGE_CSS = "html,body{height:100%;margin:0}#dc-root,#dc-root>.sc-host{height:100%}"; 133 function rootNameForDocument(doc, loc) { 134 let bootPath = loc.pathname || ""; 135 if (!/\.dc\.html?$/i.test(safeDecode(bootPath))) { 136 try { 137 bootPath = new URL(doc.baseURI || "/").pathname; 138 } catch { 139 } 140 } 141 return dcNameFromPath(bootPath); 142 } 143 function safeDecode(s) { 144 try { 145 return decodeURIComponent(s); 146 } catch { 147 return s; 148 } 149 } 150 function boot(runtime, doc = document) { 151 const parsed = parseDcDocument(doc); 152 if (!parsed) return null; 153 const React = getReact(); 154 const rootName = rootNameForDocument(doc, location); 155 runtime.markFetched(rootName); 156 runtime.setRootName(rootName); 157 runtime.adoptParsed(rootName, parsed); 158 if (!window.__resources) { 159 fetch(location.href).then((res) => res.ok ? res.text() : "").then((t) => { 160 const raw = t ? parseDcText(t) : null; 161 if (raw?.template) runtime.updateHtml(rootName, raw.template); 162 }).catch(() => { 163 }); 164 } 165 const dc = doc.querySelector("x-dc"); 166 const hostEl = doc.createElement("div"); 167 hostEl.id = "dc-root"; 168 dc.replaceWith(hostEl); 169 if (!parsed.preview) { 170 const s = doc.createElement("style"); 171 s.textContent = FULL_PAGE_CSS; 172 doc.head.appendChild(s); 173 } 174 const Root = runtime.getDC(rootName); 175 const entry = runtime.registry.get(rootName); 176 function StandaloneRoot() { 177 const [, setTick] = React.useState(0); 178 React.useEffect(() => { 179 const sub = () => setTick((n) => n + 1); 180 entry.subs.add(sub); 181 return () => { 182 entry.subs.delete(sub); 183 }; 184 }, []); 185 const defaults = React.useMemo(() => { 186 const d = {}; 187 for (const k in entry.propsMeta || {}) { 188 const v = entry.propsMeta?.[k]?.default; 189 if (v !== void 0) d[k] = v; 190 } 191 return d; 192 }, [entry.propsMeta]); 193 return h(Root, { ...defaults, ...entry.propOverrides || {} }); 194 } 195 const ReactDOM = getReactDOM(); 196 if (ReactDOM.createRoot) 197 ReactDOM.createRoot(hostEl).render(h(StandaloneRoot)); 198 else ReactDOM.render(h(StandaloneRoot), hostEl); 199 return rootName; 200 } 201 202
202// src/expr.ts 203 var IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*/; 204 var NUMBER_RE = /^-?\d+(\.\d+)?$/; 205 function resolve(vals, src) { 206 const expr = String(src).trim(); 207 if (!expr) return void 0; 208 if (expr[0] === "(" && expr[expr.length - 1] === ")" && parensWrapWhole(expr)) { 209 return resolve(vals, expr.slice(1, -1)); 210 } 211 const eq = findTopLevelEquality(expr); 212 if (eq) { 213 const lv = resolve(vals, expr.slice(0, eq.index)); 214 const rv = resolve(vals, expr.slice(eq.index + eq.op.length)); 215 switch (eq.op) { 216 case "===": 217 return lv === rv; 218 case "!==": 219 return lv !== rv; 220 case "==": 221 return lv == rv; 222 default: 223 return lv != rv; 224 } 225 } 226 if (expr[0] === "!") return !resolve(vals, expr.slice(1)); 227 if (expr === "true") return true; 228 if (expr === "false") return false; 229 if (expr === "null") return null; 230 if (expr === "undefined") return void 0; 231 if (NUMBER_RE.test(expr)) return Number(expr); 232 if (expr.length >= 2 && (expr[0] === '"' || expr[0] === "'") && expr[expr.length - 1] === expr[0]) { 233 return expr.slice(1, -1); 234 } 235 return resolvePath(vals, expr); 236 } 237 function parensWrapWhole(expr) { 238 let depth = 0; 239 for (let i = 0; i < expr.length - 1; i++) { 240 if (expr[i] === "(") depth++; 241 else if (expr[i] === ")") { 242 depth--; 243 if (depth === 0) return false; 244 } 245 } 246 return true; 247 } 248 function findTopLevelEquality(expr) { 249 let depth = 0; 250 for (let i = 0; i < expr.length; i++) { 251 const c = expr[i]; 252 if (c === "[" || c === "(") depth++; 253 else if (c === "]" || c === ")") depth--; 254 else if (depth === 0 && (c === "=" || c === "!") && expr[i + 1] === "=") { 255 if (i > 0 && (expr[i - 1] === "=" || expr[i - 1] === "!")) continue; 256 if (!expr.slice(0, i).trim()) continue; 257 const op = expr[i + 2] === "=" ? c + "==" : c + "="; 258 return { index: i, op }; 259 } 260 } 261 return null; 262 } 263 function resolvePath(vals, expr) { 264 const head = expr.match(IDENT_RE); 265 if (!head) return void 0; 266 let cur = vals == null ? void 0 : vals[head[0]]; 267 let i = head[0].length; 268 while (i < expr.length) { 269 if (expr[i] === ".") { 270 const m = expr.slice(i + 1).match(IDENT_RE) || expr.slice(i + 1).match(/^\d+/); 271 if (!m) return void 0; 272 cur = cur == null ? void 0 : cur[m[0]]; 273 i += 1 + m[0].length; 274 } else if (expr[i] === "[") { 275 let depth = 1; 276 let j = i + 1; 277 while (j < expr.length && depth > 0) { 278 if (expr[j] === "[") depth++; 279 else if (expr[j] === "]") { 280 depth--; 281 if (depth === 0) break; 282 } 283 j++; 284 } 285 if (depth !== 0) return void 0; 286 const key = resolve(vals, expr.slice(i + 1, j)); 287 cur = cur == null ? void 0 : cur[key]; 288 i = j + 1; 289 } else { 290 return void 0; 291 } 292 } 293 return cur; 294 } 295 296
296// src/encode.ts 297 var CAMEL_ATTR = "sc-camel-"; 298 var INLINE_TEXT_TAGS = new Set( 299 "a abbr b bdi bdo br cite code del dfn em i ins kbd mark q s samp small span strike strong sub sup u var wbr".split( 300 " " 301 ) 302 ); 303 var RAW_WRAP = { 304 select: "sc-raw-select", 305 table: "sc-raw-table", 306 tbody: "sc-raw-tbody", 307 thead: "sc-raw-thead", 308 tfoot: "sc-raw-tfoot", 309 tr: "sc-raw-tr", 310 td: "sc-raw-td", 311 th: "sc-raw-th", 312 caption: "sc-raw-caption" 313 }; 314 var RAW_UNWRAP = Object.fromEntries( 315 Object.entries(RAW_WRAP).map(([k, v]) => [v, k]) 316 ); 317 var EVENT_MAP = { 318 onclick: "onClick", 319 onchange: "onChange", 320 oninput: "onInput", 321 onsubmit: "onSubmit", 322 onkeydown: "onKeyDown", 323 onkeyup: "onKeyUp", 324 onkeypress: "onKeyPress", 325 onmousedown: "onMouseDown", 326 onmouseup: "onMouseUp", 327 onmouseenter: "onMouseEnter", 328 onmouseleave: "onMouseLeave", 329 onfocus: "onFocus", 330 onblur: "onBlur", 331 ondoubleclick: "onDoubleClick", 332 oncontextmenu: "onContextMenu", 333 onmousemove: "onMouseMove", 334 onmouseover: "onMouseOver", 335 onmouseout: "onMouseOut", 336 onpointerdown: "onPointerDown", 337 onpointerup: "onPointerUp", 338 onpointermove: "onPointerMove", 339 onpointerenter: "onPointerEnter", 340 onpointerleave: "onPointerLeave", 341 onpointercancel: "onPointerCancel", 342 onpointerover: "onPointerOver", 343 onpointerout: "onPointerOut", 344 ongotpointercapture: "onGotPointerCapture", 345 onlostpointercapture: "onLostPointerCapture", 346 ontouchstart: "onTouchStart", 347 ontouchend: "onTouchEnd", 348 ontouchmove: "onTouchMove", 349 ontouchcancel: "onTouchCancel", 350 ondragstart: "onDragStart", 351 ondragend: "onDragEnd", 352 ondragenter: "onDragEnter", 353 ondragleave: "onDragLeave", 354 ondragover: "onDragOver", 355 onanimationstart: "onAnimationStart", 356 onanimationend: "onAnimationEnd", 357 onanimationiteration: "onAnimationIteration", 358 ontransitionend: "onTransitionEnd" 359 }; 360 var ATTRS = `(?:[^>"']|"[^"]*"|'[^']*')*`; 361 var IMPORT_SELF_CLOSE_RE = new RegExp( 362 "<(x-import|dc-import)(" + ATTRS + ")/>", 363 "gi" 364 ); 365 var CAMEL_ATTR_RE = /(\s)([a-z]+[A-Z][A-Za-z0-9]*)(\s*=)/g; 366 function encodeCamelAttrs(html) { 367 return html.replace( 368 CAMEL_ATTR_RE, 369 (_, sp, name, eq) => sp + CAMEL_ATTR + name.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()) + eq 370 ); 371 } 372 function encodeCase(html) { 373 html = html.replace( 374 IMPORT_SELF_CLOSE_RE, 375 (_, t, a) => "<" + t + a + "></" + t + ">" 376 ); 377 html = html.replace(/<helmet(\s|>)/gi, "<sc-helmet$1"); 378 html = html.replace(/<\/helmet\s*>/gi, "</sc-helmet>"); 379 html = encodeCamelAttrs(html); 380 for (const [real, alias] of Object.entries(RAW_WRAP)) { 381 html = html.replace( 382 new RegExp("(</?)" + real + "(?=[\\s>])", "gi"), 383 "$1" + alias 384 ); 385 } 386 return html; 387 } 388 function kebabToCamel(s) { 389 return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase()); 390 } 391 function cssToObj(css) { 392 const o = {}; 393 for (const decl of css.split(";")) { 394 const i = decl.indexOf(":"); 395 if (i < 0) continue; 396 const prop = decl.slice(0, i).trim(); 397 o[prop.startsWith("--") ? prop : kebabToCamel(prop)] = decl.slice(i + 1).trim(); 398 } 399 return o; 400 } 401 function compileAttr(raw) { 402 const whole = raw.match(/^\s*\{\{([\s\S]+?)\}\}\s*$/); 403 if (whole) { 404 const path = whole[1]; 405 return (vals) => resolve(vals, path); 406 } 407 if (raw.includes("{{")) { 408 const parts = raw.split(/\{\{([\s\S]+?)\}\}/g); 409 return (vals) => parts.map((s, i) => i & 1 ? resolve(vals, s) ?? "" : s).join(""); 410 } 411 return () => raw; 412 } 413 414
414// src/compile.ts 415 function collectProps(node, kind, host) { 416 const propGetters = []; 417 const pseudoClasses = []; 418 let hintSize = null; 419 for (const { name, value } of [...node.attributes]) { 420 if (name === "sc-name" || name === "data-dc-tpl") continue; 421 let key = name; 422 if (key.startsWith(CAMEL_ATTR)) 423 key = kebabToCamel(key.slice(CAMEL_ATTR.length)); 424 if (key === "hint-size") { 425 hintSize = value; 426 continue; 427 } 428 if (key.startsWith("style-")) { 429 pseudoClasses.push(host.pseudoClass(key.slice(6), value)); 430 continue; 431 } 432 if (kind !== "dom") { 433 if (key.includes("-") && !(kind === "x-import" && (key.startsWith("aria-") || key.startsWith("data-")))) 434 key = kebabToCamel(key); 435 } else { 436 if (key === "class") key = "className"; 437 else if (key === "for") key = "htmlFor"; 438 else if (key.startsWith("on")) 439 key = EVENT_MAP[key] || "on" + key[2].toUpperCase() + key.slice(3); 440 } 441 propGetters.push([key, compileAttr(value)]); 442 } 443 return { propGetters, pseudoClasses, hintSize }; 444 } 445 var HOST_STYLE_PROPS = /* @__PURE__ */ new Set([ 446 "position", 447 "left", 448 "right", 449 "top", 450 "bottom", 451 "inset", 452 "width", 453 "height", 454 "z-index", 455 "transform" 456 ]); 457 function hostPositionStyle(style) { 458 const all = typeof style === "string" ? cssToObj(style) : style != null && typeof style === "object" ? style : null; 459 if (!all) return void 0; 460 const out = {}; 461 for (const [k, v] of Object.entries(all)) { 462 const kebab = k.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()); 463 if (HOST_STYLE_PROPS.has(kebab)) out[k] = v; 464 } 465 return Object.keys(out).length ? out : void 0; 466 } 467 function compileTemplate(html, host) { 468 const tpl = document.createElement("template"); 469 //! nosemgrep: direct-inner-html-assignment 470 tpl.innerHTML = encodeCase(html); 471 let tplN = 0; 472 (function stamp(node) { 473 if (node.nodeType === Node.ELEMENT_NODE) { 474 node.setAttribute("data-dc-tpl", String(tplN++)); 475 } 476 for (const c of node.childNodes) stamp(c); 477 })(tpl.content); 478 const builders = walkChildren(tpl.content, host); 479 const render = ((vals, ctx) => builders.map((b, i) => b(vals || {}, ctx, i))); 480 render.__annotated = tpl.innerHTML; 481 return render; 482 } 483 function walkChildren(node, host) { 484 return [...node.childNodes].map((c) => walk(c, host)).filter((b) => b != null); 485 } 486 var SLIDE_ID_VALUE_RE = /^[0-9a-f]{8}$/; 487 var DECK_CONTROL_FLOW_RE = /^(sc-if|sc-for|sc-else|dc-import|x-import)$/; 488 var DECK_AUX_RE = /^(template|script|style|sc-helmet|helmet)$/; 489 function isDeckMountTag(el) { 490 if (el.localName === "deck-stage") return true; 491 return el.localName === "x-import" && (el.getAttribute("component-from-global-scope") || "") === "deck-stage"; 492 } 493 function walkDeckChildren(el, host) { 494 const pairs = [...el.childNodes].map((c) => ({ c, b: walk(c, host) })).filter((p) => p.b !== null); 495 const kids = pairs.map((p) => p.b); 496 const seen = /* @__PURE__ */ new Set(); 497 const wsSeen = /* @__PURE__ */ new Map(); 498 const keys = []; 499 const nextSlideId = new Array(pairs.length); 500 { 501 let upcoming = null; 502 for (let j = pairs.length - 1; j >= 0; j--) { 503 const n = pairs[j].c; 504 if (n.nodeType === Node.ELEMENT_NODE) { 505 const t = n.localName; 506 upcoming = !DECK_AUX_RE.test(t) && !DECK_CONTROL_FLOW_RE.test(t) ? n.getAttribute("data-om-slide-id") : null; 507 } 508 nextSlideId[j] = upcoming; 509 } 510 } 511 for (let j = 0; j < pairs.length; j++) { 512 const { c } = pairs[j]; 513 if (c.nodeType === Node.TEXT_NODE) { 514 if ((c.nodeValue ?? "").trim() === "") { 515 const base = nextSlideId[j] ? "omid-ws:" + nextSlideId[j] : "omid-ws:aux"; 516 const n = wsSeen.get(base) ?? 0; 517 wsSeen.set(base, n + 1); 518 keys.push(n === 0 ? base : base + ":" + n); 519 continue; 520 } 521 return { kids, keys: null }; 522 } 523 if (c.nodeType !== Node.ELEMENT_NODE) { 524 keys.push(j); 525 continue; 526 } 527 const child = c; 528 const tag = child.localName; 529 if (DECK_AUX_RE.test(tag)) { 530 keys.push(j); 531 continue; 532 } 533 if (DECK_CONTROL_FLOW_RE.test(tag)) return { kids, keys: null }; 534 const v = child.getAttribute("data-om-slide-id"); 535 if (!v || !SLIDE_ID_VALUE_RE.test(v) || seen.has(v)) { 536 return { kids, keys: null }; 537 } 538 seen.add(v); 539 keys.push("omid:" + v); 540 } 541 return { kids, keys }; 542 } 543 function renderDeckKids(kids, kidKeys, vals, ctx) { 544 return kids.map((b, j) => {
545 const k = kidKeys ? kidKeys[j] : j; 546 const out = b(vals, ctx, k); 547 return kidKeys != null && typeof out === "string" ? h(getReact().Fragment, { key: k }, out) : out; 548 }); 549 } 550 function walk(node, host) { 551 if (node.nodeType === Node.TEXT_NODE) return walkText(node); 552 if (node.nodeType !== Node.ELEMENT_NODE) return null; 553 const el = node; 554 const tag = el.tagName.toLowerCase(); 555 if (tag === "sc-for") return walkFor(el, host); 556 if (tag === "sc-if") return walkIf(el, host); 557 if (tag === "x-import") return walkXImport(el, host); 558 if (tag === "sc-helmet") return host.helmet(el); 559 if (tag === "dc-import") return walkComponent(el, host); 560 return walkElement(el, host); 561 } 562 var warnedHoles = /* @__PURE__ */ new Set(); 563 function warnUnresolved(ctx, what) { 564 const key = (ctx?.__name || "?") + "\0" + what; 565 if (warnedHoles.has(key)) return; 566 warnedHoles.add(key); 567 console.warn("[dc-runtime] " + (ctx?.__name || "template") + ": " + what); 568 } 569 function walkText(node) { 570 const txt = node.nodeValue ?? ""; 571 if (!txt.includes("{{")) { 572 if (!txt.trim() && !txt.includes(" ")) return null; 573 return () => txt; 574 } 575 const parts = txt.split(/\{\{([\s\S]+?)\}\}/g); 576 return (vals, ctx, key) => h( 577 getReact().Fragment, 578 { key }, 579 ...parts.map((p, i) => { 580 if (!(i & 1)) return p; 581 const v = resolve(vals, p); 582 if (v === void 0) { 583 if (!ctx?.__streamingNow) { 584 if (document.body?.hasAttribute("data-dc-editor-on")) { 585 return h( 586 "span", 587 { key: i, className: "sc-interp sc-unresolved" }, 588 "{{ " + p.trim() + " }}" 589 ); 590 } 591 warnUnresolved( 592 ctx, 593 "{{ " + p.trim() + " }} never resolved \u2014 rendered as empty" 594 ); 595 return null; 596 } 597 return h( 598 "span", 599 { key: i, className: "sc-interp sc-missing" }, 600 p.trim() 601 ); 602 } 603 if (getReact().isValidElement(v) || Array.isArray(v)) { 604 return h(getReact().Fragment, { key: i }, v); 605 } 606 if (v === null || typeof v === "boolean") return null; 607 return h("span", { key: i, className: "sc-interp" }, String(v)); 608 }) 609 ); 610 } 611 function walkFor(el, host) { 612 const listGet = compileAttr(el.getAttribute("list") || ""); 613 const asName = el.getAttribute("as") || "item"; 614 const hintN = parseInt(el.getAttribute("hint-placeholder-count") || "0", 10); 615 const kids = walkChildren(el, host); 616 const listSrc = el.getAttribute("list") || ""; 617 return (vals, ctx, key) => { 618 let list = listGet(vals); 619 if (!Array.isArray(list)) { 620 if (!ctx?.__streamingNow) { 621 if (list !== void 0 && list !== null) { 622 warnUnresolved( 623 ctx, 624 'sc-for list="' + listSrc + '" is not an array (' + typeof list + ")" 625 ); 626 } 627 list = []; 628 } else { 629 list = hintN > 0 ? Array(hintN).fill(void 0) : []; 630 } 631 } 632 return h( 633 getReact().Fragment, 634 { key }, 635 list.map((item, i) => { 636 const sub = { ...vals, [asName]: item, $index: i }; 637 return h( 638 getReact().Fragment, 639 { key: i }, 640 kids.map((b, j) => b(sub, ctx, j)) 641 ); 642 }) 643 ); 644 }; 645 } 646 function walkIf(el, host) { 647 const valGet = compileAttr(el.getAttribute("value") || ""); 648 const hintRaw = el.getAttribute("hint-placeholder-val"); 649 const hintGet = hintRaw != null ? compileAttr(hintRaw) : null; 650 const kids = walkChildren(el, host); 651 return (vals, ctx, key) => { 652 let v = valGet(vals); 653 if (v === void 0 && hintGet && ctx?.__streamingNow) v = hintGet(vals); 654 return v ? h( 655 getReact().Fragment, 656 { key }, 657 kids.map((b, j) => b(vals, ctx, j)) 658 ) : null; 659 }; 660 } 661 function walkComponent(el, host) { 662 const name = el.getAttribute("name") || el.getAttribute("component") || ""; 663 el.removeAttribute("name"); 664 el.removeAttribute("component"); 665 const tplId = el.getAttribute("data-dc-tpl"); 666 const styleRaw = el.getAttribute("style"); 667 el.removeAttribute("style"); 668 const styleGet = styleRaw != null ? compileAttr(styleRaw) : null; 669 const { propGetters, hintSize } = collectProps(el, "dc-import", host);
670 const kids = walkChildren(el, host); 671 return (vals, ctx, key) => { 672 const props = { 673 key, 674 __hintSize: hintSize, 675 __tplId: tplId, 676 __hostStyle: styleGet ? hostPositionStyle(styleGet(vals)) : void 0 677 }; 678 for (const [k, g] of propGetters) { 679 const v = g(vals); 680 if (k === "dcProps") { 681 if (v && typeof v === "object") Object.assign(props, v); 682 continue; 683 } 684 props[k] = v; 685 } 686 if (kids.length) props.children = kids.map((b, j) => b(vals, ctx, j)); 687 return h(host.component(name), props); 688 }; 689 } 690 function walkXImport(el, host) { 691 const globalNameGet = compileAttr( 692 el.getAttribute("component-from-global-scope") || "" 693 ); 694 const exportNameGet = compileAttr( 695 el.getAttribute("component") || el.getAttribute("name") || "" 696 ); 697 const fromRaw = el.getAttribute("from") || (el.getAttribute("component-from-global-scope") ? "" : el.getAttribute("src") || el.getAttribute("import") || ""); 698 const urls = fromRaw.trim() ? fromRaw.trim().split(/\s+/) : []; 699 const url = urls.length ? urls[urls.length - 1] : ""; 700 const kindOf = (u) => /\.(jsx|tsx)(\?|#|$)/i.test(u) ? "jsx" : "js"; 701 const tplId = el.getAttribute("data-dc-tpl"); 702 const styleRaw = el.getAttribute("style"); 703 el.removeAttribute("style"); 704 const styleGet = styleRaw != null ? compileAttr(styleRaw) : null; 705 const wrap = tplId != null || styleGet != null; 706 const { propGetters, hintSize } = collectProps(el, "x-import", host); 707 const hasContent = el.children.length > 0 || !!(el.textContent || "").trim(); 708 const deckKeyed = hasContent && isDeckMountTag(el) ? walkDeckChildren(el, host) : null; 709 const kids = deckKeyed ? deckKeyed.kids : hasContent ? walkChildren(el, host) : []; 710 const kidKeys = deckKeyed?.keys ?? null; 711 const urlBindable = fromRaw.includes("{{"); 712 if (urls.length && !urlBindable) { 713 let prev; 714 for (const u of urls) prev = host.loadExternal(kindOf(u), u, prev); 715 } 716 const evalName = (g, vals) => { 717 const v = g(vals); 718 const s = v == null ? "" : String(v); 719 return s.includes("{{") ? "" : s; 720 }; 721 return (vals, ctx, key) => { 722 const globalName = evalName(globalNameGet, vals); 723 const name = globalName || evalName(exportNameGet, vals); 724 const C = !name || urlBindable ? null : globalName ? host.resolveExternalGlobal(url, globalName) : host.resolveExternal(url, name); 725 const hostStyle = styleGet ? hostPositionStyle(styleGet(vals)) : void 0; 726 const wrapper = wrap ? { 727 key, 728 className: "sc-host-x", 729 "data-dc-tpl": tplId, 730 style: hostStyle || { display: "contents" } 731 } : null; 732 if (!C) { 733 const error = urlBindable ? "x-import `from` cannot contain {{ \u2026 }} \u2014 module URLs are resolved at parse time; use a literal URL" : host.resolveExternalError(url, name); 734 const ph = host.placeholder({ 735 key: wrapper ? void 0 : key, 736 name, 737 hintSize, 738 error 739 }); 740 return wrapper ? h("div", wrapper, ph) : ph; 741 } 742 const props = wrapper ? {} : { key }; 743 let unresolvedHole = false; 744 for (const [k, g] of propGetters) { 745 if (k === "component" || k === "componentFromGlobalScope" || k === "from") { 746 continue; 747 } 748 const v = g(vals); 749 if (v === void 0) unresolvedHole = true; 750 if (k === "dcProps") { 751 if (v && typeof v === "object") Object.assign(props, v); 752 continue; 753 } 754 props[k] = v; 755 } 756 if (unresolvedHole && ctx?.__htmlStreamingNow) { 757 const ph = host.placeholder({ 758 key: wrapper ? void 0 : key, 759 name, 760 hintSize, 761 error: null 762 }); 763 return wrapper ? h("div", wrapper, ph) : ph; 764 } 765 if (kids.length) { 766 props.children = renderDeckKids(kids, kidKeys, vals, ctx); 767 } 768 return wrapper ? h("div", wrapper, h(C, props)) : h(C, props); 769 }; 770 } 771 function contentKey(el) { 772 const clone = el.cloneNode(true); 773 for (const d of clone.querySelectorAll("*")) { 774 while (d.attributes.length) d.removeAttribute(d.attributes[0].name); 775 } 776 const s = clone.innerHTML; 777 let h2 = 5381; 778 for (let i = 0; i < s.length;
778 i++) h2 = (h2 << 5) + h2 + s.charCodeAt(i) | 0; 779 return s.length + "." + (h2 >>> 0).toString(36); 780 } 781 var NEVER_CONTENT_KEYED = new Set( 782 "script style textarea option title select canvas iframe video audio".split( 783 " " 784 ) 785 ); 786 var NOT_INLINE_SELECTOR = ":not(" + [...INLINE_TEXT_TAGS].join(",") + ")"; 787 function walkElement(el, host) { 788 const realTag = RAW_UNWRAP[el.localName] || el.localName; 789 const tplId = el.getAttribute("data-dc-tpl"); 790 const inlineOnly = el.childNodes.length > 0 && !NEVER_CONTENT_KEYED.has(realTag) && el.querySelector(NOT_INLINE_SELECTOR) === null; 791 const keySuffix = inlineOnly ? "|" + contentKey(el) : ""; 792 const { propGetters, pseudoClasses } = collectProps(el, "dom", host); 793 const deckKeyed = isDeckMountTag(el) ? walkDeckChildren(el, host) : null; 794 const kids = deckKeyed ? deckKeyed.kids : walkChildren(el, host); 795 const kidKeys = deckKeyed?.keys ?? null; 796 return (vals, ctx, key) => { 797 const props = { 798 key: key + keySuffix, 799 "data-dc-tpl": tplId 800 }; 801 for (const [k, g] of propGetters) { 802 let v = g(vals); 803 if (k === "style" && typeof v === "string") v = cssToObj(v); 804 if ((k === "value" || k === "checked") && v === void 0) { 805 v = k === "checked" ? false : ""; 806 } 807 props[k] = v; 808 } 809 if (pseudoClasses.length) { 810 props.className = [props.className, ...pseudoClasses].filter(Boolean).join(" "); 811 } 812 return h(realTag, props, ...renderDeckKids(kids, kidKeys, vals, ctx)); 813 }; 814 } 815 816
816// src/logic.ts 817 var StreamableLogic = class { 818 constructor(props) { 819 __publicField(this, "props"); 820 __publicField(this, "state", {}); 821 /** Back-pointer to the wrapper component, installed after construction. */ 822 __publicField(this, "__host"); 823 this.props = props || {}; 824 } 825 setState(update, cb) { 826 this.__host && this.__host.__setLogicState(update, cb); 827 } 828 forceUpdate() { 829 this.__host && this.__host.forceUpdate(); 830 } 831 componentDidMount() { 832 } 833 componentDidUpdate(_prevProps) { 834 } 835 componentWillUnmount() { 836 } 837 /** The flat object the template renders against (merged over props). */ 838 renderVals() { 839 return {}; 840 } 841 }; 842 function evalDcLogic(src) { 843 //! nosemgrep: eval-and-function-constructor 844 const fn = new Function( 845 "DCLogic", 846 "StreamableLogic", 847 "React", 848 src + '\n;return (typeof Component!=="undefined"&&Component)||undefined;' 849 ); 850 return fn(StreamableLogic, StreamableLogic, getReact()); 851 } 852 853
853// src/component.ts 854 function shallowEqual(a, b) { 855 if (!b) return false; 856 const ak = Object.keys(a).filter((k) => k !== "children"); 857 const bk = Object.keys(b).filter((k) => k !== "children"); 858 if (ak.length !== bk.length) return false; 859 for (const k of ak) if (a[k] !== b[k]) return false; 860 return true; 861 } 862 function Placeholder({ 863 name, 864 hintSize, 865 streaming, 866 error 867 }) { 868 const [w, hgt] = (hintSize || "100%,60px").split(","); 869 return h( 870 "div", 871 { 872 className: "sc-placeholder" + (streaming ? " sc-streaming" : ""), 873 style: { width: w.trim(), height: hgt && hgt.trim() }, 874 title: name 875 }, 876 error ? h( 877 "div", 878 { className: "sc-placeholder-error" }, 879 (name ? name + ": " : "") + error 880 ) : null 881 ); 882 } 883 function hintToMin(hint) { 884 if (!hint) return void 0; 885 const [w, hgt] = hint.split(","); 886 return { minWidth: w.trim(), minHeight: hgt && hgt.trim() }; 887 } 888 function createComponentFactory(registry, ensureFetched) { 889 const React = getReact(); 890 const AncestorContext = React.createContext([]); 891 class StreamableComponent extends React.Component { 892 constructor(props) { 893 super(props); 894 __publicField(this, "__name"); 895 __publicField(this, "__sub"); 896 __publicField(this, "__needsDidMount", false); 897 /** Snapshot of the registry's streaming flags taken at render time â 898 * builders read it off the RenderCtx (this) to pick placeholder vs 899 * render-nothing for unresolved values. */ 900 __publicField(this, "__streamingNow", false); 901 __publicField(this, "__htmlStreamingNow", false); 902 /** When a construct throws, remember the (class, registry.ver, props) 903 * triple so render-time reconcile doesn't re-attempt it on every parent 904 * re-render. A registry bump (new class, template, external module 905 * resolving via bumpAll) changes `ver` and breaks the memo so an 906 * env-dependent constructor can self-heal. */ 907 __publicField(this, "__failedLogic", null); 908 __publicField(this, "__failedUserProps", null); 909 __publicField(this, "__failedVer", -1); 910 /** Per-instance constructor error â kept here (not on the registry entry) 911 * so one instance's successful construct can't hide a sibling's failure, 912 * and a construct can never wipe an eval error `updateJs` recorded on 913 * `r.logicError`. */ 914 __publicField(this, "__ctorError", null); 915 __publicField(this, "logic"); 916 this.__name = props.__name; 917 this.state = { __v: 0, __err: null }; 918 this.__sub = () => { 919 if (this.state.__err) this.setState({ __err: null }); 920 this.forceUpdate(); 921 }; 922 this.__makeLogic(registry.get(this.__name).Logic, null); 923 ensureFetched(this.__name); 924 } 925 /** Error-boundary hook: a render crash anywhere in this DC's subtree 926 * (its own template, an x-import'd component, a child DC without its 927 * own deeper boundary) lands here instead of unmounting the page. */ 928 static getDerivedStateFromError(e) { 929 return { __err: e instanceof Error && e.message ? e.message : String(e) }; 930 } 931 componentDidCatch(e, info) { 932 console.error( 933 "[dc-runtime] render error in <" + this.__name + ">:", 934 e, 935 info?.componentStack || "" 936 ); 937 } 938 /** Instantiate the logic class (or the no-op base) and adopt `prevState` 939 * over its initial state â used both at mount and on hot-swap. */ 940 __makeLogic(Logic, prevState) { 941 const L = Logic || StreamableLogic; 942 try { 943 this.logic = new L(this.__userProps()); 944 this.__failedLogic = null; 945 this.__failedUserProps = null; 946 this.__ctorError = null; 947 } catch (e) { 948 console.error(e); 949 this.__failedLogic = Logic; 950 this.__failedUserProps = this.__userProps(); 951 this.__failedVer = registry.get(this.__name).ver; 952 this.__ctorError = this.__name + ": " + (e instanceof Error && e.message ? e.message :
952String(e)); 953 this.logic = new StreamableLogic( 954 this.__userProps() 955 ); 956 } 957 this.logic.__host = this; 958 if (prevState) 959 this.logic.state = { ...this.logic.state || {}, ...prevState }; 960 } 961 /** The props the author's logic + template see â internal __-prefixed 962 * wiring stripped. */ 963 __userProps() { 964 const { __name, __hintSize, __tplId, __hostStyle, ...rest } = this.props; 965 return rest; 966 } 967 __setLogicState(update, cb) { 968 const prev = this.logic.state; 969 const patch = typeof update === "function" ? update(prev) : update; 970 this.logic.state = { ...prev, ...patch }; 971 this.setState((s) => ({ __v: s.__v + 1 }), cb); 972 } 973 /** Swap the logic instance when the registry's Logic class changed 974 * (streaming completion, hot reload). State carries over; didMount 975 * re-fires after the swap commits so refs exist. */ 976 __reconcileLogic() { 977 const r = registry.get(this.__name); 978 const Next = r.Logic; 979 const Cur = this.logic.constructor; 980 if (Next === Cur || !Next && Cur === StreamableLogic || Next === this.__failedLogic && r.ver === this.__failedVer && shallowEqual(this.__userProps(), this.__failedUserProps)) { 981 return; 982 } 983 if (!this.__needsDidMount) { 984 try { 985 this.logic.componentWillUnmount(); 986 } catch (e) { 987 console.error(e); 988 } 989 } 990 this.__makeLogic(Next, this.logic.state); 991 this.__needsDidMount = true; 992 } 993 componentDidMount() { 994 registry.get(this.__name).subs.add(this.__sub); 995 try { 996 this.logic.componentDidMount(); 997 } catch (e) { 998 console.error(e); 999 } 1000 } 1001 componentDidUpdate(prevProps) { 1002 this.logic.props = this.__userProps(); 1003 if (this.__needsDidMount) { 1004 if (this.state.__err || !registry.get(this.__name).tpl) return; 1005 this.__needsDidMount = false; 1006 try { 1007 this.logic.componentDidMount(); 1008 } catch (e) { 1009 console.error(e); 1010 } 1011 } else { 1012 try { 1013 this.logic.componentDidUpdate(prevProps); 1014 } catch (e) { 1015 console.error(e); 1016 } 1017 } 1018 } 1019 componentWillUnmount() { 1020 registry.get(this.__name).subs.delete(this.__sub); 1021 if (!this.__needsDidMount) { 1022 try { 1023 this.logic.componentWillUnmount(); 1024 } catch (e) { 1025 console.error(e); 1026 } 1027 } 1028 } 1029 render() { 1030 const r = registry.get(this.__name); 1031 const cls = "sc-host" + (r.htmlStreaming ? " sc-streaming-html" : "") + (r.jsStreaming ? " sc-streaming-js" : ""); 1032 const hintStyle = r.htmlStreaming ? hintToMin(this.props.__hintSize) : void 0; 1033 const hostStyle = this.props.__hostStyle || hintStyle ? { ...hintStyle || {}, ...this.props.__hostStyle || {} } : void 0; 1034 const hostBase = { 1035 className: cls, 1036 style: hostStyle, 1037 "data-sc-name": this.__name, 1038 "data-dc-tpl": this.props.__tplId 1039 }; 1040 const chain = Array.isArray(this.context) ? this.context : []; 1041 if (chain.includes(this.__name)) { 1042 const cycle = [ 1043 ...chain.slice(chain.indexOf(this.__name)), 1044 this.__name 1045 ].join(" \u2192 "); 1046 return h( 1047 "div", 1048 { ...hostBase, className: cls + " sc-has-error" }, 1049 h(Placeholder, { 1050 name: this.__name, 1051 hintSize: this.props.__hintSize, 1052 error: "circular import: " + cycle 1053 }) 1054 ); 1055 } 1056 if (this.state.__err) { 1057 return h( 1058 "div", 1059 { ...hostBase, className: cls + " sc-has-error" }, 1060 h( 1061 "div", 1062 { className: "sc-logic-error", "data-omelette-chrome": "" }, 1063 this.__name + ": " + this.state.__err 1064 ), 1065 h(Placeholder, { 1066 name: this.__name, 1067 hintSize: this.props.__hintSize, 1068 error: this.state.__err 1069 }) 1070 ); 1071 } 1072 this.__reconcileLogic(); 1073 if (!r.tpl) { 1074 return h( 1075 "div", 1076 hostBase, 1077 h(Placeholder, { name: this.__name, hintSize: this.props.__hintSize }) 1078 ); 1079 } 1080 const userProps = this.__userProps(); 1081 this.logic.props = userProps; 1082 let vals = userProps; 1083 let renderErr = r.logicError || this.__ctorError; 1084 try { 1085 vals = { ...userProps, ...this.logic.renderVals() || {} }; 1086 } catch (e) { 1087 console.error(e); 1088 renderErr = this.__name + ".renderVals(): " + (e instanceof Error && e.message ? e.message :
1088String(e)); 1089 } 1090 this.__streamingNow = !!(r.htmlStreaming || r.jsStreaming); 1091 this.__htmlStreamingNow = !!r.htmlStreaming; 1092 return h( 1093 "div", 1094 { ...hostBase, className: cls + (renderErr ? " sc-has-error" : "") }, 1095 renderErr && h( 1096 "div", 1097 { className: "sc-logic-error", "data-omelette-chrome": "" }, 1098 renderErr 1099 ), 1100 h( 1101 AncestorContext.Provider, 1102 { value: [...chain, this.__name] }, 1103 r.tpl(vals, this) 1104 ) 1105 ); 1106 } 1107 } 1108 __publicField(StreamableComponent, "contextType", AncestorContext); 1109 const named = /* @__PURE__ */ new Map(); 1110 function getDC(name) { 1111 const hit = named.get(name); 1112 if (hit) return hit; 1113 function Dispatcher(p) { 1114 const [, setTick] = React.useState(0); 1115 React.useEffect(() => { 1116 const sub = () => setTick((n) => n + 1); 1117 registry.get(name).subs.add(sub); 1118 return () => { 1119 registry.get(name).subs.delete(sub); 1120 }; 1121 }, []); 1122 ensureFetched(name); 1123 return h(StreamableComponent, { ...p, __name: name }); 1124 } 1125 Dispatcher.displayName = name; 1126 named.set(name, Dispatcher); 1127 return Dispatcher; 1128 } 1129 return { 1130 getDC, 1131 StreamableComponent 1132 }; 1133 } 1134 1135
1135// src/bundled.ts 1136 function bundledBlob(url) { 1137 const blobs = window.__resourceBlobs; 1138 const b = blobs ? blobs[url.split("#")[0]] : void 0; 1139 return b instanceof Blob ? b : null; 1140 } 1141 1142
1142// src/cdn.ts 1143 // PATCHED: self-hosted instead of unpkg.com (DSGVO: no third-party request before consent). 1144 // Files in /vendor are byte-identical to unpkg (same SRI). Re-apply after regenerating support.js. 1145 var REACT_URL = "/vendor/react.production.min.js"; 1146 var REACT_SRI = "sha384-DGyLxAyjq0f9SPpVevD6IgztCFlnMF6oW/XQGmfe+IsZ8TqEiDrcHkMLKI6fiB/Z"; 1147 var REACT_DOM_URL = "/vendor/react-dom.production.min.js"; 1148 var REACT_DOM_SRI = "sha384-gTGxhz21lVGYNMcdJOyq01Edg0jhn/c22nsx0kyqP0TxaV5WVdsSH1fSDUf5YJj1"; 1149 var BABEL_URL = "/vendor/babel.min.js"; 1150 var BABEL_SRI = "sha384-m08KidiNqLdpJqLq95G/LEi8Qvjl/xUYll3QILypMoQ65QorJ9Lvtp2RXYGBFj1y"; 1151 function cdnScriptFor(url, sri) { 1152 const res = window.__resources; 1153 const v = res ? res[url] : void 0; 1154 return typeof v === "string" && v ? { src: v } : { src: url, integrity: sri }; 1155 } 1156 1157
1157// src/external.ts 1158 var isCustomElementName = (n) => !n.includes(".") && n.includes("-"); 1159 function isRenderableType(g) { 1160 if (typeof g === "function") return !isElementClass(g); 1161 return typeof g === "object" && g !== null && typeof g.$$typeof === "symbol"; 1162 } 1163 function resolveDottedPath(root, name) { 1164 let cur = root; 1165 for (const seg of name.split(".")) { 1166 if (cur == null) return void 0; 1167 cur = cur[seg]; 1168 } 1169 return cur; 1170 } 1171 var GLOBAL_POLL_INTERVAL_MS = 50; 1172 var GLOBAL_POLL_TIMEOUT_MS = 3e4; 1173 function createExternalModules(onResolved) { 1174 const cache = /* @__PURE__ */ new Map(); 1175 let babelLoading = null; 1176 const reportedMissing = /* @__PURE__ */ new Map(); 1177 const polling = /* @__PURE__ */ new Set(); 1178 function ensureBabel() { 1179 if (window.Babel) return Promise.resolve(); 1180 if (babelLoading) return babelLoading; 1181 const babel = cdnScriptFor(BABEL_URL, BABEL_SRI); 1182 babelLoading = new Promise((res, rej) => { 1183 const s = document.createElement("script"); 1184 s.src = babel.src; 1185 if (babel.integrity) { 1186 s.integrity = babel.integrity; 1187 s.crossOrigin = "anonymous"; 1188 } 1189 s.onload = () => res(); 1190 s.onerror = rej; 1191 document.head.appendChild(s); 1192 }); 1193 return babelLoading; 1194 } 1195 const pending = /* @__PURE__ */ new Map(); 1196 function load(kind, url, after) { 1197 const existing = pending.get(url); 1198 if (existing) return existing; 1199 cache.set(url, null); 1200 console.info("[dc-runtime] x-import: loading", url, "(" + kind + ")"); 1201 const ready = Promise.all([
1202 kind === "jsx" ? ensureBabel() : Promise.resolve(), 1203 after ?? Promise.resolve() 1204 ]); 1205 const p = ready.then(() => { 1206 const pre = bundledBlob(url); 1207 if (pre) return pre.text(); 1208 return fetch(url).then((r) => { 1209 if (!r.ok) throw new Error("HTTP " + r.status); 1210 return r.text(); 1211 }); 1212 }).then((src) => { 1213 const code = kind === "jsx" ? window.Babel.transform(src, { 1214 filename: url, 1215 presets: ["react", "typescript"] 1216 }).code : src; 1217 const module = { exports: {} }; 1218 const before = new Set(Object.keys(window)); 1219 //! nosemgrep: eval-and-function-constructor 1220 new Function("React", "module", "exports", "require", code)( 1221 getReact(), 1222 module, 1223 module.exports, 1224 () => ({}) 1225 ); 1226 const globals = {}; 1227 for (const k of Object.keys(window)) { 1228 if (!before.has(k) && typeof window[k] === "function") { 1229 globals[k] = window[k]; 1230 } 1231 } 1232 cache.set(url, { mod: module.exports, globals }); 1233 console.info( 1234 "[dc-runtime] x-import: loaded", 1235 url, 1236 "\u2014 exports:", 1237 Object.keys(module.exports), 1238 "window globals:", 1239 Object.keys(globals) 1240 ); 1241 onResolved(); 1242 }).catch((e) => { 1243 cache.set(url, { 1244 mod: {}, 1245 globals: {}, 1246 error: "failed to load: " + (e instanceof Error && e.message ? e.message : String(e)) 1247 }); 1248 console.error( 1249 "[dc-runtime] x-import: FAILED to load", 1250 url, 1251 "(" + kind + ")", 1252 e 1253 ); 1254 onResolved(); 1255 }); 1256 pending.set(url, p); 1257 return p; 1258 } 1259 function resolve2(url, name) { 1260 const entry = cache.get(url); 1261 if (!entry) return null; 1262 const { mod, globals } = entry; 1263 const C = mod && mod[name] || globals && globals[name] || typeof window !== "undefined" && window[name] || mod && mod.default; 1264 if (typeof C === "function") return C; 1265 const key = url + "\0" + name; 1266 if (!reportedMissing.has(key)) { 1267 reportedMissing.set( 1268 key, 1269 entry.error || 'no export named "' + name + '" (has: ' + Object.keys(mod).join(", ") + ")" 1270 ); 1271 console.error( 1272 "[dc-runtime] x-import: module", 1273 url, 1274 "loaded but has no component named", 1275 JSON.stringify(name), 1276 "\u2014 available exports:", 1277 Object.keys(mod), 1278 "window globals:", 1279 Object.keys(globals), 1280 ". The module must `module.exports = {" + name + "}` or set `window." + name + "`." 1281 ); 1282 } 1283 return null; 1284 } 1285 function waitForGlobal(name) { 1286 if (polling.has(name)) return; 1287 polling.add(name); 1288 const started = Date.now(); 1289 const isCE = isCustomElementName(name); 1290 const tick = () => { 1291 const found = isCE ? customElements.get(name) : isRenderableType(resolveDottedPath(window, name)); 1292 if (found) { 1293 polling.delete(name); 1294 onResolved(); 1295 return; 1296 } 1297 if (Date.now() - started >= GLOBAL_POLL_TIMEOUT_MS) { 1298 console.warn( 1299 "[dc-runtime] x-import: global", 1300 JSON.stringify(name), 1301 "never appeared on window after " + GLOBAL_POLL_TIMEOUT_MS + "ms"
1302 ); 1303 return; 1304 } 1305 setTimeout(tick, GLOBAL_POLL_INTERVAL_MS); 1306 }; 1307 setTimeout(tick, GLOBAL_POLL_INTERVAL_MS); 1308 } 1309 function resolveGlobal(url, name) { 1310 const isCE = isCustomElementName(name); 1311 if (!url) { 1312 if (isCE) { 1313 if (customElements.get(name)) return name; 1314 waitForGlobal(name); 1315 return null; 1316 } 1317 const g2 = resolveDottedPath(window, name); 1318 if (isRenderableType(g2)) return g2; 1319 waitForGlobal(name); 1320 return null; 1321 } 1322 const entry = cache.get(url); 1323 if (!entry) return null; 1324 if (isCE && customElements.get(name)) return name; 1325 const g = entry.globals[name] ?? resolveDottedPath(window, name); 1326 if (isRenderableType(g)) return g; 1327 if (name.includes(".")) return null; 1328 const key = url + "\0global\0" + name; 1329 if (!reportedMissing.has(key)) { 1330 reportedMissing.set(key, null); 1331 if (isCE && !customElements.get(name)) { 1332 console.warn( 1333 "[dc-runtime] x-import:", 1334 url, 1335 "loaded but no custom element", 1336 JSON.stringify(name), 1337 "is registered and window." + name + " is not a function \u2014 rendering <" + name + "> as an unknown element." 1338 ); 1339 } 1340 } 1341 return name; 1342 } 1343 function getError(url, name) { 1344 const entry = cache.get(url); 1345 if (entry?.error) return entry.error; 1346 return reportedMissing.get(url + "\0" + name) || null; 1347 } 1348 return { load, resolve: resolve2, resolveGlobal, getError }; 1349 } 1350 function isElementClass(g) { 1351 try { 1352 return typeof g === "function" && typeof HTMLElement !== "undefined" && g.prototype instanceof HTMLElement; 1353 } catch { 1354 return false; 1355 } 1356 } 1357 1358
1358// src/atomics.ts 1359 var ATOMIC_CSS = ( 1360 // layout 1361 ".fx{display:flex}.col{display:flex;flex-direction:column}.grid{display:grid}.ac{align-items:center}.jc{justify-content:center}.jb{justify-content:space-between}.f1{flex:1}.noshrink{flex-shrink:0}.wrap{flex-wrap:wrap}.fw5{font-weight:500}.fw6{font-weight:600}.fw7{font-weight:700}.fw8{font-weight:800}.fs11{font-size:11px}.fs12{font-size:12px}.fs13{font-size:13px}.fs14{font-size:14px}.fs15{font-size:15px}.fs16{font-size:16px}.fs20{font-size:20px}.fs22{font-size:22px}.upper{text-transform:uppercase}.tc{text-align:center}.nowrap{white-space:nowrap}.gap8{gap:8px}.gap10{gap:10px}.gap12{gap:12px}.gap16{gap:16px}.gap24{gap:24px}.m0{margin:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}.posrel{position:relative}.posabs{position:absolute}.round{border-radius:50%}.ohide{overflow:hidden}.bbox{box-sizing:border-box}.pointer{cursor:pointer}.w100{width:100%}.b0{border:none}" 1362 ); 1363 1364
1364// src/helmet.ts 1365 var DESIGN_DOC_MODE_RE = /<meta\b[^>]*\bname\s*=\s*["']design_doc_mode["'][^>]*\b(?:content|value)\s*=\s*["'](\w+)["']/i; 1366 var CANVAS_BG_LIGHT = "#f0eee6"; 1367 var CANVAS_BG_DARK = "#2e2c26"; 1368 function createHelmetManager(doc, isStreaming) { 1369 const mounted = /* @__PURE__ */ new Set(); 1370 const live = /* @__PURE__ */ new Map(); 1371 let designDocMode = null; 1372 let canvasStyleEl = null; 1373 let appTheme = "light"; 1374 try { 1375 const ds = doc.documentElement.dataset.theme; 1376 appTheme = ds === "dark" || ds === "light" ? ds : new URLSearchParams(doc.defaultView?.location.search ?? "").get( 1377 "theme" 1378 ) === "dark" ? "dark" : "light"; 1379 } catch { 1380 } 1381 function applyCanvasBg() { 1382 if (!canvasStyleEl) return; 1383 const bg = appTheme === "dark" ? CANVAS_BG_DARK : CANVAS_BG_LIGHT; 1384 canvasStyleEl.textContent = `html,body{background:${bg}}#dc-root>.sc-host{position:relative}`; 1385 } 1386 function postDesignMode(mode) { 1387 if (window.parent === window) return; 1388 try { 1389 window.parent.postMessage({ type: "__dc_design_mode", mode }, "*"); 1390 } catch { 1391 } 1392 } 1393 function setDesignDocMode(mode) { 1394 if (mode === designDocMode) return; 1395 designDocMode = mode; 1396 postDesignMode(mode); 1397 if (mode === "canvas") { 1398 doc.documentElement.setAttribute("data-dc-canvas", ""); 1399 canvasStyleEl = doc.createElement("style"); 1400 canvasStyleEl.setAttribute("data-dc-canvas", ""); 1401 applyCanvasBg(); 1402 doc.head.appendChild(canvasStyleEl); 1403 } else { 1404 doc.documentElement.removeAttribute("data-dc-canvas"); 1405 canvasStyleEl?.remove(); 1406 canvasStyleEl = null; 1407 } 1408 } 1409 window.addEventListener("message", (e) => { 1410 const type = e.data && e.data.type; 1411 if (type === "__dc_theme") { 1412 const t = e.data.theme; 1413 if (t === "light" || t === "dark") { 1414 appTheme = t; 1415 applyCanvasBg(); 1416 } 1417 return; 1418 } 1419 if (!designDocMode || type !== "__dc_probe") return; 1420 postDesignMode(designDocMode); 1421 }); 1422 function compile(node) { 1423 const raw = [...node.children]; 1424 const helmetClosed = node.nextSibling != null || node.parentNode?.nextSibling != null; 1425 if (node.hasAttribute("data-dc-atomics") && !mounted.has("__dc-atomics")) { 1426 mounted.add("__dc-atomics"); 1427 const el = doc.createElement("style"); 1428 el.id = "__dc-atomics"; 1429 el.textContent = ATOMIC_CSS; 1430 doc.head.appendChild(el); 1431 } 1432 return (_vals, ctx) => { 1433 const name = ctx && ctx.__name || ""; 1434 const streaming = !!(name && isStreaming(name)); 1435 for (let i = 0; i < raw.length; i++) { 1436 const child = raw[i]; 1437 const tag = child.tagName; 1438 const mayBePartial = streaming && !helmetClosed && i === raw.length - 1; 1439 if (tag === "SCRIPT") { 1440 if (mayBePartial) continue; 1441 const key = "SCRIPT|" + (child.getAttribute("src") || child.textContent || ""); 1442 if (mounted.has(key)) continue; 1443 mounted.add(key); 1444 const el = doc.createElement("script"); 1445 for (const { name: an, value } of [...child.attributes]) 1446 el.setAttribute(an, value); 1447 if (child.textContent) el.textContent = child.textContent; 1448 doc.head.appendChild(el); 1449 } else if (tag === "LINK" || tag === "META") { 1450 if (mayBePartial) continue; 1451 const key = tag + "|" + (child.getAttribute("href") || child.getAttribute("src") || child.outerHTML); 1452 if (mounted.has(key)) continue; 1453 mounted.add(key); 1454 if (tag === "LINK") { 1455 const rel = (child.getAttribute("rel") || "").toLowerCase().split(/\s+/); 1456 const href = (child.getAttribute("href") || "").trim(); 1457 const res = window.__resources; 1458 const pre = res && rel.includes("stylesheet") && !rel.includes("alternate") ? res[href] : void 0; 1459 const blob = typeof pre === "string" && pre ? bundledBlob(pre) : null; 1460 if (blob) { 1461 const el = doc.createElement("style"); 1462 if (child.hasAttribute("disabled")) { 1463 el.setAttribute("media", "not all"); 1464 } else if (child.getAttribute("media")) { 1465 el.setAttribute("media", child.getAttribute("media")); 1466 } 1467 if (child.getAttribute("title")) 1468 el.setAttribute("title", child.getAttribute("title")); 1469 void blob.text().then((css) => { 1470 el.textContent = css; 1471 }); 1472 doc.head.appendChild(el); 1473 continue; 1474 } 1475 } 1476 doc.head.appendChild(child.cloneNode(true)); 1477 } else {
1478 const key = name + "|" + i; 1479 let el = live.get(key); 1480 if (!el || el.tagName !== tag) { 1481 if (el) el.remove(); 1482 el = doc.createElement(tag.toLowerCase()); 1483 live.set(key, el); 1484 doc.head.appendChild(el); 1485 } 1486 for (const { name: an, value } of [...child.attributes]) { 1487 if (el.getAttribute(an) !== value) el.setAttribute(an, value); 1488 } 1489 if (el.textContent !== child.textContent) 1490 el.textContent = child.textContent; 1491 } 1492 } 1493 return null; 1494 }; 1495 } 1496 return { compile, setDesignDocMode }; 1497 } 1498 1499
1499// src/pseudo.ts 1500 function scanUnquotedUrl(css, i) { 1501 if (css[i] !== "u" && css[i] !== "U" || css.slice(i, i + 4).toLowerCase() !== "url(" || /[a-z0-9_-]/i.test(css[i - 1] ?? "")) { 1502 return -1; 1503 } 1504 let j = i + 4; 1505 while (j < css.length && /\s/.test(css[j])) j++; 1506 if (css[j] === '"' || css[j] === "'") return -1; 1507 while (j < css.length && css[j] !== ")") { 1508 if (css[j] === "\\") j++; 1509 j++; 1510 } 1511 return j < css.length ? j + 1 : css.length; 1512 } 1513 function stripComments(css) { 1514 let out = ""; 1515 let quote = ""; 1516 for (let i = 0; i < css.length; i++) { 1517 const c = css[i]; 1518 if (quote) { 1519 if (c === "\\") { 1520 out += c + (css[i + 1] ?? ""); 1521 i++; 1522 continue; 1523 } 1524 if (c === quote) quote = ""; 1525 out += c; 1526 } else if (c === "'" || c === '"') { 1527 quote = c; 1528 out += c; 1529 } else if (c === "/" && css[i + 1] === "*") { 1530 const end = css.indexOf("*/", i + 2); 1531 i = end === -1 ? css.length : end + 1; 1532 out += " "; 1533 } else { 1534 const end = scanUnquotedUrl(css, i); 1535 if (end === -1) out += c; 1536 else { 1537 out += css.slice(i, end); 1538 i = end - 1; 1539 } 1540 } 1541 } 1542 return out; 1543 } 1544 function importantify(css) { 1545 css = stripComments(css); 1546 const decls = []; 1547 let start = 0; 1548 let depth = 0; 1549 let quote = ""; 1550 for (let i = 0; i < css.length; i++) { 1551 const c = css[i]; 1552 if (quote) { 1553 if (c === "\\") i++; 1554 else if (c === quote) quote = ""; 1555 } else if (c === "'" || c === '"') quote = c; 1556 else if (c === "(") depth++; 1557 else if (c === ")") depth = Math.max(0, depth - 1); 1558 else if (c === ";" && depth === 0) { 1559 decls.push(css.slice(start, i)); 1560 start = i + 1; 1561 } else { 1562 const end = scanUnquotedUrl(css, i); 1563 if (end !== -1) i = end - 1; 1564 } 1565 } 1566 decls.push(css.slice(start)); 1567 return decls.map((d) => d.trim()).filter(Boolean).map((d) => /!\s*important$/i.test(d) ? d : d + " !important").join(";"); 1568 } 1569 function createPseudoSheet(doc) { 1570 let el = null; 1571 const cache = /* @__PURE__ */ new Map(); 1572 let n = 0; 1573 return (pseudo, css) => { 1574 const k = pseudo + "|" + css; 1575 const hit = cache.get(k); 1576 if (hit) return hit; 1577 if (!el) { 1578 el = doc.createElement("style"); 1579 doc.head.appendChild(el); 1580 } 1581 const cls = "scp" + (n++).toString(36); 1582 const isPseudoElement = pseudo === "before" || pseudo === "after"; 1583 const sel = isPseudoElement ? "." + cls + "::" + pseudo : "." + cls + ":" + pseudo; 1584 el.sheet.insertRule( 1585 sel + "{" + (isPseudoElement ? css : importantify(css)) + "}", 1586 el.sheet.cssRules.length 1587 ); 1588 cache.set(k, cls); 1589 return cls; 1590 }; 1591 } 1592 1593
1593// src/registry.ts 1594 function createRegistry() { 1595 const entries = /* @__PURE__ */ Object.create(null); 1596 function get(name) { 1597 return entries[name] || (entries[name] = { 1598 html: "", 1599 tpl: null, 1600 Logic: null, 1601 jsStreaming: false, 1602 htmlStreaming: false, 1603 ver: 0, 1604 subs: /* @__PURE__ */ new Set(), 1605 fetched: false 1606 }); 1607 } 1608 function bump(name) { 1609 const r = get(name); 1610 r.ver++; 1611 for (const fn of r.subs) fn(); 1612 } 1613 return { 1614 entries, 1615 get, 1616 bump, 1617 bumpAll() { 1618 for (const n in entries) bump(n); 1619 } 1620 }; 1621 } 1622 1623
1623// src/runtime.ts 1624 // PATCHED: "" statt "." â Komponenten absolut ab /, damit sie auch unter sauberen URLs wie /wissen/perma-modell/ laden. 1625 var COMPONENT_DIR = ""; 1626 function createRuntime(doc = document) { 1627 const registry = createRegistry(); 1628 const pseudoClass = createPseudoSheet(doc); 1629 const helmet = createHelmetManager( 1630 doc, 1631 (name) => registry.get(name).htmlStreaming 1632 ); 1633 const external = createExternalModules(() => registry.bumpAll()); 1634 const factory = createComponentFactory(registry, ensureFetched); 1635 const host = { 1636 component: (name) => factory.getDC(name), 1637 placeholder: (props) => h(Placeholder, props), 1638 helmet: (node) => helmet.compile(node), 1639 loadExternal: (kind, url, after) => external.load(kind, url, after), 1640 resolveExternal: (url, name) => external.resolve(url, name), 1641 resolveExternalGlobal: (url, name) => external.resolveGlobal(url, name), 1642 resolveExternalError: (url, name) => external.getError(url, name), 1643 pseudoClass 1644 }; 1645 function ensureFetched(name) { 1646 const r = registry.get(name); 1647 if (r.fetched) return; 1648 r.fetched = true; 1649 const url = COMPONENT_DIR + "/" + encodeURIComponent(name) + ".dc.html"; 1650 const res = window.__resources; 1651 const pre = res ? res[url] : void 0; 1652 const target = typeof pre === "string" && pre ? pre : url; 1653 const blob = bundledBlob(target); 1654 (blob ? blob.text() : fetch(target).then((res2) => { 1655 if (!res2.ok) { 1656 console.error( 1657 '[dc-runtime] sibling fetch for "' + name + '" failed:', 1658 url, 1659 "returned", 1660 res2.status, 1661 "\u2014 the reference renders as an empty placeholder." 1662 ); 1663 return ""; 1664 } 1665 return res2.text(); 1666 })).then((t) => { 1667 if (!t) return; 1668 const parsed = parseDcText(t); 1669 if (!parsed) { 1670 console.error( 1671 '[dc-runtime] sibling fetch for "' + name + '":', 1672 url, 1673 "has no <x-dc> block \u2014 not a Design Component." 1674 ); 1675 return; 1676 } 1677 if (parsed.props) r.propsMeta = parsed.props; 1678 if (parsed.preview) r.preview = parsed.preview; 1679 if (parsed.template && !r.html) updateHtml(name, parsed.template); 1680 if (parsed.js && !r.Logic) updateJs(name, parsed.js); 1681 }).catch( 1682 (e) => console.error( 1683 '[dc-runtime] sibling fetch for "' + name + '" threw:', 1684 url, 1685 e 1686 ) 1687 ); 1688 } 1689 let rootName = null; 1690 function updateHtml(name, html) { 1691 const r = registry.get(name); 1692 r.html = html; 1693 if (name === rootName) { 1694 const mode = DESIGN_DOC_MODE_RE.exec(html)?.[1] ?? null; 1695 if (mode || !r.htmlStreaming) helmet.setDesignDocMode(mode); 1696 } 1697 try { 1698 r.tpl = compileTemplate(html, host); 1699 } catch (e) { 1700 console.error("[dc-runtime] template compile FAILED for", name, e); 1701 } 1702 registry.bump(name); 1703 } 1704 function updateJs(name, src) { 1705 const r = registry.get(name); 1706 const seq = r.jsSeq = (r.jsSeq || 0) + 1; 1707 try { 1708 const Cls = evalDcLogic(src); 1709 if (r.jsSeq !== seq) return; 1710 if (typeof Cls !== "function") { 1711 r.logicError = name + ".dc.html: <script data-dc-script> must define `class Component extends DCLogic`"; 1712 } else { 1713 r.logicError = null; 1714 r.Logic = Cls; 1715 } 1716 } catch (e) { 1717 if (r.jsSeq !== seq) return; 1718 console.error( 1719 "[dc-runtime] logic class eval FAILED for", 1720 name, 1721 "\u2014 the template renders with props only.", 1722 e 1723 ); 1724 r.logicError = name + ": " + (e instanceof Error && e.message ? e.message : String(e)); 1725 } 1726 registry.bump(name); 1727 } 1728 function setStreaming(name, kind, on) { 1729 const r = registry.get(name); 1730 if (kind === "html") r.htmlStreaming = !!on; 1731 else r.jsStreaming = !!on; 1732 let any = false; 1733 for (const n in registry.entries) { 1734 const e = registry.entries[n]; 1735 if (e && (e.htmlStreaming || e.jsStreaming)) { 1736 any = true; 1737 break; 1738 } 1739 } 1740 doc.documentElement.classList.toggle("sc-dc-streaming", any); 1741 registry.bump(name); 1742 } 1743 function dcUpdate(name, kind, content, streaming) { 1744 if (streaming) registry.get(name).fetched = true; 1745 if (kind === "html") { 1746 setStreaming(name, "html", !!streaming); 1747 updateHtml(name, content); 1748 }
1748 else if (kind === "js") { 1749 setStreaming(name, "js", !!streaming); 1750 if (!streaming) updateJs(name, content); 1751 } else if (kind === "props") { 1752 const { props, preview } = parseDataProps(content); 1753 const r = registry.get(name); 1754 r.propsMeta = props ?? void 0; 1755 r.preview = preview; 1756 registry.bump(name); 1757 } 1758 } 1759 function setProps(name, overrides) { 1760 registry.get(name).propOverrides = overrides && typeof overrides === "object" ? { ...overrides } : null; 1761 registry.bump(name); 1762 } 1763 function adoptParsed(name, parsed) { 1764 if (!parsed) return; 1765 const r = registry.get(name); 1766 if (parsed.props) r.propsMeta = parsed.props; 1767 if (parsed.preview) r.preview = parsed.preview; 1768 if (parsed.template) updateHtml(name, parsed.template); 1769 if (parsed.js) updateJs(name, parsed.js); 1770 } 1771 return { 1772 registry, 1773 getDC: factory.getDC, 1774 updateHtml, 1775 updateJs, 1776 dcUpdate, 1777 setProps, 1778 adoptParsed, 1779 setRootName: (name) => { 1780 rootName = name; 1781 }, 1782 markFetched: (name) => { 1783 registry.get(name).fetched = true; 1784 }, 1785 annotatedTemplate: (name) => { 1786 const r = registry.get(name); 1787 return r.tpl && r.tpl.__annotated || null; 1788 }, 1789 templateSource: (name) => registry.get(name).html || null, 1790 StreamableLogic 1791 }; 1792 } 1793 1794
1794// src/stream-state.ts 1795 function createStreamTracker(staleMs = 6e4, now = Date.now) { 1796 const since = /* @__PURE__ */ new Map(); 1797 const liveOne = (n) => { 1798 const t = since.get(n); 1799 if (t === void 0) return false; 1800 if (now() - t > staleMs) { 1801 since.delete(n); 1802 return false; 1803 } 1804 return true; 1805 }; 1806 return { 1807 push(name, streaming, viewportKey) { 1808 if (viewportKey === "dc-model") return; 1809 if (streaming) since.set(name, now()); 1810 else since.delete(name); 1811 }, 1812 live(name) { 1813 if (name !== void 0) return liveOne(name); 1814 for (const n of [...since.keys()]) if (liveOne(n)) return true; 1815 return false; 1816 } 1817 }; 1818 } 1819 1820
1820// src/index.ts 1821 function hideRawTemplate() { 1822 const s = document.createElement("style"); 1823 s.textContent = "x-dc{display:none!important}"; 1824 document.head.appendChild(s); 1825 } 1826 function loadScript(src, integrity) { 1827 return new Promise((resolve2, reject) => { 1828 //! nosemgrep: create-script-element 1829 const s = document.createElement("script"); 1830 s.src = src; 1831 if (integrity) { 1832 s.integrity = integrity; 1833 s.crossOrigin = "anonymous"; 1834 } 1835 s.async = false; 1836 s.onload = () => resolve2(); 1837 s.onerror = () => reject(new Error(`failed to load ${src}`)); 1838 document.head.appendChild(s); 1839 }); 1840 } 1841 function loadReactUmd() { 1842 const w = window; 1843 if (w.React && w.ReactDOM) return Promise.resolve(); 1844 const react = cdnScriptFor(REACT_URL, REACT_SRI); 1845 const reactDom = cdnScriptFor(REACT_DOM_URL, REACT_DOM_SRI); 1846 return Promise.all([ 1847 loadScript(react.src, react.integrity), 1848 loadScript(reactDom.src, reactDom.integrity) 1849 ]).then(() => void 0); 1850 } 1851 function init() { 1852 const runtime = createRuntime(document); 1853 let rootName = "Root"; 1854 const baseCss = document.createElement("style"); 1855 baseCss.textContent = BASE_CSS; 1856 document.head.prepend(baseCss); 1857 const notifyHost = () => { 1858 if (window.parent === window) return; 1859 const r = runtime.registry.entries[rootName]; 1860 try { 1861 window.parent.postMessage( 1862 { 1863 type: "__dc_booted", 1864 rootName, 1865 propsMeta: r && r.propsMeta || null, 1866 preview: r && r.preview || null 1867 }, 1868 "*" 1869 ); 1870 } catch { 1871 } 1872 }; 1873 const streams = createStreamTracker(); 1874 const api = { 1875 __dcUpdate: (name, kind, content, streaming, viewportKey) => { 1876 streams.push(name, streaming, viewportKey); 1877 runtime.dcUpdate(name, kind, content, streaming); 1878 if (name === rootName && !streaming && kind === "props") notifyHost(); 1879 }, 1880 __dcStreaming: (name) => streams.live(name), 1881 __dcSetProps: (name, overrides) => runtime.setProps(name, overrides), 1882 /** Name of the component currently mounted as the page root â DC tools 1883 * push their template-stream here when targeting "the open page". */ 1884 __dcRootName: () => rootName, 1885 /** Editor bridge â the encoded, `data-dc-tpl`-annotated template source. 1886 * The host editor parses this into its own template DOM so it can map a 1887 * rendered node (carrying the same `data-dc-tpl`) back to the source 1888 * node that emitted it. Returns the encoded form (`sc-camel-*` attrs, 1889 * `<sc-raw-*>`/`<sc-helmet>` tags); the editor decodes on serialize. */ 1890 __dcAnnotatedTemplate: (name) => runtime.annotatedTemplate(name), 1891 /** Editor bridge â the *original* (decoded) template source. */ 1892 __dcTemplateSource: (name) => runtime.templateSource(name), 1893 __dcBoot: () => { 1894 rootName = boot(runtime, document) ?? rootName; 1895 notifyHost(); 1896 }, 1897 __dcRegistry: runtime.registry.entries, 1898 getDC: (name) => runtime.getDC(name), 1899 // `DCLogic` is the documented base class name; `StreamableLogic` is the 1900 // implementation alias kept for any project that already references it. 1901 DCLogic: runtime.StreamableLogic, 1902 StreamableLogic: runtime.StreamableLogic 1903 }; 1904 Object.assign(window, api); 1905 window.__dcContentKeyed = true; 1906 if (document.readyState !== "loading") api.__dcBoot(); 1907 else document.addEventListener("DOMContentLoaded", () => api.__dcBoot()); 1908 } 1909 hideRawTemplate(); 1910 loadReactUmd().then(init).catch((err) => { 1911 console.error("[dc] failed to load React or boot:", err); 1912 throw err; 1913 }); 1914})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.