@stacksjs/stx 0.2.118 → 0.2.120

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 (60) hide show
  1. package/dist/builtins/attrs.d.ts +16 -0
  2. package/dist/builtins/attrs.js +16 -0
  3. package/dist/builtins/safe-image.js +2 -9
  4. package/dist/builtins/stx-image.js +2 -9
  5. package/dist/builtins/stx-link.js +2 -9
  6. package/dist/cli.js +1869 -824
  7. package/dist/client-script-bundler.d.ts +0 -11
  8. package/dist/client-script-bundler.js +26 -4
  9. package/dist/client-script.d.ts +24 -0
  10. package/dist/client-script.js +59 -5
  11. package/dist/component-registry.d.ts +1 -0
  12. package/dist/component-renderer.js +13 -5
  13. package/dist/composables/index.d.ts +1 -0
  14. package/dist/composables/index.js +1 -0
  15. package/dist/composables/use-scroll-lock.d.ts +13 -0
  16. package/dist/composables/use-scroll-lock.js +55 -0
  17. package/dist/composables/use-timer.d.ts +1 -1
  18. package/dist/composables/use-timer.js +13 -3
  19. package/dist/composition-api.d.ts +1 -1
  20. package/dist/composition-api.js +13 -4
  21. package/dist/craft-bridge.d.ts +80 -1
  22. package/dist/craft-bridge.js +80 -1
  23. package/dist/craft-components.d.ts +77 -3
  24. package/dist/craft-components.js +138 -9
  25. package/dist/craft.js +481 -73
  26. package/dist/dev-server/crosswind.d.ts +15 -1
  27. package/dist/dev-server/crosswind.js +12 -3
  28. package/dist/dev-server/serve-app.js +3 -3
  29. package/dist/document-shell.d.ts +17 -0
  30. package/dist/document-shell.js +72 -2
  31. package/dist/expressions.js +14 -7
  32. package/dist/head.d.ts +8 -0
  33. package/dist/head.js +11 -8
  34. package/dist/html-masking.d.ts +12 -0
  35. package/dist/html-masking.js +50 -15
  36. package/dist/index.d.ts +9 -1
  37. package/dist/index.js +9 -1
  38. package/dist/process.js +11 -3
  39. package/dist/pwa.js +1172 -431
  40. package/dist/runtime-globals.d.ts +7 -4
  41. package/dist/runtime-globals.js +10 -2
  42. package/dist/runtime-injection.js +15 -1
  43. package/dist/signal-processing.js +19 -28
  44. package/dist/signals-api.d.ts +2 -0
  45. package/dist/signals-api.js +9 -0
  46. package/dist/signals.js +802 -62
  47. package/dist/ssg.js +1161 -420
  48. package/dist/state-management.d.ts +1 -1
  49. package/dist/state-management.js +1 -1
  50. package/dist/strict-lint.d.ts +1 -1
  51. package/dist/strict-lint.js +1 -1
  52. package/dist/stx.d.ts +6 -0
  53. package/dist/style-scoping.js +10 -0
  54. package/dist/utils.js +5 -3
  55. package/dist/variable-extractor.js +14 -22
  56. package/dist/vue-template.js +3 -2
  57. package/dist/x-element.d.ts +2 -2
  58. package/dist/x-element.js +9 -8
  59. package/package.json +5 -5
  60. package/stx.d.ts +6 -0
