@stacksjs/stx 0.2.176 → 0.2.178
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 +19 -0
- package/dist/builtins/attrs.js +18 -0
- package/dist/builtins/safe-image.js +2 -1
- package/dist/builtins/stx-image.js +2 -1
- package/dist/builtins/stx-link.js +2 -1
- package/dist/cli-flags.d.ts +34 -0
- package/dist/cli-flags.js +20 -0
- package/dist/cli.js +899 -778
- package/dist/client-script.js +2 -1
- package/dist/component-registry.d.ts +9 -0
- package/dist/component-renderer.js +20 -1
- package/dist/composables/use-fetch.d.ts +6 -1
- package/dist/composables/use-fetch.js +40 -18
- package/dist/composables/use-query.d.ts +7 -2
- package/dist/cookie-serialize.d.ts +40 -0
- package/dist/cookie-serialize.js +18 -0
- package/dist/craft.js +500 -381
- package/dist/crosswind-config.d.ts +13 -0
- package/dist/crosswind-config.js +6 -2
- package/dist/dev-server/crosswind.js +2 -1
- package/dist/edge-runtime.d.ts +2 -9
- package/dist/edge-runtime.js +2 -16
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/page-action.d.ts +10 -20
- package/dist/page-action.js +33 -9
- package/dist/production-server.js +8 -7
- package/dist/pwa.js +452 -333
- package/dist/reactive.js +2 -3
- package/dist/signal-processing.js +37 -6
- package/dist/signals.js +150 -32
- package/dist/ssg.js +465 -346
- package/dist/ssr.js +2 -16
- package/dist/stx-virtual-ts.d.ts +45 -1
- package/dist/stx-virtual-ts.js +75 -5
- package/dist/stx.d.ts +66 -7
- package/dist/template-hydrator.d.ts +1 -1
- package/dist/template-hydrator.js +6 -6
- package/dist/theme-tokens.d.ts +88 -0
- package/dist/theme-tokens.js +71 -0
- package/dist/typecheck.d.ts +6 -1
- package/dist/typecheck.js +7 -6
- package/package.json +5 -5
- package/stx.d.ts +66 -7
package/dist/builtins/attrs.d.ts
CHANGED
|
@@ -28,3 +28,22 @@ import type { ResolvedProps } from '../component-registry';
|
|
|
28
28
|
* @param consumed - Prop names the builtin has already rendered itself.
|
|
29
29
|
*/
|
|
30
30
|
export declare function forwardStaticAttrs(props: ResolvedProps, consumed: Set<string>): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Render the server-evaluated `:prop` bindings a builtin did not consume.
|
|
33
|
+
*
|
|
34
|
+
* Only `static` was ever forwarded, so `<StxLink to="/x" :title="pageTitle">`
|
|
35
|
+
* emitted an `<a>` with no title and no warning — the binding was resolved,
|
|
36
|
+
* stored, and thrown away (stacksjs/stx#1930). Client-reactive `:prop` and
|
|
37
|
+
* `@event` bindings already reach the element by another route (the component
|
|
38
|
+
* renderer re-applies them to the root), which is what made the gap specific to
|
|
39
|
+
* the server-evaluated ones and easy to miss.
|
|
40
|
+
*
|
|
41
|
+
* `null`, `undefined` and `false` DROP the attribute rather than rendering the
|
|
42
|
+
* word — that is what makes `:aria-current="active ? 'page' : null"` express
|
|
43
|
+
* "this attribute is conditional", which is the whole reason to reach for a
|
|
44
|
+
* binding instead of a literal. `true` renders bare, as HTML booleans do.
|
|
45
|
+
*
|
|
46
|
+
* @param props - The component's resolved props.
|
|
47
|
+
* @param consumed - Prop names the builtin has already rendered itself.
|
|
48
|
+
*/
|
|
49
|
+
export declare function forwardResolvedAttrs(props: ResolvedProps, consumed: Set<string>): string[];
|
package/dist/builtins/attrs.js
CHANGED
|
@@ -19,3 +19,21 @@ export function forwardStaticAttrs(props, consumed) {
|
|
|
19
19
|
}
|
|
20
20
|
return attrs;
|
|
21
21
|
}
|
|
22
|
+
export function forwardResolvedAttrs(props, consumed) {
|
|
23
|
+
const attrs = [];
|
|
24
|
+
for (const [key, value] of Object.entries(props.serverDynamic ?? {})) {
|
|
25
|
+
if (consumed.has(key))
|
|
26
|
+
continue;
|
|
27
|
+
if (value === null || value === void 0 || value === !1)
|
|
28
|
+
continue;
|
|
29
|
+
const name = props.serverDynamicNames?.[key] ?? key;
|
|
30
|
+
if (value === !0) {
|
|
31
|
+
attrs.push(escapeAttr(name));
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (typeof value === "object")
|
|
35
|
+
continue;
|
|
36
|
+
attrs.push(`${escapeAttr(name)}="${escapeAttr(stripControlChars(String(value)))}"`);
|
|
37
|
+
}
|
|
38
|
+
return attrs;
|
|
39
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardStaticAttrs } from "./attrs.js";
|
|
1
|
+
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
2
|
const DEFAULT_FALLBACK = "/images/safe-image-default.svg";
|
|
3
3
|
function escapeAttr(value) {
|
|
4
4
|
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -34,6 +34,7 @@ export const SafeImageBuiltin = {
|
|
|
34
34
|
"fallbackClassName"
|
|
35
35
|
]);
|
|
36
36
|
imgAttrs.push(...forwardStaticAttrs(props, consumed));
|
|
37
|
+
imgAttrs.push(...forwardResolvedAttrs(props, consumed));
|
|
37
38
|
const imgTag = `<img ${imgAttrs.join(" ")} />`, renderCtx = ctx.context;
|
|
38
39
|
if (!renderCtx.__safeImageHandlerEmitted) {
|
|
39
40
|
renderCtx.__safeImageHandlerEmitted = !0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardStaticAttrs } from "./attrs.js";
|
|
1
|
+
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
2
|
const DEFAULT_BREAKPOINTS = {
|
|
3
3
|
sm: 640,
|
|
4
4
|
md: 768,
|
|
@@ -165,6 +165,7 @@ export const StxImageBuiltin = {
|
|
|
165
165
|
"picture"
|
|
166
166
|
]);
|
|
167
167
|
imgAttrs.push(...forwardStaticAttrs(props, consumedStatic));
|
|
168
|
+
imgAttrs.push(...forwardResolvedAttrs(props, consumedStatic));
|
|
168
169
|
const imgTag = `<img ${imgAttrs.join(" ")} />`;
|
|
169
170
|
let preloadTag = "";
|
|
170
171
|
if (preload) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardStaticAttrs } from "./attrs.js";
|
|
1
|
+
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
2
|
function escapeAttr(value) {
|
|
3
3
|
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
4
4
|
}
|
|
@@ -29,6 +29,7 @@ export const StxLinkBuiltin = {
|
|
|
29
29
|
attrs.push("data-stx-prefetch");
|
|
30
30
|
const consumedStatic = new Set(["to", "class", "className", "activeClass", "exactActiveClass", "prefetch"]);
|
|
31
31
|
attrs.push(...forwardStaticAttrs(props, consumedStatic));
|
|
32
|
+
attrs.push(...forwardResolvedAttrs(props, consumedStatic));
|
|
32
33
|
return `<a ${attrs.join(" ")}>${slotContent}</a>`;
|
|
33
34
|
}
|
|
34
35
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a flag that may legitimately appear more than once.
|
|
3
|
+
*
|
|
4
|
+
* The CLI parser collapses repeats to the LAST value — `--lib a --lib b` arrives
|
|
5
|
+
* as the string `"b"`, and the same is true of `<path...>` and `[path...]`, so
|
|
6
|
+
* there is no option spec that expresses "repeatable". The typecheck command
|
|
7
|
+
* documented `--lib` as repeatable and had an `Array.isArray(options.lib)`
|
|
8
|
+
* branch that could therefore never run: a project splitting its ambient
|
|
9
|
+
* declarations across two files silently got whichever one it listed last
|
|
10
|
+
* (stacksjs/stx#1925, stacksjs/stx#1926).
|
|
11
|
+
*
|
|
12
|
+
* The failure points the wrong way, which is what made it expensive. Listing
|
|
13
|
+
* every declaration file — the obvious move, and what "repeatable" invites —
|
|
14
|
+
* lands on the UNHELPED baseline, because the one file that was helping got
|
|
15
|
+
* replaced by one that does not cover those names. That reads as "the flag does
|
|
16
|
+
* nothing" rather than "the flag is dropping all but one of my files", and it
|
|
17
|
+
* changes which errors are reported rather than merely how many: names that
|
|
18
|
+
* would resolve come back as `Cannot find name`, hiding the real diagnostics
|
|
19
|
+
* underneath them.
|
|
20
|
+
*
|
|
21
|
+
* So the values are read from argv, where all of them still are.
|
|
22
|
+
*
|
|
23
|
+
* @module cli-flags
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Every value given for `flag`, in the order written.
|
|
27
|
+
*
|
|
28
|
+
* Accepts both spellings — `--lib a` and `--lib=a` — because a user who has
|
|
29
|
+
* been told a flag repeats will reasonably try either.
|
|
30
|
+
*
|
|
31
|
+
* Values are returned verbatim; resolving them against a directory is the
|
|
32
|
+
* caller's business, since it is the caller that knows what they name.
|
|
33
|
+
*/
|
|
34
|
+
export declare function collectRepeatedFlag(argv: readonly string[], flag: string): string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function collectRepeatedFlag(argv, flag) {
|
|
2
|
+
const values = [], inline = `${flag}=`;
|
|
3
|
+
for (let i = 0;i < argv.length; i++) {
|
|
4
|
+
const arg = argv[i];
|
|
5
|
+
if (arg.startsWith(inline)) {
|
|
6
|
+
const value = arg.slice(inline.length);
|
|
7
|
+
if (value)
|
|
8
|
+
values.push(value);
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (arg === flag) {
|
|
12
|
+
const next = argv[i + 1];
|
|
13
|
+
if (next !== void 0 && !next.startsWith("-")) {
|
|
14
|
+
values.push(next);
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return values;
|
|
20
|
+
}
|