@fluixi/core 1.0.0-alpha.82 → 1.0.0-alpha.84
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/cdn/core.global.js +2 -1
- package/dist/cli/generate.cjs +4117 -292
- package/dist/cli/generate.mjs +4122 -292
- package/dist/cli/index.cjs +4117 -292
- package/dist/cli/index.mjs +4122 -292
- package/dist/cli/run.cjs +63 -1
- package/dist/cli/run.mjs +39 -1
- package/dist/src/cdn/chunk-VNLCQBFQ.mjs +747 -0
- package/dist/src/cdn/core.cjs +1279 -1
- package/dist/src/cdn/core.d.ts +3 -3
- package/dist/src/cdn/core.js +3 -3
- package/dist/src/cdn/core.mjs +642 -1
- package/dist/src/cdn/router-WMN2AA7E.mjs +66 -0
- package/dist/src/index.cjs +1201 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -11
- package/dist/src/index.mjs +1313 -1
- package/dist/src/jsx-dev-runtime.cjs +26 -1
- package/dist/src/jsx-dev-runtime.mjs +24 -1
- package/dist/src/jsx-runtime.cjs +26 -1
- package/dist/src/jsx-runtime.js +0 -9
- package/dist/src/jsx-runtime.mjs +24 -1
- package/dist/src/lib/client/chunk-2C2KDDQV.mjs +133 -0
- package/dist/src/lib/client/index.cjs +870 -1
- package/dist/src/lib/client/index.d.ts +10 -14
- package/dist/src/lib/client/index.d.ts.map +1 -1
- package/dist/src/lib/client/index.js +36 -21
- package/dist/src/lib/client/index.mjs +222 -1
- package/dist/src/lib/client/router-X526HSWQ.mjs +548 -0
- package/dist/src/lib/context/context.cjs +118 -1
- package/dist/src/lib/context/context.d.ts +20 -38
- package/dist/src/lib/context/context.d.ts.map +1 -1
- package/dist/src/lib/context/context.js +10 -47
- package/dist/src/lib/context/context.mjs +99 -1
- package/dist/src/lib/context/index.cjs +120 -1
- package/dist/src/lib/context/index.mjs +99 -1
- package/dist/src/lib/control-flow.cjs +35 -1
- package/dist/src/lib/control-flow.mjs +25 -1
- package/dist/src/lib/core.cjs +1200 -1
- package/dist/src/lib/core.d.ts +0 -2
- package/dist/src/lib/core.d.ts.map +1 -1
- package/dist/src/lib/core.js +14 -48
- package/dist/src/lib/core.mjs +1313 -1
- package/dist/src/lib/env/index.cjs +60 -1
- package/dist/src/lib/env/index.d.ts +7 -8
- package/dist/src/lib/env/index.d.ts.map +1 -1
- package/dist/src/lib/env/index.js +14 -9
- package/dist/src/lib/env/index.mjs +39 -1
- package/dist/src/lib/i18n/index.cjs +108 -1
- package/dist/src/lib/i18n/index.d.ts +31 -10
- package/dist/src/lib/i18n/index.d.ts.map +1 -1
- package/dist/src/lib/i18n/index.js +31 -10
- package/dist/src/lib/i18n/index.mjs +88 -1
- package/dist/src/lib/index.cjs +633 -1
- package/dist/src/lib/index.d.ts +0 -2
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +5 -11
- package/dist/src/lib/index.mjs +721 -1
- package/dist/src/lib/isomorphic.cjs +85 -1
- package/dist/src/lib/isomorphic.d.ts +41 -8
- package/dist/src/lib/isomorphic.d.ts.map +1 -1
- package/dist/src/lib/isomorphic.js +38 -5
- package/dist/src/lib/isomorphic.mjs +64 -1
- package/dist/src/lib/jsx-runtime/index.cjs +21 -1
- package/dist/src/lib/jsx-runtime/index.d.ts +1 -1
- package/dist/src/lib/jsx-runtime/index.js +1 -11
- package/dist/src/lib/jsx-runtime/index.mjs +4 -1
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -1
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -1
- package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -8
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +15 -1
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -1
- package/dist/src/lib/plugins/fluixi-routes-plugin.js +19 -5
- package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -8
- package/dist/src/lib/plugins/index.cjs +311 -8
- package/dist/src/lib/plugins/index.mjs +279 -8
- package/dist/src/lib/plugins/route-codegen.cjs +73 -8
- package/dist/src/lib/plugins/route-codegen.d.ts +0 -1
- package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -1
- package/dist/src/lib/plugins/route-codegen.js +4 -5
- package/dist/src/lib/plugins/route-codegen.mjs +52 -8
- package/dist/src/lib/plugins/route-scanner.cjs +189 -1
- package/dist/src/lib/plugins/route-scanner.d.ts +1 -2
- package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -1
- package/dist/src/lib/plugins/route-scanner.js +7 -8
- package/dist/src/lib/plugins/route-scanner.mjs +158 -1
- package/dist/src/lib/plugins/vite.cjs +27 -1
- package/dist/src/lib/plugins/vite.mjs +6 -1
- package/dist/src/lib/render/await.cjs +38 -1
- package/dist/src/lib/render/await.d.ts +18 -0
- package/dist/src/lib/render/await.d.ts.map +1 -1
- package/dist/src/lib/render/await.js +20 -2
- package/dist/src/lib/render/await.mjs +17 -1
- package/dist/src/lib/render/component.cjs +221 -1
- package/dist/src/lib/render/component.d.ts +3 -44
- package/dist/src/lib/render/component.d.ts.map +1 -1
- package/dist/src/lib/render/component.js +32 -59
- package/dist/src/lib/render/component.mjs +214 -1
- package/dist/src/lib/render/deferred.cjs +175 -1
- package/dist/src/lib/render/deferred.d.ts.map +1 -1
- package/dist/src/lib/render/deferred.js +8 -8
- package/dist/src/lib/render/deferred.mjs +158 -1
- package/dist/src/lib/render/index.cjs +573 -1
- package/dist/src/lib/render/index.d.ts +3 -17
- package/dist/src/lib/render/index.d.ts.map +1 -1
- package/dist/src/lib/render/index.js +12 -26
- package/dist/src/lib/render/index.mjs +590 -1
- package/dist/src/lib/render/lazy.cjs +67 -1
- package/dist/src/lib/render/lazy.d.ts +22 -1
- package/dist/src/lib/render/lazy.d.ts.map +1 -1
- package/dist/src/lib/render/lazy.js +47 -8
- package/dist/src/lib/render/lazy.mjs +50 -1
- package/dist/src/lib/render/suspense.cjs +141 -1
- package/dist/src/lib/render/suspense.d.ts +40 -0
- package/dist/src/lib/render/suspense.d.ts.map +1 -1
- package/dist/src/lib/render/suspense.js +47 -7
- package/dist/src/lib/render/suspense.mjs +136 -1
- package/dist/src/lib/render/versions.cjs +35 -1
- package/dist/src/lib/render/versions.js +6 -6
- package/dist/src/lib/render/versions.mjs +14 -1
- package/dist/src/lib/router/data.cjs +230 -1
- package/dist/src/lib/router/data.d.ts +1 -13
- package/dist/src/lib/router/data.d.ts.map +1 -1
- package/dist/src/lib/router/data.js +1 -13
- package/dist/src/lib/router/data.mjs +214 -1
- package/dist/src/lib/router/index.cjs +627 -1
- package/dist/src/lib/router/index.d.ts +62 -10
- package/dist/src/lib/router/index.d.ts.map +1 -1
- package/dist/src/lib/router/index.js +90 -39
- package/dist/src/lib/router/index.mjs +639 -1
- package/dist/src/lib/server/hydration.cjs +169 -1
- package/dist/src/lib/server/hydration.d.ts +15 -55
- package/dist/src/lib/server/hydration.d.ts.map +1 -1
- package/dist/src/lib/server/hydration.js +23 -62
- package/dist/src/lib/server/hydration.mjs +148 -1
- package/dist/src/lib/server/index.cjs +401 -11
- package/dist/src/lib/server/index.d.ts +30 -6
- package/dist/src/lib/server/index.d.ts.map +1 -1
- package/dist/src/lib/server/index.js +34 -11
- package/dist/src/lib/server/index.mjs +379 -11
- package/dist/src/lib/server/reactive.cjs +197 -1
- package/dist/src/lib/server/reactive.d.ts +18 -77
- package/dist/src/lib/server/reactive.d.ts.map +1 -1
- package/dist/src/lib/server/reactive.js +19 -78
- package/dist/src/lib/server/reactive.mjs +176 -1
- package/dist/src/lib/theme/index.cjs +110 -1
- package/dist/src/lib/theme/index.d.ts +19 -4
- package/dist/src/lib/theme/index.d.ts.map +1 -1
- package/dist/src/lib/theme/index.js +17 -2
- package/dist/src/lib/theme/index.mjs +89 -1
- package/dist/src/lib/utils/index.cjs +209 -1
- package/dist/src/lib/utils/index.d.ts +0 -93
- package/dist/src/lib/utils/index.d.ts.map +1 -1
- package/dist/src/lib/utils/index.js +0 -93
- package/dist/src/lib/utils/index.mjs +188 -1
- package/dist/src/routes.cjs +37 -1
- package/dist/src/routes.d.ts +1 -1
- package/dist/src/routes.js +2 -2
- package/dist/src/routes.mjs +17 -1
- package/dist/src/server.cjs +400 -11
- package/dist/src/server.d.ts +0 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +0 -1
- package/dist/src/server.mjs +377 -11
- package/dist/src/utils.cjs +21 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.mjs +4 -1
- package/dist/src/version.generated.cjs +26 -1
- package/dist/src/version.generated.d.ts +1 -1
- package/dist/src/version.generated.js +2 -2
- package/dist/src/version.generated.mjs +5 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/index.ts +2 -14
- package/dist/src/cdn/chunk-RN7C7HNS.mjs +0 -1
- package/dist/src/cdn/router-QB3W43UQ.mjs +0 -1
- package/dist/src/lib/client/chunk-FT22BLCQ.mjs +0 -1
- package/dist/src/lib/client/router-IH7JYMRU.mjs +0 -1
|
@@ -1 +1,189 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/lib/plugins/route-scanner.ts
|
|
31
|
+
var route_scanner_exports = {};
|
|
32
|
+
__export(route_scanner_exports, {
|
|
33
|
+
scanRoutes: () => scanRoutes
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(route_scanner_exports);
|
|
36
|
+
var fs = __toESM(require("fs"), 1);
|
|
37
|
+
var path = __toESM(require("path"), 1);
|
|
38
|
+
var DEFAULT_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
39
|
+
function scanRoutes(routesDir, options = {}) {
|
|
40
|
+
const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
|
|
41
|
+
const absDir = path.resolve(routesDir);
|
|
42
|
+
if (!fs.existsSync(absDir)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return scanDirectory(absDir, absDir, "", extensions);
|
|
46
|
+
}
|
|
47
|
+
function scanDirectory(dir, rootDir, parentUrlPath, extensions) {
|
|
48
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
49
|
+
const routes = [];
|
|
50
|
+
const layoutRoute = null;
|
|
51
|
+
const files = [];
|
|
52
|
+
const dirs = [];
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
if (entry.isDirectory()) {
|
|
55
|
+
dirs.push(entry);
|
|
56
|
+
} else if (entry.isFile() && hasValidExtension(entry.name, extensions)) {
|
|
57
|
+
files.push(entry);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
let layout;
|
|
61
|
+
const nonLayoutFiles = [];
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
const baseName = stripExtension(file.name);
|
|
64
|
+
if (baseName === "layout") {
|
|
65
|
+
layout = buildFileRoute(file.name, dir, rootDir, parentUrlPath, true);
|
|
66
|
+
} else {
|
|
67
|
+
nonLayoutFiles.push(file);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const fileRoutes = [];
|
|
71
|
+
for (const file of nonLayoutFiles) {
|
|
72
|
+
fileRoutes.push(
|
|
73
|
+
buildFileRoute(file.name, dir, rootDir, parentUrlPath, false)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const dirRoutes = [];
|
|
77
|
+
for (const d of dirs) {
|
|
78
|
+
const dirName = d.name;
|
|
79
|
+
const isGroup = isRouteGroup(dirName);
|
|
80
|
+
const segment = isGroup ? "" : dirNameToSegment(dirName);
|
|
81
|
+
const childUrlPath = segment ? joinUrlPath(parentUrlPath, segment) : parentUrlPath;
|
|
82
|
+
const children = scanDirectory(
|
|
83
|
+
path.join(dir, dirName),
|
|
84
|
+
rootDir,
|
|
85
|
+
childUrlPath,
|
|
86
|
+
extensions
|
|
87
|
+
);
|
|
88
|
+
if (isGroup) {
|
|
89
|
+
dirRoutes.push(...children);
|
|
90
|
+
} else {
|
|
91
|
+
const childLayout = children.find((c) => c.isLayout && c.urlPath === childUrlPath);
|
|
92
|
+
const childNonLayout = children.filter((c) => !c.isLayout || c.urlPath !== childUrlPath);
|
|
93
|
+
if (childLayout) {
|
|
94
|
+
childLayout.children = [...childLayout.children, ...childNonLayout];
|
|
95
|
+
dirRoutes.push(childLayout);
|
|
96
|
+
} else if (childNonLayout.length > 0) {
|
|
97
|
+
dirRoutes.push(...childNonLayout);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (layout) {
|
|
102
|
+
layout.children = [...fileRoutes, ...dirRoutes];
|
|
103
|
+
routes.push(layout);
|
|
104
|
+
} else {
|
|
105
|
+
routes.push(...fileRoutes, ...dirRoutes);
|
|
106
|
+
}
|
|
107
|
+
return sortRoutes(routes);
|
|
108
|
+
}
|
|
109
|
+
function buildFileRoute(fileName, dir, rootDir, parentUrlPath, isLayout) {
|
|
110
|
+
const baseName = stripExtension(fileName);
|
|
111
|
+
const filePath = path.relative(rootDir, path.join(dir, fileName));
|
|
112
|
+
const isIndex = baseName === "index";
|
|
113
|
+
const isCatchAll = baseName.startsWith("[...");
|
|
114
|
+
const isDynamic = !isCatchAll && baseName.startsWith("[") && baseName.endsWith("]");
|
|
115
|
+
let urlSegment;
|
|
116
|
+
if (isLayout) {
|
|
117
|
+
urlSegment = "";
|
|
118
|
+
} else if (isIndex) {
|
|
119
|
+
urlSegment = "/";
|
|
120
|
+
} else if (isCatchAll) {
|
|
121
|
+
const paramName = baseName.slice(4, -1);
|
|
122
|
+
urlSegment = `*${paramName}`;
|
|
123
|
+
} else if (isDynamic) {
|
|
124
|
+
const paramName = baseName.slice(1, -1);
|
|
125
|
+
urlSegment = `:${paramName}`;
|
|
126
|
+
} else {
|
|
127
|
+
urlSegment = baseName;
|
|
128
|
+
}
|
|
129
|
+
const urlPath = isLayout ? parentUrlPath || "/" : isIndex ? parentUrlPath || "/" : joinUrlPath(parentUrlPath, urlSegment);
|
|
130
|
+
const absoluteFilePath = path.join(dir, fileName);
|
|
131
|
+
let hasRouteData = false;
|
|
132
|
+
try {
|
|
133
|
+
const content = fs.readFileSync(absoluteFilePath, "utf-8");
|
|
134
|
+
hasRouteData = /export\s+(const|function|async\s+function)\s+routeData\b/.test(content);
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
filePath: filePath.replace(/\\/g, "/"),
|
|
139
|
+
// normalize to forward slashes
|
|
140
|
+
urlSegment,
|
|
141
|
+
urlPath,
|
|
142
|
+
isLayout,
|
|
143
|
+
isIndex,
|
|
144
|
+
isDynamic,
|
|
145
|
+
isCatchAll,
|
|
146
|
+
isGroup: false,
|
|
147
|
+
children: [],
|
|
148
|
+
parentUrlPath,
|
|
149
|
+
hasRouteData,
|
|
150
|
+
rootDir,
|
|
151
|
+
dir
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function hasValidExtension(fileName, extensions) {
|
|
155
|
+
return extensions.some((ext) => fileName.endsWith(ext));
|
|
156
|
+
}
|
|
157
|
+
function stripExtension(fileName) {
|
|
158
|
+
const lastDot = fileName.lastIndexOf(".");
|
|
159
|
+
return lastDot > 0 ? fileName.slice(0, lastDot) : fileName;
|
|
160
|
+
}
|
|
161
|
+
function isRouteGroup(dirName) {
|
|
162
|
+
return dirName.startsWith("(") && dirName.endsWith(")");
|
|
163
|
+
}
|
|
164
|
+
function dirNameToSegment(dirName) {
|
|
165
|
+
if (dirName.startsWith("[...") && dirName.endsWith("]")) {
|
|
166
|
+
return "*" + dirName.slice(4, -1);
|
|
167
|
+
}
|
|
168
|
+
if (dirName.startsWith("[") && dirName.endsWith("]")) {
|
|
169
|
+
return ":" + dirName.slice(1, -1);
|
|
170
|
+
}
|
|
171
|
+
return dirName;
|
|
172
|
+
}
|
|
173
|
+
function joinUrlPath(parent, segment) {
|
|
174
|
+
const base = parent.endsWith("/") ? parent : parent + "/";
|
|
175
|
+
return base + segment;
|
|
176
|
+
}
|
|
177
|
+
function sortRoutes(routes) {
|
|
178
|
+
return routes.sort((a, b) => {
|
|
179
|
+
if (a.isLayout && !b.isLayout) return -1;
|
|
180
|
+
if (!a.isLayout && b.isLayout) return 1;
|
|
181
|
+
if (a.isIndex && !b.isIndex) return -1;
|
|
182
|
+
if (!a.isIndex && b.isIndex) return 1;
|
|
183
|
+
if (!a.isDynamic && !a.isCatchAll && (b.isDynamic || b.isCatchAll)) return -1;
|
|
184
|
+
if ((a.isDynamic || a.isCatchAll) && !b.isDynamic && !b.isCatchAll) return 1;
|
|
185
|
+
if (a.isDynamic && b.isCatchAll) return -1;
|
|
186
|
+
if (a.isCatchAll && b.isDynamic) return 1;
|
|
187
|
+
return a.urlSegment.localeCompare(b.urlSegment);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview File-system route scanner
|
|
3
2
|
* @module @fluixi/core/plugins/route-scanner
|
|
4
3
|
*
|
|
5
4
|
* Scans a routes directory and builds a route tree following SolidStart conventions.
|
|
6
|
-
* Pure utility
|
|
5
|
+
* Pure utility, no bundler dependency.
|
|
7
6
|
*/
|
|
8
7
|
export interface ScannedRoute {
|
|
9
8
|
/** Relative file path from routes dir: 'users/[id].tsx' */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-scanner.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/route-scanner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"route-scanner.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/route-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,WAAW,YAAY;IAC3B,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,0BAA0B;IAC1B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAQD;;GAEG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,WAAgB,GACxB,YAAY,EAAE,CAShB"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview File-system route scanner
|
|
3
2
|
* @module @fluixi/core/plugins/route-scanner
|
|
4
3
|
*
|
|
5
4
|
* Scans a routes directory and builds a route tree following SolidStart conventions.
|
|
6
|
-
* Pure utility
|
|
5
|
+
* Pure utility, no bundler dependency.
|
|
7
6
|
*/
|
|
8
7
|
import * as fs from 'fs';
|
|
9
8
|
import * as path from 'path';
|
|
@@ -71,7 +70,7 @@ function scanDirectory(dir, rootDir, parentUrlPath, extensions) {
|
|
|
71
70
|
else {
|
|
72
71
|
// Regular directory: becomes a nested route
|
|
73
72
|
// If there's a DIRECT layout in the children (urlPath matches this dir's path),
|
|
74
|
-
// it becomes the parent route. We must
|
|
73
|
+
// it becomes the parent route. We must not pick up layouts from deeper descendants
|
|
75
74
|
// (e.g. campaigns/[id]/workspace/layout.tsx must not be the layout for campaigns/).
|
|
76
75
|
const childLayout = children.find((c) => c.isLayout && c.urlPath === childUrlPath);
|
|
77
76
|
const childNonLayout = children.filter((c) => !c.isLayout || c.urlPath !== childUrlPath);
|
|
@@ -81,7 +80,7 @@ function scanDirectory(dir, rootDir, parentUrlPath, extensions) {
|
|
|
81
80
|
dirRoutes.push(childLayout);
|
|
82
81
|
}
|
|
83
82
|
else if (childNonLayout.length > 0) {
|
|
84
|
-
// No layout
|
|
83
|
+
// No layout, just add children with their full paths
|
|
85
84
|
dirRoutes.push(...childNonLayout);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
@@ -114,12 +113,12 @@ function buildFileRoute(fileName, dir, rootDir, parentUrlPath, isLayout) {
|
|
|
114
113
|
urlSegment = '/';
|
|
115
114
|
}
|
|
116
115
|
else if (isCatchAll) {
|
|
117
|
-
// [...rest]
|
|
116
|
+
// [...rest] -> *rest
|
|
118
117
|
const paramName = baseName.slice(4, -1); // remove '[...' and ']'
|
|
119
118
|
urlSegment = `*${paramName}`;
|
|
120
119
|
}
|
|
121
120
|
else if (isDynamic) {
|
|
122
|
-
// [id]
|
|
121
|
+
// [id] -> :id
|
|
123
122
|
const paramName = baseName.slice(1, -1); // remove '[' and ']'
|
|
124
123
|
urlSegment = `:${paramName}`;
|
|
125
124
|
}
|
|
@@ -173,10 +172,10 @@ function isRouteGroup(dirName) {
|
|
|
173
172
|
/** Convert a directory name to its URL segment, matching the same rules as file names. */
|
|
174
173
|
function dirNameToSegment(dirName) {
|
|
175
174
|
if (dirName.startsWith('[...') && dirName.endsWith(']')) {
|
|
176
|
-
return '*' + dirName.slice(4, -1); // [...rest]
|
|
175
|
+
return '*' + dirName.slice(4, -1); // [...rest] -> *rest
|
|
177
176
|
}
|
|
178
177
|
if (dirName.startsWith('[') && dirName.endsWith(']')) {
|
|
179
|
-
return ':' + dirName.slice(1, -1); // [id]
|
|
178
|
+
return ':' + dirName.slice(1, -1); // [id] -> :id
|
|
180
179
|
}
|
|
181
180
|
return dirName;
|
|
182
181
|
}
|
|
@@ -1 +1,158 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/plugins/route-scanner.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
var DEFAULT_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
5
|
+
function scanRoutes(routesDir, options = {}) {
|
|
6
|
+
const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
|
|
7
|
+
const absDir = path.resolve(routesDir);
|
|
8
|
+
if (!fs.existsSync(absDir)) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return scanDirectory(absDir, absDir, "", extensions);
|
|
12
|
+
}
|
|
13
|
+
function scanDirectory(dir, rootDir, parentUrlPath, extensions) {
|
|
14
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
15
|
+
const routes = [];
|
|
16
|
+
const layoutRoute = null;
|
|
17
|
+
const files = [];
|
|
18
|
+
const dirs = [];
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
dirs.push(entry);
|
|
22
|
+
} else if (entry.isFile() && hasValidExtension(entry.name, extensions)) {
|
|
23
|
+
files.push(entry);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let layout;
|
|
27
|
+
const nonLayoutFiles = [];
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
const baseName = stripExtension(file.name);
|
|
30
|
+
if (baseName === "layout") {
|
|
31
|
+
layout = buildFileRoute(file.name, dir, rootDir, parentUrlPath, true);
|
|
32
|
+
} else {
|
|
33
|
+
nonLayoutFiles.push(file);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const fileRoutes = [];
|
|
37
|
+
for (const file of nonLayoutFiles) {
|
|
38
|
+
fileRoutes.push(
|
|
39
|
+
buildFileRoute(file.name, dir, rootDir, parentUrlPath, false)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const dirRoutes = [];
|
|
43
|
+
for (const d of dirs) {
|
|
44
|
+
const dirName = d.name;
|
|
45
|
+
const isGroup = isRouteGroup(dirName);
|
|
46
|
+
const segment = isGroup ? "" : dirNameToSegment(dirName);
|
|
47
|
+
const childUrlPath = segment ? joinUrlPath(parentUrlPath, segment) : parentUrlPath;
|
|
48
|
+
const children = scanDirectory(
|
|
49
|
+
path.join(dir, dirName),
|
|
50
|
+
rootDir,
|
|
51
|
+
childUrlPath,
|
|
52
|
+
extensions
|
|
53
|
+
);
|
|
54
|
+
if (isGroup) {
|
|
55
|
+
dirRoutes.push(...children);
|
|
56
|
+
} else {
|
|
57
|
+
const childLayout = children.find((c) => c.isLayout && c.urlPath === childUrlPath);
|
|
58
|
+
const childNonLayout = children.filter((c) => !c.isLayout || c.urlPath !== childUrlPath);
|
|
59
|
+
if (childLayout) {
|
|
60
|
+
childLayout.children = [...childLayout.children, ...childNonLayout];
|
|
61
|
+
dirRoutes.push(childLayout);
|
|
62
|
+
} else if (childNonLayout.length > 0) {
|
|
63
|
+
dirRoutes.push(...childNonLayout);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (layout) {
|
|
68
|
+
layout.children = [...fileRoutes, ...dirRoutes];
|
|
69
|
+
routes.push(layout);
|
|
70
|
+
} else {
|
|
71
|
+
routes.push(...fileRoutes, ...dirRoutes);
|
|
72
|
+
}
|
|
73
|
+
return sortRoutes(routes);
|
|
74
|
+
}
|
|
75
|
+
function buildFileRoute(fileName, dir, rootDir, parentUrlPath, isLayout) {
|
|
76
|
+
const baseName = stripExtension(fileName);
|
|
77
|
+
const filePath = path.relative(rootDir, path.join(dir, fileName));
|
|
78
|
+
const isIndex = baseName === "index";
|
|
79
|
+
const isCatchAll = baseName.startsWith("[...");
|
|
80
|
+
const isDynamic = !isCatchAll && baseName.startsWith("[") && baseName.endsWith("]");
|
|
81
|
+
let urlSegment;
|
|
82
|
+
if (isLayout) {
|
|
83
|
+
urlSegment = "";
|
|
84
|
+
} else if (isIndex) {
|
|
85
|
+
urlSegment = "/";
|
|
86
|
+
} else if (isCatchAll) {
|
|
87
|
+
const paramName = baseName.slice(4, -1);
|
|
88
|
+
urlSegment = `*${paramName}`;
|
|
89
|
+
} else if (isDynamic) {
|
|
90
|
+
const paramName = baseName.slice(1, -1);
|
|
91
|
+
urlSegment = `:${paramName}`;
|
|
92
|
+
} else {
|
|
93
|
+
urlSegment = baseName;
|
|
94
|
+
}
|
|
95
|
+
const urlPath = isLayout ? parentUrlPath || "/" : isIndex ? parentUrlPath || "/" : joinUrlPath(parentUrlPath, urlSegment);
|
|
96
|
+
const absoluteFilePath = path.join(dir, fileName);
|
|
97
|
+
let hasRouteData = false;
|
|
98
|
+
try {
|
|
99
|
+
const content = fs.readFileSync(absoluteFilePath, "utf-8");
|
|
100
|
+
hasRouteData = /export\s+(const|function|async\s+function)\s+routeData\b/.test(content);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
filePath: filePath.replace(/\\/g, "/"),
|
|
105
|
+
// normalize to forward slashes
|
|
106
|
+
urlSegment,
|
|
107
|
+
urlPath,
|
|
108
|
+
isLayout,
|
|
109
|
+
isIndex,
|
|
110
|
+
isDynamic,
|
|
111
|
+
isCatchAll,
|
|
112
|
+
isGroup: false,
|
|
113
|
+
children: [],
|
|
114
|
+
parentUrlPath,
|
|
115
|
+
hasRouteData,
|
|
116
|
+
rootDir,
|
|
117
|
+
dir
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function hasValidExtension(fileName, extensions) {
|
|
121
|
+
return extensions.some((ext) => fileName.endsWith(ext));
|
|
122
|
+
}
|
|
123
|
+
function stripExtension(fileName) {
|
|
124
|
+
const lastDot = fileName.lastIndexOf(".");
|
|
125
|
+
return lastDot > 0 ? fileName.slice(0, lastDot) : fileName;
|
|
126
|
+
}
|
|
127
|
+
function isRouteGroup(dirName) {
|
|
128
|
+
return dirName.startsWith("(") && dirName.endsWith(")");
|
|
129
|
+
}
|
|
130
|
+
function dirNameToSegment(dirName) {
|
|
131
|
+
if (dirName.startsWith("[...") && dirName.endsWith("]")) {
|
|
132
|
+
return "*" + dirName.slice(4, -1);
|
|
133
|
+
}
|
|
134
|
+
if (dirName.startsWith("[") && dirName.endsWith("]")) {
|
|
135
|
+
return ":" + dirName.slice(1, -1);
|
|
136
|
+
}
|
|
137
|
+
return dirName;
|
|
138
|
+
}
|
|
139
|
+
function joinUrlPath(parent, segment) {
|
|
140
|
+
const base = parent.endsWith("/") ? parent : parent + "/";
|
|
141
|
+
return base + segment;
|
|
142
|
+
}
|
|
143
|
+
function sortRoutes(routes) {
|
|
144
|
+
return routes.sort((a, b) => {
|
|
145
|
+
if (a.isLayout && !b.isLayout) return -1;
|
|
146
|
+
if (!a.isLayout && b.isLayout) return 1;
|
|
147
|
+
if (a.isIndex && !b.isIndex) return -1;
|
|
148
|
+
if (!a.isIndex && b.isIndex) return 1;
|
|
149
|
+
if (!a.isDynamic && !a.isCatchAll && (b.isDynamic || b.isCatchAll)) return -1;
|
|
150
|
+
if ((a.isDynamic || a.isCatchAll) && !b.isDynamic && !b.isCatchAll) return 1;
|
|
151
|
+
if (a.isDynamic && b.isCatchAll) return -1;
|
|
152
|
+
if (a.isCatchAll && b.isDynamic) return 1;
|
|
153
|
+
return a.urlSegment.localeCompare(b.urlSegment);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
scanRoutes
|
|
158
|
+
};
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
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/lib/plugins/vite.ts
|
|
21
|
+
var vite_exports = {};
|
|
22
|
+
__export(vite_exports, {
|
|
23
|
+
createVitePlugin: () => import_vite_plugin.createVitePlugin,
|
|
24
|
+
fluixi: () => import_vite_plugin.fluixi
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(vite_exports);
|
|
27
|
+
var import_vite_plugin = require("@fluixi/vite-plugin");
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
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/lib/render/await.ts
|
|
21
|
+
var await_exports = {};
|
|
22
|
+
__export(await_exports, {
|
|
23
|
+
Await: () => Await
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(await_exports);
|
|
26
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
27
|
+
function Await(props) {
|
|
28
|
+
const fetcher = () => {
|
|
29
|
+
const v = props.value;
|
|
30
|
+
return typeof v === "function" ? v() : v;
|
|
31
|
+
};
|
|
32
|
+
const [data] = (0, import_signal.createResource)(fetcher);
|
|
33
|
+
return () => {
|
|
34
|
+
if (data.loading) return props.fallback;
|
|
35
|
+
const child = props.children;
|
|
36
|
+
return typeof child === "function" ? child(data()) : child;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -4,5 +4,23 @@ export interface AwaitProps<T> {
|
|
|
4
4
|
/** Render prop called with the resolved value (or plain children). */
|
|
5
5
|
children?: ((value: T) => unknown) | unknown;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Render the result of a promise, with a fallback while it is pending.
|
|
9
|
+
*
|
|
10
|
+
* `value` may be a promise or a function returning one. Pass a function when the promise
|
|
11
|
+
* should be created by the component rather than by whoever wrote the tag, which is what
|
|
12
|
+
* keeps a re-render from firing the request again.
|
|
13
|
+
*
|
|
14
|
+
* `children` is either a render prop called with the resolved value, or plain children
|
|
15
|
+
* that ignore it.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* html`
|
|
20
|
+
* <${Await} value=${() => fetchUser(id)} fallback=${html`<p>loading...</p>`}>
|
|
21
|
+
* ${(user) => html`<h1>${user.name}</h1>`}
|
|
22
|
+
* </${Await}>`;
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
7
25
|
export declare function Await<T>(props: AwaitProps<T>): () => unknown;
|
|
8
26
|
//# sourceMappingURL=await.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"await.d.ts","sourceRoot":"","sources":["../../../../src/lib/render/await.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;CAC9C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAW5D"}
|
|
1
|
+
{"version":3,"file":"await.d.ts","sourceRoot":"","sources":["../../../../src/lib/render/await.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAW5D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `<Await value=${promise}
|
|
2
|
+
* `<Await value=${promise}>`: resolve a promise and render its value.
|
|
3
3
|
*
|
|
4
4
|
* A thin, Suspense-free helper for the common "await one promise" case:
|
|
5
5
|
*
|
|
6
|
-
* <Await value=${fetchUser(id)} fallback=${html`<p>loading
|
|
6
|
+
* <Await value=${fetchUser(id)} fallback=${html`<p>loading...</p>`}>
|
|
7
7
|
* ${(user) => html`<span>${user.name}</span>`}
|
|
8
8
|
* </Await>
|
|
9
9
|
*
|
|
@@ -12,6 +12,24 @@
|
|
|
12
12
|
* resource read is guarded by `.loading`, so it never throws/suspends.
|
|
13
13
|
*/
|
|
14
14
|
import { createResource } from '@fluixi/reactive/signal';
|
|
15
|
+
/**
|
|
16
|
+
* Render the result of a promise, with a fallback while it is pending.
|
|
17
|
+
*
|
|
18
|
+
* `value` may be a promise or a function returning one. Pass a function when the promise
|
|
19
|
+
* should be created by the component rather than by whoever wrote the tag, which is what
|
|
20
|
+
* keeps a re-render from firing the request again.
|
|
21
|
+
*
|
|
22
|
+
* `children` is either a render prop called with the resolved value, or plain children
|
|
23
|
+
* that ignore it.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* html`
|
|
28
|
+
* <${Await} value=${() => fetchUser(id)} fallback=${html`<p>loading...</p>`}>
|
|
29
|
+
* ${(user) => html`<h1>${user.name}</h1>`}
|
|
30
|
+
* </${Await}>`;
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
15
33
|
export function Await(props) {
|
|
16
34
|
const fetcher = () => {
|
|
17
35
|
const v = props.value;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/render/await.ts
|
|
2
|
+
import { createResource } from "@fluixi/reactive/signal";
|
|
3
|
+
function Await(props) {
|
|
4
|
+
const fetcher = () => {
|
|
5
|
+
const v = props.value;
|
|
6
|
+
return typeof v === "function" ? v() : v;
|
|
7
|
+
};
|
|
8
|
+
const [data] = createResource(fetcher);
|
|
9
|
+
return () => {
|
|
10
|
+
if (data.loading) return props.fallback;
|
|
11
|
+
const child = props.children;
|
|
12
|
+
return typeof child === "function" ? child(data()) : child;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
Await
|
|
17
|
+
};
|