@jasonshimmy/custom-elements-runtime 2.2.3 → 2.2.5

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 (34) hide show
  1. package/dist/custom-elements-runtime.cjs.js +9 -9
  2. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  3. package/dist/custom-elements-runtime.es.js +1728 -1639
  4. package/dist/custom-elements-runtime.es.js.map +1 -1
  5. package/dist/custom-elements-runtime.router.cjs.js +19 -17
  6. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  7. package/dist/custom-elements-runtime.router.es.js +181 -165
  8. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  9. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  10. package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
  11. package/dist/custom-elements-runtime.ssr.es.js +12 -10
  12. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  13. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  14. package/dist/custom-elements-runtime.transitions.es.js +1 -1
  15. package/dist/{helpers-D3UjNfYY.cjs → namespace-helpers-DwMMXN9Q.cjs} +3 -3
  16. package/dist/namespace-helpers-DwMMXN9Q.cjs.map +1 -0
  17. package/dist/{helpers-CDfJhmMS.js → namespace-helpers-Vwt2Fzds.js} +97 -55
  18. package/dist/namespace-helpers-Vwt2Fzds.js.map +1 -0
  19. package/dist/router.d.ts +2 -2
  20. package/dist/runtime/event-manager.d.ts +6 -6
  21. package/dist/runtime/namespace-helpers.d.ts +17 -0
  22. package/dist/runtime/node-metadata.d.ts +2 -2
  23. package/dist/runtime/types.d.ts +2 -2
  24. package/dist/runtime/vdom-model-helpers.d.ts +2 -2
  25. package/dist/runtime/vdom-ssr.d.ts +7 -1
  26. package/dist/runtime/vdom.d.ts +4 -4
  27. package/dist/ssr.d.ts +21 -0
  28. package/dist/{transitions-m6FraTTL.js → transitions-DCIjMqzG.js} +35 -34
  29. package/dist/{transitions-m6FraTTL.js.map → transitions-DCIjMqzG.js.map} +1 -1
  30. package/dist/{transitions-Bv8lUAOe.cjs → transitions-DHQuI3AY.cjs} +2 -2
  31. package/dist/{transitions-Bv8lUAOe.cjs.map → transitions-DHQuI3AY.cjs.map} +1 -1
  32. package/package.json +1 -1
  33. package/dist/helpers-CDfJhmMS.js.map +0 -1
  34. package/dist/helpers-D3UjNfYY.cjs.map +0 -1
package/dist/ssr.d.ts CHANGED
@@ -1,6 +1,27 @@
1
1
  /**
2
2
  * SSR entrypoint — small re-export so consumers can import SSR-only helpers
3
3
  * without pulling them into the main client runtime bundle.
4
+ *
5
+ * renderToString accepts an optional second argument to control SSR behavior:
6
+ *
7
+ * renderToString(vnode, { injectSvgNamespace?: boolean })
8
+ *
9
+ * - injectSvgNamespace (default: true): when true, the SSR renderer will
10
+ * inject the standard SVG namespace attribute (xmlns="http://www.w3.org/2000/svg")
11
+ * onto `<svg>` elements that do not already provide an explicit `xmlns`.
12
+ * This matches the client runtime behavior (createElementNS) and avoids
13
+ * hydration/namespace mismatches. Set to `false` to opt out and keep SSR
14
+ * output minimal.
15
+ *
16
+ * Examples
17
+ *
18
+ * // Default (injects xmlns for <svg> if missing)
19
+ * import { renderToString } from '@custom-elements/ssr';
20
+ * const html = renderToString(vnodeTree);
21
+ *
22
+ * // Opt-out
23
+ * const htmlNoNs = renderToString(vnodeTree, { injectSvgNamespace: false });
4
24
  */
5
25
  export { renderToString } from './runtime/vdom-ssr';
6
26
  export type { VNode } from './runtime/types';
27
+ export type { RenderOptions } from './runtime/vdom-ssr';
@@ -1,5 +1,5 @@
1
- import { anchorBlock as ye } from "./custom-elements-runtime.directives.es.js";
2
- const $e = `/*
1
+ import { anchorBlock as $e } from "./custom-elements-runtime.directives.es.js";
2
+ const ye = `/*
3
3
  * Custom Elements Variables CSS
4
4
  * CSS variables for colors and fonts
5
5
  */
