sibujs 4.7.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/browser.cjs +45 -4
  2. package/dist/browser.d.cts +23 -0
  3. package/dist/browser.d.ts +23 -0
  4. package/dist/browser.js +6 -5
  5. package/dist/build.cjs +513 -78
  6. package/dist/build.d.cts +22 -8
  7. package/dist/build.d.ts +22 -8
  8. package/dist/build.js +68 -21
  9. package/dist/cdn.dev.global.js +15 -13
  10. package/dist/cdn.full.dev.global.js +15 -13
  11. package/dist/cdn.full.global.js +14 -12
  12. package/dist/cdn.global.js +14 -12
  13. package/dist/chunk-3ACAAQIN.js +224 -0
  14. package/dist/{chunk-DKXRACVN.js → chunk-44MTL7ED.js} +6 -6
  15. package/dist/{chunk-3QWBSL5R.js → chunk-4WMSTZ7J.js} +8 -5
  16. package/dist/{chunk-H3SRKIYX.js → chunk-62BDYGAG.js} +8 -0
  17. package/dist/{chunk-BSY63EM6.js → chunk-C5PEWEGH.js} +20 -5
  18. package/dist/{chunk-BC2SECJD.js → chunk-C7AA2CZX.js} +1 -1
  19. package/dist/{chunk-SLM3IA34.js → chunk-CZPRSWSS.js} +1 -1
  20. package/dist/{chunk-FQRUXCEE.js → chunk-DSID757X.js} +1 -1
  21. package/dist/{chunk-ZVL7TY4K.js → chunk-EGUQLBHE.js} +22 -8
  22. package/dist/{chunk-2INLLLMZ.js → chunk-EXXSN3BW.js} +202 -26
  23. package/dist/{chunk-HURREPU2.js → chunk-FC6KCJSA.js} +87 -150
  24. package/dist/{chunk-Z3OHK6QT.js → chunk-GSGNX35Q.js} +5 -5
  25. package/dist/{chunk-XYV3EDB7.js → chunk-J3YQ457H.js} +37 -20
  26. package/dist/{chunk-VZSG24LS.js → chunk-JUTFX2RM.js} +18 -10
  27. package/dist/{chunk-RUSSKG6G.js → chunk-KJ3UKABJ.js} +1 -1
  28. package/dist/{chunk-UNWRJRKC.js → chunk-LI4W3U6C.js} +1 -1
  29. package/dist/{chunk-FNJXNGYZ.js → chunk-O6TRVMJI.js} +58 -6
  30. package/dist/{chunk-7LUJQAOJ.js → chunk-Q5J2LVKH.js} +1 -1
  31. package/dist/{chunk-4AWA2PVD.js → chunk-QGMSESDD.js} +10 -5
  32. package/dist/{chunk-XZR4PXRE.js → chunk-RGLPEBDE.js} +13 -10
  33. package/dist/{chunk-JWKYU5GV.js → chunk-TQQUN4WR.js} +1 -1
  34. package/dist/{chunk-WOLJZUFQ.js → chunk-UCNP3HVM.js} +12 -8
  35. package/dist/{chunk-WEQ3DMVL.js → chunk-V3LHZSU5.js} +1 -1
  36. package/dist/{chunk-UOL2ECCS.js → chunk-VWT3VXPL.js} +18 -12
  37. package/dist/{chunk-2BPG2XDA.js → chunk-ZVLHNEEL.js} +17 -35
  38. package/dist/{customElement-MmInOW1U.d.ts → customElement-pYDKUzWl.d.cts} +11 -3
  39. package/dist/{customElement-MmInOW1U.d.cts → customElement-pYDKUzWl.d.ts} +11 -3
  40. package/dist/data.cjs +9 -2
  41. package/dist/data.js +6 -6
  42. package/dist/devtools.cjs +1 -1
  43. package/dist/devtools.js +5 -5
  44. package/dist/ecosystem.cjs +400 -37
  45. package/dist/ecosystem.js +9 -8
  46. package/dist/extras.cjs +621 -252
  47. package/dist/extras.d.cts +2 -2
  48. package/dist/extras.d.ts +2 -2
  49. package/dist/extras.js +24 -23
  50. package/dist/index.cjs +464 -70
  51. package/dist/index.d.cts +28 -2
  52. package/dist/index.d.ts +28 -2
  53. package/dist/index.js +16 -12
  54. package/dist/motion.cjs +1 -1
  55. package/dist/motion.js +3 -3
  56. package/dist/patterns.cjs +10 -7
  57. package/dist/patterns.js +6 -6
  58. package/dist/performance.cjs +31 -2
  59. package/dist/performance.d.cts +12 -2
  60. package/dist/performance.d.ts +12 -2
  61. package/dist/performance.js +8 -6
  62. package/dist/plugins.cjs +558 -231
  63. package/dist/plugins.d.cts +8 -3
  64. package/dist/plugins.d.ts +8 -3
  65. package/dist/plugins.js +22 -28
  66. package/dist/{ssr-XOTUASDO.js → ssr-5OWAH3U2.js} +4 -2
  67. package/dist/{ssr-Bli9XRW5.d.ts → ssr-C8hgIAw7.d.cts} +6 -0
  68. package/dist/{ssr-Bli9XRW5.d.cts → ssr-C8hgIAw7.d.ts} +6 -0
  69. package/dist/ssr.cjs +457 -131
  70. package/dist/ssr.d.cts +55 -5
  71. package/dist/ssr.d.ts +55 -5
  72. package/dist/ssr.js +11 -9
  73. package/dist/testing.cjs +3 -3
  74. package/dist/testing.js +4 -4
  75. package/dist/ui.cjs +608 -240
  76. package/dist/ui.d.cts +1 -1
  77. package/dist/ui.d.ts +1 -1
  78. package/dist/ui.js +9 -8
  79. package/dist/widgets.cjs +1 -1
  80. package/dist/widgets.js +7 -7
  81. package/package.json +5 -4
