@novely/core 0.31.2 → 0.32.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 +22 -2
- package/dist/index.global.js +32 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +32 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -862,6 +862,9 @@ var novely = ({
|
|
|
862
862
|
let stored = await storage.get();
|
|
863
863
|
for (const migration of migrations) {
|
|
864
864
|
stored = migration(stored);
|
|
865
|
+
if (DEV2 && !stored) {
|
|
866
|
+
throw new Error("Migrations should return a value.");
|
|
867
|
+
}
|
|
865
868
|
}
|
|
866
869
|
if (overrideLanguage || !stored.meta[0]) {
|
|
867
870
|
stored.meta[0] = getLanguageWithoutParameters();
|
|
@@ -1022,16 +1025,21 @@ var novely = ({
|
|
|
1022
1025
|
return current;
|
|
1023
1026
|
};
|
|
1024
1027
|
const exit = (force = false, saving = true) => {
|
|
1025
|
-
|
|
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()) {
|
|
1026
1037
|
renderer.ui.showExitPrompt();
|
|
1027
1038
|
return;
|
|
1028
1039
|
}
|
|
1029
|
-
const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
|
|
1030
1040
|
if (interacted > 0 && saving) {
|
|
1031
1041
|
save("auto");
|
|
1032
1042
|
}
|
|
1033
|
-
const stack = useStack(ctx);
|
|
1034
|
-
const current = stack.value;
|
|
1035
1043
|
stack.clear();
|
|
1036
1044
|
ctx.clear(EMPTY_SET, EMPTY_SET, { music: EMPTY_SET, sounds: EMPTY_SET }, noop);
|
|
1037
1045
|
renderer.ui.showScreen("mainmenu");
|
|
@@ -1205,7 +1213,13 @@ var novely = ({
|
|
|
1205
1213
|
push();
|
|
1206
1214
|
},
|
|
1207
1215
|
voice({ ctx, push }, [source]) {
|
|
1208
|
-
|
|
1216
|
+
const [lang] = storageData.get().meta;
|
|
1217
|
+
const audioSource = isString(source) ? source : source[lang];
|
|
1218
|
+
if (!audioSource) {
|
|
1219
|
+
push();
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
ctx.audio.voice(audioSource);
|
|
1209
1223
|
push();
|
|
1210
1224
|
},
|
|
1211
1225
|
stopVoice({ ctx, push }) {
|
|
@@ -1529,6 +1543,9 @@ var novely = ({
|
|
|
1529
1543
|
d: null,
|
|
1530
1544
|
c: null
|
|
1531
1545
|
};
|
|
1546
|
+
const getCurrentStorageData = () => {
|
|
1547
|
+
return coreData.get().dataLoaded ? klona(storageData.get()) : null;
|
|
1548
|
+
};
|
|
1532
1549
|
return {
|
|
1533
1550
|
/**
|
|
1534
1551
|
* Function to set game script
|
|
@@ -1613,7 +1630,16 @@ var novely = ({
|
|
|
1613
1630
|
dataLoaded.cancel();
|
|
1614
1631
|
UIInstance.unmount();
|
|
1615
1632
|
unsubscribeFromBrowserVisibilityChange();
|
|
1616
|
-
}
|
|
1633
|
+
},
|
|
1634
|
+
/**
|
|
1635
|
+
* Funtion to get current storage data
|
|
1636
|
+
*
|
|
1637
|
+
* @example
|
|
1638
|
+
* ```ts
|
|
1639
|
+
* const currentStorageData = engine.getCurrentStorageData();
|
|
1640
|
+
* ```
|
|
1641
|
+
*/
|
|
1642
|
+
getCurrentStorageData
|
|
1617
1643
|
};
|
|
1618
1644
|
};
|
|
1619
1645
|
|