reroute-js 0.8.0 → 0.9.0
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/cli/bin.d.ts +1 -1
- package/cli/bin.js +110 -20
- package/cli/bin.js.map +5 -5
- package/cli/index.d.ts +1 -1
- package/cli/index.js +2 -2
- package/cli/index.js.map +1 -1
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/boot.d.ts +1 -1
- package/cli/src/commands/build.d.ts +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/libs/command.d.ts +1 -1
- package/cli/src/libs/index.d.ts +1 -1
- package/cli/src/libs/log.d.ts +1 -1
- package/cli/src/libs/markdown-processor.d.ts +1 -1
- package/cli/src/libs/markdown.d.ts +1 -1
- package/cli/src/libs/production.d.ts +1 -1
- package/cli/src/libs/tailwind.d.ts +1 -1
- package/cli/src/libs/version.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +106 -16
- package/core/index.js.map +7 -7
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/bundler/transpile.d.ts +2 -1
- package/core/src/bundler/transpile.d.ts.map +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/content/registry.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/ssr/data.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/modules.d.ts +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/render.d.ts.map +1 -1
- package/core/src/ssr/seed.d.ts +1 -1
- package/core/src/template/html.d.ts +1 -1
- package/core/src/template/index.d.ts +1 -1
- package/core/src/types.d.ts +9 -1
- package/core/src/types.d.ts.map +1 -1
- package/core/src/utils/cache.d.ts +1 -1
- package/core/src/utils/compression.d.ts +2 -1
- package/core/src/utils/compression.d.ts.map +1 -1
- package/core/src/utils/index.d.ts +1 -1
- package/core/src/utils/mime.d.ts +1 -1
- package/core/src/utils/path.d.ts +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +225 -26
- package/elysia/index.js.map +8 -8
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/dev.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +2 -2
- package/elysia/src/routes/ssr.d.ts.map +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/routes/static.d.ts.map +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
- package/react/index.js.map +1 -1
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
- package/react/src/utils/content.d.ts +1 -1
- package/react/src/utils/head.d.ts +1 -1
- package/react/src/utils/index.d.ts +1 -1
package/cli/bin.d.ts
CHANGED
package/cli/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
/**
|
|
4
|
-
* reroute-js v0.
|
|
4
|
+
* reroute-js v0.9.0
|
|
5
5
|
*
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -47,7 +47,7 @@ async function getVersionString() {
|
|
|
47
47
|
}
|
|
48
48
|
async function getVersion() {
|
|
49
49
|
if (true) {
|
|
50
|
-
return "0.
|
|
50
|
+
return "0.9.0";
|
|
51
51
|
}
|
|
52
52
|
const possiblePaths = [
|
|
53
53
|
path.join(import.meta.dir, "../../../../package.json"),
|
|
@@ -65,7 +65,7 @@ async function getVersion() {
|
|
|
65
65
|
}
|
|
66
66
|
async function getCommit() {
|
|
67
67
|
if (true) {
|
|
68
|
-
return "
|
|
68
|
+
return "a5db82d";
|
|
69
69
|
}
|
|
70
70
|
return "dev";
|
|
71
71
|
}
|
|
@@ -2196,11 +2196,19 @@ async function transpileFile(filePath, originalPath, options, bundleCache) {
|
|
|
2196
2196
|
target: "browser",
|
|
2197
2197
|
format: "esm",
|
|
2198
2198
|
minify: options.minify,
|
|
2199
|
-
splitting:
|
|
2199
|
+
splitting: true,
|
|
2200
2200
|
sourcemap: sm,
|
|
2201
|
+
jsx: {
|
|
2202
|
+
runtime: "automatic",
|
|
2203
|
+
importSource: "react",
|
|
2204
|
+
development: !options.minify
|
|
2205
|
+
},
|
|
2201
2206
|
define: {
|
|
2202
|
-
"process.env.NODE_ENV": options.minify ? '"production"' : '"development"'
|
|
2203
|
-
|
|
2207
|
+
"process.env.NODE_ENV": options.minify ? '"production"' : '"development"',
|
|
2208
|
+
__DEV__: options.minify ? "false" : "true",
|
|
2209
|
+
"import.meta.env.MODE": options.minify ? '"production"' : '"development"'
|
|
2210
|
+
},
|
|
2211
|
+
...options.minify ? { drop: ["console", "debugger"] } : {}
|
|
2204
2212
|
});
|
|
2205
2213
|
}
|
|
2206
2214
|
let result;
|
|
@@ -2216,8 +2224,19 @@ async function transpileFile(filePath, originalPath, options, bundleCache) {
|
|
|
2216
2224
|
console.error(log2);
|
|
2217
2225
|
throw new Error(`Failed to transpile ${filePath}`);
|
|
2218
2226
|
}
|
|
2219
|
-
const
|
|
2220
|
-
|
|
2227
|
+
const outputs = await Promise.all(result.outputs.map(async (o) => ({
|
|
2228
|
+
path: o.path,
|
|
2229
|
+
text: await o.text()
|
|
2230
|
+
})));
|
|
2231
|
+
const entryBase = basename2(originalPath, extname2(originalPath));
|
|
2232
|
+
let entry = outputs.find((o) => o.path.endsWith(`${entryBase}.js`));
|
|
2233
|
+
if (!entry) {
|
|
2234
|
+
entry = outputs.filter((o) => o.path.endsWith(".js")).sort((a, b) => b.text.length - a.text.length)[0];
|
|
2235
|
+
}
|
|
2236
|
+
if (!entry) {
|
|
2237
|
+
throw new Error(`[reroute] No JS output generated for ${originalPath}`);
|
|
2238
|
+
}
|
|
2239
|
+
const code = entry.text;
|
|
2221
2240
|
let sourceMap;
|
|
2222
2241
|
if (options.sourcemap && result.outputs.length > 1) {
|
|
2223
2242
|
const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
|
|
@@ -2226,10 +2245,38 @@ async function transpileFile(filePath, originalPath, options, bundleCache) {
|
|
|
2226
2245
|
}
|
|
2227
2246
|
}
|
|
2228
2247
|
const contentHash = await generateContentHash(code);
|
|
2248
|
+
const chunks = outputs.filter((o) => o !== entry && o.path.endsWith(".js")).map((o) => ({
|
|
2249
|
+
fileName: basename2(o.path),
|
|
2250
|
+
code: o.text,
|
|
2251
|
+
hash: "",
|
|
2252
|
+
isEntry: false,
|
|
2253
|
+
imports: []
|
|
2254
|
+
}));
|
|
2255
|
+
for (const c of chunks) {
|
|
2256
|
+
c.hash = await generateContentHash(c.code);
|
|
2257
|
+
try {
|
|
2258
|
+
const bn = c.fileName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2259
|
+
const re = new RegExp(`["'\`]((?:\\./)?${bn})["'\`]`, "g");
|
|
2260
|
+
const matches = [...code.matchAll(re)];
|
|
2261
|
+
if (matches.length) {
|
|
2262
|
+
c.isEntry = false;
|
|
2263
|
+
}
|
|
2264
|
+
} catch {}
|
|
2265
|
+
}
|
|
2266
|
+
const staticDepNames = [];
|
|
2267
|
+
try {
|
|
2268
|
+
for (const c of chunks) {
|
|
2269
|
+
const bn = c.fileName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2270
|
+
const re = new RegExp(`["'\`]((?:\\./)?${bn})["'\`]`, "g");
|
|
2271
|
+
if (re.test(code))
|
|
2272
|
+
staticDepNames.push(c.fileName);
|
|
2273
|
+
}
|
|
2274
|
+
} catch {}
|
|
2229
2275
|
const bundleInfo = {
|
|
2230
2276
|
hash: contentHash,
|
|
2231
2277
|
code,
|
|
2232
|
-
sourceMap
|
|
2278
|
+
sourceMap,
|
|
2279
|
+
chunks
|
|
2233
2280
|
};
|
|
2234
2281
|
bundleCache.set(cacheKey, bundleInfo);
|
|
2235
2282
|
const sizeKB = (code.length / 1024).toFixed(2);
|
|
@@ -2248,7 +2295,13 @@ async function getBundleUrlsFor(modules, clientDir, prefix, options, bundleCache
|
|
|
2248
2295
|
try {
|
|
2249
2296
|
const bundleInfo = await transpileFile(fullPath, rel, options, bundleCache);
|
|
2250
2297
|
const base = basename2(rel, extname2(rel));
|
|
2251
|
-
|
|
2298
|
+
const entryUrl = `${prefix}/${base}.${bundleInfo.hash}.js`;
|
|
2299
|
+
urls.push(entryUrl);
|
|
2300
|
+
try {
|
|
2301
|
+
const depNames = Array.isArray(bundleInfo.chunks) ? bundleInfo.chunks.map((c) => c.fileName).filter((name) => new RegExp(`["'\`]((?:\\./)?${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["'\`]`, "g").test(bundleInfo.code)) : [];
|
|
2302
|
+
const depUrls = depNames.map((n) => `${prefix}/${n}`.replace(/\/+/g, "/"));
|
|
2303
|
+
entryUrlToStaticDeps.set(entryUrl, depUrls);
|
|
2304
|
+
} catch {}
|
|
2252
2305
|
} catch (error) {
|
|
2253
2306
|
console.error(`[reroute] Error getting bundle URL for ${rel}:`, error);
|
|
2254
2307
|
urls.push(`${prefix}/${rel}`);
|
|
@@ -2256,8 +2309,13 @@ async function getBundleUrlsFor(modules, clientDir, prefix, options, bundleCache
|
|
|
2256
2309
|
}
|
|
2257
2310
|
return urls;
|
|
2258
2311
|
}
|
|
2312
|
+
function getStaticDepsForUrl(entryUrl) {
|
|
2313
|
+
return entryUrlToStaticDeps.get(entryUrl) || [];
|
|
2314
|
+
}
|
|
2315
|
+
var entryUrlToStaticDeps;
|
|
2259
2316
|
var init_transpile = __esm(() => {
|
|
2260
2317
|
init_cli();
|
|
2318
|
+
entryUrlToStaticDeps = new Map;
|
|
2261
2319
|
});
|
|
2262
2320
|
|
|
2263
2321
|
// packages/core/src/bundler/index.ts
|
|
@@ -2744,6 +2802,21 @@ async function renderSSRDocument(options) {
|
|
|
2744
2802
|
const scripts = [bundleUrl];
|
|
2745
2803
|
let hydrationScript = "";
|
|
2746
2804
|
let extraHead = "";
|
|
2805
|
+
try {
|
|
2806
|
+
if (typeof bundleUrl === "string" && bundleUrl.endsWith(".js")) {
|
|
2807
|
+
extraHead += `
|
|
2808
|
+
<link rel="modulepreload" href="${bundleUrl}" />`;
|
|
2809
|
+
}
|
|
2810
|
+
} catch {}
|
|
2811
|
+
try {
|
|
2812
|
+
const staticDeps = getStaticDepsForUrl(bundleUrl);
|
|
2813
|
+
if (Array.isArray(staticDeps) && staticDeps.length) {
|
|
2814
|
+
for (const dep of staticDeps) {
|
|
2815
|
+
extraHead += `
|
|
2816
|
+
<link rel="modulepreload" href="${dep}" />`;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
} catch {}
|
|
2747
2820
|
let statusOverride;
|
|
2748
2821
|
try {
|
|
2749
2822
|
globalThis.__REROUTE_SSR_ACCESSED__ = {};
|
|
@@ -3071,6 +3144,7 @@ ${ssrHead}`;
|
|
|
3071
3144
|
}
|
|
3072
3145
|
var init_render = __esm(() => {
|
|
3073
3146
|
init_dedent();
|
|
3147
|
+
init_bundler();
|
|
3074
3148
|
init_metadata();
|
|
3075
3149
|
init_template();
|
|
3076
3150
|
init_seed();
|
|
@@ -3150,21 +3224,35 @@ function isCompressible(contentType) {
|
|
|
3150
3224
|
}
|
|
3151
3225
|
|
|
3152
3226
|
// packages/core/src/utils/compression.ts
|
|
3227
|
+
import { brotliCompressSync } from "node:zlib";
|
|
3153
3228
|
function acceptsGzip(acceptEncoding) {
|
|
3154
3229
|
return Boolean(acceptEncoding && /gzip/i.test(acceptEncoding));
|
|
3155
3230
|
}
|
|
3231
|
+
function acceptsBrotli(acceptEncoding) {
|
|
3232
|
+
return Boolean(acceptEncoding && /\bbr\b/i.test(acceptEncoding));
|
|
3233
|
+
}
|
|
3156
3234
|
function toBytes(input) {
|
|
3157
3235
|
return typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
3158
3236
|
}
|
|
3159
3237
|
function gzipIfAccepted(body, contentType, acceptEncoding) {
|
|
3160
3238
|
const extraHeaders = {};
|
|
3161
|
-
if (
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3239
|
+
if (isCompressible(contentType)) {
|
|
3240
|
+
if (acceptsBrotli(acceptEncoding)) {
|
|
3241
|
+
try {
|
|
3242
|
+
const compressed = brotliCompressSync(toBytes(body));
|
|
3243
|
+
extraHeaders["Content-Encoding"] = "br";
|
|
3244
|
+
extraHeaders.Vary = "Accept-Encoding";
|
|
3245
|
+
return { body: compressed, extraHeaders };
|
|
3246
|
+
} catch {}
|
|
3247
|
+
}
|
|
3248
|
+
if (acceptsGzip(acceptEncoding)) {
|
|
3249
|
+
try {
|
|
3250
|
+
const compressed = Bun.gzipSync(toBytes(body));
|
|
3251
|
+
extraHeaders["Content-Encoding"] = "gzip";
|
|
3252
|
+
extraHeaders.Vary = "Accept-Encoding";
|
|
3253
|
+
return { body: compressed, extraHeaders };
|
|
3254
|
+
} catch {}
|
|
3255
|
+
}
|
|
3168
3256
|
}
|
|
3169
3257
|
return { body, extraHeaders };
|
|
3170
3258
|
}
|
|
@@ -3199,6 +3287,7 @@ __export(exports_core, {
|
|
|
3199
3287
|
join: () => join11,
|
|
3200
3288
|
isCompressible: () => isCompressible,
|
|
3201
3289
|
gzipIfAccepted: () => gzipIfAccepted,
|
|
3290
|
+
getStaticDepsForUrl: () => getStaticDepsForUrl,
|
|
3202
3291
|
getMimeType: () => getMimeType,
|
|
3203
3292
|
getContentMeta: () => getContentMeta,
|
|
3204
3293
|
getBundleUrlsFor: () => getBundleUrlsFor,
|
|
@@ -3212,6 +3301,7 @@ __export(exports_core, {
|
|
|
3212
3301
|
basename: () => basename2,
|
|
3213
3302
|
applyIndexTemplate: () => applyIndexTemplate,
|
|
3214
3303
|
acceptsGzip: () => acceptsGzip,
|
|
3304
|
+
acceptsBrotli: () => acceptsBrotli,
|
|
3215
3305
|
LRUCache: () => LRUCache
|
|
3216
3306
|
});
|
|
3217
3307
|
var init_core = __esm(() => {
|
|
@@ -5535,7 +5625,7 @@ async function getVersionString2() {
|
|
|
5535
5625
|
}
|
|
5536
5626
|
async function getVersion2() {
|
|
5537
5627
|
if (true) {
|
|
5538
|
-
return "0.
|
|
5628
|
+
return "0.9.0";
|
|
5539
5629
|
}
|
|
5540
5630
|
const possiblePaths = [
|
|
5541
5631
|
path3.join(import.meta.dir, "../../../package.json"),
|
|
@@ -5552,10 +5642,10 @@ async function getVersion2() {
|
|
|
5552
5642
|
}
|
|
5553
5643
|
async function getCommit2() {
|
|
5554
5644
|
if (true) {
|
|
5555
|
-
return "
|
|
5645
|
+
return "a5db82d";
|
|
5556
5646
|
}
|
|
5557
5647
|
return "dev";
|
|
5558
5648
|
}
|
|
5559
5649
|
main();
|
|
5560
5650
|
|
|
5561
|
-
//# debugId=
|
|
5651
|
+
//# debugId=49628F09E4188CEE64756E2164756E21
|