@ecopages/ecopages-jsx 0.2.0-alpha.35 → 0.2.0-alpha.36
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/ecopages-jsx",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.36",
|
|
4
4
|
"description": "JSX integration plugin for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@ecopages/core": "0.2.0-alpha.34",
|
|
25
|
-
"@ecopages/jsx": "0.3.0-alpha.
|
|
26
|
-
"@ecopages/radiant": "0.3.0-alpha.
|
|
25
|
+
"@ecopages/jsx": "0.3.0-alpha.23",
|
|
26
|
+
"@ecopages/radiant": "0.3.0-alpha.23"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createMarkupNodeLike } from "@ecopages/jsx";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createServerHydrationBindingState,
|
|
4
|
+
isServerRenderHydrationActive,
|
|
5
|
+
withServerHydrationBindingState
|
|
6
|
+
} from "@ecopages/jsx/server";
|
|
3
7
|
class EcopagesJsxRadiantSsrPolicy {
|
|
4
8
|
static runtimeModules;
|
|
5
9
|
static runtimeModulesPromise;
|
|
@@ -52,9 +56,12 @@ class EcopagesJsxRadiantSsrPolicy {
|
|
|
52
56
|
return void 0;
|
|
53
57
|
}
|
|
54
58
|
return createMarkupNodeLike(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
withServerHydrationBindingState(
|
|
60
|
+
createServerHydrationBindingState(),
|
|
61
|
+
() => renderBridge.renderHostToString({
|
|
62
|
+
mode: isServerRenderHydrationActive() ? "hydrate" : "plain"
|
|
63
|
+
})
|
|
64
|
+
)
|
|
58
65
|
);
|
|
59
66
|
}
|
|
60
67
|
async ensureRuntimeInstalled() {
|
|
@@ -24,6 +24,13 @@ export declare class EcopagesJsxRenderSession {
|
|
|
24
24
|
* JSX SSR scope bridge.
|
|
25
25
|
*/
|
|
26
26
|
withActiveScope<T>(render: () => T): T;
|
|
27
|
+
/**
|
|
28
|
+
* Runs work with the current page-level hydrate binding namespace attached to JSX SSR.
|
|
29
|
+
*
|
|
30
|
+
* This lets page, layout, and document renders participate in one client-owned
|
|
31
|
+
* hydration root even though Ecopages composes them through multiple sibling render calls.
|
|
32
|
+
*/
|
|
33
|
+
withHydrationBindingScope<T>(render: () => T): T;
|
|
27
34
|
beginCollectedAssetFrame(): ProcessedAsset[];
|
|
28
35
|
endCollectedAssetFrame(frame: ProcessedAsset[]): ProcessedAsset[];
|
|
29
36
|
recordCollectedAssets(collectedAssets: ProcessedAsset[]): ProcessedAsset[];
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createServerHydrationBindingState,
|
|
4
|
+
getActiveSsrScopeValue,
|
|
5
|
+
withActiveSsrScopeValue,
|
|
6
|
+
withServerHydrationBindingState
|
|
7
|
+
} from "@ecopages/jsx/server";
|
|
3
8
|
const ECOPAGES_JSX_SSR_RENDER_STATE_KEY = /* @__PURE__ */ Symbol.for("@ecopages/ecopages-jsx.ssr-render-state");
|
|
4
9
|
const renderStateStorage = new AsyncLocalStorage();
|
|
5
10
|
class EcopagesJsxRenderSession {
|
|
@@ -27,13 +32,23 @@ class EcopagesJsxRenderSession {
|
|
|
27
32
|
return renderStateStorage.run(jsxScopeState, () => render());
|
|
28
33
|
}
|
|
29
34
|
const state = {
|
|
30
|
-
collectedAssetFrames: []
|
|
35
|
+
collectedAssetFrames: [],
|
|
36
|
+
hydrationBindingState: createServerHydrationBindingState()
|
|
31
37
|
};
|
|
32
38
|
return renderStateStorage.run(
|
|
33
39
|
state,
|
|
34
40
|
() => withActiveSsrScopeValue(ECOPAGES_JSX_SSR_RENDER_STATE_KEY, state, render)
|
|
35
41
|
);
|
|
36
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Runs work with the current page-level hydrate binding namespace attached to JSX SSR.
|
|
45
|
+
*
|
|
46
|
+
* This lets page, layout, and document renders participate in one client-owned
|
|
47
|
+
* hydration root even though Ecopages composes them through multiple sibling render calls.
|
|
48
|
+
*/
|
|
49
|
+
withHydrationBindingScope(render) {
|
|
50
|
+
return withServerHydrationBindingState(this.getState().hydrationBindingState, render);
|
|
51
|
+
}
|
|
37
52
|
beginCollectedAssetFrame() {
|
|
38
53
|
const state = this.getState();
|
|
39
54
|
const frame = [];
|
|
@@ -212,9 +212,8 @@ class EcopagesJsxRenderer extends IntegrationRenderer {
|
|
|
212
212
|
}
|
|
213
213
|
async renderJsx(value) {
|
|
214
214
|
const collectedAssets = [];
|
|
215
|
-
const html = await this.
|
|
216
|
-
collectedAssets,
|
|
217
|
-
() => renderToString(value, { mode: "hydrate" })
|
|
215
|
+
const html = await this.renderSession.withHydrationBindingScope(
|
|
216
|
+
() => this.withCustomElementRenderHook(collectedAssets, () => renderToString(value, { mode: "hydrate" }))
|
|
218
217
|
);
|
|
219
218
|
const dedupedAssets = this.renderSession.recordCollectedAssets(collectedAssets);
|
|
220
219
|
return {
|