@bleedingdev/modern-js-runtime 3.2.0-ultramodern.101 → 3.2.0-ultramodern.103
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/cjs/boundary-debugger/index.js +9 -5
- package/dist/cjs/cache/index.js +9 -5
- package/dist/cjs/cli/alias.js +9 -5
- package/dist/cjs/cli/code.js +9 -5
- package/dist/cjs/cli/constants.js +20 -16
- package/dist/cjs/cli/entry.js +9 -5
- package/dist/cjs/cli/index.js +9 -5
- package/dist/cjs/cli/ssr/index.js +9 -5
- package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +9 -5
- package/dist/cjs/cli/ssr/mode.js +12 -8
- package/dist/cjs/cli/template.js +9 -5
- package/dist/cjs/cli/template.server.js +9 -5
- package/dist/cjs/common.js +14 -10
- package/dist/cjs/core/browser/hydrate.js +9 -5
- package/dist/cjs/core/browser/index.js +9 -5
- package/dist/cjs/core/browser/withCallback.js +9 -5
- package/dist/cjs/core/compat/hooks.js +14 -10
- package/dist/cjs/core/compat/index.js +9 -5
- package/dist/cjs/core/compat/requestContext.js +13 -9
- package/dist/cjs/core/config.js +12 -8
- package/dist/cjs/core/constants.js +15 -10
- package/dist/cjs/core/context/index.js +9 -5
- package/dist/cjs/core/context/monitors/default.js +12 -8
- package/dist/cjs/core/context/monitors/index.js +9 -5
- package/dist/cjs/core/context/monitors/index.server.js +9 -5
- package/dist/cjs/core/context/request/index.js +12 -8
- package/dist/cjs/core/context/request/index.server.js +9 -5
- package/dist/cjs/core/context/response/index.js +15 -11
- package/dist/cjs/core/context/response/index.server.js +9 -5
- package/dist/cjs/core/context/runtime.js +9 -5
- package/dist/cjs/core/context/serverPayload/index.js +13 -9
- package/dist/cjs/core/context/serverPayload/index.server.js +9 -5
- package/dist/cjs/core/index.js +9 -5
- package/dist/cjs/core/plugin/index.js +9 -5
- package/dist/cjs/core/react/index.js +9 -5
- package/dist/cjs/core/react/wrapper.js +9 -5
- package/dist/cjs/core/server/constants.js +15 -11
- package/dist/cjs/core/server/federatedCss.js +9 -5
- package/dist/cjs/core/server/helmet.js +9 -5
- package/dist/cjs/core/server/index.js +9 -5
- package/dist/cjs/core/server/react/index.js +9 -5
- package/dist/cjs/core/server/react/no-ssr-cache/index.js +9 -5
- package/dist/cjs/core/server/react/nossr/index.js +9 -5
- package/dist/cjs/core/server/requestHandler.js +9 -5
- package/dist/cjs/core/server/scriptOrder.js +12 -8
- package/dist/cjs/core/server/server.js +9 -5
- package/dist/cjs/core/server/shared.js +12 -8
- package/dist/cjs/core/server/stream/afterTemplate.js +9 -5
- package/dist/cjs/core/server/stream/beforeTemplate.js +9 -5
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +9 -5
- package/dist/cjs/core/server/stream/createReadableStream.js +9 -5
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +9 -5
- package/dist/cjs/core/server/stream/deferredScript.js +9 -5
- package/dist/cjs/core/server/stream/index.js +9 -5
- package/dist/cjs/core/server/stream/shared.js +9 -5
- package/dist/cjs/core/server/stream/template.js +9 -5
- package/dist/cjs/core/server/string/index.js +9 -5
- package/dist/cjs/core/server/string/loadable.js +9 -5
- package/dist/cjs/core/server/string/ssrData.js +9 -5
- package/dist/cjs/core/server/tracer.js +13 -9
- package/dist/cjs/core/server/utils.js +9 -5
- package/dist/cjs/document/Body.js +9 -5
- package/dist/cjs/document/Comment.js +9 -5
- package/dist/cjs/document/DocumentContext.js +9 -5
- package/dist/cjs/document/DocumentStructureContext.js +9 -5
- package/dist/cjs/document/Head.js +9 -5
- package/dist/cjs/document/Html.js +9 -5
- package/dist/cjs/document/Links.js +9 -5
- package/dist/cjs/document/Root.js +9 -5
- package/dist/cjs/document/Script.js +9 -5
- package/dist/cjs/document/Scripts.js +9 -5
- package/dist/cjs/document/Style.js +9 -5
- package/dist/cjs/document/Title.js +9 -5
- package/dist/cjs/document/cli/index.js +12 -6
- package/dist/cjs/document/constants.js +9 -5
- package/dist/cjs/document/index.js +9 -5
- package/dist/cjs/exports/config-routes.js +12 -8
- package/dist/cjs/exports/head.js +9 -5
- package/dist/cjs/exports/loadable.js +15 -11
- package/dist/cjs/exports/tanstack-router.js +9 -5
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/internal.js +9 -5
- package/dist/cjs/react-server.js +9 -5
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutes.js +9 -5
- package/dist/cjs/router/cli/code/getClientRoutes/index.js +9 -5
- package/dist/cjs/router/cli/code/getClientRoutes/utils.js +9 -5
- package/dist/cjs/router/cli/code/index.js +9 -5
- package/dist/cjs/router/cli/code/inspect.js +9 -5
- package/dist/cjs/router/cli/code/makeLegalIdentifier.js +12 -8
- package/dist/cjs/router/cli/code/nestedRoutes.js +9 -5
- package/dist/cjs/router/cli/code/tanstackTypes.js +9 -5
- package/dist/cjs/router/cli/code/templates.js +9 -5
- package/dist/cjs/router/cli/code/utils.js +9 -5
- package/dist/cjs/router/cli/config-routes/converter.js +9 -5
- package/dist/cjs/router/cli/config-routes/parseRouteConfig.js +9 -5
- package/dist/cjs/router/cli/constants.js +23 -19
- package/dist/cjs/router/cli/entry.js +9 -5
- package/dist/cjs/router/cli/handler.js +9 -5
- package/dist/cjs/router/cli/index.js +9 -5
- package/dist/cjs/router/index.js +9 -5
- package/dist/cjs/router/internal.js +12 -8
- package/dist/cjs/router/runtime/CSSLinks.js +9 -5
- package/dist/cjs/router/runtime/DefaultNotFound.js +9 -5
- package/dist/cjs/router/runtime/DeferredDataScripts.js +12 -8
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +9 -5
- package/dist/cjs/router/runtime/PrefetchLink.js +161 -26
- package/dist/cjs/router/runtime/constants.js +9 -5
- package/dist/cjs/router/runtime/hooks.js +9 -5
- package/dist/cjs/router/runtime/index.js +15 -10
- package/dist/cjs/router/runtime/internal.js +9 -5
- package/dist/cjs/router/runtime/lifecycle.js +18 -14
- package/dist/cjs/router/runtime/plugin.js +9 -5
- package/dist/cjs/router/runtime/plugin.node.js +9 -5
- package/dist/cjs/router/runtime/routerHelper.js +9 -5
- package/dist/cjs/router/runtime/rsc-router.js +9 -5
- package/dist/cjs/router/runtime/rsc.js +9 -5
- package/dist/cjs/router/runtime/server.js +9 -5
- package/dist/cjs/router/runtime/tanstack/basepathRewrite.js +12 -8
- package/dist/cjs/router/runtime/tanstack/dataMutation.js +9 -5
- package/dist/cjs/router/runtime/tanstack/hydrationBoundary.js +9 -5
- package/dist/cjs/router/runtime/tanstack/outlet.js +9 -5
- package/dist/cjs/router/runtime/tanstack/plugin.js +9 -5
- package/dist/cjs/router/runtime/tanstack/plugin.node.js +9 -5
- package/dist/cjs/router/runtime/tanstack/prefetchLink.js +10 -6
- package/dist/cjs/router/runtime/tanstack/routeTree.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/ClientSlot.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/CompositeComponent.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/ReplayableStream.js +14 -9
- package/dist/cjs/router/runtime/tanstack/rsc/RscNodeRenderer.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/SlotContext.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/client.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/createRscProxy.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/index.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/server.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/slotUsageSanitizer.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/symbols.js +20 -15
- package/dist/cjs/router/runtime/utils.js +9 -5
- package/dist/cjs/router/runtime/withRouter.js +9 -5
- package/dist/cjs/rsc/client.js +12 -8
- package/dist/cjs/rsc/server.js +9 -5
- package/dist/cjs/rsc/server.worker.js +9 -5
- package/dist/cjs/ssr/index.node.js +13 -9
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +9 -5
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +9 -5
- package/dist/cjs/ssr/serverRender/types.js +9 -5
- package/dist/esm/document/cli/index.mjs +3 -1
- package/dist/esm/router/runtime/PrefetchLink.mjs +152 -21
- package/dist/esm/router/runtime/tanstack/prefetchLink.mjs +1 -1
- package/dist/esm-node/document/cli/index.mjs +3 -1
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +152 -21
- package/dist/esm-node/router/runtime/tanstack/prefetchLink.mjs +1 -1
- package/dist/types/cli/entry.d.ts +2 -2
- package/dist/types/core/context/response/index.server.d.ts +4 -1
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/server/utils.d.ts +11 -1
- package/dist/types/router/cli/code/utils.d.ts +1 -1
- package/dist/types/router/cli/entry.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +5 -1
- package/package.json +10 -10
|
@@ -11,45 +11,141 @@ function composeEventHandlers(theirHandler, ourHandler) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const DEFAULT_PREFETCH_BEHAVIOR = 'render';
|
|
15
|
+
const DEFAULT_PRELOAD_BEHAVIOR = 'viewport';
|
|
16
|
+
const INTENT_DELAY = 100;
|
|
17
|
+
const VIEWPORT_ROOT_MARGIN = '200px';
|
|
18
|
+
const MAX_CONCURRENT_WARMUPS = 4;
|
|
19
|
+
const WARMUP_TTL = 30000;
|
|
20
|
+
const SLOW_EFFECTIVE_TYPES = new Set([
|
|
21
|
+
'slow-2g',
|
|
22
|
+
'2g'
|
|
23
|
+
]);
|
|
24
|
+
const warmupCache = new Map();
|
|
25
|
+
const warmupQueue = [];
|
|
26
|
+
let activeWarmups = 0;
|
|
27
|
+
const getConnection = ()=>{
|
|
28
|
+
const nav = globalThis.navigator;
|
|
29
|
+
return nav?.connection || nav?.mozConnection || nav?.webkitConnection;
|
|
30
|
+
};
|
|
31
|
+
const shouldWarmupOnCurrentNetwork = ()=>{
|
|
32
|
+
const connection = getConnection();
|
|
33
|
+
if (connection?.saveData) return false;
|
|
34
|
+
if ('string' == typeof connection?.effectiveType && SLOW_EFFECTIVE_TYPES.has(connection.effectiveType)) return false;
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
const pruneWarmupCache = (now = Date.now())=>{
|
|
38
|
+
for (const [key, timestamp] of warmupCache)if (now - timestamp > WARMUP_TTL) warmupCache.delete(key);
|
|
39
|
+
};
|
|
40
|
+
const runNextWarmup = ()=>{
|
|
41
|
+
while(activeWarmups < MAX_CONCURRENT_WARMUPS && warmupQueue.length > 0){
|
|
42
|
+
const task = warmupQueue.shift();
|
|
43
|
+
if (task.cancelled) continue;
|
|
44
|
+
activeWarmups += 1;
|
|
45
|
+
task.run().catch((error)=>{
|
|
46
|
+
console.error(error);
|
|
47
|
+
warmupCache.delete(task.key);
|
|
48
|
+
}).finally(()=>{
|
|
49
|
+
activeWarmups -= 1;
|
|
50
|
+
runNextWarmup();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const scheduleWarmup = (key, run)=>{
|
|
55
|
+
if (!shouldWarmupOnCurrentNetwork()) return ()=>{};
|
|
56
|
+
pruneWarmupCache();
|
|
57
|
+
if (warmupCache.has(key)) return ()=>{};
|
|
58
|
+
warmupCache.set(key, Date.now());
|
|
59
|
+
const task = {
|
|
60
|
+
key,
|
|
61
|
+
run,
|
|
62
|
+
cancelled: false
|
|
63
|
+
};
|
|
64
|
+
warmupQueue.push(task);
|
|
65
|
+
runNextWarmup();
|
|
66
|
+
return ()=>{
|
|
67
|
+
task.cancelled = true;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const setRef = (ref, value)=>{
|
|
71
|
+
if (!ref) return;
|
|
72
|
+
if ('function' == typeof ref) return void ref(value);
|
|
73
|
+
try {
|
|
74
|
+
ref.current = value;
|
|
75
|
+
} catch {}
|
|
76
|
+
};
|
|
77
|
+
const isDataWarmupEnabled = (route)=>{
|
|
78
|
+
const handle = route.handle;
|
|
79
|
+
return handle?.navigationWarmup?.data === true;
|
|
80
|
+
};
|
|
81
|
+
function usePrefetchBehavior(prefetch, preload, theirElementProps) {
|
|
82
|
+
const [maybeWarmup, setMaybeWarmup] = react.useState(false);
|
|
16
83
|
const [shouldPrefetch, setShouldPrefetch] = react.useState(false);
|
|
84
|
+
const [shouldPreload, setShouldPreload] = react.useState(false);
|
|
85
|
+
const [viewportElement, setViewportElement] = react.useState(null);
|
|
17
86
|
const { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
|
|
18
87
|
react.useEffect(()=>{
|
|
19
88
|
if ('render' === prefetch) setShouldPrefetch(true);
|
|
89
|
+
if ('render' === preload) setShouldPreload(true);
|
|
20
90
|
}, [
|
|
21
|
-
prefetch
|
|
91
|
+
prefetch,
|
|
92
|
+
preload
|
|
22
93
|
]);
|
|
23
94
|
const setIntent = ()=>{
|
|
24
|
-
if ('intent' === prefetch)
|
|
95
|
+
if ('intent' === prefetch || 'intent' === preload) setMaybeWarmup(true);
|
|
25
96
|
};
|
|
26
97
|
const cancelIntent = ()=>{
|
|
27
|
-
if ('intent' === prefetch) {
|
|
28
|
-
|
|
98
|
+
if ('intent' === prefetch || 'intent' === preload) {
|
|
99
|
+
setMaybeWarmup(false);
|
|
29
100
|
setShouldPrefetch(false);
|
|
101
|
+
setShouldPreload(false);
|
|
30
102
|
}
|
|
31
103
|
};
|
|
32
104
|
react.useEffect(()=>{
|
|
33
|
-
if (
|
|
105
|
+
if (maybeWarmup) {
|
|
34
106
|
const id = setTimeout(()=>{
|
|
35
|
-
setShouldPrefetch(true);
|
|
36
|
-
|
|
107
|
+
if ('intent' === prefetch) setShouldPrefetch(true);
|
|
108
|
+
if ('intent' === preload) setShouldPreload(true);
|
|
109
|
+
}, INTENT_DELAY);
|
|
37
110
|
return ()=>{
|
|
38
111
|
clearTimeout(id);
|
|
39
112
|
};
|
|
40
113
|
}
|
|
41
114
|
}, [
|
|
42
|
-
|
|
115
|
+
maybeWarmup,
|
|
116
|
+
prefetch,
|
|
117
|
+
preload
|
|
118
|
+
]);
|
|
119
|
+
react.useEffect(()=>{
|
|
120
|
+
if (!viewportElement || 'viewport' !== prefetch && 'viewport' !== preload || "u" < typeof IntersectionObserver) return;
|
|
121
|
+
const observer = new IntersectionObserver((entries)=>{
|
|
122
|
+
if (!entries.some((entry)=>entry.isIntersecting)) return;
|
|
123
|
+
if ('viewport' === prefetch) setShouldPrefetch(true);
|
|
124
|
+
if ('viewport' === preload) setShouldPreload(true);
|
|
125
|
+
observer.disconnect();
|
|
126
|
+
}, {
|
|
127
|
+
rootMargin: VIEWPORT_ROOT_MARGIN
|
|
128
|
+
});
|
|
129
|
+
observer.observe(viewportElement);
|
|
130
|
+
return ()=>{
|
|
131
|
+
observer.disconnect();
|
|
132
|
+
};
|
|
133
|
+
}, [
|
|
134
|
+
prefetch,
|
|
135
|
+
preload,
|
|
136
|
+
viewportElement
|
|
43
137
|
]);
|
|
44
138
|
return [
|
|
45
139
|
shouldPrefetch,
|
|
140
|
+
shouldPreload,
|
|
46
141
|
{
|
|
47
142
|
onFocus: composeEventHandlers(onFocus, setIntent),
|
|
48
143
|
onBlur: composeEventHandlers(onBlur, cancelIntent),
|
|
49
144
|
onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
|
|
50
145
|
onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
|
|
51
146
|
onTouchStart: composeEventHandlers(onTouchStart, setIntent)
|
|
52
|
-
}
|
|
147
|
+
},
|
|
148
|
+
setViewportElement
|
|
53
149
|
];
|
|
54
150
|
}
|
|
55
151
|
async function loadRouteModule(route, routeAssets) {
|
|
@@ -84,14 +180,34 @@ const getDataHref = (route, pathname, basename)=>{
|
|
|
84
180
|
const url = getRequestUrl(path, id);
|
|
85
181
|
return createDataHref(url.toString());
|
|
86
182
|
};
|
|
87
|
-
const PrefetchPageLinks = ({ path })=>{
|
|
183
|
+
const PrefetchPageLinks = ({ path, includeData })=>{
|
|
88
184
|
const { pathname } = path;
|
|
89
185
|
const context = useContext(InternalRuntimeContext);
|
|
90
186
|
const { routeManifest, routes } = context;
|
|
91
187
|
const { routeAssets } = routeManifest || {};
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
188
|
+
const allowNetworkWarmup = shouldWarmupOnCurrentNetwork();
|
|
189
|
+
const matches = useMemo(()=>Array.isArray(routes) ? matchRoutes(routes, pathname) : [], [
|
|
190
|
+
pathname,
|
|
191
|
+
routes
|
|
192
|
+
]);
|
|
193
|
+
react.useEffect(()=>{
|
|
194
|
+
if (!allowNetworkWarmup || !Array.isArray(matches) || !routeAssets || !__webpack_chunk_load__) return;
|
|
195
|
+
const cancellations = matches.map((match)=>{
|
|
196
|
+
const routeId = match.route.id;
|
|
197
|
+
const routeAsset = routeId ? routeAssets[routeId] : void 0;
|
|
198
|
+
const chunkIds = routeAsset?.chunkIds;
|
|
199
|
+
if (!routeId || !Array.isArray(chunkIds) || 0 === chunkIds.length) return ()=>{};
|
|
200
|
+
return scheduleWarmup(`route-module:${routeId}:${chunkIds.join(',')}`, ()=>loadRouteModule(match.route, routeAssets));
|
|
201
|
+
});
|
|
202
|
+
return ()=>{
|
|
203
|
+
cancellations.forEach((cancel)=>cancel());
|
|
204
|
+
};
|
|
205
|
+
}, [
|
|
206
|
+
allowNetworkWarmup,
|
|
207
|
+
matches,
|
|
208
|
+
routeAssets
|
|
209
|
+
]);
|
|
210
|
+
if (!allowNetworkWarmup || !includeData || !window._SSR_DATA) return null;
|
|
95
211
|
return /*#__PURE__*/ jsx(PrefetchDataLinks, {
|
|
96
212
|
matches: matches,
|
|
97
213
|
path: path,
|
|
@@ -103,7 +219,7 @@ const PrefetchDataLinks = ({ matches, path, routeManifest })=>{
|
|
|
103
219
|
const currentMatches = useMatches();
|
|
104
220
|
const basename = useHref('/');
|
|
105
221
|
const dataHrefs = useMemo(()=>matches?.filter((match, index)=>{
|
|
106
|
-
if (!match.route.loader || 'function' != typeof match.route.loader || 0 === match.route.loader.length) return false;
|
|
222
|
+
if (!isDataWarmupEnabled(match.route) || !match.route.loader || 'function' != typeof match.route.loader || 0 === match.route.loader.length) return false;
|
|
107
223
|
if (match.route.shouldRevalidate) {
|
|
108
224
|
const currentUrl = new URL(location.pathname + location.search + location.hash, window.origin);
|
|
109
225
|
const nextUrl = new URL(pathname + search + hash, window.origin);
|
|
@@ -130,20 +246,35 @@ const PrefetchDataLinks = ({ matches, path, routeManifest })=>{
|
|
|
130
246
|
children: dataHrefs
|
|
131
247
|
});
|
|
132
248
|
};
|
|
133
|
-
const
|
|
249
|
+
const normalizePreloadBehavior = (preload, prefetch)=>{
|
|
250
|
+
if (false === preload || 'none' === preload) return 'none';
|
|
251
|
+
if (void 0 !== preload) return preload;
|
|
252
|
+
if ('none' === prefetch) return 'none';
|
|
253
|
+
return DEFAULT_PRELOAD_BEHAVIOR;
|
|
254
|
+
};
|
|
255
|
+
const createPrefetchLink = (Link)=>/*#__PURE__*/ react.forwardRef(({ to, prefetch = DEFAULT_PREFETCH_BEHAVIOR, preload, ...props }, forwardedRef)=>{
|
|
134
256
|
const isAbsolute = 'string' == typeof to && ABSOLUTE_URL_REGEX.test(to);
|
|
135
|
-
const
|
|
257
|
+
const resolvedPreload = normalizePreloadBehavior(preload, prefetch);
|
|
258
|
+
const [shouldPrefetch, shouldPreload, prefetchHandlers, setViewportElement] = usePrefetchBehavior(prefetch, resolvedPreload, props);
|
|
259
|
+
const setAnchorRef = react.useCallback((element)=>{
|
|
260
|
+
setViewportElement(element);
|
|
261
|
+
setRef(forwardedRef, element);
|
|
262
|
+
}, [
|
|
263
|
+
forwardedRef,
|
|
264
|
+
setViewportElement
|
|
265
|
+
]);
|
|
136
266
|
const resolvedPath = useResolvedPath(to);
|
|
137
267
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
138
268
|
children: [
|
|
139
269
|
/*#__PURE__*/ jsx(Link, {
|
|
140
|
-
ref:
|
|
270
|
+
ref: setAnchorRef,
|
|
141
271
|
to: to,
|
|
142
272
|
...props,
|
|
143
273
|
...prefetchHandlers
|
|
144
274
|
}),
|
|
145
|
-
shouldPrefetch
|
|
146
|
-
path: resolvedPath
|
|
275
|
+
(shouldPrefetch || shouldPreload) && !isAbsolute ? /*#__PURE__*/ jsx(PrefetchPageLinks, {
|
|
276
|
+
path: resolvedPath,
|
|
277
|
+
includeData: shouldPrefetch
|
|
147
278
|
}) : null
|
|
148
279
|
]
|
|
149
280
|
});
|
|
@@ -5,7 +5,7 @@ function resolvePreloadFromPrefetch(prefetch, preload) {
|
|
|
5
5
|
if (void 0 !== preload) return preload;
|
|
6
6
|
if ('none' === prefetch) return false;
|
|
7
7
|
if ('intent' === prefetch || 'render' === prefetch || 'viewport' === prefetch) return prefetch;
|
|
8
|
-
return
|
|
8
|
+
return 'viewport';
|
|
9
9
|
}
|
|
10
10
|
const LinkComponentImpl = (props)=>{
|
|
11
11
|
const { prefetch, preload, ...rest } = props;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const hasApp: (dir: string) =>
|
|
2
|
-
export declare const isRuntimeEntry: (dir: string) =>
|
|
1
|
+
export declare const hasApp: (dir: string) => string | false;
|
|
2
|
+
export declare const isRuntimeEntry: (dir: string) => string | false;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export declare const getResponseProxy: () =>
|
|
1
|
+
export declare const getResponseProxy: () => {
|
|
2
|
+
headers: Record<string, string>;
|
|
3
|
+
status: number;
|
|
4
|
+
} | undefined;
|
|
2
5
|
export declare const setHeaders: (headers: Record<string, string>) => void;
|
|
3
6
|
export declare const setStatus: (status: number) => void;
|
|
4
7
|
export declare const redirect: (url: string, init?: number | ResponseInit) => void;
|
|
@@ -2,4 +2,4 @@ import type { InternalRuntimeContext } from '@modern-js/plugin/runtime';
|
|
|
2
2
|
import type { RuntimeConfig, RuntimeExtends, RuntimePlugin } from './types';
|
|
3
3
|
export type { RuntimePlugin };
|
|
4
4
|
export declare function registerPlugin(internalPlugins: RuntimePlugin[], runtimeConfig?: RuntimeConfig): InternalRuntimeContext<RuntimeExtends>;
|
|
5
|
-
export declare function mergeConfig(config: Record<string, any>, ...otherConfig: Record<string, any>[]): any
|
|
5
|
+
export declare function mergeConfig(config: Record<string, any>, ...otherConfig: Record<string, any>[]): Record<string, any>;
|
|
@@ -15,5 +15,15 @@ export declare function checkIsNode(): boolean;
|
|
|
15
15
|
* license at https://github.com/remix-run/remix/blob/main/LICENSE.md
|
|
16
16
|
*/
|
|
17
17
|
export declare function serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'];
|
|
18
|
-
export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries']):
|
|
18
|
+
export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries']): true | {
|
|
19
|
+
forceCSR?: boolean;
|
|
20
|
+
mode?: import("@modern-js/types").SSRMode;
|
|
21
|
+
preload?: boolean | {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
inlineScript?: boolean;
|
|
25
|
+
disablePrerender?: boolean;
|
|
26
|
+
unsafeHeaders?: string[];
|
|
27
|
+
moduleFederationAppSSR?: boolean;
|
|
28
|
+
};
|
|
19
29
|
export declare function getSSRMode(ssrConfig?: SSRConfig): 'string' | 'stream' | false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const walkDirectory: (dir: string) => string[];
|
|
2
2
|
export declare const isPageComponentFile: (filePath: string) => boolean;
|
|
3
|
-
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) =>
|
|
3
|
+
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
4
4
|
export declare const parseModule: ({ source, filename, }: {
|
|
5
5
|
source: string;
|
|
6
6
|
filename: string;
|
|
@@ -13,6 +13,6 @@ export declare const getEntrypointRoutesDir: (entrypoint: {
|
|
|
13
13
|
export declare const getEntrypointRoutesOwner: (entrypoint: {
|
|
14
14
|
[ROUTES_OWNER_META_KEY]?: string;
|
|
15
15
|
}) => string | null;
|
|
16
|
-
export declare const hasNestedRoutes: (dir: string, routesDir?: string) =>
|
|
16
|
+
export declare const hasNestedRoutes: (dir: string, routesDir?: string) => boolean;
|
|
17
17
|
export declare const isRouteEntry: (dir: string, routesDir?: string) => string | false;
|
|
18
18
|
export declare const modifyEntrypoints: (entrypoints: Entrypoint[], routesDir?: string, routesOwner?: string) => EntrypointWithRoutesMeta[];
|
|
@@ -13,14 +13,18 @@ import React from 'react';
|
|
|
13
13
|
*
|
|
14
14
|
* - "intent": Fetched when the user focuses or hovers the link
|
|
15
15
|
* - "render": Fetched when the link is rendered
|
|
16
|
+
* - "viewport": Fetched when the link enters the viewport
|
|
16
17
|
* - "none": Never fetched
|
|
17
18
|
*/
|
|
18
|
-
type PrefetchBehavior = 'intent' | 'render' | 'none';
|
|
19
|
+
type PrefetchBehavior = 'intent' | 'render' | 'viewport' | 'none';
|
|
20
|
+
type PreloadBehavior = PrefetchBehavior | false;
|
|
19
21
|
export interface LinkProps extends RouterLinkProps {
|
|
20
22
|
prefetch?: PrefetchBehavior;
|
|
23
|
+
preload?: PreloadBehavior;
|
|
21
24
|
}
|
|
22
25
|
export interface NavLinkProps extends RouterNavLinkProps {
|
|
23
26
|
prefetch?: PrefetchBehavior;
|
|
27
|
+
preload?: PreloadBehavior;
|
|
24
28
|
}
|
|
25
29
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
26
30
|
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.103",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
@@ -233,12 +233,12 @@
|
|
|
233
233
|
"isbot": "5.1.40",
|
|
234
234
|
"react-helmet-async": "3.0.0",
|
|
235
235
|
"react-is": "^19.2.6",
|
|
236
|
-
"@modern-js/plugin
|
|
237
|
-
"@modern-js/
|
|
238
|
-
"@modern-js/
|
|
239
|
-
"@modern-js/
|
|
240
|
-
"@modern-js/
|
|
241
|
-
"@modern-js/
|
|
236
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.103",
|
|
237
|
+
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.2.0-ultramodern.103",
|
|
238
|
+
"@modern-js/render": "npm:@bleedingdev/modern-js-render@3.2.0-ultramodern.103",
|
|
239
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.103",
|
|
240
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.103",
|
|
241
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.103"
|
|
242
242
|
},
|
|
243
243
|
"peerDependencies": {
|
|
244
244
|
"react": "^19.2.6",
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
},
|
|
247
247
|
"devDependencies": {
|
|
248
248
|
"@remix-run/web-fetch": "^4.4.2",
|
|
249
|
-
"@rsbuild/core": "2.0.
|
|
249
|
+
"@rsbuild/core": "2.0.10",
|
|
250
250
|
"@rslib/core": "0.21.5",
|
|
251
251
|
"@tanstack/history": "1.162.0",
|
|
252
252
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
"@typescript/native-preview": "7.0.0-dev.20260527.2",
|
|
258
258
|
"react": "^19.2.6",
|
|
259
259
|
"react-dom": "^19.2.6",
|
|
260
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.
|
|
260
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.103",
|
|
261
261
|
"@scripts/rstest-config": "2.66.0"
|
|
262
262
|
},
|
|
263
263
|
"sideEffects": false,
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
},
|
|
268
268
|
"scripts": {
|
|
269
269
|
"dev": "rslib build --watch",
|
|
270
|
-
"build": "rslib build && pnpm run gen-static",
|
|
270
|
+
"build": "rslib build && pnpm run gen-static && pnpm -w tsgo:dts \"$PWD\"",
|
|
271
271
|
"gen-static": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/gen-static.mts",
|
|
272
272
|
"test": "rstest"
|
|
273
273
|
}
|