@novely/core 0.27.3 → 0.28.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.d.ts +1 -1
- package/dist/index.global.js +58 -14
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +29 -14
- 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,32 @@ 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();
|
|
872
|
+
if (!times.has(last[2][0]))
|
|
873
|
+
return add();
|
|
859
874
|
current[2][0] = intime(Date.now());
|
|
860
875
|
current[2][1] = type;
|
|
861
|
-
|
|
862
|
-
|
|
876
|
+
const isIdentical = dequal(last[0], current[0]) && dequal(last[1], current[1]);
|
|
877
|
+
if (last[2][1] === "auto" && type === "manual") {
|
|
878
|
+
return replace2();
|
|
879
|
+
}
|
|
880
|
+
if (last[2][1] === "manual" && type === "auto" && isIdentical) {
|
|
863
881
|
return prev;
|
|
864
882
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
prev.saves[prev.saves.length - 1] = current;
|
|
868
|
-
} else {
|
|
869
|
-
prev.saves.push(current);
|
|
883
|
+
if (last[2][1] === "auto" && type === "auto") {
|
|
884
|
+
return replace2();
|
|
870
885
|
}
|
|
871
|
-
return
|
|
886
|
+
return add();
|
|
872
887
|
});
|
|
873
888
|
};
|
|
874
889
|
const newGame = () => {
|
|
@@ -928,12 +943,11 @@ var novely = ({
|
|
|
928
943
|
ctx: context,
|
|
929
944
|
data: latest[1]
|
|
930
945
|
});
|
|
931
|
-
const lastQueueItem = queue.at(-1)
|
|
932
|
-
const isLastQueueItemRequiresUserAction = isUserRequiredAction(lastQueueItem);
|
|
946
|
+
const lastQueueItem = queue.at(-1);
|
|
933
947
|
await processor.run((item) => {
|
|
934
948
|
if (!latest)
|
|
935
949
|
return;
|
|
936
|
-
if (
|
|
950
|
+
if (lastQueueItem === item) {
|
|
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
|
+
enmemory(ctx);
|
|
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);
|