@rpcbase/server 0.519.0 → 0.521.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.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/rts/ssrHydration.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4563,6 +4563,13 @@ const hasSessionUser = (req) => {
|
|
|
4563
4563
|
const escapeForInlineScript = (value) => {
|
|
4564
4564
|
return value.replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
4565
4565
|
};
|
|
4566
|
+
const toSerializedHydrationPayload = (payload) => {
|
|
4567
|
+
try {
|
|
4568
|
+
return JSON.parse(JSON.stringify(payload));
|
|
4569
|
+
} catch {
|
|
4570
|
+
return null;
|
|
4571
|
+
}
|
|
4572
|
+
};
|
|
4566
4573
|
const createRtsSsrCollector = (req, opts) => {
|
|
4567
4574
|
const maxQueries = DEFAULT_MAX_QUERIES;
|
|
4568
4575
|
const maxDocsPerQuery = DEFAULT_MAX_DOCS_PER_QUERY;
|
|
@@ -4649,15 +4656,17 @@ const createRtsSsrCollector = (req, opts) => {
|
|
|
4649
4656
|
break;
|
|
4650
4657
|
}
|
|
4651
4658
|
}
|
|
4659
|
+
const serializedPayload = toSerializedHydrationPayload(payload);
|
|
4660
|
+
if (!serializedPayload?.queries.length) return null;
|
|
4652
4661
|
resolved.clear();
|
|
4653
4662
|
resolvedPageInfo.clear();
|
|
4654
4663
|
resolvedTotalCount.clear();
|
|
4655
|
-
for (const entry of
|
|
4664
|
+
for (const entry of serializedPayload.queries) {
|
|
4656
4665
|
resolved.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.data);
|
|
4657
4666
|
resolvedPageInfo.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.pageInfo);
|
|
4658
4667
|
resolvedTotalCount.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.totalCount);
|
|
4659
4668
|
}
|
|
4660
|
-
return
|
|
4669
|
+
return serializedPayload;
|
|
4661
4670
|
};
|
|
4662
4671
|
const hasRegistrations = () => registrations.size > 0;
|
|
4663
4672
|
return {
|