@kuratchi/js 0.0.10 → 0.0.11
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/compiler/index.js +19 -11
- package/dist/runtime/request.js +1 -1
- package/package.json +1 -1
package/dist/compiler/index.js
CHANGED
|
@@ -1202,7 +1202,7 @@ export function compile(options) {
|
|
|
1202
1202
|
});
|
|
1203
1203
|
compiledRoutes.push(routeObj);
|
|
1204
1204
|
}
|
|
1205
|
-
// Scan src/assets/ for static files to embed
|
|
1205
|
+
// Scan src/assets/ for static files to embed (recursive)
|
|
1206
1206
|
const assetsDir = path.join(srcDir, 'assets');
|
|
1207
1207
|
const compiledAssets = [];
|
|
1208
1208
|
if (fs.existsSync(assetsDir)) {
|
|
@@ -1213,15 +1213,23 @@ export function compile(options) {
|
|
|
1213
1213
|
'.svg': 'image/svg+xml',
|
|
1214
1214
|
'.txt': 'text/plain; charset=utf-8',
|
|
1215
1215
|
};
|
|
1216
|
-
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1216
|
+
const scanAssets = (dir, prefix) => {
|
|
1217
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
1218
|
+
if (entry.isDirectory()) {
|
|
1219
|
+
scanAssets(path.join(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
1223
|
+
const mime = mimeTypes[ext];
|
|
1224
|
+
if (!mime)
|
|
1225
|
+
continue;
|
|
1226
|
+
const content = fs.readFileSync(path.join(dir, entry.name), 'utf-8');
|
|
1227
|
+
const etag = '"' + crypto.createHash('md5').update(content).digest('hex').slice(0, 12) + '"';
|
|
1228
|
+
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
1229
|
+
compiledAssets.push({ name, content, mime, etag });
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
scanAssets(assetsDir, '');
|
|
1225
1233
|
}
|
|
1226
1234
|
// Collect only the components that were actually imported by routes
|
|
1227
1235
|
const compiledComponents = Array.from(compiledComponentCache.values());
|
|
@@ -1720,7 +1728,7 @@ function buildRouteObject(opts) {
|
|
|
1720
1728
|
return { ${loadReturnVars.join(', ')} };`;
|
|
1721
1729
|
}
|
|
1722
1730
|
}
|
|
1723
|
-
parts.push(` async load(
|
|
1731
|
+
parts.push(` async load(__routeParams = {}) {
|
|
1724
1732
|
${loadBody}${returnObj}
|
|
1725
1733
|
}`);
|
|
1726
1734
|
}
|
package/dist/runtime/request.js
CHANGED
|
@@ -8,7 +8,7 @@ export let slug = undefined;
|
|
|
8
8
|
function __syncDerivedState() {
|
|
9
9
|
pathname = url.pathname;
|
|
10
10
|
searchParams = url.searchParams;
|
|
11
|
-
slug = params.slug;
|
|
11
|
+
slug = params.slug ?? Object.values(params)[0];
|
|
12
12
|
}
|
|
13
13
|
export function __setRequestState(request) {
|
|
14
14
|
url = new URL(request.url);
|