@novely/core 0.27.4 → 0.28.1
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.d.ts +1 -1
- package/dist/index.global.js +57 -13
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +28 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -463,6 +463,9 @@ var getResourseType = async (request, url) => {
|
|
|
463
463
|
return "other";
|
|
464
464
|
};
|
|
465
465
|
|
|
466
|
+
// src/novely.ts
|
|
467
|
+
import { dequal } from "dequal/lite";
|
|
468
|
+
|
|
466
469
|
// src/global.ts
|
|
467
470
|
var PRELOADED_ASSETS = /* @__PURE__ */ new Set();
|
|
468
471
|
|
|
@@ -847,7 +850,7 @@ var novely = ({
|
|
|
847
850
|
};
|
|
848
851
|
addEventListener("visibilitychange", onVisibilityChange);
|
|
849
852
|
addEventListener("beforeunload", throttledEmergencyOnStorageDataChange);
|
|
850
|
-
const save = (
|
|
853
|
+
const save = (type) => {
|
|
851
854
|
if (!coreData.get().dataLoaded)
|
|
852
855
|
return;
|
|
853
856
|
if (!autosaves && type === "auto")
|
|
@@ -855,20 +858,31 @@ var novely = ({
|
|
|
855
858
|
const stack = useStack(MAIN_CONTEXT_KEY);
|
|
856
859
|
const current = klona(stack.value);
|
|
857
860
|
storageData.update((prev) => {
|
|
858
|
-
const
|
|
861
|
+
const replace2 = () => {
|
|
862
|
+
prev.saves[prev.saves.length - 1] = current;
|
|
863
|
+
return prev;
|
|
864
|
+
};
|
|
865
|
+
const add = () => {
|
|
866
|
+
prev.saves.push(current);
|
|
867
|
+
return prev;
|
|
868
|
+
};
|
|
869
|
+
const last = prev.saves.at(-1);
|
|
870
|
+
if (!last)
|
|
871
|
+
return add();
|
|
859
872
|
current[2][0] = intime(Date.now());
|
|
860
873
|
current[2][1] = type;
|
|
861
|
-
|
|
862
|
-
|
|
874
|
+
const isIdentical = dequal(last[0], current[0]) && dequal(last[1], current[1]);
|
|
875
|
+
const isLastMadeInCurrentSession = times.has(last[2][0]);
|
|
876
|
+
if (isLastMadeInCurrentSession && last[2][1] === "auto" && type === "manual") {
|
|
877
|
+
return replace2();
|
|
878
|
+
}
|
|
879
|
+
if (last[2][1] === "manual" && type === "auto" && isIdentical) {
|
|
863
880
|
return prev;
|
|
864
881
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
prev.saves[prev.saves.length - 1] = current;
|
|
868
|
-
} else {
|
|
869
|
-
prev.saves.push(current);
|
|
882
|
+
if (isLastMadeInCurrentSession && last[2][1] === "auto" && type === "auto") {
|
|
883
|
+
return replace2();
|
|
870
884
|
}
|
|
871
|
-
return
|
|
885
|
+
return add();
|
|
872
886
|
});
|
|
873
887
|
};
|
|
874
888
|
const newGame = () => {
|
|
@@ -929,11 +943,11 @@ var novely = ({
|
|
|
929
943
|
data: latest[1]
|
|
930
944
|
});
|
|
931
945
|
const lastQueueItem = queue.at(-1) || [];
|
|
932
|
-
const
|
|
946
|
+
const lastQueueItemRequiresUserAction = isSkippedDuringRestore(lastQueueItem[0]) || isUserRequiredAction(lastQueueItem);
|
|
933
947
|
await processor.run((item) => {
|
|
934
948
|
if (!latest)
|
|
935
949
|
return;
|
|
936
|
-
if (
|
|
950
|
+
if (lastQueueItem === item && lastQueueItemRequiresUserAction) {
|
|
937
951
|
return;
|
|
938
952
|
}
|
|
939
953
|
const [action2, ...props] = item;
|
|
@@ -977,6 +991,7 @@ var novely = ({
|
|
|
977
991
|
return;
|
|
978
992
|
}
|
|
979
993
|
const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
|
|
994
|
+
save("auto");
|
|
980
995
|
const stack = useStack(ctx);
|
|
981
996
|
const current = stack.value;
|
|
982
997
|
stack.clear();
|
|
@@ -1069,7 +1084,7 @@ var novely = ({
|
|
|
1069
1084
|
const current = klona(stack.value);
|
|
1070
1085
|
current[2][1] = "auto";
|
|
1071
1086
|
stack.push(current);
|
|
1072
|
-
save(
|
|
1087
|
+
save("auto");
|
|
1073
1088
|
};
|
|
1074
1089
|
const nextPath = (path) => {
|
|
1075
1090
|
const last = path.at(-1);
|