mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
perf: add native hydrate wasm path
This commit is contained in:
24
vendor/wasm/stbme_core.js
vendored
24
vendor/wasm/stbme_core.js
vendored
@@ -69,6 +69,10 @@ async function loadFromWasmPackArtifacts() {
|
||||
|
||||
return {
|
||||
solve_layout: module.solve_layout,
|
||||
build_hydrate_records:
|
||||
typeof module.build_hydrate_records === "function"
|
||||
? module.build_hydrate_records
|
||||
: null,
|
||||
build_persist_delta_compact_hash:
|
||||
typeof module.build_persist_delta_compact_hash === "function"
|
||||
? module.build_persist_delta_compact_hash
|
||||
@@ -222,6 +226,26 @@ export async function installNativePersistDeltaHook() {
|
||||
return getNativeModuleStatus();
|
||||
}
|
||||
|
||||
export async function installNativeHydrateHook() {
|
||||
const module = await loadNativeModule({
|
||||
forceRetry: shouldRetryNativeLoad(),
|
||||
});
|
||||
if (!module || typeof module.build_hydrate_records !== "function") {
|
||||
throw new Error("native hydrate builder unavailable");
|
||||
}
|
||||
|
||||
globalThis.__stBmeNativeHydrateSnapshotRecords = (snapshotView = {}, options = {}) => {
|
||||
const raw = module.build_hydrate_records({
|
||||
nodes: Array.isArray(snapshotView?.nodes) ? snapshotView.nodes : [],
|
||||
edges: Array.isArray(snapshotView?.edges) ? snapshotView.edges : [],
|
||||
recordsNormalized: options?.recordsNormalized === true,
|
||||
});
|
||||
return raw && typeof raw === "object" ? raw : null;
|
||||
};
|
||||
|
||||
return getNativeModuleStatus();
|
||||
}
|
||||
|
||||
export function getNativeModuleStatus() {
|
||||
return {
|
||||
loaded: Boolean(cachedNativeModule),
|
||||
|
||||
Reference in New Issue
Block a user