@stacksjs/stx 0.2.518 → 0.2.520
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/browser-auto-imports.d.ts +26 -0
- package/dist/browser-core-imports.d.ts +2 -0
- package/dist/browser-core-imports.js +9 -0
- package/dist/{chunk-vttn2f29.js → chunk-02fry4k9.js} +5 -5
- package/dist/{chunk-cqew3ncd.js → chunk-0d9znrk3.js} +1 -1
- package/dist/{chunk-n71n8p3y.js → chunk-0rc0zanq.js} +2 -2
- package/dist/{chunk-37e1q4ae.js → chunk-0sc4hfpz.js} +1 -1
- package/dist/{chunk-9swdmq75.js → chunk-10n5sjnc.js} +1 -1
- package/dist/{chunk-0htvtbzm.js → chunk-28jnw45c.js} +1 -1
- package/dist/{chunk-zzncg4wf.js → chunk-2r852nze.js} +1 -1
- package/dist/{chunk-m30ewf97.js → chunk-2xjf207h.js} +1 -1
- package/dist/{chunk-8qzf351f.js → chunk-383fpjag.js} +1 -1
- package/dist/{chunk-yybzcsjv.js → chunk-3rt07ec9.js} +1 -1
- package/dist/{chunk-bc0cqsdj.js → chunk-49mkn02f.js} +1 -1
- package/dist/{chunk-emeagz5v.js → chunk-4ka1vqzc.js} +28 -19
- package/dist/{chunk-x3q3m68s.js → chunk-5pwdgk0p.js} +1 -1
- package/dist/chunk-5r2t5mj7.js +45 -0
- package/dist/{chunk-add8tq7t.js → chunk-5snae0x9.js} +4 -1
- package/dist/{chunk-yhdm4hjn.js → chunk-7wp5r7er.js} +1 -1
- package/dist/{chunk-3vyytftg.js → chunk-8b1g1dyc.js} +1 -1
- package/dist/{chunk-126hx5ap.js → chunk-8e062ckg.js} +1 -1
- package/dist/{chunk-ygw7gy87.js → chunk-8yzj60vj.js} +1 -1
- package/dist/{chunk-5dec5axq.js → chunk-bhah6ngn.js} +1 -1
- package/dist/chunk-bj98tbj4.js +2 -0
- package/dist/{chunk-1yq77yd0.js → chunk-bv9bf961.js} +1 -1
- package/dist/{chunk-ybx8g5yz.js → chunk-c311fczy.js} +1 -1
- package/dist/{chunk-ggmyw0r5.js → chunk-dgd0pedw.js} +2 -2
- package/dist/{chunk-vg0p8ayq.js → chunk-ebx5vyzv.js} +1 -1
- package/dist/{chunk-rb50ynhz.js → chunk-emhqzh0r.js} +1 -1
- package/dist/{chunk-tskmjte2.js → chunk-eyq96y73.js} +1 -1
- package/dist/{chunk-zsffrenb.js → chunk-f8sp9dpx.js} +1 -1
- package/dist/{chunk-05xgkzf2.js → chunk-fgvhepsg.js} +1 -1
- package/dist/{chunk-neqa5a6e.js → chunk-hrxj9rvt.js} +1 -1
- package/dist/chunk-j39n1p72.js +2 -0
- package/dist/{chunk-2rdkqw3h.js → chunk-jv96mqj5.js} +1 -1
- package/dist/{chunk-m9nfj8f6.js → chunk-jvygw613.js} +1 -1
- package/dist/{chunk-65vzx4g9.js → chunk-krmfkjmr.js} +1 -1
- package/dist/{chunk-ras8by6q.js → chunk-kwkhhb3p.js} +1 -1
- package/dist/{chunk-nw67298j.js → chunk-m49ar4nx.js} +1 -1
- package/dist/{chunk-6qw0asrf.js → chunk-mdfggh1k.js} +2 -2
- package/dist/{chunk-b5v1pcvm.js → chunk-mqhc108n.js} +1 -1
- package/dist/{chunk-sxscn7pq.js → chunk-nne0200a.js} +1 -1
- package/dist/chunk-ssq3veat.js +2 -0
- package/dist/{chunk-80ra7wyd.js → chunk-tqyv643n.js} +1 -1
- package/dist/{chunk-tgdhp919.js → chunk-v0pm4sb7.js} +1 -1
- package/dist/{chunk-zr1ahw61.js → chunk-v5hx02q8.js} +1 -1
- package/dist/{chunk-mtk2q1q3.js → chunk-vgjeneva.js} +1 -1
- package/dist/{chunk-dqg7bkwe.js → chunk-w6chh1c7.js} +1 -1
- package/dist/{chunk-enr94pyd.js → chunk-wjnt2rxg.js} +1 -1
- package/dist/{chunk-9k6fyv36.js → chunk-wkrpxnfa.js} +1 -1
- package/dist/{chunk-mhj2jz38.js → chunk-wvgr7d7p.js} +1 -1
- package/dist/{chunk-9tdvebc4.js → chunk-xa3sy06t.js} +1 -1
- package/dist/{chunk-w5rc9m3q.js → chunk-xyqw5y8g.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/client-script.js +10 -1
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/component-mapping.js +3 -0
- package/dist/native/compiler/html-to-ir.js +3 -0
- package/dist/native/compiler/ir.d.ts +3 -0
- package/dist/native/compiler/svg.d.ts +7 -0
- package/dist/native/compiler/svg.js +144 -0
- package/dist/native/components/primitives.d.ts +32 -0
- package/dist/native/components/primitives.js +3 -0
- package/dist/native/index.d.ts +4 -0
- package/dist/native/primitives/Map.stx +2 -0
- package/dist/native/primitives/MapMarker.stx +2 -0
- package/dist/native/primitives/MapPolyline.stx +2 -0
- package/dist/native/prop-names.js +11 -1
- package/dist/native/runtime/native-host.d.ts +1 -0
- package/dist/native/runtime/native-host.js +23 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +4 -1
- package/dist/ssg.js +2 -2
- package/dist/stx.d.ts +2 -0
- package/package.json +6 -5
- package/stx.d.ts +2 -0
- package/dist/chunk-4k5nq79j.js +0 -45
- package/dist/chunk-6xjx6gsh.js +0 -2
- package/dist/chunk-9m7vsjwa.js +0 -2
- package/dist/chunk-kfkbkvh1.js +0 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { STXNode } from './ir';
|
|
1
2
|
/** `"0 0 320 180"` (or with commas) to four numbers, or null. */
|
|
2
3
|
export declare function parseViewBox(value: unknown): [number, number, number, number] | null;
|
|
3
4
|
/** Path data to absolute commands. Unknown or malformed parts end the path, as a browser does. */
|
|
@@ -9,6 +10,12 @@ export declare function pathGeometry(d: string): number[];
|
|
|
9
10
|
export declare function svgGeometry(type: string, props: Record<string, unknown>): number[] | null;
|
|
10
11
|
/** Whether changing `attribute` on a `type` node changes its outline. */
|
|
11
12
|
export declare function affectsGeometry(type: string, attribute: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Parse an SVG fragment that arrived at runtime into the same IR used for
|
|
15
|
+
* inline SVG. This deliberately has no DOM or Bun dependency: native screens
|
|
16
|
+
* run in JavaScriptCore, where the markup often came from an API response.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseSvgMarkup(markup: string): STXNode[];
|
|
12
19
|
/**
|
|
13
20
|
* Vector drawing for native screens: `<svg>` and the shapes inside it.
|
|
14
21
|
*
|
|
@@ -412,3 +412,147 @@ export function svgGeometry(type, props) {
|
|
|
412
412
|
export function affectsGeometry(type, attribute) {
|
|
413
413
|
return SVG_GEOMETRY_ATTRIBUTES[type]?.includes(attribute) ?? !1;
|
|
414
414
|
}
|
|
415
|
+
export function parseSvgMarkup(markup) {
|
|
416
|
+
const roots = [], stack = [];
|
|
417
|
+
let cursor = 0;
|
|
418
|
+
const decode = (value) => value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;|'/gi, "'").replace(/&/g, "&"), camel = (name) => {
|
|
419
|
+
const lower = name.toLowerCase();
|
|
420
|
+
return {
|
|
421
|
+
viewbox: "viewBox",
|
|
422
|
+
preserveaspectratio: "preserveAspectRatio",
|
|
423
|
+
"stroke-width": "strokeWidth",
|
|
424
|
+
"stroke-dasharray": "strokeDasharray",
|
|
425
|
+
"stroke-dashoffset": "strokeDashoffset",
|
|
426
|
+
"stroke-linecap": "strokeLinecap",
|
|
427
|
+
"stroke-linejoin": "strokeLinejoin",
|
|
428
|
+
"stroke-miterlimit": "strokeMiterlimit",
|
|
429
|
+
"stroke-opacity": "strokeOpacity",
|
|
430
|
+
"fill-opacity": "fillOpacity",
|
|
431
|
+
"fill-rule": "fillRule",
|
|
432
|
+
"vector-effect": "vectorEffect",
|
|
433
|
+
"text-anchor": "textAnchor",
|
|
434
|
+
"dominant-baseline": "dominantBaseline",
|
|
435
|
+
"font-size": "fontSize",
|
|
436
|
+
"font-weight": "fontWeight"
|
|
437
|
+
}[lower] ?? lower.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
438
|
+
}, valueOf = (name, value) => {
|
|
439
|
+
const decoded = decode(value);
|
|
440
|
+
if (name === "viewBox")
|
|
441
|
+
return parseViewBox(decoded) ?? decoded;
|
|
442
|
+
if (name === "strokeDasharray")
|
|
443
|
+
return decoded.split(/[\s,]+/).map(Number).filter(Number.isFinite);
|
|
444
|
+
if (/^(?:[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)$/i.test(decoded.trim()))
|
|
445
|
+
return Number(decoded);
|
|
446
|
+
return decoded;
|
|
447
|
+
}, styleOf = (value) => {
|
|
448
|
+
const style = {}, styleRecord = style;
|
|
449
|
+
for (const declaration of decode(value).split(";")) {
|
|
450
|
+
const separator = declaration.indexOf(":");
|
|
451
|
+
if (separator < 1)
|
|
452
|
+
continue;
|
|
453
|
+
const name = camel(declaration.slice(0, separator).trim()), raw = declaration.slice(separator + 1).trim();
|
|
454
|
+
styleRecord[name] = /^-?(?:\d+\.?\d*|\.\d+)$/.test(raw) ? Number(raw) : raw;
|
|
455
|
+
}
|
|
456
|
+
return style;
|
|
457
|
+
}, attributesOf = (source) => {
|
|
458
|
+
const props = {}, style = {};
|
|
459
|
+
let classes = "";
|
|
460
|
+
const attribute = /([^\s=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?/g;
|
|
461
|
+
let match;
|
|
462
|
+
while (match = attribute.exec(source)) {
|
|
463
|
+
const rawName = match[1].toLowerCase(), rawValue = match[2] ?? match[3] ?? match[4] ?? "";
|
|
464
|
+
if (rawName === "class") {
|
|
465
|
+
classes = decode(rawValue);
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (rawName === "style") {
|
|
469
|
+
Object.assign(style, styleOf(rawValue));
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
if (rawName === "data-native" || rawName.startsWith("data-stx-"))
|
|
473
|
+
continue;
|
|
474
|
+
props[camel(rawName)] = valueOf(camel(rawName), rawValue);
|
|
475
|
+
}
|
|
476
|
+
return { props, style, classes };
|
|
477
|
+
}, endOfTag = (start) => {
|
|
478
|
+
let quote = "";
|
|
479
|
+
for (let i = start;i < markup.length; i++) {
|
|
480
|
+
const character = markup[i];
|
|
481
|
+
if (quote) {
|
|
482
|
+
if (character === quote)
|
|
483
|
+
quote = "";
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (character === '"' || character === "'") {
|
|
487
|
+
quote = character;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (character === ">")
|
|
491
|
+
return i;
|
|
492
|
+
}
|
|
493
|
+
return markup.length - 1;
|
|
494
|
+
}, append = (node) => {
|
|
495
|
+
const parent = stack[stack.length - 1];
|
|
496
|
+
if (parent?.node && !parent.dropped)
|
|
497
|
+
parent.node.children.push(node);
|
|
498
|
+
else if (!parent)
|
|
499
|
+
roots.push(node);
|
|
500
|
+
};
|
|
501
|
+
while (cursor < markup.length) {
|
|
502
|
+
const open = markup.indexOf("<", cursor);
|
|
503
|
+
if (open === -1) {
|
|
504
|
+
const text = decode(markup.slice(cursor)).replace(/\s+/g, " ");
|
|
505
|
+
if (text.trim() && stack[stack.length - 1]?.node && !stack[stack.length - 1].dropped)
|
|
506
|
+
stack[stack.length - 1].node.children.push(text);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
if (open > cursor) {
|
|
510
|
+
const text = decode(markup.slice(cursor, open)).replace(/\s+/g, " ");
|
|
511
|
+
if (text.trim() && stack[stack.length - 1]?.node && !stack[stack.length - 1].dropped)
|
|
512
|
+
stack[stack.length - 1].node.children.push(text);
|
|
513
|
+
}
|
|
514
|
+
const close = endOfTag(open + 1), token = markup.slice(open + 1, close).trim();
|
|
515
|
+
cursor = close + 1;
|
|
516
|
+
if (!token || token.startsWith("!") || token.startsWith("?"))
|
|
517
|
+
continue;
|
|
518
|
+
if (token.startsWith("/")) {
|
|
519
|
+
const tag = token.slice(1).trim().toLowerCase();
|
|
520
|
+
while (stack.length)
|
|
521
|
+
if (stack.pop().tag === tag)
|
|
522
|
+
break;
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
const selfClosing = token.endsWith("/"), source = selfClosing ? token.slice(0, -1).trim() : token, name = source.match(/^([^\s/>]+)/)?.[1]?.toLowerCase();
|
|
526
|
+
if (!name)
|
|
527
|
+
continue;
|
|
528
|
+
const parentDropped = stack[stack.length - 1]?.dropped ?? !1, type = SVG_TYPES[name];
|
|
529
|
+
if (parentDropped || SVG_DROPPED.has(name) || !type) {
|
|
530
|
+
if (!selfClosing)
|
|
531
|
+
stack.push({ tag: name, dropped: !0 });
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
const parsed = attributesOf(source.slice(name.length)), node = {
|
|
535
|
+
type,
|
|
536
|
+
props: parsed.props,
|
|
537
|
+
style: parsed.style,
|
|
538
|
+
events: {},
|
|
539
|
+
children: [],
|
|
540
|
+
_inlineStyle: { ...parsed.style }
|
|
541
|
+
};
|
|
542
|
+
if (parsed.classes)
|
|
543
|
+
node._classes = parsed.classes;
|
|
544
|
+
if (type === "Svg")
|
|
545
|
+
for (const axis of ["width", "height"]) {
|
|
546
|
+
if (typeof node.props[axis] === "number" && node.style[axis] === void 0)
|
|
547
|
+
node.style[axis] = node.props[axis];
|
|
548
|
+
delete node.props[axis];
|
|
549
|
+
}
|
|
550
|
+
const geometry = svgGeometry(type, node.props);
|
|
551
|
+
if (geometry)
|
|
552
|
+
node.props.geometry = geometry;
|
|
553
|
+
append(node);
|
|
554
|
+
if (!selfClosing)
|
|
555
|
+
stack.push({ tag: name, node, dropped: !1 });
|
|
556
|
+
}
|
|
557
|
+
return roots;
|
|
558
|
+
}
|
|
@@ -20,6 +20,9 @@ export declare const ComponentRegistry: {
|
|
|
20
20
|
Image: 'Image';
|
|
21
21
|
ImageBackground: 'ImageBackground';
|
|
22
22
|
Video: 'Video';
|
|
23
|
+
Map: 'Map';
|
|
24
|
+
MapPolyline: 'MapPolyline';
|
|
25
|
+
MapMarker: 'MapMarker';
|
|
23
26
|
FlatList: 'FlatList';
|
|
24
27
|
SectionList: 'SectionList';
|
|
25
28
|
Modal: 'Modal';
|
|
@@ -230,6 +233,35 @@ export declare interface ImageBackgroundProps extends ImageProps {
|
|
|
230
233
|
imageStyle?: STXStyle
|
|
231
234
|
}
|
|
232
235
|
// ============================================================================
|
|
236
|
+
// Map Components
|
|
237
|
+
// ============================================================================
|
|
238
|
+
export declare interface MapRegion {
|
|
239
|
+
center: { latitude: number; longitude: number }
|
|
240
|
+
span: { latitudeDelta: number; longitudeDelta: number }
|
|
241
|
+
}
|
|
242
|
+
export declare interface MapProps extends BaseProps {
|
|
243
|
+
region?: MapRegion
|
|
244
|
+
fitToBounds?: boolean
|
|
245
|
+
showsUserLocation?: boolean
|
|
246
|
+
scrollEnabled?: boolean
|
|
247
|
+
zoomEnabled?: boolean
|
|
248
|
+
rotateEnabled?: boolean
|
|
249
|
+
mapType?: 'standard' | 'satellite' | 'hybrid' | 'terrain'
|
|
250
|
+
onMarkerPress?: (event: { nativeEvent: { id: string } }) => void
|
|
251
|
+
}
|
|
252
|
+
export declare interface MapPolylineProps extends BaseProps {
|
|
253
|
+
geometry: number[]
|
|
254
|
+
strokeColor?: string
|
|
255
|
+
strokeWidth?: number
|
|
256
|
+
}
|
|
257
|
+
export declare interface MapMarkerProps extends BaseProps {
|
|
258
|
+
geometry: number[]
|
|
259
|
+
id: string
|
|
260
|
+
title?: string
|
|
261
|
+
onPress?: (event: { nativeEvent: { id: string } }) => void
|
|
262
|
+
onMarkerPress?: (event: { nativeEvent: { id: string } }) => void
|
|
263
|
+
}
|
|
264
|
+
// ============================================================================
|
|
233
265
|
// List Components
|
|
234
266
|
// ============================================================================
|
|
235
267
|
export declare interface FlatListProps<T> extends ScrollViewProps {
|
|
@@ -18,6 +18,9 @@ export const ComponentRegistry = {
|
|
|
18
18
|
Image: "Image",
|
|
19
19
|
ImageBackground: "ImageBackground",
|
|
20
20
|
Video: "Video",
|
|
21
|
+
Map: "Map",
|
|
22
|
+
MapPolyline: "MapPolyline",
|
|
23
|
+
MapMarker: "MapMarker",
|
|
21
24
|
FlatList: "FlatList",
|
|
22
25
|
SectionList: "SectionList",
|
|
23
26
|
Modal: "Modal",
|
package/dist/native/index.d.ts
CHANGED
|
@@ -70,6 +70,12 @@ const NATIVE_PROP_NAMES = [
|
|
|
70
70
|
"trackColor",
|
|
71
71
|
"underlayColor",
|
|
72
72
|
"windowSize",
|
|
73
|
+
"fitToBounds",
|
|
74
|
+
"showsUserLocation",
|
|
75
|
+
"zoomEnabled",
|
|
76
|
+
"rotateEnabled",
|
|
77
|
+
"mapType",
|
|
78
|
+
"strokeColor",
|
|
73
79
|
"autoScrollBottom",
|
|
74
80
|
"scrollKey"
|
|
75
81
|
];
|
|
@@ -97,7 +103,11 @@ export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
|
97
103
|
"showsHorizontalScrollIndicator",
|
|
98
104
|
"showsVerticalScrollIndicator",
|
|
99
105
|
"transparent",
|
|
100
|
-
"visible"
|
|
106
|
+
"visible",
|
|
107
|
+
"fitToBounds",
|
|
108
|
+
"showsUserLocation",
|
|
109
|
+
"zoomEnabled",
|
|
110
|
+
"rotateEnabled"
|
|
101
111
|
]);
|
|
102
112
|
const nativePropNames = new Map(NATIVE_PROP_NAMES.map((name) => [normaliseKey(name), name]));
|
|
103
113
|
function normaliseKey(name) {
|
|
@@ -19,6 +19,7 @@ export declare interface NativeHost {
|
|
|
19
19
|
readonly isNative: true
|
|
20
20
|
setColorScheme: (scheme: 'light' | 'dark') => void
|
|
21
21
|
setText: (node: NativeNode, value: unknown) => void
|
|
22
|
+
setMarkup: (node: NativeNode, value: unknown) => void
|
|
22
23
|
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
23
24
|
removeAttribute: (node: NativeNode, name: string) => void
|
|
24
25
|
setStyle: (node: NativeNode, value: unknown) => void
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compileClassStyles } from "../compiler/headwind-to-style.js";
|
|
2
2
|
import { resolveIconName } from "../compiler/icons.js";
|
|
3
|
-
import { affectsGeometry, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
3
|
+
import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
4
4
|
import { nativePropName } from "../prop-names.js";
|
|
5
5
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
6
6
|
function eventAt(payload, node) {
|
|
@@ -13,6 +13,7 @@ function eventAt(payload, node) {
|
|
|
13
13
|
}
|
|
14
14
|
export const HOST_METHODS = [
|
|
15
15
|
"setText",
|
|
16
|
+
"setMarkup",
|
|
16
17
|
"setAttribute",
|
|
17
18
|
"removeAttribute",
|
|
18
19
|
"setStyle",
|
|
@@ -338,6 +339,27 @@ export function createNativeHost(options) {
|
|
|
338
339
|
if (record.materialized)
|
|
339
340
|
emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
|
|
340
341
|
},
|
|
342
|
+
setMarkup(node, value) {
|
|
343
|
+
const record = recordOf(node), markup = value == null ? "" : String(value);
|
|
344
|
+
if (record.markup === markup)
|
|
345
|
+
return;
|
|
346
|
+
for (const child of [...record.children])
|
|
347
|
+
this.remove(child);
|
|
348
|
+
record.markup = markup;
|
|
349
|
+
for (const source of parseSvgMarkup(markup)) {
|
|
350
|
+
const materializeMarkup = (parent, descriptor) => {
|
|
351
|
+
const child = { __stxId: nextId("n") };
|
|
352
|
+
decoratePosition(child);
|
|
353
|
+
adopt(child, descriptor.type, null, descriptor);
|
|
354
|
+
records.get(child.__stxId).materialized = !1;
|
|
355
|
+
this.insert(parent, child);
|
|
356
|
+
for (const nested of descriptor.children)
|
|
357
|
+
if (typeof nested !== "string")
|
|
358
|
+
materializeMarkup(child, nested);
|
|
359
|
+
};
|
|
360
|
+
materializeMarkup(node, source);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
341
363
|
setAttribute(node, name, value) {
|
|
342
364
|
if (name === "class" || name === "className") {
|
|
343
365
|
const record = recordOf(node);
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Ln,Oe,Bo,Wa}from"./chunk-4c1afy15.js";import{Nn,Vr,Ha,Va,Ua}from"./chunk-jbvg29t0.js";import{No,Lo,jo,Fa,za}from"./chunk-e62nw7zk.js";import{oe,gt,Ur}from"./chunk-hkjqqx92.js";import{Xc,Gc,Jc,Yc,fr,mu}from"./chunk-3ynfz6h8.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-49mkn02f.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
package/dist/signals.js
CHANGED
|
@@ -81,6 +81,7 @@ console.log('[stx] entering IIFE');
|
|
|
81
81
|
// exactly as it was: same calls, one property lookup earlier.
|
|
82
82
|
var stxHost = window.__stx_host || {
|
|
83
83
|
setText: function(node, value) { node.textContent = value; },
|
|
84
|
+
setMarkup: function(node, value) { node.innerHTML = value == null ? '' : value; },
|
|
84
85
|
setAttribute: function(node, name, value) {
|
|
85
86
|
if (value === false) { node.removeAttribute(name); return; }
|
|
86
87
|
if (value === true) { node.setAttribute(name, ''); return; }
|
|
@@ -3416,7 +3417,9 @@ else if (name === '@html' || name === ':html' || name === 'x-html') {
|
|
|
3416
3417
|
effect(() => {
|
|
3417
3418
|
// Coerce null/undefined to '' so a missing/unresolved binding renders
|
|
3418
3419
|
// nothing rather than the literal string "undefined" (#1767).
|
|
3419
|
-
|
|
3420
|
+
var markup = evalAttrExpr(value) ?? '';
|
|
3421
|
+
if (stxHost.isNative && stxHost.setMarkup) stxHost.setMarkup(el, markup);
|
|
3422
|
+
else el.innerHTML = markup;
|
|
3420
3423
|
});
|
|
3421
3424
|
el.removeAttribute(name);
|
|
3422
3425
|
}
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-2hc5mbw8.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import{et,tt,nt,rt,st,ot}from"./chunk-1aw9qbdf.js";import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import{f,Be,N,K,n,o}from"./chunk-
|
|
2
|
+
import"./chunk-2hc5mbw8.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import{et,tt,nt,rt,st,ot}from"./chunk-1aw9qbdf.js";import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import{f,Be,N,K,n,o}from"./chunk-4ka1vqzc.js";import"./chunk-gynes6rm.js";import{nr}from"./chunk-gbfap7rv.js";import"./chunk-6k4f583z.js";import"./chunk-c311fczy.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import"./chunk-8e062ckg.js";import{ie,mt,ht}from"./chunk-krmfkjmr.js";import{Do,Oo,Mo}from"./chunk-er7y8hk9.js";import{ft,Yt,Zt}from"./chunk-g7ey7mtw.js";import"./chunk-fxxrrq9n.js";import{a}from"./chunk-dne8n6h3.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function wt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
3
|
`)}class yt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class St{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
@@ -41,7 +41,7 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now();ht();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(wt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();ht();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(wt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-5pwdgk0p.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-0sc4hfpz.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new yt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-5pwdgk0p.js");await u('<div class="bg-black"></div>')}catch{}et();let vt=s?.routeMiddleware?.dir||"middleware";await nt(process.cwd(),vt);let H=tt();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let bt=s?.routeMiddleware?.global||[];Mo(s?.layoutsDir,a(process.cwd()));let V=N(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let _=[];for(let u of V){let m=await Ot(u);for(let v of m)_.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=_.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<_.length;u+=e.concurrency)X.push(_.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],it=[...bt,...$t];if(it.length>0){let C=rt(d,L,F||{}),O=st(C,null,void 0,{isServer:!0}),E=await ot(it,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,U=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,U),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(U),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let at=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(at)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${at[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ct=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ct=!0,l.cachedCount++}if(!k){let C=await xt(v,L,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
package/dist/stx.d.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* packages/stx/src/signals.ts → window.stx = { ... }
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/// <reference path="./browser-auto-imports.d.ts" />
|
|
21
|
+
|
|
20
22
|
// ============================================================================
|
|
21
23
|
// Module declarations
|
|
22
24
|
// ============================================================================
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.520",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"README.md",
|
|
90
90
|
"dist",
|
|
91
91
|
"stx.d.ts",
|
|
92
|
+
"browser-auto-imports.d.ts",
|
|
92
93
|
"stx-module.d.ts"
|
|
93
94
|
],
|
|
94
95
|
"scripts": {
|
|
@@ -122,12 +123,12 @@
|
|
|
122
123
|
"dependencies": {
|
|
123
124
|
"@stacksjs/ts-css": "^0.3.11",
|
|
124
125
|
"@stacksjs/clapp": "^0.2.16",
|
|
125
|
-
"@stacksjs/desktop": "0.2.
|
|
126
|
-
"@stacksjs/sanitizer": "0.2.
|
|
126
|
+
"@stacksjs/desktop": "0.2.520",
|
|
127
|
+
"@stacksjs/sanitizer": "0.2.520",
|
|
127
128
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
128
|
-
"bun-plugin-stx": "0.2.
|
|
129
|
+
"bun-plugin-stx": "0.2.520",
|
|
129
130
|
"bunfig": "^0.15.19",
|
|
130
|
-
"stx-router": "0.2.
|
|
131
|
+
"stx-router": "0.2.520",
|
|
131
132
|
"ts-broadcasting": "^0.0.11",
|
|
132
133
|
"ts-images": "^0.2.22",
|
|
133
134
|
"ts-syntax-highlighter": "^0.2.1"
|
package/stx.d.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* packages/stx/src/signals.ts → window.stx = { ... }
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/// <reference path="./browser-auto-imports.d.ts" />
|
|
21
|
+
|
|
20
22
|
// ============================================================================
|
|
21
23
|
// Module declarations
|
|
22
24
|
// ============================================================================
|