@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.
- package/dist/builtins/attrs.d.ts +16 -0
- package/dist/builtins/attrs.js +16 -0
- package/dist/builtins/safe-image.js +2 -9
- package/dist/builtins/stx-image.js +2 -9
- package/dist/builtins/stx-link.js +2 -9
- package/dist/cli.js +1869 -824
- package/dist/client-script-bundler.d.ts +0 -11
- package/dist/client-script-bundler.js +26 -4
- package/dist/client-script.d.ts +24 -0
- package/dist/client-script.js +59 -5
- package/dist/component-registry.d.ts +1 -0
- package/dist/component-renderer.js +13 -5
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-scroll-lock.d.ts +13 -0
- package/dist/composables/use-scroll-lock.js +55 -0
- package/dist/composables/use-timer.d.ts +1 -1
- package/dist/composables/use-timer.js +13 -3
- package/dist/composition-api.d.ts +1 -1
- package/dist/composition-api.js +13 -4
- package/dist/craft-bridge.d.ts +80 -1
- package/dist/craft-bridge.js +80 -1
- package/dist/craft-components.d.ts +77 -3
- package/dist/craft-components.js +138 -9
- package/dist/craft.js +481 -73
- package/dist/dev-server/crosswind.d.ts +15 -1
- package/dist/dev-server/crosswind.js +12 -3
- package/dist/dev-server/serve-app.js +3 -3
- package/dist/document-shell.d.ts +17 -0
- package/dist/document-shell.js +72 -2
- package/dist/expressions.js +14 -7
- package/dist/head.d.ts +8 -0
- package/dist/head.js +11 -8
- package/dist/html-masking.d.ts +12 -0
- package/dist/html-masking.js +50 -15
- package/dist/index.d.ts +9 -1
- package/dist/index.js +9 -1
- package/dist/process.js +11 -3
- package/dist/pwa.js +1172 -431
- package/dist/runtime-globals.d.ts +7 -4
- package/dist/runtime-globals.js +10 -2
- package/dist/runtime-injection.js +15 -1
- package/dist/signal-processing.js +19 -28
- package/dist/signals-api.d.ts +2 -0
- package/dist/signals-api.js +9 -0
- package/dist/signals.js +802 -62
- package/dist/ssg.js +1161 -420
- package/dist/state-management.d.ts +1 -1
- package/dist/state-management.js +1 -1
- package/dist/strict-lint.d.ts +1 -1
- package/dist/strict-lint.js +1 -1
- package/dist/stx.d.ts +6 -0
- package/dist/style-scoping.js +10 -0
- package/dist/utils.js +5 -3
- package/dist/variable-extractor.js +14 -22
- package/dist/vue-template.js +3 -2
- package/dist/x-element.d.ts +2 -2
- package/dist/x-element.js +9 -8
- package/package.json +5 -5
- 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, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -32,15 +33,7 @@ export const SafeImageBuiltin = {
|
|
|
32
33
|
"className",
|
|
33
34
|
"fallbackClassName"
|
|
34
35
|
]);
|
|
35
|
-
|
|
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
|
-
|
|
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, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
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
|
-
|
|
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
|
};
|