@fluixi/core 1.0.0-alpha.100
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/LICENSE +21 -0
- package/README.md +334 -0
- package/dist/cdn/core.global.js +2 -0
- package/dist/cli/generate.cjs +5639 -0
- package/dist/cli/generate.d.ts +7 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +2580 -0
- package/dist/cli/generate.mjs +5644 -0
- package/dist/cli/index.cjs +5639 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2580 -0
- package/dist/cli/index.mjs +5644 -0
- package/dist/cli/run.cjs +64 -0
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +62 -0
- package/dist/cli/run.mjs +40 -0
- package/dist/fluixi.d.ts +5 -0
- package/dist/src/cdn/chunk-RKBFEFZP.mjs +987 -0
- package/dist/src/cdn/core.cjs +1592 -0
- package/dist/src/cdn/core.d.ts +16 -0
- package/dist/src/cdn/core.d.ts.map +1 -0
- package/dist/src/cdn/core.js +15 -0
- package/dist/src/cdn/core.mjs +714 -0
- package/dist/src/cdn/router-V2THK27H.mjs +74 -0
- package/dist/src/index.cjs +1711 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.mjs +1833 -0
- package/dist/src/jsx-dev-runtime.cjs +26 -0
- package/dist/src/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/jsx-dev-runtime.js +1 -0
- package/dist/src/jsx-dev-runtime.mjs +24 -0
- package/dist/src/jsx-runtime.cjs +26 -0
- package/dist/src/jsx-runtime.d.ts +7 -0
- package/dist/src/jsx-runtime.d.ts.map +1 -0
- package/dist/src/jsx-runtime.js +8 -0
- package/dist/src/jsx-runtime.mjs +24 -0
- package/dist/src/lib/client/chunk-FDOPDB6Z.mjs +53 -0
- package/dist/src/lib/client/index.cjs +1210 -0
- package/dist/src/lib/client/index.d.ts +51 -0
- package/dist/src/lib/client/index.d.ts.map +1 -0
- package/dist/src/lib/client/index.js +174 -0
- package/dist/src/lib/client/index.mjs +293 -0
- package/dist/src/lib/client/router-4PTBPZLQ.mjs +891 -0
- package/dist/src/lib/context/context.cjs +81 -0
- package/dist/src/lib/context/context.d.ts +73 -0
- package/dist/src/lib/context/context.d.ts.map +1 -0
- package/dist/src/lib/context/context.js +93 -0
- package/dist/src/lib/context/context.mjs +64 -0
- package/dist/src/lib/context/index.cjs +83 -0
- package/dist/src/lib/context/index.d.ts +3 -0
- package/dist/src/lib/context/index.d.ts.map +1 -0
- package/dist/src/lib/context/index.js +1 -0
- package/dist/src/lib/context/index.mjs +64 -0
- package/dist/src/lib/control-flow.cjs +35 -0
- package/dist/src/lib/control-flow.d.ts +4 -0
- package/dist/src/lib/control-flow.d.ts.map +1 -0
- package/dist/src/lib/control-flow.js +1 -0
- package/dist/src/lib/control-flow.mjs +25 -0
- package/dist/src/lib/core.cjs +1710 -0
- package/dist/src/lib/core.d.ts +91 -0
- package/dist/src/lib/core.d.ts.map +1 -0
- package/dist/src/lib/core.js +158 -0
- package/dist/src/lib/core.mjs +1833 -0
- package/dist/src/lib/env/index.cjs +44 -0
- package/dist/src/lib/env/index.d.ts +26 -0
- package/dist/src/lib/env/index.d.ts.map +1 -0
- package/dist/src/lib/env/index.js +31 -0
- package/dist/src/lib/env/index.mjs +23 -0
- package/dist/src/lib/i18n/index.cjs +123 -0
- package/dist/src/lib/i18n/index.d.ts +110 -0
- package/dist/src/lib/i18n/index.d.ts.map +1 -0
- package/dist/src/lib/i18n/index.js +164 -0
- package/dist/src/lib/i18n/index.mjs +103 -0
- package/dist/src/lib/index.cjs +598 -0
- package/dist/src/lib/index.d.ts +81 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +130 -0
- package/dist/src/lib/index.mjs +688 -0
- package/dist/src/lib/isomorphic.cjs +90 -0
- package/dist/src/lib/isomorphic.d.ts +114 -0
- package/dist/src/lib/isomorphic.d.ts.map +1 -0
- package/dist/src/lib/isomorphic.js +132 -0
- package/dist/src/lib/isomorphic.mjs +69 -0
- package/dist/src/lib/jsx-runtime/index.cjs +21 -0
- package/dist/src/lib/jsx-runtime/index.d.ts +13 -0
- package/dist/src/lib/jsx-runtime/index.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/index.js +13 -0
- package/dist/src/lib/jsx-runtime/index.mjs +4 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.js +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +35 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.js +118 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -0
- package/dist/src/lib/plugins/index.cjs +311 -0
- package/dist/src/lib/plugins/index.d.ts +6 -0
- package/dist/src/lib/plugins/index.d.ts.map +1 -0
- package/dist/src/lib/plugins/index.js +7 -0
- package/dist/src/lib/plugins/index.mjs +279 -0
- package/dist/src/lib/plugins/route-codegen.cjs +73 -0
- package/dist/src/lib/plugins/route-codegen.d.ts +12 -0
- package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-codegen.js +80 -0
- package/dist/src/lib/plugins/route-codegen.mjs +52 -0
- package/dist/src/lib/plugins/route-scanner.cjs +189 -0
- package/dist/src/lib/plugins/route-scanner.d.ts +38 -0
- package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-scanner.js +215 -0
- package/dist/src/lib/plugins/route-scanner.mjs +158 -0
- package/dist/src/lib/plugins/vite.cjs +27 -0
- package/dist/src/lib/plugins/vite.d.ts +3 -0
- package/dist/src/lib/plugins/vite.d.ts.map +1 -0
- package/dist/src/lib/plugins/vite.js +1 -0
- package/dist/src/lib/plugins/vite.mjs +6 -0
- package/dist/src/lib/render/await.cjs +38 -0
- package/dist/src/lib/render/await.d.ts +26 -0
- package/dist/src/lib/render/await.d.ts.map +1 -0
- package/dist/src/lib/render/await.js +45 -0
- package/dist/src/lib/render/await.mjs +17 -0
- package/dist/src/lib/render/component.cjs +221 -0
- package/dist/src/lib/render/component.d.ts +296 -0
- package/dist/src/lib/render/component.d.ts.map +1 -0
- package/dist/src/lib/render/component.js +514 -0
- package/dist/src/lib/render/component.mjs +214 -0
- package/dist/src/lib/render/deferred.cjs +175 -0
- package/dist/src/lib/render/deferred.d.ts +36 -0
- package/dist/src/lib/render/deferred.d.ts.map +1 -0
- package/dist/src/lib/render/deferred.js +141 -0
- package/dist/src/lib/render/deferred.mjs +158 -0
- package/dist/src/lib/render/index.cjs +573 -0
- package/dist/src/lib/render/index.d.ts +98 -0
- package/dist/src/lib/render/index.d.ts.map +1 -0
- package/dist/src/lib/render/index.js +180 -0
- package/dist/src/lib/render/index.mjs +590 -0
- package/dist/src/lib/render/lazy.cjs +67 -0
- package/dist/src/lib/render/lazy.d.ts +49 -0
- package/dist/src/lib/render/lazy.d.ts.map +1 -0
- package/dist/src/lib/render/lazy.js +105 -0
- package/dist/src/lib/render/lazy.mjs +50 -0
- package/dist/src/lib/render/suspense.cjs +141 -0
- package/dist/src/lib/render/suspense.d.ts +65 -0
- package/dist/src/lib/render/suspense.d.ts.map +1 -0
- package/dist/src/lib/render/suspense.js +196 -0
- package/dist/src/lib/render/suspense.mjs +136 -0
- package/dist/src/lib/render/versions.cjs +35 -0
- package/dist/src/lib/render/versions.d.ts +2 -0
- package/dist/src/lib/render/versions.d.ts.map +1 -0
- package/dist/src/lib/render/versions.js +21 -0
- package/dist/src/lib/render/versions.mjs +14 -0
- package/dist/src/lib/router/data.cjs +228 -0
- package/dist/src/lib/router/data.d.ts +142 -0
- package/dist/src/lib/router/data.d.ts.map +1 -0
- package/dist/src/lib/router/data.js +258 -0
- package/dist/src/lib/router/data.mjs +214 -0
- package/dist/src/lib/router/index.cjs +921 -0
- package/dist/src/lib/router/index.d.ts +274 -0
- package/dist/src/lib/router/index.d.ts.map +1 -0
- package/dist/src/lib/router/index.js +904 -0
- package/dist/src/lib/router/index.mjs +938 -0
- package/dist/src/lib/router/scroll.cjs +79 -0
- package/dist/src/lib/router/scroll.d.ts +19 -0
- package/dist/src/lib/router/scroll.d.ts.map +1 -0
- package/dist/src/lib/router/scroll.js +68 -0
- package/dist/src/lib/router/scroll.mjs +58 -0
- package/dist/src/lib/router/transition.cjs +75 -0
- package/dist/src/lib/router/transition.d.ts +81 -0
- package/dist/src/lib/router/transition.d.ts.map +1 -0
- package/dist/src/lib/router/transition.js +136 -0
- package/dist/src/lib/router/transition.mjs +54 -0
- package/dist/src/lib/server/hydration.cjs +169 -0
- package/dist/src/lib/server/hydration.d.ts +198 -0
- package/dist/src/lib/server/hydration.d.ts.map +1 -0
- package/dist/src/lib/server/hydration.js +345 -0
- package/dist/src/lib/server/hydration.mjs +148 -0
- package/dist/src/lib/server/index.cjs +406 -0
- package/dist/src/lib/server/index.d.ts +115 -0
- package/dist/src/lib/server/index.d.ts.map +1 -0
- package/dist/src/lib/server/index.js +164 -0
- package/dist/src/lib/server/index.mjs +384 -0
- package/dist/src/lib/server/reactive.cjs +197 -0
- package/dist/src/lib/server/reactive.d.ts +239 -0
- package/dist/src/lib/server/reactive.d.ts.map +1 -0
- package/dist/src/lib/server/reactive.js +413 -0
- package/dist/src/lib/server/reactive.mjs +176 -0
- package/dist/src/lib/storage/cache.cjs +51 -0
- package/dist/src/lib/storage/cache.d.ts +18 -0
- package/dist/src/lib/storage/cache.d.ts.map +1 -0
- package/dist/src/lib/storage/cache.js +42 -0
- package/dist/src/lib/storage/cache.mjs +30 -0
- package/dist/src/lib/storage/index.cjs +246 -0
- package/dist/src/lib/storage/index.d.ts +83 -0
- package/dist/src/lib/storage/index.d.ts.map +1 -0
- package/dist/src/lib/storage/index.js +179 -0
- package/dist/src/lib/storage/index.mjs +231 -0
- package/dist/src/lib/storage/persisted.cjs +91 -0
- package/dist/src/lib/storage/persisted.d.ts +53 -0
- package/dist/src/lib/storage/persisted.d.ts.map +1 -0
- package/dist/src/lib/storage/persisted.js +75 -0
- package/dist/src/lib/storage/persisted.mjs +70 -0
- package/dist/src/lib/theme/color-scheme.cjs +281 -0
- package/dist/src/lib/theme/color-scheme.d.ts +61 -0
- package/dist/src/lib/theme/color-scheme.d.ts.map +1 -0
- package/dist/src/lib/theme/color-scheme.js +120 -0
- package/dist/src/lib/theme/color-scheme.mjs +265 -0
- package/dist/src/lib/theme/index.cjs +267 -0
- package/dist/src/lib/theme/index.d.ts +78 -0
- package/dist/src/lib/theme/index.d.ts.map +1 -0
- package/dist/src/lib/theme/index.js +135 -0
- package/dist/src/lib/theme/index.mjs +251 -0
- package/dist/src/lib/theme/provider.cjs +346 -0
- package/dist/src/lib/theme/provider.d.ts +34 -0
- package/dist/src/lib/theme/provider.d.ts.map +1 -0
- package/dist/src/lib/theme/provider.js +60 -0
- package/dist/src/lib/theme/provider.mjs +332 -0
- package/dist/src/lib/utils/index.cjs +209 -0
- package/dist/src/lib/utils/index.d.ts +286 -0
- package/dist/src/lib/utils/index.d.ts.map +1 -0
- package/dist/src/lib/utils/index.js +434 -0
- package/dist/src/lib/utils/index.mjs +188 -0
- package/dist/src/routes.cjs +37 -0
- package/dist/src/routes.d.ts +22 -0
- package/dist/src/routes.d.ts.map +1 -0
- package/dist/src/routes.js +20 -0
- package/dist/src/routes.mjs +17 -0
- package/dist/src/server.cjs +405 -0
- package/dist/src/server.d.ts +63 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +62 -0
- package/dist/src/server.mjs +382 -0
- package/dist/src/utils.cjs +21 -0
- package/dist/src/utils.d.ts +10 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +9 -0
- package/dist/src/utils.mjs +4 -0
- package/dist/src/version.generated.cjs +26 -0
- package/dist/src/version.generated.d.ts +3 -0
- package/dist/src/version.generated.d.ts.map +1 -0
- package/dist/src/version.generated.js +3 -0
- package/dist/src/version.generated.mjs +5 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +164 -0
- package/src/index.ts +19 -0
- package/types/fluixi.d.ts +5 -0
- package/types/vinxi.d.ts +50 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// src/lib/utils/index.ts
|
|
2
|
+
function debounce(fn, delay) {
|
|
3
|
+
let timeoutId;
|
|
4
|
+
return (...args) => {
|
|
5
|
+
clearTimeout(timeoutId);
|
|
6
|
+
timeoutId = setTimeout(() => fn(...args), delay);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function throttle(fn, limit) {
|
|
10
|
+
let inThrottle;
|
|
11
|
+
return (...args) => {
|
|
12
|
+
if (!inThrottle) {
|
|
13
|
+
fn(...args);
|
|
14
|
+
inThrottle = true;
|
|
15
|
+
setTimeout(() => inThrottle = false, limit);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function memoize(fn) {
|
|
20
|
+
const cache = /* @__PURE__ */ new Map();
|
|
21
|
+
return ((...args) => {
|
|
22
|
+
const key = JSON.stringify(args);
|
|
23
|
+
if (cache.has(key)) {
|
|
24
|
+
return cache.get(key);
|
|
25
|
+
}
|
|
26
|
+
const result = fn(...args);
|
|
27
|
+
cache.set(key, result);
|
|
28
|
+
return result;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function deepClone(obj) {
|
|
32
|
+
if (obj === null || typeof obj !== "object") {
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
if (obj instanceof Date) {
|
|
36
|
+
return new Date(obj.getTime());
|
|
37
|
+
}
|
|
38
|
+
if (obj instanceof Array) {
|
|
39
|
+
return Array.from(obj).map((item) => deepClone(item));
|
|
40
|
+
}
|
|
41
|
+
if (obj instanceof Set) {
|
|
42
|
+
return new Set(Array.from(obj).map((item) => deepClone(item)));
|
|
43
|
+
}
|
|
44
|
+
if (obj instanceof Map) {
|
|
45
|
+
return new Map(
|
|
46
|
+
Array.from(obj.entries()).map(([key, value]) => [
|
|
47
|
+
deepClone(key),
|
|
48
|
+
deepClone(value)
|
|
49
|
+
])
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
const clonedObj = {};
|
|
53
|
+
for (const key in obj) {
|
|
54
|
+
if (obj.hasOwnProperty(key)) {
|
|
55
|
+
clonedObj[key] = deepClone(obj[key]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return clonedObj;
|
|
59
|
+
}
|
|
60
|
+
function deepMerge(...objects) {
|
|
61
|
+
const result = {};
|
|
62
|
+
for (const obj of objects) {
|
|
63
|
+
for (const key in obj) {
|
|
64
|
+
if (obj.hasOwnProperty(key)) {
|
|
65
|
+
const value = obj[key];
|
|
66
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
67
|
+
result[key] = deepMerge(
|
|
68
|
+
result[key] || {},
|
|
69
|
+
value
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
result[key] = value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
function uniqueId(prefix = "") {
|
|
80
|
+
return prefix + Math.random().toString(36).substr(2, 9);
|
|
81
|
+
}
|
|
82
|
+
function formatNumber(num) {
|
|
83
|
+
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
84
|
+
}
|
|
85
|
+
function formatBytes(bytes, decimals = 2) {
|
|
86
|
+
if (bytes === 0) return "0 Bytes";
|
|
87
|
+
const k = 1024;
|
|
88
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
89
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB"];
|
|
90
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
91
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
92
|
+
}
|
|
93
|
+
function capitalize(str) {
|
|
94
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
95
|
+
}
|
|
96
|
+
function kebabCase(str) {
|
|
97
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
98
|
+
}
|
|
99
|
+
function camelCase(str) {
|
|
100
|
+
return str.replace(/[-_\s](.)/g, (_, char) => char.toUpperCase());
|
|
101
|
+
}
|
|
102
|
+
function clamp(value, min, max) {
|
|
103
|
+
return Math.min(Math.max(value, min), max);
|
|
104
|
+
}
|
|
105
|
+
function random(min, max) {
|
|
106
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
107
|
+
}
|
|
108
|
+
function isEmpty(value) {
|
|
109
|
+
if (value === null || value === void 0) return true;
|
|
110
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
111
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
112
|
+
if (typeof value === "object") return Object.keys(value).length === 0;
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
function pick(obj, ...keys) {
|
|
116
|
+
const result = {};
|
|
117
|
+
keys.forEach((key) => {
|
|
118
|
+
if (key in obj) {
|
|
119
|
+
result[key] = obj[key];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
function omit(obj, ...keys) {
|
|
125
|
+
const result = { ...obj };
|
|
126
|
+
keys.forEach((key) => {
|
|
127
|
+
delete result[key];
|
|
128
|
+
});
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
function groupBy(array, fn) {
|
|
132
|
+
return array.reduce((acc, item) => {
|
|
133
|
+
const key = fn(item);
|
|
134
|
+
const group = acc.get(key) || [];
|
|
135
|
+
group.push(item);
|
|
136
|
+
acc.set(key, group);
|
|
137
|
+
return acc;
|
|
138
|
+
}, /* @__PURE__ */ new Map());
|
|
139
|
+
}
|
|
140
|
+
function range(start, end, step = 1) {
|
|
141
|
+
const result = [];
|
|
142
|
+
for (let i = start; i <= end; i += step) {
|
|
143
|
+
result.push(i);
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
async function retry(fn, retries = 3, delay = 1e3) {
|
|
148
|
+
try {
|
|
149
|
+
return await fn();
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (retries <= 0) throw error;
|
|
152
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
153
|
+
return retry(fn, retries - 1, delay);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function sleep(ms) {
|
|
157
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
158
|
+
}
|
|
159
|
+
function isDefined(value) {
|
|
160
|
+
return value !== null && value !== void 0;
|
|
161
|
+
}
|
|
162
|
+
function pipe(...fns) {
|
|
163
|
+
return (arg) => fns.reduce((acc, fn) => fn(acc), arg);
|
|
164
|
+
}
|
|
165
|
+
export {
|
|
166
|
+
camelCase,
|
|
167
|
+
capitalize,
|
|
168
|
+
clamp,
|
|
169
|
+
debounce,
|
|
170
|
+
deepClone,
|
|
171
|
+
deepMerge,
|
|
172
|
+
formatBytes,
|
|
173
|
+
formatNumber,
|
|
174
|
+
groupBy,
|
|
175
|
+
isDefined,
|
|
176
|
+
isEmpty,
|
|
177
|
+
kebabCase,
|
|
178
|
+
memoize,
|
|
179
|
+
omit,
|
|
180
|
+
pick,
|
|
181
|
+
pipe,
|
|
182
|
+
random,
|
|
183
|
+
range,
|
|
184
|
+
retry,
|
|
185
|
+
sleep,
|
|
186
|
+
throttle,
|
|
187
|
+
uniqueId
|
|
188
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*! @fluixi/core v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/routes.ts
|
|
22
|
+
var routes_exports = {};
|
|
23
|
+
__export(routes_exports, {
|
|
24
|
+
routes: () => routes
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(routes_exports);
|
|
27
|
+
function missingPlugin() {
|
|
28
|
+
throw new Error(
|
|
29
|
+
"[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, so there is no route tree. Add the plugin to your Vite config, or, in a @fluixi/start app, build with `fluixi build`/`fluixi dev` rather than calling vite directly."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
var routes = new Proxy([], {
|
|
33
|
+
get: (target, key) => (
|
|
34
|
+
// `then` is probed by any `await`; answering undefined keeps this from looking thenable.
|
|
35
|
+
key === "then" ? void 0 : missingPlugin()
|
|
36
|
+
)
|
|
37
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The file-system route tree.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { routes } from '@fluixi/core/routes';
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* This module is a **typed stand-in**. `fluixiRoutesPlugin` intercepts the specifier and
|
|
9
|
+
* serves the generated tree in its place, so what you import at runtime is the real thing
|
|
10
|
+
* scanned from `src/routes`.
|
|
11
|
+
*
|
|
12
|
+
* It exists as a real module so the types come from this package rather than from an
|
|
13
|
+
* ambient `declare module` the plugin writes into your `src/`. That generated file could
|
|
14
|
+
* drift, raised a gitignore question, and left `virtual:fluixi-routes` invisible to
|
|
15
|
+
* anything not running the Vite plugin: plain `tsc`, an editor, a test runner.
|
|
16
|
+
*
|
|
17
|
+
* `virtual:fluixi-routes` still resolves, so existing apps keep working.
|
|
18
|
+
*/
|
|
19
|
+
import type { RouteDefinition } from './lib/router/index.js';
|
|
20
|
+
/** Routes discovered under the configured routes directory (default `src/routes`). */
|
|
21
|
+
export declare const routes: RouteDefinition[];
|
|
22
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAmB7D,sFAAsF;AACtF,eAAO,MAAM,MAAM,EAAE,eAAe,EAIlC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reaching this code means the plugin did not replace the module.
|
|
3
|
+
*
|
|
4
|
+
* The alternative, exporting an empty array, is worse than it looks: the app builds, the
|
|
5
|
+
* router mounts, and every route 404s with nothing to explain why. A virtual specifier at
|
|
6
|
+
* least failed loudly when the plugin was missing, and giving that up for better types
|
|
7
|
+
* should not also give up the error. TypeScript never evaluates this, so type-checking is
|
|
8
|
+
* unaffected.
|
|
9
|
+
*/
|
|
10
|
+
function missingPlugin() {
|
|
11
|
+
throw new Error("[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, " +
|
|
12
|
+
'so there is no route tree. Add the plugin to your Vite config, or, in a @fluixi/start ' +
|
|
13
|
+
'app, build with `fluixi build`/`fluixi dev` rather than calling vite directly.');
|
|
14
|
+
}
|
|
15
|
+
/** Routes discovered under the configured routes directory (default `src/routes`). */
|
|
16
|
+
export const routes = new Proxy([], {
|
|
17
|
+
get: (target, key) =>
|
|
18
|
+
// `then` is probed by any `await`; answering undefined keeps this from looking thenable.
|
|
19
|
+
key === 'then' ? undefined : missingPlugin(),
|
|
20
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*! @fluixi/core v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/routes.ts
|
|
4
|
+
function missingPlugin() {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, so there is no route tree. Add the plugin to your Vite config, or, in a @fluixi/start app, build with `fluixi build`/`fluixi dev` rather than calling vite directly."
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
var routes = new Proxy([], {
|
|
10
|
+
get: (target, key) => (
|
|
11
|
+
// `then` is probed by any `await`; answering undefined keeps this from looking thenable.
|
|
12
|
+
key === "then" ? void 0 : missingPlugin()
|
|
13
|
+
)
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
routes
|
|
17
|
+
};
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server.ts
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
batch: () => batch,
|
|
24
|
+
cleanupHydration: () => cleanupHydration,
|
|
25
|
+
clearHydrationData: () => clearHydrationData,
|
|
26
|
+
clearHydrationDataKey: () => clearHydrationDataKey,
|
|
27
|
+
createComputed: () => createComputed,
|
|
28
|
+
createContext: () => createContext,
|
|
29
|
+
createDeferred: () => createDeferred,
|
|
30
|
+
createEffect: () => createEffect,
|
|
31
|
+
createHtmlDocument: () => createHtmlDocument,
|
|
32
|
+
createHydratableResource: () => createHydratableResource,
|
|
33
|
+
createMemo: () => createMemo,
|
|
34
|
+
createRenderEffect: () => createRenderEffect,
|
|
35
|
+
createResource: () => createResource,
|
|
36
|
+
createRoot: () => createRoot,
|
|
37
|
+
createSelector: () => createSelector,
|
|
38
|
+
createSignal: () => createSignal,
|
|
39
|
+
deserializeHydrationData: () => deserializeHydrationData,
|
|
40
|
+
getHydrationData: () => getHydrationData,
|
|
41
|
+
getOwner: () => getOwner,
|
|
42
|
+
getSSRContext: () => getSSRContext,
|
|
43
|
+
hasHydrationData: () => hasHydrationData,
|
|
44
|
+
hydrationMarker: () => hydrationMarker,
|
|
45
|
+
hydrationMarkerEnd: () => hydrationMarkerEnd,
|
|
46
|
+
hydrationMarkerStart: () => hydrationMarkerStart,
|
|
47
|
+
isClient: () => isClient2,
|
|
48
|
+
isClientEnvironment: () => isClientEnvironment,
|
|
49
|
+
isClientReactive: () => isClient,
|
|
50
|
+
isHydrating: () => isHydrating,
|
|
51
|
+
isServer: () => import_dom2.isServer,
|
|
52
|
+
isServerEnvironment: () => isServerEnvironment,
|
|
53
|
+
isServerReactive: () => isServer,
|
|
54
|
+
onCleanup: () => onCleanup,
|
|
55
|
+
onClient: () => onClient,
|
|
56
|
+
onServer: () => onServer,
|
|
57
|
+
renderToPage: () => renderToPage,
|
|
58
|
+
renderToStream: () => renderToStream,
|
|
59
|
+
renderToString: () => renderToString,
|
|
60
|
+
runWithOwner: () => runWithOwner,
|
|
61
|
+
serializeHydrationData: () => serializeHydrationData,
|
|
62
|
+
setHydrating: () => setHydrating,
|
|
63
|
+
setHydrationData: () => setHydrationData,
|
|
64
|
+
setSSRContext: () => setSSRContext,
|
|
65
|
+
startServer: () => startServer,
|
|
66
|
+
startTransition: () => startTransition,
|
|
67
|
+
untrack: () => untrack,
|
|
68
|
+
useContext: () => useContext,
|
|
69
|
+
useHydrationData: () => useHydrationData,
|
|
70
|
+
withSSRContext: () => withSSRContext
|
|
71
|
+
});
|
|
72
|
+
module.exports = __toCommonJS(server_exports);
|
|
73
|
+
|
|
74
|
+
// src/lib/server/hydration.ts
|
|
75
|
+
var import_dom = require("@fluixi/dom");
|
|
76
|
+
var hydrating = false;
|
|
77
|
+
var hydrationDataMap = /* @__PURE__ */ new Map();
|
|
78
|
+
function isHydrating() {
|
|
79
|
+
return hydrating;
|
|
80
|
+
}
|
|
81
|
+
function setHydrating(state) {
|
|
82
|
+
hydrating = state;
|
|
83
|
+
}
|
|
84
|
+
function setHydrationData(key, data) {
|
|
85
|
+
hydrationDataMap.set(key, data);
|
|
86
|
+
}
|
|
87
|
+
function getHydrationData(key) {
|
|
88
|
+
return hydrationDataMap.get(key);
|
|
89
|
+
}
|
|
90
|
+
function hasHydrationData(key) {
|
|
91
|
+
return hydrationDataMap.has(key);
|
|
92
|
+
}
|
|
93
|
+
function clearHydrationData() {
|
|
94
|
+
hydrationDataMap.clear();
|
|
95
|
+
}
|
|
96
|
+
function clearHydrationDataKey(key) {
|
|
97
|
+
hydrationDataMap.delete(key);
|
|
98
|
+
}
|
|
99
|
+
function serializeHydrationData() {
|
|
100
|
+
if (hydrationDataMap.size === 0) {
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
const data = Object.fromEntries(hydrationDataMap);
|
|
104
|
+
const json = JSON.stringify(data);
|
|
105
|
+
return `<script type="application/json" id="__FLUIXI_HYDRATION__">${json}<\/script>`;
|
|
106
|
+
}
|
|
107
|
+
function deserializeHydrationData() {
|
|
108
|
+
if (typeof window === "undefined") {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const script = document.getElementById("__FLUIXI_HYDRATION__");
|
|
112
|
+
if (!script || script.getAttribute("type") !== "application/json") {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const json = script.textContent || "{}";
|
|
117
|
+
const data = JSON.parse(json);
|
|
118
|
+
for (const [key, value] of Object.entries(data)) {
|
|
119
|
+
hydrationDataMap.set(key, value);
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("Failed to deserialize hydration data:", error);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function hydrationMarker(id) {
|
|
128
|
+
return `<!--#${id}-->`;
|
|
129
|
+
}
|
|
130
|
+
function hydrationMarkerStart(id) {
|
|
131
|
+
return `<!--#${id}-->`;
|
|
132
|
+
}
|
|
133
|
+
function hydrationMarkerEnd(id) {
|
|
134
|
+
return `<!--/${id}-->`;
|
|
135
|
+
}
|
|
136
|
+
function createHydratableResource(key, fetcher) {
|
|
137
|
+
return async () => {
|
|
138
|
+
if (isHydrating() || typeof window !== "undefined") {
|
|
139
|
+
const cached = getHydrationData(key);
|
|
140
|
+
if (cached !== void 0) {
|
|
141
|
+
return cached;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const data = await fetcher();
|
|
145
|
+
if (typeof window === "undefined") {
|
|
146
|
+
setHydrationData(key, data);
|
|
147
|
+
}
|
|
148
|
+
return data;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function useHydrationData(key, value) {
|
|
152
|
+
const hydrationData = getHydrationData(key);
|
|
153
|
+
if (hydrationData !== void 0) {
|
|
154
|
+
return hydrationData;
|
|
155
|
+
}
|
|
156
|
+
const computedValue = typeof value === "function" ? value() : value;
|
|
157
|
+
if (typeof window === "undefined") {
|
|
158
|
+
setHydrationData(key, computedValue);
|
|
159
|
+
}
|
|
160
|
+
return computedValue;
|
|
161
|
+
}
|
|
162
|
+
function cleanupHydration() {
|
|
163
|
+
if (typeof window === "undefined") {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const script = document.getElementById("__FLUIXI_HYDRATION__");
|
|
167
|
+
if (script) {
|
|
168
|
+
script.remove();
|
|
169
|
+
}
|
|
170
|
+
const walker = document.createTreeWalker(
|
|
171
|
+
document.body,
|
|
172
|
+
NodeFilter.SHOW_COMMENT,
|
|
173
|
+
null
|
|
174
|
+
);
|
|
175
|
+
const comments = [];
|
|
176
|
+
let node;
|
|
177
|
+
while (node = walker.nextNode()) {
|
|
178
|
+
const comment = node;
|
|
179
|
+
const text = comment.nodeValue || "";
|
|
180
|
+
if (text.startsWith("#") || text.startsWith("/")) {
|
|
181
|
+
comments.push(comment);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
comments.forEach((comment) => comment.remove());
|
|
185
|
+
clearHydrationData();
|
|
186
|
+
}
|
|
187
|
+
if (typeof window !== "undefined") {
|
|
188
|
+
window.addEventListener("load", () => {
|
|
189
|
+
setTimeout(cleanupHydration, 100);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function isServerEnvironment() {
|
|
193
|
+
return (0, import_dom.isServer)();
|
|
194
|
+
}
|
|
195
|
+
function isClientEnvironment() {
|
|
196
|
+
return !(0, import_dom.isServer)();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/lib/server/index.ts
|
|
200
|
+
var import_server = require("@fluixi/server");
|
|
201
|
+
var import_dom2 = require("@fluixi/dom");
|
|
202
|
+
|
|
203
|
+
// src/lib/server/reactive.ts
|
|
204
|
+
function createSignal(value, options) {
|
|
205
|
+
let current = value;
|
|
206
|
+
const read = (() => current);
|
|
207
|
+
const write = (newValue) => {
|
|
208
|
+
if (typeof newValue === "function") {
|
|
209
|
+
current = newValue(current);
|
|
210
|
+
} else {
|
|
211
|
+
current = newValue;
|
|
212
|
+
}
|
|
213
|
+
return current;
|
|
214
|
+
};
|
|
215
|
+
return [read, write];
|
|
216
|
+
}
|
|
217
|
+
function createEffect(fn, value, options) {
|
|
218
|
+
try {
|
|
219
|
+
fn(value);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.error("[Fluixi Server] Effect error:", error);
|
|
222
|
+
}
|
|
223
|
+
return { dispose: () => {
|
|
224
|
+
} };
|
|
225
|
+
}
|
|
226
|
+
function createMemo(fn, value, options) {
|
|
227
|
+
const computed = fn(value);
|
|
228
|
+
return (() => computed);
|
|
229
|
+
}
|
|
230
|
+
function createRoot(fn) {
|
|
231
|
+
const cleanups = [];
|
|
232
|
+
const dispose = () => {
|
|
233
|
+
cleanups.forEach((cleanup) => {
|
|
234
|
+
try {
|
|
235
|
+
cleanup();
|
|
236
|
+
} catch (error) {
|
|
237
|
+
console.error("[Fluixi Server] Cleanup error:", error);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
cleanups.length = 0;
|
|
241
|
+
};
|
|
242
|
+
try {
|
|
243
|
+
return fn(dispose);
|
|
244
|
+
} catch (error) {
|
|
245
|
+
dispose();
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function batch(fn) {
|
|
250
|
+
return fn();
|
|
251
|
+
}
|
|
252
|
+
function untrack(fn) {
|
|
253
|
+
return fn();
|
|
254
|
+
}
|
|
255
|
+
var currentCleanups = null;
|
|
256
|
+
function onCleanup(fn) {
|
|
257
|
+
if (currentCleanups) {
|
|
258
|
+
currentCleanups.push(fn);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
var currentOwner = null;
|
|
262
|
+
function getOwner() {
|
|
263
|
+
return currentOwner;
|
|
264
|
+
}
|
|
265
|
+
function runWithOwner(owner, fn) {
|
|
266
|
+
const prev = currentOwner;
|
|
267
|
+
currentOwner = owner;
|
|
268
|
+
try {
|
|
269
|
+
return fn();
|
|
270
|
+
} finally {
|
|
271
|
+
currentOwner = prev;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
var contextMap = /* @__PURE__ */ new Map();
|
|
275
|
+
function createContext(defaultValue) {
|
|
276
|
+
const id = /* @__PURE__ */ Symbol("context");
|
|
277
|
+
const Provider = (props) => {
|
|
278
|
+
const prevValue = contextMap.get(id);
|
|
279
|
+
contextMap.set(id, props.value);
|
|
280
|
+
try {
|
|
281
|
+
return props.children;
|
|
282
|
+
} finally {
|
|
283
|
+
if (prevValue !== void 0) {
|
|
284
|
+
contextMap.set(id, prevValue);
|
|
285
|
+
} else {
|
|
286
|
+
contextMap.delete(id);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
id,
|
|
292
|
+
Provider,
|
|
293
|
+
defaultValue
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function useContext(context) {
|
|
297
|
+
const value = contextMap.get(context.id);
|
|
298
|
+
return value !== void 0 ? value : context.defaultValue;
|
|
299
|
+
}
|
|
300
|
+
function createComputed(fn) {
|
|
301
|
+
return createEffect(fn);
|
|
302
|
+
}
|
|
303
|
+
function createRenderEffect(fn) {
|
|
304
|
+
return createEffect(fn);
|
|
305
|
+
}
|
|
306
|
+
function createDeferred(fn) {
|
|
307
|
+
return createMemo(fn);
|
|
308
|
+
}
|
|
309
|
+
function createSelector(source) {
|
|
310
|
+
const value = source();
|
|
311
|
+
return (key) => key === value;
|
|
312
|
+
}
|
|
313
|
+
function createResource(source, fetcher, options) {
|
|
314
|
+
return [
|
|
315
|
+
() => void 0,
|
|
316
|
+
{
|
|
317
|
+
mutate: (v) => v,
|
|
318
|
+
refetch: () => {
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
];
|
|
322
|
+
}
|
|
323
|
+
function startTransition(fn) {
|
|
324
|
+
fn();
|
|
325
|
+
}
|
|
326
|
+
var isServer = true;
|
|
327
|
+
var isClient = false;
|
|
328
|
+
|
|
329
|
+
// src/lib/server/index.ts
|
|
330
|
+
var import_dom3 = require("@fluixi/dom");
|
|
331
|
+
var currentSSRContext = null;
|
|
332
|
+
function getSSRContext() {
|
|
333
|
+
return currentSSRContext;
|
|
334
|
+
}
|
|
335
|
+
function setSSRContext(context) {
|
|
336
|
+
currentSSRContext = context;
|
|
337
|
+
}
|
|
338
|
+
function withSSRContext(context, fn) {
|
|
339
|
+
const prev = currentSSRContext;
|
|
340
|
+
currentSSRContext = context;
|
|
341
|
+
try {
|
|
342
|
+
return fn();
|
|
343
|
+
} finally {
|
|
344
|
+
currentSSRContext = prev;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async function renderToPage(code, options = {}) {
|
|
348
|
+
const content = await renderToString(code);
|
|
349
|
+
return createHtmlDocument(content, options);
|
|
350
|
+
}
|
|
351
|
+
function createHtmlDocument(content, options = {}) {
|
|
352
|
+
const {
|
|
353
|
+
title = "Fluixi App",
|
|
354
|
+
lang = "en",
|
|
355
|
+
stylesheets = [],
|
|
356
|
+
scripts = [],
|
|
357
|
+
head = "",
|
|
358
|
+
bodyAttributes = ""
|
|
359
|
+
} = options;
|
|
360
|
+
const styleTags = stylesheets.map((href) => `<link rel="stylesheet" href="${href}">`).join("\n ");
|
|
361
|
+
const scriptTags = scripts.map((src) => `<script type="module" src="${src}"><\/script>`).join("\n ");
|
|
362
|
+
return `<!DOCTYPE html>
|
|
363
|
+
<html lang="${lang}">
|
|
364
|
+
<head>
|
|
365
|
+
<meta charset="UTF-8">
|
|
366
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
367
|
+
<title>${title}</title>
|
|
368
|
+
${styleTags}
|
|
369
|
+
${head}
|
|
370
|
+
</head>
|
|
371
|
+
<body${bodyAttributes ? " " + bodyAttributes : ""}>
|
|
372
|
+
${content}
|
|
373
|
+
${scriptTags}
|
|
374
|
+
</body>
|
|
375
|
+
</html>`;
|
|
376
|
+
}
|
|
377
|
+
function isClient2() {
|
|
378
|
+
return !(0, import_dom3.isServer)();
|
|
379
|
+
}
|
|
380
|
+
function onServer(fn, fallback) {
|
|
381
|
+
return (0, import_dom3.isServer)() ? fn() : fallback;
|
|
382
|
+
}
|
|
383
|
+
function onClient(fn, fallback) {
|
|
384
|
+
return !(0, import_dom3.isServer)() ? fn() : fallback;
|
|
385
|
+
}
|
|
386
|
+
async function renderToString(code) {
|
|
387
|
+
const html = await (0, import_server.renderToString)(code);
|
|
388
|
+
const script = serializeHydrationData();
|
|
389
|
+
return html + script;
|
|
390
|
+
}
|
|
391
|
+
async function renderToStream(code) {
|
|
392
|
+
const html = await (0, import_server.renderToString)(code);
|
|
393
|
+
const script = serializeHydrationData();
|
|
394
|
+
return html + script;
|
|
395
|
+
}
|
|
396
|
+
function startServer(App) {
|
|
397
|
+
return {
|
|
398
|
+
/** Render the app to a full HTML string (includes hydration data) */
|
|
399
|
+
render: (url) => renderToString(() => App({ url })),
|
|
400
|
+
/** Render the app to a streamable HTML string (includes hydration data) */
|
|
401
|
+
stream: (url) => renderToStream(() => App({ url })),
|
|
402
|
+
/** Render the app to a complete HTML page document */
|
|
403
|
+
page: (url, opts) => renderToPage(() => App({ url }), opts)
|
|
404
|
+
};
|
|
405
|
+
}
|