@nifrajs/web-preact 2.6.0 → 2.7.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/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/preact-render.d.ts +1 -1
- package/dist/preact-render.d.ts.map +1 -1
- package/dist/preact-render.js +9 -3
- package/dist/preact-render.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +9 -5
- package/src/preact-render.ts +9 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAWjD,8EAA8E;AAC9E,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAWjD,8EAA8E;AAC9E,eAAO,MAAM,aAAa,EAAE,aAyB3B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -12,11 +12,15 @@ export const preactAdapter = {
|
|
|
12
12
|
// Synchronous one-pass render for non-deferred pages (renderPage's buffered fast path). The sync
|
|
13
13
|
// `renderToString` emits the same markup as the stream renderer without the chunking machinery.
|
|
14
14
|
//
|
|
15
|
-
//
|
|
16
|
-
// runtime SSR - see ./preact-render).
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
// The first render resolves the renderer lazily (from the consumer app's node_modules under Bun
|
|
16
|
+
// runtime SSR - see ./preact-render). Once loaded, return the string directly so renderPage can use
|
|
17
|
+
// its synchronous buffered fast path on every subsequent request.
|
|
18
|
+
renderToString(chain, props) {
|
|
19
|
+
const loaded = preactRenderToString();
|
|
20
|
+
if (loaded instanceof Promise) {
|
|
21
|
+
return loaded.then(({ renderToString }) => renderToString(compose(chain, props)));
|
|
22
|
+
}
|
|
23
|
+
return loaded.renderToString(compose(chain, props));
|
|
20
24
|
},
|
|
21
25
|
async renderToStream(chain, props) {
|
|
22
26
|
// `renderToReadableStream` yields a Web ReadableStream<Uint8Array>; <Suspense> boundaries
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE/E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,iGAAiG;IACjG,gGAAgG;IAChG,EAAE;IACF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE/E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,iGAAiG;IACjG,gGAAgG;IAChG,EAAE;IACF,gGAAgG;IAChG,oGAAoG;IACpG,kEAAkE;IAClE,cAAc,CAAC,KAAK,EAAE,KAAK;QACzB,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAA;QACrC,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;QACnF,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK;QAC/B,0FAA0F;QAC1F,uEAAuE;QACvE,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,oBAAoB,EAAE,CAAA;QAC/D,OAAO,sBAAsB,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,iGAAiG;IACjG,kGAAkG;IAClG,aAAa;QACX,OAAO,EAAE,CAAA;IACX,CAAC;CACF,CAAA"}
|
package/dist/preact-render.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface PreactRenderToStream {
|
|
|
28
28
|
renderToReadableStream(node: VNode): ReadableStream<Uint8Array>;
|
|
29
29
|
}
|
|
30
30
|
/** Get `preact-render-to-string` bound to the consumer app's `preact`. Cached after the first call. */
|
|
31
|
-
export declare function preactRenderToString(): Promise<PreactRenderToString>;
|
|
31
|
+
export declare function preactRenderToString(): PreactRenderToString | Promise<PreactRenderToString>;
|
|
32
32
|
/** Get `preact-render-to-string/stream` bound to the consumer app's `preact`. Cached after the first call. */
|
|
33
33
|
export declare function preactRenderToStream(): Promise<PreactRenderToStream>;
|
|
34
34
|
/** A `Bun.resolveSync`-shaped function (specifier, from) → absolute path. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preact-render.d.ts","sourceRoot":"","sources":["../src/preact-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CACpC;AACD,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC,sBAAsB,CAAC,IAAI,EAAE,KAAK,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;CAChE;
|
|
1
|
+
{"version":3,"file":"preact-render.d.ts","sourceRoot":"","sources":["../src/preact-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CACpC;AACD,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC,sBAAsB,CAAC,IAAI,EAAE,KAAK,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;CAChE;AA0BD,uGAAuG;AACvG,wBAAgB,oBAAoB,IAAI,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAS3F;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAIpE;AAED,6EAA6E;AAC7E,KAAK,WAAW,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;AAE9D;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAC1B,SAAS,EAAE,yBAAyB,GAAG,gCAAgC,EACvE,OAAO,GAAE,WAAW,GAAG,SAA2B,GACjD,OAAO,CAAC,CAAC,CAAC,CAsBZ"}
|
package/dist/preact-render.js
CHANGED
|
@@ -30,6 +30,7 @@ const bunResolver = globalThis.Bun;
|
|
|
30
30
|
const hasBunResolveSync = typeof bunResolver?.resolveSync === "function";
|
|
31
31
|
// Cache the in-flight Promises (not the modules) so concurrent first renders share one import each.
|
|
32
32
|
let cachedSync;
|
|
33
|
+
let loadedSync;
|
|
33
34
|
let cachedStream;
|
|
34
35
|
/**
|
|
35
36
|
* The consumer app root used to re-root the renderer. `nifra dev` / `nifra start` run with the CLI's
|
|
@@ -42,9 +43,14 @@ function appRoot() {
|
|
|
42
43
|
}
|
|
43
44
|
/** Get `preact-render-to-string` bound to the consumer app's `preact`. Cached after the first call. */
|
|
44
45
|
export function preactRenderToString() {
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
47
|
-
cachedSync
|
|
46
|
+
if (loadedSync !== undefined)
|
|
47
|
+
return loadedSync;
|
|
48
|
+
if (cachedSync === undefined) {
|
|
49
|
+
cachedSync = load("preact-render-to-string").then((loaded) => {
|
|
50
|
+
loadedSync = loaded;
|
|
51
|
+
return loaded;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
48
54
|
return cachedSync;
|
|
49
55
|
}
|
|
50
56
|
/** Get `preact-render-to-string/stream` bound to the consumer app's `preact`. Cached after the first call. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preact-render.js","sourceRoot":"","sources":["../src/preact-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;AAmBH,MAAM,WAAW,GAAI,UAA6C,CAAC,GAAG,CAAA;AACtE,MAAM,iBAAiB,GAAG,OAAO,WAAW,EAAE,WAAW,KAAK,UAAU,CAAA;AAExE,oGAAoG;AACpG,IAAI,UAAqD,CAAA;AACzD,IAAI,YAAuD,CAAA;AAE3D;;;;;GAKG;AACH,SAAS,OAAO;IACd,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;AACtB,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,oBAAoB;IAClC,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAA;IAC/C,UAAU,GAAG,IAAI,CAAuB,yBAAyB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"preact-render.js","sourceRoot":"","sources":["../src/preact-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;AAmBH,MAAM,WAAW,GAAI,UAA6C,CAAC,GAAG,CAAA;AACtE,MAAM,iBAAiB,GAAG,OAAO,WAAW,EAAE,WAAW,KAAK,UAAU,CAAA;AAExE,oGAAoG;AACpG,IAAI,UAAqD,CAAA;AACzD,IAAI,UAA4C,CAAA;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CAAA;IAC9D,CAAC;IACD,OAAO,CAAC,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAM,CAAA;AACvD,CAAC;AAED,gHAAgH;AAChH,SAAS,aAAa;IACpB,OAAO,iBAAiB,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS;QAChE,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC;QAC3C,CAAC,CAAC,SAAS,CAAA;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/web-preact",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Preact render adapter for @nifrajs/web - streaming SSR + hydration (no build plugin).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -80,10 +80,10 @@
|
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@nifrajs/core": "2.
|
|
84
|
-
"@nifrajs/i18n": "2.
|
|
85
|
-
"@nifrajs/image": "2.
|
|
86
|
-
"@nifrajs/web": "2.
|
|
83
|
+
"@nifrajs/core": "2.7.0",
|
|
84
|
+
"@nifrajs/i18n": "2.7.0",
|
|
85
|
+
"@nifrajs/image": "2.7.0",
|
|
86
|
+
"@nifrajs/web": "2.7.0",
|
|
87
87
|
"preact-render-to-string": "^6.5.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -14,11 +14,15 @@ export const preactAdapter: RenderAdapter = {
|
|
|
14
14
|
// Synchronous one-pass render for non-deferred pages (renderPage's buffered fast path). The sync
|
|
15
15
|
// `renderToString` emits the same markup as the stream renderer without the chunking machinery.
|
|
16
16
|
//
|
|
17
|
-
//
|
|
18
|
-
// runtime SSR - see ./preact-render).
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
// The first render resolves the renderer lazily (from the consumer app's node_modules under Bun
|
|
18
|
+
// runtime SSR - see ./preact-render). Once loaded, return the string directly so renderPage can use
|
|
19
|
+
// its synchronous buffered fast path on every subsequent request.
|
|
20
|
+
renderToString(chain, props) {
|
|
21
|
+
const loaded = preactRenderToString()
|
|
22
|
+
if (loaded instanceof Promise) {
|
|
23
|
+
return loaded.then(({ renderToString }) => renderToString(compose(chain, props)))
|
|
24
|
+
}
|
|
25
|
+
return loaded.renderToString(compose(chain, props))
|
|
22
26
|
},
|
|
23
27
|
async renderToStream(chain, props) {
|
|
24
28
|
// `renderToReadableStream` yields a Web ReadableStream<Uint8Array>; <Suspense> boundaries
|
package/src/preact-render.ts
CHANGED
|
@@ -41,6 +41,7 @@ const hasBunResolveSync = typeof bunResolver?.resolveSync === "function"
|
|
|
41
41
|
|
|
42
42
|
// Cache the in-flight Promises (not the modules) so concurrent first renders share one import each.
|
|
43
43
|
let cachedSync: Promise<PreactRenderToString> | undefined
|
|
44
|
+
let loadedSync: PreactRenderToString | undefined
|
|
44
45
|
let cachedStream: Promise<PreactRenderToStream> | undefined
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -54,9 +55,14 @@ function appRoot(): string {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/** Get `preact-render-to-string` bound to the consumer app's `preact`. Cached after the first call. */
|
|
57
|
-
export function preactRenderToString(): Promise<PreactRenderToString> {
|
|
58
|
-
if (
|
|
59
|
-
cachedSync
|
|
58
|
+
export function preactRenderToString(): PreactRenderToString | Promise<PreactRenderToString> {
|
|
59
|
+
if (loadedSync !== undefined) return loadedSync
|
|
60
|
+
if (cachedSync === undefined) {
|
|
61
|
+
cachedSync = load<PreactRenderToString>("preact-render-to-string").then((loaded) => {
|
|
62
|
+
loadedSync = loaded
|
|
63
|
+
return loaded
|
|
64
|
+
})
|
|
65
|
+
}
|
|
60
66
|
return cachedSync
|
|
61
67
|
}
|
|
62
68
|
|