@nifrajs/web-svelte 2.11.0 → 2.12.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/dist/client.d.ts +9 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +41 -7
- package/dist/client.js.map +1 -1
- package/package.json +11 -9
- package/src/client.ts +47 -6
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { MountRouterOptions, RenderProps } from "@nifrajs/web";
|
|
2
2
|
export { errorBoundary } from "./error.js";
|
|
3
3
|
/** Hydrate a server-rendered Svelte layout `chain` (with the loader `props`) inside `container`. */
|
|
4
|
-
export
|
|
4
|
+
export interface HydrationAssuranceOptions {
|
|
5
|
+
readonly onWarning?: (message: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function hydrate(chain: readonly unknown[], props: RenderProps, container: unknown, options?: HydrationAssuranceOptions): void;
|
|
8
|
+
/** Testing hook used by verification runners to observe Svelte warnings and identity. */
|
|
9
|
+
export declare const hydrationAssuranceHook: Readonly<{
|
|
10
|
+
framework: "svelte";
|
|
11
|
+
runtimeIdentity: () => object;
|
|
12
|
+
}>;
|
|
5
13
|
/**
|
|
6
14
|
* Hydrate a stateful Svelte Router. The `Router` component holds the store snapshot in `$state` and
|
|
7
15
|
* re-renders the matched layout chain on each store change - so client navigations swap routes without
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAenE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,oGAAoG;AACpG,wBAAgB,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAenE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,oGAAoG;AACpG,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/C;AAWD,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,yBAAyB,GAClC,IAAI,CAYN;AAED,yFAAyF;AACzF,eAAO,MAAM,sBAAsB;;2BAEZ,MAAM;EAC3B,CAAA;AAEF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAc7D"}
|
package/dist/client.js
CHANGED
|
@@ -12,13 +12,34 @@ import Router from "./Router.svelte";
|
|
|
12
12
|
// The `_error` boundary marker - Chain.svelte renders it as a <svelte:boundary>. Re-exported here so
|
|
13
13
|
// nifra's client codegen resolves it from `@nifrajs/web-svelte/client` alongside `mountRouter`.
|
|
14
14
|
export { errorBoundary } from "./error.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
function assuranceWarning() {
|
|
16
|
+
const value = globalThis[Symbol.for("nifra.hydration.assurance")];
|
|
17
|
+
if (typeof value !== "object" || value === null)
|
|
18
|
+
return undefined;
|
|
19
|
+
const callback = value.onWarning;
|
|
20
|
+
return typeof callback === "function" ? callback : undefined;
|
|
21
21
|
}
|
|
22
|
+
export function hydrate(chain, props, container, options) {
|
|
23
|
+
const warning = options?.onWarning ?? assuranceWarning();
|
|
24
|
+
const originalWarn = console.warn;
|
|
25
|
+
if (warning !== undefined)
|
|
26
|
+
console.warn = (...args) => warning(args.map(String).join(" "));
|
|
27
|
+
try {
|
|
28
|
+
svelteHydrate(Chain, {
|
|
29
|
+
target: container,
|
|
30
|
+
props: { chain, props, layoutData: props.layoutData },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
if (warning !== undefined)
|
|
35
|
+
console.warn = originalWarn;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Testing hook used by verification runners to observe Svelte warnings and identity. */
|
|
39
|
+
export const hydrationAssuranceHook = Object.freeze({
|
|
40
|
+
framework: "svelte",
|
|
41
|
+
runtimeIdentity: () => svelteHydrate,
|
|
42
|
+
});
|
|
22
43
|
/**
|
|
23
44
|
* Hydrate a stateful Svelte Router. The `Router` component holds the store snapshot in `$state` and
|
|
24
45
|
* re-renders the matched layout chain on each store change - so client navigations swap routes without
|
|
@@ -28,6 +49,19 @@ export function hydrate(chain, props, container) {
|
|
|
28
49
|
export function mountRouter(options) {
|
|
29
50
|
const { router, routes, searchSchemas, container } = options;
|
|
30
51
|
setMountedRouter(router); // expose it to useFetcher/useFetchers (same page, client-only)
|
|
31
|
-
|
|
52
|
+
const warning = assuranceWarning();
|
|
53
|
+
const originalWarn = console.warn;
|
|
54
|
+
if (warning !== undefined)
|
|
55
|
+
console.warn = (...args) => warning(args.map(String).join(" "));
|
|
56
|
+
try {
|
|
57
|
+
svelteHydrate(Router, {
|
|
58
|
+
target: container,
|
|
59
|
+
props: { router, routes, searchSchemas },
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (warning !== undefined)
|
|
64
|
+
console.warn = originalWarn;
|
|
65
|
+
}
|
|
32
66
|
}
|
|
33
67
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,KAAK,MAAM,gBAAgB,C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/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/web-svelte",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Svelte 5 render adapter for @nifrajs/web - SSR + hydration + the .svelte compiler Bun-plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
7
7
|
"typescript",
|
|
8
8
|
"nifra",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
9
|
+
"svelte",
|
|
10
|
+
"svelte5",
|
|
11
|
+
"ssr",
|
|
12
|
+
"hydration",
|
|
13
|
+
"render-adapter",
|
|
14
|
+
"full-stack"
|
|
13
15
|
],
|
|
14
16
|
"type": "module",
|
|
15
17
|
"main": "./dist/index.js",
|
|
@@ -98,10 +100,10 @@
|
|
|
98
100
|
"access": "public"
|
|
99
101
|
},
|
|
100
102
|
"dependencies": {
|
|
101
|
-
"@nifrajs/core": "2.
|
|
102
|
-
"@nifrajs/i18n": "2.
|
|
103
|
-
"@nifrajs/image": "2.
|
|
104
|
-
"@nifrajs/web": "2.
|
|
103
|
+
"@nifrajs/core": "2.12.0",
|
|
104
|
+
"@nifrajs/i18n": "2.12.0",
|
|
105
|
+
"@nifrajs/image": "2.12.0",
|
|
106
|
+
"@nifrajs/web": "2.12.0"
|
|
105
107
|
},
|
|
106
108
|
"peerDependencies": {
|
|
107
109
|
"mdsvex": "^0.12",
|
package/src/client.ts
CHANGED
|
@@ -16,13 +16,44 @@ import Router from "./Router.svelte"
|
|
|
16
16
|
export { errorBoundary } from "./error.ts"
|
|
17
17
|
|
|
18
18
|
/** Hydrate a server-rendered Svelte layout `chain` (with the loader `props`) inside `container`. */
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
target: container as Element,
|
|
22
|
-
props: { chain, props, layoutData: props.layoutData },
|
|
23
|
-
})
|
|
19
|
+
export interface HydrationAssuranceOptions {
|
|
20
|
+
readonly onWarning?: (message: string) => void
|
|
24
21
|
}
|
|
25
22
|
|
|
23
|
+
function assuranceWarning(): ((message: string) => void) | undefined {
|
|
24
|
+
const value = (globalThis as unknown as Record<PropertyKey, unknown>)[
|
|
25
|
+
Symbol.for("nifra.hydration.assurance")
|
|
26
|
+
]
|
|
27
|
+
if (typeof value !== "object" || value === null) return undefined
|
|
28
|
+
const callback = (value as { onWarning?: unknown }).onWarning
|
|
29
|
+
return typeof callback === "function" ? (callback as (message: string) => void) : undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function hydrate(
|
|
33
|
+
chain: readonly unknown[],
|
|
34
|
+
props: RenderProps,
|
|
35
|
+
container: unknown,
|
|
36
|
+
options?: HydrationAssuranceOptions,
|
|
37
|
+
): void {
|
|
38
|
+
const warning = options?.onWarning ?? assuranceWarning()
|
|
39
|
+
const originalWarn = console.warn
|
|
40
|
+
if (warning !== undefined) console.warn = (...args) => warning(args.map(String).join(" "))
|
|
41
|
+
try {
|
|
42
|
+
svelteHydrate(Chain, {
|
|
43
|
+
target: container as Element,
|
|
44
|
+
props: { chain, props, layoutData: props.layoutData },
|
|
45
|
+
})
|
|
46
|
+
} finally {
|
|
47
|
+
if (warning !== undefined) console.warn = originalWarn
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Testing hook used by verification runners to observe Svelte warnings and identity. */
|
|
52
|
+
export const hydrationAssuranceHook = Object.freeze({
|
|
53
|
+
framework: "svelte" as const,
|
|
54
|
+
runtimeIdentity: (): object => svelteHydrate,
|
|
55
|
+
})
|
|
56
|
+
|
|
26
57
|
/**
|
|
27
58
|
* Hydrate a stateful Svelte Router. The `Router` component holds the store snapshot in `$state` and
|
|
28
59
|
* re-renders the matched layout chain on each store change - so client navigations swap routes without
|
|
@@ -32,5 +63,15 @@ export function hydrate(chain: readonly unknown[], props: RenderProps, container
|
|
|
32
63
|
export function mountRouter(options: MountRouterOptions): void {
|
|
33
64
|
const { router, routes, searchSchemas, container } = options
|
|
34
65
|
setMountedRouter(router) // expose it to useFetcher/useFetchers (same page, client-only)
|
|
35
|
-
|
|
66
|
+
const warning = assuranceWarning()
|
|
67
|
+
const originalWarn = console.warn
|
|
68
|
+
if (warning !== undefined) console.warn = (...args) => warning(args.map(String).join(" "))
|
|
69
|
+
try {
|
|
70
|
+
svelteHydrate(Router, {
|
|
71
|
+
target: container as Element,
|
|
72
|
+
props: { router, routes, searchSchemas },
|
|
73
|
+
})
|
|
74
|
+
} finally {
|
|
75
|
+
if (warning !== undefined) console.warn = originalWarn
|
|
76
|
+
}
|
|
36
77
|
}
|