@@ -139,7 +139,7 @@ function De(e) {
139
139
  return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi, "").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, "").replace(/expression\s*\([^)]*\)/gi, "");
140
140
  }
141
141
  const pe = ke`
142
- ${$e}
142
+ ${ye}
143
143
  :host,
144
144
  *,
145
145
  ::before,
@@ -833,7 +833,8 @@ const Ce = {
833
833
  "peer-hover": (e, r) => `.peer:hover ~ ${e}{${r}}`,
834
834
  "peer-focus": (e, r) => `.peer:focus ~ ${e}{${r}}`,
835
835
  "peer-checked": (e, r) => `.peer:checked ~ ${e}{${r}}`,
836
- "peer-disabled": (e, r) => `.peer:disabled ~ ${e}{${r}}`
836
+ "peer-disabled": (e, r) => `.peer:disabled ~ ${e}{${r}}`,
837
+ "dark-class": (e, r) => `:host(.dark) ${e}{${r}}`
837
838
  }, oe = {
838
839
  sm: "(min-width:640px)",
839
840
  md: "(min-width:768px)",
@@ -872,11 +873,11 @@ function ae(e) {
872
873
  const c = o.slice(0, n), s = o.slice(n + 1);
873
874
  if (!te[c]) return null;
874
875
  if (s.includes("/")) {
875
- const [t, a] = s.split("/").map(($) => parseFloat($));
876
+ const [t, a] = s.split("/").map((y) => parseFloat(y));
876
877
  if (Number.isNaN(t) || Number.isNaN(a) || a === 0)
877
878
  return null;
878
879
  const d = t / a * 100;
879
- return te[c].map(($) => `${$}:${d}%;`).join("");
880
+ return te[c].map((y) => `${y}:${d}%;`).join("");
880
881
  }
881
882
  const u = parseFloat(s);
882
883
  if (Number.isNaN(u)) return null;
@@ -890,10 +891,10 @@ function ce(e) {
890
891
  if (s === "reverse")
891
892
  return u ? "--cer-space-x-reverse:1;" : "--cer-space-y-reverse:1;";
892
893
  if (s.includes("/")) {
893
- const [d, $] = s.split("/").map((A) => parseFloat(A));
894
- if (Number.isNaN(d) || Number.isNaN($) || $ === 0)
894
+ const [d, y] = s.split("/").map((A) => parseFloat(A));
895
+ if (Number.isNaN(d) || Number.isNaN(y) || y === 0)
895
896
  return null;
896
- const v = d / $ * 100, C = r ? "-" : "";
897
+ const v = d / y * 100, C = r ? "-" : "";
897
898
  return u ? `--cer-space-x-reverse:0;& > :not([hidden]) ~ :not([hidden]){margin-inline-start:calc(${C}${v}% * calc(1 - var(--cer-space-x-reverse)));margin-inline-end:calc(${C}${v}% * var(--cer-space-x-reverse));}` : `--cer-space-y-reverse:0;& > :not([hidden]) ~ :not([hidden]){margin-top:calc(${C}${v}% * calc(1 - var(--cer-space-y-reverse)));margin-bottom:calc(${C}${v}% * var(--cer-space-y-reverse));}`;
898
899
  }
899
900
  const m = parseFloat(s);
@@ -940,7 +941,7 @@ function se(e) {
940
941
  if (n.includes("var(")) {
941
942
  const u = /var\([^)]*\)/.exec(n);
942
943
  if (u) {
943
- const m = u[0], t = o * 100, a = `color-mix(in srgb, ${m} ${t}%, rgba(0 0 0 / 0) ${100 - t}%)`, d = /#([0-9a-f]{6}|[0-9a-f]{3})/i.exec(m), $ = /^([a-z-]+):/.exec(n), v = $ ? $[1] : "background-color";
944
+ const m = u[0], t = o * 100, a = `color-mix(in srgb, ${m} ${t}%, rgba(0 0 0 / 0) ${100 - t}%)`, d = /#([0-9a-f]{6}|[0-9a-f]{3})/i.exec(m), y = /^([a-z-]+):/.exec(n), v = y ? y[1] : "background-color";
944
945
  if (d) {
945
946
  const A = `rgb(${J(d[0])} / ${o})`, f = m.replace(
946
947
  /#([0-9a-f]{6}|[0-9a-f]{3})/i,
@@ -967,7 +968,7 @@ function se(e) {
967
968
  if (c.includes("var(")) {
968
969
  const u = /var\([^)]*\)/.exec(c);
969
970
  if (u) {
970
- const m = u[0], t = o * 100, a = `color-mix(in srgb, ${m} ${t}%, rgba(0 0 0 / 0) ${100 - t}%)`, d = /#([0-9a-f]{6}|[0-9a-f]{3})/i.exec(m), $ = /^([a-z-]+):/.exec(c), v = $ ? $[1] : null;
971
+ const m = u[0], t = o * 100, a = `color-mix(in srgb, ${m} ${t}%, rgba(0 0 0 / 0) ${100 - t}%)`, d = /#([0-9a-f]{6}|[0-9a-f]{3})/i.exec(m), y = /^([a-z-]+):/.exec(c), v = y ? y[1] : null;
971
972
  if (d && v) {
972
973
  const A = `rgb(${J(d[0])} / ${o})`, f = m.replace(
973
974
  /#([0-9a-f]{6}|[0-9a-f]{3})/i,
@@ -1104,7 +1105,7 @@ function Le(e) {
1104
1105
  const c = new Set(n), s = [[], [], [], []], u = {}, m = (f, p = !1) => {
1105
1106
  const g = p ? `dark|${f}` : f;
1106
1107
  if (g in u) return u[g];
1107
- const b = $(f, p);
1108
+ const b = y(f, p);
1108
1109
  return u[g] = b, b;
1109
1110
  }, t = (f) => {
1110
1111
  const p = f.some((k) => ne.includes(k)), g = f.some(
@@ -1132,12 +1133,12 @@ function Le(e) {
1132
1133
  even: ":nth-child(even)",
1133
1134
  "focus-within": ":focus-within",
1134
1135
  "focus-visible": ":focus-visible"
1135
- }, $ = (f, p = !1) => {
1136
+ }, y = (f, p = !1) => {
1136
1137
  const g = a(f);
1137
1138
  let b = "", k = !1;
1138
1139
  for (const i of g) {
1139
- let y = i;
1140
- if (y.startsWith("!") && (k = !0, y = y.slice(1)), re[y] || ae(y) || ce(y) || de(y) || se(y) || le(y) || Z(y)) {
1140
+ let $ = i;
1141
+ if ($.startsWith("!") && (k = !0, $ = $.slice(1)), re[$] || ae($) || ce($) || de($) || se($) || le($) || Z($)) {
1141
1142
  b = i;
1142
1143
  break;
1143
1144
  }
@@ -1162,9 +1163,9 @@ function Le(e) {
1162
1163
  for (const i of h) {
1163
1164
  if (i === "dark" || ne.includes(i) || i.startsWith("@") && (ie.includes(i.slice(1)) || i.match(/^@\[.+\]$/)))
1164
1165
  continue;
1165
- const y = _e(i);
1166
- if (y) {
1167
- S = y;
1166
+ const $ = _e(i);
1167
+ if ($) {
1168
+ S = $;
1168
1169
  continue;
1169
1170
  }
1170
1171
  const F = d[i];
@@ -1176,8 +1177,8 @@ function Le(e) {
1176
1177
  typeof E == "function" && (l = E(l, _).split("{")[0]);
1177
1178
  }
1178
1179
  const D = W.join(""), L = V.join("");
1179
- function Q(i, y) {
1180
- if (!y) return i;
1180
+ function Q(i, $) {
1181
+ if (!$) return i;
1181
1182
  let F = 0, E = 0;
1182
1183
  if (i.length && (i[0] === ">" || i[0] === "+" || i[0] === "~" || i[0] === " ")) {
1183
1184
  let j = 1;
@@ -1185,30 +1186,30 @@ function Le(e) {
1185
1186
  for (; j < i.length; j++) {
1186
1187
  const z = i[j];
1187
1188
  if (z === "[" ? F++ : z === "]" && F > 0 ? F-- : z === "(" ? E++ : z === ")" && E > 0 && E--, F === 0 && E === 0 && (i[j] === ">" || i[j] === "+" || i[j] === "~" || i[j] === " "))
1188
- return i.slice(0, j) + y + i.slice(j);
1189
+ return i.slice(0, j) + $ + i.slice(j);
1189
1190
  }
1190
- return i + y;
1191
+ return i + $;
1191
1192
  }
1192
1193
  for (let j = 0; j < i.length; j++) {
1193
1194
  const z = i[j];
1194
1195
  if (z === "[" ? F++ : z === "]" && F > 0 ? F-- : z === "(" ? E++ : z === ")" && E > 0 && E--, F === 0 && E === 0 && (z === ">" || z === "+" || z === "~" || z === " "))
1195
- return i.slice(0, j) + y + i.slice(j);
1196
+ return i.slice(0, j) + $ + i.slice(j);
1196
1197
  }
1197
- return i + y;
1198
+ return i + $;
1198
1199
  }
1199
1200
  if (S)
1200
1201
  if (S.includes("&")) {
1201
- const i = S.indexOf("&"), y = S.slice(0, i), F = S.slice(i + 1), E = w + D;
1202
+ const i = S.indexOf("&"), $ = S.slice(0, i), F = S.slice(i + 1), E = w + D;
1202
1203
  if (W.length === 0)
1203
1204
  l = l.replace(
1204
1205
  w,
1205
- y + E + L + F
1206
+ $ + E + L + F
1206
1207
  );
1207
1208
  else {
1208
1209
  const j = Q(F, L);
1209
1210
  l = l.replace(
1210
1211
  w,
1211
- y + E + j
1212
+ $ + E + j
1212
1213
  );
1213
1214
  }
1214
1215
  } else
@@ -1416,7 +1417,7 @@ function Ne(e, r) {
1416
1417
  name: t,
1417
1418
  enterFrom: a,
1418
1419
  enterActive: d,
1419
- enterTo: $,
1420
+ enterTo: y,
1420
1421
  leaveFrom: v,
1421
1422
  leaveActive: C,
1422
1423
  leaveTo: A,
@@ -1430,15 +1431,15 @@ function Ne(e, r) {
1430
1431
  onLeaveCancelled: T
1431
1432
  } = e;
1432
1433
  let h;
1433
- o && X[o] ? (h = { ...X[o] }, a && (h.enterFrom = a), d && (h.enterActive = d), $ && (h.enterTo = $), v && (h.leaveFrom = v), C && (h.leaveActive = C), A && (h.leaveTo = A)) : h = {
1434
+ o && X[o] ? (h = { ...X[o] }, a && (h.enterFrom = a), d && (h.enterActive = d), y && (h.enterTo = y), v && (h.leaveFrom = v), C && (h.leaveActive = C), A && (h.leaveTo = A)) : h = {
1434
1435
  enterFrom: a,
1435
1436
  enterActive: d,
1436
- enterTo: $,
1437
+ enterTo: y,
1437
1438
  leaveFrom: v,
1438
1439
  leaveActive: C,
1439
1440
  leaveTo: A
1440
1441
  };
1441
- const R = t || (o ? `transition-${o}` : "transition"), _ = ye(n ? r : [], R);
1442
+ const R = t || (o ? `transition-${o}` : "transition"), _ = $e(n ? r : [], R);
1442
1443
  return _._transition = {
1443
1444
  name: R,
1444
1445
  classes: h,
@@ -1470,7 +1471,7 @@ function Be(e, r) {
1470
1471
  appear: t = !1,
1471
1472
  css: a = !0,
1472
1473
  name: d,
1473
- class: $,
1474
+ class: y,
1474
1475
  style: v,
1475
1476
  enterFrom: C,
1476
1477
  enterActive: A,
@@ -1526,7 +1527,7 @@ function Be(e, r) {
1526
1527
  key: P,
1527
1528
  props: {
1528
1529
  attrs: {
1529
- ...$ ? { class: $ } : {},
1530
+ ...y ? { class: y } : {},
1530
1531
  ...V ? { style: V } : {}
1531
1532
  },
1532
1533
  _transitionGroup: {
@@ -1603,4 +1604,4 @@ export {
1603
1604
  De as s,
1604
1605
  X as t
1605
1606
  };
1606
- //# sourceMappingURL=transitions-m6FraTTL.js.map
1607
+ //# sourceMappingURL=transitions-DCIjMqzG.js.map