@@ -0,0 +1,16 @@
1
+ import type { ResolvedProps } from '../component-registry';
2
+ /**
3
+ * Render the static props a builtin did not consume as HTML attributes.
4
+ *
5
+ * Names come back spelled the way the author wrote them: prop resolution
6
+ * camelizes static attributes so a `.stx` component can destructure them, and
7
+ * `staticNames` carries the original for exactly this case. Values are escaped —
8
+ * a static attribute can still hold hostile text (`aria-label="<script>…"`).
9
+ *
10
+ * Boolean props render as bare attributes when true and are dropped when false,
11
+ * matching how HTML boolean attributes work.
12
+ *
13
+ * @param props - The component's resolved props.
14
+ * @param consumed - Prop names the builtin has already rendered itself.
15
+ */
16
+ export declare function forwardStaticAttrs(props: ResolvedProps, consumed: Set<string>): string[];
@@ -0,0 +1,16 @@
1
+ import { escapeAttr } from "./escape.js";
2
+ export function forwardStaticAttrs(props, consumed) {
3
+ const attrs = [];
4
+ for (const [key, value] of Object.entries(props.static)) {
5
+ if (consumed.has(key))
6
+ continue;
7
+ const name = props.staticNames?.[key] ?? key;
8
+ if (typeof value === "boolean") {
9
+ if (value)
10
+ attrs.push(escapeAttr(name));
11
+ continue;
12
+ }
13
+ attrs.push(`${escapeAttr(name)}="${escapeAttr(value)}"`);
14
+ }
15
+ return attrs;
16
+ }
@@ -1,3 +1,4 @@
1
+ import { forwardStaticAttrs } from "./attrs.js";
1
2
  const DEFAULT_FALLBACK = "/images/safe-image-default.svg";
2
3
  function escapeAttr(value) {
3
4
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
@@ -32,15 +33,7 @@ export const SafeImageBuiltin = {
32
33
  "className",
33
34
  "fallbackClassName"
34
35
  ]);
35
- for (const [key, value] of Object.entries(props.static)) {
36
- if (consumed.has(key))
37
- continue;
38
- if (typeof value === "boolean") {
39
- if (value)
40
- imgAttrs.push(escapeAttr(key));
41
- } else
42
- imgAttrs.push(`${escapeAttr(key)}="${escapeAttr(value)}"`);
43
- }
36
+ imgAttrs.push(...forwardStaticAttrs(props, consumed));
44
37
  const imgTag = `<img ${imgAttrs.join(" ")} />`, renderCtx = ctx.context;
45
38
  if (!renderCtx.__safeImageHandlerEmitted) {
46
39
  renderCtx.__safeImageHandlerEmitted = !0;
@@ -1,3 +1,4 @@
1
+ import { forwardStaticAttrs } from "./attrs.js";
1
2
  const DEFAULT_BREAKPOINTS = {
2
3
  sm: 640,
3
4
  md: 768,
@@ -163,15 +164,7 @@ export const StxImageBuiltin = {
163
164
  "preload",
164
165
  "picture"
165
166
  ]);
166
- for (const [key, value] of Object.entries(props.static)) {
167
- if (consumedStatic.has(key))
168
- continue;
169
- if (typeof value === "boolean") {
170
- if (value)
171
- imgAttrs.push(escapeAttr(key));
172
- } else
173
- imgAttrs.push(`${escapeAttr(key)}="${escapeAttr(value)}"`);
174
- }
167
+ imgAttrs.push(...forwardStaticAttrs(props, consumedStatic));
175
168
  const imgTag = `<img ${imgAttrs.join(" ")} />`;
176
169
  let preloadTag = "";
177
170
  if (preload) {
@@ -1,3 +1,4 @@
1
+ import { forwardStaticAttrs } from "./attrs.js";
1
2
  function escapeAttr(value) {
2
3
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3
4
  }
@@ -27,15 +28,7 @@ export const StxLinkBuiltin = {
27
28
  if (prefetch)
28
29
  attrs.push("data-stx-prefetch");
29
30
  const consumedStatic = new Set(["to", "class", "className", "activeClass", "exactActiveClass", "prefetch"]);
30
- for (const [key, value] of Object.entries(props.static)) {
31
- if (consumedStatic.has(key))
32
- continue;
33
- if (typeof value === "boolean") {
34
- if (value)
35
- attrs.push(escapeAttr(key));
36
- } else
37
- attrs.push(`${escapeAttr(key)}="${escapeAttr(value)}"`);
38
- }
31
+ attrs.push(...forwardStaticAttrs(props, consumedStatic));
39
32
  return `<a ${attrs.join(" ")}>${slotContent}</a>`;
40
33
  }
41
34
  };