@novely/core 0.31.1 → 0.31.3
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 +9 -0
- package/dist/index.global.js +26 -8
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -298,12 +298,10 @@ var createQueueProcessor = (queue, options) => {
|
|
|
298
298
|
const next = (i) => queue.slice(i + 1);
|
|
299
299
|
for (const [i, item] of queue.entries()) {
|
|
300
300
|
const [action, ...params] = item;
|
|
301
|
-
if (isUserRequiredAction(item) && !queue.slice(0, i + 1).some((action2) => isUserRequiredAction(action2))) {
|
|
302
|
-
keep.add(action);
|
|
303
|
-
}
|
|
304
301
|
if (options.skip.has(item) && item !== options.skipPreserve) {
|
|
305
302
|
continue;
|
|
306
303
|
}
|
|
304
|
+
keep.add(action);
|
|
307
305
|
if (action === "function" || action === "custom") {
|
|
308
306
|
if (action === "custom" && params[0].callOnlyLatest) {
|
|
309
307
|
const notLatest = next(i).some(([, func]) => {
|
|
@@ -864,6 +862,9 @@ var novely = ({
|
|
|
864
862
|
let stored = await storage.get();
|
|
865
863
|
for (const migration of migrations) {
|
|
866
864
|
stored = migration(stored);
|
|
865
|
+
if (DEV2 && !stored) {
|
|
866
|
+
throw new Error("Migrations should return a value.");
|
|
867
|
+
}
|
|
867
868
|
}
|
|
868
869
|
if (overrideLanguage || !stored.meta[0]) {
|
|
869
870
|
stored.meta[0] = getLanguageWithoutParameters();
|
|
@@ -1024,16 +1025,21 @@ var novely = ({
|
|
|
1024
1025
|
return current;
|
|
1025
1026
|
};
|
|
1026
1027
|
const exit = (force = false, saving = true) => {
|
|
1027
|
-
|
|
1028
|
+
const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
|
|
1029
|
+
const stack = useStack(ctx);
|
|
1030
|
+
const current = stack.value;
|
|
1031
|
+
const isSaved = () => {
|
|
1032
|
+
const { saves } = storageData.get();
|
|
1033
|
+
const [currentPath, currentData] = stack.value;
|
|
1034
|
+
return saves.some(([path, data2, [date, type2]]) => type2 === "manual" && times.has(date) && dequal(path, currentPath) && dequal(data2, currentData));
|
|
1035
|
+
};
|
|
1036
|
+
if (interacted > 1 && !force && askBeforeExit && !isSaved()) {
|
|
1028
1037
|
renderer.ui.showExitPrompt();
|
|
1029
1038
|
return;
|
|
1030
1039
|
}
|
|
1031
|
-
const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
|
|
1032
1040
|
if (interacted > 0 && saving) {
|
|
1033
1041
|
save("auto");
|
|
1034
1042
|
}
|
|
1035
|
-
const stack = useStack(ctx);
|
|
1036
|
-
const current = stack.value;
|
|
1037
1043
|
stack.clear();
|
|
1038
1044
|
ctx.clear(EMPTY_SET, EMPTY_SET, { music: EMPTY_SET, sounds: EMPTY_SET }, noop);
|
|
1039
1045
|
renderer.ui.showScreen("mainmenu");
|
|
@@ -1531,6 +1537,9 @@ var novely = ({
|
|
|
1531
1537
|
d: null,
|
|
1532
1538
|
c: null
|
|
1533
1539
|
};
|
|
1540
|
+
const getCurrentStorageData = () => {
|
|
1541
|
+
return coreData.get().dataLoaded ? klona(storageData.get()) : null;
|
|
1542
|
+
};
|
|
1534
1543
|
return {
|
|
1535
1544
|
/**
|
|
1536
1545
|
* Function to set game script
|
|
@@ -1615,7 +1624,16 @@ var novely = ({
|
|
|
1615
1624
|
dataLoaded.cancel();
|
|
1616
1625
|
UIInstance.unmount();
|
|
1617
1626
|
unsubscribeFromBrowserVisibilityChange();
|
|
1618
|
-
}
|
|
1627
|
+
},
|
|
1628
|
+
/**
|
|
1629
|
+
* Funtion to get current storage data
|
|
1630
|
+
*
|
|
1631
|
+
* @example
|
|
1632
|
+
* ```ts
|
|
1633
|
+
* const currentStorageData = engine.getCurrentStorageData();
|
|
1634
|
+
* ```
|
|
1635
|
+
*/
|
|
1636
|
+
getCurrentStorageData
|
|
1619
1637
|
};
|
|
1620
1638
|
};
|
|
1621
1639
|
|