sibujs 3.4.1 → 4.0.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/LICENSE +21 -21
- package/README.md +118 -15
- package/dist/browser.cjs +410 -101
- package/dist/browser.d.cts +50 -5
- package/dist/browser.d.ts +50 -5
- package/dist/browser.js +8 -6
- package/dist/build.cjs +777 -385
- package/dist/build.js +15 -15
- package/dist/cdn.global.js +11 -7
- package/dist/{chunk-WEZ5SP7L.js → chunk-3EKJK5FZ.js} +73 -34
- package/dist/chunk-4MFZMLUU.js +147 -0
- package/dist/chunk-52XFPGSN.js +123 -0
- package/dist/chunk-5INI7D2L.js +194 -0
- package/dist/{chunk-5MFF5EPT.js → chunk-6LG2T7LO.js} +5 -5
- package/dist/{chunk-BQLVTAUZ.js → chunk-ACBT6UZS.js} +57 -22
- package/dist/{chunk-F7HW2NI5.js → chunk-AW6HPJ3L.js} +1 -1
- package/dist/chunk-DHDZ7IVN.js +109 -0
- package/dist/{chunk-NXR2YFZB.js → chunk-DQVUBVNX.js} +16 -25
- package/dist/{chunk-7PNKW3FJ.js → chunk-DR7H6UGM.js} +232 -67
- package/dist/{chunk-CV7FAQ2R.js → chunk-E62UADKL.js} +9 -3
- package/dist/{chunk-VQZDHAEK.js → chunk-ES2GERY2.js} +1 -1
- package/dist/{chunk-FWFEBYQ6.js → chunk-EWEE7NBF.js} +115 -41
- package/dist/{chunk-PBZWJQNY.js → chunk-F64ZPCFE.js} +8 -8
- package/dist/{chunk-S2VW4NBA.js → chunk-GCSGGA3Q.js} +295 -198
- package/dist/{chunk-EX77FXTT.js → chunk-HYCCIYNS.js} +228 -51
- package/dist/{chunk-MPE75KOA.js → chunk-NF3LYCQH.js} +259 -124
- package/dist/chunk-O3QQ3XOL.js +61 -0
- package/dist/{chunk-X4JS367G.js → chunk-PBQEW5VW.js} +14 -10
- package/dist/{chunk-QHPUFNHZ.js → chunk-RRIDJQ5C.js} +3 -3
- package/dist/{chunk-S3NFJO6L.js → chunk-TIRZCERI.js} +36 -5
- package/dist/{chunk-3FFCUIGV.js → chunk-VFHIVEPF.js} +309 -188
- package/dist/chunk-VPP2FONR.js +142 -0
- package/dist/{chunk-335KJEN2.js → chunk-W55YHPEP.js} +5 -3
- package/dist/{chunk-Y22QAKJX.js → chunk-WN6WDFCB.js} +4 -4
- package/dist/{chunk-YDWP3ZOU.js → chunk-WOOMUJFT.js} +228 -86
- package/dist/{chunk-4I3M326N.js → chunk-Z2CE42DB.js} +19 -25
- package/dist/{contracts-ey_Qh8ef.d.ts → contracts-Hg6ITAEF.d.cts} +6 -6
- package/dist/{contracts-ey_Qh8ef.d.cts → contracts-Hg6ITAEF.d.ts} +6 -6
- package/dist/{customElement-CPfIrbvg.d.cts → customElement-CKLoO63w.d.cts} +73 -11
- package/dist/{customElement-CPfIrbvg.d.ts → customElement-CKLoO63w.d.ts} +73 -11
- package/dist/data.cjs +483 -205
- package/dist/data.d.cts +139 -7
- package/dist/data.d.ts +139 -7
- package/dist/data.js +9 -9
- package/dist/devtools.cjs +222 -87
- package/dist/devtools.js +8 -8
- package/dist/dispose-4FZ6OFXR.js +19 -0
- package/dist/ecosystem.cjs +419 -175
- package/dist/ecosystem.js +11 -11
- package/dist/extras.cjs +1981 -765
- package/dist/extras.d.cts +7 -7
- package/dist/extras.d.ts +7 -7
- package/dist/extras.js +29 -26
- package/dist/index.cjs +784 -385
- package/dist/index.d.cts +299 -28
- package/dist/index.d.ts +299 -28
- package/dist/index.js +33 -18
- package/dist/motion.cjs +180 -50
- package/dist/motion.d.cts +26 -0
- package/dist/motion.d.ts +26 -0
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +437 -170
- package/dist/patterns.d.cts +60 -13
- package/dist/patterns.d.ts +60 -13
- package/dist/patterns.js +7 -7
- package/dist/performance.cjs +333 -148
- package/dist/performance.d.cts +55 -7
- package/dist/performance.d.ts +55 -7
- package/dist/performance.js +9 -9
- package/dist/plugins.cjs +1371 -576
- package/dist/plugins.d.cts +227 -9
- package/dist/plugins.d.ts +227 -9
- package/dist/plugins.js +610 -321
- package/dist/{ssr-D62yFwuw.d.cts → ssr-BiPRdZ6n.d.cts} +44 -15
- package/dist/{ssr-D62yFwuw.d.ts → ssr-BiPRdZ6n.d.ts} +44 -15
- package/dist/{ssr-2PPULEK2.js → ssr-JFP5535P.js} +5 -4
- package/dist/ssr.cjs +1104 -443
- package/dist/ssr.d.cts +230 -20
- package/dist/ssr.d.ts +230 -20
- package/dist/ssr.js +15 -12
- package/dist/{startup-0Qv6aosO.d.cts → startup-BMpaiMhP.d.cts} +1 -1
- package/dist/{startup-0Qv6aosO.d.ts → startup-BMpaiMhP.d.ts} +1 -1
- package/dist/testing.cjs +205 -63
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +8 -10
- package/dist/ui.cjs +640 -199
- package/dist/ui.d.cts +2 -2
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js +10 -10
- package/dist/widgets.cjs +207 -82
- package/dist/widgets.js +9 -9
- package/package.json +12 -7
- package/dist/chunk-5VGSK6D2.js +0 -80
- package/dist/chunk-6CAJU5TP.js +0 -38
- package/dist/chunk-COY6PUD2.js +0 -34
- package/dist/chunk-DLBFEAIS.js +0 -96
- package/dist/chunk-L3GAGWCC.js +0 -111
package/dist/ssr.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate, b as hydrateIslands, f as hydrateProgressively, i as isDangerousMetaRefresh, g as island, r as renderToDocument, j as renderToReadableStream, k as renderToStream, l as renderToString, m as renderToSuspenseStream, n as resetSSRState, s as serializeState, o as ssrSuspense, p as suspenseSwapScript, t as trustHTML } from './ssr-
|
|
1
|
+
export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate, b as hydrateIslands, f as hydrateProgressively, i as isDangerousMetaRefresh, g as island, r as renderToDocument, j as renderToReadableStream, k as renderToStream, l as renderToString, m as renderToSuspenseStream, n as resetSSRState, s as serializeState, o as ssrSuspense, p as suspenseSwapScript, t as trustHTML } from './ssr-BiPRdZ6n.js';
|
|
2
2
|
|
|
3
3
|
interface HeadProps {
|
|
4
4
|
title?: string | (() => string);
|
|
@@ -12,6 +12,26 @@ interface HeadProps {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Head() manages document <head> tags reactively.
|
|
15
|
+
*
|
|
16
|
+
* META SECURITY: each meta entry is committed TRANSACTIONALLY. All of its
|
|
17
|
+
* attributes — static and reactive — are resolved into one snapshot, duplicate
|
|
18
|
+
* case-insensitive names are rejected, and the assembled snapshot is validated
|
|
19
|
+
* against the shared meta-refresh policy before anything reaches the DOM. An
|
|
20
|
+
* approved snapshot is then materialised on a fresh `<meta>` element while it is
|
|
21
|
+
* still detached and swapped in with a single `replaceWith()`, so no partially
|
|
22
|
+
* updated element is ever connected. A snapshot that fails validation withdraws
|
|
23
|
+
* the element entirely. See `utils/metaRefresh.ts`; the same policy governs SSR.
|
|
24
|
+
*
|
|
25
|
+
* NATIVE REFRESH DIRECTIVES MUST BE STATIC. A browser processes a meta refresh
|
|
26
|
+
* when the element is INSERTED — it records the pending navigation there and
|
|
27
|
+
* then, and removing or replacing the element afterwards is not a defined way to
|
|
28
|
+
* cancel it. `Head()` therefore never publishes a snapshot whose effective
|
|
29
|
+
* `http-equiv` is `refresh` from an entry that contains any reactive attribute,
|
|
30
|
+
* even when the destination is allowed: what cannot be withdrawn must not be
|
|
31
|
+
* handed over. Static refresh directives work as before, and every other
|
|
32
|
+
* reactive meta entry — description, keywords, Open Graph, non-refresh
|
|
33
|
+
* `http-equiv` — is unaffected.
|
|
34
|
+
*
|
|
15
35
|
* Supports dynamic title, meta tags, link tags, and structured data.
|
|
16
36
|
* Each instance tracks its own elements and effects for independent cleanup.
|
|
17
37
|
*/
|
|
@@ -99,7 +119,7 @@ declare function createWorkerPool<TInput = unknown, TOutput = unknown>(workerFn:
|
|
|
99
119
|
* Provides hooks and utilities to load, cache, and use WASM modules
|
|
100
120
|
* for performance-critical operations.
|
|
101
121
|
*/
|
|
102
|
-
interface WasmModuleState<T extends
|
|
122
|
+
interface WasmModuleState<T extends object = Record<string, unknown>> {
|
|
103
123
|
/** The instantiated WASM module exports, null until loaded */
|
|
104
124
|
instance: T | null;
|
|
105
125
|
/** Loading state */
|
|
@@ -109,26 +129,47 @@ interface WasmModuleState<T extends Record<string, unknown> = Record<string, unk
|
|
|
109
129
|
/** Whether the module has been loaded successfully */
|
|
110
130
|
ready: boolean;
|
|
111
131
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Configuration for the `wasm()` reactive wrapper.
|
|
134
|
+
*
|
|
135
|
+
* Deliberately the SAME option bag as the underlying `loadWasmModule()`
|
|
136
|
+
* primitive rather than a hand-copied subset. The primitive REQUIRES an
|
|
137
|
+
* explicit origin policy for URL sources (`allowedOrigins`, or an explicit
|
|
138
|
+
* `unsafelyAllowAnyOrigin` opt-in), and the wrapper previously had no way to
|
|
139
|
+
* express one — so `wasm("/math.wasm")` could only ever reject, and the public
|
|
140
|
+
* convenience API was unusable for its documented primary use case. Extending
|
|
141
|
+
* the primitive's type keeps the two from drifting again.
|
|
142
|
+
*/
|
|
143
|
+
interface WasmConfig extends LoadWasmOptions {
|
|
117
144
|
}
|
|
118
145
|
/**
|
|
119
146
|
* Hook to load and use a WebAssembly module reactively.
|
|
120
147
|
* Returns reactive state that updates when the module loads.
|
|
121
148
|
*
|
|
149
|
+
* A URL source needs an explicit origin policy — WASM is compiled code with
|
|
150
|
+
* imports into JS memory, so fetching it from an unvetted URL is a supply-chain
|
|
151
|
+
* risk equivalent to importing a remote module (CWE-829). Pass `allowedOrigins`,
|
|
152
|
+
* or `unsafelyAllowAnyOrigin: true` to opt out deliberately. An `ArrayBuffer` /
|
|
153
|
+
* `Uint8Array` source needs neither: the bytes are already in hand.
|
|
154
|
+
*
|
|
122
155
|
* @example
|
|
123
156
|
* ```ts
|
|
124
|
-
* const
|
|
157
|
+
* const math = wasm<{ add: (a: number, b: number) => number }>(
|
|
158
|
+
* 'https://cdn.example.com/math.wasm',
|
|
159
|
+
* { allowedOrigins: ['https://cdn.example.com'] },
|
|
160
|
+
* );
|
|
125
161
|
* // In reactive context:
|
|
126
|
-
* if (
|
|
127
|
-
* const result =
|
|
162
|
+
* if (math.ready()) {
|
|
163
|
+
* const result = math.instance()!.add(1, 2);
|
|
128
164
|
* }
|
|
129
165
|
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example Same-origin asset — still an explicit decision.
|
|
168
|
+
* ```ts
|
|
169
|
+
* const math = wasm('/math.wasm', { allowedOrigins: [location.origin] });
|
|
170
|
+
* ```
|
|
130
171
|
*/
|
|
131
|
-
declare function wasm<T extends
|
|
172
|
+
declare function wasm<T extends object = Record<string, unknown>>(source: string | ArrayBuffer | Uint8Array, config?: WasmConfig): {
|
|
132
173
|
instance: () => T | null;
|
|
133
174
|
loading: () => boolean;
|
|
134
175
|
error: () => Error | null;
|
|
@@ -156,7 +197,50 @@ interface LoadWasmOptions {
|
|
|
156
197
|
* a supply-chain risk equivalent to remote module import (CWE-829). */
|
|
157
198
|
unsafelyAllowAnyOrigin?: boolean;
|
|
158
199
|
}
|
|
159
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Load and instantiate a WebAssembly module — **positional/legacy form**.
|
|
202
|
+
*
|
|
203
|
+
* The second parameter is always `WebAssembly.Imports` and the third is always
|
|
204
|
+
* the cache key. There is no structural guessing, so a module namespace legally
|
|
205
|
+
* named `imports` or `cacheKey` is passed through unharmed.
|
|
206
|
+
*
|
|
207
|
+
* It previously accepted `WebAssembly.Imports | LoadWasmOptions` and decided
|
|
208
|
+
* between them at runtime by probing for `allowedOrigins` /
|
|
209
|
+
* `unsafelyAllowAnyOrigin`. That discriminator was unsound in both directions:
|
|
210
|
+
* an options bag carrying only `imports`/`cacheKey` was read as an import
|
|
211
|
+
* namespace (so `cacheKey` was dropped and the documented keyed-singleton
|
|
212
|
+
* guarantee silently did not hold), while a genuine namespace *named*
|
|
213
|
+
* `allowedOrigins` would have been read as options. No structural test can
|
|
214
|
+
* separate the two, because both are plain objects with caller-chosen keys — so
|
|
215
|
+
* the union was removed rather than re-guessed.
|
|
216
|
+
*
|
|
217
|
+
* For anything beyond imports and a cache key — notably the origin policy a URL
|
|
218
|
+
* source requires — use {@link loadWasmModuleWithOptions}.
|
|
219
|
+
*
|
|
220
|
+
* @see loadWasmModuleWithOptions
|
|
221
|
+
*/
|
|
222
|
+
declare function loadWasmModule(source: string | ArrayBuffer | Uint8Array, imports?: WebAssembly.Imports, cacheKey?: string): Promise<WebAssembly.Instance>;
|
|
223
|
+
/**
|
|
224
|
+
* Load and instantiate a WebAssembly module — **options form**.
|
|
225
|
+
*
|
|
226
|
+
* Unambiguous by construction: options live in their own parameter, so a WASM
|
|
227
|
+
* module namespace named `imports`, `cacheKey`, or `allowedOrigins` is just a
|
|
228
|
+
* namespace and nothing has to be inferred from object shape.
|
|
229
|
+
*
|
|
230
|
+
* This is the form to use for a URL source, since the origin policy
|
|
231
|
+
* (`allowedOrigins`, or an explicit `unsafelyAllowAnyOrigin`) can only be
|
|
232
|
+
* expressed here.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* const instance = await loadWasmModuleWithOptions("https://cdn.example.com/math.wasm", {
|
|
237
|
+
* allowedOrigins: ["https://cdn.example.com"],
|
|
238
|
+
* imports: { env: { log: console.log } },
|
|
239
|
+
* cacheKey: "math",
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare function loadWasmModuleWithOptions(source: string | ArrayBuffer | Uint8Array, opts?: LoadWasmOptions): Promise<WebAssembly.Instance>;
|
|
160
244
|
/**
|
|
161
245
|
* Preload and compile a WASM module without instantiating it.
|
|
162
246
|
* The compiled module is cached for instant instantiation later.
|
|
@@ -169,7 +253,7 @@ declare function preloadWasm(url: string, options?: {
|
|
|
169
253
|
* Create a type-safe bridge to a WASM module with automatic memory management.
|
|
170
254
|
* Provides helpers for passing strings and arrays between JS and WASM.
|
|
171
255
|
*/
|
|
172
|
-
declare function createWasmBridge<T extends
|
|
256
|
+
declare function createWasmBridge<T extends object>(instance: WebAssembly.Instance): {
|
|
173
257
|
exports: T;
|
|
174
258
|
memory: WebAssembly.Memory;
|
|
175
259
|
/** Allocate bytes in WASM memory (requires WASM to export malloc) */
|
|
@@ -192,7 +276,16 @@ declare function createWasmBridge<T extends Record<string, unknown>>(instance: W
|
|
|
192
276
|
readF64Array: (ptr: number, len: number) => Float64Array;
|
|
193
277
|
};
|
|
194
278
|
/**
|
|
195
|
-
*
|
|
279
|
+
* Invalidate the module, instance, and in-flight WASM cache generations.
|
|
280
|
+
*
|
|
281
|
+
* CONTRACT: work already started may still resolve to the callers that started
|
|
282
|
+
* it, but must never repopulate the caches after the clear. A load in flight
|
|
283
|
+
* across this call therefore still returns its instance to whoever awaited it,
|
|
284
|
+
* while the cache stays empty and the next load for that key compiles and
|
|
285
|
+
* instantiates afresh.
|
|
286
|
+
*
|
|
287
|
+
* This is an invalidation BARRIER, not a `Map.clear()`: emptying the maps alone
|
|
288
|
+
* would let the invalidated work write its results straight back in.
|
|
196
289
|
*/
|
|
197
290
|
declare function clearWasmCache(): void;
|
|
198
291
|
/**
|
|
@@ -216,7 +309,7 @@ interface MicroApp {
|
|
|
216
309
|
/** The outer host element */
|
|
217
310
|
element: HTMLElement;
|
|
218
311
|
}
|
|
219
|
-
interface SharedScope<T extends
|
|
312
|
+
interface SharedScope<T extends object> {
|
|
220
313
|
/** Get the current value for a key */
|
|
221
314
|
get<K extends keyof T>(key: K): T[K];
|
|
222
315
|
/** Set a value for a key, notifying all subscribers */
|
|
@@ -249,9 +342,16 @@ declare function createMicroApp(config: MicroAppConfig): MicroApp;
|
|
|
249
342
|
* Modules are cached by URL so repeated calls with the same URL return the
|
|
250
343
|
* same promise without issuing another network request.
|
|
251
344
|
*
|
|
345
|
+
* An origin policy is REQUIRED: importing a remote module is remote code
|
|
346
|
+
* execution, so the call is refused unless you either restrict it with
|
|
347
|
+
* `allowedOrigins` or opt out deliberately with `unsafelyAllowAnyOrigin`
|
|
348
|
+
* (CWE-829).
|
|
349
|
+
*
|
|
252
350
|
* @example
|
|
253
351
|
* ```ts
|
|
254
|
-
* const charts = await loadRemoteModule("https://cdn.example.com/charts.js"
|
|
352
|
+
* const charts = await loadRemoteModule("https://cdn.example.com/charts.js", {
|
|
353
|
+
* allowedOrigins: ["https://cdn.example.com"],
|
|
354
|
+
* });
|
|
255
355
|
* const el = charts.BarChart({ data: [1, 2, 3] });
|
|
256
356
|
* ```
|
|
257
357
|
*/
|
|
@@ -273,11 +373,19 @@ type RemoteLoader = () => Promise<{
|
|
|
273
373
|
* placeholder, fetches the remote module, then swaps in the real component.
|
|
274
374
|
* Subsequent calls render instantly from the cached module.
|
|
275
375
|
*
|
|
376
|
+
* The load is owner-scoped: if the container is disposed before the module
|
|
377
|
+
* arrives, the module is still cached (it is shared and expensive to fetch) but
|
|
378
|
+
* the component is NOT instantiated and nothing is written into the dead
|
|
379
|
+
* container.
|
|
380
|
+
*
|
|
276
381
|
* @example
|
|
277
382
|
* ```ts
|
|
278
383
|
* const RemoteHeader = defineRemoteComponent(
|
|
279
384
|
* "remote-header",
|
|
280
|
-
* () =>
|
|
385
|
+
* () =>
|
|
386
|
+
* loadRemoteModule("https://cdn.example.com/header.js", {
|
|
387
|
+
* allowedOrigins: ["https://cdn.example.com"],
|
|
388
|
+
* })
|
|
281
389
|
* );
|
|
282
390
|
*
|
|
283
391
|
* // Use it like any local component
|
|
@@ -309,7 +417,7 @@ declare function defineRemoteComponent(name: string, loader: RemoteLoader): Comp
|
|
|
309
417
|
* unsub();
|
|
310
418
|
* ```
|
|
311
419
|
*/
|
|
312
|
-
declare function createSharedScope<T extends
|
|
420
|
+
declare function createSharedScope<T extends object>(initialState: T): SharedScope<T>;
|
|
313
421
|
|
|
314
422
|
interface ServiceWorkerState {
|
|
315
423
|
registration: () => ServiceWorkerRegistration | null;
|
|
@@ -321,6 +429,26 @@ interface ServiceWorkerState {
|
|
|
321
429
|
}
|
|
322
430
|
/**
|
|
323
431
|
* serviceWorker registers and manages a service worker.
|
|
432
|
+
*
|
|
433
|
+
* LIFECYCLE CONTRACT
|
|
434
|
+
* ------------------
|
|
435
|
+
* Registration is asynchronous and `unregister()` can be called at any point
|
|
436
|
+
* during it, so this tracks four distinct situations rather than one boolean:
|
|
437
|
+
*
|
|
438
|
+
* registering register() in flight, nothing to unregister yet
|
|
439
|
+
* active registration adopted, listeners attached
|
|
440
|
+
* unregister asked requested before the registration resolved — the arriving
|
|
441
|
+
* registration is unregistered rather than adopted, so the
|
|
442
|
+
* browser never keeps a worker SibuJS has forgotten
|
|
443
|
+
* unregistered terminal, and only entered once unregister() actually
|
|
444
|
+
* RETURNED TRUE
|
|
445
|
+
*
|
|
446
|
+
* The last point is the important one. `ServiceWorkerRegistration.unregister()`
|
|
447
|
+
* returns `false` when the browser declined — the worker is still installed and
|
|
448
|
+
* still controlling pages. Treating that as teardown (detaching listeners,
|
|
449
|
+
* dropping the registration) left the wrapper permanently blind to a worker
|
|
450
|
+
* that was very much alive: no update tracking, no registration, no way back.
|
|
451
|
+
* A failed unregister therefore changes nothing.
|
|
324
452
|
*/
|
|
325
453
|
declare function serviceWorker(scriptUrl: string, options?: RegistrationOptions): ServiceWorkerState;
|
|
326
454
|
|
|
@@ -379,15 +507,97 @@ interface ActionResult<T> {
|
|
|
379
507
|
declare function createAction<T>(actionFn: ActionFn<T>): ActionResult<T>;
|
|
380
508
|
|
|
381
509
|
interface ScrollRestorationOptions {
|
|
510
|
+
/**
|
|
511
|
+
* `"auto"` (default) manages history-entry identity and restores the
|
|
512
|
+
* destination on `popstate`. It tags the entry the page started on, tags each
|
|
513
|
+
* entry you announce with `onNavigation()`, saves the outgoing position, and
|
|
514
|
+
* takes over `history.scrollRestoration` so the browser does not restore in
|
|
515
|
+
* parallel.
|
|
516
|
+
*
|
|
517
|
+
* What auto mode CANNOT do is notice a `history.pushState` it was not told
|
|
518
|
+
* about — no library can, short of monkey-patching `history` globally. Entries
|
|
519
|
+
* created without `onNavigation()` carry no identity and are simply not
|
|
520
|
+
* restored (a safe no-op, not a wrong position).
|
|
521
|
+
*
|
|
522
|
+
* `"manual"` attaches no listener, claims no native restoration, and tags
|
|
523
|
+
* nothing — you call `save()` / `restore()` yourself.
|
|
524
|
+
*/
|
|
382
525
|
mode?: "auto" | "manual";
|
|
526
|
+
/**
|
|
527
|
+
* Identifies the entry the user is currently on. Called once at construction
|
|
528
|
+
* to seed the current entry, and consulted as a fallback when nothing has
|
|
529
|
+
* been saved yet.
|
|
530
|
+
*
|
|
531
|
+
* Point it at whatever your app treats as a history identity — e.g.
|
|
532
|
+
* `() => router.location().key`. Pathname alone is usually wrong: `?page=2`
|
|
533
|
+
* and `#section` are distinct scroll positions to a user.
|
|
534
|
+
*/
|
|
535
|
+
getKey?: () => string | null;
|
|
536
|
+
/**
|
|
537
|
+
* History-state property used to tag entries so a `popstate` can name its
|
|
538
|
+
* DESTINATION. `popstate` reports the state of the entry being restored, and
|
|
539
|
+
* that is the only reliable way to know where the user just landed.
|
|
540
|
+
*/
|
|
541
|
+
stateKey?: string;
|
|
383
542
|
}
|
|
384
543
|
/**
|
|
385
544
|
* Manages scroll position saving and restoration keyed by route/key.
|
|
386
|
-
*
|
|
545
|
+
*
|
|
546
|
+
* AUTO MODE
|
|
547
|
+
* ---------
|
|
548
|
+
* `"auto"` previously attached a `popstate` listener that only ever called
|
|
549
|
+
* `save()` — so the documented "save/restore on popstate" behaviour was half
|
|
550
|
+
* implemented, and going Back never returned the viewport anywhere. The whole
|
|
551
|
+
* point of the feature was the half that was missing.
|
|
552
|
+
*
|
|
553
|
+
* A real restore needs to know WHICH entry the user landed on, so auto mode
|
|
554
|
+
* tags history entries with their key (`stateKey`) and the `popstate` handler
|
|
555
|
+
* reads that tag off `event.state`. On each pop it:
|
|
556
|
+
*
|
|
557
|
+
* 1. saves the position of the entry being LEFT (unless it is also the
|
|
558
|
+
* destination — a same-key pop is not a departure, and saving there would
|
|
559
|
+
* overwrite the stored position with the current one, destroying exactly
|
|
560
|
+
* the value about to be restored)
|
|
561
|
+
* 2. restores the destination's saved position, if one exists
|
|
562
|
+
*
|
|
563
|
+
* An unknown or absent destination key is a safe SibuJS no-op: no guessed
|
|
564
|
+
* position is applied. Note this is not a hand-off to the browser — auto mode
|
|
565
|
+
* leases `history.scrollRestoration` to `"manual"` while active, so nothing
|
|
566
|
+
* else is restoring either. The viewport simply stays where the engine left it.
|
|
567
|
+
*
|
|
568
|
+
* WHAT "AUTO" MEANS, EXACTLY
|
|
569
|
+
* --------------------------
|
|
570
|
+
* Reacting to `popstate` automatically is not enough on its own: the handler
|
|
571
|
+
* can only restore an entry that HAS an identity, and originally nothing ever
|
|
572
|
+
* gave one to the entry the page started on. The first Back a user pressed
|
|
573
|
+
* therefore restored nothing. Auto mode now owns identity as well as reaction:
|
|
574
|
+
*
|
|
575
|
+
* - the INITIAL entry is tagged at construction, and
|
|
576
|
+
* - `onNavigation(key)` tags each entry the application creates.
|
|
577
|
+
*
|
|
578
|
+
* That second half is an explicit hook rather than magic, and deliberately so:
|
|
579
|
+
* a library cannot observe arbitrary `history.pushState` calls without patching
|
|
580
|
+
* `history` globally, which would surprise every other consumer of it. So the
|
|
581
|
+
* honest contract is:
|
|
582
|
+
*
|
|
583
|
+
* > Auto mode restores any entry it was given identity for, and never guesses
|
|
584
|
+
* > about entries it was not told about.
|
|
585
|
+
*
|
|
586
|
+
* Auto mode also leases `history.scrollRestoration = "manual"` while active, so
|
|
587
|
+
* the browser is not restoring the viewport at the same time SibuJS is. The
|
|
588
|
+
* previous value is restored when the last controller is disposed.
|
|
387
589
|
*/
|
|
388
590
|
declare function scrollRestoration(options?: ScrollRestorationOptions): {
|
|
389
591
|
save: (key: string) => void;
|
|
390
592
|
restore: (key: string) => void;
|
|
593
|
+
/**
|
|
594
|
+
* Tell auto mode that the application created a new history entry.
|
|
595
|
+
*
|
|
596
|
+
* Records the outgoing entry's position, tags the new entry with `key`, and
|
|
597
|
+
* makes it current. Call it immediately after your `pushState` (before any
|
|
598
|
+
* scrolling), so the position captured is the one the user is leaving.
|
|
599
|
+
*/
|
|
600
|
+
onNavigation: (key: string) => void;
|
|
391
601
|
getPosition: (key: string) => {
|
|
392
602
|
x: number;
|
|
393
603
|
y: number;
|
|
@@ -416,4 +626,4 @@ declare function createMiddlewareChain(): {
|
|
|
416
626
|
}) => Promise<void>;
|
|
417
627
|
};
|
|
418
628
|
|
|
419
|
-
export { type ActionFn, type ActionResult, Head, type ISROptions, type LoadRemoteModuleOptions, type LoadWasmOptions, type MicroApp, type MicroAppConfig, type MiddlewareFn, type SSGOptions, type SSGResult, type ScrollRestorationOptions, type ServiceWorkerState, type SharedScope, type UseWorkerFnReturn, type UseWorkerReturn, type WasmConfig, type WasmModuleState, type WorkerPool, clearWasmCache, composeMiddleware, createAction, createISR, createMicroApp, createMiddlewareChain, createSharedScope, createWasmBridge, createWorkerPool, defineRemoteComponent, generateStaticSite, isWasmCached, loadRemoteModule, loadWasmModule, preloadWasm, scrollRestoration, serviceWorker, setCanonical, setStructuredData, wasm, worker, workerFn };
|
|
629
|
+
export { type ActionFn, type ActionResult, Head, type ISROptions, type LoadRemoteModuleOptions, type LoadWasmOptions, type MicroApp, type MicroAppConfig, type MiddlewareFn, type SSGOptions, type SSGResult, type ScrollRestorationOptions, type ServiceWorkerState, type SharedScope, type UseWorkerFnReturn, type UseWorkerReturn, type WasmConfig, type WasmModuleState, type WorkerPool, clearWasmCache, composeMiddleware, createAction, createISR, createMicroApp, createMiddlewareChain, createSharedScope, createWasmBridge, createWorkerPool, defineRemoteComponent, generateStaticSite, isWasmCached, loadRemoteModule, loadWasmModule, loadWasmModuleWithOptions, preloadWasm, scrollRestoration, serviceWorker, setCanonical, setStructuredData, wasm, worker, workerFn };
|
package/dist/ssr.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isWasmCached,
|
|
15
15
|
loadRemoteModule,
|
|
16
16
|
loadWasmModule,
|
|
17
|
+
loadWasmModuleWithOptions,
|
|
17
18
|
preloadWasm,
|
|
18
19
|
scrollRestoration,
|
|
19
20
|
serviceWorker,
|
|
@@ -22,8 +23,9 @@ import {
|
|
|
22
23
|
wasm,
|
|
23
24
|
worker,
|
|
24
25
|
workerFn
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-VFHIVEPF.js";
|
|
27
|
+
import "./chunk-52XFPGSN.js";
|
|
28
|
+
import "./chunk-ES2GERY2.js";
|
|
27
29
|
import {
|
|
28
30
|
collectStream,
|
|
29
31
|
deserializeState,
|
|
@@ -43,17 +45,17 @@ import {
|
|
|
43
45
|
ssrSuspense,
|
|
44
46
|
suspenseSwapScript,
|
|
45
47
|
trustHTML
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import "./chunk-
|
|
48
|
-
import "./chunk-
|
|
48
|
+
} from "./chunk-HYCCIYNS.js";
|
|
49
|
+
import "./chunk-DQVUBVNX.js";
|
|
50
|
+
import "./chunk-4MFZMLUU.js";
|
|
51
|
+
import "./chunk-5INI7D2L.js";
|
|
49
52
|
import "./chunk-7ZHH77QA.js";
|
|
50
|
-
import "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
53
|
-
import "./chunk-
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
-
import "./chunk-COY6PUD2.js";
|
|
53
|
+
import "./chunk-PBQEW5VW.js";
|
|
54
|
+
import "./chunk-TIRZCERI.js";
|
|
55
|
+
import "./chunk-DHDZ7IVN.js";
|
|
56
|
+
import "./chunk-W55YHPEP.js";
|
|
57
|
+
import "./chunk-ACBT6UZS.js";
|
|
58
|
+
import "./chunk-VPP2FONR.js";
|
|
57
59
|
export {
|
|
58
60
|
Head,
|
|
59
61
|
clearWasmCache,
|
|
@@ -78,6 +80,7 @@ export {
|
|
|
78
80
|
island,
|
|
79
81
|
loadRemoteModule,
|
|
80
82
|
loadWasmModule,
|
|
83
|
+
loadWasmModuleWithOptions,
|
|
81
84
|
preloadWasm,
|
|
82
85
|
renderToDocument,
|
|
83
86
|
renderToReadableStream,
|
|
@@ -25,7 +25,7 @@ declare function createModuleRegistry(): {
|
|
|
25
25
|
* Each key maps to a factory function that is invoked lazily on first access.
|
|
26
26
|
* Returns an object with only the requested exports.
|
|
27
27
|
*/
|
|
28
|
-
declare function createBundle<T extends
|
|
28
|
+
declare function createBundle<T extends object>(modules: Record<string, () => unknown>): T;
|
|
29
29
|
/**
|
|
30
30
|
* Lazy module loader that only imports a module when first accessed.
|
|
31
31
|
* Uses ES module dynamic import under the hood.
|
|
@@ -25,7 +25,7 @@ declare function createModuleRegistry(): {
|
|
|
25
25
|
* Each key maps to a factory function that is invoked lazily on first access.
|
|
26
26
|
* Returns an object with only the requested exports.
|
|
27
27
|
*/
|
|
28
|
-
declare function createBundle<T extends
|
|
28
|
+
declare function createBundle<T extends object>(modules: Record<string, () => unknown>): T;
|
|
29
29
|
/**
|
|
30
30
|
* Lazy module loader that only imports a module when first accessed.
|
|
31
31
|
* Uses ES module dynamic import under the hood.
|