@rangojs/router 0.6.0 → 0.8.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/dist/types/cache/cf/cf-cache-store.d.ts +30 -16
- package/dist/types/cache/shell-snapshot.d.ts +2 -2
- package/dist/types/cache/types.d.ts +26 -7
- package/dist/types/client-urls/server-projection.d.ts +10 -1
- package/dist/types/client-urls/types.d.ts +5 -2
- package/dist/types/router/segment-resolution/loader-mask.d.ts +9 -9
- package/dist/types/rsc/shell-capture.d.ts +5 -4
- package/dist/types/urls/path-helper-types.d.ts +4 -1
- package/dist/types/vite/plugins/client-ref-dedup.d.ts +0 -11
- package/dist/vite/index.js +360 -108
- package/package.json +25 -25
- package/skills/client-urls/SKILL.md +9 -9
- package/skills/cloudflare/SKILL.md +5 -3
- package/skills/ppr/SKILL.md +11 -7
- package/src/cache/cf/cf-cache-store.ts +118 -62
- package/src/cache/shell-snapshot.ts +2 -2
- package/src/cache/types.ts +27 -7
- package/src/client-urls/client-urls.ts +78 -0
- package/src/client-urls/server-projection.ts +95 -4
- package/src/client-urls/types.ts +8 -2
- package/src/router/segment-resolution/fresh.ts +8 -2
- package/src/router/segment-resolution/loader-cache.ts +34 -13
- package/src/router/segment-resolution/loader-mask.ts +9 -9
- package/src/router/segment-resolution/revalidation.ts +3 -1
- package/src/rsc/shell-build-manifest.ts +13 -6
- package/src/rsc/shell-capture.ts +22 -5
- package/src/urls/path-helper-types.ts +4 -1
- package/src/vite/plugins/client-ref-dedup.ts +281 -19
- package/src/vite/plugins/expose-action-id.ts +45 -23
package/dist/vite/index.js
CHANGED
|
@@ -119,7 +119,7 @@ __export(client_ref_hashing_exports, {
|
|
|
119
119
|
hashRefKey: () => hashRefKey,
|
|
120
120
|
transformClientRefs: () => transformClientRefs
|
|
121
121
|
});
|
|
122
|
-
import { relative as
|
|
122
|
+
import { relative as relative3 } from "node:path";
|
|
123
123
|
import { createHash as createHash2 } from "node:crypto";
|
|
124
124
|
function hashRefKey(relativeId) {
|
|
125
125
|
return createHash2("sha256").update(relativeId).digest("hex").slice(0, 12);
|
|
@@ -132,10 +132,10 @@ function computeProductionHash(projectRoot, refKey) {
|
|
|
132
132
|
const absPath = decodeURIComponent(
|
|
133
133
|
refKey.slice(CLIENT_IN_SERVER_PKG_PROXY_PREFIX.length)
|
|
134
134
|
);
|
|
135
|
-
toHash =
|
|
135
|
+
toHash = relative3(projectRoot, absPath).replaceAll("\\", "/");
|
|
136
136
|
} else if (refKey.startsWith(FS_PREFIX)) {
|
|
137
137
|
const absPath = refKey.slice(FS_PREFIX.length - 1);
|
|
138
|
-
toHash =
|
|
138
|
+
toHash = relative3(projectRoot, absPath).replaceAll("\\", "/");
|
|
139
139
|
} else if (refKey.startsWith("/")) {
|
|
140
140
|
toHash = refKey.slice(1);
|
|
141
141
|
} else {
|
|
@@ -1098,10 +1098,11 @@ var init_loader = __esm({
|
|
|
1098
1098
|
});
|
|
1099
1099
|
|
|
1100
1100
|
// src/vite/rango.ts
|
|
1101
|
-
import { readFileSync as
|
|
1101
|
+
import { readFileSync as readFileSync10, existsSync as existsSync11 } from "node:fs";
|
|
1102
1102
|
import { resolve as resolve13 } from "node:path";
|
|
1103
1103
|
|
|
1104
1104
|
// src/vite/plugins/expose-action-id.ts
|
|
1105
|
+
import { getPluginApi } from "@vitejs/plugin-rsc";
|
|
1105
1106
|
import MagicString from "magic-string";
|
|
1106
1107
|
import path2 from "node:path";
|
|
1107
1108
|
import fs from "node:fs";
|
|
@@ -1358,17 +1359,36 @@ function registerServerReferenceRegex() {
|
|
|
1358
1359
|
// src/vite/plugins/expose-action-id.ts
|
|
1359
1360
|
init_debug();
|
|
1360
1361
|
var debug = createRangoDebugger(NS.transform);
|
|
1362
|
+
function getServerReferenceMetaEntries(manager) {
|
|
1363
|
+
if (manager?.serverReferences?.metaMap) {
|
|
1364
|
+
return manager.serverReferences.metaMap;
|
|
1365
|
+
}
|
|
1366
|
+
if (manager?.serverReferenceMetaMap) {
|
|
1367
|
+
return Object.entries(manager.serverReferenceMetaMap);
|
|
1368
|
+
}
|
|
1369
|
+
throw new Error(
|
|
1370
|
+
"[rango] Unsupported @vitejs/plugin-rsc server reference metadata shape. Expected manager.serverReferences.metaMap or manager.serverReferenceMetaMap."
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1361
1373
|
function getRscPluginApi(config) {
|
|
1362
|
-
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1374
|
+
const pluginApi = getPluginApi(config);
|
|
1375
|
+
if (pluginApi) {
|
|
1376
|
+
return pluginApi;
|
|
1377
|
+
}
|
|
1378
|
+
const plugin = config.plugins.find((p) => {
|
|
1379
|
+
try {
|
|
1380
|
+
getServerReferenceMetaEntries(
|
|
1381
|
+
p.api?.manager
|
|
1370
1382
|
);
|
|
1383
|
+
return true;
|
|
1384
|
+
} catch {
|
|
1385
|
+
return false;
|
|
1371
1386
|
}
|
|
1387
|
+
});
|
|
1388
|
+
if (plugin) {
|
|
1389
|
+
console.warn(
|
|
1390
|
+
`[rango:expose-action-id] RSC plugin found by API structure (name: "${plugin.name}"). Consider updating the name lookup if the plugin was renamed.`
|
|
1391
|
+
);
|
|
1372
1392
|
}
|
|
1373
1393
|
return plugin?.api;
|
|
1374
1394
|
}
|
|
@@ -1472,9 +1492,8 @@ function exposeActionId() {
|
|
|
1472
1492
|
}
|
|
1473
1493
|
if (!isBuild) return;
|
|
1474
1494
|
hashToFileMap = /* @__PURE__ */ new Map();
|
|
1475
|
-
const
|
|
1476
|
-
|
|
1477
|
-
serverReferenceMetaMap
|
|
1495
|
+
for (const [absolutePath, meta] of getServerReferenceMetaEntries(
|
|
1496
|
+
rscPluginApi.manager
|
|
1478
1497
|
)) {
|
|
1479
1498
|
if (!isUseServerModule(absolutePath)) {
|
|
1480
1499
|
continue;
|
|
@@ -3166,8 +3185,11 @@ function warnOnNearMissDirectives(ast, fileId, warn) {
|
|
|
3166
3185
|
|
|
3167
3186
|
// src/vite/plugins/client-ref-dedup.ts
|
|
3168
3187
|
init_debug();
|
|
3188
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3189
|
+
import { isAbsolute, join, normalize, relative } from "node:path";
|
|
3169
3190
|
var debug5 = createRangoDebugger(NS.transform);
|
|
3170
3191
|
var CLIENT_IN_SERVER_PROXY_PREFIX = "virtual:vite-rsc/client-in-server-package-proxy/";
|
|
3192
|
+
var DEDUP_PREFIX = "\0rango:dedup/";
|
|
3171
3193
|
function extractPackageName(absolutePath) {
|
|
3172
3194
|
const marker = "/node_modules/";
|
|
3173
3195
|
const idx = absolutePath.lastIndexOf(marker);
|
|
@@ -3181,9 +3203,156 @@ function extractPackageName(absolutePath) {
|
|
|
3181
3203
|
const name = afterModules.split("/")[0];
|
|
3182
3204
|
return name || null;
|
|
3183
3205
|
}
|
|
3206
|
+
function stripQueryAndHash(id) {
|
|
3207
|
+
const suffixIndex = id.search(/[?#]/);
|
|
3208
|
+
return suffixIndex === -1 ? id : id.slice(0, suffixIndex);
|
|
3209
|
+
}
|
|
3210
|
+
function getPackageRoot(source) {
|
|
3211
|
+
const packageName = extractPackageName(source);
|
|
3212
|
+
if (!packageName) return;
|
|
3213
|
+
const marker = "/node_modules/";
|
|
3214
|
+
const markerIndex = source.lastIndexOf(marker);
|
|
3215
|
+
return source.slice(0, markerIndex + marker.length) + packageName;
|
|
3216
|
+
}
|
|
3217
|
+
function readPackageMetadata(source, cache3) {
|
|
3218
|
+
const root = getPackageRoot(source);
|
|
3219
|
+
if (!root) return;
|
|
3220
|
+
const cached = cache3.get(root);
|
|
3221
|
+
if (cached !== void 0) return cached ?? void 0;
|
|
3222
|
+
const packageJsonPath = join(root, "package.json");
|
|
3223
|
+
if (!existsSync(packageJsonPath)) {
|
|
3224
|
+
cache3.set(root, null);
|
|
3225
|
+
return;
|
|
3226
|
+
}
|
|
3227
|
+
try {
|
|
3228
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
3229
|
+
if (typeof packageJson.name !== "string" || !packageJson.name) {
|
|
3230
|
+
cache3.set(root, null);
|
|
3231
|
+
return;
|
|
3232
|
+
}
|
|
3233
|
+
const metadata = {
|
|
3234
|
+
root,
|
|
3235
|
+
selfName: packageJson.name,
|
|
3236
|
+
exports: packageJson.exports
|
|
3237
|
+
};
|
|
3238
|
+
cache3.set(root, metadata);
|
|
3239
|
+
return metadata;
|
|
3240
|
+
} catch {
|
|
3241
|
+
cache3.set(root, null);
|
|
3242
|
+
return;
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
function collectStringTargets(value, targets) {
|
|
3246
|
+
if (typeof value === "string") {
|
|
3247
|
+
targets.push(value);
|
|
3248
|
+
return;
|
|
3249
|
+
}
|
|
3250
|
+
if (Array.isArray(value)) {
|
|
3251
|
+
for (const item of value) collectStringTargets(item, targets);
|
|
3252
|
+
return;
|
|
3253
|
+
}
|
|
3254
|
+
if (typeof value !== "object" || value === null) return;
|
|
3255
|
+
for (const target of Object.values(value)) {
|
|
3256
|
+
collectStringTargets(target, targets);
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
function singleStarParts(value) {
|
|
3260
|
+
const starIndex = value.indexOf("*");
|
|
3261
|
+
if (starIndex === -1 || value.indexOf("*", starIndex + 1) !== -1) return;
|
|
3262
|
+
return [value.slice(0, starIndex), value.slice(starIndex + 1)];
|
|
3263
|
+
}
|
|
3264
|
+
function targetCanMapToSource(target, sourceRelative) {
|
|
3265
|
+
const targetStar = singleStarParts(target);
|
|
3266
|
+
if (!targetStar) return target === sourceRelative;
|
|
3267
|
+
const [prefix, suffix] = targetStar;
|
|
3268
|
+
return sourceRelative.startsWith(prefix) && sourceRelative.endsWith(suffix) && sourceRelative.length >= prefix.length + suffix.length;
|
|
3269
|
+
}
|
|
3270
|
+
function getPublicSpecifierCandidates(metadata, packageSpecifier, source) {
|
|
3271
|
+
if (typeof metadata.exports !== "object" || metadata.exports === null || Array.isArray(metadata.exports)) {
|
|
3272
|
+
return [];
|
|
3273
|
+
}
|
|
3274
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
3275
|
+
const sourceRelative = `./${relative(metadata.root, source).replaceAll("\\", "/")}`;
|
|
3276
|
+
if (sourceRelative.startsWith("./../") || isAbsolute(sourceRelative.slice(2))) {
|
|
3277
|
+
return [];
|
|
3278
|
+
}
|
|
3279
|
+
for (const [exportKey, target] of Object.entries(metadata.exports)) {
|
|
3280
|
+
if (!exportKey.startsWith("./") || exportKey === ".") continue;
|
|
3281
|
+
const keyStar = singleStarParts(exportKey);
|
|
3282
|
+
if (!keyStar) {
|
|
3283
|
+
const targets2 = [];
|
|
3284
|
+
collectStringTargets(target, targets2);
|
|
3285
|
+
if (targets2.some((target2) => targetCanMapToSource(target2, sourceRelative))) {
|
|
3286
|
+
candidates.add(`${packageSpecifier}${exportKey.slice(1)}`);
|
|
3287
|
+
}
|
|
3288
|
+
continue;
|
|
3289
|
+
}
|
|
3290
|
+
const captures = /* @__PURE__ */ new Set();
|
|
3291
|
+
const targets = [];
|
|
3292
|
+
collectStringTargets(target, targets);
|
|
3293
|
+
for (const targetPattern of targets) {
|
|
3294
|
+
const targetStar = singleStarParts(targetPattern);
|
|
3295
|
+
if (!targetStar) continue;
|
|
3296
|
+
const [prefix, suffix] = targetStar;
|
|
3297
|
+
if (!sourceRelative.startsWith(prefix) || !sourceRelative.endsWith(suffix) || sourceRelative.length < prefix.length + suffix.length) {
|
|
3298
|
+
continue;
|
|
3299
|
+
}
|
|
3300
|
+
captures.add(
|
|
3301
|
+
sourceRelative.slice(
|
|
3302
|
+
prefix.length,
|
|
3303
|
+
sourceRelative.length - suffix.length
|
|
3304
|
+
)
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3307
|
+
if (captures.size === 1) {
|
|
3308
|
+
const capture = captures.values().next().value;
|
|
3309
|
+
if (capture !== void 0) {
|
|
3310
|
+
const publicSubpath = `${keyStar[0]}${capture}${keyStar[1]}`;
|
|
3311
|
+
candidates.add(`${packageSpecifier}${publicSubpath.slice(1)}`);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
return [...candidates];
|
|
3316
|
+
}
|
|
3317
|
+
function belongsToPackage(resolvedId, packageRoot) {
|
|
3318
|
+
return normalize(getPackageRoot(resolvedId) ?? "") === normalize(packageRoot);
|
|
3319
|
+
}
|
|
3320
|
+
async function resolvePublicSpecifier(source, metadata, installedSpecifier, resolvePackage, importer) {
|
|
3321
|
+
const packageSpecifiers = installedSpecifier === metadata.selfName ? [installedSpecifier] : [installedSpecifier, metadata.selfName];
|
|
3322
|
+
for (const packageSpecifier of packageSpecifiers) {
|
|
3323
|
+
for (const candidate of getPublicSpecifierCandidates(
|
|
3324
|
+
metadata,
|
|
3325
|
+
packageSpecifier,
|
|
3326
|
+
source
|
|
3327
|
+
)) {
|
|
3328
|
+
try {
|
|
3329
|
+
const resolved = await resolvePackage(candidate, importer);
|
|
3330
|
+
if (!resolved) continue;
|
|
3331
|
+
const resolvedId = stripQueryAndHash(resolved);
|
|
3332
|
+
if (normalize(resolvedId) === normalize(source) && belongsToPackage(resolvedId, metadata.root)) {
|
|
3333
|
+
return candidate;
|
|
3334
|
+
}
|
|
3335
|
+
} catch {
|
|
3336
|
+
continue;
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
try {
|
|
3340
|
+
const rootResolved = await resolvePackage(packageSpecifier, importer);
|
|
3341
|
+
if (rootResolved && belongsToPackage(stripQueryAndHash(rootResolved), metadata.root)) {
|
|
3342
|
+
return packageSpecifier;
|
|
3343
|
+
}
|
|
3344
|
+
} catch {
|
|
3345
|
+
continue;
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3184
3349
|
function clientRefDedup() {
|
|
3185
3350
|
let clientExclude = [];
|
|
3351
|
+
let rootImporter = "";
|
|
3352
|
+
let resolvePackage;
|
|
3186
3353
|
const dedupedPackages = /* @__PURE__ */ new Set();
|
|
3354
|
+
const packageMetadataCache = /* @__PURE__ */ new Map();
|
|
3355
|
+
const publicSpecifierCache = /* @__PURE__ */ new Map();
|
|
3187
3356
|
return {
|
|
3188
3357
|
name: "@rangojs/router:client-ref-dedup",
|
|
3189
3358
|
enforce: "pre",
|
|
@@ -3191,6 +3360,8 @@ function clientRefDedup() {
|
|
|
3191
3360
|
configResolved(config) {
|
|
3192
3361
|
const clientEnv = config.environments?.["client"];
|
|
3193
3362
|
clientExclude = clientEnv?.optimizeDeps?.exclude ?? config.optimizeDeps?.exclude ?? [];
|
|
3363
|
+
rootImporter = join(config.root, "index.html");
|
|
3364
|
+
resolvePackage = config.createResolver({ scan: true });
|
|
3194
3365
|
},
|
|
3195
3366
|
buildEnd() {
|
|
3196
3367
|
if (debug5 && dedupedPackages.size > 0) {
|
|
@@ -3205,18 +3376,52 @@ function clientRefDedup() {
|
|
|
3205
3376
|
if (this.environment?.name !== "client") return;
|
|
3206
3377
|
if (!importer?.includes(CLIENT_IN_SERVER_PROXY_PREFIX)) return;
|
|
3207
3378
|
if (!source.includes("/node_modules/")) return;
|
|
3208
|
-
const
|
|
3209
|
-
|
|
3379
|
+
const cleanSource = stripQueryAndHash(source);
|
|
3380
|
+
const packageName = extractPackageName(cleanSource);
|
|
3381
|
+
if (!packageName || !resolvePackage) return;
|
|
3210
3382
|
if (clientExclude.includes(packageName)) return;
|
|
3211
|
-
|
|
3212
|
-
return
|
|
3383
|
+
const metadata = readPackageMetadata(cleanSource, packageMetadataCache);
|
|
3384
|
+
if (!metadata || clientExclude.includes(metadata.selfName)) return;
|
|
3385
|
+
let specifierPromise = publicSpecifierCache.get(cleanSource);
|
|
3386
|
+
if (!specifierPromise) {
|
|
3387
|
+
specifierPromise = resolvePublicSpecifier(
|
|
3388
|
+
cleanSource,
|
|
3389
|
+
metadata,
|
|
3390
|
+
packageName,
|
|
3391
|
+
resolvePackage,
|
|
3392
|
+
rootImporter
|
|
3393
|
+
);
|
|
3394
|
+
publicSpecifierCache.set(cleanSource, specifierPromise);
|
|
3395
|
+
void specifierPromise.then(
|
|
3396
|
+
(specifier) => {
|
|
3397
|
+
if (!specifier && publicSpecifierCache.get(cleanSource) === specifierPromise) {
|
|
3398
|
+
publicSpecifierCache.delete(cleanSource);
|
|
3399
|
+
}
|
|
3400
|
+
},
|
|
3401
|
+
() => {
|
|
3402
|
+
if (publicSpecifierCache.get(cleanSource) === specifierPromise) {
|
|
3403
|
+
publicSpecifierCache.delete(cleanSource);
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
);
|
|
3407
|
+
}
|
|
3408
|
+
return specifierPromise.then((specifier) => {
|
|
3409
|
+
if (!specifier) return;
|
|
3410
|
+
if (debug5) dedupedPackages.add(packageName);
|
|
3411
|
+
return `${DEDUP_PREFIX}${encodeURIComponent(specifier)}`;
|
|
3412
|
+
});
|
|
3213
3413
|
},
|
|
3214
3414
|
load(id) {
|
|
3215
|
-
if (!id.startsWith(
|
|
3216
|
-
|
|
3415
|
+
if (!id.startsWith(DEDUP_PREFIX)) return;
|
|
3416
|
+
let specifier;
|
|
3417
|
+
try {
|
|
3418
|
+
specifier = decodeURIComponent(id.slice(DEDUP_PREFIX.length));
|
|
3419
|
+
} catch {
|
|
3420
|
+
return;
|
|
3421
|
+
}
|
|
3217
3422
|
return [
|
|
3218
|
-
`export * from ${JSON.stringify(
|
|
3219
|
-
`import * as __all__ from ${JSON.stringify(
|
|
3423
|
+
`export * from ${JSON.stringify(specifier)};`,
|
|
3424
|
+
`import * as __all__ from ${JSON.stringify(specifier)};`,
|
|
3220
3425
|
`export default __all__.default;`
|
|
3221
3426
|
].join("\n");
|
|
3222
3427
|
}
|
|
@@ -3473,14 +3678,14 @@ function getVirtualVersionContent(version) {
|
|
|
3473
3678
|
}
|
|
3474
3679
|
|
|
3475
3680
|
// src/vite/utils/package-resolution.ts
|
|
3476
|
-
import { existsSync } from "node:fs";
|
|
3681
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
3477
3682
|
import { createRequire } from "node:module";
|
|
3478
3683
|
import { resolve } from "node:path";
|
|
3479
3684
|
|
|
3480
3685
|
// package.json
|
|
3481
3686
|
var package_default = {
|
|
3482
3687
|
name: "@rangojs/router",
|
|
3483
|
-
version: "0.
|
|
3688
|
+
version: "0.8.0",
|
|
3484
3689
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
3485
3690
|
keywords: [
|
|
3486
3691
|
"react",
|
|
@@ -3662,6 +3867,7 @@ var package_default = {
|
|
|
3662
3867
|
prepublishOnly: "pnpm build",
|
|
3663
3868
|
typecheck: "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit && tsc -p tsconfig.augment-check.json --noEmit",
|
|
3664
3869
|
test: "playwright test",
|
|
3870
|
+
"test:preload": "playwright test --config=playwright.preload.config.ts",
|
|
3665
3871
|
"test:ui": "playwright test --ui",
|
|
3666
3872
|
"test:hmr-local": "playwright test --project=dev-warmup --project=hmr-basename --project=hmr-prerender --no-deps --workers=1 && RANGO_E2E_ROUTE_HMR_ONLY=1 playwright test --project=hmr-routes --no-deps --workers=1",
|
|
3667
3873
|
"test:hmr-routes-local": "RANGO_E2E_ROUTE_HMR_ONLY=1 playwright test --project=hmr-routes --no-deps --workers=1",
|
|
@@ -3671,7 +3877,7 @@ var package_default = {
|
|
|
3671
3877
|
},
|
|
3672
3878
|
dependencies: {
|
|
3673
3879
|
"@types/debug": "^4.1.12",
|
|
3674
|
-
"@vitejs/plugin-rsc": "^0.5.
|
|
3880
|
+
"@vitejs/plugin-rsc": "^0.5.31",
|
|
3675
3881
|
debug: "^4.4.1",
|
|
3676
3882
|
"magic-string": "^0.30.17",
|
|
3677
3883
|
picomatch: "^4.0.4",
|
|
@@ -3704,9 +3910,9 @@ var package_default = {
|
|
|
3704
3910
|
"@playwright/test": "^1.49.1",
|
|
3705
3911
|
"@testing-library/react": ">=16",
|
|
3706
3912
|
"@vercel/functions": "^3.0.0",
|
|
3707
|
-
"@vitejs/plugin-rsc": "^0.5.
|
|
3708
|
-
react: ">=19.2.
|
|
3709
|
-
"react-dom": ">=19.2.
|
|
3913
|
+
"@vitejs/plugin-rsc": "^0.5.31",
|
|
3914
|
+
react: ">=19.2.8 <20",
|
|
3915
|
+
"react-dom": ">=19.2.8 <20",
|
|
3710
3916
|
vite: "^8.0.16",
|
|
3711
3917
|
vitest: ">=3"
|
|
3712
3918
|
},
|
|
@@ -3746,7 +3952,7 @@ function getPublishedPackageName() {
|
|
|
3746
3952
|
}
|
|
3747
3953
|
function isInstalledFromNpm() {
|
|
3748
3954
|
const packageName = getPublishedPackageName();
|
|
3749
|
-
return
|
|
3955
|
+
return existsSync2(resolve(process.cwd(), "node_modules", packageName));
|
|
3750
3956
|
}
|
|
3751
3957
|
function isWorkspaceDevelopment() {
|
|
3752
3958
|
return !isInstalledFromNpm();
|
|
@@ -3932,7 +4138,7 @@ declare global {
|
|
|
3932
4138
|
}
|
|
3933
4139
|
|
|
3934
4140
|
// src/build/route-types/scan-filter.ts
|
|
3935
|
-
import { join, relative } from "node:path";
|
|
4141
|
+
import { join as join2, relative as relative2 } from "node:path";
|
|
3936
4142
|
import { readdirSync } from "node:fs";
|
|
3937
4143
|
import picomatch from "picomatch";
|
|
3938
4144
|
var DEFAULT_EXCLUDE_PATTERNS = [
|
|
@@ -3952,7 +4158,7 @@ function createScanFilter(root, opts) {
|
|
|
3952
4158
|
const includeMatcher = hasInclude ? picomatch(include) : null;
|
|
3953
4159
|
const excludeMatcher = effectiveExclude.length > 0 ? picomatch(effectiveExclude) : null;
|
|
3954
4160
|
return (absolutePath) => {
|
|
3955
|
-
const rel =
|
|
4161
|
+
const rel = relative2(root, absolutePath);
|
|
3956
4162
|
if (excludeMatcher && excludeMatcher(rel)) return false;
|
|
3957
4163
|
if (includeMatcher) return includeMatcher(rel);
|
|
3958
4164
|
return true;
|
|
@@ -3970,7 +4176,7 @@ function findTsFiles(dir, filter) {
|
|
|
3970
4176
|
return results;
|
|
3971
4177
|
}
|
|
3972
4178
|
for (const entry of entries) {
|
|
3973
|
-
const fullPath =
|
|
4179
|
+
const fullPath = join2(dir, entry.name);
|
|
3974
4180
|
if (entry.isDirectory()) {
|
|
3975
4181
|
if (entry.name === "node_modules" || entry.name.startsWith(".") || entry.name === "dist" || entry.name === "build" || entry.name === "coverage")
|
|
3976
4182
|
continue;
|
|
@@ -3987,7 +4193,7 @@ function findTsFiles(dir, filter) {
|
|
|
3987
4193
|
import ts4 from "typescript";
|
|
3988
4194
|
|
|
3989
4195
|
// src/build/route-types/include-resolution.ts
|
|
3990
|
-
import { readFileSync, existsSync as
|
|
4196
|
+
import { readFileSync as readFileSync2, existsSync as existsSync3 } from "node:fs";
|
|
3991
4197
|
import { dirname, resolve as resolve2 } from "node:path";
|
|
3992
4198
|
import ts3 from "typescript";
|
|
3993
4199
|
function createScanMemo() {
|
|
@@ -4013,7 +4219,7 @@ function readSourceMemoized(memo, realPath) {
|
|
|
4013
4219
|
const cached = memo.files.get(realPath);
|
|
4014
4220
|
if (cached !== void 0) return cached;
|
|
4015
4221
|
}
|
|
4016
|
-
const source =
|
|
4222
|
+
const source = readFileSync2(realPath, "utf-8");
|
|
4017
4223
|
if (memo) memo.files.set(realPath, source);
|
|
4018
4224
|
return source;
|
|
4019
4225
|
}
|
|
@@ -4225,7 +4431,7 @@ function resolveImportPath(importSpec, fromFile) {
|
|
|
4225
4431
|
resolve2(dir, base + "/index.jsx")
|
|
4226
4432
|
];
|
|
4227
4433
|
for (const candidate of candidates) {
|
|
4228
|
-
if (
|
|
4434
|
+
if (existsSync3(candidate)) return candidate;
|
|
4229
4435
|
}
|
|
4230
4436
|
return null;
|
|
4231
4437
|
}
|
|
@@ -4526,14 +4732,14 @@ function buildCombinedRouteMapWithSearch(filePath, variableName, visited, diagno
|
|
|
4526
4732
|
|
|
4527
4733
|
// src/build/route-types/router-processing.ts
|
|
4528
4734
|
import {
|
|
4529
|
-
readFileSync as
|
|
4735
|
+
readFileSync as readFileSync3,
|
|
4530
4736
|
writeFileSync,
|
|
4531
|
-
existsSync as
|
|
4737
|
+
existsSync as existsSync4,
|
|
4532
4738
|
unlinkSync,
|
|
4533
4739
|
readdirSync as readdirSync2
|
|
4534
4740
|
} from "node:fs";
|
|
4535
4741
|
import {
|
|
4536
|
-
join as
|
|
4742
|
+
join as join3,
|
|
4537
4743
|
dirname as dirname2,
|
|
4538
4744
|
resolve as resolve3,
|
|
4539
4745
|
sep,
|
|
@@ -4572,7 +4778,7 @@ function findCallSiteFilesRecursive(dir, pattern, patternG, stopAtMatchDir, filt
|
|
|
4572
4778
|
const childDirs = [];
|
|
4573
4779
|
const matchesInDir = [];
|
|
4574
4780
|
for (const entry of entries) {
|
|
4575
|
-
const fullPath =
|
|
4781
|
+
const fullPath = join3(dir, entry.name);
|
|
4576
4782
|
if (entry.isDirectory()) {
|
|
4577
4783
|
if (!isExcludedScanDir(entry.name)) childDirs.push(fullPath);
|
|
4578
4784
|
continue;
|
|
@@ -4580,7 +4786,7 @@ function findCallSiteFilesRecursive(dir, pattern, patternG, stopAtMatchDir, filt
|
|
|
4580
4786
|
if (!isRoutableSourceFile(entry.name)) continue;
|
|
4581
4787
|
if (filter && !filter(fullPath)) continue;
|
|
4582
4788
|
try {
|
|
4583
|
-
const source =
|
|
4789
|
+
const source = readFileSync3(fullPath, "utf-8");
|
|
4584
4790
|
if (pattern.test(source) && firstCodeMatchIndex(source, patternG) >= 0) {
|
|
4585
4791
|
matchesInDir.push(fullPath);
|
|
4586
4792
|
}
|
|
@@ -4802,7 +5008,7 @@ function mergeRouteMaps(target, source) {
|
|
|
4802
5008
|
}
|
|
4803
5009
|
function genFileTsPath(sourceFile) {
|
|
4804
5010
|
const base = pathBasename(sourceFile).replace(/\.(tsx?|jsx?)$/, "");
|
|
4805
|
-
return
|
|
5011
|
+
return join3(dirname2(sourceFile), `${base}.named-routes.gen.ts`);
|
|
4806
5012
|
}
|
|
4807
5013
|
function resolveSearchSchemas(publicRouteNames, runtimeSchemas, sourceFile) {
|
|
4808
5014
|
if (runtimeSchemas && Object.keys(runtimeSchemas).length > 0) {
|
|
@@ -4822,7 +5028,7 @@ function resolveSearchSchemas(publicRouteNames, runtimeSchemas, sourceFile) {
|
|
|
4822
5028
|
function buildCombinedRouteMapForRouterFile(routerFilePath) {
|
|
4823
5029
|
let routerSource;
|
|
4824
5030
|
try {
|
|
4825
|
-
routerSource =
|
|
5031
|
+
routerSource = readFileSync3(routerFilePath, "utf-8");
|
|
4826
5032
|
} catch {
|
|
4827
5033
|
return { routes: {}, searchSchemas: {} };
|
|
4828
5034
|
}
|
|
@@ -4879,8 +5085,8 @@ function findHostRouterFiles(root, filter) {
|
|
|
4879
5085
|
}
|
|
4880
5086
|
function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
|
|
4881
5087
|
try {
|
|
4882
|
-
const oldCombinedPath =
|
|
4883
|
-
if (
|
|
5088
|
+
const oldCombinedPath = join3(root, "src", "named-routes.gen.ts");
|
|
5089
|
+
if (existsSync4(oldCombinedPath)) {
|
|
4884
5090
|
unlinkSync(oldCombinedPath);
|
|
4885
5091
|
console.log(
|
|
4886
5092
|
`[rango] Removed stale combined route types: ${oldCombinedPath}`
|
|
@@ -4899,14 +5105,14 @@ function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
|
|
|
4899
5105
|
if (Object.keys(result.routes).length === 0 && Object.keys(result.searchSchemas).length === 0) {
|
|
4900
5106
|
let routerSource;
|
|
4901
5107
|
try {
|
|
4902
|
-
routerSource =
|
|
5108
|
+
routerSource = readFileSync3(routerFilePath, "utf-8");
|
|
4903
5109
|
} catch {
|
|
4904
5110
|
continue;
|
|
4905
5111
|
}
|
|
4906
5112
|
if (!extractUrlsFromRouter(routerSource)) continue;
|
|
4907
5113
|
}
|
|
4908
5114
|
const outPath = genFileTsPath(routerFilePath);
|
|
4909
|
-
const existing =
|
|
5115
|
+
const existing = existsSync4(outPath) ? readFileSync3(outPath, "utf-8") : null;
|
|
4910
5116
|
if (Object.keys(result.routes).length === 0) {
|
|
4911
5117
|
if (!existing) {
|
|
4912
5118
|
const emptySource = generateRouteTypesSource({});
|
|
@@ -5155,7 +5361,7 @@ function isViteDepCachePath(filePath, cacheDir) {
|
|
|
5155
5361
|
|
|
5156
5362
|
// src/vite/utils/shared-utils.ts
|
|
5157
5363
|
import * as Vite from "vite";
|
|
5158
|
-
import { isAbsolute, resolve as resolve4 } from "node:path";
|
|
5364
|
+
import { isAbsolute as isAbsolute2, resolve as resolve4 } from "node:path";
|
|
5159
5365
|
|
|
5160
5366
|
// src/vite/plugins/performance-tracks.ts
|
|
5161
5367
|
init_debug();
|
|
@@ -5242,7 +5448,7 @@ var sharedRolldownOptions = {
|
|
|
5242
5448
|
function normalizeHostRouterEntry(rawInput, root, exists) {
|
|
5243
5449
|
const raw = rawInput.replaceAll("\\", "/");
|
|
5244
5450
|
const isRelative = raw.startsWith("./") || raw.startsWith("../");
|
|
5245
|
-
const isRooted = raw.startsWith("/") ||
|
|
5451
|
+
const isRooted = raw.startsWith("/") || isAbsolute2(rawInput);
|
|
5246
5452
|
if (isRooted) return raw;
|
|
5247
5453
|
if (isRelative) {
|
|
5248
5454
|
if (!exists(resolve4(root, raw))) {
|
|
@@ -5402,8 +5608,8 @@ function resolveClientChunks(option, ctx) {
|
|
|
5402
5608
|
|
|
5403
5609
|
// src/vite/plugins/vercel-output.ts
|
|
5404
5610
|
import { rm, mkdir, cp, writeFile } from "node:fs/promises";
|
|
5405
|
-
import { existsSync as
|
|
5406
|
-
import { resolve as resolve5, join as
|
|
5611
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
5612
|
+
import { resolve as resolve5, join as join4 } from "node:path";
|
|
5407
5613
|
import { createRequire as createRequire2 } from "node:module";
|
|
5408
5614
|
import { pathToFileURL } from "node:url";
|
|
5409
5615
|
var LAUNCHER_SOURCE = `import { toNodeHandler } from "srvx/node";
|
|
@@ -5476,14 +5682,14 @@ async function assemble(root, options, assetsDir, publicDir) {
|
|
|
5476
5682
|
const vercel = options.vercel ?? {};
|
|
5477
5683
|
assertVercelNodeRuntime(vercel.runtime);
|
|
5478
5684
|
const assetsPrefix = assetsDir.replace(/^\/+|\/+$/g, "");
|
|
5479
|
-
if (publicDir && assetsPrefix &&
|
|
5685
|
+
if (publicDir && assetsPrefix && existsSync5(join4(publicDir, assetsPrefix))) {
|
|
5480
5686
|
console.warn(
|
|
5481
|
-
`[rango] preset "vercel": ${
|
|
5687
|
+
`[rango] preset "vercel": ${join4(publicDir, assetsPrefix)} exists. Files under public/${assetsPrefix}/ share the /${assetsPrefix}/ URL prefix with hashed build assets and will be served with a one-year immutable cache-control header. Move un-hashed public files out of "${assetsPrefix}/".`
|
|
5482
5688
|
);
|
|
5483
5689
|
}
|
|
5484
|
-
const dist =
|
|
5690
|
+
const dist = join4(root, "dist");
|
|
5485
5691
|
for (const dir of ["client", "rsc", "ssr"]) {
|
|
5486
|
-
if (!
|
|
5692
|
+
if (!existsSync5(join4(dist, dir))) {
|
|
5487
5693
|
throw new Error(
|
|
5488
5694
|
`[rango] preset "vercel": missing dist/${dir}. Run the production build first.`
|
|
5489
5695
|
);
|
|
@@ -5491,15 +5697,15 @@ async function assemble(root, options, assetsDir, publicDir) {
|
|
|
5491
5697
|
}
|
|
5492
5698
|
const functionName = vercel.functionName ?? "index";
|
|
5493
5699
|
assertValidVercelFunctionName(functionName);
|
|
5494
|
-
const out =
|
|
5495
|
-
const funcDir =
|
|
5700
|
+
const out = join4(root, ".vercel", "output");
|
|
5701
|
+
const funcDir = join4(out, "functions", `${functionName}.func`);
|
|
5496
5702
|
await rm(out, { recursive: true, force: true });
|
|
5497
5703
|
await mkdir(funcDir, { recursive: true });
|
|
5498
|
-
await cp(
|
|
5499
|
-
await cp(
|
|
5500
|
-
await cp(
|
|
5501
|
-
if (
|
|
5502
|
-
await cp(
|
|
5704
|
+
await cp(join4(dist, "client"), join4(out, "static"), { recursive: true });
|
|
5705
|
+
await cp(join4(dist, "rsc"), join4(funcDir, "rsc"), { recursive: true });
|
|
5706
|
+
await cp(join4(dist, "ssr"), join4(funcDir, "ssr"), { recursive: true });
|
|
5707
|
+
if (existsSync5(join4(dist, "static"))) {
|
|
5708
|
+
await cp(join4(dist, "static"), join4(funcDir, "static"), {
|
|
5503
5709
|
recursive: true
|
|
5504
5710
|
});
|
|
5505
5711
|
}
|
|
@@ -5512,7 +5718,7 @@ async function assemble(root, options, assetsDir, publicDir) {
|
|
|
5512
5718
|
'[rango] preset "vercel" requires "srvx" (a dependency of @rangojs/router). Reinstall dependencies.'
|
|
5513
5719
|
);
|
|
5514
5720
|
}
|
|
5515
|
-
const appRequire = createRequire2(
|
|
5721
|
+
const appRequire = createRequire2(join4(root, "package.json"));
|
|
5516
5722
|
const resolveEsbuildPath = () => {
|
|
5517
5723
|
try {
|
|
5518
5724
|
const viteRequire = createRequire2(appRequire.resolve("vite"));
|
|
@@ -5545,7 +5751,7 @@ async function assemble(root, options, assetsDir, publicDir) {
|
|
|
5545
5751
|
sourcefile: "func-entry.mjs",
|
|
5546
5752
|
loader: "js"
|
|
5547
5753
|
},
|
|
5548
|
-
outfile:
|
|
5754
|
+
outfile: join4(funcDir, "index.mjs"),
|
|
5549
5755
|
bundle: true,
|
|
5550
5756
|
format: "esm",
|
|
5551
5757
|
platform: "node",
|
|
@@ -5573,15 +5779,15 @@ async function assemble(root, options, assetsDir, publicDir) {
|
|
|
5573
5779
|
throw error;
|
|
5574
5780
|
}
|
|
5575
5781
|
await writeFile(
|
|
5576
|
-
|
|
5782
|
+
join4(funcDir, "package.json"),
|
|
5577
5783
|
JSON.stringify({ type: "module" }, null, 2) + "\n"
|
|
5578
5784
|
);
|
|
5579
5785
|
await writeFile(
|
|
5580
|
-
|
|
5786
|
+
join4(funcDir, ".vc-config.json"),
|
|
5581
5787
|
JSON.stringify(buildVercelVcConfig(vercel), null, 2) + "\n"
|
|
5582
5788
|
);
|
|
5583
5789
|
await writeFile(
|
|
5584
|
-
|
|
5790
|
+
join4(out, "config.json"),
|
|
5585
5791
|
JSON.stringify(buildVercelOutputConfig(functionName, assetsDir), null, 2) + "\n"
|
|
5586
5792
|
);
|
|
5587
5793
|
console.log(
|
|
@@ -5764,7 +5970,7 @@ function createCjsToEsmPlugin() {
|
|
|
5764
5970
|
// src/vite/router-discovery.ts
|
|
5765
5971
|
import { createServer as createViteServer } from "vite";
|
|
5766
5972
|
import { resolve as resolve12 } from "node:path";
|
|
5767
|
-
import { readFileSync as
|
|
5973
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
5768
5974
|
import { createRequire as createRequire3, register } from "node:module";
|
|
5769
5975
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
5770
5976
|
|
|
@@ -6129,7 +6335,7 @@ function createDiscoveryState(entryPath, opts) {
|
|
|
6129
6335
|
|
|
6130
6336
|
// src/vite/discovery/self-gen-tracking.ts
|
|
6131
6337
|
import { createHash as createHash3 } from "node:crypto";
|
|
6132
|
-
import { readFileSync as
|
|
6338
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
6133
6339
|
function markSelfGenWrite(state, filePath, content) {
|
|
6134
6340
|
const hash = createHash3("sha256").update(content).digest("hex");
|
|
6135
6341
|
state.selfWrittenGenFiles.set(filePath, { at: Date.now(), hash });
|
|
@@ -6148,7 +6354,7 @@ function checkSelfGenWrite(state, filePath, consume) {
|
|
|
6148
6354
|
return false;
|
|
6149
6355
|
}
|
|
6150
6356
|
try {
|
|
6151
|
-
const current =
|
|
6357
|
+
const current = readFileSync4(filePath, "utf-8");
|
|
6152
6358
|
const currentHash = createHash3("sha256").update(current).digest("hex");
|
|
6153
6359
|
if (currentHash === info.hash) {
|
|
6154
6360
|
if (consume) state.selfWrittenGenFiles.delete(filePath);
|
|
@@ -6646,7 +6852,7 @@ function contextSet(variables, keyOrVar, value, options) {
|
|
|
6646
6852
|
import { createHash as createHash4 } from "node:crypto";
|
|
6647
6853
|
import {
|
|
6648
6854
|
copyFileSync,
|
|
6649
|
-
existsSync as
|
|
6855
|
+
existsSync as existsSync6,
|
|
6650
6856
|
mkdirSync,
|
|
6651
6857
|
rmSync,
|
|
6652
6858
|
statSync,
|
|
@@ -6818,7 +7024,7 @@ function writeBuildAssetModule(dir, prefix, exportValue) {
|
|
|
6818
7024
|
const contentHash = createHash4("sha256").update(exportValue).digest("hex").slice(0, 8);
|
|
6819
7025
|
const fileName = `${prefix}-${contentHash}.js`;
|
|
6820
7026
|
const filePath = resolve7(dir, fileName);
|
|
6821
|
-
if (!
|
|
7027
|
+
if (!existsSync6(filePath)) {
|
|
6822
7028
|
writeFileSync2(filePath, `export default ${exportValue};
|
|
6823
7029
|
`);
|
|
6824
7030
|
}
|
|
@@ -7326,8 +7532,8 @@ init_debug();
|
|
|
7326
7532
|
init_client_ref_hashing();
|
|
7327
7533
|
|
|
7328
7534
|
// src/vite/discovery/client-urls-projection.ts
|
|
7329
|
-
import { existsSync as
|
|
7330
|
-
import { isAbsolute as
|
|
7535
|
+
import { existsSync as existsSync7, readFileSync as readFileSync5 } from "node:fs";
|
|
7536
|
+
import { isAbsolute as isAbsolute3, relative as relative4, resolve as resolve8 } from "node:path";
|
|
7331
7537
|
import { normalizePath as normalizePath4, parseAst as parseAst5 } from "vite";
|
|
7332
7538
|
|
|
7333
7539
|
// src/client-urls/server-projection.ts
|
|
@@ -8696,7 +8902,14 @@ var SEARCH_SCHEMA_VALUES = /* @__PURE__ */ new Set([
|
|
|
8696
8902
|
var PROJECTION_OPTIONS = /* @__PURE__ */ new Set([
|
|
8697
8903
|
"name",
|
|
8698
8904
|
"search",
|
|
8699
|
-
"trailingSlash"
|
|
8905
|
+
"trailingSlash",
|
|
8906
|
+
"ppr"
|
|
8907
|
+
]);
|
|
8908
|
+
var PPR_NUMBER_KEYS = /* @__PURE__ */ new Set([
|
|
8909
|
+
"ttl",
|
|
8910
|
+
"swr",
|
|
8911
|
+
"captureTimeout",
|
|
8912
|
+
"maxSnapshotBytes"
|
|
8700
8913
|
]);
|
|
8701
8914
|
function routeDescription(route2) {
|
|
8702
8915
|
return `route "${route2.pattern}" (${route2.id})`;
|
|
@@ -8727,9 +8940,6 @@ function serializeOptions(route2) {
|
|
|
8727
8940
|
const source = route2.options;
|
|
8728
8941
|
if (!source) return Object.freeze({});
|
|
8729
8942
|
for (const key of Reflect.ownKeys(source)) {
|
|
8730
|
-
if (key === "ppr") {
|
|
8731
|
-
throw projectionError(route2, 'path option "ppr" is not supported');
|
|
8732
|
-
}
|
|
8733
8943
|
if (!PROJECTION_OPTIONS.has(key)) {
|
|
8734
8944
|
throw projectionError(
|
|
8735
8945
|
route2,
|
|
@@ -8744,8 +8954,50 @@ function serializeOptions(route2) {
|
|
|
8744
8954
|
if (source.trailingSlash !== void 0) {
|
|
8745
8955
|
options.trailingSlash = source.trailingSlash;
|
|
8746
8956
|
}
|
|
8957
|
+
if (source.ppr !== void 0) {
|
|
8958
|
+
options.ppr = serializePpr(route2, source.ppr);
|
|
8959
|
+
}
|
|
8747
8960
|
return Object.freeze(options);
|
|
8748
8961
|
}
|
|
8962
|
+
function serializePpr(route2, source) {
|
|
8963
|
+
if (source === true) return true;
|
|
8964
|
+
if (typeof source !== "object" || source === null || Array.isArray(source)) {
|
|
8965
|
+
throw projectionError(
|
|
8966
|
+
route2,
|
|
8967
|
+
'path option "ppr" must be true or a PartialPrerenderProps object'
|
|
8968
|
+
);
|
|
8969
|
+
}
|
|
8970
|
+
const out = {};
|
|
8971
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
8972
|
+
if (PPR_NUMBER_KEYS.has(key)) {
|
|
8973
|
+
const value = source[key];
|
|
8974
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
8975
|
+
throw projectionError(
|
|
8976
|
+
route2,
|
|
8977
|
+
`path option "ppr.${String(key)}" must be a finite number`
|
|
8978
|
+
);
|
|
8979
|
+
}
|
|
8980
|
+
out[key] = value;
|
|
8981
|
+
continue;
|
|
8982
|
+
}
|
|
8983
|
+
if (key === "tags") {
|
|
8984
|
+
const tags = source.tags;
|
|
8985
|
+
if (!Array.isArray(tags) || tags.some((tag) => typeof tag !== "string" || tag === "")) {
|
|
8986
|
+
throw projectionError(
|
|
8987
|
+
route2,
|
|
8988
|
+
'path option "ppr.tags" must be an array of non-empty strings'
|
|
8989
|
+
);
|
|
8990
|
+
}
|
|
8991
|
+
out.tags = Object.freeze([...tags]);
|
|
8992
|
+
continue;
|
|
8993
|
+
}
|
|
8994
|
+
throw projectionError(
|
|
8995
|
+
route2,
|
|
8996
|
+
`path option "ppr.${String(key)}" is not supported`
|
|
8997
|
+
);
|
|
8998
|
+
}
|
|
8999
|
+
return Object.freeze(out);
|
|
9000
|
+
}
|
|
8749
9001
|
function serializeTransition(route2) {
|
|
8750
9002
|
const source = route2.transition;
|
|
8751
9003
|
if (!source) return void 0;
|
|
@@ -8828,7 +9080,7 @@ function hasDefaultExport(code) {
|
|
|
8828
9080
|
}
|
|
8829
9081
|
function normalizeSource(state, id) {
|
|
8830
9082
|
const cleanId = id.split("?", 1)[0];
|
|
8831
|
-
const absoluteId =
|
|
9083
|
+
const absoluteId = isAbsolute3(cleanId) ? cleanId : resolve8(state.projectRoot, cleanId);
|
|
8832
9084
|
return normalizePath4(absoluteId);
|
|
8833
9085
|
}
|
|
8834
9086
|
function referenceId(referenceKey) {
|
|
@@ -8840,8 +9092,8 @@ function recordClientUrlsModule(state, code, id) {
|
|
|
8840
9092
|
}
|
|
8841
9093
|
const source = normalizeSource(state, id);
|
|
8842
9094
|
const projectRoot = normalizePath4(resolve8(state.projectRoot));
|
|
8843
|
-
const relativeId = normalizePath4(
|
|
8844
|
-
const outsideProject = relativeId === ".." || relativeId.startsWith("../") ||
|
|
9095
|
+
const relativeId = normalizePath4(relative4(projectRoot, source));
|
|
9096
|
+
const outsideProject = relativeId === ".." || relativeId.startsWith("../") || isAbsolute3(relativeId);
|
|
8845
9097
|
const devReferenceKey = outsideProject ? `/@fs${source}` : `/${relativeId}`;
|
|
8846
9098
|
const sourceByReferenceId = state.clientUrlSourceByReferenceId ??= /* @__PURE__ */ new Map();
|
|
8847
9099
|
sourceByReferenceId.set(referenceId(devReferenceKey), source);
|
|
@@ -8858,7 +9110,7 @@ function scanForClientUrlModules(state) {
|
|
|
8858
9110
|
for (const filePath of findTsFiles(state.projectRoot, state.scanFilter)) {
|
|
8859
9111
|
let code;
|
|
8860
9112
|
try {
|
|
8861
|
-
code =
|
|
9113
|
+
code = readFileSync5(filePath, "utf-8");
|
|
8862
9114
|
} catch {
|
|
8863
9115
|
continue;
|
|
8864
9116
|
}
|
|
@@ -8940,7 +9192,7 @@ async function discoverClientUrlProjections(state, ssrEnv, serverMod) {
|
|
|
8940
9192
|
try {
|
|
8941
9193
|
module = await ssrEnv.runner.import(source);
|
|
8942
9194
|
} catch (cause) {
|
|
8943
|
-
if (!
|
|
9195
|
+
if (!existsSync7(source)) {
|
|
8944
9196
|
removedSources.push(source);
|
|
8945
9197
|
continue;
|
|
8946
9198
|
}
|
|
@@ -9180,8 +9432,8 @@ async function discoverRouters(state, rscEnv, ssrEnv) {
|
|
|
9180
9432
|
}
|
|
9181
9433
|
|
|
9182
9434
|
// src/vite/discovery/shell-prerender-phase.ts
|
|
9183
|
-
import { existsSync as
|
|
9184
|
-
import { join as
|
|
9435
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9436
|
+
import { join as join5, resolve as resolve9 } from "node:path";
|
|
9185
9437
|
|
|
9186
9438
|
// src/prerender/shell-manifest-key.ts
|
|
9187
9439
|
function buildShellManifestKey(pathname) {
|
|
@@ -9235,8 +9487,8 @@ async function runShellPrerenderPhase(s, builder) {
|
|
|
9235
9487
|
"@rangojs/router/internal/deps/html-stream-server"
|
|
9236
9488
|
);
|
|
9237
9489
|
const clientOutDir = builder?.environments?.client?.config?.build?.outDir ?? resolve9(s.projectRoot, "dist/client");
|
|
9238
|
-
const clientAssetsDir =
|
|
9239
|
-
const entryFile =
|
|
9490
|
+
const clientAssetsDir = join5(clientOutDir, "assets");
|
|
9491
|
+
const entryFile = existsSync8(clientAssetsDir) ? readdirSync3(clientAssetsDir).find((f) => /^index-.*\.js$/.test(f)) : void 0;
|
|
9240
9492
|
if (!entryFile) {
|
|
9241
9493
|
console.warn(
|
|
9242
9494
|
`[rango] shell prerender: built client entry not found under ${clientAssetsDir}; skipping \u2014 routes keep runtime shell capture.`
|
|
@@ -9403,7 +9655,7 @@ async function runShellPrerenderPhase(s, builder) {
|
|
|
9403
9655
|
}
|
|
9404
9656
|
function writeShellManifest(s, rscOutDir, staged) {
|
|
9405
9657
|
const rscEntryPath = resolve9(rscOutDir, s.rscEntryFileName ?? "index.js");
|
|
9406
|
-
if (!
|
|
9658
|
+
if (!existsSync8(rscEntryPath)) {
|
|
9407
9659
|
console.warn(
|
|
9408
9660
|
`[rango] shell prerender: RSC entry not found at ${rscEntryPath}; entries not persisted \u2014 routes keep runtime capture.`
|
|
9409
9661
|
);
|
|
@@ -9429,7 +9681,7 @@ function writeShellManifest(s, rscOutDir, staged) {
|
|
|
9429
9681
|
].join("\n");
|
|
9430
9682
|
writeFileSync3(resolve9(rscOutDir, "__shell-manifest.js"), manifestCode);
|
|
9431
9683
|
totalBytes += Buffer.byteLength(manifestCode);
|
|
9432
|
-
const rscCode =
|
|
9684
|
+
const rscCode = readFileSync6(rscEntryPath, "utf-8");
|
|
9433
9685
|
if (!rscCode.includes("__shell-manifest.js")) {
|
|
9434
9686
|
const injection = `globalThis.__loadShellManifestModule = () => import("./__shell-manifest.js");
|
|
9435
9687
|
`;
|
|
@@ -9479,8 +9731,8 @@ function createDevPrerenderCache(maxEntriesPerRouter = MAX_ENTRIES_PER_ROUTER) {
|
|
|
9479
9731
|
}
|
|
9480
9732
|
|
|
9481
9733
|
// src/vite/discovery/route-types-writer.ts
|
|
9482
|
-
import { dirname as dirname3, join as
|
|
9483
|
-
import { readFileSync as
|
|
9734
|
+
import { dirname as dirname3, join as join6, resolve as resolve10 } from "node:path";
|
|
9735
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, existsSync as existsSync9, unlinkSync as unlinkSync2 } from "node:fs";
|
|
9484
9736
|
function filterUserNamedRoutes(manifest) {
|
|
9485
9737
|
const filtered = {};
|
|
9486
9738
|
for (const [name, pattern] of Object.entries(manifest)) {
|
|
@@ -9491,7 +9743,7 @@ function filterUserNamedRoutes(manifest) {
|
|
|
9491
9743
|
return filtered;
|
|
9492
9744
|
}
|
|
9493
9745
|
function writeGenFileIfChanged(state, outPath, source, opts) {
|
|
9494
|
-
const existing =
|
|
9746
|
+
const existing = existsSync9(outPath) ? readFileSync7(outPath, "utf-8") : null;
|
|
9495
9747
|
if (existing === source) return;
|
|
9496
9748
|
markSelfGenWrite(state, outPath, source);
|
|
9497
9749
|
writeFileSync4(outPath, source);
|
|
@@ -9511,8 +9763,8 @@ function writeRouteTypesFiles(state) {
|
|
|
9511
9763
|
const entryDir = dirname3(
|
|
9512
9764
|
resolve10(state.projectRoot, state.resolvedEntryPath)
|
|
9513
9765
|
);
|
|
9514
|
-
const oldCombinedPath =
|
|
9515
|
-
if (
|
|
9766
|
+
const oldCombinedPath = join6(entryDir, "named-routes.gen.ts");
|
|
9767
|
+
if (existsSync9(oldCombinedPath)) {
|
|
9516
9768
|
unlinkSync2(oldCombinedPath);
|
|
9517
9769
|
console.log(
|
|
9518
9770
|
`[rango] Removed stale combined route types: ${oldCombinedPath}`
|
|
@@ -9594,7 +9846,7 @@ function supplementGenFilesWithRuntimeRoutes(state) {
|
|
|
9594
9846
|
|
|
9595
9847
|
// src/vite/discovery/virtual-module-codegen.ts
|
|
9596
9848
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
9597
|
-
import { dirname as dirname4, basename, join as
|
|
9849
|
+
import { dirname as dirname4, basename, join as join7 } from "node:path";
|
|
9598
9850
|
var MANIFEST_EXTERNALIZE_THRESHOLD = 512 * 1024;
|
|
9599
9851
|
function devDiscoveryBootstrap(state) {
|
|
9600
9852
|
if (state.isBuildMode || state.opts?.preset !== "cloudflare" || state.devDiscoveryEpoch === void 0) {
|
|
@@ -9617,7 +9869,7 @@ function generateRoutesManifestModule(state) {
|
|
|
9617
9869
|
/\.(tsx?|jsx?)$/,
|
|
9618
9870
|
""
|
|
9619
9871
|
);
|
|
9620
|
-
const genPath =
|
|
9872
|
+
const genPath = join7(
|
|
9621
9873
|
routerDir,
|
|
9622
9874
|
`${routerBasename}.named-routes.gen.js`
|
|
9623
9875
|
).replaceAll("\\", "/");
|
|
@@ -9730,7 +9982,7 @@ function generatePerRouterModule(state, routerId) {
|
|
|
9730
9982
|
if (sourceFile) {
|
|
9731
9983
|
const routerDir = dirname4(sourceFile);
|
|
9732
9984
|
const routerBasename = basename(sourceFile).replace(/\.(tsx?|jsx?)$/, "");
|
|
9733
|
-
const genPath =
|
|
9985
|
+
const genPath = join7(
|
|
9734
9986
|
routerDir,
|
|
9735
9987
|
`${routerBasename}.named-routes.gen.js`
|
|
9736
9988
|
).replaceAll("\\", "/");
|
|
@@ -9744,10 +9996,10 @@ function generatePerRouterModule(state, routerId) {
|
|
|
9744
9996
|
const payloadJson = hasTrie || hasEntries ? JSON.stringify(payload) : "";
|
|
9745
9997
|
const useTextModule = state.isBuildMode && preset === "cloudflare" && override !== "0" && (hasTrie || hasEntries) && (override === "1" || payloadJson.length >= MANIFEST_EXTERNALIZE_THRESHOLD);
|
|
9746
9998
|
if (useTextModule) {
|
|
9747
|
-
const dir =
|
|
9999
|
+
const dir = join7(state.projectRoot, "node_modules", ".rango");
|
|
9748
10000
|
mkdirSync2(dir, { recursive: true });
|
|
9749
10001
|
const safeId = `${routerId.replace(/[^a-zA-Z0-9_-]/g, "_")}-${shortHash(routerId)}`;
|
|
9750
|
-
const filePath =
|
|
10002
|
+
const filePath = join7(dir, `manifest-${safeId}.txt`).replaceAll("\\", "/");
|
|
9751
10003
|
writeFileSync5(filePath, payloadJson);
|
|
9752
10004
|
lines.push(`import __manifestJson from ${JSON.stringify(filePath)};`);
|
|
9753
10005
|
lines.push(`const __manifestData = JSON.parse(__manifestJson);`);
|
|
@@ -9778,7 +10030,7 @@ function emitManifestExports(lines, hasTrie, hasEntries) {
|
|
|
9778
10030
|
|
|
9779
10031
|
// src/vite/discovery/bundle-postprocess.ts
|
|
9780
10032
|
import { resolve as resolve11 } from "node:path";
|
|
9781
|
-
import { readFileSync as
|
|
10033
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, existsSync as existsSync10 } from "node:fs";
|
|
9782
10034
|
function postprocessBundle(state) {
|
|
9783
10035
|
const hasPrerenderData = state.prerenderManifestEntries && Object.keys(state.prerenderManifestEntries).length > 0;
|
|
9784
10036
|
const hasStaticData = state.staticManifestEntries && Object.keys(state.staticManifestEntries).length > 0;
|
|
@@ -9806,7 +10058,7 @@ function postprocessBundle(state) {
|
|
|
9806
10058
|
for (const info of target.infos) {
|
|
9807
10059
|
const chunkPath = resolve11(state.projectRoot, "dist/rsc", info.fileName);
|
|
9808
10060
|
try {
|
|
9809
|
-
const code =
|
|
10061
|
+
const code = readFileSync8(chunkPath, "utf-8");
|
|
9810
10062
|
const result = evictHandlerCode(
|
|
9811
10063
|
code,
|
|
9812
10064
|
info.exports,
|
|
@@ -9829,8 +10081,8 @@ function postprocessBundle(state) {
|
|
|
9829
10081
|
}
|
|
9830
10082
|
state.handlerChunkInfoMap.clear();
|
|
9831
10083
|
state.staticHandlerChunkInfoMap.clear();
|
|
9832
|
-
if (hasPrerenderData &&
|
|
9833
|
-
const rscCode =
|
|
10084
|
+
if (hasPrerenderData && existsSync10(rscEntryPath)) {
|
|
10085
|
+
const rscCode = readFileSync8(rscEntryPath, "utf-8");
|
|
9834
10086
|
if (!rscCode.includes("__prerender-manifest.js")) {
|
|
9835
10087
|
try {
|
|
9836
10088
|
let totalBytes = copyStagedBuildAssets(
|
|
@@ -9869,8 +10121,8 @@ function postprocessBundle(state) {
|
|
|
9869
10121
|
}
|
|
9870
10122
|
}
|
|
9871
10123
|
}
|
|
9872
|
-
if (hasStaticData &&
|
|
9873
|
-
const rscCode =
|
|
10124
|
+
if (hasStaticData && existsSync10(rscEntryPath)) {
|
|
10125
|
+
const rscCode = readFileSync8(rscEntryPath, "utf-8");
|
|
9874
10126
|
if (!rscCode.includes("__static-manifest.js")) {
|
|
9875
10127
|
try {
|
|
9876
10128
|
const manifestEntries = [];
|
|
@@ -11165,7 +11417,7 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
|
|
|
11165
11417
|
}
|
|
11166
11418
|
const inRecoveryMode = !!s.lastDiscoveryError;
|
|
11167
11419
|
try {
|
|
11168
|
-
const source =
|
|
11420
|
+
const source = readFileSync9(filePath, "utf-8");
|
|
11169
11421
|
const trimmed = source.trimStart();
|
|
11170
11422
|
const isUseClient = trimmed.startsWith('"use client"') || trimmed.startsWith("'use client'");
|
|
11171
11423
|
let hasClientUrls = source.includes("clientUrls(");
|
|
@@ -11725,7 +11977,7 @@ async function rango(options) {
|
|
|
11725
11977
|
routerRef.path = normalizeHostRouterEntry(
|
|
11726
11978
|
explicitHostRouter,
|
|
11727
11979
|
root,
|
|
11728
|
-
|
|
11980
|
+
existsSync11
|
|
11729
11981
|
);
|
|
11730
11982
|
routerRef.kind = "host";
|
|
11731
11983
|
return;
|
|
@@ -11915,7 +12167,7 @@ If this is a multi-app host router, export a createHostRouter() instance and set
|
|
|
11915
12167
|
if (!file.endsWith(".tsx") && !file.endsWith(".ts") && !file.endsWith(".jsx") && !file.endsWith(".js"))
|
|
11916
12168
|
return;
|
|
11917
12169
|
try {
|
|
11918
|
-
const source =
|
|
12170
|
+
const source = readFileSync10(file, "utf-8");
|
|
11919
12171
|
if (hasUseClientDirective(source)) {
|
|
11920
12172
|
return [];
|
|
11921
12173
|
}
|