mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
perf: add dirty persist and hydrate/layout optimizations
This commit is contained in:
20
vendor/wasm/stbme_core.js
vendored
20
vendor/wasm/stbme_core.js
vendored
@@ -73,6 +73,10 @@ async function loadFromWasmPackArtifacts() {
|
||||
typeof module.build_hydrate_records === "function"
|
||||
? module.build_hydrate_records
|
||||
: null,
|
||||
build_hydrate_records_compact:
|
||||
typeof module.build_hydrate_records_compact === "function"
|
||||
? module.build_hydrate_records_compact
|
||||
: null,
|
||||
build_persist_delta_compact_hash:
|
||||
typeof module.build_persist_delta_compact_hash === "function"
|
||||
? module.build_persist_delta_compact_hash
|
||||
@@ -230,16 +234,26 @@ export async function installNativeHydrateHook() {
|
||||
const module = await loadNativeModule({
|
||||
forceRetry: shouldRetryNativeLoad(),
|
||||
});
|
||||
if (!module || typeof module.build_hydrate_records !== "function") {
|
||||
if (
|
||||
!module ||
|
||||
(typeof module.build_hydrate_records !== "function" &&
|
||||
typeof module.build_hydrate_records_compact !== "function")
|
||||
) {
|
||||
throw new Error("native hydrate builder unavailable");
|
||||
}
|
||||
|
||||
globalThis.__stBmeNativeHydrateSnapshotRecords = (snapshotView = {}, options = {}) => {
|
||||
const raw = module.build_hydrate_records({
|
||||
const hydratePayload = {
|
||||
nodes: Array.isArray(snapshotView?.nodes) ? snapshotView.nodes : [],
|
||||
edges: Array.isArray(snapshotView?.edges) ? snapshotView.edges : [],
|
||||
recordsNormalized: options?.recordsNormalized === true,
|
||||
});
|
||||
preferCompactResult: options?.preferCompactResult !== false,
|
||||
};
|
||||
const raw =
|
||||
typeof module.build_hydrate_records_compact === "function" &&
|
||||
options?.preferCompactResult !== false
|
||||
? module.build_hydrate_records_compact(hydratePayload)
|
||||
: module.build_hydrate_records(hydratePayload);
|
||||
return raw && typeof raw === "object" ? raw : null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user