@stacksjs/stx 0.2.280 → 0.2.283
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/a11y.d.ts +3 -3
- package/dist/a11y.js +40 -0
- package/dist/build-externalize.js +3 -3
- package/dist/build-views.d.ts +1 -1
- package/dist/build-views.js +2 -2
- package/dist/builtins/transition-group.d.ts +1 -1
- package/dist/{chunk-0ym08enb.js → chunk-0f1kz0x2.js} +1 -1
- package/dist/{chunk-shh4jfwc.js → chunk-0fgcnv6y.js} +1 -1
- package/dist/chunk-0h7ty10c.js +2 -0
- package/dist/{chunk-6vaa771b.js → chunk-1a8e5xpf.js} +1 -1
- package/dist/chunk-1rcn9yfj.js +2 -0
- package/dist/{chunk-5vday0wx.js → chunk-2g9jwgs7.js} +1 -1
- package/dist/chunk-3828z7q8.js +2 -0
- package/dist/{chunk-w1asc0zd.js → chunk-39f40yc4.js} +1 -1
- package/dist/{chunk-9y5xb0p4.js → chunk-3bv8h4r6.js} +1 -1
- package/dist/{chunk-yqkjgz9q.js → chunk-4ds1cmgq.js} +1 -1
- package/dist/chunk-50mpsfpx.js +3 -0
- package/dist/{chunk-shyqtvbq.js → chunk-52mh63sp.js} +1 -1
- package/dist/{chunk-71r0nchv.js → chunk-5aq35j2e.js} +1 -1
- package/dist/chunk-5k3qb1am.js +22 -0
- package/dist/chunk-5v6atbsr.js +2 -0
- package/dist/{chunk-gex3spzq.js → chunk-7etzqabz.js} +1 -1
- package/dist/chunk-7n45tcyf.js +2 -0
- package/dist/{chunk-y3r71hx6.js → chunk-7p9ns60j.js} +1 -1
- package/dist/{chunk-tyr2z96r.js → chunk-7rxtra1g.js} +1 -1
- package/dist/chunk-822x6vhb.js +2 -0
- package/dist/{chunk-5v2wk7sj.js → chunk-90qr4f9m.js} +1 -1
- package/dist/{chunk-0cdkfqw6.js → chunk-9236skjs.js} +2 -2
- package/dist/{chunk-exwgbdz5.js → chunk-9x4jejq0.js} +1 -1
- package/dist/{chunk-e8jazdsk.js → chunk-9zndrzb3.js} +1 -1
- package/dist/{chunk-3kj7kd8g.js → chunk-a2qghr2x.js} +1 -1
- package/dist/{chunk-jj6nrqje.js → chunk-a54n1r1q.js} +1 -1
- package/dist/{chunk-37dznstc.js → chunk-a63y3aa0.js} +1 -1
- package/dist/chunk-a95mf15m.js +2 -0
- package/dist/{chunk-9w2e55wt.js → chunk-abydddye.js} +2 -2
- package/dist/{chunk-3tr99nn5.js → chunk-areethga.js} +1 -1
- package/dist/{chunk-q4desjj6.js → chunk-ayrjwkyw.js} +1 -1
- package/dist/chunk-b29wbjs5.js +2 -0
- package/dist/chunk-ba6tthsm.js +2 -0
- package/dist/{chunk-sfaayvmn.js → chunk-bf8wf3r2.js} +38 -38
- package/dist/{chunk-w1zde8wp.js → chunk-bz2gytfs.js} +1 -1
- package/dist/{chunk-6gb72zp2.js → chunk-c0an64km.js} +1 -1
- package/dist/{chunk-gfhzedsr.js → chunk-c6fw33zh.js} +1 -1
- package/dist/chunk-crmgatrx.js +2 -0
- package/dist/{chunk-n3j3z889.js → chunk-cvhyxt55.js} +1 -1
- package/dist/{chunk-2fx2xdre.js → chunk-cvnh7dma.js} +1 -1
- package/dist/{chunk-dyd3jdrn.js → chunk-d0c3v7ax.js} +1 -1
- package/dist/{chunk-5d0jtpqm.js → chunk-e4hhz9j3.js} +1 -1
- package/dist/{chunk-x4w3awav.js → chunk-e7jfpyqy.js} +1 -1
- package/dist/{chunk-4k0y2fnh.js → chunk-e9nmf863.js} +1 -1
- package/dist/chunk-ef5663vk.js +2 -0
- package/dist/{chunk-q2twgdxk.js → chunk-f16kkw9v.js} +1 -1
- package/dist/{chunk-e5vy94ck.js → chunk-f3hfk78e.js} +1 -1
- package/dist/chunk-f80wwn5x.js +2 -0
- package/dist/chunk-ffqddern.js +2 -0
- package/dist/{chunk-08q58gc0.js → chunk-fjkstnz3.js} +1 -1
- package/dist/{chunk-y1637mma.js → chunk-fskfes13.js} +1 -1
- package/dist/chunk-fxyrvwqw.js +2 -0
- package/dist/{chunk-zkbgy7kj.js → chunk-g3fy0tw8.js} +1 -1
- package/dist/{chunk-c9t5x0rg.js → chunk-gjemavhx.js} +56 -56
- package/dist/{chunk-debdyxmk.js → chunk-gn9q45yp.js} +2 -2
- package/dist/chunk-gp3s8020.js +2 -0
- package/dist/chunk-gzxbnyde.js +2 -0
- package/dist/chunk-j03bare5.js +2 -0
- package/dist/{chunk-azfjfrns.js → chunk-jn6m8zf7.js} +1 -1
- package/dist/{chunk-d8j22791.js → chunk-jt4gqtag.js} +1 -1
- package/dist/{chunk-z4mrwx1z.js → chunk-k4qx7jbk.js} +1 -1
- package/dist/{chunk-4xbakvp1.js → chunk-kdrpx9ft.js} +1 -1
- package/dist/{chunk-4963bekg.js → chunk-kzyhvrp8.js} +1 -1
- package/dist/{chunk-9p25rqhp.js → chunk-mb518a4n.js} +1 -1
- package/dist/{chunk-04k37rg4.js → chunk-mjkfc2v6.js} +1 -1
- package/dist/chunk-mrbw9vts.js +2 -0
- package/dist/chunk-mx8k7bwh.js +2 -0
- package/dist/{chunk-k484xgz0.js → chunk-nvgxjvnb.js} +1 -1
- package/dist/{chunk-b1tjzeb0.js → chunk-p396xrew.js} +1 -1
- package/dist/{chunk-gjhwmkw8.js → chunk-pbk8jxe2.js} +1 -1
- package/dist/{chunk-zbynjn6g.js → chunk-phhzfeh9.js} +1 -1
- package/dist/{chunk-mx5sme23.js → chunk-pmw28376.js} +1 -1
- package/dist/chunk-q68xmak4.js +60 -0
- package/dist/chunk-qccdz9t1.js +3756 -0
- package/dist/{chunk-ha5zt2y3.js → chunk-qd8ggjdx.js} +1 -1
- package/dist/chunk-qp97dx7x.js +2 -0
- package/dist/chunk-r5fp0bse.js +2 -0
- package/dist/{chunk-gdhyfrst.js → chunk-s2284nbk.js} +1 -1
- package/dist/chunk-s5ttqj6h.js +2 -0
- package/dist/chunk-s5y267vs.js +2 -0
- package/dist/{chunk-4z157x30.js → chunk-s67mgegv.js} +1 -1
- package/dist/{chunk-e7avk421.js → chunk-sb7k89hq.js} +1 -1
- package/dist/{chunk-y91519ss.js → chunk-se360fvh.js} +1 -1
- package/dist/{chunk-kr0r8x5w.js → chunk-snknv47x.js} +1 -1
- package/dist/{chunk-z45t29sf.js → chunk-sskbegsz.js} +1 -1
- package/dist/{chunk-3p2w5dag.js → chunk-sw16pkqg.js} +1 -1
- package/dist/{chunk-82kkkpw2.js → chunk-t1k5dpbr.js} +1 -1
- package/dist/{chunk-k47az0ta.js → chunk-vbdca0k1.js} +1 -1
- package/dist/{chunk-ysrwm6fr.js → chunk-vckr41zn.js} +11 -11
- package/dist/{chunk-86d1vte8.js → chunk-vhsrgtcg.js} +1 -1
- package/dist/chunk-vrvehb01.js +2 -0
- package/dist/chunk-w4eykv3z.js +2 -0
- package/dist/{chunk-s6759be9.js → chunk-x0zv8dt4.js} +1 -1
- package/dist/chunk-x11dh3a3.js +2 -0
- package/dist/{chunk-xay59qky.js → chunk-y6kw0wb7.js} +1 -1
- package/dist/{chunk-5mkc9fvx.js → chunk-yq1d9hb3.js} +1 -1
- package/dist/{chunk-xqwmj65h.js → chunk-ysnk7x79.js} +1 -1
- package/dist/chunk-ytgnzeeb.js +2 -0
- package/dist/{chunk-1w9s36v0.js → chunk-zfr4d08r.js} +1 -1
- package/dist/chunk-zkzmxy32.js +2 -0
- package/dist/chunk-zn5jgmqw.js +5 -0
- package/dist/cli.js +14 -14
- package/dist/color-mode-boot.js +10 -6
- package/dist/component-processing.d.ts +40 -2
- package/dist/component-processing.js +13 -2
- package/dist/component-renderer.js +18 -6
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/dev-server/index.d.ts +2 -2
- package/dist/dev-server/index.js +1 -1
- package/dist/dev-server/serve-app.js +12 -12
- package/dist/dev-server/serve-file.js +6 -6
- package/dist/dev-server/serve-multi.js +3 -3
- package/dist/dev-server/ts-css.d.ts +108 -0
- package/dist/dev-server/{crosswind.js → ts-css.js} +86 -88
- package/dist/document-shell.d.ts +1 -1
- package/dist/expressions.js +4 -4
- package/dist/i18n.d.ts +24 -0
- package/dist/i18n.js +45 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/misc-directives.d.ts +0 -11
- package/dist/misc-directives.js +6 -4
- package/dist/process.js +2 -2
- package/dist/production-builder.js +3 -3
- package/dist/pwa.js +2 -2
- package/dist/render-memo.d.ts +1 -1
- package/dist/render.js +2 -2
- package/dist/safe-evaluator.d.ts +0 -15
- package/dist/safe-evaluator.js +12 -2
- package/dist/site-builder/build.d.ts +1 -1
- package/dist/site-builder/build.js +2 -2
- package/dist/ssg.d.ts +2 -2
- package/dist/ssg.js +10 -10
- package/dist/story/collect/analyzer.d.ts +1 -1
- package/dist/story/index.d.ts +2 -2
- package/dist/story/index.js +1 -1
- package/dist/story/renderer.d.ts +3 -3
- package/dist/story/renderer.js +2 -2
- package/dist/story/ts-css.d.ts +29 -0
- package/dist/story/{crosswind.js → ts-css.js} +9 -9
- package/dist/story/types.d.ts +1 -1
- package/dist/theme-tokens.d.ts +1 -1
- package/dist/{crosswind-config.d.ts → ts-css-config.d.ts} +5 -5
- package/dist/{crosswind-config.js → ts-css-config.js} +1 -1
- package/dist/types/config-types.d.ts +3 -3
- package/dist/visual-testing.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-0kexd0d9.js +0 -2
- package/dist/chunk-2218hm3h.js +0 -2
- package/dist/chunk-3rbdvrp0.js +0 -2
- package/dist/chunk-3yg0f94g.js +0 -5
- package/dist/chunk-57y6g4bj.js +0 -2
- package/dist/chunk-61rfw29f.js +0 -2
- package/dist/chunk-8vk9jjf1.js +0 -2
- package/dist/chunk-8x3fhher.js +0 -2
- package/dist/chunk-99ppngnm.js +0 -2
- package/dist/chunk-bavv2k2z.js +0 -2
- package/dist/chunk-bkbnxd7s.js +0 -2
- package/dist/chunk-edctags2.js +0 -2
- package/dist/chunk-gm2wsf2d.js +0 -3
- package/dist/chunk-h0t73k2z.js +0 -3801
- package/dist/chunk-hcjmvwnt.js +0 -2
- package/dist/chunk-hqsadyfr.js +0 -2
- package/dist/chunk-hysmnz0q.js +0 -2
- package/dist/chunk-jkd1185y.js +0 -2
- package/dist/chunk-k7m8p93y.js +0 -2
- package/dist/chunk-nmxc5vnq.js +0 -2
- package/dist/chunk-pghw8xrx.js +0 -2
- package/dist/chunk-pgvskhg2.js +0 -2
- package/dist/chunk-qp1shwek.js +0 -2
- package/dist/chunk-qrx23zbx.js +0 -2
- package/dist/chunk-ragz3hr7.js +0 -2
- package/dist/chunk-rvmt27kv.js +0 -2
- package/dist/chunk-t7snemp0.js +0 -2
- package/dist/chunk-vxskcekj.js +0 -2
- package/dist/chunk-wkb78edm.js +0 -2
- package/dist/chunk-wknpthr7.js +0 -2
- package/dist/chunk-xen25bsv.js +0 -2
- package/dist/chunk-xpxw2ked.js +0 -15
- package/dist/chunk-ydzmhy4c.js +0 -22
- package/dist/dev-server/crosswind.d.ts +0 -132
- package/dist/story/crosswind.d.ts +0 -29
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { hasLocalConfig } from "bunfig";
|
|
3
|
-
import {
|
|
3
|
+
import { mergeCssConfig } from "../ts-css-config.js";
|
|
4
4
|
import { stateDir } from "../state-dir.js";
|
|
5
5
|
import { colors } from "./terminal-colors.js";
|
|
6
6
|
import { contentKey, renderMemo } from "../render-memo.js";
|
|
7
|
-
let
|
|
7
|
+
let cssModule = null, cssLoadAttempted = !1, cachedConfig = null, cachedCSS = "", isBuilding = !1;
|
|
8
8
|
const MAX_CACHE = 256, cssByClassSet = new Map, serveCssByHash = new Map;
|
|
9
9
|
let diskCacheRoot = null, configFingerprint = null;
|
|
10
10
|
function shortHash(input) {
|
|
@@ -26,7 +26,7 @@ function registerServeCss(css) {
|
|
|
26
26
|
serveCssByHash.set(hash, css);
|
|
27
27
|
return hash;
|
|
28
28
|
}
|
|
29
|
-
export function
|
|
29
|
+
export function getCssServeAsset(hash) {
|
|
30
30
|
const css = serveCssByHash.get(hash);
|
|
31
31
|
if (css === void 0)
|
|
32
32
|
return;
|
|
@@ -55,7 +55,7 @@ async function writeDiskCache(key, css) {
|
|
|
55
55
|
await Bun.write(path.join(diskCacheRoot, `cw-${shortHash(key)}.css`), css);
|
|
56
56
|
} catch {}
|
|
57
57
|
}
|
|
58
|
-
async function
|
|
58
|
+
async function tryImportCss(importPath) {
|
|
59
59
|
try {
|
|
60
60
|
const pkg = await import(importPath);
|
|
61
61
|
if (pkg && pkg.CSSGenerator)
|
|
@@ -69,50 +69,52 @@ async function tryImportCrosswind(importPath) {
|
|
|
69
69
|
} catch {}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
const ENGINE_PACKAGE_ENTRIES = [
|
|
73
|
+
["@stacksjs", "ts-css", "dist", "engine", "index.js"],
|
|
74
|
+
["@stacksjs", "ts-css", "src", "engine", "index.ts"]
|
|
75
|
+
], ENGINE_SPECIFIERS = [
|
|
76
|
+
"@stacksjs/ts-css/engine",
|
|
77
|
+
"@stacksjs/ts-css/dist/engine/index.js"
|
|
78
|
+
];
|
|
79
|
+
function findProjectCssPaths() {
|
|
73
80
|
const paths = [];
|
|
74
81
|
let currentDir = process.cwd();
|
|
75
82
|
while (currentDir !== path.dirname(currentDir)) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
paths.push(path.join(currentDir, "pantry", "@cwcss", "crosswind", "src", "index.ts"));
|
|
80
|
-
paths.push(path.join(currentDir, "node_modules", "@stacksjs", "crosswind", "dist", "index.js"));
|
|
81
|
-
paths.push(path.join(currentDir, "pantry", "@stacksjs", "crosswind", "dist", "index.js"));
|
|
83
|
+
for (const store of ["node_modules", "pantry"])
|
|
84
|
+
for (const entry of ENGINE_PACKAGE_ENTRIES)
|
|
85
|
+
paths.push(path.join(currentDir, store, ...entry));
|
|
82
86
|
currentDir = path.dirname(currentDir);
|
|
83
87
|
}
|
|
84
88
|
return paths;
|
|
85
89
|
}
|
|
86
|
-
function
|
|
87
|
-
const paths = [], homeDir = process.env.HOME || process.env.USERPROFILE || ""
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
];
|
|
97
|
-
paths.push(...devPaths);
|
|
90
|
+
function findDevCssPaths() {
|
|
91
|
+
const paths = [], homeDir = process.env.HOME || process.env.USERPROFILE || "", checkouts = [
|
|
92
|
+
homeDir && path.join(homeDir, "Code", "Tools", "crosswind"),
|
|
93
|
+
homeDir && path.join(homeDir, "repos", "stacks-org", "crosswind"),
|
|
94
|
+
path.join(process.cwd(), "..", "crosswind"),
|
|
95
|
+
path.join(process.cwd(), "..", "ts-css")
|
|
96
|
+
].filter(Boolean);
|
|
97
|
+
for (const checkout of checkouts) {
|
|
98
|
+
paths.push(path.join(checkout, "packages", "toolkit", "dist", "engine", "index.js"));
|
|
99
|
+
paths.push(path.join(checkout, "packages", "toolkit", "src", "engine", "index.ts"));
|
|
98
100
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
if (homeDir)
|
|
102
|
+
paths.push(path.join(homeDir, "Code", "Tools", "stx", "node_modules", "@stacksjs", "ts-css", "dist", "engine", "index.js"));
|
|
101
103
|
return paths;
|
|
102
104
|
}
|
|
103
|
-
export async function
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
106
|
-
|
|
105
|
+
export async function loadCssEngine() {
|
|
106
|
+
if (cssLoadAttempted)
|
|
107
|
+
return cssModule;
|
|
108
|
+
cssLoadAttempted = !0;
|
|
107
109
|
try {
|
|
108
110
|
const loadFrom = async (candidates) => {
|
|
109
111
|
for (const candidate of candidates) {
|
|
110
112
|
if (!await Bun.file(candidate).exists())
|
|
111
113
|
continue;
|
|
112
|
-
const result = await
|
|
114
|
+
const result = await tryImportCss(candidate);
|
|
113
115
|
if (result) {
|
|
114
116
|
if (!process.env.STACKS_DEV_QUIET)
|
|
115
|
-
console.log(`${colors.green}[
|
|
117
|
+
console.log(`${colors.green}[ts-css]${colors.reset} CSS engine loaded from ${path.dirname(path.dirname(candidate))}`);
|
|
116
118
|
return result;
|
|
117
119
|
}
|
|
118
120
|
}
|
|
@@ -121,63 +123,59 @@ export async function loadCrosswind() {
|
|
|
121
123
|
if (process.env.CROSSWIND_SRC) {
|
|
122
124
|
const explicitPath = path.resolve(process.env.CROSSWIND_SRC), explicitModule = await loadFrom([explicitPath]);
|
|
123
125
|
if (!explicitModule)
|
|
124
|
-
throw Error(`CROSSWIND_SRC did not resolve to a
|
|
125
|
-
|
|
126
|
-
return
|
|
126
|
+
throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${explicitPath}`);
|
|
127
|
+
cssModule = explicitModule;
|
|
128
|
+
return cssModule;
|
|
127
129
|
}
|
|
128
|
-
const projectModule = await loadFrom(
|
|
130
|
+
const projectModule = await loadFrom(findProjectCssPaths());
|
|
129
131
|
if (projectModule) {
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
+
cssModule = projectModule;
|
|
133
|
+
return cssModule;
|
|
132
134
|
}
|
|
133
|
-
const importPaths =
|
|
134
|
-
"@cwcss/crosswind",
|
|
135
|
-
"@cwcss/crosswind/dist/index.js",
|
|
136
|
-
"@stacksjs/crosswind",
|
|
137
|
-
"@stacksjs/crosswind/dist/index.js"
|
|
138
|
-
];
|
|
135
|
+
const importPaths = ENGINE_SPECIFIERS;
|
|
139
136
|
for (const importPath of importPaths) {
|
|
140
|
-
const result = await
|
|
137
|
+
const result = await tryImportCss(importPath);
|
|
141
138
|
if (result) {
|
|
142
|
-
|
|
139
|
+
cssModule = result;
|
|
143
140
|
if (!process.env.STACKS_DEV_QUIET)
|
|
144
|
-
console.log(`${colors.green}[
|
|
145
|
-
return
|
|
141
|
+
console.log(`${colors.green}[ts-css]${colors.reset} CSS engine loaded`);
|
|
142
|
+
return cssModule;
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
|
-
const devModule = await loadFrom(
|
|
145
|
+
const devModule = await loadFrom(findDevCssPaths());
|
|
149
146
|
if (devModule) {
|
|
150
|
-
|
|
151
|
-
return
|
|
147
|
+
cssModule = devModule;
|
|
148
|
+
return cssModule;
|
|
152
149
|
}
|
|
153
|
-
throw Error("
|
|
150
|
+
throw Error("Css CSSGenerator not found in any location");
|
|
154
151
|
} catch {
|
|
155
|
-
console.warn(`${colors.yellow}[
|
|
156
|
-
console.warn(`${colors.yellow}Run 'bun add @stacksjs/
|
|
152
|
+
console.warn(`${colors.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${colors.reset}`);
|
|
153
|
+
console.warn(`${colors.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${colors.reset}`);
|
|
157
154
|
return null;
|
|
158
155
|
}
|
|
159
156
|
}
|
|
160
157
|
export function resetCssCache() {
|
|
161
158
|
cssByPage.clear();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
export function resetCrosswindCache() {
|
|
166
|
-
cssByPage.clear();
|
|
167
|
-
crosswindModule = null;
|
|
168
|
-
crosswindLoadAttempted = !1;
|
|
159
|
+
cssModule = null;
|
|
160
|
+
cssLoadAttempted = !1;
|
|
169
161
|
cachedConfig = null;
|
|
170
162
|
cachedCSS = "";
|
|
171
163
|
cssByClassSet.clear();
|
|
172
164
|
serveCssByHash.clear();
|
|
173
165
|
configFingerprint = null;
|
|
174
166
|
}
|
|
175
|
-
|
|
167
|
+
let warnedLegacyConfigName = !1;
|
|
168
|
+
export async function loadCssEngineConfig(cwd) {
|
|
176
169
|
try {
|
|
177
|
-
|
|
170
|
+
const name = hasLocalConfig({ name: "css", cwd }) ? "css" : hasLocalConfig({ name: "crosswind", cwd }) ? "crosswind" : null;
|
|
171
|
+
if (!name)
|
|
178
172
|
return null;
|
|
173
|
+
if (name === "crosswind" && !process.env.STACKS_DEV_QUIET && !warnedLegacyConfigName) {
|
|
174
|
+
warnedLegacyConfigName = !0;
|
|
175
|
+
console.warn(`${colors.yellow}[ts-css]${colors.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);
|
|
176
|
+
}
|
|
179
177
|
const { loadConfigWithResult } = await import("bunfig"), result = await loadConfigWithResult({
|
|
180
|
-
name
|
|
178
|
+
name,
|
|
181
179
|
cwd,
|
|
182
180
|
defaultConfig: {},
|
|
183
181
|
checkEnv: !1,
|
|
@@ -187,16 +185,16 @@ export async function loadCrosswindConfig(cwd) {
|
|
|
187
185
|
return null;
|
|
188
186
|
const rel = path.relative(cwd, result.path);
|
|
189
187
|
if (!process.env.STACKS_DEV_QUIET)
|
|
190
|
-
console.log(`${colors.green}[
|
|
188
|
+
console.log(`${colors.green}[ts-css]${colors.reset} Loaded config from ${rel || result.path}`);
|
|
191
189
|
return result.config;
|
|
192
190
|
} catch (error) {
|
|
193
191
|
if (error instanceof Error && error.name === "ConfigNotFoundError")
|
|
194
192
|
return null;
|
|
195
|
-
console.warn(`${colors.yellow}[
|
|
193
|
+
console.warn(`${colors.yellow}[ts-css]${colors.reset} Failed to load css config:`, error instanceof Error ? error.message : error);
|
|
196
194
|
return null;
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
|
-
export async function
|
|
197
|
+
export async function resolveUserCssConfig(resolveRoot) {
|
|
200
198
|
let stxCssConfig = null;
|
|
201
199
|
try {
|
|
202
200
|
const { loadStxConfig } = await import("../config.js"), stxConfig = await loadStxConfig(resolveRoot);
|
|
@@ -206,7 +204,7 @@ export async function resolveUserCrosswindConfig(resolveRoot) {
|
|
|
206
204
|
if (await Bun.file(configPath).exists()) {
|
|
207
205
|
const mod = await import(configPath);
|
|
208
206
|
stxCssConfig = mod.default || mod;
|
|
209
|
-
console.log(`${colors.green}[
|
|
207
|
+
console.log(`${colors.green}[ts-css]${colors.reset} Loaded config from stx.config.ts \u2192 ${stxConfig.css}`);
|
|
210
208
|
}
|
|
211
209
|
} else {
|
|
212
210
|
stxCssConfig = {
|
|
@@ -222,10 +220,10 @@ export async function resolveUserCrosswindConfig(resolveRoot) {
|
|
|
222
220
|
stxCssConfig = { ...mod.default || mod, ...stxCssConfig };
|
|
223
221
|
}
|
|
224
222
|
}
|
|
225
|
-
console.log(`${colors.green}[
|
|
223
|
+
console.log(`${colors.green}[ts-css]${colors.reset} Using inline CSS config from stx.config.ts`);
|
|
226
224
|
}
|
|
227
225
|
} catch {}
|
|
228
|
-
return stxCssConfig || await
|
|
226
|
+
return stxCssConfig || await loadCssEngineConfig(resolveRoot);
|
|
229
227
|
}
|
|
230
228
|
export function fingerprintConfig(config) {
|
|
231
229
|
try {
|
|
@@ -244,18 +242,18 @@ export function fingerprintConfig(config) {
|
|
|
244
242
|
return "unhashable";
|
|
245
243
|
}
|
|
246
244
|
}
|
|
247
|
-
export async function
|
|
245
|
+
export async function buildCss(cwd) {
|
|
248
246
|
if (isBuilding)
|
|
249
247
|
return cachedCSS;
|
|
250
248
|
isBuilding = !0;
|
|
251
249
|
try {
|
|
252
|
-
const hw = await
|
|
250
|
+
const hw = await loadCssEngine();
|
|
253
251
|
if (!hw || !hw.build) {
|
|
254
252
|
isBuilding = !1;
|
|
255
253
|
return "";
|
|
256
254
|
}
|
|
257
255
|
if (!cachedConfig)
|
|
258
|
-
cachedConfig = await
|
|
256
|
+
cachedConfig = await loadCssEngineConfig(cwd);
|
|
259
257
|
if (!cachedConfig) {
|
|
260
258
|
isBuilding = !1;
|
|
261
259
|
return "";
|
|
@@ -273,7 +271,7 @@ export async function buildCrosswindCSS(cwd) {
|
|
|
273
271
|
}
|
|
274
272
|
}, start = performance.now(), result = await hw.build(config), duration = performance.now() - start;
|
|
275
273
|
cachedCSS = result.css;
|
|
276
|
-
console.log(`${colors.cyan}[
|
|
274
|
+
console.log(`${colors.cyan}[ts-css]${colors.reset} Built ${result.classes.size} classes in ${duration.toFixed(1)}ms`);
|
|
277
275
|
if (config.output) {
|
|
278
276
|
const outputPath = path.isAbsolute(config.output) ? config.output : path.join(cwd, config.output), outputDir = path.dirname(outputPath);
|
|
279
277
|
if (!fs.existsSync(outputDir))
|
|
@@ -283,14 +281,14 @@ export async function buildCrosswindCSS(cwd) {
|
|
|
283
281
|
isBuilding = !1;
|
|
284
282
|
return result.css;
|
|
285
283
|
} catch (error) {
|
|
286
|
-
console.error(`${colors.red}[
|
|
284
|
+
console.error(`${colors.red}[ts-css]${colors.reset} Build error:`, error);
|
|
287
285
|
isBuilding = !1;
|
|
288
286
|
return cachedCSS;
|
|
289
287
|
}
|
|
290
288
|
}
|
|
291
|
-
export async function
|
|
289
|
+
export async function rebuildCss(cwd) {
|
|
292
290
|
cachedConfig = null;
|
|
293
|
-
await
|
|
291
|
+
await buildCss(cwd);
|
|
294
292
|
}
|
|
295
293
|
export function getCachedCSS() {
|
|
296
294
|
return cachedCSS;
|
|
@@ -319,18 +317,18 @@ export function extractClassNames(htmlContent) {
|
|
|
319
317
|
return classes;
|
|
320
318
|
}
|
|
321
319
|
const cssByPage = renderMemo(64);
|
|
322
|
-
export async function
|
|
320
|
+
export async function generateCss(htmlContent, appDir) {
|
|
323
321
|
const remembered = cssByPage.get(contentKey(htmlContent, appDir, configFingerprint));
|
|
324
322
|
if (remembered !== void 0)
|
|
325
323
|
return remembered;
|
|
326
|
-
const css = await
|
|
324
|
+
const css = await generateCssUncached(htmlContent, appDir);
|
|
327
325
|
if (css)
|
|
328
326
|
cssByPage.set(contentKey(htmlContent, appDir, configFingerprint), css);
|
|
329
327
|
return css;
|
|
330
328
|
}
|
|
331
|
-
async function
|
|
329
|
+
async function generateCssUncached(htmlContent, appDir) {
|
|
332
330
|
try {
|
|
333
|
-
const hw = await
|
|
331
|
+
const hw = await loadCssEngine();
|
|
334
332
|
if (!hw)
|
|
335
333
|
return "";
|
|
336
334
|
const classes = typeof hw.extractClasses === "function" ? hw.extractClasses(htmlContent) : extractClassNames(htmlContent);
|
|
@@ -350,16 +348,16 @@ async function generateCrosswindCSSUncached(htmlContent, appDir) {
|
|
|
350
348
|
return onDisk;
|
|
351
349
|
}
|
|
352
350
|
if (!cachedConfig) {
|
|
353
|
-
cachedConfig = await
|
|
351
|
+
cachedConfig = await resolveUserCssConfig(resolveRoot);
|
|
354
352
|
configFingerprint = fingerprintConfig(cachedConfig);
|
|
355
353
|
}
|
|
356
|
-
const baseConfig = hw.defaultConfig || hw.config, userConfig = cachedConfig || {}, merged =
|
|
354
|
+
const baseConfig = hw.defaultConfig || hw.config, userConfig = cachedConfig || {}, merged = mergeCssConfig(baseConfig, userConfig), { safelist, includePreflight, minify, tokenCSS } = merged, cssConfig = merged.config, generator = new hw.CSSGenerator(cssConfig);
|
|
357
355
|
for (const cls of safelist)
|
|
358
356
|
generator.generate(cls);
|
|
359
357
|
for (const className of classes)
|
|
360
358
|
generator.generate(className);
|
|
361
359
|
let css = generator.toCSS(includePreflight, minify);
|
|
362
|
-
const shortcuts =
|
|
360
|
+
const shortcuts = cssConfig.shortcuts || userConfig.shortcuts || {};
|
|
363
361
|
for (const [name, classStr] of Object.entries(shortcuts)) {
|
|
364
362
|
if (!classes.has(name) && !safelist.includes(name))
|
|
365
363
|
continue;
|
|
@@ -408,17 +406,17 @@ async function generateCrosswindCSSUncached(htmlContent, appDir) {
|
|
|
408
406
|
writeDiskCache(cacheKey, css);
|
|
409
407
|
return css;
|
|
410
408
|
} catch (error) {
|
|
411
|
-
console.warn("Failed to generate
|
|
409
|
+
console.warn("Failed to generate Css CSS:", error);
|
|
412
410
|
return "";
|
|
413
411
|
}
|
|
414
412
|
}
|
|
415
|
-
export async function
|
|
416
|
-
const css = await
|
|
413
|
+
export async function injectCss(htmlContent, appDir, serveMode = !1) {
|
|
414
|
+
const css = await generateCss(htmlContent, appDir);
|
|
417
415
|
if (!css)
|
|
418
416
|
return htmlContent;
|
|
419
|
-
const assetTag = serveMode ? `<link data-
|
|
417
|
+
const assetTag = serveMode ? `<link data-css="generated" rel="stylesheet" href="/_stx/css.${registerServeCss(css)}.css">` : `<style data-css="generated">
|
|
420
418
|
${css}
|
|
421
|
-
</style>`, existing = /(?:<style\b[^>]*\bdata-
|
|
419
|
+
</style>`, existing = /(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;
|
|
422
420
|
if (existing.test(htmlContent)) {
|
|
423
421
|
let placed = !1;
|
|
424
422
|
return htmlContent.replace(existing, () => {
|
package/dist/document-shell.d.ts
CHANGED
|
@@ -152,7 +152,7 @@ export declare function generateDocumentShell(content: string, headConfig?: AppH
|
|
|
152
152
|
* escaped — that is the XSS path (#1792 item 4).
|
|
153
153
|
*/
|
|
154
154
|
titleIsHtml?: boolean;
|
|
155
|
-
/** Extra styles to inject in <head> (e.g.
|
|
155
|
+
/** Extra styles to inject in <head> (e.g. Css CSS, scoped styles) */
|
|
156
156
|
styles?: string[];
|
|
157
157
|
/** Extra scripts to inject before </body> (e.g. signals runtime, router) */
|
|
158
158
|
bodyScripts?: string[];
|
package/dist/expressions.js
CHANGED
|
@@ -461,10 +461,10 @@ export function processExpressions(template, context, filePath) {
|
|
|
461
461
|
return createDetailedErrorMessage("Expression", `Error evaluating: {{ ${trimmedExpr} }}: ${msg}`, filePath, template, offset, match);
|
|
462
462
|
}
|
|
463
463
|
});
|
|
464
|
-
|
|
465
|
-
output = output.replace(
|
|
466
|
-
|
|
467
|
-
output = output.replace(
|
|
464
|
+
if (scriptBlocks.length > 0)
|
|
465
|
+
output = output.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g, (match, i) => scriptBlocks[Number(i)] ?? match);
|
|
466
|
+
if (styleBlocks.length > 0)
|
|
467
|
+
output = output.replace(/<!--__STX_STYLE_(\d+)__-->/g, (match, i) => styleBlocks[Number(i)] ?? match);
|
|
468
468
|
return output;
|
|
469
469
|
}
|
|
470
470
|
export function applyFilters(value, filterExpression, context) {
|
package/dist/i18n.d.ts
CHANGED
|
@@ -307,6 +307,30 @@ export declare function isICUFormat(message: string): boolean;
|
|
|
307
307
|
* // => '5 items'
|
|
308
308
|
*/
|
|
309
309
|
export declare function getTranslation(key: string, translations: Record<string, any>, fallbackToKey?: boolean, params?: Record<string, any>): string;
|
|
310
|
+
/** Text direction of a document or element. */
|
|
311
|
+
export type TextDirection = 'ltr' | 'rtl';
|
|
312
|
+
/**
|
|
313
|
+
* Resolve the writing direction of a BCP 47 locale tag.
|
|
314
|
+
*
|
|
315
|
+
* An explicit script subtag decides on its own; otherwise the language subtag
|
|
316
|
+
* does. Anything unrecognised is `'ltr'`, which is both the CSS initial value
|
|
317
|
+
* and the safer guess.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* getLocaleDirection('en') // 'ltr'
|
|
321
|
+
* getLocaleDirection('ar-EG') // 'rtl'
|
|
322
|
+
* getLocaleDirection('ha-Arab') // 'rtl' — script overrides the language
|
|
323
|
+
* getLocaleDirection('fa-Latn') // 'ltr' — and in the other direction too
|
|
324
|
+
*/
|
|
325
|
+
export declare function getLocaleDirection(locale: string | undefined | null): TextDirection;
|
|
326
|
+
/**
|
|
327
|
+
* Whether a locale is written right-to-left.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* isRtlLocale('he') // true
|
|
331
|
+
* isRtlLocale('en') // false
|
|
332
|
+
*/
|
|
333
|
+
export declare function isRtlLocale(locale: string | undefined | null): boolean;
|
|
310
334
|
/**
|
|
311
335
|
* Process @translate directive
|
|
312
336
|
*/
|
package/dist/i18n.js
CHANGED
|
@@ -532,6 +532,51 @@ export function getTranslation(key, translations, fallbackToKey = !0, params = {
|
|
|
532
532
|
}
|
|
533
533
|
return result;
|
|
534
534
|
}
|
|
535
|
+
const RTL_LANGUAGES = new Set([
|
|
536
|
+
"ar",
|
|
537
|
+
"arc",
|
|
538
|
+
"ckb",
|
|
539
|
+
"dv",
|
|
540
|
+
"fa",
|
|
541
|
+
"he",
|
|
542
|
+
"khw",
|
|
543
|
+
"ks",
|
|
544
|
+
"nqo",
|
|
545
|
+
"prs",
|
|
546
|
+
"ps",
|
|
547
|
+
"sd",
|
|
548
|
+
"syr",
|
|
549
|
+
"ug",
|
|
550
|
+
"ur",
|
|
551
|
+
"uz-af",
|
|
552
|
+
"yi"
|
|
553
|
+
]), RTL_SCRIPTS = new Set([
|
|
554
|
+
"adlm",
|
|
555
|
+
"arab",
|
|
556
|
+
"aran",
|
|
557
|
+
"hebr",
|
|
558
|
+
"nkoo",
|
|
559
|
+
"rohg",
|
|
560
|
+
"syrc",
|
|
561
|
+
"thaa",
|
|
562
|
+
"yezi"
|
|
563
|
+
]);
|
|
564
|
+
export function getLocaleDirection(locale) {
|
|
565
|
+
if (!locale)
|
|
566
|
+
return "ltr";
|
|
567
|
+
const subtags = locale.trim().toLowerCase().replace(/_/g, "-").split("-"), language = subtags[0];
|
|
568
|
+
if (!language)
|
|
569
|
+
return "ltr";
|
|
570
|
+
const script = subtags[1]?.length === 4 ? subtags[1] : void 0;
|
|
571
|
+
if (script)
|
|
572
|
+
return RTL_SCRIPTS.has(script) ? "rtl" : "ltr";
|
|
573
|
+
if (subtags.length > 1 && RTL_LANGUAGES.has(`${language}-${subtags[1]}`))
|
|
574
|
+
return "rtl";
|
|
575
|
+
return RTL_LANGUAGES.has(language) ? "rtl" : "ltr";
|
|
576
|
+
}
|
|
577
|
+
export function isRtlLocale(locale) {
|
|
578
|
+
return getLocaleDirection(locale) === "rtl";
|
|
579
|
+
}
|
|
535
580
|
export async function processTranslateDirective(template, context, filePath, options) {
|
|
536
581
|
let output = template;
|
|
537
582
|
const fixedTranslateRegex = /@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g, i18nConfig = {
|
package/dist/index.d.ts
CHANGED
|
@@ -271,9 +271,9 @@ export * from './dynamic-components';
|
|
|
271
271
|
export { definePlugin, pluginManager } from './plugin-system';
|
|
272
272
|
// These modules are exported first to establish their types
|
|
273
273
|
export * from './render';
|
|
274
|
-
export { extractClassNames,
|
|
275
|
-
// One
|
|
276
|
-
export { deepMergeThemes,
|
|
274
|
+
export { extractClassNames, generateCss, getCssServeAsset, injectCss } from './dev-server/ts-css';
|
|
275
|
+
// One css merge shared by every render path (#1867)
|
|
276
|
+
export { deepMergeThemes, mergeCssConfig, type MergedCssConfig } from './ts-css-config';
|
|
277
277
|
// Dev-mode invalidation for the store/composable bundles (#1877)
|
|
278
278
|
export { clearStoreCache, getStoreScript } from './store-loader';
|
|
279
279
|
export { clearComposableCache } from './composable-loader';
|
package/dist/index.js
CHANGED
|
@@ -156,8 +156,8 @@ export { createApp, createApp as createStxApp, defineCustomElement } from "./app
|
|
|
156
156
|
export * from "./dynamic-components.js";
|
|
157
157
|
export { definePlugin, pluginManager } from "./plugin-system.js";
|
|
158
158
|
export * from "./render.js";
|
|
159
|
-
export { extractClassNames,
|
|
160
|
-
export { deepMergeThemes,
|
|
159
|
+
export { extractClassNames, generateCss, getCssServeAsset, injectCss } from "./dev-server/ts-css.js";
|
|
160
|
+
export { deepMergeThemes, mergeCssConfig } from "./ts-css-config.js";
|
|
161
161
|
export { clearStoreCache, getStoreScript } from "./store-loader.js";
|
|
162
162
|
export { clearComposableCache } from "./composable-loader.js";
|
|
163
163
|
export { discoverLayoutNames, generateLayoutTypes, LAYOUT_TYPES_FILE, renderLayoutTypes } from "./layout-types.js";
|
|
@@ -52,15 +52,4 @@ export declare function processRefAttributes(template: string): string;
|
|
|
52
52
|
* element carrying `x-no-cloak` is left visible regardless.
|
|
53
53
|
*/
|
|
54
54
|
export declare function addCloakToUnresolvedExpressions(html: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* Add x-cloak to every element carrying a reactive conditional / visibility
|
|
57
|
-
* directive (:if, :else, :else-if, :show, x-if, x-else, x-else-if, x-show,
|
|
58
|
-
* and the @if / @show element-attribute forms).
|
|
59
|
-
*
|
|
60
|
-
* Without this, false branches and hidden elements paint before the runtime
|
|
61
|
-
* hides them — the FOUC described in stacksjs/stx#1736. The runtime already
|
|
62
|
-
* strips x-cloak the moment it processes each element, so this is purely an
|
|
63
|
-
* SSR-side additive pass; hand-written x-cloak is preserved (we skip tags
|
|
64
|
-
* that already have it).
|
|
65
|
-
*/
|
|
66
55
|
export declare function addCloakToConditionalDirectives(html: string): string;
|
package/dist/misc-directives.js
CHANGED
|
@@ -242,16 +242,18 @@ export function addCloakToUnresolvedExpressions(html) {
|
|
|
242
242
|
result += html.slice(lastIndex);
|
|
243
243
|
return result;
|
|
244
244
|
}
|
|
245
|
-
const CONDITIONAL_DIRECTIVE_RE = /(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)
|
|
245
|
+
const CONDITIONAL_DIRECTIVE_RE = /(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/, SCRIPT_CLOSE_TAG = /<\/script>/gi, STYLE_CLOSE_TAG = /<\/style>/gi;
|
|
246
246
|
export function addCloakToConditionalDirectives(html) {
|
|
247
247
|
const tagStartRe = /<[a-z][\w-]*/gi;
|
|
248
248
|
let result = "", lastIndex = 0, tagMatch;
|
|
249
249
|
while ((tagMatch = tagStartRe.exec(html)) !== null) {
|
|
250
250
|
const tagOpenStart = tagMatch.index, tagName = tagMatch[0].slice(1).toLowerCase();
|
|
251
251
|
if (tagName === "script" || tagName === "style") {
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
const closeRe = tagName === "script" ? SCRIPT_CLOSE_TAG : STYLE_CLOSE_TAG;
|
|
253
|
+
closeRe.lastIndex = tagOpenStart;
|
|
254
|
+
const close = closeRe.exec(html);
|
|
255
|
+
if (close !== null)
|
|
256
|
+
tagStartRe.lastIndex = close.index + close[0].length;
|
|
255
257
|
continue;
|
|
256
258
|
}
|
|
257
259
|
let i = tagOpenStart + tagMatch[0].length, inSingleQuote = !1, inDoubleQuote = !1, tagCloseIdx = -1;
|
package/dist/process.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { injectCss } from "./dev-server/ts-css.js";
|
|
4
4
|
import { findBodyOpenTag, replaceBodyOpenTag } from "./find-body-tag.js";
|
|
5
5
|
import { matchHtmlComment, matchStyleElement, maskAtElementPosition, stashScriptElements } from "./html-masking.js";
|
|
6
6
|
import { processA11yDirectives } from "./a11y.js";
|
|
@@ -360,7 +360,7 @@ ${tag}`).join("");
|
|
|
360
360
|
if (isTopLevel)
|
|
361
361
|
result = normalizeCriticalHeadOrder(result);
|
|
362
362
|
if (isTopLevel && context.__stx_inject_css !== !1)
|
|
363
|
-
result = await
|
|
363
|
+
result = await injectCss(result, void 0, options.buildMode === "serve");
|
|
364
364
|
if (isTopLevel)
|
|
365
365
|
result = dedupeScopedStyles(result);
|
|
366
366
|
result = result.replace(/\x00STX_ESCAPED_AT\x00/g, "@");
|
|
@@ -8,7 +8,7 @@ import { generateManifest, writeManifest } from "./manifest.js";
|
|
|
8
8
|
import { injectColorModeBootScript } from "./color-mode-boot.js";
|
|
9
9
|
import { applyHtmlAttrs, ensureDocumentShell } from "./document-shell.js";
|
|
10
10
|
import { extractContainerContent } from "./app-shell.js";
|
|
11
|
-
import {
|
|
11
|
+
import { injectCss } from "./dev-server/ts-css.js";
|
|
12
12
|
import { loadStxConfig } from "./config.js";
|
|
13
13
|
const PUBLIC_ASSET_BLOCKLIST = new Set([
|
|
14
14
|
".DS_Store",
|
|
@@ -100,8 +100,8 @@ export async function buildForProduction(options = {}) {
|
|
|
100
100
|
compiled.html = compiled.html.replace(/<body([^>]*)>/, `<body$1 ${dataStxAttr}>`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
compiled.html = compiled.html.replace(/<style data-
|
|
104
|
-
compiled.html = await
|
|
103
|
+
compiled.html = compiled.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g, "");
|
|
104
|
+
compiled.html = await injectCss(compiled.html);
|
|
105
105
|
compiled.fragment = extractContainerContent(compiled.html, routerContainer);
|
|
106
106
|
const safeRouteName = route.pattern === "/" ? "index" : route.pattern.slice(1).replace(/\//g, "-").replace(/[[\]]/g, "_"), compiledPath = path.join("server", "pages", `${safeRouteName}.compiled.json`), fragmentPath = path.join("server", "fragments", `${safeRouteName}.html`);
|
|
107
107
|
await Bun.write(path.join(outputDir, compiledPath), JSON.stringify(compiled, null, 2));
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
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-
|
|
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-
|
|
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-s2284nbk.js";import{$u as Pq,Wu as Aq,Xu as bq,Yu as Sq,Zu as zq,_u as Dq}from"./chunk-jn6m8zf7.js";import{dv as N}from"./chunk-sskbegsz.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-gp3s8020.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">
|
package/dist/render-memo.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* SSR of an unchanged view re-ran every stage on the same bytes: the component
|
|
5
5
|
* bundle was read from disk, re-wrapped and re-inlined; the DOM-API validator
|
|
6
|
-
* re-scanned the same script; the composable scan and the
|
|
6
|
+
* re-scanned the same script; the composable scan and the css class
|
|
7
7
|
* extraction walked the same few hundred KB of page. The JS heap stayed flat —
|
|
8
8
|
* nothing was retained — but each stage makes native copies of a large string,
|
|
9
9
|
* and the allocator's high-water mark climbed by megabytes per render. The
|