@teyik0/furin 0.1.0-alpha.11 → 0.1.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/build/compile-entry.ts +129 -0
- package/dist/build/entry-template.ts +133 -0
- package/dist/build/index.js +453 -282
- package/dist/build/server-routes-entry.ts +55 -0
- package/dist/cli/index.js +457 -286
- package/dist/env.d.ts +50 -0
- package/dist/furin.js +402 -263
- package/dist/internal.js +17 -0
- package/dist/link.d.ts +5 -438
- package/dist/link.js +228 -137
- package/dist/plugin/index.js +9 -7
- package/dist/render/cache.d.ts +18 -5
- package/dist/render/dev-cache.d.ts +29 -0
- package/dist/render/index.ts +870 -0
- package/dist/render/route-cache.d.ts +26 -0
- package/dist/render/shell.ts +187 -0
- package/dist/router-provider.d.ts +467 -0
- package/dist/router.js +515 -368
- package/dist/router.ts +1034 -0
- package/dist/runtime-env.js +10 -0
- package/package.json +47 -17
- package/src/adapter/bun.ts +4 -1
- package/src/build/entry-template.ts +13 -6
- package/src/build/hydrate.ts +7 -5
- package/src/build/scan-server.ts +32 -3
- package/src/dev-page-plugin.ts +6 -0
- package/src/link.tsx +43 -1297
- package/src/plugin/transform-client.ts +10 -8
- package/src/render/cache.ts +77 -67
- package/src/render/dev-cache.ts +106 -15
- package/src/render/index.ts +4 -3
- package/src/render/route-cache.ts +124 -0
- package/src/router-provider.tsx +1428 -0
package/dist/router.js
CHANGED
|
@@ -146,77 +146,12 @@ function assembleHTML(template, headData, reactHtml, data) {
|
|
|
146
146
|
|
|
147
147
|
// src/render/dev-cache.ts
|
|
148
148
|
import { statSync } from "fs";
|
|
149
|
-
var devISRLoaderCache = new Map;
|
|
150
|
-
var devSSGLoaderCache = new Map;
|
|
151
|
-
var sourceFileToCacheKeys = new Map;
|
|
152
|
-
var isrHandle = { cache: devISRLoaderCache, kind: "isr" };
|
|
153
|
-
var ssgHandle = { cache: devSSGLoaderCache, kind: "ssg" };
|
|
154
|
-
function indexEntryDependencies(cacheKey, deps) {
|
|
155
|
-
for (const dep of deps) {
|
|
156
|
-
let bucket = sourceFileToCacheKeys.get(dep);
|
|
157
|
-
if (!bucket) {
|
|
158
|
-
bucket = new Set;
|
|
159
|
-
sourceFileToCacheKeys.set(dep, bucket);
|
|
160
|
-
}
|
|
161
|
-
bucket.add(cacheKey);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function unindexEntryDependencies(cacheKey, deps) {
|
|
165
|
-
for (const dep of deps) {
|
|
166
|
-
const bucket = sourceFileToCacheKeys.get(dep);
|
|
167
|
-
if (!bucket) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
bucket.delete(cacheKey);
|
|
171
|
-
if (bucket.size === 0) {
|
|
172
|
-
sourceFileToCacheKeys.delete(dep);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function setEntry(handle, key, entry) {
|
|
177
|
-
const previous = handle.cache.get(key);
|
|
178
|
-
if (previous) {
|
|
179
|
-
unindexEntryDependencies(key, previous.dependencies);
|
|
180
|
-
}
|
|
181
|
-
handle.cache.set(key, entry);
|
|
182
|
-
indexEntryDependencies(key, entry.dependencies);
|
|
183
|
-
}
|
|
184
|
-
function getDevISRLoaderCache(key) {
|
|
185
|
-
return devISRLoaderCache.get(key);
|
|
186
|
-
}
|
|
187
|
-
function setDevISRLoaderCache(key, entry) {
|
|
188
|
-
setEntry(isrHandle, key, entry);
|
|
189
|
-
}
|
|
190
|
-
function getDevSSGLoaderCache(key) {
|
|
191
|
-
return devSSGLoaderCache.get(key);
|
|
192
|
-
}
|
|
193
|
-
function setDevSSGLoaderCache(key, entry) {
|
|
194
|
-
setEntry(ssgHandle, key, entry);
|
|
195
|
-
}
|
|
196
|
-
function isDevLoaderCacheFresh(entry) {
|
|
197
|
-
return Date.now() - entry.generatedAt < entry.revalidate * 1000;
|
|
198
|
-
}
|
|
199
|
-
function isDevLoaderCacheValid(entry) {
|
|
200
|
-
if (!isDevLoaderCacheFresh(entry)) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
for (const dep of entry.dependencies) {
|
|
204
|
-
let mtimeMs;
|
|
205
|
-
try {
|
|
206
|
-
mtimeMs = statSync(dep).mtimeMs;
|
|
207
|
-
} catch {
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
if (mtimeMs > entry.generatedAt) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
149
|
|
|
217
|
-
// src/render/
|
|
218
|
-
import {
|
|
219
|
-
|
|
150
|
+
// src/render/cache.ts
|
|
151
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
152
|
+
|
|
153
|
+
// src/context-logger.ts
|
|
154
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
220
155
|
|
|
221
156
|
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/utils.mjs
|
|
222
157
|
function formatDuration(ms) {
|
|
@@ -1123,30 +1058,281 @@ function finalizeAudit(event) {
|
|
|
1123
1058
|
return;
|
|
1124
1059
|
event.audit = decorateAudit(a, String(event.timestamp));
|
|
1125
1060
|
}
|
|
1126
|
-
//
|
|
1127
|
-
import {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
}
|
|
1061
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/elysia/index.mjs
|
|
1062
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
1063
|
+
import { Elysia } from "elysia";
|
|
1064
|
+
var storage = new AsyncLocalStorage;
|
|
1065
|
+
var activeLoggers = /* @__PURE__ */ new WeakSet;
|
|
1066
|
+
function useLogger2() {
|
|
1067
|
+
const logger = storage.getStore();
|
|
1068
|
+
if (!logger || !activeLoggers.has(logger))
|
|
1069
|
+
throw new Error("[evlog] useLogger() was called outside of an evlog plugin context. Make sure app.use(evlog()) is registered before your routes.");
|
|
1070
|
+
return logger;
|
|
1071
|
+
}
|
|
1137
1072
|
|
|
1138
|
-
// src/
|
|
1139
|
-
|
|
1073
|
+
// src/context-logger.ts
|
|
1074
|
+
var noopLogger2 = {
|
|
1075
|
+
set: () => {},
|
|
1076
|
+
error: () => {},
|
|
1077
|
+
info: () => {},
|
|
1078
|
+
warn: () => {},
|
|
1079
|
+
emit: () => null,
|
|
1080
|
+
getContext: () => ({}),
|
|
1081
|
+
fork: (_label, fn) => fn()
|
|
1082
|
+
};
|
|
1083
|
+
var syntheticRenderStorage = new AsyncLocalStorage2;
|
|
1084
|
+
function useLogger3() {
|
|
1085
|
+
try {
|
|
1086
|
+
return useLogger2();
|
|
1087
|
+
} catch {
|
|
1088
|
+
return syntheticRenderStorage.getStore() ?? noopLogger2;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
async function runInSyntheticRenderScope(fn, initialContext) {
|
|
1092
|
+
const logger = createLogger(initialContext);
|
|
1093
|
+
try {
|
|
1094
|
+
const result = await syntheticRenderStorage.run(logger, () => Promise.resolve(fn()));
|
|
1095
|
+
logger.emit();
|
|
1096
|
+
return result;
|
|
1097
|
+
} catch (err) {
|
|
1098
|
+
logger.error(err instanceof Error ? err : new Error(String(err)));
|
|
1099
|
+
logger.emit();
|
|
1100
|
+
throw err;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1140
1103
|
|
|
1141
|
-
// src/
|
|
1142
|
-
function
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1104
|
+
// src/render/route-cache.ts
|
|
1105
|
+
function defaultPathFromKey(key) {
|
|
1106
|
+
return key;
|
|
1107
|
+
}
|
|
1108
|
+
function matchesPath(urlPath, path, type) {
|
|
1109
|
+
if (type === "page") {
|
|
1110
|
+
return urlPath === path;
|
|
1111
|
+
}
|
|
1112
|
+
const prefix = path === "/" || path.endsWith("/") ? path : `${path}/`;
|
|
1113
|
+
return urlPath === path || urlPath.startsWith(prefix);
|
|
1114
|
+
}
|
|
1115
|
+
function createRouteCache(options) {
|
|
1116
|
+
const store = new Map;
|
|
1117
|
+
const pathFromKey = options.pathFromKey ?? defaultPathFromKey;
|
|
1118
|
+
const evictOldest = () => {
|
|
1119
|
+
if (options.maxSize === undefined || store.size <= options.maxSize) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
const oldest = store.keys().next().value;
|
|
1123
|
+
if (oldest !== undefined) {
|
|
1124
|
+
deleteEntry(oldest);
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
const deleteEntry = (key) => {
|
|
1128
|
+
const entry = store.get(key);
|
|
1129
|
+
if (entry === undefined) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
store.delete(key);
|
|
1133
|
+
options.onDelete?.(key, entry);
|
|
1134
|
+
return true;
|
|
1135
|
+
};
|
|
1136
|
+
return {
|
|
1137
|
+
name: options.name,
|
|
1138
|
+
store,
|
|
1139
|
+
get size() {
|
|
1140
|
+
return store.size;
|
|
1141
|
+
},
|
|
1142
|
+
get(key) {
|
|
1143
|
+
const entry = store.get(key);
|
|
1144
|
+
if (entry !== undefined && options.maxSize !== undefined) {
|
|
1145
|
+
store.delete(key);
|
|
1146
|
+
store.set(key, entry);
|
|
1147
|
+
}
|
|
1148
|
+
return entry;
|
|
1149
|
+
},
|
|
1150
|
+
set(key, entry) {
|
|
1151
|
+
const previous = store.get(key);
|
|
1152
|
+
if (previous !== undefined) {
|
|
1153
|
+
store.delete(key);
|
|
1154
|
+
}
|
|
1155
|
+
store.set(key, entry);
|
|
1156
|
+
options.onSet?.(key, entry, previous);
|
|
1157
|
+
evictOldest();
|
|
1158
|
+
},
|
|
1159
|
+
delete(key) {
|
|
1160
|
+
return deleteEntry(key);
|
|
1161
|
+
},
|
|
1162
|
+
clear() {
|
|
1163
|
+
for (const key of [...store.keys()]) {
|
|
1164
|
+
deleteEntry(key);
|
|
1165
|
+
}
|
|
1166
|
+
store.clear();
|
|
1167
|
+
},
|
|
1168
|
+
has(key) {
|
|
1169
|
+
return store.has(key);
|
|
1170
|
+
},
|
|
1171
|
+
entries() {
|
|
1172
|
+
return store.entries();
|
|
1173
|
+
},
|
|
1174
|
+
keys() {
|
|
1175
|
+
return store.keys();
|
|
1176
|
+
},
|
|
1177
|
+
invalidatePath(path, type) {
|
|
1178
|
+
let deleted = false;
|
|
1179
|
+
const purgedPaths = [];
|
|
1180
|
+
for (const key of [...store.keys()]) {
|
|
1181
|
+
const urlPath = pathFromKey(key);
|
|
1182
|
+
if (urlPath === null || !matchesPath(urlPath, path, type)) {
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1185
|
+
deleteEntry(key);
|
|
1186
|
+
deleted = true;
|
|
1187
|
+
purgedPaths.push(urlPath);
|
|
1188
|
+
}
|
|
1189
|
+
return { deleted, purgedPaths: [...new Set(purgedPaths)] };
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// src/render/cache.ts
|
|
1195
|
+
var MAX_ISR_CACHE_SIZE = 1000;
|
|
1196
|
+
var MAX_SSG_CACHE_SIZE = 1000;
|
|
1197
|
+
var isrRouteCache = createRouteCache({
|
|
1198
|
+
maxSize: MAX_ISR_CACHE_SIZE,
|
|
1199
|
+
name: "render:isr-html"
|
|
1200
|
+
});
|
|
1201
|
+
var ssgRouteCache = createRouteCache({
|
|
1202
|
+
maxSize: MAX_SSG_CACHE_SIZE,
|
|
1203
|
+
name: "render:ssg-html"
|
|
1204
|
+
});
|
|
1205
|
+
var isrCache = isrRouteCache.store;
|
|
1206
|
+
var ssgCache = ssgRouteCache.store;
|
|
1207
|
+
function getISRCache(key) {
|
|
1208
|
+
return isrRouteCache.get(key);
|
|
1209
|
+
}
|
|
1210
|
+
function getSSGCache(key) {
|
|
1211
|
+
return ssgRouteCache.get(key);
|
|
1212
|
+
}
|
|
1213
|
+
function setISRCache(key, entry) {
|
|
1214
|
+
isrRouteCache.set(key, entry);
|
|
1215
|
+
}
|
|
1216
|
+
function setSSGCache(key, entry) {
|
|
1217
|
+
ssgRouteCache.set(key, entry);
|
|
1218
|
+
}
|
|
1219
|
+
var _requestInvalidationScope = new AsyncLocalStorage3;
|
|
1220
|
+
var _globalPendingInvalidations = new Set;
|
|
1221
|
+
var _cacheInvalidators = new Map;
|
|
1222
|
+
function registerCacheInvalidator(invalidator) {
|
|
1223
|
+
const existing = _cacheInvalidators.get(invalidator.name);
|
|
1224
|
+
if (existing !== undefined && existing !== invalidator) {
|
|
1225
|
+
throw new Error(`Cache invalidator "${invalidator.name}" is already registered with a different instance.`);
|
|
1226
|
+
}
|
|
1227
|
+
if (existing === invalidator) {
|
|
1228
|
+
return () => {
|
|
1229
|
+
if (_cacheInvalidators.get(invalidator.name) === invalidator) {
|
|
1230
|
+
_cacheInvalidators.delete(invalidator.name);
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1146
1233
|
}
|
|
1147
|
-
|
|
1234
|
+
_cacheInvalidators.set(invalidator.name, invalidator);
|
|
1235
|
+
return () => {
|
|
1236
|
+
if (_cacheInvalidators.get(invalidator.name) === invalidator) {
|
|
1237
|
+
_cacheInvalidators.delete(invalidator.name);
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
registerCacheInvalidator(isrRouteCache);
|
|
1242
|
+
registerCacheInvalidator(ssgRouteCache);
|
|
1243
|
+
|
|
1244
|
+
// src/render/dev-cache.ts
|
|
1245
|
+
var sourceFileToCacheKeys = new Map;
|
|
1246
|
+
function indexEntryDependencies(cacheKey, deps) {
|
|
1247
|
+
for (const dep of deps) {
|
|
1248
|
+
let bucket = sourceFileToCacheKeys.get(dep);
|
|
1249
|
+
if (!bucket) {
|
|
1250
|
+
bucket = new Set;
|
|
1251
|
+
sourceFileToCacheKeys.set(dep, bucket);
|
|
1252
|
+
}
|
|
1253
|
+
bucket.add(cacheKey);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
function unindexEntryDependencies(cacheKey, deps) {
|
|
1257
|
+
for (const dep of deps) {
|
|
1258
|
+
const bucket = sourceFileToCacheKeys.get(dep);
|
|
1259
|
+
if (!bucket) {
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
bucket.delete(cacheKey);
|
|
1263
|
+
if (bucket.size === 0) {
|
|
1264
|
+
sourceFileToCacheKeys.delete(dep);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function createDevLoaderCache(name) {
|
|
1269
|
+
return createRouteCache({
|
|
1270
|
+
name,
|
|
1271
|
+
onDelete: (key, entry) => {
|
|
1272
|
+
unindexEntryDependencies(key, entry.dependencies);
|
|
1273
|
+
},
|
|
1274
|
+
onSet: (key, entry, previous) => {
|
|
1275
|
+
if (previous) {
|
|
1276
|
+
unindexEntryDependencies(key, previous.dependencies);
|
|
1277
|
+
}
|
|
1278
|
+
indexEntryDependencies(key, entry.dependencies);
|
|
1279
|
+
},
|
|
1280
|
+
pathFromKey: urlPathFromCacheKey
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
var devISRLoaderCache = createDevLoaderCache("render:dev-isr-loader");
|
|
1284
|
+
var devSSGLoaderCache = createDevLoaderCache("render:dev-ssg-loader");
|
|
1285
|
+
var isrHandle = { cache: devISRLoaderCache, kind: "isr" };
|
|
1286
|
+
var ssgHandle = { cache: devSSGLoaderCache, kind: "ssg" };
|
|
1287
|
+
function setEntry(handle, key, entry) {
|
|
1288
|
+
handle.cache.set(key, entry);
|
|
1289
|
+
}
|
|
1290
|
+
function getDevISRLoaderCache(key) {
|
|
1291
|
+
return devISRLoaderCache.get(key);
|
|
1292
|
+
}
|
|
1293
|
+
function setDevISRLoaderCache(key, entry) {
|
|
1294
|
+
setEntry(isrHandle, key, entry);
|
|
1295
|
+
}
|
|
1296
|
+
function getDevSSGLoaderCache(key) {
|
|
1297
|
+
return devSSGLoaderCache.get(key);
|
|
1298
|
+
}
|
|
1299
|
+
function setDevSSGLoaderCache(key, entry) {
|
|
1300
|
+
setEntry(ssgHandle, key, entry);
|
|
1301
|
+
}
|
|
1302
|
+
function urlPathFromCacheKey(key) {
|
|
1303
|
+
const sep = key.lastIndexOf(":/");
|
|
1304
|
+
if (sep === -1) {
|
|
1305
|
+
return null;
|
|
1306
|
+
}
|
|
1307
|
+
return key.slice(sep + 1);
|
|
1308
|
+
}
|
|
1309
|
+
registerCacheInvalidator(devISRLoaderCache);
|
|
1310
|
+
registerCacheInvalidator(devSSGLoaderCache);
|
|
1311
|
+
function isDevLoaderCacheFresh(entry) {
|
|
1312
|
+
return Date.now() - entry.generatedAt < entry.revalidate * 1000;
|
|
1313
|
+
}
|
|
1314
|
+
function isDevLoaderCacheValid(entry) {
|
|
1315
|
+
if (!isDevLoaderCacheFresh(entry)) {
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1318
|
+
for (const dep of entry.dependencies) {
|
|
1319
|
+
let mtimeMs;
|
|
1320
|
+
try {
|
|
1321
|
+
mtimeMs = statSync(dep).mtimeMs;
|
|
1322
|
+
} catch {
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1325
|
+
if (mtimeMs > entry.generatedAt) {
|
|
1326
|
+
return false;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return true;
|
|
1148
1330
|
}
|
|
1149
1331
|
|
|
1332
|
+
// src/render/index.ts
|
|
1333
|
+
import { createElement as createElement3 } from "react";
|
|
1334
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
1335
|
+
|
|
1150
1336
|
// src/not-found.ts
|
|
1151
1337
|
var NOT_FOUND_BRAND = "FURIN_NOT_FOUND";
|
|
1152
1338
|
|
|
@@ -1162,21 +1348,235 @@ function isNotFoundError(err) {
|
|
|
1162
1348
|
return err instanceof FurinNotFoundError || typeof err === "object" && err !== null && err.__furinBrand === NOT_FOUND_BRAND;
|
|
1163
1349
|
}
|
|
1164
1350
|
|
|
1165
|
-
// src/
|
|
1166
|
-
import {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1351
|
+
// src/router-provider.tsx
|
|
1352
|
+
import {
|
|
1353
|
+
createContext,
|
|
1354
|
+
createElement as createElement2,
|
|
1355
|
+
useCallback as useCallback2,
|
|
1356
|
+
useContext,
|
|
1357
|
+
useEffect as useEffect2,
|
|
1358
|
+
useLayoutEffect,
|
|
1359
|
+
useMemo,
|
|
1360
|
+
useRef as useRef2,
|
|
1361
|
+
useState
|
|
1362
|
+
} from "react";
|
|
1363
|
+
|
|
1364
|
+
// src/render/boundaries.tsx
|
|
1365
|
+
import { Component, Fragment } from "react";
|
|
1366
|
+
|
|
1367
|
+
// src/error.ts
|
|
1368
|
+
function getPublicErrorMessage(error) {
|
|
1369
|
+
const branded = error;
|
|
1370
|
+
if (branded?.__furinBrand === "FURIN_NOT_FOUND") {
|
|
1371
|
+
return error.message;
|
|
1372
|
+
}
|
|
1373
|
+
return "Something went wrong";
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// src/link.tsx
|
|
1377
|
+
import { createElement, useCallback, useEffect, useRef } from "react";
|
|
1378
|
+
function computeLinkView({
|
|
1379
|
+
to,
|
|
1380
|
+
search,
|
|
1381
|
+
hash,
|
|
1382
|
+
children,
|
|
1383
|
+
activeProps,
|
|
1384
|
+
inactiveProps
|
|
1385
|
+
}, router) {
|
|
1386
|
+
const logicalHref = buildHref(to, search, hash);
|
|
1387
|
+
const logicalHrefWithoutHash = buildHref(to, search, undefined);
|
|
1388
|
+
const isAbsolute = logicalHref.startsWith("http://") || logicalHref.startsWith("https://") || logicalHref.startsWith("//");
|
|
1389
|
+
const href = isAbsolute ? logicalHref : router.basePath + logicalHref;
|
|
1390
|
+
const isActive = !isAbsolute && router.currentHref === normalizeHref(logicalHrefWithoutHash);
|
|
1391
|
+
const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
|
|
1392
|
+
const extraProps = {
|
|
1393
|
+
...inactiveProps && !isActive ? inactiveProps() : {},
|
|
1394
|
+
...activeProps ? activeProps({ isActive }) : {}
|
|
1395
|
+
};
|
|
1396
|
+
return { logicalHref, href, isActive, resolvedChildren, extraProps };
|
|
1397
|
+
}
|
|
1398
|
+
function LinkInteractive({
|
|
1399
|
+
to,
|
|
1400
|
+
search,
|
|
1401
|
+
hash,
|
|
1402
|
+
preload,
|
|
1403
|
+
preloadDelay,
|
|
1404
|
+
preloadStaleTime,
|
|
1405
|
+
replace,
|
|
1406
|
+
disabled,
|
|
1407
|
+
resetScroll,
|
|
1408
|
+
activeProps,
|
|
1409
|
+
inactiveProps,
|
|
1410
|
+
onClick,
|
|
1411
|
+
onMouseEnter,
|
|
1412
|
+
onMouseLeave,
|
|
1413
|
+
onFocus,
|
|
1414
|
+
children,
|
|
1415
|
+
href: _href,
|
|
1416
|
+
...anchorProps
|
|
1417
|
+
}) {
|
|
1418
|
+
const router = useRouter();
|
|
1419
|
+
const anchorRef = useRef(null);
|
|
1420
|
+
const intentTimerRef = useRef(null);
|
|
1421
|
+
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ to, search, hash, children, activeProps, inactiveProps }, router);
|
|
1422
|
+
const effectivePreload = preload ?? router.defaultPreload;
|
|
1423
|
+
const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
|
|
1424
|
+
const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
|
|
1425
|
+
const triggerPrefetch = useCallback(() => {
|
|
1426
|
+
router.prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
1427
|
+
}, [router, logicalHref, effectiveStaleTime]);
|
|
1428
|
+
useEffect(() => {
|
|
1429
|
+
if (effectivePreload === "render") {
|
|
1430
|
+
triggerPrefetch();
|
|
1431
|
+
}
|
|
1432
|
+
}, [effectivePreload, triggerPrefetch]);
|
|
1433
|
+
useEffect(() => {
|
|
1434
|
+
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
1438
|
+
if (entry?.isIntersecting) {
|
|
1439
|
+
triggerPrefetch();
|
|
1440
|
+
observer.disconnect();
|
|
1441
|
+
}
|
|
1442
|
+
}, { rootMargin: "200px" });
|
|
1443
|
+
observer.observe(anchorRef.current);
|
|
1444
|
+
return () => observer.disconnect();
|
|
1445
|
+
}, [effectivePreload, triggerPrefetch]);
|
|
1446
|
+
useEffect(() => () => {
|
|
1447
|
+
if (intentTimerRef.current !== null) {
|
|
1448
|
+
clearTimeout(intentTimerRef.current);
|
|
1449
|
+
intentTimerRef.current = null;
|
|
1450
|
+
}
|
|
1451
|
+
}, []);
|
|
1452
|
+
const isInternal = (url) => {
|
|
1453
|
+
try {
|
|
1454
|
+
return new URL(url, window.location.origin).origin === window.location.origin;
|
|
1455
|
+
} catch {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
const handleClick = (e) => {
|
|
1460
|
+
onClick?.(e);
|
|
1461
|
+
if (e.defaultPrevented) {
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (disabled) {
|
|
1465
|
+
e.preventDefault();
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
if (anchorProps.target && anchorProps.target !== "_self") {
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
if (!isInternal(href)) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
e.preventDefault();
|
|
1478
|
+
router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
|
|
1479
|
+
};
|
|
1480
|
+
const handleMouseEnter = (e) => {
|
|
1481
|
+
onMouseEnter?.(e);
|
|
1482
|
+
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
1483
|
+
intentTimerRef.current = setTimeout(triggerPrefetch, effectiveDelay);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
const handleMouseLeave = (e) => {
|
|
1487
|
+
onMouseLeave?.(e);
|
|
1488
|
+
if (intentTimerRef.current !== null) {
|
|
1489
|
+
clearTimeout(intentTimerRef.current);
|
|
1490
|
+
intentTimerRef.current = null;
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
const handleFocus = (e) => {
|
|
1494
|
+
onFocus?.(e);
|
|
1495
|
+
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
1496
|
+
triggerPrefetch();
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
return createElement("a", {
|
|
1500
|
+
ref: anchorRef,
|
|
1501
|
+
href,
|
|
1502
|
+
"data-furin-link": true,
|
|
1503
|
+
onClick: handleClick,
|
|
1504
|
+
onMouseEnter: handleMouseEnter,
|
|
1505
|
+
onMouseLeave: handleMouseLeave,
|
|
1506
|
+
onFocus: handleFocus,
|
|
1507
|
+
...isActive ? { "data-status": "active" } : {},
|
|
1508
|
+
...anchorProps,
|
|
1509
|
+
...extraProps,
|
|
1510
|
+
...disabled ? { "aria-disabled": true } : {}
|
|
1511
|
+
}, resolvedChildren);
|
|
1512
|
+
}
|
|
1513
|
+
var SSR_FALLBACK_ROUTER = {
|
|
1514
|
+
basePath: "",
|
|
1515
|
+
currentHref: "/",
|
|
1516
|
+
navigate: () => Promise.resolve(),
|
|
1517
|
+
prefetch: () => {},
|
|
1518
|
+
invalidatePrefetch: () => {},
|
|
1519
|
+
refresh: () => Promise.resolve(),
|
|
1520
|
+
isNavigating: false,
|
|
1521
|
+
defaultPreload: "intent",
|
|
1522
|
+
defaultPreloadDelay: 50,
|
|
1523
|
+
defaultPreloadStaleTime: 30000
|
|
1524
|
+
};
|
|
1525
|
+
function renderLinkElement(props, router) {
|
|
1526
|
+
const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router);
|
|
1527
|
+
const {
|
|
1528
|
+
to: _to,
|
|
1529
|
+
search: _search,
|
|
1530
|
+
hash: _hash,
|
|
1531
|
+
children: _children,
|
|
1532
|
+
activeProps: _ap,
|
|
1533
|
+
inactiveProps: _ip,
|
|
1534
|
+
disabled,
|
|
1535
|
+
preload: _p,
|
|
1536
|
+
preloadDelay: _pd,
|
|
1537
|
+
preloadStaleTime: _ps,
|
|
1538
|
+
replace: _r,
|
|
1539
|
+
resetScroll: _rs,
|
|
1540
|
+
onClick: _oc,
|
|
1541
|
+
onMouseEnter: _ome,
|
|
1542
|
+
onMouseLeave: _oml,
|
|
1543
|
+
onFocus: _of,
|
|
1544
|
+
href: _href,
|
|
1545
|
+
...anchorProps
|
|
1546
|
+
} = props;
|
|
1547
|
+
return createElement("a", {
|
|
1548
|
+
href,
|
|
1549
|
+
"data-furin-link": true,
|
|
1550
|
+
...isActive ? { "data-status": "active" } : {},
|
|
1551
|
+
...anchorProps,
|
|
1552
|
+
...extraProps,
|
|
1553
|
+
...disabled ? { "aria-disabled": true } : {}
|
|
1554
|
+
}, resolvedChildren);
|
|
1555
|
+
}
|
|
1556
|
+
function Link(props) {
|
|
1557
|
+
if (typeof window === "undefined") {
|
|
1558
|
+
return createElement(RouterContext.Consumer, {
|
|
1559
|
+
children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
return createElement(LinkInteractive, props);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// src/render/default-screens.tsx
|
|
1566
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
1567
|
+
var FONT_SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
|
|
1568
|
+
var FONT_MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace';
|
|
1569
|
+
var COLOR_BG = "#000000";
|
|
1570
|
+
var COLOR_TEXT = "#ffffff";
|
|
1571
|
+
var COLOR_TEXT_DIM = "rgba(255, 255, 255, 0.7)";
|
|
1572
|
+
var COLOR_TEXT_MUTED = "rgba(255, 255, 255, 0.45)";
|
|
1573
|
+
var COLOR_GRID = "rgba(255, 255, 255, 0.04)";
|
|
1574
|
+
var COLOR_BRACKET = "rgba(255, 255, 255, 0.55)";
|
|
1575
|
+
var COLOR_DANGER_DIM = "rgba(239, 68, 68, 0.6)";
|
|
1576
|
+
var PAGE_STYLE = {
|
|
1577
|
+
alignItems: "center",
|
|
1578
|
+
backgroundColor: COLOR_BG,
|
|
1579
|
+
backgroundImage: `
|
|
1180
1580
|
linear-gradient(${COLOR_GRID} 1px, transparent 1px),
|
|
1181
1581
|
linear-gradient(90deg, ${COLOR_GRID} 1px, transparent 1px)
|
|
1182
1582
|
`,
|
|
@@ -1547,7 +1947,7 @@ class FurinNotFoundBoundary extends Component {
|
|
|
1547
1947
|
}
|
|
1548
1948
|
}
|
|
1549
1949
|
|
|
1550
|
-
// src/
|
|
1950
|
+
// src/router-provider.tsx
|
|
1551
1951
|
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
1552
1952
|
function buildHref(to, search, hash) {
|
|
1553
1953
|
let url = to;
|
|
@@ -1570,7 +1970,8 @@ function buildHref(to, search, hash) {
|
|
|
1570
1970
|
}
|
|
1571
1971
|
var RouterContext = createContext(null);
|
|
1572
1972
|
function useRouter() {
|
|
1573
|
-
|
|
1973
|
+
const ctx = useContext(RouterContext);
|
|
1974
|
+
return ctx ?? {
|
|
1574
1975
|
basePath: "",
|
|
1575
1976
|
currentHref: "/",
|
|
1576
1977
|
navigate: (href) => {
|
|
@@ -1589,268 +1990,14 @@ function useRouter() {
|
|
|
1589
1990
|
defaultPreloadStaleTime: 30000
|
|
1590
1991
|
};
|
|
1591
1992
|
}
|
|
1592
|
-
function
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
activeProps,
|
|
1598
|
-
inactiveProps
|
|
1599
|
-
}, router) {
|
|
1600
|
-
const logicalHref = buildHref(to, search, hash);
|
|
1601
|
-
const logicalHrefWithoutHash = buildHref(to, search, undefined);
|
|
1602
|
-
const href = router.basePath + logicalHref;
|
|
1603
|
-
const isActive = router.currentHref === logicalHrefWithoutHash;
|
|
1604
|
-
const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
|
|
1605
|
-
const extraProps = {
|
|
1606
|
-
...inactiveProps && !isActive ? inactiveProps() : {},
|
|
1607
|
-
...activeProps ? activeProps({ isActive }) : {}
|
|
1608
|
-
};
|
|
1609
|
-
return { logicalHref, href, isActive, resolvedChildren, extraProps };
|
|
1610
|
-
}
|
|
1611
|
-
function LinkInteractive({
|
|
1612
|
-
to,
|
|
1613
|
-
search,
|
|
1614
|
-
hash,
|
|
1615
|
-
preload,
|
|
1616
|
-
preloadDelay,
|
|
1617
|
-
preloadStaleTime,
|
|
1618
|
-
replace,
|
|
1619
|
-
disabled,
|
|
1620
|
-
resetScroll,
|
|
1621
|
-
activeProps,
|
|
1622
|
-
inactiveProps,
|
|
1623
|
-
onClick,
|
|
1624
|
-
onMouseEnter,
|
|
1625
|
-
onMouseLeave,
|
|
1626
|
-
onFocus,
|
|
1627
|
-
children,
|
|
1628
|
-
...anchorProps
|
|
1629
|
-
}) {
|
|
1630
|
-
const router = useRouter();
|
|
1631
|
-
const anchorRef = useRef(null);
|
|
1632
|
-
const intentTimerRef = useRef(null);
|
|
1633
|
-
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ to, search, hash, children, activeProps, inactiveProps }, router);
|
|
1634
|
-
const effectivePreload = preload ?? router.defaultPreload;
|
|
1635
|
-
const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
|
|
1636
|
-
const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
|
|
1637
|
-
const triggerPrefetch = useCallback(() => {
|
|
1638
|
-
router.prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
1639
|
-
}, [router, logicalHref, effectiveStaleTime]);
|
|
1640
|
-
useEffect(() => {
|
|
1641
|
-
if (effectivePreload === "render") {
|
|
1642
|
-
triggerPrefetch();
|
|
1643
|
-
}
|
|
1644
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
1645
|
-
useEffect(() => {
|
|
1646
|
-
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
1647
|
-
return;
|
|
1648
|
-
}
|
|
1649
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
1650
|
-
if (entry?.isIntersecting) {
|
|
1651
|
-
triggerPrefetch();
|
|
1652
|
-
observer.disconnect();
|
|
1653
|
-
}
|
|
1654
|
-
}, { rootMargin: "200px" });
|
|
1655
|
-
observer.observe(anchorRef.current);
|
|
1656
|
-
return () => observer.disconnect();
|
|
1657
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
1658
|
-
const isInternal = (url) => {
|
|
1659
|
-
try {
|
|
1660
|
-
return new URL(url, window.location.origin).origin === window.location.origin;
|
|
1661
|
-
} catch {
|
|
1662
|
-
return false;
|
|
1663
|
-
}
|
|
1664
|
-
};
|
|
1665
|
-
const handleClick = (e) => {
|
|
1666
|
-
onClick?.(e);
|
|
1667
|
-
if (e.defaultPrevented || disabled) {
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
1671
|
-
return;
|
|
1672
|
-
}
|
|
1673
|
-
if (anchorProps.target && anchorProps.target !== "_self") {
|
|
1674
|
-
return;
|
|
1675
|
-
}
|
|
1676
|
-
if (!isInternal(href)) {
|
|
1677
|
-
return;
|
|
1678
|
-
}
|
|
1679
|
-
e.preventDefault();
|
|
1680
|
-
router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
|
|
1681
|
-
};
|
|
1682
|
-
const handleMouseEnter = (e) => {
|
|
1683
|
-
onMouseEnter?.(e);
|
|
1684
|
-
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
1685
|
-
intentTimerRef.current = setTimeout(triggerPrefetch, effectiveDelay);
|
|
1686
|
-
}
|
|
1687
|
-
};
|
|
1688
|
-
const handleMouseLeave = (e) => {
|
|
1689
|
-
onMouseLeave?.(e);
|
|
1690
|
-
if (intentTimerRef.current !== null) {
|
|
1691
|
-
clearTimeout(intentTimerRef.current);
|
|
1692
|
-
intentTimerRef.current = null;
|
|
1693
|
-
}
|
|
1694
|
-
};
|
|
1695
|
-
const handleFocus = (e) => {
|
|
1696
|
-
onFocus?.(e);
|
|
1697
|
-
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
1698
|
-
triggerPrefetch();
|
|
1699
|
-
}
|
|
1700
|
-
};
|
|
1701
|
-
return createElement("a", {
|
|
1702
|
-
ref: anchorRef,
|
|
1703
|
-
href,
|
|
1704
|
-
onClick: handleClick,
|
|
1705
|
-
onMouseEnter: handleMouseEnter,
|
|
1706
|
-
onMouseLeave: handleMouseLeave,
|
|
1707
|
-
onFocus: handleFocus,
|
|
1708
|
-
...isActive ? { "data-status": "active" } : {},
|
|
1709
|
-
...anchorProps,
|
|
1710
|
-
...extraProps,
|
|
1711
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
1712
|
-
}, resolvedChildren);
|
|
1713
|
-
}
|
|
1714
|
-
var SSR_FALLBACK_ROUTER = {
|
|
1715
|
-
basePath: "",
|
|
1716
|
-
currentHref: "/",
|
|
1717
|
-
navigate: () => Promise.resolve(),
|
|
1718
|
-
prefetch: () => {},
|
|
1719
|
-
invalidatePrefetch: () => {},
|
|
1720
|
-
refresh: () => Promise.resolve(),
|
|
1721
|
-
isNavigating: false,
|
|
1722
|
-
defaultPreload: "intent",
|
|
1723
|
-
defaultPreloadDelay: 50,
|
|
1724
|
-
defaultPreloadStaleTime: 30000
|
|
1725
|
-
};
|
|
1726
|
-
function renderLinkElement(props, router) {
|
|
1727
|
-
const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router);
|
|
1728
|
-
const {
|
|
1729
|
-
to: _to,
|
|
1730
|
-
search: _search,
|
|
1731
|
-
hash: _hash,
|
|
1732
|
-
children: _children,
|
|
1733
|
-
activeProps: _ap,
|
|
1734
|
-
inactiveProps: _ip,
|
|
1735
|
-
disabled,
|
|
1736
|
-
preload: _p,
|
|
1737
|
-
preloadDelay: _pd,
|
|
1738
|
-
preloadStaleTime: _ps,
|
|
1739
|
-
replace: _r,
|
|
1740
|
-
resetScroll: _rs,
|
|
1741
|
-
onClick: _oc,
|
|
1742
|
-
onMouseEnter: _ome,
|
|
1743
|
-
onMouseLeave: _oml,
|
|
1744
|
-
onFocus: _of,
|
|
1745
|
-
...anchorProps
|
|
1746
|
-
} = props;
|
|
1747
|
-
return createElement("a", {
|
|
1748
|
-
href,
|
|
1749
|
-
...isActive ? { "data-status": "active" } : {},
|
|
1750
|
-
...anchorProps,
|
|
1751
|
-
...extraProps,
|
|
1752
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
1753
|
-
}, resolvedChildren);
|
|
1754
|
-
}
|
|
1755
|
-
function Link(props) {
|
|
1756
|
-
if (typeof window === "undefined") {
|
|
1757
|
-
return createElement(RouterContext.Consumer, {
|
|
1758
|
-
children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
|
|
1759
|
-
});
|
|
1760
|
-
}
|
|
1761
|
-
return createElement(LinkInteractive, props);
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
// src/render/cache.ts
|
|
1765
|
-
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
1766
|
-
|
|
1767
|
-
// src/context-logger.ts
|
|
1768
|
-
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
1769
|
-
|
|
1770
|
-
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/elysia/index.mjs
|
|
1771
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
1772
|
-
import { Elysia } from "elysia";
|
|
1773
|
-
var storage = new AsyncLocalStorage;
|
|
1774
|
-
var activeLoggers = /* @__PURE__ */ new WeakSet;
|
|
1775
|
-
function useLogger2() {
|
|
1776
|
-
const logger = storage.getStore();
|
|
1777
|
-
if (!logger || !activeLoggers.has(logger))
|
|
1778
|
-
throw new Error("[evlog] useLogger() was called outside of an evlog plugin context. Make sure app.use(evlog()) is registered before your routes.");
|
|
1779
|
-
return logger;
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
// src/context-logger.ts
|
|
1783
|
-
var noopLogger2 = {
|
|
1784
|
-
set: () => {},
|
|
1785
|
-
error: () => {},
|
|
1786
|
-
info: () => {},
|
|
1787
|
-
warn: () => {},
|
|
1788
|
-
emit: () => null,
|
|
1789
|
-
getContext: () => ({}),
|
|
1790
|
-
fork: (_label, fn) => fn()
|
|
1791
|
-
};
|
|
1792
|
-
var syntheticRenderStorage = new AsyncLocalStorage2;
|
|
1793
|
-
function useLogger3() {
|
|
1794
|
-
try {
|
|
1795
|
-
return useLogger2();
|
|
1796
|
-
} catch {
|
|
1797
|
-
return syntheticRenderStorage.getStore() ?? noopLogger2;
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
async function runInSyntheticRenderScope(fn, initialContext) {
|
|
1801
|
-
const logger = createLogger(initialContext);
|
|
1802
|
-
try {
|
|
1803
|
-
const result = await syntheticRenderStorage.run(logger, () => Promise.resolve(fn()));
|
|
1804
|
-
logger.emit();
|
|
1805
|
-
return result;
|
|
1806
|
-
} catch (err) {
|
|
1807
|
-
logger.error(err instanceof Error ? err : new Error(String(err)));
|
|
1808
|
-
logger.emit();
|
|
1809
|
-
throw err;
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
// src/render/cache.ts
|
|
1814
|
-
var MAX_ISR_CACHE_SIZE = 1000;
|
|
1815
|
-
var MAX_SSG_CACHE_SIZE = 1000;
|
|
1816
|
-
var isrCache = new Map;
|
|
1817
|
-
var ssgCache = new Map;
|
|
1818
|
-
function evictOldest(map, maxSize) {
|
|
1819
|
-
if (map.size > maxSize) {
|
|
1820
|
-
const oldest = map.keys().next().value;
|
|
1821
|
-
if (oldest !== undefined) {
|
|
1822
|
-
map.delete(oldest);
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
function getISRCache(key) {
|
|
1827
|
-
const entry = isrCache.get(key);
|
|
1828
|
-
if (entry !== undefined) {
|
|
1829
|
-
isrCache.delete(key);
|
|
1830
|
-
isrCache.set(key, entry);
|
|
1831
|
-
}
|
|
1832
|
-
return entry;
|
|
1833
|
-
}
|
|
1834
|
-
function getSSGCache(key) {
|
|
1835
|
-
const entry = ssgCache.get(key);
|
|
1836
|
-
if (entry !== undefined) {
|
|
1837
|
-
ssgCache.delete(key);
|
|
1838
|
-
ssgCache.set(key, entry);
|
|
1993
|
+
function normalizeHref(href) {
|
|
1994
|
+
const url = new URL(href, "http://localhost");
|
|
1995
|
+
let pathname = url.pathname;
|
|
1996
|
+
if (pathname !== "/") {
|
|
1997
|
+
pathname = pathname.replace(/\/+$/g, "");
|
|
1839
1998
|
}
|
|
1840
|
-
return
|
|
1841
|
-
}
|
|
1842
|
-
function setISRCache(key, entry) {
|
|
1843
|
-
isrCache.delete(key);
|
|
1844
|
-
isrCache.set(key, entry);
|
|
1845
|
-
evictOldest(isrCache, MAX_ISR_CACHE_SIZE);
|
|
1999
|
+
return pathname + url.search + url.hash;
|
|
1846
2000
|
}
|
|
1847
|
-
function setSSGCache(key, entry) {
|
|
1848
|
-
ssgCache.delete(key);
|
|
1849
|
-
ssgCache.set(key, entry);
|
|
1850
|
-
evictOldest(ssgCache, MAX_SSG_CACHE_SIZE);
|
|
1851
|
-
}
|
|
1852
|
-
var _requestInvalidationScope = new AsyncLocalStorage3;
|
|
1853
|
-
var _globalPendingInvalidations = new Set;
|
|
1854
2001
|
|
|
1855
2002
|
// src/render/element.tsx
|
|
1856
2003
|
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
@@ -2036,7 +2183,7 @@ var IS_DEV = true;
|
|
|
2036
2183
|
|
|
2037
2184
|
// src/render/index.ts
|
|
2038
2185
|
function withSSRRouterContext(element, contextValue) {
|
|
2039
|
-
return
|
|
2186
|
+
return createElement3(RouterContext.Provider, { value: contextValue }, element);
|
|
2040
2187
|
}
|
|
2041
2188
|
async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomputedLoaderResult) {
|
|
2042
2189
|
const loaderStart = Date.now();
|
|
@@ -2079,7 +2226,7 @@ async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomp
|
|
|
2079
2226
|
}
|
|
2080
2227
|
const ssrContext = {
|
|
2081
2228
|
basePath: basePath ?? "",
|
|
2082
|
-
currentHref: ctx.path,
|
|
2229
|
+
currentHref: normalizeHref(ctx.path),
|
|
2083
2230
|
navigate: () => Promise.resolve(),
|
|
2084
2231
|
prefetch: () => {},
|
|
2085
2232
|
invalidatePrefetch: () => {},
|