@teyik0/furin 0.4.0-alpha.1 → 0.4.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/bun.d.ts +2 -18
- package/dist/adapter/package.d.ts +2 -2
- package/dist/adapter/runtime-build.d.ts +33 -0
- package/dist/adapter/vercel.d.ts +3 -0
- package/dist/build/client.d.ts +1 -1
- package/dist/build/compile-entry.d.ts +4 -3
- package/dist/build/compile-entry.ts +24 -69
- package/dist/build/entry-template.d.ts +4 -2
- package/dist/build/entry-template.ts +31 -8
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8596 -6375
- package/dist/build/ssg-cache.d.ts +13 -0
- package/dist/build/types.d.ts +25 -2
- package/dist/build/virtual-entry.d.ts +8 -0
- package/dist/cache.d.ts +5 -0
- package/dist/cache.js +97 -0
- package/dist/cli/index.js +9099 -6771
- package/dist/cli/preview.d.ts +7 -0
- package/dist/client/boundaries.d.ts +1 -0
- package/dist/client/browser-events-runtime.d.ts +2 -0
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/define-route.d.ts +9 -8
- package/dist/client/dev-error-overlay.d.ts +1 -0
- package/dist/client/dev-error-overlay.ts +201 -0
- package/dist/client/document.d.ts +1 -0
- package/dist/client/hmr.d.ts +4 -2
- package/dist/client/link.js +251 -82
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/sync-catch-up.d.ts +1 -1
- package/dist/client/router/types.d.ts +8 -10
- package/dist/client.js +37 -23
- package/dist/config.d.ts +17 -0
- package/dist/config.js +9 -1
- package/dist/define-route.d.ts +11 -8
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +1 -1
- package/dist/furin.js +12991 -9491
- package/dist/plugin/index.js +476 -7
- package/dist/plugin/routes.d.ts +4 -3
- package/dist/rsc/build/index.d.ts +5 -1
- package/dist/server/browser-events/plugin.d.ts +11 -0
- package/dist/server/browser-events/types.d.ts +9 -0
- package/dist/server/cache/invalidation.d.ts +1 -2
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/dev/browser-events.d.ts +4 -0
- package/dist/server/dev/diagnostics.d.ts +39 -0
- package/dist/server/dev/error.d.ts +17 -0
- package/dist/server/dev/graph.d.ts +86 -0
- package/dist/server/dev/plugin.d.ts +9 -0
- package/dist/server/dev/request-security.d.ts +1 -0
- package/dist/server/dev/rewrite-module-specifiers.d.ts +7 -0
- package/dist/server/dev/runtime.production.d.ts +5 -0
- package/dist/server/dev/symbolicate.d.ts +11 -0
- package/dist/server/dev/transform-failure.d.ts +4 -0
- package/dist/server/dev-page-plugin.production.d.ts +1 -0
- package/dist/server/devtools/hub.d.ts +3 -2
- package/dist/server/devtools/instrumentation.d.ts +1 -1
- package/dist/server/devtools/instrumentation.production.d.ts +1 -1
- package/dist/server/devtools/plugin.d.ts +1 -1
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +14 -2
- package/dist/server/internal.js +436 -1
- package/dist/server/render/element.d.ts +1 -0
- package/dist/server/render/index.d.ts +1 -1
- package/dist/server/render/index.ts +1 -1
- package/dist/server/render/ppr-document.d.ts +21 -0
- package/dist/server/render/ppr-request.d.ts +26 -0
- package/dist/server/render/ppr-route.d.ts +3 -1
- package/dist/server/render/shell.ts +0 -12
- package/dist/server/render/ssg.d.ts +2 -0
- package/dist/server/render/ssr.d.ts +17 -6
- package/dist/server/router/hmr.production.d.ts +2 -0
- package/dist/server/router/patterns.d.ts +1 -0
- package/dist/server/router/plugin.d.ts +3 -1
- package/dist/server/sync/adapter.d.ts +13 -0
- package/dist/server/sync/config.d.ts +5 -5
- package/dist/server/sync/index.d.ts +6 -6
- package/dist/server/sync/index.js +491 -516
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +101 -6
- package/dist/server/sync/stream.d.ts +4 -13
- package/dist/shared/await.d.ts +3 -3
- package/dist/shared/browser-events.d.ts +22 -0
- package/dist/shared/compact-json.d.ts +8 -0
- package/dist/shared/deferred-ndjson.d.ts +6 -5
- package/dist/shared/dev-diagnostics.d.ts +36 -0
- package/dist/shared/prefix.d.ts +2 -0
- package/package.json +16 -7
- package/src/adapter/README.md +45 -0
- package/src/adapter/bun.ts +45 -268
- package/src/adapter/package.ts +15 -9
- package/src/adapter/runtime-build.ts +375 -0
- package/src/adapter/static.ts +79 -2
- package/src/adapter/vercel.ts +857 -0
- package/src/build/client.ts +38 -13
- package/src/build/compile-entry.ts +24 -69
- package/src/build/entry-template.ts +31 -8
- package/src/build/hydrate.ts +60 -20
- package/src/build/index.ts +19 -5
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/shared.ts +2 -1
- package/src/build/ssg-cache.ts +97 -11
- package/src/build/types.ts +31 -2
- package/src/build/virtual-entry.ts +27 -0
- package/src/cache.ts +14 -0
- package/src/cli/index.ts +55 -3
- package/src/cli/preview.ts +90 -0
- package/src/client/boundaries.tsx +10 -1
- package/src/client/browser-events-runtime.ts +204 -0
- package/src/client/browser-events.ts +22 -0
- package/src/client/define-route.ts +7 -17
- package/src/client/dev-error-overlay.ts +201 -0
- package/src/client/document.tsx +4 -7
- package/src/client/hmr.ts +26 -3
- package/src/client/router/boundary-tree.tsx +4 -4
- package/src/client/router/provider.tsx +165 -63
- package/src/client/router/sync-catch-up.ts +3 -4
- package/src/client/router/types.ts +6 -6
- package/src/config.ts +25 -0
- package/src/define-route.ts +20 -7
- package/src/devtools/devtools-element.js +56 -77
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +157 -77
- package/src/plugin/routes.ts +206 -36
- package/src/plugin/transform-client.ts +685 -3
- package/src/react-dom-edge.d.ts +6 -0
- package/src/rsc/build/index.ts +15 -3
- package/src/server/auto-invalidate/runtime.ts +5 -2
- package/src/server/browser-events/plugin.ts +168 -0
- package/src/server/browser-events/types.ts +11 -0
- package/src/server/cache/dev-loader.ts +30 -29
- package/src/server/cache/invalidation.ts +13 -22
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/dev/browser-events.ts +54 -0
- package/src/server/dev/diagnostics.ts +297 -0
- package/src/server/dev/error.ts +148 -0
- package/src/server/dev/graph.ts +438 -0
- package/src/server/dev/plugin.ts +130 -0
- package/src/server/dev/request-security.ts +38 -0
- package/src/server/dev/rewrite-module-specifiers.ts +81 -0
- package/src/server/dev/runtime.production.ts +24 -0
- package/src/server/dev/symbolicate.ts +135 -0
- package/src/server/dev/transform-failure.ts +8 -0
- package/src/server/dev-page-plugin.production.ts +3 -0
- package/src/server/dev-page-plugin.ts +92 -53
- package/src/server/devtools/hub.ts +6 -5
- package/src/server/devtools/instrumentation.production.ts +1 -1
- package/src/server/devtools/instrumentation.ts +12 -6
- package/src/server/devtools/plugin.ts +7 -150
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +39 -2
- package/src/server/render/assemble.ts +4 -4
- package/src/server/render/document.tsx +13 -4
- package/src/server/render/element.tsx +18 -14
- package/src/server/render/index.ts +1 -1
- package/src/server/render/isr.ts +44 -19
- package/src/server/render/loaders.ts +13 -3
- package/src/server/render/not-found.ts +28 -4
- package/src/server/render/ppr-document.ts +239 -0
- package/src/server/render/ppr-request.ts +104 -0
- package/src/server/render/ppr-route.ts +152 -31
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +38 -20
- package/src/server/render/ssr.ts +211 -83
- package/src/server/render/template.ts +47 -11
- package/src/server/router/defined-route.ts +7 -39
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +106 -67
- package/src/server/router/patterns.ts +5 -1
- package/src/server/router/plugin.ts +124 -35
- package/src/server/router/source-version.ts +3 -10
- package/src/server/sync/adapter.ts +13 -0
- package/src/server/sync/config.ts +12 -12
- package/src/server/sync/index.ts +8 -8
- package/src/server/sync/notifier.ts +1 -0
- package/src/server/sync/plugin.ts +4 -1
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/runtime.ts +12 -0
- package/src/server/sync/stream.ts +78 -113
- package/src/shared/await.tsx +3 -3
- package/src/shared/browser-events.ts +28 -0
- package/src/shared/compact-json.ts +77 -0
- package/src/shared/deferred-ndjson.ts +20 -6
- package/src/shared/dev-diagnostics.ts +44 -0
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +10 -1
package/dist/plugin/index.js
CHANGED
|
@@ -1267,7 +1267,7 @@ var MagicString = class MagicString {
|
|
|
1267
1267
|
return this._replaceRegexp(searchValue, replacement);
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
|
-
// ../../node_modules/.bun/yuku-ast@0.9.
|
|
1270
|
+
// ../../node_modules/.bun/yuku-ast@0.9.5/node_modules/yuku-ast/dist/aliases.js
|
|
1271
1271
|
var ALIAS_GROUPS = {
|
|
1272
1272
|
Expression: [
|
|
1273
1273
|
"Identifier",
|
|
@@ -1423,7 +1423,7 @@ var ALIAS_GROUPS = {
|
|
|
1423
1423
|
};
|
|
1424
1424
|
var ALIAS_NAMES = Object.keys(ALIAS_GROUPS);
|
|
1425
1425
|
|
|
1426
|
-
// ../../node_modules/.bun/yuku-ast@0.9.
|
|
1426
|
+
// ../../node_modules/.bun/yuku-ast@0.9.5/node_modules/yuku-ast/dist/context.js
|
|
1427
1427
|
class WalkContext {
|
|
1428
1428
|
_ancestors = [];
|
|
1429
1429
|
_node = null;
|
|
@@ -1491,7 +1491,7 @@ class WalkContext {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
1493
|
|
|
1494
|
-
// ../../node_modules/.bun/yuku-ast@0.9.
|
|
1494
|
+
// ../../node_modules/.bun/yuku-ast@0.9.5/node_modules/yuku-ast/dist/generated.js
|
|
1495
1495
|
var KEYS = Object.create(null);
|
|
1496
1496
|
function ck(type, keys) {
|
|
1497
1497
|
const prev = KEYS[type];
|
|
@@ -1863,7 +1863,7 @@ var TYPES = [
|
|
|
1863
1863
|
];
|
|
1864
1864
|
var NODE_TYPES = [...new Set(TYPES)];
|
|
1865
1865
|
|
|
1866
|
-
// ../../node_modules/.bun/yuku-ast@0.9.
|
|
1866
|
+
// ../../node_modules/.bun/yuku-ast@0.9.5/node_modules/yuku-ast/dist/walk.js
|
|
1867
1867
|
function createDispatch(visitors) {
|
|
1868
1868
|
let enter = null;
|
|
1869
1869
|
let leave = null;
|
|
@@ -2513,7 +2513,18 @@ function transformIsomorphicFunctions(source, filename, environment) {
|
|
|
2513
2513
|
// src/plugin/transform-client.ts
|
|
2514
2514
|
var FURIN_CLIENT_MODULES = new Set(["@teyik0/furin/client", "furin/client"]);
|
|
2515
2515
|
var FURIN_SERVER_MODULES = new Set(["@teyik0/furin", "furin"]);
|
|
2516
|
+
var REACT_COMPONENT_WRAPPERS = new Set(["forwardRef", "memo"]);
|
|
2516
2517
|
var SERVER_ONLY_METHODS = new Set(["config", "head", "loader", "requestLoader", "staticParams"]);
|
|
2518
|
+
var REACT_HOOK_NAME_RE = /^use[A-Z0-9]/;
|
|
2519
|
+
var HMR_DATA_SIGNATURE = "furin.hmr.data-signature";
|
|
2520
|
+
var TYPESCRIPT_RUNTIME_WRAPPERS = new Map([
|
|
2521
|
+
["TSAsExpression", ["expression"]],
|
|
2522
|
+
["TSInstantiationExpression", ["expression"]],
|
|
2523
|
+
["TSNonNullExpression", ["expression"]],
|
|
2524
|
+
["TSParameterProperty", ["decorators", "parameter"]],
|
|
2525
|
+
["TSSatisfiesExpression", ["expression"]],
|
|
2526
|
+
["TSTypeAssertion", ["expression"]]
|
|
2527
|
+
]);
|
|
2517
2528
|
function isFurinRouteModule(source) {
|
|
2518
2529
|
return typeof source === "string" && (FURIN_SERVER_MODULES.has(source) || FURIN_CLIENT_MODULES.has(source));
|
|
2519
2530
|
}
|
|
@@ -2637,6 +2648,429 @@ function removeChainedServerCalls(source, program, bindings) {
|
|
|
2637
2648
|
});
|
|
2638
2649
|
return transformed;
|
|
2639
2650
|
}
|
|
2651
|
+
function collectBindingNames(pattern, names) {
|
|
2652
|
+
const node = asAstNode(pattern);
|
|
2653
|
+
if (!node) {
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
if (node.type === "Identifier" && typeof node.name === "string") {
|
|
2657
|
+
names.push(node.name);
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
if (node.type === "AssignmentPattern") {
|
|
2661
|
+
collectBindingNames(node.left, names);
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
if (node.type === "RestElement") {
|
|
2665
|
+
collectBindingNames(node.argument, names);
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
if (node.type === "ArrayPattern" && Array.isArray(node.elements)) {
|
|
2669
|
+
for (const element of node.elements) {
|
|
2670
|
+
collectBindingNames(element, names);
|
|
2671
|
+
}
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
if (node.type === "ObjectPattern" && Array.isArray(node.properties)) {
|
|
2675
|
+
for (const property of node.properties) {
|
|
2676
|
+
const propertyNode = asAstNode(property);
|
|
2677
|
+
collectBindingNames(propertyNode?.type === "Property" ? propertyNode.value : propertyNode?.argument, names);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
function collectDeclarationBindings(declaration, declarations) {
|
|
2682
|
+
if (declaration?.type === "FunctionDeclaration" || declaration?.type === "ClassDeclaration") {
|
|
2683
|
+
const identifier = asAstNode(declaration.id);
|
|
2684
|
+
if (identifier?.type === "Identifier" && typeof identifier.name === "string") {
|
|
2685
|
+
declarations.set(identifier.name, declaration);
|
|
2686
|
+
}
|
|
2687
|
+
return;
|
|
2688
|
+
}
|
|
2689
|
+
if (declaration?.type !== "VariableDeclaration" || !Array.isArray(declaration.declarations)) {
|
|
2690
|
+
return;
|
|
2691
|
+
}
|
|
2692
|
+
for (const item of declaration.declarations) {
|
|
2693
|
+
const names = [];
|
|
2694
|
+
collectBindingNames(item.id, names);
|
|
2695
|
+
for (const name of names) {
|
|
2696
|
+
declarations.set(name, item);
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
function collectModuleBindings(program) {
|
|
2701
|
+
const declarations = new Map;
|
|
2702
|
+
const imports = new Set;
|
|
2703
|
+
for (const statement of program.body) {
|
|
2704
|
+
if (statement.type === "ImportDeclaration" && Array.isArray(statement.specifiers)) {
|
|
2705
|
+
for (const specifier of statement.specifiers) {
|
|
2706
|
+
const local = localName2(specifier);
|
|
2707
|
+
if (local) {
|
|
2708
|
+
imports.add(local);
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
const declaration = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" ? asAstNode(statement.declaration) : statement;
|
|
2714
|
+
collectDeclarationBindings(declaration, declarations);
|
|
2715
|
+
}
|
|
2716
|
+
return { declarations, imports };
|
|
2717
|
+
}
|
|
2718
|
+
function isBindingIdentifier(identifier, pattern) {
|
|
2719
|
+
const node = asAstNode(pattern);
|
|
2720
|
+
if (!node) {
|
|
2721
|
+
return false;
|
|
2722
|
+
}
|
|
2723
|
+
if (node.type === "Identifier") {
|
|
2724
|
+
return node.start === identifier.start && node.end === identifier.end;
|
|
2725
|
+
}
|
|
2726
|
+
if (node.type === "AssignmentPattern") {
|
|
2727
|
+
return isBindingIdentifier(identifier, node.left);
|
|
2728
|
+
}
|
|
2729
|
+
if (node.type === "RestElement") {
|
|
2730
|
+
return isBindingIdentifier(identifier, node.argument);
|
|
2731
|
+
}
|
|
2732
|
+
if (node.type === "ArrayPattern" && Array.isArray(node.elements)) {
|
|
2733
|
+
return node.elements.some((element) => isBindingIdentifier(identifier, element));
|
|
2734
|
+
}
|
|
2735
|
+
if (node.type === "ObjectPattern" && Array.isArray(node.properties)) {
|
|
2736
|
+
return node.properties.some((property) => {
|
|
2737
|
+
const propertyNode = asAstNode(property);
|
|
2738
|
+
return isBindingIdentifier(identifier, propertyNode?.type === "Property" ? propertyNode.value : propertyNode?.argument);
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
return false;
|
|
2742
|
+
}
|
|
2743
|
+
function nodeContains(container, node) {
|
|
2744
|
+
if (Array.isArray(container)) {
|
|
2745
|
+
return container.some((entry) => nodeContains(entry, node));
|
|
2746
|
+
}
|
|
2747
|
+
const containerNode = asAstNode(container);
|
|
2748
|
+
return Boolean(containerNode && containerNode.start <= node.start && node.end <= containerNode.end);
|
|
2749
|
+
}
|
|
2750
|
+
function isTypePosition(node, ancestors) {
|
|
2751
|
+
return ancestors.some((ancestor) => {
|
|
2752
|
+
if (!ancestor.type.startsWith("TS")) {
|
|
2753
|
+
return false;
|
|
2754
|
+
}
|
|
2755
|
+
const runtimeChildren = TYPESCRIPT_RUNTIME_WRAPPERS.get(ancestor.type);
|
|
2756
|
+
if (runtimeChildren) {
|
|
2757
|
+
return !runtimeChildren.some((key) => nodeContains(ancestor[key], node));
|
|
2758
|
+
}
|
|
2759
|
+
return true;
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
function isNonReferenceKey(node, parent) {
|
|
2763
|
+
return Boolean(parent && (parent.type === "MemberExpression" && parent.computed !== true && parent.property === node || parent.type === "Property" && parent.computed !== true && parent.shorthand !== true && parent.key === node || (parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.computed !== true && parent.key === node || (parent.type === "LabeledStatement" || parent.type === "BreakStatement" || parent.type === "ContinueStatement") && parent.label === node));
|
|
2764
|
+
}
|
|
2765
|
+
function isReferenceIdentifier(node, ancestors) {
|
|
2766
|
+
if (isTypePosition(node, ancestors) || isNonReferenceKey(node, ancestors.at(-1))) {
|
|
2767
|
+
return false;
|
|
2768
|
+
}
|
|
2769
|
+
for (const ancestor of ancestors) {
|
|
2770
|
+
if (ancestor.type === "VariableDeclarator" && isBindingIdentifier(node, ancestor.id) || (ancestor.type === "FunctionDeclaration" || ancestor.type === "FunctionExpression" || ancestor.type === "ArrowFunctionExpression") && (isBindingIdentifier(node, ancestor.id) || Array.isArray(ancestor.params) && ancestor.params.some((parameter) => isBindingIdentifier(node, parameter))) || ancestor.type === "ClassDeclaration" && isBindingIdentifier(node, ancestor.id) || ancestor.type === "CatchClause" && isBindingIdentifier(node, ancestor.param)) {
|
|
2771
|
+
return false;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
return true;
|
|
2775
|
+
}
|
|
2776
|
+
function walkWithAncestors(value, ancestors, visitor) {
|
|
2777
|
+
if (Array.isArray(value)) {
|
|
2778
|
+
for (const entry of value) {
|
|
2779
|
+
walkWithAncestors(entry, ancestors, visitor);
|
|
2780
|
+
}
|
|
2781
|
+
return;
|
|
2782
|
+
}
|
|
2783
|
+
const node = asAstNode(value);
|
|
2784
|
+
if (!node) {
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
visitor(node, ancestors);
|
|
2788
|
+
const nextAncestors = [...ancestors, node];
|
|
2789
|
+
for (const [key, child] of Object.entries(node)) {
|
|
2790
|
+
if (key !== "type" && key !== "start" && key !== "end" && key !== "comments") {
|
|
2791
|
+
walkWithAncestors(child, nextAncestors, visitor);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
function collectDependencyIdentifier(child, ancestors, trackImports, state) {
|
|
2796
|
+
if (child.type !== "Identifier" || typeof child.name !== "string" || !isReferenceIdentifier(child, ancestors) || hasShadowingDeclaration(child.name, ancestors)) {
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
const declaration = state.moduleBindings.declarations.get(child.name);
|
|
2800
|
+
if (!declaration) {
|
|
2801
|
+
if (trackImports && state.moduleBindings.imports.has(child.name)) {
|
|
2802
|
+
state.hasUnresolvedImport = true;
|
|
2803
|
+
}
|
|
2804
|
+
return;
|
|
2805
|
+
}
|
|
2806
|
+
const alreadyTracked = state.dependencies.has(declaration.start);
|
|
2807
|
+
if (!alreadyTracked) {
|
|
2808
|
+
state.dependencies.set(declaration.start, declaration);
|
|
2809
|
+
}
|
|
2810
|
+
if (trackImports) {
|
|
2811
|
+
if (state.importTrackedDependencies.has(declaration.start)) {
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
state.importTrackedDependencies.add(declaration.start);
|
|
2815
|
+
} else if (alreadyTracked) {
|
|
2816
|
+
return;
|
|
2817
|
+
}
|
|
2818
|
+
collectDependencies(declaration, trackImports, state);
|
|
2819
|
+
}
|
|
2820
|
+
function collectDependencies(node, trackImports, state) {
|
|
2821
|
+
walkWithAncestors(node, [], (child, ancestors) => {
|
|
2822
|
+
collectDependencyIdentifier(child, ancestors, trackImports, state);
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
function createHmrDataSignature(code, program, bindings) {
|
|
2826
|
+
const serverStages = [];
|
|
2827
|
+
const dependencyState = {
|
|
2828
|
+
dependencies: new Map,
|
|
2829
|
+
hasUnresolvedImport: false,
|
|
2830
|
+
importTrackedDependencies: new Set,
|
|
2831
|
+
moduleBindings: collectModuleBindings(program)
|
|
2832
|
+
};
|
|
2833
|
+
walk(program, {
|
|
2834
|
+
CallExpression(call, context) {
|
|
2835
|
+
const callee = asAstNode(call.callee);
|
|
2836
|
+
if (callee?.type !== "MemberExpression" || callee.computed === true || !callee.property || typeof callee.property !== "object") {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
const property = callee.property;
|
|
2840
|
+
if (property.type !== "Identifier" || typeof property.name !== "string" || !SERVER_ONLY_METHODS.has(property.name) || !chainRootIsDefineRoute(callee.object, bindings, context.ancestors())) {
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
const object = asAstNode(callee.object);
|
|
2844
|
+
if (!object) {
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
serverStages.push({
|
|
2848
|
+
source: code.slice(object.end, call.end),
|
|
2849
|
+
start: call.start
|
|
2850
|
+
});
|
|
2851
|
+
if (Array.isArray(call.arguments)) {
|
|
2852
|
+
for (const argument of call.arguments) {
|
|
2853
|
+
const argumentNode = asAstNode(argument);
|
|
2854
|
+
if (argumentNode) {
|
|
2855
|
+
collectDependencies(argumentNode, property.name !== "config", dependencyState);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
});
|
|
2861
|
+
const dataSource = [
|
|
2862
|
+
...serverStages,
|
|
2863
|
+
...[...dependencyState.dependencies.values()].map((dependency) => ({
|
|
2864
|
+
source: code.slice(dependency.start, dependency.end),
|
|
2865
|
+
start: dependency.start
|
|
2866
|
+
}))
|
|
2867
|
+
].sort((left, right) => left.start - right.start).map((entry) => entry.source).join(`
|
|
2868
|
+
`);
|
|
2869
|
+
const hash = new Bun.CryptoHasher("sha256").update(dataSource).digest("hex");
|
|
2870
|
+
return dependencyState.hasUnresolvedImport ? `external:${hash}` : hash;
|
|
2871
|
+
}
|
|
2872
|
+
function calledHookName(call) {
|
|
2873
|
+
const callee = asAstNode(call.callee);
|
|
2874
|
+
if (callee?.type === "Identifier" && typeof callee.name === "string") {
|
|
2875
|
+
return REACT_HOOK_NAME_RE.test(callee.name) ? callee.name : null;
|
|
2876
|
+
}
|
|
2877
|
+
if (callee?.type === "MemberExpression" && callee.computed !== true && callee.property && typeof callee.property === "object") {
|
|
2878
|
+
const property = callee.property;
|
|
2879
|
+
if (property.type === "Identifier" && typeof property.name === "string" && REACT_HOOK_NAME_RE.test(property.name)) {
|
|
2880
|
+
return property.name;
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
return null;
|
|
2884
|
+
}
|
|
2885
|
+
function routeComponentExpression(program, bindings) {
|
|
2886
|
+
let component = null;
|
|
2887
|
+
walk(program, {
|
|
2888
|
+
CallExpression(call, context) {
|
|
2889
|
+
const callee = asAstNode(call.callee);
|
|
2890
|
+
if (callee?.type !== "MemberExpression" || callee.computed === true || !callee.property || typeof callee.property !== "object") {
|
|
2891
|
+
return;
|
|
2892
|
+
}
|
|
2893
|
+
const property = callee.property;
|
|
2894
|
+
const ancestors = context.ancestors();
|
|
2895
|
+
const routeDeclarator = ancestors.find((ancestor) => {
|
|
2896
|
+
if (ancestor.type !== "VariableDeclarator") {
|
|
2897
|
+
return false;
|
|
2898
|
+
}
|
|
2899
|
+
const identifier = asAstNode(ancestor.id);
|
|
2900
|
+
return identifier?.type === "Identifier" && identifier.name === "route";
|
|
2901
|
+
});
|
|
2902
|
+
if (!(routeDeclarator && ancestors.some((ancestor) => ancestor.type === "ExportNamedDeclaration")) || property.type !== "Identifier" || property.name !== "page" && property.name !== "layout" || !chainRootIsDefineRoute(callee.object, bindings, ancestors)) {
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
const args = call.arguments;
|
|
2906
|
+
component = Array.isArray(args) ? asAstNode(args[0]) : null;
|
|
2907
|
+
context.stop();
|
|
2908
|
+
}
|
|
2909
|
+
});
|
|
2910
|
+
return component;
|
|
2911
|
+
}
|
|
2912
|
+
function namedFunction(declaration, name) {
|
|
2913
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
2914
|
+
const identifier = asAstNode(declaration.id);
|
|
2915
|
+
return identifier?.type === "Identifier" && identifier.name === name ? declaration : null;
|
|
2916
|
+
}
|
|
2917
|
+
if (declaration.type === "VariableDeclaration" && Array.isArray(declaration.declarations)) {
|
|
2918
|
+
for (const item of declaration.declarations) {
|
|
2919
|
+
const identifier = asAstNode(item.id);
|
|
2920
|
+
const initializer = asAstNode(item.init);
|
|
2921
|
+
if (identifier?.type === "Identifier" && identifier.name === name && (initializer?.type === "ArrowFunctionExpression" || initializer?.type === "FunctionExpression")) {
|
|
2922
|
+
return initializer;
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
return null;
|
|
2927
|
+
}
|
|
2928
|
+
function localFunction(program, name) {
|
|
2929
|
+
for (const statement of program.body) {
|
|
2930
|
+
const declaration = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" ? asAstNode(statement.declaration) : statement;
|
|
2931
|
+
const component = declaration ? namedFunction(declaration, name) : null;
|
|
2932
|
+
if (component) {
|
|
2933
|
+
return component;
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
return null;
|
|
2937
|
+
}
|
|
2938
|
+
function isImportedBinding(program, name) {
|
|
2939
|
+
return program.body.some((statement) => statement.type === "ImportDeclaration" && statement.importKind !== "type" && statement.specifiers.some((specifier) => specifier.importKind !== "type" && localName2(specifier) === name));
|
|
2940
|
+
}
|
|
2941
|
+
function collectReactWrapperBindings(program) {
|
|
2942
|
+
const bindings = {
|
|
2943
|
+
members: new Set,
|
|
2944
|
+
namespaces: new Set
|
|
2945
|
+
};
|
|
2946
|
+
for (const statement of program.body) {
|
|
2947
|
+
if (statement.type !== "ImportDeclaration" || statement.source.value !== "react") {
|
|
2948
|
+
continue;
|
|
2949
|
+
}
|
|
2950
|
+
for (const specifier of statement.specifiers) {
|
|
2951
|
+
const local = localName2(specifier);
|
|
2952
|
+
if (!local || specifier.importKind === "type") {
|
|
2953
|
+
continue;
|
|
2954
|
+
}
|
|
2955
|
+
const imported = importedName2(specifier);
|
|
2956
|
+
if (specifier.type === "ImportSpecifier" && imported && REACT_COMPONENT_WRAPPERS.has(imported)) {
|
|
2957
|
+
bindings.members.add(local);
|
|
2958
|
+
} else if (specifier.type === "ImportDefaultSpecifier" || specifier.type === "ImportNamespaceSpecifier" || specifier.type === "ImportSpecifier" && imported === "default") {
|
|
2959
|
+
bindings.namespaces.add(local);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
return bindings;
|
|
2964
|
+
}
|
|
2965
|
+
function wrappedComponentFunction(program, expression, bindings) {
|
|
2966
|
+
if (expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression") {
|
|
2967
|
+
return expression;
|
|
2968
|
+
}
|
|
2969
|
+
if (expression.type === "Identifier" && typeof expression.name === "string") {
|
|
2970
|
+
return localFunction(program, expression.name);
|
|
2971
|
+
}
|
|
2972
|
+
if (expression.type !== "CallExpression") {
|
|
2973
|
+
return null;
|
|
2974
|
+
}
|
|
2975
|
+
const callee = asAstNode(expression.callee);
|
|
2976
|
+
const isNamedWrapper = callee?.type === "Identifier" && typeof callee.name === "string" && bindings.members.has(callee.name);
|
|
2977
|
+
const object = callee?.type === "MemberExpression" ? asAstNode(callee.object) : null;
|
|
2978
|
+
const property = callee?.type === "MemberExpression" ? asAstNode(callee.property) : null;
|
|
2979
|
+
const isNamespaceWrapper = callee?.type === "MemberExpression" && callee.computed !== true && object?.type === "Identifier" && typeof object.name === "string" && bindings.namespaces.has(object.name) && property?.type === "Identifier" && typeof property.name === "string" && REACT_COMPONENT_WRAPPERS.has(property.name);
|
|
2980
|
+
if (!(isNamedWrapper || isNamespaceWrapper)) {
|
|
2981
|
+
return null;
|
|
2982
|
+
}
|
|
2983
|
+
const args = expression.arguments;
|
|
2984
|
+
const wrapped = Array.isArray(args) ? asAstNode(args[0]) : null;
|
|
2985
|
+
return wrapped ? wrappedComponentFunction(program, wrapped, bindings) : null;
|
|
2986
|
+
}
|
|
2987
|
+
function importedMemberBinding(program, expression) {
|
|
2988
|
+
let object = expression.type === "MemberExpression" ? asAstNode(expression.object) : null;
|
|
2989
|
+
while (object?.type === "MemberExpression") {
|
|
2990
|
+
object = asAstNode(object.object);
|
|
2991
|
+
}
|
|
2992
|
+
return object?.type === "Identifier" && typeof object.name === "string" && isImportedBinding(program, object.name) ? object.name : null;
|
|
2993
|
+
}
|
|
2994
|
+
function sourceText(code, node) {
|
|
2995
|
+
return node ? code.slice(node.start, node.end) : "";
|
|
2996
|
+
}
|
|
2997
|
+
function unusedIdentifier(program, preferred) {
|
|
2998
|
+
const identifiers = new Set;
|
|
2999
|
+
walk(program, {
|
|
3000
|
+
Identifier(node) {
|
|
3001
|
+
identifiers.add(node.name);
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
if (!identifiers.has(preferred)) {
|
|
3005
|
+
return preferred;
|
|
3006
|
+
}
|
|
3007
|
+
let suffix = 1;
|
|
3008
|
+
while (identifiers.has(`${preferred}_${suffix}`)) {
|
|
3009
|
+
suffix += 1;
|
|
3010
|
+
}
|
|
3011
|
+
return `${preferred}_${suffix}`;
|
|
3012
|
+
}
|
|
3013
|
+
function hookCallsiteSignature(code, call, hookName, parent) {
|
|
3014
|
+
let key = parent?.type === "VariableDeclarator" ? sourceText(code, asAstNode(parent.id)) : "";
|
|
3015
|
+
const args = call.arguments;
|
|
3016
|
+
const stateArgument = Array.isArray(args) ? asAstNode(args[0]) : null;
|
|
3017
|
+
const reducerArgument = Array.isArray(args) ? asAstNode(args[1]) : null;
|
|
3018
|
+
if (hookName === "useState" && stateArgument) {
|
|
3019
|
+
key += `(${sourceText(code, stateArgument)})`;
|
|
3020
|
+
} else if (hookName === "useReducer" && reducerArgument) {
|
|
3021
|
+
key += `(${sourceText(code, reducerArgument)})`;
|
|
3022
|
+
}
|
|
3023
|
+
return `${hookName}{${key}}`;
|
|
3024
|
+
}
|
|
3025
|
+
function collectFunctionHookSignature(code, component) {
|
|
3026
|
+
const hooks = [];
|
|
3027
|
+
walk(component, {
|
|
3028
|
+
CallExpression(call, context) {
|
|
3029
|
+
const callNode = call;
|
|
3030
|
+
const name = calledHookName(callNode);
|
|
3031
|
+
if (name) {
|
|
3032
|
+
hooks.push(hookCallsiteSignature(code, callNode, name, asAstNode(context.parent)));
|
|
3033
|
+
}
|
|
3034
|
+
},
|
|
3035
|
+
Function(node, context) {
|
|
3036
|
+
if (node !== component) {
|
|
3037
|
+
context.skip();
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
});
|
|
3041
|
+
return hooks;
|
|
3042
|
+
}
|
|
3043
|
+
function collectClientHookSignature(code, filename) {
|
|
3044
|
+
const lang = detectLangFromPath(filename);
|
|
3045
|
+
const { program } = parseSource(code, lang);
|
|
3046
|
+
const componentExpression = routeComponentExpression(program, collectDefineRouteBindings(program));
|
|
3047
|
+
if (!componentExpression) {
|
|
3048
|
+
return null;
|
|
3049
|
+
}
|
|
3050
|
+
const wrappedComponent = wrappedComponentFunction(program, componentExpression, collectReactWrapperBindings(program));
|
|
3051
|
+
if (wrappedComponent) {
|
|
3052
|
+
return collectFunctionHookSignature(code, wrappedComponent);
|
|
3053
|
+
}
|
|
3054
|
+
if (componentExpression.type !== "Identifier" || typeof componentExpression.name !== "string") {
|
|
3055
|
+
if (importedMemberBinding(program, componentExpression)) {
|
|
3056
|
+
return {
|
|
3057
|
+
end: componentExpression.end,
|
|
3058
|
+
expression: sourceText(code, componentExpression),
|
|
3059
|
+
start: componentExpression.start
|
|
3060
|
+
};
|
|
3061
|
+
}
|
|
3062
|
+
return collectFunctionHookSignature(code, componentExpression);
|
|
3063
|
+
}
|
|
3064
|
+
const component = localFunction(program, componentExpression.name);
|
|
3065
|
+
if (component) {
|
|
3066
|
+
return collectFunctionHookSignature(code, component);
|
|
3067
|
+
}
|
|
3068
|
+
return isImportedBinding(program, componentExpression.name) ? {
|
|
3069
|
+
end: componentExpression.end,
|
|
3070
|
+
expression: componentExpression.name,
|
|
3071
|
+
start: componentExpression.start
|
|
3072
|
+
} : "external";
|
|
3073
|
+
}
|
|
2640
3074
|
function transformForClient(code, filename) {
|
|
2641
3075
|
const lang = detectLangFromPath(filename);
|
|
2642
3076
|
if (lang === "dts") {
|
|
@@ -2656,13 +3090,48 @@ function transformForClient(code, filename) {
|
|
|
2656
3090
|
if (removedServerCode) {
|
|
2657
3091
|
source = deadCodeElimination(source, code, lang);
|
|
2658
3092
|
}
|
|
2659
|
-
|
|
3093
|
+
const transformedCode = source.toString();
|
|
3094
|
+
let hookSignature = routeBindings.size > 0 ? collectClientHookSignature(transformedCode, filename) : null;
|
|
3095
|
+
if (hookSignature && typeof hookSignature === "object" && !Array.isArray(hookSignature)) {
|
|
3096
|
+
const createElementBinding = unusedIdentifier(program, "__furinCreateElement");
|
|
3097
|
+
source = new MagicString(transformedCode);
|
|
3098
|
+
source.prepend(`import { createElement as ${createElementBinding} } from "react";
|
|
3099
|
+
`);
|
|
3100
|
+
source.update(hookSignature.start, hookSignature.end, `(import.meta.hot ? (props) => ${createElementBinding}(${hookSignature.expression}, props) : ${hookSignature.expression})`);
|
|
3101
|
+
hookSignature = [];
|
|
3102
|
+
}
|
|
3103
|
+
if (routeBindings.size > 0 && hookSignature !== null) {
|
|
3104
|
+
const originalParse = parseSource(code, lang);
|
|
3105
|
+
const originalError = originalParse.diagnostics.find((diagnostic) => diagnostic.severity === "error");
|
|
3106
|
+
if (originalError) {
|
|
3107
|
+
throw new Error(`Failed to parse ${filename}: ${originalError.message}`);
|
|
3108
|
+
}
|
|
3109
|
+
const hmrDataSignature = createHmrDataSignature(code, originalParse.program, collectDefineRouteBindings(originalParse.program));
|
|
3110
|
+
const signatureValue = Array.isArray(hookSignature) ? JSON.stringify(hookSignature) : 'route.component[Symbol.for("furin.hmr.hook-signature")] ?? [String(route.component)]';
|
|
2660
3111
|
source.append(`
|
|
2661
|
-
if (import.meta.hot) {
|
|
3112
|
+
if (import.meta.hot && route?.component) {
|
|
3113
|
+
const previousDataSignature = ${JSON.stringify(hmrDataSignature)};
|
|
3114
|
+
Object.defineProperty(route, Symbol.for(${JSON.stringify(HMR_DATA_SIGNATURE)}), {
|
|
3115
|
+
configurable: true,
|
|
3116
|
+
value: previousDataSignature,
|
|
3117
|
+
});
|
|
3118
|
+
Object.defineProperty(route.component, Symbol.for("furin.hmr.hook-signature"), {
|
|
3119
|
+
configurable: true,
|
|
3120
|
+
value: ${signatureValue},
|
|
3121
|
+
});
|
|
2662
3122
|
import.meta.hot.accept((updatedModule) => {
|
|
2663
3123
|
const updatedRoute = updatedModule?.route;
|
|
2664
3124
|
if (updatedRoute?.component) {
|
|
2665
|
-
|
|
3125
|
+
const updatedDataSignature = Reflect.get(
|
|
3126
|
+
updatedRoute,
|
|
3127
|
+
Symbol.for(${JSON.stringify(HMR_DATA_SIGNATURE)})
|
|
3128
|
+
);
|
|
3129
|
+
const dataChanged =
|
|
3130
|
+
previousDataSignature.startsWith("external:") ||
|
|
3131
|
+
typeof updatedDataSignature !== "string" ||
|
|
3132
|
+
updatedDataSignature.startsWith("external:") ||
|
|
3133
|
+
updatedDataSignature !== previousDataSignature;
|
|
3134
|
+
window.__FURIN_HMR_UPDATE__?.(${JSON.stringify(filename)}, updatedRoute.component, dataChanged);
|
|
2666
3135
|
}
|
|
2667
3136
|
});
|
|
2668
3137
|
}
|
package/dist/plugin/routes.d.ts
CHANGED
|
@@ -8,12 +8,13 @@ export interface CreateRoutesPluginOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export interface DevRouteTopologyWatcher {
|
|
10
10
|
close: () => void;
|
|
11
|
+
refresh: () => Promise<void>;
|
|
11
12
|
}
|
|
12
13
|
export interface DevRouteTopologyWatcherOptions {
|
|
13
14
|
instance: RouteInstanceSpec;
|
|
14
|
-
onRouteFilesTouched?: () => Promise<void> | void;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
onRouteFilesTouched?: (sourcePaths: readonly string[]) => Promise<void> | void;
|
|
16
|
+
onSourceError?: (error: unknown, sourcePath: string) => void;
|
|
17
|
+
onTopologyChange: (sourcePaths: readonly string[]) => Promise<void> | void;
|
|
17
18
|
}
|
|
18
19
|
export declare function routeModuleSpecifier(instance: RouteInstanceSpec): string;
|
|
19
20
|
export declare function routeSourcePaths(instance: RouteInstanceSpec): string[];
|
|
@@ -12,4 +12,8 @@ export interface RscManifest {
|
|
|
12
12
|
clientReferences: readonly ClientReference[];
|
|
13
13
|
css: readonly RscCssAsset[];
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export interface RscBuildApp {
|
|
16
|
+
root: RootLayout;
|
|
17
|
+
routes: ResolvedRoute[];
|
|
18
|
+
}
|
|
19
|
+
export declare function buildRscGraph(apps: RscBuildApp[], outDir: string, buildId: string, userPlugins: Bun.BunPlugin[] | undefined): Promise<RscManifest>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AnyElysia } from "elysia";
|
|
2
|
+
import type { FurinSyncOptions } from "../sync/config.ts";
|
|
3
|
+
import type { BrowserEventSource } from "./types.ts";
|
|
4
|
+
interface BrowserEventsPluginOptions {
|
|
5
|
+
sources?: readonly BrowserEventSource[];
|
|
6
|
+
sync?: FurinSyncOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function createBrowserEventsPlugin(options: BrowserEventsPluginOptions): AnyElysia;
|
|
9
|
+
export declare function browserEventsClientScript(basePath: string): string;
|
|
10
|
+
export declare function injectBrowserEventsClient(html: string, basePath: string): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BrowserEventEnvelope } from "../../shared/browser-events.ts";
|
|
2
|
+
export interface BrowserEventSubscription {
|
|
3
|
+
unsubscribe: () => void;
|
|
4
|
+
}
|
|
5
|
+
export interface BrowserEventSource {
|
|
6
|
+
subscribe: (listener: (event: Exclude<BrowserEventEnvelope, {
|
|
7
|
+
channel: "sync";
|
|
8
|
+
}>) => void) => Promise<BrowserEventSubscription> | BrowserEventSubscription;
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type FurinInstance } from "../instance.ts";
|
|
2
|
+
import { type CachePurger } from "./purger.ts";
|
|
2
3
|
import type { RevalidateType } from "./route-cache";
|
|
3
4
|
export declare function _runWithRequestInvalidationScope<T>(fn: () => T): T;
|
|
4
5
|
export declare function consumePendingInvalidations(): string[];
|
|
5
6
|
export declare function peekPendingInvalidations(): string[];
|
|
6
|
-
type CachePurger = (paths: string[]) => Promise<void>;
|
|
7
7
|
export declare function setCachePurger(fn: CachePurger): void;
|
|
8
8
|
export declare function callCachePurger(paths: string[]): void;
|
|
9
9
|
/**
|
|
@@ -27,4 +27,3 @@ export declare function revalidatePathForInstance(instance: FurinInstance, path:
|
|
|
27
27
|
};
|
|
28
28
|
/** @internal — resets all module state between tests */
|
|
29
29
|
export declare function __resetCacheState(): void;
|
|
30
|
-
export {};
|
|
@@ -16,4 +16,5 @@ export declare function releaseISRCacheGeneration(key: string, generation: ISRCa
|
|
|
16
16
|
export declare function setISRCacheIfGenerationUnchanged(key: string, entry: ISRCacheEntry, generation: ISRCacheGeneration): boolean;
|
|
17
17
|
export declare function pendingISRRevalidations(): Map<string, Promise<void>>;
|
|
18
18
|
export declare function clearPendingISRRevalidations(instance?: FurinInstance): void;
|
|
19
|
+
export declare function hasPendingISRRevalidations(): boolean;
|
|
19
20
|
export declare function waitForPendingISRRevalidations(): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type CachePurger = (keys: string[]) => Promise<void>;
|
|
2
|
+
export declare function setCachePurger(purger: CachePurger): void;
|
|
3
|
+
/** Deployment-only semantic tag hook; the public CDN hook remains path-only. */
|
|
4
|
+
export declare function setCacheTagPurger(purger: CachePurger): void;
|
|
5
|
+
export declare function callCachePurger(paths: string[]): void;
|
|
6
|
+
export declare function callCacheTagPurger(tags: string[]): void;
|
|
7
|
+
export declare function resetCachePurgers(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RuntimeCacheOptions {
|
|
2
|
+
namespace?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface RuntimeCacheSetOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
tags?: string[];
|
|
7
|
+
ttl?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RuntimeCache {
|
|
10
|
+
delete: (key: string) => Promise<void>;
|
|
11
|
+
expireTag: (tag: string | string[]) => Promise<void>;
|
|
12
|
+
get: (key: string) => Promise<unknown | null>;
|
|
13
|
+
set: (key: string, value: unknown, options?: RuntimeCacheSetOptions) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface RuntimeCacheProvider {
|
|
16
|
+
getCache: (options: RuntimeCacheOptions | undefined) => RuntimeCache;
|
|
17
|
+
}
|
|
18
|
+
export declare function getCache(options?: RuntimeCacheOptions): RuntimeCache;
|
|
19
|
+
export declare function setRuntimeCacheProvider(provider: RuntimeCacheProvider): void;
|
|
20
|
+
export declare function hasExternalRuntimeCache(): boolean;
|
|
21
|
+
export declare function resetRuntimeCacheProvider(): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BrowserEventSource } from "../browser-events/types.ts";
|
|
2
|
+
import type { FurinInstance } from "../instance.ts";
|
|
3
|
+
import type { DevDiagnosticStore } from "./diagnostics.ts";
|
|
4
|
+
export declare function createDevelopmentBrowserEventSources(instance: FurinInstance, diagnostics: DevDiagnosticStore): readonly BrowserEventSource[];
|