package/dist/ssr.cjs CHANGED
@@ -313,8 +313,10 @@ function isSSR() {
313
313
  function stripControlChars(value) {
314
314
  return value.replace(/[\x00-\x20\x7f-\x9f]+/g, "");
315
315
  }
316
+ var ASCII_UPPER = /[A-Z]/;
317
+ var ASCII_UPPER_G = /[A-Z]/g;
316
318
  function canonicalAttrName(name) {
317
- return name.replace(/[A-Z]/g, (ch) => String.fromCharCode(ch.charCodeAt(0) + 32));
319
+ return ASCII_UPPER.test(name) ? name.replace(ASCII_UPPER_G, (ch) => String.fromCharCode(ch.charCodeAt(0) + 32)) : name;
318
320
  }
319
321
  function isEventHandlerAttr(name) {
320
322
  if (name.length < 3) return false;
@@ -327,6 +329,9 @@ function sanitizeUrl(url) {
327
329
  const probe = stripControlChars(url).trim();
328
330
  if (!probe) return "";
329
331
  const output2 = url.replace(OUTER_TRIM, "");
332
+ if (probe.length >= 2 && (probe[0] === "\\" || probe[0] === "/") && (probe[1] === "\\" || probe[1] === "/") && (probe[0] === "\\" || probe[1] === "\\")) {
333
+ return "";
334
+ }
330
335
  const lower = probe.toLowerCase();
331
336
  let schemeEnd = -1;
332
337
  for (let i2 = 0; i2 < lower.length; i2++) {
@@ -343,19 +348,58 @@ function sanitizeUrl(url) {
343
348
  if (SAFE_URL_PROTOCOLS.indexOf(scheme) === -1) return "";
344
349
  return output2;
345
350
  }
346
- var SRCSET_DESCRIPTOR = /^\s+\d+(\.\d+)?[wx]$/;
351
+ var SRCSET_DESCRIPTOR = /^\d+(\.\d+)?[wx]$/;
352
+ function isSrcsetWhitespace(ch) {
353
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f";
354
+ }
347
355
  function sanitizeSrcset(value) {
348
- const parts = value.split(",");
356
+ const input2 = String(value);
349
357
  const out = [];
350
- for (let i2 = 0; i2 < parts.length; i2++) {
351
- const part = parts[i2].trim();
352
- if (!part) continue;
353
- const m = part.match(/^(\S+)(\s+.+)?$/);
354
- if (!m) continue;
355
- if (m[2] !== void 0 && !SRCSET_DESCRIPTOR.test(m[2])) continue;
356
- const safe = sanitizeUrl(m[1]);
358
+ let i2 = 0;
359
+ const n = input2.length;
360
+ while (i2 < n) {
361
+ while (i2 < n && (isSrcsetWhitespace(input2[i2]) || input2[i2] === ",")) i2++;
362
+ if (i2 >= n) break;
363
+ const urlStart = i2;
364
+ while (i2 < n && !isSrcsetWhitespace(input2[i2])) i2++;
365
+ let url = input2.slice(urlStart, i2);
366
+ const descriptors = [];
367
+ if (url.endsWith(",")) {
368
+ url = url.replace(/,+$/, "");
369
+ } else {
370
+ let current = "";
371
+ let inParens = false;
372
+ while (i2 < n) {
373
+ const ch = input2[i2];
374
+ if (inParens) {
375
+ current += ch;
376
+ if (ch === ")") inParens = false;
377
+ i2++;
378
+ continue;
379
+ }
380
+ if (isSrcsetWhitespace(ch)) {
381
+ if (current) descriptors.push(current);
382
+ current = "";
383
+ i2++;
384
+ continue;
385
+ }
386
+ if (ch === ",") {
387
+ i2++;
388
+ break;
389
+ }
390
+ if (ch === "(") inParens = true;
391
+ current += ch;
392
+ i2++;
393
+ }
394
+ if (current) descriptors.push(current);
395
+ }
396
+ if (url === "") continue;
397
+ if (descriptors.length > 1) continue;
398
+ if (descriptors.length === 1 && !SRCSET_DESCRIPTOR.test(descriptors[0])) continue;
399
+ const safe = sanitizeUrl(url);
357
400
  if (!safe) continue;
358
- out.push(m[2] ? `${safe}${m[2]}` : safe);
401
+ if (safe.startsWith(",") || safe.endsWith(",")) continue;
402
+ out.push(descriptors.length === 1 ? `${safe} ${descriptors[0]}` : safe);
359
403
  }
360
404
  return out.join(", ");
361
405
  }
@@ -414,8 +458,16 @@ var BLOCKED_CSS_NEEDLES = [
414
458
  "behavior:",
415
459
  "@import",
416
460
  "image-set(",
417
- "filter:progid"
461
+ "filter:progid",
462
+ // CSS Images 4 `image("…")` and CSS Values 5 `src("…")` take a URL as a
463
+ // plain STRING, so they fetch without ever spelling `url(`. Support is thin
464
+ // today, which is exactly when a blocklist should get ahead of it.
465
+ "image(",
466
+ "src("
418
467
  ];
468
+ var CSS_REASON_MOZ_BINDING = 4;
469
+ var CSS_REASON_BEHAVIOR = 5;
470
+ var CSS_REASON_PROGID = 8;
419
471
  function describeElement(el) {
420
472
  if (!el) return "an element";
421
473
  let out = el.tagName.toLowerCase();
@@ -439,7 +491,9 @@ function warnDroppedDeclaration(value, reason, ctx) {
439
491
  "behavior: loads and runs a remote HTC script",
440
492
  "@import pulls in a remote stylesheet",
441
493
  "image-set() fetches remote images, the same exfiltration channel as url()",
442
- "filter:progid activates legacy scriptable filters"
494
+ "filter:progid activates legacy scriptable filters",
495
+ "image() fetches its string argument as a URL, the same exfiltration channel as url()",
496
+ "src() fetches its string argument as a URL, the same exfiltration channel as url()"
443
497
  ];
444
498
  const declaration = ctx?.property ? `${ctx.property}: ${value}` : value;
445
499
  const where = describeElement(ctx?.element);
@@ -454,27 +508,110 @@ function warnDroppedDeclaration(value, reason, ctx) {
454
508
  return `style declaration "${declaration}" was dropped by the style sanitizer on ${where} \u2014 ${reasons[reason]}. The element renders without it, which usually looks like a missing image rather than an error. Sanctioned alternatives: for a content image use an <img> element (or a <picture>); for decoration, put the rule in a stylesheet and set a class instead \u2014 stylesheet CSS is not sanitized, only inline style attributes are. If this declaration is not yours, it came from untrusted data and the drop just prevented an exfiltration.`;
455
509
  });
456
510
  }
511
+ function normalizeCssForScan(value) {
512
+ const normalized = value.includes("\\") ? decodeCssEscapes(value) : value;
513
+ return normalized.toLowerCase().replace(/\s+/g, "");
514
+ }
457
515
  function blockedCssReason(value) {
458
516
  if (!CSS_DANGER_GATE.test(value)) return -1;
459
- const normalized = value.includes("\\") ? decodeCssEscapes(value) : value;
460
- const lower = normalized.toLowerCase().replace(/\s+/g, "");
517
+ const lower = normalizeCssForScan(value);
461
518
  for (let i2 = 0; i2 < BLOCKED_CSS_NEEDLES.length; i2++) {
462
519
  if (lower.includes(BLOCKED_CSS_NEEDLES[i2])) return i2;
463
520
  }
464
521
  return -1;
465
522
  }
466
- function sanitizeCSSValue(value, context) {
467
- const reason = blockedCssReason(value);
523
+ function sanitizeCSSDeclaration(property, value, context) {
524
+ const reason = blockedDeclarationReason(property, value);
468
525
  if (reason === -1) return value;
469
- warnDroppedDeclaration(value, reason, context);
526
+ warnDroppedDeclaration(value, reason, { property, element: context?.element });
470
527
  return "";
471
528
  }
529
+ function blockedDeclarationReason(property, value) {
530
+ const reason = blockedCssReason(value);
531
+ if (reason !== -1) return reason;
532
+ const name = canonicalAttrName(property);
533
+ if (name === "behavior") return CSS_REASON_BEHAVIOR;
534
+ if (name === "-moz-binding") return CSS_REASON_MOZ_BINDING;
535
+ if ((name === "filter" || name === "-ms-filter") && normalizeCssForScan(value).includes("progid:")) {
536
+ return CSS_REASON_PROGID;
537
+ }
538
+ return -1;
539
+ }
540
+ function parseStyleDeclarations(css) {
541
+ const chunks = [];
542
+ let buf = "";
543
+ let depth = 0;
544
+ let quote2 = "";
545
+ for (let i2 = 0; i2 < css.length; i2++) {
546
+ const ch = css[i2];
547
+ if (quote2) {
548
+ buf += ch;
549
+ if (ch === "\\" && i2 + 1 < css.length) buf += css[++i2];
550
+ else if (ch === quote2) quote2 = "";
551
+ continue;
552
+ }
553
+ if (ch === "\\") {
554
+ buf += ch;
555
+ if (i2 + 1 < css.length) buf += css[++i2];
556
+ continue;
557
+ }
558
+ if (ch === "/" && css[i2 + 1] === "*") {
559
+ const end = css.indexOf("*/", i2 + 2);
560
+ if (end === -1) return null;
561
+ i2 = end + 1;
562
+ continue;
563
+ }
564
+ if (ch === '"' || ch === "'") quote2 = ch;
565
+ else if (ch === "(" || ch === "[") depth++;
566
+ else if (ch === ")" || ch === "]") {
567
+ if (--depth < 0) return null;
568
+ } else if (ch === "{" || ch === "}") return null;
569
+ else if (ch === ";" && depth === 0) {
570
+ chunks.push(buf);
571
+ buf = "";
572
+ continue;
573
+ }
574
+ buf += ch;
575
+ }
576
+ if (quote2 || depth !== 0) return null;
577
+ chunks.push(buf);
578
+ const out = [];
579
+ for (const chunk of chunks) {
580
+ const colon = chunk.indexOf(":");
581
+ if (colon === -1) continue;
582
+ const rawName = chunk.slice(0, colon).trim();
583
+ if (!/^(--[\w-]+|-?[a-zA-Z_][\w-]*)$/.test(rawName)) continue;
584
+ let value = chunk.slice(colon + 1).trim();
585
+ const bang = /!\s*important\s*$/i.exec(value);
586
+ if (bang) value = value.slice(0, bang.index).trim();
587
+ if (value === "") continue;
588
+ const property = rawName.startsWith("--") ? rawName : canonicalAttrName(rawName);
589
+ out.push([property, value, bang !== null]);
590
+ }
591
+ return out;
592
+ }
593
+ function sanitizeStyleDeclarationList(cssText, context) {
594
+ const input2 = String(cssText);
595
+ const declarations = parseStyleDeclarations(input2);
596
+ if (declarations === null) {
597
+ if (blockedCssReason(input2) !== -1) warnDroppedDeclaration(input2, blockedCssReason(input2), context);
598
+ return "";
599
+ }
600
+ const kept = [];
601
+ for (const [property, value, important] of declarations) {
602
+ const reason = blockedDeclarationReason(property, value);
603
+ if (reason !== -1) {
604
+ warnDroppedDeclaration(value, reason, { property, element: context?.element });
605
+ continue;
606
+ }
607
+ kept.push(`${property}: ${value}${important ? " !important" : ""}`);
608
+ }
609
+ return kept.join("; ");
610
+ }
472
611
  function sanitizeStyleAttribute(cssText, context) {
473
612
  const input2 = String(cssText);
474
613
  if (input2.trim() === "") return "";
475
- if (typeof document === "undefined") {
476
- return sanitizeCSSValue(input2, context) === "" ? "" : input2;
477
- }
614
+ if (typeof document === "undefined") return sanitizeStyleDeclarationList(input2, context);
478
615
  const probe = document.createElement("div");
479
616
  try {
480
617
  probe.style.cssText = input2;
@@ -485,8 +622,7 @@ function sanitizeStyleAttribute(cssText, context) {
485
622
  for (let i2 = 0; i2 < probe.style.length; i2++) {
486
623
  const property = probe.style[i2];
487
624
  const value = probe.style.getPropertyValue(property);
488
- let reason = blockedCssReason(value);
489
- if (reason === -1) reason = blockedCssReason(`${property}:${value}`);
625
+ const reason = blockedDeclarationReason(property, value);
490
626
  if (reason !== -1) {
491
627
  warnDroppedDeclaration(value, reason, { property, element: context?.element });
492
628
  continue;
@@ -518,6 +654,9 @@ var HTML_CONTENT_ATTRIBUTES = /* @__PURE__ */ new Set(["srcdoc"]);
518
654
  function isHtmlContentAttribute(name) {
519
655
  return HTML_CONTENT_ATTRIBUTES.has(name.toLowerCase());
520
656
  }
657
+ function isUrlAttribute(attr) {
658
+ return URL_ATTRIBUTES.has(attr.toLowerCase());
659
+ }
521
660
  function isPolicyAttribute(name) {
522
661
  const lower = name.toLowerCase();
523
662
  return lower === "style" || URL_ATTRIBUTES.has(lower);
@@ -529,6 +668,11 @@ function sanitizeAttributeString(attr, value, context) {
529
668
  if (lower === "style") return sanitizeStyleAttribute(value, context);
530
669
  return value;
531
670
  }
671
+ function resolveAttributeValue(attr, value, context) {
672
+ if (!isPolicyAttribute(attr)) return value;
673
+ const safe = sanitizeAttributeString(attr, value, context);
674
+ return safe === "" ? null : safe;
675
+ }
532
676
 
533
677
  // src/utils/metaRefresh.ts
534
678
  function isAsciiWhitespace(ch) {
@@ -544,40 +688,40 @@ function trimAsciiWhitespace(value) {
544
688
  var forbidden = (reason) => ({ kind: "forbidden", reason });
545
689
  function parseMetaRefreshContent(content) {
546
690
  const raw = trimAsciiWhitespace(stripControlChars(content));
547
- if (raw === "") return forbidden("empty content");
691
+ if (raw === "") return forbidden(DEV ? "empty content" : "");
548
692
  let i2 = 0;
549
693
  while (i2 < raw.length && raw[i2] >= "0" && raw[i2] <= "9") i2++;
550
- if (i2 === 0) return forbidden("missing or non-numeric delay");
694
+ if (i2 === 0) return forbidden(DEV ? "missing or non-numeric delay" : "");
551
695
  const delay = Number.parseInt(raw.slice(0, i2), 10);
552
- if (!Number.isFinite(delay)) return forbidden("unparseable delay");
696
+ if (!Number.isFinite(delay)) return forbidden(DEV ? "unparseable delay" : "");
553
697
  while (i2 < raw.length && isAsciiWhitespace(raw[i2])) i2++;
554
698
  if (i2 === raw.length) return { kind: "delay-only", delay };
555
- if (raw[i2] !== ";" && raw[i2] !== ",") return forbidden("unexpected text after delay");
699
+ if (raw[i2] !== ";" && raw[i2] !== ",") return forbidden(DEV ? "unexpected text after delay" : "");
556
700
  i2++;
557
701
  while (i2 < raw.length && isAsciiWhitespace(raw[i2])) i2++;
558
702
  const keyStart = i2;
559
703
  while (i2 < raw.length && !isAsciiWhitespace(raw[i2]) && raw[i2] !== "=") i2++;
560
704
  const key = raw.slice(keyStart, i2).toLowerCase();
561
- if (key !== "url") return forbidden(`unsupported refresh key ${JSON.stringify(key)}`);
705
+ if (key !== "url") return forbidden(DEV ? `unsupported refresh key ${JSON.stringify(key)}` : "");
562
706
  while (i2 < raw.length && isAsciiWhitespace(raw[i2])) i2++;
563
- if (raw[i2] !== "=") return forbidden("missing '=' after url");
707
+ if (raw[i2] !== "=") return forbidden(DEV ? "missing '=' after url" : "");
564
708
  i2++;
565
709
  while (i2 < raw.length && isAsciiWhitespace(raw[i2])) i2++;
566
710
  let destination;
567
711
  const quote2 = raw[i2];
568
712
  if (quote2 === '"' || quote2 === "'") {
569
713
  const close = raw.indexOf(quote2, i2 + 1);
570
- if (close === -1) return forbidden("unterminated quoted destination");
714
+ if (close === -1) return forbidden(DEV ? "unterminated quoted destination" : "");
571
715
  destination = raw.slice(i2 + 1, close);
572
716
  const rest = trimAsciiWhitespace(raw.slice(close + 1));
573
- if (rest !== "") return forbidden("trailing text after quoted destination");
717
+ if (rest !== "") return forbidden(DEV ? "trailing text after quoted destination" : "");
574
718
  } else {
575
719
  destination = trimAsciiWhitespace(raw.slice(i2));
576
- if (/[;,]/.test(destination)) return forbidden("multiple refresh assignments");
720
+ if (/[;,]/.test(destination)) return forbidden(DEV ? "multiple refresh assignments" : "");
577
721
  }
578
- if (destination === "") return forbidden("empty destination");
722
+ if (destination === "") return forbidden(DEV ? "empty destination" : "");
579
723
  const sanitizedDestination = sanitizeUrl(destination);
580
- if (sanitizedDestination === "") return forbidden("destination uses a disallowed protocol");
724
+ if (sanitizedDestination === "") return forbidden(DEV ? "destination uses a disallowed protocol" : "");
581
725
  return { kind: "allowed", delay, destination, sanitizedDestination };
582
726
  }
583
727
  function resolveMetaRefreshPolicy(attributes) {
@@ -593,7 +737,7 @@ function resolveMetaRefreshPolicy(attributes) {
593
737
  else if (canonical === "content") content = value;
594
738
  }
595
739
  if (duplicateName !== void 0) {
596
- return forbidden(`duplicate case-insensitive attribute ${JSON.stringify(duplicateName)}`);
740
+ return forbidden(DEV ? `duplicate case-insensitive attribute ${JSON.stringify(duplicateName)}` : "");
597
741
  }
598
742
  if (typeof httpEquiv !== "string") return { kind: "not-refresh" };
599
743
  if (trimAsciiWhitespace(stripControlChars(httpEquiv)).toLowerCase() !== "refresh") {
@@ -619,6 +763,128 @@ function isForbiddenMetaEntry(props) {
619
763
  return resolveMetaRefreshPolicy(normalized).kind === "forbidden";
620
764
  }
621
765
 
766
+ // src/utils/elementPolicy.ts
767
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
768
+ var SVG_NS = "http://www.w3.org/2000/svg";
769
+ var BLOCKED_ELEMENTS = /* @__PURE__ */ new Set(["script", "iframe", "object", "embed", "frame", "frameset"]);
770
+ function canonicalTagName(tag) {
771
+ return canonicalAttrName(tag);
772
+ }
773
+ function isBlockedElement(tag) {
774
+ return BLOCKED_ELEMENTS.has(canonicalTagName(tag));
775
+ }
776
+ var CODE_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["script", "style"]);
777
+ function isCodeTextElement(tag) {
778
+ return CODE_TEXT_ELEMENTS.has(canonicalTagName(tag));
779
+ }
780
+ var ContextualRefusal = {
781
+ None: 0,
782
+ /** The element would carry a refresh directive the shared policy forbids. */
783
+ MetaRefreshForbidden: 1,
784
+ /** A `<meta>` with a reactive binding may not carry any refresh directive. */
785
+ MetaRefreshReactive: 2,
786
+ /** A runtime value may not choose which program a `<script>` runs. */
787
+ ScriptSource: 3,
788
+ /** An SVG animation may not target a URL, handler or document attribute. */
789
+ AnimationTarget: 4,
790
+ /** A runtime-written `href` may not become an applied stylesheet. */
791
+ StylesheetSource: 5
792
+ };
793
+ var SCRIPT_SOURCE_ATTRIBUTES = /* @__PURE__ */ new Set(["src", "href", "xlink:href", "type", "language"]);
794
+ var SVG_ANIMATION_ELEMENTS = /* @__PURE__ */ new Set(["animate", "set", "animateMotion", "animateTransform", "animateColor"]);
795
+ var reactiveMetaElements = /* @__PURE__ */ new WeakSet();
796
+ function isHtmlNamespace(el) {
797
+ return el.namespaceURI === HTML_NS || el.namespaceURI === null;
798
+ }
799
+ function metaSnapshot(el, canonical, value) {
800
+ const snapshot = /* @__PURE__ */ new Map();
801
+ const attrs = el.attributes;
802
+ for (let i2 = 0; i2 < attrs.length; i2++) {
803
+ const attr = attrs[i2];
804
+ if (attr.name === canonical) continue;
805
+ snapshot.set(attr.name, attr.value);
806
+ }
807
+ if (canonical !== null && value !== null) snapshot.set(canonical, value);
808
+ return snapshot;
809
+ }
810
+ function claimReactiveMeta(el) {
811
+ if (reactiveMetaElements.has(el)) return;
812
+ reactiveMetaElements.add(el);
813
+ if (el.getAttribute("content") === null) return;
814
+ if (resolveMetaRefreshPolicy(metaSnapshot(el, null, null)).kind !== "not-refresh") {
815
+ el.removeAttribute("content");
816
+ }
817
+ }
818
+ function metaRefusal(el, name, value, origin) {
819
+ if (!isHtmlNamespace(el)) return ContextualRefusal.None;
820
+ const canonical = canonicalAttrName(name);
821
+ if (canonical !== "http-equiv" && canonical !== "content") return ContextualRefusal.None;
822
+ if (origin === "reactive") claimReactiveMeta(el);
823
+ if (value === null) return ContextualRefusal.None;
824
+ if (canonical === "content" && !el.hasAttribute("http-equiv")) return ContextualRefusal.None;
825
+ const decision = resolveMetaRefreshPolicy(metaSnapshot(el, canonical, value));
826
+ if (decision.kind === "forbidden") return ContextualRefusal.MetaRefreshForbidden;
827
+ if (decision.kind !== "not-refresh" && reactiveMetaElements.has(el)) return ContextualRefusal.MetaRefreshReactive;
828
+ return ContextualRefusal.None;
829
+ }
830
+ function animationRefusal(name, value) {
831
+ if (value === null || canonicalAttrName(name) !== "attributename") return ContextualRefusal.None;
832
+ const target = stripControlChars(value);
833
+ return isUrlAttribute(target) || isEventHandlerAttr(target) || isHtmlContentAttribute(target) ? ContextualRefusal.AnimationTarget : ContextualRefusal.None;
834
+ }
835
+ var runtimeHrefLinks = /* @__PURE__ */ new WeakSet();
836
+ function relHasStylesheet(rel) {
837
+ if (rel === null) return false;
838
+ const lower = canonicalAttrName(rel);
839
+ if (!lower.includes("stylesheet")) return false;
840
+ const tokens = lower.split(/[\t\n\f\r ]+/);
841
+ for (let i2 = 0; i2 < tokens.length; i2++) if (tokens[i2] === "stylesheet") return true;
842
+ return false;
843
+ }
844
+ function stylesheetRefusal(el, name, value, origin) {
845
+ if (!isHtmlNamespace(el)) return ContextualRefusal.None;
846
+ const canonical = canonicalAttrName(name);
847
+ if (canonical === "href") {
848
+ if (origin === "static" || value === null) return ContextualRefusal.None;
849
+ if (relHasStylesheet(el.getAttribute("rel"))) return ContextualRefusal.StylesheetSource;
850
+ runtimeHrefLinks.add(el);
851
+ return ContextualRefusal.None;
852
+ }
853
+ if (canonical === "rel") {
854
+ if (!relHasStylesheet(value)) return ContextualRefusal.None;
855
+ return runtimeHrefLinks.has(el) && el.hasAttribute("href") ? ContextualRefusal.StylesheetSource : ContextualRefusal.None;
856
+ }
857
+ return ContextualRefusal.None;
858
+ }
859
+ function contextualAttributeRefusal(el, name, value, origin) {
860
+ const local = el.localName;
861
+ if (local === "meta") return metaRefusal(el, name, value, origin);
862
+ if (local === "link") return stylesheetRefusal(el, name, value, origin);
863
+ if (local === "script") {
864
+ if (origin === "static" || value === null) return ContextualRefusal.None;
865
+ return SCRIPT_SOURCE_ATTRIBUTES.has(canonicalAttrName(name)) ? ContextualRefusal.ScriptSource : ContextualRefusal.None;
866
+ }
867
+ if (SVG_ANIMATION_ELEMENTS.has(local) && el.namespaceURI === SVG_NS) return animationRefusal(name, value);
868
+ return ContextualRefusal.None;
869
+ }
870
+ function settleAttributeProvenance(el, name, origin) {
871
+ if (el.localName !== "link" || canonicalAttrName(name) !== "href") return;
872
+ if (origin !== "static" && el.hasAttribute("href")) runtimeHrefLinks.add(el);
873
+ else runtimeHrefLinks.delete(el);
874
+ }
875
+ function isForbiddenMetaSnapshot(attributes) {
876
+ return resolveMetaRefreshPolicy(attributes).kind === "forbidden";
877
+ }
878
+
879
+ // src/utils/guards.ts
880
+ function readOwnGlobal(key) {
881
+ if (typeof window === "undefined") return void 0;
882
+ if (!Object.hasOwn(window, key)) return void 0;
883
+ const value = window[key];
884
+ if (typeof Node !== "undefined" && value instanceof Node) return void 0;
885
+ return value;
886
+ }
887
+
622
888
  // src/utils/headEntry.ts
623
889
  var SAFE_HEAD_ATTR_NAME = /^[A-Za-z_:][-A-Za-z0-9_.:]*$/;
624
890
  function isEmittableHeadAttrName(name) {
@@ -629,9 +895,7 @@ function isEmittableHeadAttrName(name) {
629
895
  return true;
630
896
  }
631
897
  function sanitizeHeadAttrValue(canonical, value) {
632
- if (!isPolicyAttribute(canonical)) return value;
633
- const safe = sanitizeAttributeString(canonical, value);
634
- return safe === "" ? null : safe;
898
+ return resolveAttributeValue(canonical, value);
635
899
  }
636
900
  function findDuplicateAttributeName(names) {
637
901
  const seen = /* @__PURE__ */ new Set();
@@ -688,15 +952,9 @@ function serializeHeadEntry(tag, attrs) {
688
952
  }
689
953
 
690
954
  // src/platform/ssr.ts
691
- function isPolicyAttr(lowerName) {
692
- return isPolicyAttribute(lowerName);
693
- }
694
955
  function isForbiddenSsrAttr(lowerName) {
695
956
  return isHtmlContentAttribute(lowerName);
696
957
  }
697
- function sanitizeSsrAttributeValue(lowerName, value) {
698
- return sanitizeAttributeString(lowerName, value);
699
- }
700
958
  var SAFE_ATTR_NAME = /^[A-Za-z_:][-A-Za-z0-9_.:]*$/;
701
959
  function isSafeAttrName(name) {
702
960
  return SAFE_ATTR_NAME.test(name);
@@ -727,6 +985,64 @@ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
727
985
  "track",
728
986
  "wbr"
729
987
  ]);
988
+ function findNativeGetter(proto, name) {
989
+ for (let p2 = proto; p2; p2 = Object.getPrototypeOf(p2)) {
990
+ const get = Object.getOwnPropertyDescriptor(p2, name)?.get;
991
+ if (get) return get;
992
+ }
993
+ return null;
994
+ }
995
+ var nativeAccessorsByRealm = /* @__PURE__ */ new WeakMap();
996
+ function nativeAccessors() {
997
+ const realm = Element;
998
+ let accessors = nativeAccessorsByRealm.get(realm);
999
+ if (!accessors) {
1000
+ accessors = {
1001
+ attributes: findNativeGetter(Element.prototype, "attributes"),
1002
+ tagName: findNativeGetter(Element.prototype, "tagName"),
1003
+ childNodes: findNativeGetter(Node.prototype, "childNodes"),
1004
+ getAttribute: Element.prototype.getAttribute
1005
+ };
1006
+ nativeAccessorsByRealm.set(realm, accessors);
1007
+ }
1008
+ return accessors;
1009
+ }
1010
+ function attributesOf(el) {
1011
+ const get = nativeAccessors().attributes;
1012
+ return get ? get.call(el) : el.attributes;
1013
+ }
1014
+ function tagNameOf(el) {
1015
+ const get = nativeAccessors().tagName;
1016
+ return get ? get.call(el) : el.tagName;
1017
+ }
1018
+ function childNodesOf(node) {
1019
+ const get = nativeAccessors().childNodes;
1020
+ return get ? get.call(node) : node.childNodes;
1021
+ }
1022
+ function getAttributeOf(el, name) {
1023
+ return nativeAccessors().getAttribute.call(el, name);
1024
+ }
1025
+ function serializeOpenTag(element, tag) {
1026
+ let html2 = `<${tag}`;
1027
+ const meta2 = tag === "meta" ? /* @__PURE__ */ new Map() : null;
1028
+ const attrs = attributesOf(element);
1029
+ for (let i2 = 0; i2 < attrs.length; i2++) {
1030
+ const attr = attrs[i2];
1031
+ const rawName = attr.name;
1032
+ if (!isSafeAttrName(rawName)) continue;
1033
+ if (isEventHandlerAttr(rawName)) continue;
1034
+ if (isForbiddenSsrAttr(rawName)) continue;
1035
+ const value = resolveAttributeValue(rawName.toLowerCase(), attr.value);
1036
+ if (value === null) continue;
1037
+ meta2?.set(rawName, value);
1038
+ html2 += ` ${rawName}="${escapeAttr(value)}"`;
1039
+ }
1040
+ if (meta2 && isForbiddenMetaSnapshot(meta2)) return null;
1041
+ if (!getAttributeOf(element, "data-sibu-hydrate")) {
1042
+ html2 += ` data-sibu-ssr="true"`;
1043
+ }
1044
+ return html2;
1045
+ }
730
1046
  function renderToString(element) {
731
1047
  if (element instanceof DocumentFragment) {
732
1048
  return Array.from(element.childNodes).map((child) => {
@@ -746,35 +1062,21 @@ function renderToString(element) {
746
1062
  if (!(element instanceof HTMLElement)) {
747
1063
  return escapeHtml(element.textContent || "");
748
1064
  }
749
- const tag = element.tagName.toLowerCase();
750
- if (tag === "script" || tag === "style") {
1065
+ const tag = tagNameOf(element).toLowerCase();
1066
+ if (isCodeTextElement(tag)) {
751
1067
  return DEV ? `<!--ssr:${tag}-stripped-->` : "";
752
1068
  }
753
1069
  if (!/^[a-z][a-z0-9-]*$/i.test(tag)) {
754
1070
  return DEV ? "<!--ssr:invalid-tag-->" : "";
755
1071
  }
756
- let html2 = `<${tag}`;
757
- for (const attr of Array.from(element.attributes)) {
758
- const rawName = attr.name;
759
- if (!isSafeAttrName(rawName)) continue;
760
- if (isEventHandlerAttr(rawName)) continue;
761
- if (isForbiddenSsrAttr(rawName)) continue;
762
- const lowerName = rawName.toLowerCase();
763
- let value = attr.value;
764
- if (isPolicyAttr(lowerName)) {
765
- value = sanitizeSsrAttributeValue(lowerName, value);
766
- if (!value) continue;
767
- }
768
- html2 += ` ${rawName}="${escapeAttr(value)}"`;
769
- }
770
- if (element.dataset && !element.dataset.sibuHydrate) {
771
- html2 += ` data-sibu-ssr="true"`;
772
- }
1072
+ const openTag = serializeOpenTag(element, tag);
1073
+ if (openTag === null) return DEV ? `<!--ssr:${tag}-stripped-->` : "";
1074
+ let html2 = openTag;
773
1075
  if (VOID_ELEMENTS.has(tag)) {
774
1076
  return `${html2} />`;
775
1077
  }
776
1078
  html2 += ">";
777
- for (const child of Array.from(element.childNodes)) {
1079
+ for (const child of Array.from(childNodesOf(element))) {
778
1080
  try {
779
1081
  html2 += renderToString(child);
780
1082
  } catch (err) {
@@ -924,12 +1226,8 @@ function buildAttrString(attrs, { allowEventHandlers = false } = {}) {
924
1226
  if (!isSafeAttrName(rawKey)) continue;
925
1227
  if (!allowEventHandlers && isEventHandlerAttr(rawKey)) continue;
926
1228
  if (isForbiddenSsrAttr(rawKey)) continue;
927
- const lowerKey = rawKey.toLowerCase();
928
- let value = String(attrs[rawKey]);
929
- if (isPolicyAttr(lowerKey)) {
930
- value = sanitizeSsrAttributeValue(lowerKey, value);
931
- if (!value) continue;
932
- }
1229
+ const value = resolveAttributeValue(rawKey.toLowerCase(), String(attrs[rawKey]));
1230
+ if (value === null) continue;
933
1231
  out.push(`${rawKey}="${escapeAttr(value)}"`);
934
1232
  }
935
1233
  return out.join(" ");
@@ -992,8 +1290,8 @@ async function* renderToStream(element) {
992
1290
  yield escapeHtml(element.textContent || "");
993
1291
  return;
994
1292
  }
995
- const tag = element.tagName.toLowerCase();
996
- if (tag === "script" || tag === "style") {
1293
+ const tag = tagNameOf(element).toLowerCase();
1294
+ if (isCodeTextElement(tag)) {
997
1295
  if (DEV) yield `<!--ssr:${tag}-stripped-->`;
998
1296
  return;
999
1297
  }
@@ -1001,29 +1299,17 @@ async function* renderToStream(element) {
1001
1299
  if (DEV) yield "<!--ssr:invalid-tag-->";
1002
1300
  return;
1003
1301
  }
1004
- let openTag = `<${tag}`;
1005
- for (const attr of Array.from(element.attributes)) {
1006
- const rawName = attr.name;
1007
- if (!isSafeAttrName(rawName)) continue;
1008
- if (isEventHandlerAttr(rawName)) continue;
1009
- if (isForbiddenSsrAttr(rawName)) continue;
1010
- const lowerName = rawName.toLowerCase();
1011
- let value = attr.value;
1012
- if (isPolicyAttr(lowerName)) {
1013
- value = sanitizeSsrAttributeValue(lowerName, value);
1014
- if (!value) continue;
1015
- }
1016
- openTag += ` ${rawName}="${escapeAttr(value)}"`;
1017
- }
1018
- if (element.dataset && !element.dataset.sibuHydrate) {
1019
- openTag += ` data-sibu-ssr="true"`;
1302
+ const openTag = serializeOpenTag(element, tag);
1303
+ if (openTag === null) {
1304
+ if (DEV) yield `<!--ssr:${tag}-stripped-->`;
1305
+ return;
1020
1306
  }
1021
1307
  if (VOID_ELEMENTS.has(tag)) {
1022
1308
  yield `${openTag} />`;
1023
1309
  return;
1024
1310
  }
1025
1311
  yield `${openTag}>`;
1026
- for (const child of Array.from(element.childNodes)) {
1312
+ for (const child of Array.from(childNodesOf(element))) {
1027
1313
  try {
1028
1314
  yield* renderToStream(child);
1029
1315
  } catch (err) {
@@ -1208,8 +1494,7 @@ function deserializeState(validate) {
1208
1494
  "[SibuJS SSR] deserializeState() called without a validate guard \u2014 tampered SSR payloads will not be detected."
1209
1495
  );
1210
1496
  }
1211
- const w = window;
1212
- const raw = w[SSR_DATA_ATTR];
1497
+ const raw = readOwnGlobal(SSR_DATA_ATTR);
1213
1498
  if (raw === void 0) return void 0;
1214
1499
  if (validate && !validate(raw)) return void 0;
1215
1500
  return raw;
@@ -1712,7 +1997,7 @@ function forEachSubscriber(signal2, visit) {
1712
1997
  }
1713
1998
 
1714
1999
  // src/reactivity/track.ts
1715
- var _runtimeVersion = true ? "4.7.0" : "dev";
2000
+ var _runtimeVersion = true ? "4.8.0" : "dev";
1716
2001
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
1717
2002
  function resolveReactiveApi() {
1718
2003
  const g2 = globalThis;
@@ -2523,25 +2808,43 @@ function createMiddlewareChain() {
2523
2808
  }
2524
2809
 
2525
2810
  // src/utils/setSafeAttribute.ts
2526
- var HTML_NS = "http://www.w3.org/1999/xhtml";
2527
- var SVG_NS = "http://www.w3.org/2000/svg";
2811
+ var HTML_NS2 = "http://www.w3.org/1999/xhtml";
2812
+ var SVG_NS2 = "http://www.w3.org/2000/svg";
2528
2813
  var XLINK_NS = "http://www.w3.org/1999/xlink";
2529
2814
  var XML_NS = "http://www.w3.org/XML/1998/namespace";
2530
2815
  var BOOLEAN_IDL_ATTRS = /* @__PURE__ */ new Set(["checked", "disabled", "selected"]);
2531
2816
  function isHtmlElement(el) {
2532
- return el.namespaceURI === null || el.namespaceURI === HTML_NS;
2817
+ return el.namespaceURI === null || el.namespaceURI === HTML_NS2;
2818
+ }
2819
+ function warnContextualRefusal(label2, name, refusal) {
2820
+ devWarnLazy(() => {
2821
+ const reasons = [
2822
+ "",
2823
+ 'the element would become a <meta http-equiv="refresh"> directive the shared refresh policy forbids (a destination outside the URL allowlist, or a directive too malformed to read unambiguously)',
2824
+ "a <meta> whose http-equiv or content is reactive may never carry a refresh directive: a browser schedules the navigation as soon as the directive is valid, and nothing can withdraw it when the state changes back",
2825
+ "a runtime value may not choose the program a <script> runs; name the script in static template source, or load it through Head({ script }) as an explicit trust decision",
2826
+ "an SVG animation may not target a URL, event-handler or nested-document attribute; its to / values would be written into that attribute without passing the URL policy",
2827
+ 'a runtime-chosen href may not become an applied <link rel="stylesheet">: a well-formed URL is not a trusted stylesheet. Name the stylesheet in static template source, or load a runtime-chosen one through Head({ link }) as an explicit trust decision'
2828
+ ];
2829
+ return `${label2}: refusing "${name}" in this element's context \u2014 ${reasons[refusal]}. The write was not performed.`;
2830
+ });
2533
2831
  }
2534
2832
  function setProp(el, key, val) {
2535
2833
  el[key] = val;
2536
2834
  }
2537
2835
  function namespaceFor(el, name) {
2538
- if (el.namespaceURI !== SVG_NS) return null;
2836
+ if (el.namespaceURI !== SVG_NS2) return null;
2539
2837
  const lower = name.toLowerCase();
2540
2838
  if (lower.startsWith("xlink:")) return XLINK_NS;
2541
2839
  if (lower.startsWith("xml:")) return XML_NS;
2542
2840
  return null;
2543
2841
  }
2544
2842
  function setSafeAttribute(el, name, value, options = {}) {
2843
+ const written = commitSafeAttribute(el, name, value, options);
2844
+ if (el.localName === "link") settleAttributeProvenance(el, name, options.reactive ? "reactive" : "runtime");
2845
+ return written;
2846
+ }
2847
+ function commitSafeAttribute(el, name, value, options) {
2545
2848
  const ns = namespaceFor(el, name);
2546
2849
  const localName = ns ? name.slice(name.indexOf(":") + 1) : name;
2547
2850
  if (isEventHandlerAttr(name)) {
@@ -2554,6 +2857,14 @@ function setSafeAttribute(el, name, value, options = {}) {
2554
2857
  else el.removeAttribute(name);
2555
2858
  return false;
2556
2859
  }
2860
+ const pending = value == null || value === false ? null : value === true ? "" : String(value);
2861
+ const refusal = contextualAttributeRefusal(el, name, pending, options.reactive ? "reactive" : "runtime");
2862
+ if (refusal !== ContextualRefusal.None) {
2863
+ warnContextualRefusal(options.label ?? "setSafeAttribute", name, refusal);
2864
+ if (ns) el.removeAttributeNS(ns, localName);
2865
+ else el.removeAttribute(name);
2866
+ return false;
2867
+ }
2557
2868
  if (value == null) {
2558
2869
  if (ns) el.removeAttributeNS(ns, localName);
2559
2870
  else el.removeAttribute(name);
@@ -2597,7 +2908,12 @@ function setSafeAttribute(el, name, value, options = {}) {
2597
2908
  setProp(el, idlName, idlName === "checked" ? Boolean(value) : str);
2598
2909
  return true;
2599
2910
  }
2600
- const safe = sanitizeAttributeString(name, str, { element: el });
2911
+ const safe = str === "" ? "" : resolveAttributeValue(name, str, { element: el });
2912
+ if (safe === null) {
2913
+ if (ns) el.removeAttributeNS(ns, localName);
2914
+ else el.removeAttribute(name);
2915
+ return true;
2916
+ }
2601
2917
  const current = ns ? el.getAttributeNS(ns, localName) : el.getAttribute(name);
2602
2918
  if (current === safe) return true;
2603
2919
  if (ns) el.setAttributeNS(ns, name, safe);
@@ -2620,7 +2936,7 @@ function bindAttribute(el, attr, getter) {
2620
2936
  reportError(err, { phase: "binding", name: `bindAttribute("${attr}")`, node: el });
2621
2937
  return;
2622
2938
  }
2623
- setSafeAttribute(el, attr, value, { label: `bindAttribute("${attr}")` });
2939
+ setSafeAttribute(el, attr, value, { label: `bindAttribute("${attr}")`, reactive: true });
2624
2940
  }
2625
2941
  return reactiveBinding2(commit, el);
2626
2942
  }
@@ -2794,11 +3110,7 @@ function bindChildNode(placeholder, getter) {
2794
3110
  }
2795
3111
 
2796
3112
  // src/core/rendering/tagFactory.ts
2797
- var SVG_NS2 = "http://www.w3.org/2000/svg";
2798
- var BLOCKED_TAGS = /* @__PURE__ */ new Set(["script", "iframe", "object", "embed", "frame", "frameset"]);
2799
- function isBlockedTag(tag) {
2800
- return BLOCKED_TAGS.has(tag.toLowerCase());
2801
- }
3113
+ var SVG_NS3 = "http://www.w3.org/2000/svg";
2802
3114
  var CLOBBER_RISKY_IDS = /* @__PURE__ */ new Set([
2803
3115
  "config",
2804
3116
  "location",
@@ -2843,11 +3155,12 @@ function applyStyle(el, style2) {
2843
3155
  }
2844
3156
  const next = [];
2845
3157
  for (const prop in value) {
3158
+ if (!Object.hasOwn(value, prop)) continue;
2846
3159
  const val = value[prop];
2847
3160
  if (val == null) continue;
2848
3161
  const name = toKebab(prop);
2849
3162
  next.push(name);
2850
- decl.setProperty(name, sanitizeCSSValue(String(val), { property: name, element: el }));
3163
+ decl.setProperty(name, sanitizeCSSDeclaration(name, String(val), { element: el }));
2851
3164
  }
2852
3165
  for (let i2 = 0; i2 < written.length; i2++) {
2853
3166
  if (next.indexOf(written[i2]) === -1) decl.removeProperty(written[i2]);
@@ -2863,16 +3176,17 @@ function applyStyle(el, style2) {
2863
3176
  }
2864
3177
  const htmlEl = el;
2865
3178
  for (const prop in style2) {
3179
+ if (!Object.hasOwn(style2, prop)) continue;
2866
3180
  const val = style2[prop];
2867
3181
  const name = toKebab(prop);
2868
3182
  if (typeof val === "function") {
2869
3183
  const getter = val;
2870
3184
  const teardown = reactiveBinding2(() => {
2871
- htmlEl.style.setProperty(name, sanitizeCSSValue(String(getter()), { property: name, element: el }));
3185
+ htmlEl.style.setProperty(name, sanitizeCSSDeclaration(name, String(getter()), { element: el }));
2872
3186
  }, el);
2873
3187
  registerDisposer(el, teardown);
2874
3188
  } else {
2875
- htmlEl.style.setProperty(name, sanitizeCSSValue(String(val), { property: name, element: el }));
3189
+ htmlEl.style.setProperty(name, sanitizeCSSDeclaration(name, String(val), { element: el }));
2876
3190
  }
2877
3191
  }
2878
3192
  }
@@ -2894,6 +3208,7 @@ function applyClass(el, cls) {
2894
3208
  let hasReactive = false;
2895
3209
  let result = "";
2896
3210
  for (const name in obj) {
3211
+ if (!Object.hasOwn(obj, name)) continue;
2897
3212
  const val = obj[name];
2898
3213
  if (typeof val === "function") {
2899
3214
  hasReactive = true;
@@ -2905,6 +3220,7 @@ function applyClass(el, cls) {
2905
3220
  const update = () => {
2906
3221
  let r = "";
2907
3222
  for (const name in obj) {
3223
+ if (!Object.hasOwn(obj, name)) continue;
2908
3224
  const val = obj[name];
2909
3225
  const active = typeof val === "function" ? val() : val;
2910
3226
  if (active) r = r ? `${r} ${name}` : name;
@@ -2968,7 +3284,7 @@ function appendChildren(el, nodes) {
2968
3284
  }
2969
3285
  }
2970
3286
  function tagFactory(tag, ns) {
2971
- const blocked = isBlockedTag(tag);
3287
+ const blocked = isBlockedElement(tag);
2972
3288
  return (first, second) => {
2973
3289
  if (blocked) {
2974
3290
  throw new Error(`tagFactory: refusing to create <${tag}> \u2014 tag is blocked for security reasons.`);
@@ -3031,6 +3347,7 @@ function tagFactory(tag, ns) {
3031
3347
  const pOn = props.on;
3032
3348
  if (pOn) {
3033
3349
  for (const ev in pOn) {
3350
+ if (!Object.hasOwn(pOn, ev)) continue;
3034
3351
  const handler = pOn[ev];
3035
3352
  if (typeof handler === "function") {
3036
3353
  el.addEventListener(ev, handler);
@@ -3057,6 +3374,7 @@ function tagFactory(tag, ns) {
3057
3374
  continue;
3058
3375
  // already handled above / below
3059
3376
  default: {
3377
+ if (!Object.hasOwn(props, key)) continue;
3060
3378
  const value = props[key];
3061
3379
  if (value == null) continue;
3062
3380
  if (isEventHandlerAttr(key)) continue;
@@ -3146,7 +3464,7 @@ var param = tagFactory("param");
3146
3464
  var picture = tagFactory("picture");
3147
3465
  var portal = tagFactory("portal");
3148
3466
  var source = tagFactory("source");
3149
- var svg = tagFactory("svg", SVG_NS2);
3467
+ var svg = tagFactory("svg", SVG_NS3);
3150
3468
  var math = tagFactory("math");
3151
3469
  var canvas = tagFactory("canvas");
3152
3470
  var noscript = tagFactory("noscript");
@@ -3187,26 +3505,26 @@ var base = tagFactory("base");
3187
3505
  var link = tagFactory("link");
3188
3506
  var meta = tagFactory("meta");
3189
3507
  var style = tagFactory("style");
3190
- var circle = tagFactory("circle", SVG_NS2);
3191
- var ellipse = tagFactory("ellipse", SVG_NS2);
3192
- var g = tagFactory("g", SVG_NS2);
3193
- var line = tagFactory("line", SVG_NS2);
3194
- var path = tagFactory("path", SVG_NS2);
3195
- var polygon = tagFactory("polygon", SVG_NS2);
3196
- var polyline = tagFactory("polyline", SVG_NS2);
3197
- var rect = tagFactory("rect", SVG_NS2);
3198
- var text = tagFactory("text", SVG_NS2);
3199
- var tspan = tagFactory("tspan", SVG_NS2);
3200
- var defs = tagFactory("defs", SVG_NS2);
3201
- var clipPath = tagFactory("clipPath", SVG_NS2);
3202
- var mask = tagFactory("mask", SVG_NS2);
3203
- var pattern = tagFactory("pattern", SVG_NS2);
3204
- var linearGradient = tagFactory("linearGradient", SVG_NS2);
3205
- var radialGradient = tagFactory("radialGradient", SVG_NS2);
3206
- var stop = tagFactory("stop", SVG_NS2);
3207
- var use = tagFactory("use", SVG_NS2);
3208
- var symbol = tagFactory("symbol", SVG_NS2);
3209
- var marker = tagFactory("marker", SVG_NS2);
3508
+ var circle = tagFactory("circle", SVG_NS3);
3509
+ var ellipse = tagFactory("ellipse", SVG_NS3);
3510
+ var g = tagFactory("g", SVG_NS3);
3511
+ var line = tagFactory("line", SVG_NS3);
3512
+ var path = tagFactory("path", SVG_NS3);
3513
+ var polygon = tagFactory("polygon", SVG_NS3);
3514
+ var polyline = tagFactory("polyline", SVG_NS3);
3515
+ var rect = tagFactory("rect", SVG_NS3);
3516
+ var text = tagFactory("text", SVG_NS3);
3517
+ var tspan = tagFactory("tspan", SVG_NS3);
3518
+ var defs = tagFactory("defs", SVG_NS3);
3519
+ var clipPath = tagFactory("clipPath", SVG_NS3);
3520
+ var mask = tagFactory("mask", SVG_NS3);
3521
+ var pattern = tagFactory("pattern", SVG_NS3);
3522
+ var linearGradient = tagFactory("linearGradient", SVG_NS3);
3523
+ var radialGradient = tagFactory("radialGradient", SVG_NS3);
3524
+ var stop = tagFactory("stop", SVG_NS3);
3525
+ var use = tagFactory("use", SVG_NS3);
3526
+ var symbol = tagFactory("symbol", SVG_NS3);
3527
+ var marker = tagFactory("marker", SVG_NS3);
3210
3528
  var center = tagFactory("center");
3211
3529
  var font = tagFactory("font");
3212
3530
  var marquee = tagFactory("marquee");
@@ -3487,7 +3805,16 @@ function toError(err) {
3487
3805
  if (err !== null && typeof err === "object" && "name" in err && "message" in err) return err;
3488
3806
  return new Error(String(err));
3489
3807
  }
3808
+ function workerSource(fn, api) {
3809
+ if (typeof fn !== "function") {
3810
+ throw new TypeError(
3811
+ `${api}: expected a function, got ${typeof fn}. Worker code must be a function defined in your source \u2014 a string would be evaluated as code.`
3812
+ );
3813
+ }
3814
+ return Function.prototype.toString.call(fn);
3815
+ }
3490
3816
  function worker(workerFn2) {
3817
+ const fnBody = workerSource(workerFn2, "worker");
3491
3818
  const [result, setResult] = signal(null);
3492
3819
  const [error, setError] = signal(null);
3493
3820
  const [loading, setLoading] = signal(false);
@@ -3503,7 +3830,6 @@ function worker(workerFn2) {
3503
3830
  if (typeof Worker === "undefined") {
3504
3831
  throw new Error("Web Workers are not supported in this environment");
3505
3832
  }
3506
- const fnBody = workerFn2.toString();
3507
3833
  const blob = new Blob([`self.onmessage = ${fnBody};`], { type: "application/javascript" });
3508
3834
  blobUrl = URL.createObjectURL(blob);
3509
3835
  worker2 = new Worker(blobUrl);
@@ -3552,6 +3878,7 @@ function worker(workerFn2) {
3552
3878
  return { post, result, error, loading, terminate };
3553
3879
  }
3554
3880
  function workerFn(fn) {
3881
+ const fnStr = workerSource(fn, "workerFn");
3555
3882
  const [loading, setLoading] = signal(false);
3556
3883
  let worker2 = null;
3557
3884
  let blobUrl = null;
@@ -3566,7 +3893,6 @@ function workerFn(fn) {
3566
3893
  if (typeof Worker === "undefined") {
3567
3894
  throw new Error("Web Workers are not supported in this environment");
3568
3895
  }
3569
- const fnStr = fn.toString();
3570
3896
  const blob = new Blob(
3571
3897
  [
3572
3898
  `self.onmessage = function(e) {
@@ -3626,6 +3952,7 @@ function workerFn(fn) {
3626
3952
  return { run, loading, terminate };
3627
3953
  }
3628
3954
  function createWorkerPool(workerFn2, poolSize) {
3955
+ const fnBody = workerSource(workerFn2, "createWorkerPool");
3629
3956
  const size = poolSize || typeof navigator !== "undefined" && navigator.hardwareConcurrency || 4;
3630
3957
  const workers = [];
3631
3958
  const queues = [];
@@ -3684,7 +4011,6 @@ function createWorkerPool(workerFn2, poolSize) {
3684
4011
  if (typeof Worker === "undefined") {
3685
4012
  throw new Error("Web Workers are not supported in this environment");
3686
4013
  }
3687
- const fnBody = workerFn2.toString();
3688
4014
  const blob = new Blob([`self.onmessage = ${fnBody};`], { type: "application/javascript" });
3689
4015
  blobUrl = URL.createObjectURL(blob);
3690
4016
  for (let i2 = 0; i2 < size; i2++) {