@stacksjs/stx 0.2.279 → 0.2.281
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-an8s3rjv.js → chunk-0cdkfqw6.js} +2 -2
- package/dist/{chunk-08a9bfpq.js → chunk-0kexd0d9.js} +1 -1
- package/dist/{chunk-wz87behc.js → chunk-3p2w5dag.js} +1 -1
- package/dist/{chunk-rqx69p0n.js → chunk-3rbdvrp0.js} +1 -1
- package/dist/{chunk-1wbr71dj.js → chunk-40bzrw9q.js} +1 -1
- package/dist/{chunk-ddh7j0ed.js → chunk-4k0y2fnh.js} +1 -1
- package/dist/{chunk-1k3zp68a.js → chunk-61rfw29f.js} +1 -1
- package/dist/{chunk-2x85y8hb.js → chunk-6vaa771b.js} +1 -1
- package/dist/{chunk-2r0sm7yh.js → chunk-78yh2zqa.js} +9 -9
- package/dist/{chunk-4afj0w1m.js → chunk-86d1vte8.js} +1 -1
- package/dist/{chunk-9334fg4q.js → chunk-99ppngnm.js} +1 -1
- package/dist/{chunk-aj9xtx4y.js → chunk-9w2e55wt.js} +2 -2
- package/dist/{chunk-dgtbkxfd.js → chunk-bavv2k2z.js} +1 -1
- package/dist/{chunk-42mwkqa5.js → chunk-bkbnxd7s.js} +1 -1
- package/dist/{chunk-0m5vyswh.js → chunk-cnbqznms.js} +1 -1
- package/dist/{chunk-1kgz9eet.js → chunk-d8j22791.js} +1 -1
- package/dist/chunk-e7avk421.js +28 -0
- package/dist/{chunk-3cqwrprg.js → chunk-edctags2.js} +1 -1
- package/dist/{chunk-cbaa2gpx.js → chunk-exwdzxbq.js} +1 -1
- package/dist/{chunk-fg50mb11.js → chunk-gdja5ak8.js} +1 -1
- package/dist/{chunk-gyr2qp4d.js → chunk-gex3spzq.js} +1 -1
- package/dist/{chunk-e3m5zefg.js → chunk-gm2wsf2d.js} +1 -1
- package/dist/{chunk-qs1kypwa.js → chunk-h0t73k2z.js} +325 -325
- package/dist/{chunk-34d33f18.js → chunk-hcjmvwnt.js} +1 -1
- package/dist/{chunk-c40n039h.js → chunk-hghg9hcj.js} +1 -1
- package/dist/{chunk-2m8aq999.js → chunk-hqsadyfr.js} +1 -1
- package/dist/{chunk-s0v2g53x.js → chunk-hysmnz0q.js} +1 -1
- package/dist/{chunk-083kj0ge.js → chunk-k7m8p93y.js} +1 -1
- package/dist/{chunk-kr2q64k9.js → chunk-pgvskhg2.js} +1 -1
- package/dist/{chunk-8c18h010.js → chunk-q2twgdxk.js} +1 -1
- package/dist/{chunk-b6txvycf.js → chunk-qp1shwek.js} +1 -1
- package/dist/{chunk-ashkqdsb.js → chunk-qrx23zbx.js} +1 -1
- package/dist/{chunk-f0f8pne1.js → chunk-rvmt27kv.js} +1 -1
- package/dist/{chunk-zpne6q7q.js → chunk-s6759be9.js} +1 -1
- package/dist/chunk-vc973skb.js +898 -0
- package/dist/{chunk-tjgyd8gt.js → chunk-vxskcekj.js} +1 -1
- package/dist/{chunk-jsnybr5z.js → chunk-x8pbbdp1.js} +1 -1
- package/dist/{chunk-q0ctxav6.js → chunk-xen25bsv.js} +1 -1
- package/dist/{chunk-eakr9att.js → chunk-y8sqjqwg.js} +1 -1
- package/dist/{chunk-3564b157.js → chunk-y91519ss.js} +1 -1
- package/dist/{chunk-abx8rmt4.js → chunk-ydzmhy4c.js} +1 -1
- package/dist/{chunk-q9y29cgw.js → chunk-yqkjgz9q.js} +1 -1
- package/dist/{chunk-ev7490c4.js → chunk-z4mrwx1z.js} +1 -1
- package/dist/{chunk-5q8yyck0.js → chunk-ztzas1ew.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/color-mode-boot.d.ts +0 -50
- package/dist/color-mode-boot.js +2 -12
- package/dist/component-processing.js +12 -1
- package/dist/composable-loader.d.ts +10 -1
- package/dist/composable-loader.js +4 -4
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/head-injection.d.ts +17 -0
- package/dist/head-injection.js +14 -6
- package/dist/process.js +37 -36
- package/dist/pwa.js +1 -1
- package/dist/runtime-injection.js +5 -6
- package/dist/seo.js +9 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-9mjw29f1.js +0 -28
- package/dist/chunk-dqzxr0pk.js +0 -898
|
@@ -7,6 +7,15 @@ export function pascalToKebab(str) {
|
|
|
7
7
|
import { restoreStashedScripts, stashScriptElements } from "./html-masking.js";
|
|
8
8
|
|
|
9
9
|
export { restoreStashedScripts, stashScriptElements };
|
|
10
|
+
const tagNameMatchers = new Map;
|
|
11
|
+
function tagNameMatcherFor(tagPattern) {
|
|
12
|
+
let matcher = tagNameMatchers.get(tagPattern.source);
|
|
13
|
+
if (!matcher) {
|
|
14
|
+
matcher = new RegExp(`(${tagPattern.source})(?![\\w.:-])`, "y");
|
|
15
|
+
tagNameMatchers.set(tagPattern.source, matcher);
|
|
16
|
+
}
|
|
17
|
+
return matcher;
|
|
18
|
+
}
|
|
10
19
|
export function findComponentTags(html, tagPattern, skipTags) {
|
|
11
20
|
const matches = [];
|
|
12
21
|
let pos = 0;
|
|
@@ -14,7 +23,9 @@ export function findComponentTags(html, tagPattern, skipTags) {
|
|
|
14
23
|
const tagStart = html.indexOf("<", pos);
|
|
15
24
|
if (tagStart === -1)
|
|
16
25
|
break;
|
|
17
|
-
const
|
|
26
|
+
const matcher = tagNameMatcherFor(tagPattern);
|
|
27
|
+
matcher.lastIndex = tagStart + 1;
|
|
28
|
+
const tagNameMatch = matcher.exec(html);
|
|
18
29
|
if (!tagNameMatch) {
|
|
19
30
|
pos = tagStart + 1;
|
|
20
31
|
continue;
|
|
@@ -46,7 +46,16 @@ export declare function listComposableModules(composablesDir?: string): Promise<
|
|
|
46
46
|
* reach. Omit to emit every composable, which is what a caller with no page in
|
|
47
47
|
* hand needs.
|
|
48
48
|
*/
|
|
49
|
-
export declare function getComposableScript(composablesDir?: string, pageSource?: string
|
|
49
|
+
export declare function getComposableScript(composablesDir?: string, pageSource?: string,
|
|
50
|
+
/**
|
|
51
|
+
* Text that is not (yet) part of `pageSource` but will ship with the page --
|
|
52
|
+
* the store bundle and the framework-composable bundle, which are collected
|
|
53
|
+
* alongside this one and spliced into the document together (#1945). They are
|
|
54
|
+
* scanned for reachability the same way the page is, because a composable
|
|
55
|
+
* used only from a store still has to be kept (#1936); passing them here
|
|
56
|
+
* rather than splicing them in first is what lets the three share one splice.
|
|
57
|
+
*/
|
|
58
|
+
extraSources?: readonly string[]): Promise<string | null>;
|
|
50
59
|
/**
|
|
51
60
|
* Clear the cached composable script (for dev mode hot reload).
|
|
52
61
|
*/
|
|
@@ -63,7 +63,7 @@ export async function listComposableModules(composablesDir) {
|
|
|
63
63
|
function mentions(text, name) {
|
|
64
64
|
return new RegExp(`\\b${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`).test(text);
|
|
65
65
|
}
|
|
66
|
-
function selectReachable(modules, codeByFile,
|
|
66
|
+
function selectReachable(modules, codeByFile, pageSources) {
|
|
67
67
|
const fileForName = new Map;
|
|
68
68
|
for (const { file, names } of modules)
|
|
69
69
|
for (const name of names)
|
|
@@ -76,7 +76,7 @@ function selectReachable(modules, codeByFile, pageSource) {
|
|
|
76
76
|
found.push(file);
|
|
77
77
|
return found;
|
|
78
78
|
}, selected = new Set;
|
|
79
|
-
let frontier = filesMentionedIn
|
|
79
|
+
let frontier = pageSources.flatMap(filesMentionedIn);
|
|
80
80
|
while (frontier.length > 0) {
|
|
81
81
|
const next = [];
|
|
82
82
|
for (const file of frontier) {
|
|
@@ -91,7 +91,7 @@ function selectReachable(modules, codeByFile, pageSource) {
|
|
|
91
91
|
}
|
|
92
92
|
return selected;
|
|
93
93
|
}
|
|
94
|
-
export async function getComposableScript(composablesDir, pageSource) {
|
|
94
|
+
export async function getComposableScript(composablesDir, pageSource, extraSources) {
|
|
95
95
|
const resolvedDir = await resolveComposablesDir(composablesDir);
|
|
96
96
|
if (!resolvedDir)
|
|
97
97
|
return null;
|
|
@@ -124,7 +124,7 @@ export async function getComposableScript(composablesDir, pageSource) {
|
|
|
124
124
|
} catch {
|
|
125
125
|
codeByFile.set(file, "");
|
|
126
126
|
}
|
|
127
|
-
const selected = pageSource === void 0 ? new Set(composableFiles) : selectReachable(modules, codeByFile, pageSource);
|
|
127
|
+
const selected = pageSource === void 0 ? new Set(composableFiles) : selectReachable(modules, codeByFile, extraSources ? [pageSource, ...extraSources] : [pageSource]);
|
|
128
128
|
if (selected.size === 0)
|
|
129
129
|
return null;
|
|
130
130
|
const includedFiles = composableFiles.filter((file) => selected.has(file)), cacheKey = `${resolvedDir}\x00${includedFiles.join("\x00")}`, cached = readSigned(_cachedComposableScripts, cacheKey, signature);
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$j as Aj,Zj as Nj,_j as wj}from"./chunk-jr3jp3ev.js";import{bk as Uj,ck as Xj,dk as Yj,ek as Zj,fk as _j,gk as $j,hk as qj,ik as Fj,jk as Oj,kk as Vj,lk as Ij,mk as Qj,nk as Wj,ok as Kj}from"./chunk-
|
|
2
|
+
import{$j as Aj,Zj as Nj,_j as wj}from"./chunk-jr3jp3ev.js";import{bk as Uj,ck as Xj,dk as Yj,ek as Zj,fk as _j,gk as $j,hk as qj,ik as Fj,jk as Oj,kk as Vj,lk as Ij,mk as Qj,nk as Wj,ok as Kj}from"./chunk-4k0y2fnh.js";import"./chunk-0cdkfqw6.js";import"./chunk-h0t73k2z.js";import"./chunk-xpxw2ked.js";import"./chunk-6gb72zp2.js";import"./chunk-82kkkpw2.js";import"./chunk-shyqtvbq.js";import"./chunk-ydzmhy4c.js";import"./chunk-w1asc0zd.js";import"./chunk-xqwmj65h.js";import"./chunk-0ym08enb.js";import"./chunk-q4desjj6.js";import"./chunk-gfhzedsr.js";import"./chunk-sfaayvmn.js";import"./chunk-azfjfrns.js";import"./chunk-z45t29sf.js";var I=new Map,Q=new Map;function L(j,B){let G=B?.id||g(j),J=h(j),U=I.get(G);if(U&&U.hash===J)return U;let X=S(j),Z=y(j),Y=T(j),_=v(X),{staticParts:q,dynamicParts:$}=C(X),F=u(j),O={id:G,hash:J,tree:X,scripts:Z,styles:Y,staticParts:q,dynamicParts:$,dependencies:F,metadata:_};return I.set(G,O),O}async function r(j,B={},G={}){let J=performance.now();if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`,_=Q.get(Y);if(_&&Date.now()-_.timestamp<(G.cacheTTL||60000))return{html:_.html,styles:j.styles.join(`
|
|
3
3
|
`),scripts:j.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:_.html.length,componentCount:j.metadata.componentCount}}}let U;if(G.streaming)U=await H(j.tree,B);else U=W(j.tree,B);let X;if(G.hydrate){let Y=k(U,j,B);U=Y.html,X=Y.data}if(G.minify)U=x(U);if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`;Q.set(Y,{html:U,timestamp:Date.now()})}let Z=performance.now()-J;return{html:U,styles:j.styles.join(`
|
|
5
5
|
`),scripts:j.scripts.join(`
|
package/dist/craft.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$j as Aj,Zj as Nj,_j as wj}from"./chunk-jr3jp3ev.js";import{bk as Uj,ck as Xj,dk as Yj,ek as Zj,fk as _j,gk as $j,hk as qj,ik as Fj,jk as Oj,kk as Vj,lk as Ij,mk as Qj,nk as Wj,ok as Kj}from"./chunk-
|
|
2
|
+
import{$j as Aj,Zj as Nj,_j as wj}from"./chunk-jr3jp3ev.js";import{bk as Uj,ck as Xj,dk as Yj,ek as Zj,fk as _j,gk as $j,hk as qj,ik as Fj,jk as Oj,kk as Vj,lk as Ij,mk as Qj,nk as Wj,ok as Kj}from"./chunk-4k0y2fnh.js";import"./chunk-0cdkfqw6.js";import"./chunk-h0t73k2z.js";import"./chunk-xpxw2ked.js";import"./chunk-6gb72zp2.js";import"./chunk-82kkkpw2.js";import"./chunk-shyqtvbq.js";import"./chunk-ydzmhy4c.js";import"./chunk-w1asc0zd.js";import"./chunk-xqwmj65h.js";import"./chunk-0ym08enb.js";import"./chunk-q4desjj6.js";import"./chunk-gfhzedsr.js";import"./chunk-sfaayvmn.js";import"./chunk-azfjfrns.js";import"./chunk-z45t29sf.js";var I=new Map,Q=new Map;function L(j,B){let G=B?.id||g(j),J=h(j),U=I.get(G);if(U&&U.hash===J)return U;let X=S(j),Z=y(j),Y=T(j),_=v(X),{staticParts:q,dynamicParts:$}=C(X),F=u(j),O={id:G,hash:J,tree:X,scripts:Z,styles:Y,staticParts:q,dynamicParts:$,dependencies:F,metadata:_};return I.set(G,O),O}async function r(j,B={},G={}){let J=performance.now();if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`,_=Q.get(Y);if(_&&Date.now()-_.timestamp<(G.cacheTTL||60000))return{html:_.html,styles:j.styles.join(`
|
|
3
3
|
`),scripts:j.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:_.html.length,componentCount:j.metadata.componentCount}}}let U;if(G.streaming)U=await H(j.tree,B);else U=W(j.tree,B);let X;if(G.hydrate){let Y=k(U,j,B);U=Y.html,X=Y.data}if(G.minify)U=x(U);if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`;Q.set(Y,{html:U,timestamp:Date.now()})}let Z=performance.now()-J;return{html:U,styles:j.styles.join(`
|
|
5
5
|
`),scripts:j.scripts.join(`
|
package/dist/head-injection.d.ts
CHANGED
|
@@ -42,3 +42,20 @@ export declare function hasHeadInjections(injections: HeadInjections): boolean;
|
|
|
42
42
|
* are served with the same information in response headers instead.
|
|
43
43
|
*/
|
|
44
44
|
export declare function applyHeadInjections(html: string, injections: HeadInjections): string;
|
|
45
|
+
/**
|
|
46
|
+
* Offset of the canonical head-injection position: just inside `<head>`, after
|
|
47
|
+
* a `<meta charset>` that leads it. `null` when the document has no head.
|
|
48
|
+
*
|
|
49
|
+
* Stepping over the charset is not cosmetic. The encoding declaration has to
|
|
50
|
+
* land inside the document's first 1024 bytes, and what gets inserted here is
|
|
51
|
+
* big enough to push it out -- the signals runtime is the whole client library,
|
|
52
|
+
* the default SEO block ~500 bytes. Displacing it was then repaired at the end
|
|
53
|
+
* of the pipeline by hoisting the charset back up, which rebuilt the whole
|
|
54
|
+
* document (186KB on a 199KB page) to move three bytes. Every injector landing
|
|
55
|
+
* after the charset means the order is right the first time and there is
|
|
56
|
+
* nothing to repair (stacksjs/stx#1945).
|
|
57
|
+
*
|
|
58
|
+
* `hoistCharsetMeta` stays as the backstop for anything that does not come
|
|
59
|
+
* through here.
|
|
60
|
+
*/
|
|
61
|
+
export declare function headInsertionPoint(html: string): number | null;
|
package/dist/head-injection.js
CHANGED
|
@@ -7,14 +7,22 @@ export function hasHeadInjections(injections) {
|
|
|
7
7
|
export function applyHeadInjections(html, injections) {
|
|
8
8
|
if (!hasHeadInjections(injections))
|
|
9
9
|
return html;
|
|
10
|
-
const afterOpen = injections.afterOpen.join(""), beforeClose = injections.beforeClose.join(""),
|
|
11
|
-
if (openAt ===
|
|
10
|
+
const afterOpen = injections.afterOpen.join(""), beforeClose = injections.beforeClose.join(""), headCloseIdx = html.lastIndexOf("</head>"), openAt = afterOpen ? headInsertionPoint(html) : null, closeAt = beforeClose && headCloseIdx !== -1 ? headCloseIdx : null;
|
|
11
|
+
if (openAt === null && closeAt === null)
|
|
12
12
|
return html;
|
|
13
|
-
if (openAt
|
|
14
|
-
return closeAt === -1 ? html : `${html.slice(0, closeAt)}${beforeClose}${html.slice(closeAt)}`;
|
|
15
|
-
if (openAt !== -1 && closeAt !== -1)
|
|
13
|
+
if (openAt !== null && closeAt !== null)
|
|
16
14
|
return `${html.slice(0, openAt)}${afterOpen}${html.slice(openAt, closeAt)}${beforeClose}${html.slice(closeAt)}`;
|
|
17
|
-
if (openAt !==
|
|
15
|
+
if (openAt !== null)
|
|
18
16
|
return `${html.slice(0, openAt)}${afterOpen}${html.slice(openAt)}`;
|
|
19
17
|
return `${html.slice(0, closeAt)}${beforeClose}${html.slice(closeAt)}`;
|
|
20
18
|
}
|
|
19
|
+
const LEADING_CHARSET_META = /\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;
|
|
20
|
+
export function headInsertionPoint(html) {
|
|
21
|
+
const headOpen = /<head\b[^>]*>/i.exec(html);
|
|
22
|
+
if (!headOpen)
|
|
23
|
+
return null;
|
|
24
|
+
const afterTag = headOpen.index + headOpen[0].length;
|
|
25
|
+
LEADING_CHARSET_META.lastIndex = afterTag;
|
|
26
|
+
const charset = LEADING_CHARSET_META.exec(html);
|
|
27
|
+
return charset ? afterTag + charset[0].length : afterTag;
|
|
28
|
+
}
|
package/dist/process.js
CHANGED
|
@@ -212,6 +212,7 @@ function findScriptBlockByAttribute(html, attribute) {
|
|
|
212
212
|
end: closeEnd + 1
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
+
const STYLE_OPEN_TAG = /<style\b[^>]*>/iy, STYLE_CLOSE_TAG = /<\/style>/gi, SCRIPT_OPEN_TAG = /<script\b[^>]*>/iy;
|
|
215
216
|
function findFirstScriptTag(html) {
|
|
216
217
|
let searchFrom = 0;
|
|
217
218
|
while (searchFrom < html.length) {
|
|
@@ -223,13 +224,16 @@ function findFirstScriptTag(html) {
|
|
|
223
224
|
searchFrom = commentEnd === -1 ? html.length : commentEnd + 3;
|
|
224
225
|
continue;
|
|
225
226
|
}
|
|
226
|
-
|
|
227
|
+
STYLE_OPEN_TAG.lastIndex = tagStart;
|
|
228
|
+
const styleTag = STYLE_OPEN_TAG.exec(html);
|
|
227
229
|
if (styleTag) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
+
STYLE_CLOSE_TAG.lastIndex = tagStart + styleTag[0].length;
|
|
231
|
+
const styleEnd = STYLE_CLOSE_TAG.exec(html);
|
|
232
|
+
searchFrom = styleEnd === null ? html.length : styleEnd.index + 8;
|
|
230
233
|
continue;
|
|
231
234
|
}
|
|
232
|
-
|
|
235
|
+
SCRIPT_OPEN_TAG.lastIndex = tagStart;
|
|
236
|
+
if (SCRIPT_OPEN_TAG.test(html))
|
|
233
237
|
return tagStart;
|
|
234
238
|
searchFrom = tagStart + 1;
|
|
235
239
|
}
|
|
@@ -255,8 +259,11 @@ export async function processDirectives(template, context, filePath, options, de
|
|
|
255
259
|
if (context.__stx_signals_gate === void 0)
|
|
256
260
|
context.__stx_signals_gate = usesSignalsInScript(template, filePath);
|
|
257
261
|
const isTopLevel = !context.__stxProcessingDepth;
|
|
258
|
-
if (isTopLevel)
|
|
262
|
+
if (isTopLevel) {
|
|
259
263
|
initializeComponentClientFactories(context);
|
|
264
|
+
context.__stx_head_injections = createHeadInjections();
|
|
265
|
+
context.__stx_seo_staged = !1;
|
|
266
|
+
}
|
|
260
267
|
if (!context.__stxProcessingDepth)
|
|
261
268
|
context.__stxProcessingDepth = 0;
|
|
262
269
|
context.__stxProcessingDepth++;
|
|
@@ -314,7 +321,7 @@ export async function processDirectives(template, context, filePath, options, de
|
|
|
314
321
|
}
|
|
315
322
|
}
|
|
316
323
|
if (isTopLevel) {
|
|
317
|
-
const headInjections = createHeadInjections(), cloak = cloakStyleFragment(result);
|
|
324
|
+
const headInjections = context.__stx_head_injections ?? createHeadInjections(), cloak = cloakStyleFragment(result);
|
|
318
325
|
if (cloak !== null)
|
|
319
326
|
headInjections.beforeClose.push(cloak);
|
|
320
327
|
const buildId = buildIdFragment(result);
|
|
@@ -326,36 +333,30 @@ export async function processDirectives(template, context, filePath, options, de
|
|
|
326
333
|
result = injectColorModeBootScript(result, colorModeConfig);
|
|
327
334
|
result = placeSignalsRuntimeBeforeScripts(result);
|
|
328
335
|
}
|
|
329
|
-
if (isTopLevel)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const composableTag = `<script data-stx-composables>${composableCode}</script>`, anchor = findScriptBlockByAttribute(result, "data-stx-stores") || findScriptBlockByAttribute(result, "data-stx-runtime");
|
|
354
|
-
if (anchor)
|
|
355
|
-
result = result.slice(0, anchor.end) + `
|
|
356
|
-
` + composableTag + result.slice(anchor.end);
|
|
357
|
-
}
|
|
358
|
-
} catch {}
|
|
336
|
+
if (isTopLevel) {
|
|
337
|
+
const runtime = findScriptBlockByAttribute(result, "data-stx-runtime");
|
|
338
|
+
if (runtime) {
|
|
339
|
+
let storeTag = null, composableTag = null, frameworkScript = null;
|
|
340
|
+
try {
|
|
341
|
+
const { getStoreScript } = await importOnce("stx/store-loader", () => import("./store-loader.js")), resolvedStoresDir = options.storesDir, storeCode = await getStoreScript(resolvedStoresDir);
|
|
342
|
+
if (storeCode)
|
|
343
|
+
storeTag = `<script data-stx-stores>${storeCode}</script>`;
|
|
344
|
+
} catch {}
|
|
345
|
+
try {
|
|
346
|
+
const { getFrameworkComposableScript } = await importOnce("stx/framework-composables", () => import("./framework-composables.js"));
|
|
347
|
+
frameworkScript = await getFrameworkComposableScript(result);
|
|
348
|
+
} catch {}
|
|
349
|
+
try {
|
|
350
|
+
const { getComposableScript } = await importOnce("stx/composable-loader", () => import("./composable-loader.js")), resolvedComposablesDir = options.composablesDir, pending = [storeTag, frameworkScript].filter((text) => text !== null), composableCode = await getComposableScript(resolvedComposablesDir, result, pending);
|
|
351
|
+
if (composableCode)
|
|
352
|
+
composableTag = `<script data-stx-composables>${composableCode}</script>`;
|
|
353
|
+
} catch {}
|
|
354
|
+
const tags = [storeTag, composableTag, frameworkScript].filter((text) => text !== null).map((tag) => `
|
|
355
|
+
${tag}`).join("");
|
|
356
|
+
if (tags)
|
|
357
|
+
result = result.slice(0, runtime.end) + tags + result.slice(runtime.end);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
359
360
|
if (isTopLevel)
|
|
360
361
|
result = normalizeCriticalHeadOrder(result);
|
|
361
362
|
if (isTopLevel && context.__stx_inject_css !== !1)
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Hk as wq,Ik as dq,Jk as Cq,Kk as mq,Lk as gq}from"./chunk-hpybjwwf.js";import{Mk as S,Nk as Tq,Ok as _q,Pk as z,Qk as D,Rk as P,Sk as kq,Tk as vq,Uk as w,Vk as Iq,Wk as d,Xk as Hq,Yk as Oq,Zk as Mq}from"./chunk-gdhyfrst.js";import{Su as Aq,Tu as bq,Uu as Sq,Vu as zq,Wu as Dq,Xu as Pq}from"./chunk-azfjfrns.js";import{$u as N}from"./chunk-z45t29sf.js";import p from"fs";import E from"path";import C from"fs";import L from"path";var k=[72,96,128,144,152,192,384,512],v=[120,152,167,180],I=[16,32];async function H(G,B){let q={success:!0,generatedFiles:[],errors:[],warnings:[]},K=G.pwa?.icons;if(!K?.src)return q.errors.push("No source icon specified in pwa.icons.src"),q.success=!1,q;let Y=L.isAbsolute(K.src)?K.src:L.resolve(process.cwd(),K.src);if(!await Bun.file(Y).exists())return q.errors.push(`Source icon not found: ${Y}`),q.success=!1,q;let Q=L.resolve(B,K.outputDir||"pwa-icons");try{C.mkdirSync(Q,{recursive:!0})}catch{return q.errors.push(`Failed to create output directory: ${Q}`),q.success=!1,q}let X=K.sizes||k,j=K.generateWebP??!0,J=K.generateAppleIcons??!0;try{let y;try{y=await import("sharp")}catch{return q.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),q.success=!1,q}let R=await y.default(Y).metadata();if(R.width&&R.width<512)q.warnings.push(`Source icon is ${R.width}x${R.height}. Recommend using at least 512x512 for best quality.`);for(let $ of X){let x=L.join(Q,`icon-${$}x${$}.png`);if(await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x),j){let F=L.join(Q,`icon-${$}x${$}.webp`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(F),q.generatedFiles.push(F)}}if(J){for(let x of v){let F=L.join(Q,`apple-touch-icon-${x}x${x}.png`);await y.default(Y).resize(x,x,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(F),q.generatedFiles.push(F)}let $=L.join(Q,"apple-touch-icon.png");await y.default(Y).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),q.generatedFiles.push($)}for(let $ of I){let x=L.join(Q,`favicon-${$}x${$}.png`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x)}let U=512,T=L.join(Q,`icon-maskable-${U}x${U}.png`),Z=Math.floor(U*0.1),_=U-Z*2;await y.default(Y).resize(_,_,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Z,bottom:Z,left:Z,right:Z,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(T),q.generatedFiles.push(T)}catch(y){let V=y instanceof Error?y.message:String(y);q.errors.push(`Icon generation failed: ${V}`),q.success=!1}return q}function n(G){let B=G.sizes||k,q=G.outputDir?`/${G.outputDir}`:"/pwa-icons",K=G.generateWebP??!0,Y=G.generateAppleIcons??!0,Q=[];for(let X of B)if(Q.push(`${q}/icon-${X}x${X}.png`),K)Q.push(`${q}/icon-${X}x${X}.webp`);if(Y){Q.push(`${q}/apple-touch-icon.png`);for(let X of v)Q.push(`${q}/apple-touch-icon-${X}x${X}.png`)}for(let X of I)Q.push(`${q}/favicon-${X}x${X}.png`);return Q.push(`${q}/icon-maskable-512x512.png`),Q}async function O(){try{return await import("sharp"),!0}catch{return!1}}function m(G,B,q,K){let Y=[],Q=K.join(" ");for(let X of G)if(Y.push({src:`${B}/icon-${X}x${X}.png`,sizes:`${X}x${X}`,type:"image/png",purpose:Q}),q)Y.push({src:`${B}/icon-${X}x${X}.webp`,sizes:`${X}x${X}`,type:"image/webp",purpose:Q});return Y}function g(G){return G.map((B)=>({name:B.name,short_name:B.shortName,description:B.description,url:B.url,icons:B.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function h(G){let B=G.pwa?.shareTarget;if(!B?.enabled)return;let q={action:B.action||"/share",method:B.method||"POST",enctype:B.enctype||"multipart/form-data",params:{title:B.params?.title||"title",text:B.params?.text||"text",url:B.params?.url||"url"}};if(B.acceptFiles&&B.acceptFiles.length>0)q.params.files=B.acceptFiles.map((K)=>({name:K.name,accept:K.accept}));return q}function c(G){let B=G.pwa?.fileHandlers;if(!B?.enabled||!B.accept)return;let q=[{action:B.action||"/",accept:B.accept,launch_type:B.launchType||"single-client"}];if(B.icons)q[0].icons=B.icons.map((K)=>({src:K.src,sizes:K.sizes,type:K.type}));return q}function l(G){let B=G.pwa?.protocolHandlers;if(!B||B.length===0)return;return B.map((q)=>({protocol:q.protocol,url:q.url}))}function u(G){let B=G.pwa;if(!B?.enabled||!B.manifest)return null;let{manifest:q,icons:K}=B,Y=K?.sizes||[72,96,128,144,152,192,384,512],Q=K?.outputDir?`/${K.outputDir}`:"/pwa-icons",X=K?.generateWebP??!0,j=K?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:m(Y,Q,X,j)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=g(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((U)=>({src:U.src,sizes:U.sizes,type:U.type,label:U.label,form_factor:U.platform}));let y=h(G);if(y)J.share_target=y;let V=c(G);if(V)J.file_handlers=V;let R=l(G);if(R)J.protocol_handlers=R;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function M(G){let B=u(G);if(!B)return"";let q=JSON.parse(JSON.stringify(B));return JSON.stringify(q,null,2)}function i(G,B){return{...B,...G,shortcuts:G.shortcuts||B.shortcuts,screenshots:G.screenshots||B.screenshots,categories:G.categories||B.categories}}function s(G){let B=[],q=G.pwa;if(!q?.enabled)return B;let K=q.manifest;if(!K)return B.push("PWA manifest configuration is missing"),B;if(!K.name)B.push("Manifest name is required");let Y=["fullscreen","standalone","minimal-ui","browser"];if(K.display&&!Y.includes(K.display))B.push(`Invalid display mode: ${K.display}. Must be one of: ${Y.join(", ")}`);let Q=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(K.orientation&&!Q.includes(K.orientation))B.push(`Invalid orientation: ${K.orientation}`);let X=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(K.themeColor&&!X.test(K.themeColor))B.push(`Invalid theme color: ${K.themeColor}. Must be a valid hex color.`);if(K.backgroundColor&&!X.test(K.backgroundColor))B.push(`Invalid background color: ${K.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)B.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)B.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let j of q.protocolHandlers){if(!j.protocol)B.push("Protocol handler missing protocol");if(!j.url||!j.url.includes("%s"))B.push(`Protocol handler URL must contain %s placeholder: ${j.protocol}`)}return B}import A from"path";async function b(G){let B=G.pwa?.offline;if(!B?.enabled)return"";if(B.page){let q=A.isAbsolute(B.page)?B.page:A.resolve(process.cwd(),B.page);if(await Bun.file(q).exists())try{let{processDirectives:K}=await import("./chunk-
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),q.success=!1,q}let R=await y.default(Y).metadata();if(R.width&&R.width<512)q.warnings.push(`Source icon is ${R.width}x${R.height}. Recommend using at least 512x512 for best quality.`);for(let $ of X){let x=L.join(Q,`icon-${$}x${$}.png`);if(await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x),j){let F=L.join(Q,`icon-${$}x${$}.webp`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(F),q.generatedFiles.push(F)}}if(J){for(let x of v){let F=L.join(Q,`apple-touch-icon-${x}x${x}.png`);await y.default(Y).resize(x,x,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(F),q.generatedFiles.push(F)}let $=L.join(Q,"apple-touch-icon.png");await y.default(Y).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),q.generatedFiles.push($)}for(let $ of I){let x=L.join(Q,`favicon-${$}x${$}.png`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x)}let U=512,T=L.join(Q,`icon-maskable-${U}x${U}.png`),Z=Math.floor(U*0.1),_=U-Z*2;await y.default(Y).resize(_,_,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Z,bottom:Z,left:Z,right:Z,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(T),q.generatedFiles.push(T)}catch(y){let V=y instanceof Error?y.message:String(y);q.errors.push(`Icon generation failed: ${V}`),q.success=!1}return q}function n(G){let B=G.sizes||k,q=G.outputDir?`/${G.outputDir}`:"/pwa-icons",K=G.generateWebP??!0,Y=G.generateAppleIcons??!0,Q=[];for(let X of B)if(Q.push(`${q}/icon-${X}x${X}.png`),K)Q.push(`${q}/icon-${X}x${X}.webp`);if(Y){Q.push(`${q}/apple-touch-icon.png`);for(let X of v)Q.push(`${q}/apple-touch-icon-${X}x${X}.png`)}for(let X of I)Q.push(`${q}/favicon-${X}x${X}.png`);return Q.push(`${q}/icon-maskable-512x512.png`),Q}async function O(){try{return await import("sharp"),!0}catch{return!1}}function m(G,B,q,K){let Y=[],Q=K.join(" ");for(let X of G)if(Y.push({src:`${B}/icon-${X}x${X}.png`,sizes:`${X}x${X}`,type:"image/png",purpose:Q}),q)Y.push({src:`${B}/icon-${X}x${X}.webp`,sizes:`${X}x${X}`,type:"image/webp",purpose:Q});return Y}function g(G){return G.map((B)=>({name:B.name,short_name:B.shortName,description:B.description,url:B.url,icons:B.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function h(G){let B=G.pwa?.shareTarget;if(!B?.enabled)return;let q={action:B.action||"/share",method:B.method||"POST",enctype:B.enctype||"multipart/form-data",params:{title:B.params?.title||"title",text:B.params?.text||"text",url:B.params?.url||"url"}};if(B.acceptFiles&&B.acceptFiles.length>0)q.params.files=B.acceptFiles.map((K)=>({name:K.name,accept:K.accept}));return q}function c(G){let B=G.pwa?.fileHandlers;if(!B?.enabled||!B.accept)return;let q=[{action:B.action||"/",accept:B.accept,launch_type:B.launchType||"single-client"}];if(B.icons)q[0].icons=B.icons.map((K)=>({src:K.src,sizes:K.sizes,type:K.type}));return q}function l(G){let B=G.pwa?.protocolHandlers;if(!B||B.length===0)return;return B.map((q)=>({protocol:q.protocol,url:q.url}))}function u(G){let B=G.pwa;if(!B?.enabled||!B.manifest)return null;let{manifest:q,icons:K}=B,Y=K?.sizes||[72,96,128,144,152,192,384,512],Q=K?.outputDir?`/${K.outputDir}`:"/pwa-icons",X=K?.generateWebP??!0,j=K?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:m(Y,Q,X,j)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=g(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((U)=>({src:U.src,sizes:U.sizes,type:U.type,label:U.label,form_factor:U.platform}));let y=h(G);if(y)J.share_target=y;let V=c(G);if(V)J.file_handlers=V;let R=l(G);if(R)J.protocol_handlers=R;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function M(G){let B=u(G);if(!B)return"";let q=JSON.parse(JSON.stringify(B));return JSON.stringify(q,null,2)}function i(G,B){return{...B,...G,shortcuts:G.shortcuts||B.shortcuts,screenshots:G.screenshots||B.screenshots,categories:G.categories||B.categories}}function s(G){let B=[],q=G.pwa;if(!q?.enabled)return B;let K=q.manifest;if(!K)return B.push("PWA manifest configuration is missing"),B;if(!K.name)B.push("Manifest name is required");let Y=["fullscreen","standalone","minimal-ui","browser"];if(K.display&&!Y.includes(K.display))B.push(`Invalid display mode: ${K.display}. Must be one of: ${Y.join(", ")}`);let Q=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(K.orientation&&!Q.includes(K.orientation))B.push(`Invalid orientation: ${K.orientation}`);let X=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(K.themeColor&&!X.test(K.themeColor))B.push(`Invalid theme color: ${K.themeColor}. Must be a valid hex color.`);if(K.backgroundColor&&!X.test(K.backgroundColor))B.push(`Invalid background color: ${K.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)B.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)B.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let j of q.protocolHandlers){if(!j.protocol)B.push("Protocol handler missing protocol");if(!j.url||!j.url.includes("%s"))B.push(`Protocol handler URL must contain %s placeholder: ${j.protocol}`)}return B}import A from"path";async function b(G){let B=G.pwa?.offline;if(!B?.enabled)return"";if(B.page){let q=A.isAbsolute(B.page)?B.page:A.resolve(process.cwd(),B.page);if(await Bun.file(q).exists())try{let{processDirectives:K}=await import("./chunk-qrx23zbx.js"),Y=await Bun.file(q).text();return await K(Y,{},q,G,new Set)}catch(K){console.warn(`[PWA] Failed to process custom offline page: ${K}`)}else console.warn(`[PWA] Custom offline page not found: ${q}`)}return f(G)}function f(G){let B=G.pwa?.offline,q=G.pwa?.manifest,K=B?.fallbackTitle||"You are offline",Y=B?.fallbackMessage||"Please check your internet connection and try again.",Q=q?.themeColor||"#4f46e5",X=q?.shortName||q?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { headInsertionPoint } from "./head-injection.js";
|
|
1
2
|
import { BROWSER_CORE_IMPORTS } from "./browser-core-imports.js";
|
|
2
3
|
import { getOwnedRouteMatchers } from "./owned-routes.js";
|
|
3
4
|
import { toScriptJson } from "./script-json.js";
|
|
@@ -65,12 +66,10 @@ function placeRuntimeTag(template, runtimeScript) {
|
|
|
65
66
|
if (firstScript !== -1 && (doctype === -1 || firstScript > doctype))
|
|
66
67
|
return template.slice(0, firstScript) + runtimeScript + `
|
|
67
68
|
` + template.slice(firstScript);
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
${runtimeScript}${template.slice(at)}`;
|
|
73
|
-
}
|
|
69
|
+
const headAt = headInsertionPoint(template);
|
|
70
|
+
if (headAt !== null)
|
|
71
|
+
return `${template.slice(0, headAt)}
|
|
72
|
+
${runtimeScript}${template.slice(headAt)}`;
|
|
74
73
|
if (template.includes("</head>")) {
|
|
75
74
|
const idx = template.indexOf("</head>");
|
|
76
75
|
return template.slice(0, idx) + runtimeScript + `
|
package/dist/seo.js
CHANGED
|
@@ -244,7 +244,7 @@ export function processSeoDirective(template, context, _filePath, _options) {
|
|
|
244
244
|
export function injectSeoTags(html, context, options) {
|
|
245
245
|
if (options.seo?.enabled === !1)
|
|
246
246
|
return html;
|
|
247
|
-
if (html.includes("<!-- stx SEO Tags -->") || options.skipDefaultSeoTags === !0)
|
|
247
|
+
if (html.includes("<!-- stx SEO Tags -->") || context.__stx_seo_staged === !0 || options.skipDefaultSeoTags === !0)
|
|
248
248
|
return html;
|
|
249
249
|
const runtimeHead = context.__stx_runtime_head;
|
|
250
250
|
if (!!(runtimeHead?.title || runtimeHead?.meta?.some((m) => m.property === "og:title" || m.name === "og:title" || m.name === "twitter:title" || m.name === "description")))
|
|
@@ -303,6 +303,14 @@ export function injectSeoTags(html, context, options) {
|
|
|
303
303
|
if (!hasTitle)
|
|
304
304
|
result = result.replace(/<head[^>]*>/, `$&
|
|
305
305
|
<title>${escapeHtml(title)}</title>`);
|
|
306
|
+
const staged = context.__stx_head_injections;
|
|
307
|
+
if (staged) {
|
|
308
|
+
context.__stx_seo_staged = !0;
|
|
309
|
+
staged.afterOpen.push(`
|
|
310
|
+
${seoTagsMinimal}
|
|
311
|
+
`);
|
|
312
|
+
return result;
|
|
313
|
+
}
|
|
306
314
|
return result.replace(/<head[^>]*>/, `$&
|
|
307
315
|
${seoTagsMinimal}
|
|
308
316
|
`);
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Dk as Fq,yk as Uq,zk as Iq}from"./chunk-3yg0f94g.js";import{Ek as Eq,Fk as Tq,Gk as Dq}from"./chunk-58f0mthg.js";import{$k as _q,cl as zq,dl as Aq}from"./chunk-
|
|
2
|
+
import{Dk as Fq,yk as Uq,zk as Iq}from"./chunk-3yg0f94g.js";import{Ek as Eq,Fk as Tq,Gk as Dq}from"./chunk-58f0mthg.js";import{$k as _q,cl as zq,dl as Aq}from"./chunk-yqkjgz9q.js";import{Jm as Oq,Mq as P,Zp as Bq,fp as l,ip as Hq,js as n}from"./chunk-h0t73k2z.js";import"./chunk-xpxw2ked.js";import"./chunk-6gb72zp2.js";import"./chunk-82kkkpw2.js";import"./chunk-shyqtvbq.js";import{nt as Xq}from"./chunk-ydzmhy4c.js";import{st as d}from"./chunk-w1asc0zd.js";import"./chunk-xqwmj65h.js";import"./chunk-0ym08enb.js";import"./chunk-q4desjj6.js";import"./chunk-gfhzedsr.js";import{Gu as Yq,Hu as Vq,Iu as jq,Ju as Gq,Ku as Lq,Lu as Nq}from"./chunk-sfaayvmn.js";import"./chunk-azfjfrns.js";import{$u as y}from"./chunk-z45t29sf.js";import O from"fs";import j from"path";import{createHash as xq}from"crypto";function yq(q){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(q).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return q}}var Pq=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Cq(q){return Bun.hash(q).toString(16)}function Qq(q,Z={}){if(!q.includes('type="stx/island"'))return{html:q,chunks:[]};let $=new Map,Q=q.replace(Pq,(J,W,z,A)=>{let G=A.trim();if(!G)return J;if(/\bdata-stx-src=/.test(z))return J;if(Z.minify)G=yq(G);let X=Cq(G);if(!$.has(X))$.set(X,G);let B=Z.integrity?` data-stx-integrity="sha384-${xq("sha384").update(G).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${X}.js"${B}${z}></script>`}),K=Array.from($,([J,W])=>({hash:J,code:W}));return{html:Q,chunks:K}}var gq=new Set(["visible","idle"]);function Zq(q){if(!q.includes("data-stx-src="))return q;let Z=new Map,$=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,Q;while((Q=$.exec(q))!==null)Z.set(Q[1],Q[2]);let K=new Set,J=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,W;while((W=J.exec(q))!==null)if(gq.has(Z.get(W[1])||""))K.add(W[2]);let z=q.lastIndexOf("</head>");if(K.size===0||z===-1)return q;let A=Array.from(K).filter((G)=>!q.includes(`rel="prefetch" href="${G}"`)).map((G)=>`<link rel="prefetch" href="${G}" as="script">`).join("");if(!A)return q;return q.slice(0,z)+A+q.slice(z)}var fq=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function h(q){let Z=q.trim();if(!Z)return null;let $=/^https?:\/\//i.test(Z)?Z:`https://${Z}`;try{return new URL($).origin+new URL($).pathname.replace(/\/$/,"")}catch{return null}}function mq(q){for(let Z of fq){let $=q[Z];if(!$)continue;let Q=h($);if(Q)return{url:Q,source:"env",via:Z}}return null}function $q(q){if(!q||typeof q!=="object")return null;let Z=q,$=Z.site?.url??Z.url??Z.app?.url;return typeof $==="string"?h($):null}async function dq(q){let{existsSync:Z}=await import("fs"),$=await import("path");for(let Q of["site.config.ts","site.config.js",".config/site.config.ts"]){let K=$.resolve(q,Q);if(!Z(K))continue;try{let J=await import(K),W=$q(J.default??J);if(W)return W}catch{}}return null}async function Kq(q={}){let Z=q.cwd??process.cwd(),$=q.env??process.env;if(q.explicit){let W=h(q.explicit);if(W)return{url:W,source:"option"}}let Q=$q(q.stxConfig);if(Q)return{url:Q,source:"stx.config",via:"site.url"};let K=await dq(Z);if(K)return{url:K,source:"site.config",via:"url"};let J=mq($);if(J)return J;return{url:"http://localhost",source:"fallback"}}function Wq(){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 Rq{cacheDir;cache=new Map;loaded=!1;salt;constructor(q,Z=""){this.cacheDir=q,this.salt=Z}async load(){if(this.loaded)return;let q=j.join(this.cacheDir,"build-cache.json");if(await Bun.file(q).exists())try{let Z=JSON.parse(await Bun.file(q).text());for(let[$,Q]of Object.entries(Z))this.cache.set($,Q)}catch{}this.loaded=!0}async save(){await O.promises.mkdir(this.cacheDir,{recursive:!0});let q=j.join(this.cacheDir,"build-cache.json"),Z={};for(let[$,Q]of this.cache)Z[$]=Q;await Bun.write(q,JSON.stringify(Z))}getHash(q,Z){let $=O.statSync(q),Q=`${this.salt}|${q}:${$.mtimeMs}`;for(let J of Z)if(O.existsSync(J)){let W=O.statSync(J);Q+=`:${J}:${W.mtimeMs}`}let K=0;for(let J=0;J<Q.length;J++){let W=Q.charCodeAt(J);K=(K<<5)-K+W,K=K&K}return Math.abs(K).toString(36)}get(q,Z){let $=this.cache.get(q);if(!$)return null;let Q=this.getHash(Z,$.dependencies??[]);if($.hash!==Q)return this.cache.delete(q),null;return $.html}set(q,Z,$,Q){let K=this.getHash(Z,$);this.cache.set(q,{hash:K,html:Q,generatedAt:Date.now(),dependencies:$})}}class Mq{cacheDir;constructor(q){this.cacheDir=q}getFilePath(q){let Z=q.replace(/[^a-zA-Z0-9]/g,"_")+".json";return j.join(this.cacheDir,"isr",Z)}async get(q){let Z=this.getFilePath(q);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set(q,Z){let $=this.getFilePath(q);await O.promises.mkdir(j.dirname($),{recursive:!0}),await Bun.write($,JSON.stringify(Z))}async invalidate(q){let Z=this.getFilePath(q);if(await Bun.file(Z).exists())await O.promises.unlink(Z)}async invalidatePattern(q){let Z=j.join(this.cacheDir,"isr");if(!O.existsSync(Z))return;let $=await O.promises.readdir(Z);for(let Q of $){let K=Q.replace(/_/g,"/").replace(".json","");if(q.test(K))await O.promises.unlink(j.join(Z,Q))}}async needsRevalidation(q){let Z=await this.get(q);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function pq(q){try{let $=(await Bun.file(q).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!$)return null;let Q=$[1];if(!Q.includes("getStaticPaths"))return null;let K=Q.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!K)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${K[1]}
|
|
@@ -41,7 +41,7 @@ ${q.map((Q)=>{let K=new URL(Q.loc,Z).href,J=` <url>
|
|
|
41
41
|
${$.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function rq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},z=new Set,A=0,G={},X={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&O.existsSync(J.outputDir))await O.promises.rm(J.outputDir,{recursive:!0});await O.promises.mkdir(J.outputDir,{recursive:!0});let L=J.cacheSalt;if(!L){let{resolveUserCrosswindConfig:Y,fingerprintConfig:N}=await import("./chunk-
|
|
44
|
+
</rss>`}async function rq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},z=new Set,A=0,G={},X={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&O.existsSync(J.outputDir))await O.promises.rm(J.outputDir,{recursive:!0});await O.promises.mkdir(J.outputDir,{recursive:!0});let L=J.cacheSalt;if(!L){let{resolveUserCrosswindConfig:Y,fingerprintConfig:N}=await import("./chunk-99ppngnm.js");try{L=N(await Y(process.cwd()))}catch{}}let{prepareImageDelivery:_}=await import("./chunk-jkd1185y.js"),F=await _(J.publicDir,J.outputDir);if(F.count>0)console.log(`Optimized ${F.count} image(s) for responsive delivery`),L=[L,F.fingerprint].filter(Boolean).join(":");let C=new Rq(J.cacheDir,L);if(J.cache)await C.load();try{let{generateCrosswindCSS:Y}=await import("./chunk-99ppngnm.js");await Y('<div class="bg-black"></div>')}catch{}Yq();let kq=$?.routeMiddleware?.dir||"middleware";await jq(process.cwd(),kq);let p=Vq();if(p.length>0)console.log(`Loaded ${p.length} middleware: ${p.join(", ")}`);let bq=$?.routeMiddleware?.global||[];Fq($?.layoutsDir,d(process.cwd()));let i=l(".",{pagesDir:J.pagesDir});console.log(`Found ${i.length} routes`);let g=[];for(let Y of i){let N=await uq(Y);for(let H of N)g.push({route:Y,url:H.url,params:H.params,props:H.props,revalidate:H.revalidate??J.revalidate})}W.totalPages=g.length,console.log(`Generating ${W.totalPages} pages...`);let b=[],s=[];for(let Y=0;Y<g.length;Y+=J.concurrency)s.push(g.slice(Y,Y+J.concurrency));for(let Y of s)await Promise.all(Y.map(async(N)=>{let{route:H,url:V,params:S,props:Sq,revalidate:r}=N;try{await J.hooks.onPageStart?.(V);let R=await Bun.file(H.filePath).text(),M=JJ(R),vq=M?.middleware?Array.isArray(M.middleware)?M.middleware:[M.middleware]:[],t=[...bq,...vq];if(t.length>0){let D=Gq(V,S,M||{}),w=Lq(D,null,void 0,{isServer:!0}),E=await Nq(t,w);if(E.redirect){let U=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,x=QJ(String(U),V),k=ZJ(V,J);await O.promises.mkdir(j.dirname(k),{recursive:!0}),await Bun.write(k,x),W.successCount++,W.pages.push({route:V,outputPath:k,size:Buffer.byteLength(x),cached:!1}),b.push({loc:V,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${V} \u2192 redirect to ${U}`);return}if(E.abort){let U=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${V} \u2014 middleware aborted: ${U}`);return}}let e=R.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(e)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${e[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:S})){console.warn(`Validation failed for ${V}, skipping...`);return}}catch{}let I=null,qq=!1;if(J.cache){if(I=C.get(V,H.filePath),I)qq=!0,W.cachedCount++}if(!I){let D=await wq(H,S,Sq,J,$);if(I=D.html,J.failOnIncludeError&&D.includeFailures.length>0)throw Error(`${D.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.281",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.19",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.14",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.281",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.281",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.281",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.281",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.17",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-9mjw29f1.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$i as v,_i as _,aj as U}from"./chunk-9n0gvfrg.js";import{Ol as C,Pl as N,Rl as E,Uq as T,js as S}from"./chunk-qs1kypwa.js";import{Qt as y}from"./chunk-gfhzedsr.js";import L from"path";var j=new Map,M=new Map,b=["composables","functions"];function K(V){let J=L.basename(V,".ts");return J==="index"||J==="types"||V.endsWith(".d.ts")}async function F(V){if(V)return L.resolve(V);let J=`<default>:${process.cwd()}`,Q=M.get(J);if(Q!==void 0)return Q;let z=await h();if(z!==null)M.set(J,z);return z}async function h(){let V=await S(),J=V.root||process.cwd(),Q=V.composablesDir;if(Q)return L.resolve(J,Q);for(let z of b){let Z=L.resolve(J,z);try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:Z,absolute:!0}))if(!K(Y))return Z}catch{}}return null}async function s(V){let J=await F(V);if(!J)return[];let Q=[];try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:J,absolute:!0}))if(!K(Y))Q.push(Y)}catch{return[]}Q.sort();let z=T({loader:"ts",target:"browser",define:E()}),Z=[];for(let W of Q)try{let Y=await Bun.file(W).text(),G=z.scan(Y).exports.filter(($)=>$!=="default");if(G.length>0)Z.push({file:W,names:G})}catch{}return Z}function u(V,J){return new RegExp(`\\b${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(V)}function f(V,J,Q){let z=new Map;for(let{file:G,names:$}of V)for(let O of $)if(!z.has(O))z.set(O,G);let Z=(G)=>{let $=[];for(let[O,P]of z)if(u(G,O))$.push(P);return $},W=new Set,Y=Z(Q);while(Y.length>0){let G=[];for(let $ of Y){if(W.has($))continue;W.add($);for(let O of Z(J.get($)??""))if(!W.has(O))G.push(O)}Y=G}return W}async function i(V,J){let Q=await F(V);if(!Q)return null;let z=[];try{let q=new Bun.Glob("**/*.ts");for await(let H of q.scan({cwd:Q,absolute:!0})){if(K(H))continue;z.push(H)}}catch{return U(j,Q,"",""),null}let Z=_(z);if(z.length===0)return U(j,Q,Z,""),null;z.sort();let W=T({loader:"ts",target:"browser",define:E()}),Y=new Map,G=[];for(let q of z)try{let H=await Bun.file(q).text();Y.set(q,H);let w=W.scan(H).exports.filter((X)=>X!=="default");if(w.length>0)G.push({file:q,names:w})}catch{Y.set(q,"")}let $=J===void 0?new Set(z):f(G,Y,J);if($.size===0)return null;let O=z.filter((q)=>$.has(q)),P=`${Q}\x00${O.join("\x00")}`,B=v(j,P,Z);if(B!==void 0)return B||null;let A=[],R=new Set,I=new Set;for(let q of O)try{let H=Y.get(q)??await Bun.file(q).text(),w=L.basename(q,".ts");for(let X of H.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(X[1])I.add(X[1]);try{for(let X of W.scan(H).exports)if(X!=="default")R.add(X)}catch{}H=C(H),H=N(H),H=H.replace(/^export\s+(default\s+)?/gm,""),H=W.transformSync(H),A.push(`// Composable: ${w}
|
|
3
|
-
${H.trim()}`)}catch(H){console.warn(`[stx] Failed to load composable ${q}:`,H)}if(A.length===0||R.size===0)return U(j,P,Z,""),null;let D=[...R].map((q)=>` try { __c[${JSON.stringify(q)}] = ${q}; } catch (e) {}`).join(`
|
|
4
|
-
`),g=JSON.stringify([...R]),k=A.join(`
|
|
5
|
-
|
|
6
|
-
`),x=`;(function(){
|
|
7
|
-
window.__composables = window.__composables || {};
|
|
8
|
-
var __c = window.__composables;
|
|
9
|
-
var __stx = window.stx || {};
|
|
10
|
-
${y.filter((q)=>!I.has(q)&&new RegExp(`\\b${q}\\b`).test(k)).map((q)=>`var ${q} = __stx[${JSON.stringify(q)}];`).join(`
|
|
11
|
-
`)}
|
|
12
|
-
${k}
|
|
13
|
-
${D}
|
|
14
|
-
var __names = ${g};
|
|
15
|
-
for (var __i = 0; __i < __names.length; __i++) {
|
|
16
|
-
var __n = __names[__i];
|
|
17
|
-
if (!(__n in __c)) continue;
|
|
18
|
-
var __takenByBuiltin = !!(window.stx && __n in window.stx);
|
|
19
|
-
if (__takenByBuiltin || __n in window) {
|
|
20
|
-
console.warn('[stx] composable "' + __n + '" is not available as a bare identifier: '
|
|
21
|
-
+ (__takenByBuiltin ? 'a built-in of that name already exists' : 'window already defines that property')
|
|
22
|
-
+ '. Rename it, or use: import { ' + __n + ' } from "@composables"');
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
window[__n] = __c[__n];
|
|
26
|
-
}
|
|
27
|
-
})();`;return U(j,P,Z,x),x}function o(){j.clear(),M.clear()}
|
|
28
|
-
export{s as Xi,i as Yi,o as Zi};
|