@teyik0/furin 0.6.0-alpha.1 → 0.7.0-alpha.2
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/adapter/runtime-build.d.ts +1 -1
- package/dist/build/client.d.ts +4 -1
- package/dist/build/elysia-aot-worker.d.ts +22 -0
- package/dist/build/elysia-aot.d.ts +1 -1
- package/dist/build/entry-template.d.ts +3 -0
- package/dist/build/entry-template.ts +7 -0
- package/dist/build/hydrate.d.ts +1 -1
- package/dist/build/index.js +1880 -401
- package/dist/build/preload-manifest.d.ts +17 -0
- package/dist/build/types.d.ts +6 -0
- package/dist/cli/index.js +1878 -408
- package/dist/client/client-module.d.ts +26 -0
- package/dist/client/define-route.d.ts +9 -0
- package/dist/client/document.d.ts +2 -0
- package/dist/client/internal/runtime-types.d.ts +2 -0
- package/dist/client/link.js +942 -122
- package/dist/client/mutation.d.ts +38 -0
- package/dist/client/query-store.d.ts +85 -0
- package/dist/client/query.d.ts +14 -0
- package/dist/client/route-api.d.ts +11 -0
- package/dist/client/router/context.d.ts +3 -2
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +8 -1
- package/dist/client/router/navigation.d.ts +2 -9
- package/dist/client/router/optimistic.d.ts +41 -0
- package/dist/client/router/search/index.d.ts +3 -3
- package/dist/client/router/search-store.d.ts +1 -0
- package/dist/client/router/sync-catch-up.d.ts +3 -0
- package/dist/client/router/types.d.ts +51 -7
- package/dist/client/sync.d.ts +39 -22
- package/dist/client.d.ts +11 -33
- package/dist/client.js +1219 -59
- package/dist/config.d.ts +7 -0
- package/dist/config.js +1 -0
- package/dist/define-route.d.ts +78 -32
- package/dist/env.d.ts +2 -2
- package/dist/furin.d.ts +1 -2
- package/dist/furin.js +2484 -708
- package/dist/plugin/hmr-dependencies.d.ts +2 -0
- package/dist/plugin/index.js +349 -18
- package/dist/plugin/transform-client-module.d.ts +16 -0
- package/dist/plugin/transform-client.d.ts +2 -0
- package/dist/plugin/transform-isomorphic.d.ts +1 -1
- package/dist/routes.d.ts +6 -0
- package/dist/rsc-client.js +87 -16
- package/dist/rsc.js +87 -16
- package/dist/server/auto-invalidate/registry.d.ts +1 -0
- package/dist/server/auto-invalidate/types.d.ts +2 -0
- package/dist/server/cache/isr.d.ts +2 -4
- package/dist/server/cache/route-cache.d.ts +5 -0
- package/dist/server/dev/graph.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +5 -19
- package/dist/server/internal.d.ts +3 -0
- package/dist/server/internal.js +55 -35
- package/dist/server/production-server.js +54 -34
- package/dist/server/render/loaders.d.ts +4 -2
- package/dist/server/render/react-stream.d.ts +3 -0
- package/dist/server/render/ssr.d.ts +2 -1
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +2 -0
- package/dist/server/router/hmr.d.ts +1 -1
- package/dist/server/router/patterns.d.ts +2 -0
- package/dist/server/router/types.d.ts +1 -1
- package/dist/server/sync/adapter.d.ts +25 -4
- package/dist/server/sync/atomic.d.ts +25 -0
- package/dist/server/sync/drizzle/index.d.ts +45 -0
- package/dist/server/sync/drizzle/index.js +540 -0
- package/dist/server/sync/execution-error.d.ts +2 -0
- package/dist/server/sync/index.d.ts +2 -1
- package/dist/server/sync/index.js +533 -105
- package/dist/server/sync/mutation-handler.d.ts +4 -0
- package/dist/server/sync/plugin.d.ts +34 -11
- package/dist/server/sync/postgres/execute.d.ts +3 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +34 -13
- package/dist/server/sync/postgres/sql.d.ts +8 -0
- package/dist/server/sync/prisma/index.d.ts +24 -0
- package/dist/server/sync/prisma/index.js +340 -0
- package/dist/server/sync/queries.d.ts +21 -0
- package/dist/server/sync/query-context.d.ts +5 -0
- package/dist/server/sync/redis/index.js +3 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/response.d.ts +1 -0
- package/dist/server/sync/sqlite/index.d.ts +3 -0
- package/dist/server/sync/sqlite/index.js +10 -4
- package/dist/server/sync/stream.d.ts +2 -5
- package/dist/server/sync/validation.d.ts +4 -0
- package/dist/shared/defer.d.ts +31 -0
- package/dist/shared/error.d.ts +2 -2
- package/dist/shared/page-key.d.ts +7 -0
- package/dist/shared/query-bindings.d.ts +12 -0
- package/dist/shared/route-frame.d.ts +1 -0
- package/dist/shared/sync-query.d.ts +40 -0
- package/package.json +29 -6
- package/src/adapter/package.ts +12 -2
- package/src/adapter/runtime-build.ts +63 -12
- package/src/adapter/static.ts +7 -2
- package/src/adapter/vercel.ts +15 -13
- package/src/build/client.ts +23 -5
- package/src/build/elysia-aot-worker.ts +51 -0
- package/src/build/elysia-aot.ts +83 -19
- package/src/build/entry-template.ts +7 -0
- package/src/build/hydrate.ts +21 -3
- package/src/build/preload-manifest.ts +100 -0
- package/src/build/production-instrumentation.ts +6 -3
- package/src/build/types.ts +4 -0
- package/src/cli/index.ts +1 -0
- package/src/client/browser-events-runtime.ts +4 -0
- package/src/client/client-module.ts +57 -0
- package/src/client/define-route.ts +11 -1
- package/src/client/document.tsx +28 -18
- package/src/client/hmr.ts +2 -1
- package/src/client/internal/runtime-types.ts +2 -0
- package/src/client/link.tsx +8 -8
- package/src/client/mutation.ts +136 -0
- package/src/client/query-store.ts +418 -0
- package/src/client/query.tsx +67 -0
- package/src/client/route-api.tsx +75 -0
- package/src/client/router/boundary-tree.tsx +19 -12
- package/src/client/router/context.ts +57 -4
- package/src/client/router/index.ts +3 -0
- package/src/client/router/link-utils.ts +29 -1
- package/src/client/router/navigation.ts +3 -50
- package/src/client/router/optimistic.ts +233 -0
- package/src/client/router/provider.tsx +306 -46
- package/src/client/router/search/index.ts +37 -17
- package/src/client/router/search-store.ts +4 -0
- package/src/client/router/sync-catch-up.ts +7 -0
- package/src/client/router/types.ts +73 -9
- package/src/client/sync.ts +438 -65
- package/src/client.ts +20 -60
- package/src/config.ts +5 -0
- package/src/define-route.ts +113 -55
- package/src/env.d.ts +2 -2
- package/src/furin.ts +75 -13
- package/src/plugin/hmr-dependencies.ts +58 -0
- package/src/plugin/index.ts +38 -2
- package/src/plugin/routes.ts +28 -16
- package/src/plugin/transform-client-module.ts +123 -0
- package/src/plugin/transform-client.ts +293 -13
- package/src/plugin/transform-isomorphic.ts +11 -5
- package/src/routes.ts +8 -0
- package/src/rsc/shared.tsx +104 -18
- package/src/server/auto-invalidate/registry.ts +4 -0
- package/src/server/auto-invalidate/runtime.ts +17 -0
- package/src/server/auto-invalidate/types.ts +6 -0
- package/src/server/cache/isr.ts +6 -34
- package/src/server/cache/route-cache.ts +40 -4
- package/src/server/dev/graph.ts +16 -2
- package/src/server/dev-page-plugin.ts +93 -59
- package/src/server/internal.ts +3 -0
- package/src/server/render/document.tsx +10 -1
- package/src/server/render/element.tsx +21 -11
- package/src/server/render/isr.ts +61 -29
- package/src/server/render/loaders.ts +118 -47
- package/src/server/render/mixed-cache.ts +33 -4
- package/src/server/render/not-found.ts +4 -7
- package/src/server/render/ppr-document.ts +2 -1
- package/src/server/render/ppr-route.ts +30 -10
- package/src/server/render/react-stream.ts +17 -0
- package/src/server/render/route-frame-transport.ts +3 -0
- package/src/server/render/ssg.ts +51 -18
- package/src/server/render/ssr.ts +53 -8
- package/src/server/render/template.ts +23 -0
- package/src/server/router/defined-route.ts +3 -0
- package/src/server/router/discovery.ts +25 -9
- package/src/server/router/hmr.ts +3 -2
- package/src/server/router/patterns.ts +16 -0
- package/src/server/router/plugin.ts +27 -12
- package/src/server/router/types.ts +1 -1
- package/src/server/sync/adapter.ts +41 -4
- package/src/server/sync/atomic.ts +303 -0
- package/src/server/sync/drizzle/index.ts +145 -0
- package/src/server/sync/execution-error.ts +1 -0
- package/src/server/sync/fingerprint.ts +2 -6
- package/src/server/sync/index.ts +6 -0
- package/src/server/sync/mutation-handler.ts +69 -0
- package/src/server/sync/plugin.ts +177 -60
- package/src/server/sync/postgres/execute.ts +20 -0
- package/src/server/sync/postgres/index.ts +52 -16
- package/src/server/sync/postgres/sql.ts +20 -0
- package/src/server/sync/prisma/index.ts +70 -0
- package/src/server/sync/queries.ts +75 -0
- package/src/server/sync/query-context.ts +85 -0
- package/src/server/sync/redis/index.ts +7 -3
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/response.ts +21 -0
- package/src/server/sync/sqlite/index.ts +19 -8
- package/src/server/sync/stream.ts +14 -22
- package/src/server/sync/validation.ts +34 -0
- package/src/shared/defer.ts +48 -0
- package/src/shared/error.ts +2 -2
- package/src/shared/page-key.ts +36 -0
- package/src/shared/query-bindings.ts +138 -0
- package/src/shared/route-frame.ts +13 -1
- package/src/shared/route-map.ts +12 -2
- package/src/shared/sync-query.ts +138 -0
package/dist/rsc-client.js
CHANGED
|
@@ -128,25 +128,96 @@ function restoreRscSource(kind, bytes) {
|
|
|
128
128
|
const state = { bytes, kind, tree: decodeFlightBytes(bytes) };
|
|
129
129
|
return kind === "renderable" ? createRenderableSource(state) : { [RSC_SOURCE]: state };
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
function isLazyNode(value) {
|
|
132
|
+
return "$$typeof" in value && value.$$typeof === Symbol.for("react.lazy");
|
|
133
|
+
}
|
|
134
|
+
function containsSlot(value, visited) {
|
|
135
|
+
if (value === null || typeof value !== "object" || visited.has(value)) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
visited.add(value);
|
|
139
|
+
if (isLazyNode(value)) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
if (isValidElement(value)) {
|
|
143
|
+
return value.type === SLOT_MARKER || containsSlot(value.props, visited);
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(value)) {
|
|
146
|
+
return value.some((item) => containsSlot(item, visited));
|
|
147
|
+
}
|
|
148
|
+
return Object.getPrototypeOf(value) === Object.prototype && Object.values(value).some((item) => containsSlot(item, visited));
|
|
149
|
+
}
|
|
150
|
+
function resolveSlotArgument(value, slots, visited) {
|
|
151
|
+
if (!containsSlot(value, new WeakSet)) {
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
if (visited.has(value)) {
|
|
155
|
+
return visited.get(value);
|
|
156
|
+
}
|
|
157
|
+
if (isLazyNode(value)) {
|
|
158
|
+
const result = createElement(LazySlots, { node: value, slots });
|
|
159
|
+
visited.set(value, result);
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
if (isValidElement(value)) {
|
|
163
|
+
const resolved = resolveSlotElement(value, slots);
|
|
164
|
+
const result = isValidElement(resolved) ? Children.map(value, () => resolved)?.[0] : resolved;
|
|
165
|
+
visited.set(value, result);
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
if (Array.isArray(value)) {
|
|
169
|
+
const result = [];
|
|
170
|
+
visited.set(value, result);
|
|
171
|
+
for (const item of value) {
|
|
172
|
+
result.push(resolveSlotArgument(item, slots, visited));
|
|
135
173
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
|
|
174
|
+
const keys = new Set(result.filter(isValidElement).map((element) => element.key));
|
|
175
|
+
for (const [index, resolved] of result.entries()) {
|
|
176
|
+
if (isValidElement(resolved) && resolved.key === null) {
|
|
177
|
+
let key = String(index);
|
|
178
|
+
while (keys.has(key)) {
|
|
179
|
+
key = `.${key}`;
|
|
180
|
+
}
|
|
181
|
+
keys.add(key);
|
|
182
|
+
result[index] = cloneElement(resolved, { key });
|
|
140
183
|
}
|
|
141
|
-
const implementation = Reflect.get(slots, marker.name);
|
|
142
|
-
if (typeof implementation === "function") {
|
|
143
|
-
return implementation(...marker.args ?? []);
|
|
144
|
-
}
|
|
145
|
-
return implementation;
|
|
146
184
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
const result = {};
|
|
188
|
+
visited.set(value, result);
|
|
189
|
+
for (const [key, item] of Object.entries(value)) {
|
|
190
|
+
Object.defineProperty(result, key, {
|
|
191
|
+
configurable: true,
|
|
192
|
+
enumerable: true,
|
|
193
|
+
value: resolveSlotArgument(item, slots, visited),
|
|
194
|
+
writable: true
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
function resolveSlotElement(child, slots) {
|
|
200
|
+
if (child.type === SLOT_MARKER) {
|
|
201
|
+
const marker = child.props;
|
|
202
|
+
if (typeof marker.name !== "string") {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
const implementation = Reflect.get(slots, marker.name);
|
|
206
|
+
if (typeof implementation === "function") {
|
|
207
|
+
const visited = new WeakMap;
|
|
208
|
+
const args = (marker.args ?? []).map((argument) => resolveSlotArgument(argument, slots, visited));
|
|
209
|
+
return implementation(...args);
|
|
210
|
+
}
|
|
211
|
+
return implementation;
|
|
212
|
+
}
|
|
213
|
+
const props = resolveSlotArgument(child.props, slots, new WeakMap);
|
|
214
|
+
return props === child.props ? child : cloneElement(child, props);
|
|
215
|
+
}
|
|
216
|
+
function resolveSlots(node, slots) {
|
|
217
|
+
return Children.map(node, (child) => isValidElement(child) ? resolveSlotElement(child, slots) : child);
|
|
218
|
+
}
|
|
219
|
+
function LazySlots({ node, slots }) {
|
|
220
|
+
return resolveSlots(node, slots);
|
|
150
221
|
}
|
|
151
222
|
function CompositeComponent(props) {
|
|
152
223
|
const { src, ...slots } = props;
|
package/dist/rsc.js
CHANGED
|
@@ -284,25 +284,96 @@ function restoreRscSource(kind, bytes) {
|
|
|
284
284
|
const state = { bytes, kind, tree: decodeFlightBytes(bytes) };
|
|
285
285
|
return kind === "renderable" ? createRenderableSource(state) : { [RSC_SOURCE]: state };
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
return
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
function isLazyNode(value) {
|
|
288
|
+
return "$$typeof" in value && value.$$typeof === Symbol.for("react.lazy");
|
|
289
|
+
}
|
|
290
|
+
function containsSlot(value, visited) {
|
|
291
|
+
if (value === null || typeof value !== "object" || visited.has(value)) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
visited.add(value);
|
|
295
|
+
if (isLazyNode(value)) {
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
if (isValidElement(value)) {
|
|
299
|
+
return value.type === SLOT_MARKER || containsSlot(value.props, visited);
|
|
300
|
+
}
|
|
301
|
+
if (Array.isArray(value)) {
|
|
302
|
+
return value.some((item) => containsSlot(item, visited));
|
|
303
|
+
}
|
|
304
|
+
return Object.getPrototypeOf(value) === Object.prototype && Object.values(value).some((item) => containsSlot(item, visited));
|
|
305
|
+
}
|
|
306
|
+
function resolveSlotArgument(value, slots, visited) {
|
|
307
|
+
if (!containsSlot(value, new WeakSet)) {
|
|
308
|
+
return value;
|
|
309
|
+
}
|
|
310
|
+
if (visited.has(value)) {
|
|
311
|
+
return visited.get(value);
|
|
312
|
+
}
|
|
313
|
+
if (isLazyNode(value)) {
|
|
314
|
+
const result = createElement(LazySlots, { node: value, slots });
|
|
315
|
+
visited.set(value, result);
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
if (isValidElement(value)) {
|
|
319
|
+
const resolved = resolveSlotElement(value, slots);
|
|
320
|
+
const result = isValidElement(resolved) ? Children.map(value, () => resolved)?.[0] : resolved;
|
|
321
|
+
visited.set(value, result);
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
if (Array.isArray(value)) {
|
|
325
|
+
const result = [];
|
|
326
|
+
visited.set(value, result);
|
|
327
|
+
for (const item of value) {
|
|
328
|
+
result.push(resolveSlotArgument(item, slots, visited));
|
|
291
329
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
330
|
+
const keys = new Set(result.filter(isValidElement).map((element) => element.key));
|
|
331
|
+
for (const [index, resolved] of result.entries()) {
|
|
332
|
+
if (isValidElement(resolved) && resolved.key === null) {
|
|
333
|
+
let key = String(index);
|
|
334
|
+
while (keys.has(key)) {
|
|
335
|
+
key = `.${key}`;
|
|
336
|
+
}
|
|
337
|
+
keys.add(key);
|
|
338
|
+
result[index] = cloneElement(resolved, { key });
|
|
300
339
|
}
|
|
301
|
-
return implementation;
|
|
302
340
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
const result = {};
|
|
344
|
+
visited.set(value, result);
|
|
345
|
+
for (const [key, item] of Object.entries(value)) {
|
|
346
|
+
Object.defineProperty(result, key, {
|
|
347
|
+
configurable: true,
|
|
348
|
+
enumerable: true,
|
|
349
|
+
value: resolveSlotArgument(item, slots, visited),
|
|
350
|
+
writable: true
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
function resolveSlotElement(child, slots) {
|
|
356
|
+
if (child.type === SLOT_MARKER) {
|
|
357
|
+
const marker = child.props;
|
|
358
|
+
if (typeof marker.name !== "string") {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
const implementation = Reflect.get(slots, marker.name);
|
|
362
|
+
if (typeof implementation === "function") {
|
|
363
|
+
const visited = new WeakMap;
|
|
364
|
+
const args = (marker.args ?? []).map((argument) => resolveSlotArgument(argument, slots, visited));
|
|
365
|
+
return implementation(...args);
|
|
366
|
+
}
|
|
367
|
+
return implementation;
|
|
368
|
+
}
|
|
369
|
+
const props = resolveSlotArgument(child.props, slots, new WeakMap);
|
|
370
|
+
return props === child.props ? child : cloneElement(child, props);
|
|
371
|
+
}
|
|
372
|
+
function resolveSlots(node, slots) {
|
|
373
|
+
return Children.map(node, (child) => isValidElement(child) ? resolveSlotElement(child, slots) : child);
|
|
374
|
+
}
|
|
375
|
+
function LazySlots({ node, slots }) {
|
|
376
|
+
return resolveSlots(node, slots);
|
|
306
377
|
}
|
|
307
378
|
function CompositeComponent(props) {
|
|
308
379
|
const { src, ...slots } = props;
|
|
@@ -6,6 +6,7 @@ export declare class AutoInvalidateRegistry {
|
|
|
6
6
|
private reindexPath;
|
|
7
7
|
registerLoaderTags(urlPath: string, tags: readonly string[] | undefined, owner?: string): void;
|
|
8
8
|
pathsForTags(tags: readonly string[]): string[];
|
|
9
|
+
tagsForPath(path: string): string[];
|
|
9
10
|
unregisterPath(urlPath: string, owner?: string): void;
|
|
10
11
|
reset(): void;
|
|
11
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CacheTag } from "../../furin.ts";
|
|
2
|
+
import type { SyncQueryIdentity } from "../../shared/sync-query.ts";
|
|
2
3
|
import type { RevalidateType } from "../cache/route-cache.ts";
|
|
3
4
|
export type InvalidationRule = {
|
|
4
5
|
path: string;
|
|
@@ -10,3 +11,4 @@ export type InvalidationRule = {
|
|
|
10
11
|
type?: never;
|
|
11
12
|
};
|
|
12
13
|
export type InvalidationInput = InvalidationRule | readonly InvalidationRule[];
|
|
14
|
+
export type SyncInvalidationInput = InvalidationRule | SyncQueryIdentity | readonly (InvalidationRule | SyncQueryIdentity)[];
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { type FurinInstance } from "../instance.ts";
|
|
2
2
|
import { type ISRCacheEntry } from "./isr-ssg";
|
|
3
|
-
import type { Cache } from "./route-cache";
|
|
3
|
+
import type { Cache, CacheGeneration } from "./route-cache";
|
|
4
4
|
import { type StoreView } from "./store-view";
|
|
5
|
-
export
|
|
6
|
-
valid: boolean;
|
|
7
|
-
}
|
|
5
|
+
export type ISRCacheGeneration = CacheGeneration;
|
|
8
6
|
export declare function isrRouteCache(instance?: FurinInstance): Cache<ISRCacheEntry>;
|
|
9
7
|
/** Raw store view over the current instance's ISR cache. */
|
|
10
8
|
export declare const isrCache: StoreView<ISRCacheEntry>;
|
|
@@ -3,7 +3,11 @@ export interface CacheInvalidationResult {
|
|
|
3
3
|
deleted: boolean;
|
|
4
4
|
purgedPaths: string[];
|
|
5
5
|
}
|
|
6
|
+
export interface CacheGeneration {
|
|
7
|
+
valid: boolean;
|
|
8
|
+
}
|
|
6
9
|
export interface Cache<Entry> {
|
|
10
|
+
captureGeneration: (key: string) => CacheGeneration;
|
|
7
11
|
clear: () => void;
|
|
8
12
|
delete: (key: string) => boolean;
|
|
9
13
|
entries: () => IterableIterator<[string, Entry]>;
|
|
@@ -12,6 +16,7 @@ export interface Cache<Entry> {
|
|
|
12
16
|
invalidatePath: (path: string, type: RevalidateType) => CacheInvalidationResult;
|
|
13
17
|
keys: () => IterableIterator<string>;
|
|
14
18
|
readonly name: string;
|
|
19
|
+
releaseGeneration: (key: string, generation: CacheGeneration) => void;
|
|
15
20
|
set: (key: string, entry: Entry) => void;
|
|
16
21
|
get size(): number;
|
|
17
22
|
readonly store: Map<string, Entry>;
|
|
@@ -66,6 +66,7 @@ export declare class DevGraph<Snapshot> {
|
|
|
66
66
|
importModule<Module>(path: string, sourceVersion: string, importModule: DevModuleImporter<Module>): Promise<Module>;
|
|
67
67
|
importChain(from: string, to: string): string[];
|
|
68
68
|
dependsOn(from: string, to: string): boolean;
|
|
69
|
+
sourceDependencies(from: string): string[];
|
|
69
70
|
clearSourceErrors(path: string): void;
|
|
70
71
|
publishError(error: DevErrorPayload): Extract<DevGraphEvent, {
|
|
71
72
|
type: "error";
|
|
@@ -47,10 +47,8 @@
|
|
|
47
47
|
* guaranteeing a single shared React instance regardless of CWD or
|
|
48
48
|
* hot-reload state.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* that modules which both import and re-export from the same package are fully
|
|
53
|
-
* rewritten while string literals in non-import positions are left untouched.
|
|
50
|
+
* Static imports, re-exports, and literal dynamic imports are rewritten from
|
|
51
|
+
* the parsed module, leaving ordinary strings and comments untouched.
|
|
54
52
|
*/
|
|
55
53
|
export declare const WORKSPACE_SOURCE_FILTER: RegExp;
|
|
56
54
|
interface CachedDevPageContents {
|
|
@@ -97,24 +95,12 @@ export declare function injectJsxHelperImports(transpiled: string): string;
|
|
|
97
95
|
/** @internal exported for testing */
|
|
98
96
|
export declare function rewriteRelativeImports(source: string, dir: string): string;
|
|
99
97
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Uses `Bun.Transpiler.scan()` on the original source to get the authoritative
|
|
104
|
-
* list of *actual* import specifiers (parsing correctly handles template
|
|
105
|
-
* literals, comments, etc.). For each bare specifier that is not already
|
|
106
|
-
* handled by `rewriteSingletonImports`, it calls `Bun.resolveSync` and
|
|
107
|
-
* replaces **every** import/re-export occurrence of the quoted specifier using
|
|
108
|
-
* a context-aware regex with the `g` flag — mirroring the approach used by
|
|
109
|
-
* `rewriteSingletonImports`. This correctly handles modules that both import
|
|
110
|
-
* and re-export from the same package without leaving any bare specifier
|
|
111
|
-
* behind. String literals that happen to contain the same text (inside
|
|
112
|
-
* template literals, JSX props, etc.) are not touched because the regex
|
|
113
|
-
* requires a preceding `from` or `import` keyword.
|
|
98
|
+
* Resolves static imports, re-exports, and literal dynamic imports from the
|
|
99
|
+
* page file's directory, including tsconfig aliases in virtual modules.
|
|
114
100
|
*
|
|
115
101
|
* @internal exported for testing
|
|
116
102
|
*/
|
|
117
|
-
export declare function rewriteBareImports(
|
|
103
|
+
export declare function rewriteBareImports(transpiled: string, dir: string): string;
|
|
118
104
|
export declare function transformDevSource(raw: string, filePath: string, options: {
|
|
119
105
|
renderFragment?: boolean;
|
|
120
106
|
rewriteBareImports: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AnyElysia } from "elysia";
|
|
2
|
+
import type { ClientPreloadManifest } from "../build/preload-manifest.ts";
|
|
2
3
|
import type { SsgCacheEntry } from "./cache/index.ts";
|
|
3
4
|
import { type RuntimeCacheProvider } from "./cache/runtime-cache.ts";
|
|
4
5
|
import { setRuntimeEvlogWaitUntil as installRuntimeEvlogWaitUntil } from "./evlog.ts";
|
|
@@ -26,6 +27,8 @@ export interface CompileContext {
|
|
|
26
27
|
nativeRoutes?: AnyElysia;
|
|
27
28
|
/** Mount prefix this app was built for (`""` = root). */
|
|
28
29
|
prefix?: string;
|
|
30
|
+
/** Chunk URLs to modulepreload, produced by the client build. */
|
|
31
|
+
preloadManifest?: ClientPreloadManifest;
|
|
29
32
|
/** Root-level conventions discovered at compile time. */
|
|
30
33
|
rootConventions?: {
|
|
31
34
|
errorPath?: string;
|
package/dist/server/internal.js
CHANGED
|
@@ -11,7 +11,7 @@ var __esm = (fn, res, err) => () => {
|
|
|
11
11
|
return res;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
14
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/streamResponse-OlirMA5P.mjs
|
|
15
15
|
function shouldDeferEmitForResponse(response) {
|
|
16
16
|
if (!response.body)
|
|
17
17
|
return false;
|
|
@@ -91,7 +91,7 @@ function bindStreamingResponseLifecycle(response, onComplete) {
|
|
|
91
91
|
}
|
|
92
92
|
var init_streamResponse_OlirMA5P = () => {};
|
|
93
93
|
|
|
94
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
94
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/utils.mjs
|
|
95
95
|
function elapsedMs(startTime) {
|
|
96
96
|
return Math.max(0, Date.now() - startTime);
|
|
97
97
|
}
|
|
@@ -232,7 +232,7 @@ var init_utils = __esm(() => {
|
|
|
232
232
|
_isoDate = /* @__PURE__ */ new Date;
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
235
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/redact-C7FmdhwI.mjs
|
|
236
236
|
function normalizeRedactPathPattern(pattern) {
|
|
237
237
|
if (!pattern.includes("*") && !pattern.includes("."))
|
|
238
238
|
return `**.${pattern}`;
|
|
@@ -541,7 +541,7 @@ var init_redact_C7FmdhwI = __esm(() => {
|
|
|
541
541
|
globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
542
542
|
});
|
|
543
543
|
|
|
544
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
544
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/globalRegistry-Bh3bIGwA.mjs
|
|
545
545
|
function logPluginError(name, hook, err) {
|
|
546
546
|
console.error(`[evlog/${name}] ${hook} failed:`, err);
|
|
547
547
|
}
|
|
@@ -711,7 +711,7 @@ var init_globalRegistry_Bh3bIGwA = __esm(() => {
|
|
|
711
711
|
globalConfig = getRegistry().config;
|
|
712
712
|
});
|
|
713
713
|
|
|
714
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
714
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/pretty-error-D8rlWNL1.mjs
|
|
715
715
|
function pushTreeSpacer(children) {
|
|
716
716
|
children.push(PRETTY_ERROR_TREE_SPACER);
|
|
717
717
|
}
|
|
@@ -1012,7 +1012,7 @@ var init_pretty_error_D8rlWNL1 = __esm(() => {
|
|
|
1012
1012
|
SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
1013
1013
|
});
|
|
1014
1014
|
|
|
1015
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1015
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/dev-terminal-Brarc6vc.mjs
|
|
1016
1016
|
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
1017
1017
|
const compact = partial.compact ?? (inDev && pretty);
|
|
1018
1018
|
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
@@ -1065,7 +1065,7 @@ var init_dev_terminal_Brarc6vc = __esm(() => {
|
|
|
1065
1065
|
};
|
|
1066
1066
|
});
|
|
1067
1067
|
|
|
1068
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1068
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/wideEventChannel-BUDW48oP.mjs
|
|
1069
1069
|
function hasWideEventPublisher() {
|
|
1070
1070
|
return publisher !== null;
|
|
1071
1071
|
}
|
|
@@ -1081,7 +1081,7 @@ function publishWideEvent(event) {
|
|
|
1081
1081
|
var publisher = null;
|
|
1082
1082
|
var init_wideEventChannel_BUDW48oP = () => {};
|
|
1083
1083
|
|
|
1084
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1084
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/error-brand-D0-DCPvr.mjs
|
|
1085
1085
|
function isEvlogError(error) {
|
|
1086
1086
|
return typeof error === "object" && error !== null && error[evlogErrorBrand] === true;
|
|
1087
1087
|
}
|
|
@@ -1090,7 +1090,7 @@ var init_error_brand_D0_DCPvr = __esm(() => {
|
|
|
1090
1090
|
evlogErrorBrand = Symbol.for("evlog.error.brand");
|
|
1091
1091
|
});
|
|
1092
1092
|
|
|
1093
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1093
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/error.mjs
|
|
1094
1094
|
var evlogErrorInternalKey, evlogErrorDataKey, EvlogError;
|
|
1095
1095
|
var init_error = __esm(() => {
|
|
1096
1096
|
init_utils();
|
|
@@ -1199,7 +1199,7 @@ var init_error = __esm(() => {
|
|
|
1199
1199
|
});
|
|
1200
1200
|
});
|
|
1201
1201
|
|
|
1202
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1202
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/headers-Bx1ieR-m.mjs
|
|
1203
1203
|
function extractSafeHeaders(headers) {
|
|
1204
1204
|
const raw = {};
|
|
1205
1205
|
headers.forEach((value, key) => {
|
|
@@ -1220,7 +1220,7 @@ var init_headers_Bx1ieR_m = __esm(() => {
|
|
|
1220
1220
|
init_utils();
|
|
1221
1221
|
});
|
|
1222
1222
|
|
|
1223
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1223
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/audit-C8euLMvu.mjs
|
|
1224
1224
|
function writePrettyStdout(text) {
|
|
1225
1225
|
(globalThis.__evlogNativeStdoutWrite ?? nativeStdoutWrite)?.(text);
|
|
1226
1226
|
}
|
|
@@ -2142,7 +2142,7 @@ var init_audit_C8euLMvu = __esm(() => {
|
|
|
2142
2142
|
initLogger(__EVLOG_CONFIG__);
|
|
2143
2143
|
});
|
|
2144
2144
|
|
|
2145
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2145
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/errors-CL8dDgIi.mjs
|
|
2146
2146
|
function extractErrorStatus(error) {
|
|
2147
2147
|
if (error === null || typeof error !== "object")
|
|
2148
2148
|
return 500;
|
|
@@ -2152,7 +2152,7 @@ function extractErrorStatus(error) {
|
|
|
2152
2152
|
}
|
|
2153
2153
|
var init_errors_CL8dDgIi = () => {};
|
|
2154
2154
|
|
|
2155
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2155
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/deferred-drain-CfRYimo5.mjs
|
|
2156
2156
|
function shouldLog(path, include, exclude) {
|
|
2157
2157
|
if (exclude && exclude.length > 0) {
|
|
2158
2158
|
if (exclude.some((pattern) => matchesPattern(path, pattern)))
|
|
@@ -2180,7 +2180,7 @@ var init_deferred_drain_CfRYimo5 = __esm(() => {
|
|
|
2180
2180
|
init_utils();
|
|
2181
2181
|
});
|
|
2182
2182
|
|
|
2183
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2183
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/middleware-fam3VyaL.mjs
|
|
2184
2184
|
function resolveMiddlewarePluginRunner(options) {
|
|
2185
2185
|
const global = getGlobalPluginRunner();
|
|
2186
2186
|
const local = options.plugins;
|
|
@@ -2375,7 +2375,7 @@ var init_middleware_fam3VyaL = __esm(() => {
|
|
|
2375
2375
|
runnerCache = /* @__PURE__ */ new WeakMap;
|
|
2376
2376
|
});
|
|
2377
2377
|
|
|
2378
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2378
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/integration-CGD18W8r.mjs
|
|
2379
2379
|
function attachForkToLogger(storage, parent, middlewareOptions, lifecycle) {
|
|
2380
2380
|
const log = parent;
|
|
2381
2381
|
log.fork = (label, fn) => {
|
|
@@ -2478,7 +2478,7 @@ var init_integration_CGD18W8r = __esm(() => {
|
|
|
2478
2478
|
init_middleware_fam3VyaL();
|
|
2479
2479
|
});
|
|
2480
2480
|
|
|
2481
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2481
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/toolkit/storage.mjs
|
|
2482
2482
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2483
2483
|
function createLoggerStorage(contextHint, id = contextHint) {
|
|
2484
2484
|
const storage = getSharedStorage(id, () => new AsyncLocalStorage2);
|
|
@@ -2497,7 +2497,7 @@ var init_storage = __esm(() => {
|
|
|
2497
2497
|
init_globalRegistry_Bh3bIGwA();
|
|
2498
2498
|
});
|
|
2499
2499
|
|
|
2500
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2500
|
+
// ../../node_modules/.bun/evlog@2.29.0+e419d84a67dec76a/node_modules/evlog/dist/toolkit.mjs
|
|
2501
2501
|
var init_toolkit = __esm(() => {
|
|
2502
2502
|
init_integration_CGD18W8r();
|
|
2503
2503
|
init_storage();
|
|
@@ -2653,6 +2653,9 @@ class AutoInvalidateRegistry {
|
|
|
2653
2653
|
}
|
|
2654
2654
|
return [...paths];
|
|
2655
2655
|
}
|
|
2656
|
+
tagsForPath(path) {
|
|
2657
|
+
return [...this.pathToTags.get(path) ?? []];
|
|
2658
|
+
}
|
|
2656
2659
|
unregisterPath(urlPath, owner) {
|
|
2657
2660
|
if (owner === undefined) {
|
|
2658
2661
|
this.pathOwners.delete(urlPath);
|
|
@@ -2699,7 +2702,14 @@ function matchesPath(urlPath, path, type) {
|
|
|
2699
2702
|
}
|
|
2700
2703
|
function createRouteCache(options) {
|
|
2701
2704
|
const store = new Map;
|
|
2705
|
+
const generations = new Map;
|
|
2702
2706
|
const pathFromKey = options.pathFromKey ?? defaultPathFromKey;
|
|
2707
|
+
const invalidateGenerations = (key) => {
|
|
2708
|
+
for (const generation of generations.get(key) ?? []) {
|
|
2709
|
+
generation.valid = false;
|
|
2710
|
+
}
|
|
2711
|
+
generations.delete(key);
|
|
2712
|
+
};
|
|
2703
2713
|
const evictOldest = () => {
|
|
2704
2714
|
if (options.maxSize === undefined || store.size <= options.maxSize) {
|
|
2705
2715
|
return;
|
|
@@ -2710,6 +2720,7 @@ function createRouteCache(options) {
|
|
|
2710
2720
|
}
|
|
2711
2721
|
};
|
|
2712
2722
|
const deleteEntry = (key) => {
|
|
2723
|
+
invalidateGenerations(key);
|
|
2713
2724
|
const entry = store.get(key);
|
|
2714
2725
|
if (entry === undefined) {
|
|
2715
2726
|
return false;
|
|
@@ -2719,7 +2730,20 @@ function createRouteCache(options) {
|
|
|
2719
2730
|
return true;
|
|
2720
2731
|
};
|
|
2721
2732
|
return {
|
|
2733
|
+
captureGeneration(key) {
|
|
2734
|
+
const generation = { valid: true };
|
|
2735
|
+
let pending = generations.get(key);
|
|
2736
|
+
if (pending === undefined) {
|
|
2737
|
+
pending = new Set;
|
|
2738
|
+
generations.set(key, pending);
|
|
2739
|
+
}
|
|
2740
|
+
pending.add(generation);
|
|
2741
|
+
return generation;
|
|
2742
|
+
},
|
|
2722
2743
|
clear() {
|
|
2744
|
+
for (const key of generations.keys()) {
|
|
2745
|
+
invalidateGenerations(key);
|
|
2746
|
+
}
|
|
2723
2747
|
for (const key of [...store.keys()]) {
|
|
2724
2748
|
deleteEntry(key);
|
|
2725
2749
|
}
|
|
@@ -2745,14 +2769,15 @@ function createRouteCache(options) {
|
|
|
2745
2769
|
invalidatePath(path, type) {
|
|
2746
2770
|
let deleted = false;
|
|
2747
2771
|
const purgedPaths = [];
|
|
2748
|
-
for (const key of [...store.keys()]) {
|
|
2772
|
+
for (const key of new Set([...store.keys(), ...generations.keys()])) {
|
|
2749
2773
|
const urlPath = pathFromKey(key);
|
|
2750
2774
|
if (urlPath === null || !matchesPath(urlPath, path, type)) {
|
|
2751
2775
|
continue;
|
|
2752
2776
|
}
|
|
2753
|
-
deleteEntry(key)
|
|
2754
|
-
|
|
2755
|
-
|
|
2777
|
+
if (deleteEntry(key)) {
|
|
2778
|
+
deleted = true;
|
|
2779
|
+
purgedPaths.push(urlPath);
|
|
2780
|
+
}
|
|
2756
2781
|
}
|
|
2757
2782
|
return { deleted, purgedPaths: [...new Set(purgedPaths)] };
|
|
2758
2783
|
},
|
|
@@ -2760,6 +2785,13 @@ function createRouteCache(options) {
|
|
|
2760
2785
|
return store.keys();
|
|
2761
2786
|
},
|
|
2762
2787
|
name: options.name,
|
|
2788
|
+
releaseGeneration(key, generation) {
|
|
2789
|
+
const pending = generations.get(key);
|
|
2790
|
+
pending?.delete(generation);
|
|
2791
|
+
if (pending?.size === 0) {
|
|
2792
|
+
generations.delete(key);
|
|
2793
|
+
}
|
|
2794
|
+
},
|
|
2763
2795
|
set(key, entry) {
|
|
2764
2796
|
const previous = store.get(key);
|
|
2765
2797
|
if (previous !== undefined) {
|
|
@@ -2826,22 +2858,10 @@ function createStoreView(resolve) {
|
|
|
2826
2858
|
|
|
2827
2859
|
// src/server/cache/isr.ts
|
|
2828
2860
|
var instanceIsrCache = instanceSlot((instance) => {
|
|
2829
|
-
const generations = new Map;
|
|
2830
2861
|
const pendingRevalidations = new Map;
|
|
2831
|
-
const cache = createHtmlRouteCache("isr"
|
|
2832
|
-
onDelete: (key) => {
|
|
2833
|
-
const pending = generations.get(key);
|
|
2834
|
-
if (pending === undefined) {
|
|
2835
|
-
return;
|
|
2836
|
-
}
|
|
2837
|
-
for (const generation of pending) {
|
|
2838
|
-
generation.valid = false;
|
|
2839
|
-
}
|
|
2840
|
-
generations.delete(key);
|
|
2841
|
-
}
|
|
2842
|
-
});
|
|
2862
|
+
const cache = createHtmlRouteCache("isr");
|
|
2843
2863
|
registerCacheInvalidator(cache, instance);
|
|
2844
|
-
return { cache,
|
|
2864
|
+
return { cache, pendingRevalidations };
|
|
2845
2865
|
});
|
|
2846
2866
|
var isrCache = createStoreView(() => instanceIsrCache().cache.store);
|
|
2847
2867
|
function hasPendingISRRevalidations() {
|