@stacksjs/stx 0.2.791 → 0.2.793
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/chunk-0a9ceqa8.js +2 -0
- package/dist/{chunk-vqwxv8ck.js → chunk-0cm94ksp.js} +1 -1
- package/dist/{chunk-894fga23.js → chunk-0ppx28f6.js} +1 -1
- package/dist/{chunk-064faxda.js → chunk-0ykteae5.js} +1 -1
- package/dist/{chunk-c046mq5d.js → chunk-1aent61q.js} +1 -1
- package/dist/{chunk-4vj99vqh.js → chunk-1pbyr47e.js} +1 -1
- package/dist/{chunk-xxkxk6j2.js → chunk-1z9hbzpk.js} +1 -1
- package/dist/chunk-22z2cwhv.js +2 -0
- package/dist/{chunk-98bxcss9.js → chunk-276e3d0g.js} +1 -1
- package/dist/chunk-27vn4674.js +2 -0
- package/dist/{chunk-09ybdmk1.js → chunk-2hwwmn7c.js} +3 -3
- package/dist/{chunk-xfnj17kd.js → chunk-44ep7dkr.js} +1 -1
- package/dist/{chunk-3tmcmbj6.js → chunk-44tq4d62.js} +1 -1
- package/dist/chunk-499v1ade.js +2 -0
- package/dist/{chunk-a8sb2jwq.js → chunk-4cffjp4f.js} +6 -6
- package/dist/{chunk-axfz9jcz.js → chunk-4de6rhaj.js} +2 -2
- package/dist/{chunk-mbm6vg8r.js → chunk-4gx5ze56.js} +1 -1
- package/dist/{chunk-gvr9kdqp.js → chunk-55j4jxwe.js} +5 -5
- package/dist/chunk-55wsqxfk.js +2 -0
- package/dist/{chunk-a3v7jkp6.js → chunk-56yhvhjq.js} +2 -2
- package/dist/{chunk-838nk7ad.js → chunk-5pe7wcvh.js} +1 -1
- package/dist/chunk-5y5k6x3r.js +2 -0
- package/dist/{chunk-dmkaaf3k.js → chunk-628jcm1d.js} +1 -1
- package/dist/{chunk-x4ssghte.js → chunk-66r0f799.js} +1 -1
- package/dist/{chunk-m58ga249.js → chunk-6h7yhyb8.js} +1 -1
- package/dist/{chunk-q5jxnqfr.js → chunk-6jx0trea.js} +4 -4
- package/dist/{chunk-e4x4q5rf.js → chunk-6jzqzap6.js} +4 -4
- package/dist/{chunk-ahvtsmj7.js → chunk-7fx8p9w5.js} +1 -1
- package/dist/{chunk-np7ryj86.js → chunk-7yb8943c.js} +1 -1
- package/dist/{chunk-sc5fx7vj.js → chunk-8698v9gf.js} +1 -1
- package/dist/{chunk-fdafgcxp.js → chunk-98308vtv.js} +1 -1
- package/dist/{chunk-3a5qnt2f.js → chunk-a1ynjj47.js} +21 -4
- package/dist/{chunk-khjcp7jn.js → chunk-a4cse2tj.js} +1 -1
- package/dist/{chunk-p3qx6bhx.js → chunk-ad2fk303.js} +1 -1
- package/dist/{chunk-efpsvjp9.js → chunk-bb2zfgwf.js} +2 -2
- package/dist/{chunk-j3qpzk2g.js → chunk-brqcepmv.js} +1 -1
- package/dist/{chunk-pa785cdg.js → chunk-bxxgr5c5.js} +1 -1
- package/dist/{chunk-mafav2b3.js → chunk-c2qwbej3.js} +2 -2
- package/dist/{chunk-40tsja2j.js → chunk-ddbkw53b.js} +1 -1
- package/dist/{chunk-qm79fkj3.js → chunk-dtnyrjcj.js} +1 -1
- package/dist/chunk-dyp0kgmr.js +177 -0
- package/dist/chunk-fc384a2h.js +2 -0
- package/dist/{chunk-4jxfd333.js → chunk-g3z2g6hm.js} +1 -1
- package/dist/{chunk-4pkhz90f.js → chunk-g7anxh36.js} +1 -1
- package/dist/{chunk-njse2cjy.js → chunk-g89fx9rq.js} +4 -4
- package/dist/{chunk-j0ye6whq.js → chunk-gg71gm25.js} +1 -1
- package/dist/{chunk-s5cmn70z.js → chunk-gnydrw29.js} +1 -1
- package/dist/{chunk-kpreycjr.js → chunk-hs9fzxn0.js} +1 -1
- package/dist/{chunk-8vq5w11w.js → chunk-j4s5k8sp.js} +2 -2
- package/dist/chunk-jkm34gec.js +2 -0
- package/dist/{chunk-f5zktb21.js → chunk-js5zve3p.js} +1 -1
- package/dist/chunk-k3mcb700.js +3 -0
- package/dist/{chunk-8ft5vgp3.js → chunk-m997knnz.js} +1 -1
- package/dist/{chunk-tkyqm6tq.js → chunk-ncxed9r1.js} +1 -1
- package/dist/chunk-nptp3x62.js +2 -0
- package/dist/{chunk-c2s10cg6.js → chunk-qd9f47ds.js} +1 -1
- package/dist/{chunk-hmncyjhc.js → chunk-r2nvxbjc.js} +1 -1
- package/dist/{chunk-xwqkmkvw.js → chunk-spt5kmb2.js} +1 -1
- package/dist/{chunk-sqq3hqpb.js → chunk-syheccfj.js} +1 -1
- package/dist/chunk-t8vtf522.js +2 -0
- package/dist/{chunk-nmpkabry.js → chunk-t9744tty.js} +1 -1
- package/dist/{chunk-sg63qj3m.js → chunk-vaqqch06.js} +1 -1
- package/dist/{chunk-bnpckvpq.js → chunk-vj59es75.js} +1 -1
- package/dist/{chunk-64g7z2m2.js → chunk-xadd911n.js} +1 -1
- package/dist/{chunk-xws9e6j9.js → chunk-xc0vws7m.js} +2 -2
- package/dist/{chunk-07fj6472.js → chunk-zsjw2jgy.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/client/signals-component-hydration-runtime.js +3 -1
- package/dist/client/signals-component-props-runtime.js +1 -1
- package/dist/client/signals-expression-compiler-runtime.js +4 -1
- package/dist/client/signals-expression-runtime.js +3 -1
- package/dist/client/signals-pipe-runtime.js +10 -0
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/class-table.d.ts +24 -0
- package/dist/native/compiler/class-table.js +46 -0
- package/dist/native/compiler/headwind-to-style.d.ts +4 -0
- package/dist/native/compiler/headwind-to-style.js +23 -7
- package/dist/native/compiler/inline-style.d.ts +0 -1
- package/dist/native/compiler/inline-style.js +5 -1
- package/dist/native/compiler/ir.d.ts +2 -0
- package/dist/native/compiler/render-screen.js +4 -0
- package/dist/native/compiler/style-config.d.ts +2 -0
- package/dist/native/compiler/style-config.js +3 -0
- package/dist/native/runtime/binding-tree.d.ts +10 -5
- package/dist/native/runtime/binding-tree.js +18 -10
- package/dist/native/runtime/native-host.d.ts +4 -0
- package/dist/native/runtime/native-host.js +128 -55
- package/dist/native/runtime/shared-screen.js +1 -0
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-07w4gp1w.js +0 -2
- package/dist/chunk-1ac8dt85.js +0 -2
- package/dist/chunk-1nr15t1f.js +0 -2
- package/dist/chunk-1vr1gw3h.js +0 -2
- package/dist/chunk-513b47g2.js +0 -177
- package/dist/chunk-5c89afzb.js +0 -3
- package/dist/chunk-6g0nqqf5.js +0 -2
- package/dist/chunk-cjwghh53.js +0 -2
- package/dist/chunk-fpxwpxwr.js +0 -2
- package/dist/chunk-h84k7ybc.js +0 -2
- package/dist/chunk-jwt8034r.js +0 -2
- package/dist/chunk-qngta0pe.js +0 -2
|
@@ -2,7 +2,7 @@ import type { BindingManifest } from '../../binding-manifest';
|
|
|
2
2
|
import type { NativeHost, NativeNode } from './native-host';
|
|
3
3
|
import type { STXDocument } from '../compiler/ir';
|
|
4
4
|
/** Clone the DOM-shaped metadata while the host clones the native descriptor. */
|
|
5
|
-
export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string, onClassChange?: (value: string) => void): NativeBindingNode;
|
|
5
|
+
export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string, onClassChange?: (value: string) => void, Element?: BindingElementClass): NativeBindingNode;
|
|
6
6
|
/** Build host handles and a manifest-id lookup from already translated IR. */
|
|
7
7
|
export declare function materializeNativeBindingTree(document: STXDocument, manifest: BindingManifest, host: NativeHost): NativeBindingTree;
|
|
8
8
|
export declare interface NativeBindingNode extends NativeNode {
|
|
@@ -33,13 +33,16 @@ export declare interface NativeBindingTree {
|
|
|
33
33
|
nodes: Map<number, NativeBindingNode>
|
|
34
34
|
scopes: Map<string, NativeBindingNode>
|
|
35
35
|
}
|
|
36
|
+
export type BindingElementClass = new (id: string, type: string, attributes: Array<{ name: string, value: string }>, onClassChange?: (value: string) => void) => BindingElement;
|
|
36
37
|
/**
|
|
37
38
|
* A native node as the shared signals runtime sees it: the DOM element subset
|
|
38
39
|
* it reads and writes. A class, so a screen's hundreds of nodes share their
|
|
39
40
|
* methods; an object literal per node made a dozen closures and accessors for
|
|
40
|
-
* each, which an interpreted engine paid for on every mount.
|
|
41
|
+
* each, which an interpreted engine paid for on every mount. A native host
|
|
42
|
+
* extends it once per screen with its position methods (`measure`,
|
|
43
|
+
* `nextSibling`, ...), so even those cost a node nothing.
|
|
41
44
|
*/
|
|
42
|
-
declare class BindingElement {
|
|
45
|
+
export declare class BindingElement {
|
|
43
46
|
__stxId: string;
|
|
44
47
|
__stxScope: string | undefined;
|
|
45
48
|
nodeType: 1;
|
|
@@ -49,11 +52,13 @@ declare class BindingElement {
|
|
|
49
52
|
parentElement: NativeBindingNode | null;
|
|
50
53
|
childNodes: NativeNode[];
|
|
51
54
|
children: NativeNode[];
|
|
52
|
-
|
|
53
|
-
nextElementSibling: NativeBindingNode | null;
|
|
55
|
+
__stxOwner: NativeNode | null;
|
|
54
56
|
namespaceURI: string;
|
|
55
57
|
isConnected: boolean;
|
|
56
58
|
constructor(id: string, type: string, attributes: Array<{ name: string, value: string }>, onClassChange?: (value: string) => void);
|
|
59
|
+
get nextSibling(): NativeNode | null;
|
|
60
|
+
get nextElementSibling(): NativeBindingNode | null;
|
|
61
|
+
protected classChanged(value: string): void;
|
|
57
62
|
get className(): string;
|
|
58
63
|
set className(value: string);
|
|
59
64
|
get classList(): { add: (...tokens: string[]) => void, remove: (...tokens: string[]) => void };
|
|
@@ -6,7 +6,7 @@ function decodeBindingValue(value) {
|
|
|
6
6
|
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;/g, "'").replace(/'/gi, "'").replace(/&/g, "&");
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
class BindingElement {
|
|
9
|
+
export class BindingElement {
|
|
10
10
|
__stxId;
|
|
11
11
|
__stxScope = void 0;
|
|
12
12
|
nodeType = 1;
|
|
@@ -16,8 +16,7 @@ class BindingElement {
|
|
|
16
16
|
parentElement = null;
|
|
17
17
|
childNodes = [];
|
|
18
18
|
children = [];
|
|
19
|
-
|
|
20
|
-
nextElementSibling = null;
|
|
19
|
+
__stxOwner = null;
|
|
21
20
|
namespaceURI = "";
|
|
22
21
|
isConnected = !0;
|
|
23
22
|
byName;
|
|
@@ -30,6 +29,15 @@ class BindingElement {
|
|
|
30
29
|
this.byName = new Map(attributes.map((attribute) => [attribute.name, attribute]));
|
|
31
30
|
this.onClassChange = onClassChange;
|
|
32
31
|
}
|
|
32
|
+
get nextSibling() {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
get nextElementSibling() {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
classChanged(value) {
|
|
39
|
+
this.onClassChange?.(value);
|
|
40
|
+
}
|
|
33
41
|
get className() {
|
|
34
42
|
return this.getAttribute("class") ?? "";
|
|
35
43
|
}
|
|
@@ -68,7 +76,7 @@ class BindingElement {
|
|
|
68
76
|
this.byName.set(name, attribute);
|
|
69
77
|
}
|
|
70
78
|
if (name === "class")
|
|
71
|
-
this.
|
|
79
|
+
this.classChanged(String(value));
|
|
72
80
|
}
|
|
73
81
|
removeAttribute(name) {
|
|
74
82
|
if (name === "data-stx-scope")
|
|
@@ -79,7 +87,7 @@ class BindingElement {
|
|
|
79
87
|
this.byName.delete(name);
|
|
80
88
|
}
|
|
81
89
|
if (name === "class")
|
|
82
|
-
this.
|
|
90
|
+
this.classChanged("");
|
|
83
91
|
}
|
|
84
92
|
contains(candidate) {
|
|
85
93
|
for (let current = candidate;current; current = current.parentNode)
|
|
@@ -103,24 +111,24 @@ class BindingElement {
|
|
|
103
111
|
return found;
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
|
-
function createBindingNode(id, type, bindings, connected = !0, classes = "", onClassChange) {
|
|
114
|
+
function createBindingNode(id, type, bindings, connected = !0, classes = "", onClassChange, Element = BindingElement) {
|
|
107
115
|
const attributes = bindings.map((binding) => ({
|
|
108
116
|
name: binding.name,
|
|
109
117
|
value: decodeBindingValue(binding.value)
|
|
110
118
|
}));
|
|
111
119
|
if (classes && !attributes.some((attribute) => attribute.name === "class"))
|
|
112
120
|
attributes.push({ name: "class", value: classes });
|
|
113
|
-
const node = new
|
|
121
|
+
const node = new Element(id, type, attributes, onClassChange);
|
|
114
122
|
node.isConnected = connected;
|
|
115
123
|
return node;
|
|
116
124
|
}
|
|
117
|
-
export function cloneNativeBindingNode(source, id, onClassChange) {
|
|
125
|
+
export function cloneNativeBindingNode(source, id, onClassChange, Element) {
|
|
118
126
|
const bindings = source.attributes.map((attribute) => ({
|
|
119
127
|
name: attribute.name,
|
|
120
128
|
value: attribute.value,
|
|
121
129
|
kind: "attr"
|
|
122
130
|
}));
|
|
123
|
-
return createBindingNode(id, source.tagName, bindings, !1, source.className, onClassChange);
|
|
131
|
+
return createBindingNode(id, source.tagName, bindings, !1, source.className, onClassChange, Element);
|
|
124
132
|
}
|
|
125
133
|
export function materializeNativeBindingTree(document, manifest, host) {
|
|
126
134
|
const entries = new Map(manifest.entries.map((entry) => [entry.id, entry])), nodes = new Map, scopes = new Map;
|
|
@@ -130,7 +138,7 @@ export function materializeNativeBindingTree(document, manifest, host) {
|
|
|
130
138
|
for (const [name, value] of Object.entries(source.bindings ?? {}))
|
|
131
139
|
if (!runtimeBindings.some((binding) => binding.name.replace(/^[:@]/, "") === name))
|
|
132
140
|
runtimeBindings.push({ name: `:${name}`, value, kind: "attr" });
|
|
133
|
-
const node = createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
|
|
141
|
+
const node = host.bindingElement ? createBindingNode(id, source.type, runtimeBindings, !0, source._classes, void 0, host.bindingElement) : createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
|
|
134
142
|
if (source.type === "Checkbox" && source.props.type === "checkbox")
|
|
135
143
|
node.tagName = "INPUT";
|
|
136
144
|
if (source.props["data-stx-native-template"])
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type BindingElementClass } from './binding-tree';
|
|
2
|
+
import { type NativeClassTable } from '../compiler/class-table';
|
|
1
3
|
import { type NativeFocusOptions, type NativeViewBounds, type NativeViewOperations } from './view-operations';
|
|
2
4
|
import { type NativeOverlayEntry } from './overlay-presenter';
|
|
3
5
|
import type { NativeMutationOperation } from '../bridge/protocol';
|
|
@@ -20,6 +22,7 @@ export declare interface NativeHostOptions {
|
|
|
20
22
|
viewportWidth?: number
|
|
21
23
|
stylesheetTheme?: NativeStylesheetTheme
|
|
22
24
|
stylesheetRules?: NativeStylesheetRules
|
|
25
|
+
classTable?: NativeClassTable
|
|
23
26
|
pointer?: boolean
|
|
24
27
|
send: (operations: NativeMutationOperation[]) => void
|
|
25
28
|
schedule?: (flush: () => void) => void
|
|
@@ -28,6 +31,7 @@ export declare interface NativeHostOptions {
|
|
|
28
31
|
}
|
|
29
32
|
export declare interface NativeHost {
|
|
30
33
|
readonly isNative: true
|
|
34
|
+
readonly bindingElement?: BindingElementClass
|
|
31
35
|
focus: (node: NativeNode, options?: NativeFocusOptions) => Promise<true>
|
|
32
36
|
measure: (node: NativeNode) => Promise<NativeViewBounds>
|
|
33
37
|
syncOverlays: (entries: NativeOverlayEntry[]) => void
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { accessibilityChanges, authoredAccessibilityProps, projectAccessibility } from "../accessibility.js";
|
|
2
|
+
import { seedClassTable } from "../compiler/class-table.js";
|
|
2
3
|
import { compileClassStyles, NATIVE_STATE_VARIANTS } from "../compiler/headwind-to-style.js";
|
|
3
4
|
import { resolveIconName } from "../compiler/icons.js";
|
|
4
5
|
import { applyNativeLayoutDefaults, parseNativeStyleLayers } from "../compiler/inline-style.js";
|
|
@@ -7,7 +8,7 @@ import { affectsGeometry, applySvgAnimation, parseSvgMarkup, parseViewBox, SVG_A
|
|
|
7
8
|
import { NATIVE_EVENT_NAMES } from "../event-names.js";
|
|
8
9
|
import { nativePropName } from "../prop-names.js";
|
|
9
10
|
import { authoredTextEntryProps, projectTextEntry, TEXT_ENTRY_SOURCES, textEntryChanges } from "../text-entry.js";
|
|
10
|
-
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
11
|
+
import { BindingElement, cloneNativeBindingNode } from "./binding-tree.js";
|
|
11
12
|
import { NATIVE_FORM_ENTRIES } from "./jsc-globals.js";
|
|
12
13
|
import { createNativeOverlayPresenter } from "./overlay-presenter.js";
|
|
13
14
|
import { prepareInitialMedia } from "./initial-media-mutations.js";
|
|
@@ -72,7 +73,10 @@ export function createNativeHost(options) {
|
|
|
72
73
|
return !0;
|
|
73
74
|
return !1;
|
|
74
75
|
};
|
|
75
|
-
let stylesheetVariables = createStyleVariables(options.stylesheetTheme?.[colorScheme] ?? []).computed()
|
|
76
|
+
let stylesheetVariables = createStyleVariables(options.stylesheetTheme?.[colorScheme] ?? []).computed();
|
|
77
|
+
if (options.classTable)
|
|
78
|
+
seedClassTable(options.classTable, colorScheme, stylesheetVariables, options.stylesheetRules);
|
|
79
|
+
let disposed = !1;
|
|
76
80
|
const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), { followLink, linkState } = options, nextId = (prefix) => `${prefix}${++counter}`;
|
|
77
81
|
function notifyAttributes(node, name) {
|
|
78
82
|
for (const observer of attributeObservers.get(node) ?? [])
|
|
@@ -84,6 +88,22 @@ export function createNativeHost(options) {
|
|
|
84
88
|
if (record)
|
|
85
89
|
refreshDividersOf(record);
|
|
86
90
|
}
|
|
91
|
+
function viewCountOf(record) {
|
|
92
|
+
if (record.viewCount === void 0) {
|
|
93
|
+
let count = 0;
|
|
94
|
+
for (const child of record.children)
|
|
95
|
+
if (child.__stxAnchor === void 0)
|
|
96
|
+
count++;
|
|
97
|
+
record.viewCount = count;
|
|
98
|
+
}
|
|
99
|
+
return record.viewCount;
|
|
100
|
+
}
|
|
101
|
+
function lastIndexOfChild(children, id) {
|
|
102
|
+
for (let i = children.length - 1;i >= 0; i--)
|
|
103
|
+
if (children[i].__stxId === id)
|
|
104
|
+
return i;
|
|
105
|
+
return -1;
|
|
106
|
+
}
|
|
87
107
|
function refreshDividersOf(record) {
|
|
88
108
|
if (!record.divide && !record.hadDividers)
|
|
89
109
|
return;
|
|
@@ -159,7 +179,7 @@ export function createNativeHost(options) {
|
|
|
159
179
|
markCurrentLink(node);
|
|
160
180
|
if (!followLink)
|
|
161
181
|
return;
|
|
162
|
-
if (isBindingNode(node) && node.attributes.some((attribute) => /^(?::|x-bind:|@bind:|x-)href$/.test(attribute.name)) || typeof descriptorOf(node)?.props.href === "string")
|
|
182
|
+
if (isBindingNode(node) && node.attributes.some((attribute) => attribute.name.endsWith("href") && /^(?::|x-bind:|@bind:|x-)href$/.test(attribute.name)) || typeof descriptorOf(node)?.props.href === "string")
|
|
163
183
|
host.listen(node, "click", followsHref);
|
|
164
184
|
}
|
|
165
185
|
function markCurrentLink(node) {
|
|
@@ -318,8 +338,11 @@ export function createNativeHost(options) {
|
|
|
318
338
|
}
|
|
319
339
|
if (!record || controlsWithDefaultListeners.has(node))
|
|
320
340
|
return;
|
|
341
|
+
const pressable = record.type === "Button" || record.type === "Pressable";
|
|
342
|
+
if (!pressable && record.type !== "TextInput" && record.type !== "Picker" && record.type !== "Checkbox")
|
|
343
|
+
return;
|
|
321
344
|
let delegatedPress = !1;
|
|
322
|
-
if (
|
|
345
|
+
if (pressable) {
|
|
323
346
|
for (let owner = node.__stxOwner;owner; owner = owner.__stxOwner)
|
|
324
347
|
if (componentListeners.get(owner)?.some((listener) => (NATIVE_EVENT_NAMES[listener.event.toLowerCase()] ?? listener.event) === "onPress")) {
|
|
325
348
|
delegatedPress = !0;
|
|
@@ -563,35 +586,61 @@ export function createNativeHost(options) {
|
|
|
563
586
|
function isBindingNode(node) {
|
|
564
587
|
return node.nodeType === 1;
|
|
565
588
|
}
|
|
589
|
+
function nextSiblingOf(node) {
|
|
590
|
+
const owner = node.__stxOwner;
|
|
591
|
+
if (!owner)
|
|
592
|
+
return null;
|
|
593
|
+
const siblings = recordOf(owner).children, index = lastIndexOfChild(siblings, node.__stxId);
|
|
594
|
+
return index === -1 ? null : siblings[index + 1] ?? null;
|
|
595
|
+
}
|
|
596
|
+
function nextElementSiblingOf(node) {
|
|
597
|
+
let sibling = nextSiblingOf(node);
|
|
598
|
+
while (sibling && !isBindingNode(sibling))
|
|
599
|
+
sibling = nextSiblingOf(sibling);
|
|
600
|
+
return sibling;
|
|
601
|
+
}
|
|
602
|
+
const positionDescriptors = {
|
|
603
|
+
focus: { configurable: !0, writable: !0, value(focusOptions) {
|
|
604
|
+
return host.focus(this, focusOptions);
|
|
605
|
+
} },
|
|
606
|
+
measure: { configurable: !0, writable: !0, value() {
|
|
607
|
+
return host.measure(this);
|
|
608
|
+
} },
|
|
609
|
+
observeLayout: { configurable: !0, writable: !0, value(callback) {
|
|
610
|
+
return host.listen(this, "layout", callback);
|
|
611
|
+
} },
|
|
612
|
+
nextSibling: { configurable: !0, get() {
|
|
613
|
+
return nextSiblingOf(this);
|
|
614
|
+
} },
|
|
615
|
+
nextElementSibling: { configurable: !0, get() {
|
|
616
|
+
return nextElementSiblingOf(this);
|
|
617
|
+
} },
|
|
618
|
+
__stxPositionDecorated: { configurable: !0, writable: !0, value: !0 }
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
class HostElement extends BindingElement {
|
|
622
|
+
classChanged(value) {
|
|
623
|
+
host.setAttribute(this, "class", value);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
Object.defineProperties(HostElement.prototype, positionDescriptors);
|
|
627
|
+
const plainNodePrototype = Object.create(Object.prototype, positionDescriptors), anchorPrototype = Object.create(plainNodePrototype, {
|
|
628
|
+
parentNode: { configurable: !0, get() {
|
|
629
|
+
return this.__stxOwner ?? null;
|
|
630
|
+
} },
|
|
631
|
+
parentElement: { configurable: !0, get() {
|
|
632
|
+
return this.__stxOwner ?? null;
|
|
633
|
+
} }
|
|
634
|
+
});
|
|
635
|
+
function plainNode(id, prototype = plainNodePrototype) {
|
|
636
|
+
const node = Object.create(prototype);
|
|
637
|
+
node.__stxId = id;
|
|
638
|
+
return node;
|
|
639
|
+
}
|
|
566
640
|
function decoratePosition(node) {
|
|
567
|
-
|
|
568
|
-
if (target.__stxPositionDecorated)
|
|
641
|
+
if (node.__stxPositionDecorated)
|
|
569
642
|
return;
|
|
570
|
-
Object.defineProperties(
|
|
571
|
-
focus: { configurable: !0, value: (focusOptions) => host.focus(node, focusOptions) },
|
|
572
|
-
measure: { configurable: !0, value: () => host.measure(node) },
|
|
573
|
-
observeLayout: { configurable: !0, value: (callback) => host.listen(node, "layout", callback) },
|
|
574
|
-
nextSibling: {
|
|
575
|
-
configurable: !0,
|
|
576
|
-
get() {
|
|
577
|
-
const owner = target.__stxOwner;
|
|
578
|
-
if (!owner)
|
|
579
|
-
return null;
|
|
580
|
-
const siblings = recordOf(owner).children, index = siblings.findIndex((candidate) => candidate.__stxId === target.__stxId);
|
|
581
|
-
return index === -1 ? null : siblings[index + 1] ?? null;
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
nextElementSibling: {
|
|
585
|
-
configurable: !0,
|
|
586
|
-
get() {
|
|
587
|
-
let sibling = target.nextSibling;
|
|
588
|
-
while (sibling && !isBindingNode(sibling))
|
|
589
|
-
sibling = sibling.nextSibling;
|
|
590
|
-
return sibling;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
target.__stxPositionDecorated = !0;
|
|
643
|
+
Object.defineProperties(node, positionDescriptors);
|
|
595
644
|
}
|
|
596
645
|
async function withMountedView(node, request) {
|
|
597
646
|
await Promise.resolve();
|
|
@@ -634,9 +683,12 @@ export function createNativeHost(options) {
|
|
|
634
683
|
}
|
|
635
684
|
}
|
|
636
685
|
function adopt(node, type, owner, descriptor) {
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
686
|
+
const id = node.__stxId;
|
|
687
|
+
let digits = id.length;
|
|
688
|
+
while (digits > 0 && id.charCodeAt(digits - 1) >= 48 && id.charCodeAt(digits - 1) <= 57)
|
|
689
|
+
digits--;
|
|
690
|
+
if (digits < id.length)
|
|
691
|
+
counter = Math.max(counter, Number(id.slice(digits)));
|
|
640
692
|
const classes = descriptor?._classes ?? "", compiledClasses = compileClassStyles(classes), classStyle = compiledClasses.style, baseStyle = descriptor?._styleSource !== void 0 ? {} : descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
|
|
641
693
|
type,
|
|
642
694
|
key: descriptor?.key,
|
|
@@ -666,11 +718,14 @@ export function createNativeHost(options) {
|
|
|
666
718
|
records.set(node.__stxId, record);
|
|
667
719
|
decorateControl(node, type);
|
|
668
720
|
decoratePosition(node);
|
|
721
|
+
const previousOwner = node.__stxOwner;
|
|
669
722
|
node.__stxOwner = owner ?? null;
|
|
670
723
|
if (owner) {
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
724
|
+
const ownerRecord = recordOf(owner), children = ownerRecord.children;
|
|
725
|
+
if (previousOwner !== owner || lastIndexOfChild(children, node.__stxId) === -1) {
|
|
673
726
|
children.push(node);
|
|
727
|
+
ownerRecord.viewCount = void 0;
|
|
728
|
+
}
|
|
674
729
|
}
|
|
675
730
|
installControlListeners(node);
|
|
676
731
|
installLinkListener(node);
|
|
@@ -701,6 +756,7 @@ export function createNativeHost(options) {
|
|
|
701
756
|
listen: (node, event, callback) => host.listen(node, event, callback)
|
|
702
757
|
}), host = {
|
|
703
758
|
isNative: !0,
|
|
759
|
+
bindingElement: HostElement,
|
|
704
760
|
focus: (node, focusOptions) => withMountedView(node, (views) => views.focus(node.__stxId, focusOptions)),
|
|
705
761
|
measure: (node) => withMountedView(node, (views) => views.measure(node.__stxId)),
|
|
706
762
|
syncOverlays: (entries) => overlayPresenter.sync(entries),
|
|
@@ -741,6 +797,8 @@ export function createNativeHost(options) {
|
|
|
741
797
|
return;
|
|
742
798
|
colorScheme = scheme;
|
|
743
799
|
stylesheetVariables = createStyleVariables(options.stylesheetTheme?.[scheme] ?? []).computed();
|
|
800
|
+
if (options.classTable)
|
|
801
|
+
seedClassTable(options.classTable, scheme, stylesheetVariables, options.stylesheetRules, !1);
|
|
744
802
|
const children = new Set([...records.values()].flatMap((record) => record.children.map((child) => child.__stxId)));
|
|
745
803
|
for (const id of records.keys())
|
|
746
804
|
if (!children.has(id))
|
|
@@ -805,8 +863,7 @@ export function createNativeHost(options) {
|
|
|
805
863
|
record.markup = markup;
|
|
806
864
|
for (const source of parseSvgMarkup(markup)) {
|
|
807
865
|
const materializeMarkup = (parent, descriptor) => {
|
|
808
|
-
const child =
|
|
809
|
-
decoratePosition(child);
|
|
866
|
+
const child = plainNode(nextId("n"));
|
|
810
867
|
adopt(child, descriptor.type, null, descriptor);
|
|
811
868
|
records.get(child.__stxId).materialized = !1;
|
|
812
869
|
this.insert(parent, child);
|
|
@@ -1157,16 +1214,14 @@ export function createNativeHost(options) {
|
|
|
1157
1214
|
return was;
|
|
1158
1215
|
},
|
|
1159
1216
|
anchor(label) {
|
|
1160
|
-
const anchor =
|
|
1161
|
-
|
|
1162
|
-
parentNode: { configurable: !0, get: () => anchor.__stxOwner ?? null },
|
|
1163
|
-
parentElement: { configurable: !0, get: () => anchor.__stxOwner ?? null }
|
|
1164
|
-
});
|
|
1165
|
-
decoratePosition(anchor);
|
|
1217
|
+
const anchor = plainNode(nextId("a"), anchorPrototype);
|
|
1218
|
+
anchor.__stxAnchor = label;
|
|
1166
1219
|
return anchor;
|
|
1167
1220
|
},
|
|
1168
1221
|
clone(node) {
|
|
1169
|
-
const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id,
|
|
1222
|
+
const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id, void 0, HostElement) : plainNode(id);
|
|
1223
|
+
if (!isBindingNode(node))
|
|
1224
|
+
copy.__stxOwner = node.__stxOwner;
|
|
1170
1225
|
decoratePosition(copy);
|
|
1171
1226
|
if (node.__stxScope !== void 0)
|
|
1172
1227
|
copy.__stxScope = node.__stxScope;
|
|
@@ -1213,17 +1268,24 @@ export function createNativeHost(options) {
|
|
|
1213
1268
|
return copy;
|
|
1214
1269
|
},
|
|
1215
1270
|
insert(parent, node, before) {
|
|
1216
|
-
const record = recordOf(parent), oldOwner = node.__stxOwner, existing = oldOwner === parent ? record.children.findIndex((child) => child.__stxId === node.__stxId) : -1;
|
|
1217
|
-
if (existing !== -1)
|
|
1271
|
+
const record = recordOf(parent), oldOwner = node.__stxOwner, isView = node.__stxAnchor === void 0, existing = oldOwner === parent ? record.children.findIndex((child) => child.__stxId === node.__stxId) : -1;
|
|
1272
|
+
if (existing !== -1) {
|
|
1218
1273
|
record.children.splice(existing, 1);
|
|
1219
|
-
|
|
1274
|
+
if (isView && record.viewCount !== void 0)
|
|
1275
|
+
record.viewCount--;
|
|
1276
|
+
} else if (oldOwner && oldOwner !== parent) {
|
|
1220
1277
|
const oldRecord = recordOf(oldOwner), oldIndex = oldRecord.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
1221
|
-
if (oldIndex !== -1)
|
|
1278
|
+
if (oldIndex !== -1) {
|
|
1222
1279
|
oldRecord.children.splice(oldIndex, 1);
|
|
1280
|
+
if (isView && oldRecord.viewCount !== void 0)
|
|
1281
|
+
oldRecord.viewCount--;
|
|
1282
|
+
}
|
|
1223
1283
|
}
|
|
1224
1284
|
removeFromBindingParent(node);
|
|
1225
|
-
const index = before ? Math.max(0, record.children
|
|
1285
|
+
const index = before ? Math.max(0, lastIndexOfChild(record.children, before.__stxId)) : record.children.length;
|
|
1226
1286
|
record.children.splice(index, 0, node);
|
|
1287
|
+
if (isView && record.viewCount !== void 0)
|
|
1288
|
+
record.viewCount++;
|
|
1227
1289
|
node.__stxOwner = parent;
|
|
1228
1290
|
refreshStyleTree(node, record.variables);
|
|
1229
1291
|
insertIntoBindingParent(parent, node, index);
|
|
@@ -1240,9 +1302,17 @@ export function createNativeHost(options) {
|
|
|
1240
1302
|
return;
|
|
1241
1303
|
materialize(node);
|
|
1242
1304
|
let nativeIndex = 0;
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1305
|
+
if (index <= record.children.length >> 1) {
|
|
1306
|
+
for (let i = 0;i < index; i++)
|
|
1307
|
+
if (record.children[i].__stxAnchor === void 0)
|
|
1308
|
+
nativeIndex++;
|
|
1309
|
+
} else {
|
|
1310
|
+
let viewsAfter = 0;
|
|
1311
|
+
for (let i = record.children.length - 1;i > index; i--)
|
|
1312
|
+
if (record.children[i].__stxAnchor === void 0)
|
|
1313
|
+
viewsAfter++;
|
|
1314
|
+
nativeIndex = viewCountOf(record) - 1 - viewsAfter;
|
|
1315
|
+
}
|
|
1246
1316
|
emit({
|
|
1247
1317
|
op: existing === -1 ? "insertChild" : "moveChild",
|
|
1248
1318
|
parentId: parent.__stxId,
|
|
@@ -1265,9 +1335,12 @@ export function createNativeHost(options) {
|
|
|
1265
1335
|
remove(node) {
|
|
1266
1336
|
const wasMaterialized = descriptorOf(node)?.materialized === !0, hadFocus = descriptorOf(node)?.focusWithin === !0, owner = node.__stxOwner;
|
|
1267
1337
|
if (owner) {
|
|
1268
|
-
const record = recordOf(owner), at = record.children
|
|
1269
|
-
if (at !== -1)
|
|
1338
|
+
const record = recordOf(owner), at = lastIndexOfChild(record.children, node.__stxId);
|
|
1339
|
+
if (at !== -1) {
|
|
1270
1340
|
record.children.splice(at, 1);
|
|
1341
|
+
if (node.__stxAnchor === void 0 && record.viewCount !== void 0)
|
|
1342
|
+
record.viewCount--;
|
|
1343
|
+
}
|
|
1271
1344
|
}
|
|
1272
1345
|
removeFromBindingParent(node);
|
|
1273
1346
|
node.__stxOwner = null;
|
|
@@ -25,6 +25,7 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
|
|
|
25
25
|
viewportWidth: Number(bridge.viewportWidth) || 0,
|
|
26
26
|
stylesheetTheme: document.root._stylesheetTheme,
|
|
27
27
|
stylesheetRules: document.root._stylesheetRules,
|
|
28
|
+
classTable: document.root._classTable,
|
|
28
29
|
pointer: bridge.platform === "macos",
|
|
29
30
|
...followLink ? { followLink, linkState: (href, match) => nativeLinkState(href, String(globalThis.location?.href ?? ""), match) } : {},
|
|
30
31
|
send(operations) {
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Zs,Ht,vl,kg}from"./chunk-bwcj9z19.js";import{Ys,Ai,vg,xg,Sg}from"./chunk-4s5q1aea.js";import{yl,bl,wl,bg,wg}from"./chunk-dhqp3z4w.js";import{Ue,Tn,Pi}from"./chunk-k4bdf0dw.js";import{_g,Cg,Eg,Tg,Qs,ly}from"./chunk-7pk3t82j.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-nptp3x62.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/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-7sh9fa3q.js";import{w,tl}from"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import{Rt,S}from"./chunk-
|
|
2
|
+
import"./chunk-7sh9fa3q.js";import{w,tl}from"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import{Rt,S}from"./chunk-4cffjp4f.js";import"./chunk-27rzdq3n.js";import"./chunk-syheccfj.js";import"./chunk-h0jnatd4.js";import{kt,_t,Ct,Et,Tt,$t}from"./chunk-q14d714d.js";import{a}from"./chunk-j4s5k8sp.js";import{Cs}from"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-g7anxh36.js";import{he,en,tn}from"./chunk-gg71gm25.js";import"./chunk-276e3d0g.js";import{y}from"./chunk-bb2zfgwf.js";import{yt,i}from"./chunk-g89fx9rq.js";import"./chunk-6h7yhyb8.js";import"./chunk-6jzqzap6.js";import{ds}from"./chunk-56yhvhjq.js";import"./chunk-a4cse2tj.js";import"./chunk-2gqhfge6.js";import{Ga,Ja,Ya}from"./chunk-d18xd9x5.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{Qt}from"./chunk-628jcm1d.js";import"./chunk-k3mcb700.js";import"./chunk-qv85c3qy.js";import{X,we}from"./chunk-6jx0trea.js";import"./chunk-w5hhqjwr.js";import"./chunk-m997knnz.js";import{l}from"./chunk-jdj1358b.js";import{s,ge}from"./chunk-14ft0zc7.js";import D from"fs";import f from"path";import{createHash as vt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Dt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function It(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(Dt,(e,u,g,v)=>{let x=v.trim();if(!x)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)x=Pt(x);let p=It(x);if(!n.has(p))n.set(p,x);let P=r.integrity?` data-stx-integrity="sha384-${vt("sha384").update(x).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let x=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!x)return t;return t.slice(0,v)+x+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function K(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let n=t[r];if(!n)continue;let o=K(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?K(n):null}async function At(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=n.resolve(t,o);if(!r(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=K(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){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
|
`)}function q(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=ge(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(n[c.index]!==0)continue;let u=w(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=w(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(n[c.index]!==0)continue;let u=tl(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let n=await Bun.file(t).text();r="parse";let o=Qt(n),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>n.indexOf(e.fullTag)-n.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(s(g))&&Rt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(q);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let x=await v();r="result";let p=Array.isArray(x)?{paths:x}:x;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(n){return{kind:"error",phase:r,error:n instanceof Error?n:Error(String(n))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[n,o]of Object.entries(r))this.cache.set(n,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),r={};for(let[n,o]of this.cache)r[n]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let n=D.statSync(t),o=`${this.salt}|${t}:${n.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=ft(r).some((u)=>D.existsSync(u)),c=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ds(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(r,n.dependencies??[]);if(n.hash!==e)return this.cache.delete(t),null;return n.html}set(t,r,n,o){let c=this.getHash(r,n);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:n})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let n=this.getFilePath(t);await D.promises.mkdir(f.dirname(n),{recursive:!0}),await Bun.write(n,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=f.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let n=await D.promises.readdir(r);for(let o of n){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await D.promises.unlink(f.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Ut(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let n=await gt(t.filePath);if(n.kind==="error")throw Error(`getStaticPaths ${n.phase} failed for ${t.pattern} (${t.filePath}): ${n.error.message}`,{cause:n.error});if(n.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=n.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}function ft(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of ft(t))if(await Bun.file(r).exists())try{let n=await import(r);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:o,...c}=n;return c}}catch(n){console.error(`Error loading data file ${r}:`,n)}return null}async function Gt(t,r,n){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
|
|
4
4
|
return (async function getStaticProps() {
|
|
5
5
|
${e[1]}
|
|
@@ -37,7 +37,7 @@ ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
|
|
|
37
37
|
${n.join(`
|
|
38
38
|
`)}
|
|
39
39
|
</channel>
|
|
40
|
-
</rss>`}async function Vt(t={}){let r=Date.now();tn();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,x={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-
|
|
40
|
+
</rss>`}async function Vt(t={}){let r=Date.now();tn();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,x={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-1pbyr47e.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-dtnyrjcj.js"),R=await b(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-1pbyr47e.js");await d('<div class="bg-black"></div>')}catch{}kt();let wt=n?.routeMiddleware?.dir||"middleware";await Ct(process.cwd(),wt);let J=_t();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let St=n?.routeMiddleware?.global||[];Ya(n?.layoutsDir,l(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:G,props:xt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=Yt(A),bt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...St,...bt];if(nt.length>0){let B=Et(h,G,O||{}),L=Tt(B,null,void 0,{isServer:!0}),j=await $t(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=te(String(C),h),U=ee(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
|
|
41
41
|
const validate = ${it[1]};
|
|
42
42
|
return validate(route);
|
|
43
43
|
`)({params:G})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,G,xt,e,n);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
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.793",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@stacksjs/ts-css": "^0.3.11",
|
|
130
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
131
|
-
"@stacksjs/desktop": "0.2.
|
|
132
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.793",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.793",
|
|
133
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
134
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.793",
|
|
135
135
|
"bunfig": "^0.15.21",
|
|
136
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.793",
|
|
137
137
|
"ts-broadcasting": "^0.0.11",
|
|
138
138
|
"ts-images": "^0.2.22",
|
|
139
139
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-07w4gp1w.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Wg}from"./chunk-xxkxk6j2.js";import"./chunk-09ybdmk1.js";import"./chunk-dmkaaf3k.js";import"./chunk-4pkhz90f.js";import"./chunk-5c89afzb.js";import"./chunk-q5jxnqfr.js";import"./chunk-8vq5w11w.js";import"./chunk-8ft5vgp3.js";import"./chunk-h0jnatd4.js";import"./chunk-605b93pe.js";import"./chunk-w9nwb8r3.js";import"./chunk-q14d714d.js";import"./chunk-a8sb2jwq.js";import"./chunk-sqq3hqpb.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";export{Wg as startProductionServer};
|
package/dist/chunk-1ac8dt85.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{yo,oh,ih}from"./chunk-064faxda.js";import"./chunk-j0ye6whq.js";import"./chunk-4pkhz90f.js";import"./chunk-7sh9fa3q.js";import"./chunk-a3v7jkp6.js";import"./chunk-q5jxnqfr.js";import"./chunk-w5hhqjwr.js";import"./chunk-8vq5w11w.js";import"./chunk-8ft5vgp3.js";import"./chunk-h0jnatd4.js";import"./chunk-605b93pe.js";import"./chunk-w9nwb8r3.js";import"./chunk-q14d714d.js";import"./chunk-a8sb2jwq.js";import"./chunk-sqq3hqpb.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";export{ih as clearComposableCache,oh as getComposableScript,yo as listComposableModules};
|
package/dist/chunk-1nr15t1f.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ka,_a,Ca,Ea,bh}from"./chunk-kpreycjr.js";import"./chunk-3gn1t0pa.js";import"./chunk-axfz9jcz.js";import"./chunk-c0ejyxfj.js";import"./chunk-njse2cjy.js";import"./chunk-efpsvjp9.js";import"./chunk-e4x4q5rf.js";import"./chunk-2gqhfge6.js";import"./chunk-m58ga249.js";import"./chunk-5c89afzb.js";import"./chunk-khjcp7jn.js";import"./chunk-qv85c3qy.js";import"./chunk-a3v7jkp6.js";import"./chunk-q5jxnqfr.js";import"./chunk-w5hhqjwr.js";import"./chunk-98bxcss9.js";import"./chunk-8vq5w11w.js";import"./chunk-8ft5vgp3.js";import"./chunk-h0jnatd4.js";import"./chunk-605b93pe.js";import"./chunk-w9nwb8r3.js";import"./chunk-q14d714d.js";import"./chunk-a8sb2jwq.js";import"./chunk-sqq3hqpb.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";export{ka as buildNative,bh as default,_a as findCraftBinary,Ea as getAvailableFormats,Ca as getAvailableTargets};
|
package/dist/chunk-1vr1gw3h.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{_l,Cl}from"./chunk-gvr9kdqp.js";import"./chunk-1y9ez7nz.js";import"./chunk-xwqkmkvw.js";import"./chunk-bnpckvpq.js";import"./chunk-xxkxk6j2.js";import"./chunk-b4r7d6me.js";import"./chunk-h0c6jtrj.js";import"./chunk-fdafgcxp.js";import"./chunk-64g7z2m2.js";import"./chunk-09ybdmk1.js";import"./chunk-5j619xgb.js";import"./chunk-v8rfeev5.js";import"./chunk-vrbcdds3.js";import"./chunk-pa785cdg.js";import"./chunk-0r61tkfe.js";import"./chunk-vkn133cs.js";import"./chunk-2p4yad7w.js";import"./chunk-rrb9m2q2.js";import"./chunk-6v4b0xc1.js";import"./chunk-pa9zfbh6.js";import"./chunk-hmncyjhc.js";import"./chunk-x4ssghte.js";import"./chunk-agtvdtx4.js";import"./chunk-tnn0br4w.js";import"./chunk-gv3bfkdm.js";import"./chunk-tnkxww7b.js";import"./chunk-np7ryj86.js";import"./chunk-064faxda.js";import"./chunk-3a5qnt2f.js";import"./chunk-axfz9jcz.js";import"./chunk-c0ejyxfj.js";import"./chunk-d18xd9x5.js";import{Qt}from"./chunk-dmkaaf3k.js";import"./chunk-j0ye6whq.js";import"./chunk-4pkhz90f.js";import"./chunk-7sh9fa3q.js";import{Re,i}from"./chunk-njse2cjy.js";import"./chunk-efpsvjp9.js";import"./chunk-e4x4q5rf.js";import"./chunk-2gqhfge6.js";import"./chunk-m58ga249.js";import"./chunk-5c89afzb.js";import"./chunk-khjcp7jn.js";import"./chunk-qv85c3qy.js";import"./chunk-a3v7jkp6.js";import{we}from"./chunk-q5jxnqfr.js";import"./chunk-w5hhqjwr.js";import{lr,ur}from"./chunk-98bxcss9.js";import{vs,j,a}from"./chunk-8vq5w11w.js";import"./chunk-8ft5vgp3.js";import"./chunk-h0jnatd4.js";import"./chunk-605b93pe.js";import"./chunk-w9nwb8r3.js";import"./chunk-q14d714d.js";import{m,Le}from"./chunk-a8sb2jwq.js";import"./chunk-sqq3hqpb.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";import"./chunk-5a92srn2.js";import"./chunk-e3wmnjz8.js";export{vs as buildWebComponents,ur as cacheTemplate,lr as checkCache,Qt as classifyAllScripts,_l as createMiddleware,Cl as createRoute,j as defaultConfig,m as extractVariables,we as injectRouterScript,a as loadStxConfig,Le as processClientScript,i as processDirectives,Re as readMarkdownFile};
|