@zenithbuild/runtime 0.7.11 → 0.7.12
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/expressions.js +20 -2
- package/dist/payload.d.ts +4 -0
- package/dist/payload.js +7 -0
- package/package.json +1 -1
package/dist/expressions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { throwZenithRuntimeError, DOCS_LINKS } from './diagnostics.js';
|
|
2
2
|
import { _fragment } from './markup.js';
|
|
3
|
+
import { readSsrPayload } from './payload.js';
|
|
3
4
|
export const UNRESOLVED_LITERAL = Symbol('unresolved_literal');
|
|
4
5
|
const OWN = Object.prototype.hasOwnProperty;
|
|
5
6
|
export const STRICT_MEMBER_CHAIN_LITERAL_RE = /^(?:true|false|null|undefined|[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*)$/;
|
|
@@ -56,12 +57,13 @@ export function _evaluateExpression(binding, stateValues, stateKeys, signalMap,
|
|
|
56
57
|
if (primitiveValue !== UNRESOLVED_LITERAL) {
|
|
57
58
|
return primitiveValue;
|
|
58
59
|
}
|
|
59
|
-
const
|
|
60
|
+
const hydrationSsrData = _resolveHydrationSsrData(binding, ssrData);
|
|
61
|
+
const canonicalRootValue = _rcr(trimmedLiteral, params, hydrationSsrData, runtimeProps);
|
|
60
62
|
if (canonicalRootValue !== UNRESOLVED_LITERAL) {
|
|
61
63
|
return canonicalRootValue;
|
|
62
64
|
}
|
|
63
65
|
const source = _resolveBindingSource(binding, markerBinding, eventBinding);
|
|
64
|
-
const strictMemberValue = _resolveStrictMemberChainLiteral(trimmedLiteral, stateValues, stateKeys, params,
|
|
66
|
+
const strictMemberValue = _resolveStrictMemberChainLiteral(trimmedLiteral, stateValues, stateKeys, params, hydrationSsrData, mode, runtimeProps, binding.marker_index, source);
|
|
65
67
|
if (strictMemberValue !== UNRESOLVED_LITERAL) {
|
|
66
68
|
return strictMemberValue;
|
|
67
69
|
}
|
|
@@ -236,6 +238,22 @@ function _rcb(binding, componentBindings) {
|
|
|
236
238
|
}
|
|
237
239
|
return instanceBindings[binding.component_binding];
|
|
238
240
|
}
|
|
241
|
+
function _resolveHydrationSsrData(binding, ssrData) {
|
|
242
|
+
const payload = readSsrPayload(ssrData);
|
|
243
|
+
const scopedDataKey = typeof binding?.scoped_data_key === 'string' && binding.scoped_data_key.length > 0
|
|
244
|
+
? binding.scoped_data_key
|
|
245
|
+
: null;
|
|
246
|
+
if (!scopedDataKey) {
|
|
247
|
+
return payload.route;
|
|
248
|
+
}
|
|
249
|
+
if (!OWN.call(payload.scoped, scopedDataKey) || !_isObjectRecord(payload.scoped[scopedDataKey])) {
|
|
250
|
+
throw new Error(`[Zenith:ScopedServerData] Missing scoped hydration payload for ${scopedDataKey}`);
|
|
251
|
+
}
|
|
252
|
+
return payload.scoped[scopedDataKey];
|
|
253
|
+
}
|
|
254
|
+
function _isObjectRecord(value) {
|
|
255
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
256
|
+
}
|
|
239
257
|
function _rcr(literal, params, ssrData, props) {
|
|
240
258
|
if (literal === 'data' || literal === 'ssr')
|
|
241
259
|
return ssrData;
|
package/dist/payload.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export function _validatePayload(payload: any): {
|
|
|
13
13
|
props: any;
|
|
14
14
|
exprFns: any;
|
|
15
15
|
};
|
|
16
|
+
export function readSsrPayload(raw: any): {
|
|
17
|
+
route: any;
|
|
18
|
+
scoped: any;
|
|
19
|
+
};
|
|
16
20
|
export function _resolveComponentProps(propTable: any, signalMap: any): any;
|
|
17
21
|
export function _deepFreezePayload(obj: any): void;
|
|
18
22
|
export function _isHydrationRefObject(obj: any): boolean;
|
package/dist/payload.js
CHANGED
|
@@ -139,6 +139,13 @@ export function _validatePayload(payload) {
|
|
|
139
139
|
exprFns: _f(exprFns)
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
+
export function readSsrPayload(raw) {
|
|
143
|
+
const root = _ir(raw) ? raw : {};
|
|
144
|
+
return {
|
|
145
|
+
route: root,
|
|
146
|
+
scoped: _ir(root.scoped) ? root.scoped : {}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
142
149
|
function _assertValidSourceSpan(source, contextLabel) {
|
|
143
150
|
if (source === undefined || source === null) {
|
|
144
151
|
return;
|