sibujs 4.13.0 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser.cjs +15 -2
- package/dist/browser.js +9 -7
- package/dist/build.cjs +880 -281
- package/dist/build.d.cts +68 -3
- package/dist/build.d.ts +68 -3
- package/dist/build.js +88 -30
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +13 -13
- package/dist/cdn.full.global.js +12 -12
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-7K7W4AA5.js → chunk-2TTRW2TE.js} +6 -6
- package/dist/{chunk-J6FW5TV6.js → chunk-3HEX6QJQ.js} +5 -3
- package/dist/chunk-3HZOSMPX.js +90 -0
- package/dist/{chunk-GNSRXK34.js → chunk-4FJSAUKB.js} +11 -3
- package/dist/{chunk-IV74C2YX.js → chunk-4TQDTWWN.js} +6 -5
- package/dist/{chunk-L3QHS4O4.js → chunk-7ILEHTVX.js} +1 -1
- package/dist/{chunk-CK5F2IR5.js → chunk-A454RAEK.js} +4 -4
- package/dist/{chunk-BRRRVLHQ.js → chunk-AE32RGWX.js} +10 -6
- package/dist/{chunk-EXXSN3BW.js → chunk-B3HOT4TK.js} +1 -1
- package/dist/{chunk-F4W7WYXY.js → chunk-BKZ5N6NK.js} +8 -6
- package/dist/{chunk-MNEITZ27.js → chunk-BNXRWZZV.js} +49 -8
- package/dist/chunk-BOYKGGVD.js +2015 -0
- package/dist/{chunk-G6366I2A.js → chunk-CCKUNHVU.js} +2 -2
- package/dist/{chunk-346BYZL2.js → chunk-CJ7KS3DF.js} +16 -10
- package/dist/chunk-CNPT6NKV.js +1859 -0
- package/dist/{chunk-ENFRHCMK.js → chunk-F67F77IA.js} +2 -2
- package/dist/{chunk-TUCPL2HB.js → chunk-GIJ33UJZ.js} +1 -1
- package/dist/chunk-GVAMIU6K.js +195 -0
- package/dist/{chunk-HDKDBC6V.js → chunk-HQIAL7F2.js} +8 -6
- package/dist/{chunk-ZE5LF44R.js → chunk-JTFQ7IL4.js} +8 -8
- package/dist/{chunk-AM6DZLBM.js → chunk-LJMX4SQ7.js} +2 -2
- package/dist/{chunk-HVVRXRGO.js → chunk-MIRKTVH4.js} +7 -14
- package/dist/{chunk-YJ57VR6Y.js → chunk-N7A6FKWW.js} +5 -3
- package/dist/chunk-NT3ZYB5S.js +167 -0
- package/dist/{chunk-Z3EZX6DZ.js → chunk-QS6GMWDD.js} +151 -86
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/{chunk-3C56VNCK.js → chunk-RVR5NPFL.js} +3 -3
- package/dist/{chunk-F2UWOZ6J.js → chunk-RVWJGWCL.js} +2 -2
- package/dist/{chunk-NYNYSPK7.js → chunk-S37PZD6I.js} +30 -45
- package/dist/{chunk-QV5WEOFD.js → chunk-SVULV7O4.js} +119 -26
- package/dist/{chunk-C2FAO6VQ.js → chunk-TLS4NVIB.js} +5 -5
- package/dist/{chunk-M25RIH6Y.js → chunk-UUIKJJIK.js} +10 -8
- package/dist/chunk-UYTYNCMZ.js +199 -0
- package/dist/chunk-VM2U5LEL.js +2596 -0
- package/dist/{chunk-24L5RDPS.js → chunk-Y4LUM2XS.js} +8 -6
- package/dist/data.cjs +265 -35
- package/dist/data.d.cts +31 -1
- package/dist/data.d.ts +31 -1
- package/dist/data.js +16 -10
- package/dist/devtools.cjs +15 -2
- package/dist/devtools.js +9 -7
- package/dist/{dispose-GEIG2KOF.js → dispose-EIHHHDC7.js} +3 -1
- package/dist/ecosystem.cjs +62 -23
- package/dist/ecosystem.js +14 -12
- package/dist/extras.cjs +3520 -270
- package/dist/extras.d.cts +3 -3
- package/dist/extras.d.ts +3 -3
- package/dist/extras.js +39 -29
- package/dist/index.cjs +442 -253
- package/dist/index.d.cts +93 -283
- package/dist/index.d.ts +93 -283
- package/dist/index.js +26 -16
- package/dist/motion.cjs +12 -1
- package/dist/motion.js +6 -4
- package/dist/patterns.cjs +15 -2
- package/dist/patterns.js +10 -8
- package/dist/performance.cjs +36 -2
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +14 -10
- package/dist/plugins.cjs +5225 -1807
- package/dist/plugins.d.cts +8 -834
- package/dist/plugins.d.ts +8 -834
- package/dist/plugins.js +64 -2329
- package/dist/prerenderServer-MXJEVWA3.js +350 -0
- package/dist/renderRoute-DP20XwMS.d.cts +86 -0
- package/dist/renderRoute-fxgsm2Ir.d.ts +86 -0
- package/dist/routeHead-CE9SV-cH.d.cts +995 -0
- package/dist/routeHead-DzVxPviY.d.ts +995 -0
- package/dist/{routeMiddleware-B1sp4P7a.d.ts → routeMiddleware-BySbueoE.d.ts} +0 -25
- package/dist/{routeMiddleware-CedQTsLK.d.cts → routeMiddleware-CijZD5eW.d.cts} +0 -25
- package/dist/ssr-JpGpHnpC.d.cts +841 -0
- package/dist/ssr-JpGpHnpC.d.ts +841 -0
- package/dist/{ssr-VBM6J5SJ.js → ssr-NECEU4X4.js} +15 -6
- package/dist/ssr-dom.cjs +1862 -0
- package/dist/ssr-dom.d.cts +341 -0
- package/dist/ssr-dom.d.ts +341 -0
- package/dist/ssr-dom.js +19 -0
- package/dist/ssr.cjs +7630 -2064
- package/dist/ssr.d.cts +63 -5
- package/dist/ssr.d.ts +63 -5
- package/dist/ssr.js +136 -14
- package/dist/testing.cjs +6543 -87
- package/dist/testing.d.cts +80 -1
- package/dist/testing.d.ts +80 -1
- package/dist/testing.js +117 -4
- package/dist/ui.cjs +36 -2
- package/dist/ui.js +17 -14
- package/dist/widgets.cjs +14 -1
- package/dist/widgets.js +11 -9
- package/package.json +9 -2
- package/dist/chunk-2F4PSJ5Z.js +0 -765
- package/dist/chunk-7XHATCIH.js +0 -121
- package/dist/chunk-B36ADEIR.js +0 -21
- package/dist/ssr-Db0Sgdu3.d.cts +0 -245
- package/dist/ssr-Db0Sgdu3.d.ts +0 -245
package/dist/ssr.d.cts
CHANGED
|
@@ -1,7 +1,63 @@
|
|
|
1
|
-
export { A as ActionFn, a as ActionResult, H as Head, I as ISROptions, L as LoadRemoteModuleOptions, b as LoadWasmOptions, M as MicroApp, c as MicroAppConfig, d as MiddlewareFn, S as SSGOptions, e as SSGResult, f as ScrollRestorationOptions, g as ServiceWorkerState, h as SharedScope, U as UseWorkerFnReturn, i as UseWorkerReturn, W as WasmConfig, j as WasmModuleState, k as WorkerPool, l as clearWasmCache, m as composeMiddleware, n as createAction, o as createISR, p as createMicroApp, q as createMiddlewareChain, r as createSharedScope, s as createWasmBridge, t as createWorkerPool, u as defineRemoteComponent, v as generateStaticSite, w as isWasmCached, x as loadRemoteModule, y as loadWasmModule, z as loadWasmModuleWithOptions, B as preloadWasm, C as scrollRestoration, D as serviceWorker, E as setCanonical, F as setStructuredData, G as wasm, J as worker, K as workerFn } from './routeMiddleware-
|
|
2
|
-
export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate,
|
|
1
|
+
export { A as ActionFn, a as ActionResult, H as Head, I as ISROptions, L as LoadRemoteModuleOptions, b as LoadWasmOptions, M as MicroApp, c as MicroAppConfig, d as MiddlewareFn, S as SSGOptions, e as SSGResult, f as ScrollRestorationOptions, g as ServiceWorkerState, h as SharedScope, U as UseWorkerFnReturn, i as UseWorkerReturn, W as WasmConfig, j as WasmModuleState, k as WorkerPool, l as clearWasmCache, m as composeMiddleware, n as createAction, o as createISR, p as createMicroApp, q as createMiddlewareChain, r as createSharedScope, s as createWasmBridge, t as createWorkerPool, u as defineRemoteComponent, v as generateStaticSite, w as isWasmCached, x as loadRemoteModule, y as loadWasmModule, z as loadWasmModuleWithOptions, B as preloadWasm, C as scrollRestoration, D as serviceWorker, E as setCanonical, F as setStructuredData, G as wasm, J as worker, K as workerFn } from './routeMiddleware-CijZD5eW.cjs';
|
|
2
|
+
export { v as ADOPT_ID_ATTR, w as AdoptMismatch, x as AdoptOptions, y as AdoptResult, A as AsyncRenderOptions, C as ComponentIslandOptions, z as DEFAULT_SETTLE_TIMEOUT, B as DEFAULT_TRANSFER_MAX_BYTES, D as DocumentOptions, H as HydrateOptions, a as HydrationMismatch, I as ISLAND_PROPS_ATTR, E as RenderDiagnostics, R as RenderResult, S as SerializeOptions, F as SettleOptions, G as SettleResult, J as StreamRenderOptions, T as TrustedHTML, b as assembleDocument, c as collectStream, K as componentIsland, L as describeNodePath, d as deserializeState, e as escapeScriptJson, M as formatRenderDiagnostics, h as hydrate, f as hydrateIslands, g as hydrateProgressively, i as isDangerousMetaRefresh, j as island, N as islandComponent, O as renderFailure, r as renderToDocument, P as renderToDocumentAsync, k as renderToReadableStream, l as renderToStream, m as renderToString, Q as renderToStringAsync, n as renderToStringWith, o as renderToSuspenseStream, p as resetSSRState, s as serializeState, U as settled, q as ssrSuspense, t as suspenseSwapScript, u as trustHTML } from './ssr-JpGpHnpC.cjs';
|
|
3
|
+
import { a as RouteDef } from './routeHead-CE9SV-cH.cjs';
|
|
4
|
+
import { R as RenderRouteOptions, a as RouteRenderResult } from './renderRoute-DP20XwMS.cjs';
|
|
5
|
+
export { b as RenderedRoute, c as RouteRenderMode, r as renderRoute } from './renderRoute-DP20XwMS.cjs';
|
|
3
6
|
import './types-CJFViL6Q.cjs';
|
|
4
7
|
|
|
8
|
+
/** Options of {@link createRenderHandler}. */
|
|
9
|
+
interface RenderHandlerOptions extends RenderRouteOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Keep rendered pages in memory. `max` entries (default 500), each for `ttl`
|
|
12
|
+
* ms (default 60 000); `version()` is part of the key, so changing what it
|
|
13
|
+
* returns makes every cached page stale at once. The cache also holds at
|
|
14
|
+
* most `maxBytes` of HTML (default 32 MB): any query string is a distinct
|
|
15
|
+
* key, so a client inventing them evicts the oldest pages but cannot grow the
|
|
16
|
+
* process without bound.
|
|
17
|
+
*
|
|
18
|
+
* A page is stored only when it is a 200 or 404 that did not time out AND
|
|
19
|
+
* its `Cache-Control` (from `cacheControl`) allows a shared cache: no
|
|
20
|
+
* `no-store`, `no-cache` or `private` directive. This cache is shared by
|
|
21
|
+
* every visitor, so a personalized page must say `private` (or `no-store`)
|
|
22
|
+
* — that is the opt-out, and the default 404 (`no-store`) is not stored
|
|
23
|
+
* either. `x-sibu-cache` says what happened: `hit`, `miss` (rendered and
|
|
24
|
+
* stored) or `bypass` (rendered, not stored).
|
|
25
|
+
*/
|
|
26
|
+
cache?: {
|
|
27
|
+
max?: number;
|
|
28
|
+
ttl?: number;
|
|
29
|
+
maxBytes?: number;
|
|
30
|
+
version?: () => string | number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The `Cache-Control` value for a result. Default: 200 →
|
|
34
|
+
* `public, max-age=0, s-maxage=60, stale-while-revalidate=600`; 301/308 →
|
|
35
|
+
* `public, max-age=3600`; a timed-out render and anything else → `no-store`.
|
|
36
|
+
* Return `null` to send none.
|
|
37
|
+
*/
|
|
38
|
+
cacheControl?: (result: RouteRenderResult) => string | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Serve server-rendered pages from a route table.
|
|
42
|
+
*
|
|
43
|
+
* @param routes The app's route table.
|
|
44
|
+
* @param options `renderRoute` options (a `document` is used by default, so the
|
|
45
|
+
* response is a full page), plus `cache` and `cacheControl`.
|
|
46
|
+
* @returns A `Request → Response` handler. GET and HEAD only (others: 405). A
|
|
47
|
+
* render that throws answers a bare 500 (`no-store`, no error details) and is
|
|
48
|
+
* logged with `console.error`; the handler itself never rejects.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const handle = createRenderHandler(routes, {
|
|
53
|
+
* router: { head },
|
|
54
|
+
* document: { scripts: ["/assets/main.js"] },
|
|
55
|
+
* cache: { version: () => catalogVersion },
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function createRenderHandler(routes: RouteDef[], options?: RenderHandlerOptions): (request: Request) => Promise<Response>;
|
|
60
|
+
|
|
5
61
|
/**
|
|
6
62
|
* Whether this code is running inside the build-time pre-renderer.
|
|
7
63
|
*
|
|
@@ -19,13 +75,15 @@ declare function isPrerendering(): boolean;
|
|
|
19
75
|
*/
|
|
20
76
|
declare function prerenderRoute(): string | null;
|
|
21
77
|
/**
|
|
22
|
-
* Make the pre-renderer
|
|
78
|
+
* Make the pre-renderer — and an async server render (`renderToStringAsync`,
|
|
79
|
+
* `renderRoute`) — wait for `promise` before it serializes the page.
|
|
23
80
|
* A no-op in the browser, so it can wrap any data load unconditionally.
|
|
24
81
|
*
|
|
25
82
|
* `fetch()` calls are awaited automatically; register anything else the
|
|
26
83
|
* rendered content depends on (a timer, IndexedDB, a worker).
|
|
27
84
|
*
|
|
28
85
|
* @param promise Work the rendered page depends on.
|
|
86
|
+
* @param label Names the work in a server render's timeout diagnostics.
|
|
29
87
|
* @returns `promise`, unchanged.
|
|
30
88
|
*
|
|
31
89
|
* @example
|
|
@@ -33,6 +91,6 @@ declare function prerenderRoute(): string | null;
|
|
|
33
91
|
* const products = prerenderWait(loadProductsFromCache());
|
|
34
92
|
* ```
|
|
35
93
|
*/
|
|
36
|
-
declare function prerenderWait<T extends PromiseLike<unknown>>(promise: T): T;
|
|
94
|
+
declare function prerenderWait<T extends PromiseLike<unknown>>(promise: T, label?: string): T;
|
|
37
95
|
|
|
38
|
-
export { isPrerendering, prerenderRoute, prerenderWait };
|
|
96
|
+
export { type RenderHandlerOptions, RenderRouteOptions, RouteRenderResult, createRenderHandler, isPrerendering, prerenderRoute, prerenderWait };
|
package/dist/ssr.d.ts
CHANGED
|
@@ -1,7 +1,63 @@
|
|
|
1
|
-
export { A as ActionFn, a as ActionResult, H as Head, I as ISROptions, L as LoadRemoteModuleOptions, b as LoadWasmOptions, M as MicroApp, c as MicroAppConfig, d as MiddlewareFn, S as SSGOptions, e as SSGResult, f as ScrollRestorationOptions, g as ServiceWorkerState, h as SharedScope, U as UseWorkerFnReturn, i as UseWorkerReturn, W as WasmConfig, j as WasmModuleState, k as WorkerPool, l as clearWasmCache, m as composeMiddleware, n as createAction, o as createISR, p as createMicroApp, q as createMiddlewareChain, r as createSharedScope, s as createWasmBridge, t as createWorkerPool, u as defineRemoteComponent, v as generateStaticSite, w as isWasmCached, x as loadRemoteModule, y as loadWasmModule, z as loadWasmModuleWithOptions, B as preloadWasm, C as scrollRestoration, D as serviceWorker, E as setCanonical, F as setStructuredData, G as wasm, J as worker, K as workerFn } from './routeMiddleware-
|
|
2
|
-
export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate,
|
|
1
|
+
export { A as ActionFn, a as ActionResult, H as Head, I as ISROptions, L as LoadRemoteModuleOptions, b as LoadWasmOptions, M as MicroApp, c as MicroAppConfig, d as MiddlewareFn, S as SSGOptions, e as SSGResult, f as ScrollRestorationOptions, g as ServiceWorkerState, h as SharedScope, U as UseWorkerFnReturn, i as UseWorkerReturn, W as WasmConfig, j as WasmModuleState, k as WorkerPool, l as clearWasmCache, m as composeMiddleware, n as createAction, o as createISR, p as createMicroApp, q as createMiddlewareChain, r as createSharedScope, s as createWasmBridge, t as createWorkerPool, u as defineRemoteComponent, v as generateStaticSite, w as isWasmCached, x as loadRemoteModule, y as loadWasmModule, z as loadWasmModuleWithOptions, B as preloadWasm, C as scrollRestoration, D as serviceWorker, E as setCanonical, F as setStructuredData, G as wasm, J as worker, K as workerFn } from './routeMiddleware-BySbueoE.js';
|
|
2
|
+
export { v as ADOPT_ID_ATTR, w as AdoptMismatch, x as AdoptOptions, y as AdoptResult, A as AsyncRenderOptions, C as ComponentIslandOptions, z as DEFAULT_SETTLE_TIMEOUT, B as DEFAULT_TRANSFER_MAX_BYTES, D as DocumentOptions, H as HydrateOptions, a as HydrationMismatch, I as ISLAND_PROPS_ATTR, E as RenderDiagnostics, R as RenderResult, S as SerializeOptions, F as SettleOptions, G as SettleResult, J as StreamRenderOptions, T as TrustedHTML, b as assembleDocument, c as collectStream, K as componentIsland, L as describeNodePath, d as deserializeState, e as escapeScriptJson, M as formatRenderDiagnostics, h as hydrate, f as hydrateIslands, g as hydrateProgressively, i as isDangerousMetaRefresh, j as island, N as islandComponent, O as renderFailure, r as renderToDocument, P as renderToDocumentAsync, k as renderToReadableStream, l as renderToStream, m as renderToString, Q as renderToStringAsync, n as renderToStringWith, o as renderToSuspenseStream, p as resetSSRState, s as serializeState, U as settled, q as ssrSuspense, t as suspenseSwapScript, u as trustHTML } from './ssr-JpGpHnpC.js';
|
|
3
|
+
import { a as RouteDef } from './routeHead-DzVxPviY.js';
|
|
4
|
+
import { R as RenderRouteOptions, a as RouteRenderResult } from './renderRoute-fxgsm2Ir.js';
|
|
5
|
+
export { b as RenderedRoute, c as RouteRenderMode, r as renderRoute } from './renderRoute-fxgsm2Ir.js';
|
|
3
6
|
import './types-CJFViL6Q.js';
|
|
4
7
|
|
|
8
|
+
/** Options of {@link createRenderHandler}. */
|
|
9
|
+
interface RenderHandlerOptions extends RenderRouteOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Keep rendered pages in memory. `max` entries (default 500), each for `ttl`
|
|
12
|
+
* ms (default 60 000); `version()` is part of the key, so changing what it
|
|
13
|
+
* returns makes every cached page stale at once. The cache also holds at
|
|
14
|
+
* most `maxBytes` of HTML (default 32 MB): any query string is a distinct
|
|
15
|
+
* key, so a client inventing them evicts the oldest pages but cannot grow the
|
|
16
|
+
* process without bound.
|
|
17
|
+
*
|
|
18
|
+
* A page is stored only when it is a 200 or 404 that did not time out AND
|
|
19
|
+
* its `Cache-Control` (from `cacheControl`) allows a shared cache: no
|
|
20
|
+
* `no-store`, `no-cache` or `private` directive. This cache is shared by
|
|
21
|
+
* every visitor, so a personalized page must say `private` (or `no-store`)
|
|
22
|
+
* — that is the opt-out, and the default 404 (`no-store`) is not stored
|
|
23
|
+
* either. `x-sibu-cache` says what happened: `hit`, `miss` (rendered and
|
|
24
|
+
* stored) or `bypass` (rendered, not stored).
|
|
25
|
+
*/
|
|
26
|
+
cache?: {
|
|
27
|
+
max?: number;
|
|
28
|
+
ttl?: number;
|
|
29
|
+
maxBytes?: number;
|
|
30
|
+
version?: () => string | number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The `Cache-Control` value for a result. Default: 200 →
|
|
34
|
+
* `public, max-age=0, s-maxage=60, stale-while-revalidate=600`; 301/308 →
|
|
35
|
+
* `public, max-age=3600`; a timed-out render and anything else → `no-store`.
|
|
36
|
+
* Return `null` to send none.
|
|
37
|
+
*/
|
|
38
|
+
cacheControl?: (result: RouteRenderResult) => string | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Serve server-rendered pages from a route table.
|
|
42
|
+
*
|
|
43
|
+
* @param routes The app's route table.
|
|
44
|
+
* @param options `renderRoute` options (a `document` is used by default, so the
|
|
45
|
+
* response is a full page), plus `cache` and `cacheControl`.
|
|
46
|
+
* @returns A `Request → Response` handler. GET and HEAD only (others: 405). A
|
|
47
|
+
* render that throws answers a bare 500 (`no-store`, no error details) and is
|
|
48
|
+
* logged with `console.error`; the handler itself never rejects.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const handle = createRenderHandler(routes, {
|
|
53
|
+
* router: { head },
|
|
54
|
+
* document: { scripts: ["/assets/main.js"] },
|
|
55
|
+
* cache: { version: () => catalogVersion },
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function createRenderHandler(routes: RouteDef[], options?: RenderHandlerOptions): (request: Request) => Promise<Response>;
|
|
60
|
+
|
|
5
61
|
/**
|
|
6
62
|
* Whether this code is running inside the build-time pre-renderer.
|
|
7
63
|
*
|
|
@@ -19,13 +75,15 @@ declare function isPrerendering(): boolean;
|
|
|
19
75
|
*/
|
|
20
76
|
declare function prerenderRoute(): string | null;
|
|
21
77
|
/**
|
|
22
|
-
* Make the pre-renderer
|
|
78
|
+
* Make the pre-renderer — and an async server render (`renderToStringAsync`,
|
|
79
|
+
* `renderRoute`) — wait for `promise` before it serializes the page.
|
|
23
80
|
* A no-op in the browser, so it can wrap any data load unconditionally.
|
|
24
81
|
*
|
|
25
82
|
* `fetch()` calls are awaited automatically; register anything else the
|
|
26
83
|
* rendered content depends on (a timer, IndexedDB, a worker).
|
|
27
84
|
*
|
|
28
85
|
* @param promise Work the rendered page depends on.
|
|
86
|
+
* @param label Names the work in a server render's timeout diagnostics.
|
|
29
87
|
* @returns `promise`, unchanged.
|
|
30
88
|
*
|
|
31
89
|
* @example
|
|
@@ -33,6 +91,6 @@ declare function prerenderRoute(): string | null;
|
|
|
33
91
|
* const products = prerenderWait(loadProductsFromCache());
|
|
34
92
|
* ```
|
|
35
93
|
*/
|
|
36
|
-
declare function prerenderWait<T extends PromiseLike<unknown>>(promise: T): T;
|
|
94
|
+
declare function prerenderWait<T extends PromiseLike<unknown>>(promise: T, label?: string): T;
|
|
37
95
|
|
|
38
|
-
export { isPrerendering, prerenderRoute, prerenderWait };
|
|
96
|
+
export { type RenderHandlerOptions, RenderRouteOptions, RouteRenderResult, createRenderHandler, isPrerendering, prerenderRoute, prerenderWait };
|
package/dist/ssr.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderRoute
|
|
3
|
+
} from "./chunk-GVAMIU6K.js";
|
|
1
4
|
import {
|
|
2
5
|
isPrerendering,
|
|
3
6
|
prerenderRoute,
|
|
4
7
|
prerenderWait
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VM2U5LEL.js";
|
|
6
9
|
import {
|
|
7
10
|
Head,
|
|
8
11
|
clearWasmCache,
|
|
@@ -28,56 +31,168 @@ import {
|
|
|
28
31
|
wasm,
|
|
29
32
|
worker,
|
|
30
33
|
workerFn
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-BNXRWZZV.js";
|
|
32
35
|
import "./chunk-52XFPGSN.js";
|
|
33
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-7ILEHTVX.js";
|
|
34
37
|
import {
|
|
38
|
+
ADOPT_ID_ATTR,
|
|
39
|
+
DEFAULT_SETTLE_TIMEOUT,
|
|
40
|
+
DEFAULT_TRANSFER_MAX_BYTES,
|
|
41
|
+
ISLAND_PROPS_ATTR,
|
|
42
|
+
assembleDocument,
|
|
35
43
|
collectStream,
|
|
44
|
+
componentIsland,
|
|
45
|
+
describeNodePath,
|
|
36
46
|
deserializeState,
|
|
37
47
|
escapeScriptJson,
|
|
48
|
+
formatRenderDiagnostics,
|
|
38
49
|
hydrate,
|
|
39
50
|
hydrateIslands,
|
|
40
51
|
hydrateProgressively,
|
|
41
52
|
isDangerousMetaRefresh,
|
|
42
53
|
island,
|
|
54
|
+
islandComponent,
|
|
55
|
+
renderFailure,
|
|
43
56
|
renderToDocument,
|
|
57
|
+
renderToDocumentAsync,
|
|
44
58
|
renderToReadableStream,
|
|
45
59
|
renderToStream,
|
|
46
60
|
renderToString,
|
|
61
|
+
renderToStringAsync,
|
|
62
|
+
renderToStringWith,
|
|
47
63
|
renderToSuspenseStream,
|
|
48
64
|
resetSSRState,
|
|
49
65
|
serializeState,
|
|
66
|
+
settled,
|
|
50
67
|
ssrSuspense,
|
|
51
68
|
suspenseSwapScript,
|
|
52
69
|
trustHTML
|
|
53
|
-
} from "./chunk-
|
|
54
|
-
import "./chunk-
|
|
70
|
+
} from "./chunk-BOYKGGVD.js";
|
|
71
|
+
import "./chunk-CNPT6NKV.js";
|
|
72
|
+
import "./chunk-LJMX4SQ7.js";
|
|
73
|
+
import "./chunk-3HZOSMPX.js";
|
|
55
74
|
import "./chunk-62BDYGAG.js";
|
|
56
|
-
import "./chunk-
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
75
|
+
import "./chunk-CJ7KS3DF.js";
|
|
76
|
+
import "./chunk-HQIAL7F2.js";
|
|
77
|
+
import "./chunk-RVWJGWCL.js";
|
|
59
78
|
import "./chunk-7ZHH77QA.js";
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
62
|
-
import "./chunk-
|
|
63
|
-
import "./chunk-
|
|
64
|
-
import "./chunk-
|
|
65
|
-
import "./chunk-
|
|
79
|
+
import "./chunk-AE32RGWX.js";
|
|
80
|
+
import "./chunk-B3HOT4TK.js";
|
|
81
|
+
import "./chunk-UYTYNCMZ.js";
|
|
82
|
+
import "./chunk-4FJSAUKB.js";
|
|
83
|
+
import "./chunk-MIRKTVH4.js";
|
|
84
|
+
import "./chunk-S37PZD6I.js";
|
|
85
|
+
import "./chunk-NT3ZYB5S.js";
|
|
86
|
+
import "./chunk-R5U7XKVJ.js";
|
|
87
|
+
|
|
88
|
+
// src/platform/renderHandler.ts
|
|
89
|
+
var encoder = new TextEncoder();
|
|
90
|
+
function sharedCacheable(control) {
|
|
91
|
+
if (!control) return true;
|
|
92
|
+
for (const part of control.split(",")) {
|
|
93
|
+
const name = part.split("=")[0].trim().toLowerCase();
|
|
94
|
+
if (name === "no-store" || name === "no-cache" || name === "private") return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
function defaultCacheControl(result) {
|
|
99
|
+
if (result.diagnostics.timedOut) return "no-store";
|
|
100
|
+
if (result.status === 200) return "public, max-age=0, s-maxage=60, stale-while-revalidate=600";
|
|
101
|
+
if (result.status === 301 || result.status === 308) return "public, max-age=3600";
|
|
102
|
+
return "no-store";
|
|
103
|
+
}
|
|
104
|
+
function createRenderHandler(routes, options = {}) {
|
|
105
|
+
const { cache, cacheControl = defaultCacheControl, ...renderOptions } = options;
|
|
106
|
+
const document = renderOptions.document ?? {};
|
|
107
|
+
const store = cache ? /* @__PURE__ */ new Map() : null;
|
|
108
|
+
const max = cache?.max ?? 500;
|
|
109
|
+
const ttl = cache?.ttl ?? 6e4;
|
|
110
|
+
const maxBytes = cache?.maxBytes ?? 32 * 1024 * 1024;
|
|
111
|
+
let cachedBytes = 0;
|
|
112
|
+
const evict = (key) => {
|
|
113
|
+
const entry = store?.get(key);
|
|
114
|
+
if (!entry) return;
|
|
115
|
+
store?.delete(key);
|
|
116
|
+
cachedBytes -= entry.bytes;
|
|
117
|
+
};
|
|
118
|
+
const respond = (status, html, head, headers) => new Response(head || status === 204 || status >= 300 && status < 400 ? null : html, {
|
|
119
|
+
status,
|
|
120
|
+
headers: { "content-type": "text/html; charset=utf-8", ...headers }
|
|
121
|
+
});
|
|
122
|
+
return async (request) => {
|
|
123
|
+
const method = request.method.toUpperCase();
|
|
124
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
125
|
+
return new Response(null, { status: 405, headers: { allow: "GET, HEAD" } });
|
|
126
|
+
}
|
|
127
|
+
const url = new URL(request.url);
|
|
128
|
+
const path = url.pathname + url.search;
|
|
129
|
+
const key = store ? `${cache?.version?.() ?? ""}\0${path}` : "";
|
|
130
|
+
const head = method === "HEAD";
|
|
131
|
+
if (store) {
|
|
132
|
+
const hit = store.get(key);
|
|
133
|
+
if (hit && hit.expires > Date.now()) {
|
|
134
|
+
store.delete(key);
|
|
135
|
+
store.set(key, hit);
|
|
136
|
+
const hitHeaders = { "x-sibu-cache": "hit" };
|
|
137
|
+
if (hit.control) hitHeaders["cache-control"] = hit.control;
|
|
138
|
+
return respond(hit.status, hit.html, head, hitHeaders);
|
|
139
|
+
}
|
|
140
|
+
if (hit) evict(key);
|
|
141
|
+
}
|
|
142
|
+
let result;
|
|
143
|
+
try {
|
|
144
|
+
result = await renderRoute(routes, path, { ...renderOptions, document });
|
|
145
|
+
} catch (err) {
|
|
146
|
+
console.error(`[SibuJS SSR] render of ${path} failed:`, err);
|
|
147
|
+
return new Response(head ? null : "Internal Server Error", {
|
|
148
|
+
status: 500,
|
|
149
|
+
headers: { "content-type": "text/plain; charset=utf-8", "cache-control": "no-store" }
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const headers = {};
|
|
153
|
+
const control = cacheControl(result);
|
|
154
|
+
if (control) headers["cache-control"] = control;
|
|
155
|
+
if (result.location) headers.location = result.location;
|
|
156
|
+
if (store) {
|
|
157
|
+
const eligible = (result.status === 200 || result.status === 404) && !result.diagnostics.timedOut && sharedCacheable(control);
|
|
158
|
+
const bytes = eligible ? encoder.encode(result.html).byteLength : 0;
|
|
159
|
+
if (eligible && bytes <= maxBytes) {
|
|
160
|
+
evict(key);
|
|
161
|
+
store.set(key, { status: result.status, html: result.html, control, expires: Date.now() + ttl, bytes });
|
|
162
|
+
cachedBytes += bytes;
|
|
163
|
+
while (store.size > max || cachedBytes > maxBytes) evict(store.keys().next().value);
|
|
164
|
+
headers["x-sibu-cache"] = "miss";
|
|
165
|
+
} else {
|
|
166
|
+
headers["x-sibu-cache"] = "bypass";
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return respond(result.status, result.html, head, headers);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
66
172
|
export {
|
|
173
|
+
ADOPT_ID_ATTR,
|
|
174
|
+
DEFAULT_SETTLE_TIMEOUT,
|
|
175
|
+
DEFAULT_TRANSFER_MAX_BYTES,
|
|
67
176
|
Head,
|
|
177
|
+
ISLAND_PROPS_ATTR,
|
|
178
|
+
assembleDocument,
|
|
68
179
|
clearWasmCache,
|
|
69
180
|
collectStream,
|
|
181
|
+
componentIsland,
|
|
70
182
|
composeMiddleware,
|
|
71
183
|
createAction,
|
|
72
184
|
createISR,
|
|
73
185
|
createMicroApp,
|
|
74
186
|
createMiddlewareChain,
|
|
187
|
+
createRenderHandler,
|
|
75
188
|
createSharedScope,
|
|
76
189
|
createWasmBridge,
|
|
77
190
|
createWorkerPool,
|
|
78
191
|
defineRemoteComponent,
|
|
192
|
+
describeNodePath,
|
|
79
193
|
deserializeState,
|
|
80
194
|
escapeScriptJson,
|
|
195
|
+
formatRenderDiagnostics,
|
|
81
196
|
generateStaticSite,
|
|
82
197
|
hydrate,
|
|
83
198
|
hydrateIslands,
|
|
@@ -86,16 +201,22 @@ export {
|
|
|
86
201
|
isPrerendering,
|
|
87
202
|
isWasmCached,
|
|
88
203
|
island,
|
|
204
|
+
islandComponent,
|
|
89
205
|
loadRemoteModule,
|
|
90
206
|
loadWasmModule,
|
|
91
207
|
loadWasmModuleWithOptions,
|
|
92
208
|
preloadWasm,
|
|
93
209
|
prerenderRoute,
|
|
94
210
|
prerenderWait,
|
|
211
|
+
renderFailure,
|
|
212
|
+
renderRoute,
|
|
95
213
|
renderToDocument,
|
|
214
|
+
renderToDocumentAsync,
|
|
96
215
|
renderToReadableStream,
|
|
97
216
|
renderToStream,
|
|
98
217
|
renderToString,
|
|
218
|
+
renderToStringAsync,
|
|
219
|
+
renderToStringWith,
|
|
99
220
|
renderToSuspenseStream,
|
|
100
221
|
resetSSRState,
|
|
101
222
|
scrollRestoration,
|
|
@@ -103,6 +224,7 @@ export {
|
|
|
103
224
|
serviceWorker,
|
|
104
225
|
setCanonical,
|
|
105
226
|
setStructuredData,
|
|
227
|
+
settled,
|
|
106
228
|
ssrSuspense,
|
|
107
229
|
suspenseSwapScript,
|
|
108
230
|
trustHTML,
|