mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
fix: harden persistence tiers and opfs durability
This commit is contained in:
29
vendor/wasm/stbme_core.js
vendored
29
vendor/wasm/stbme_core.js
vendored
@@ -3,6 +3,21 @@ let triedLoad = false;
|
||||
let loadError = null;
|
||||
let moduleSource = "none";
|
||||
|
||||
function shouldRetryNativeLoad() {
|
||||
return (
|
||||
!cachedNativeModule &&
|
||||
triedLoad &&
|
||||
typeof globalThis.__stBmeLoadRustWasmLayout === "function"
|
||||
);
|
||||
}
|
||||
|
||||
export function resetNativeModuleStatus() {
|
||||
cachedNativeModule = null;
|
||||
triedLoad = false;
|
||||
loadError = null;
|
||||
moduleSource = "none";
|
||||
}
|
||||
|
||||
async function resolveWasmModuleInput(wasmUrl) {
|
||||
if (
|
||||
wasmUrl &&
|
||||
@@ -69,12 +84,18 @@ async function loadFromWasmPackArtifacts() {
|
||||
};
|
||||
}
|
||||
|
||||
async function loadNativeModule() {
|
||||
async function loadNativeModule(options = {}) {
|
||||
if (cachedNativeModule) return cachedNativeModule;
|
||||
if (triedLoad) {
|
||||
if (triedLoad && !(options?.forceRetry === true || shouldRetryNativeLoad())) {
|
||||
throw loadError || new Error("stbme_core native module unavailable");
|
||||
}
|
||||
|
||||
if (triedLoad && (options?.forceRetry === true || shouldRetryNativeLoad())) {
|
||||
triedLoad = false;
|
||||
loadError = null;
|
||||
moduleSource = "none";
|
||||
}
|
||||
|
||||
triedLoad = true;
|
||||
|
||||
let wasmPackError = null;
|
||||
@@ -148,7 +169,9 @@ export async function solveLayout(payload) {
|
||||
}
|
||||
|
||||
export async function installNativePersistDeltaHook() {
|
||||
const module = await loadNativeModule();
|
||||
const module = await loadNativeModule({
|
||||
forceRetry: shouldRetryNativeLoad(),
|
||||
});
|
||||
if (
|
||||
!module ||
|
||||
(typeof module.build_persist_delta_compact_hash !== "function" &&
|
||||
|
||||
Reference in New Issue
Block a user