@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.d.ts
CHANGED
|
@@ -718,6 +718,15 @@ declare const novely: <$Language extends string, $Characters extends Record<stri
|
|
|
718
718
|
* Data updates still will work in case Novely already was loaded
|
|
719
719
|
*/
|
|
720
720
|
destroy(): void;
|
|
721
|
+
/**
|
|
722
|
+
* Funtion to get current storage data
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* const currentStorageData = engine.getCurrentStorageData();
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
getCurrentStorageData: () => StorageData<$Language, $Data> | null;
|
|
721
730
|
};
|
|
722
731
|
|
|
723
732
|
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterHandle, type ConditionParams, type Context, type CoreData, type CustomHandler, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, type FunctionableValue, type GetActionParameters, JP, KK, type Lang, type NovelyInit, type NovelyScreen, type Path, type PluralType, type Pluralization, RU, type Renderer, type RendererInit, type Save, type Stack, type StackHolder, type State, type StateFunction, type Storage, type StorageData, type StorageMeta, type Stored, type Story, type TextContent, type Thenable, type TranslationActions, type TypewriterSpeed, type ValidAction, localStorageStorage, novely };
|
package/dist/index.global.js
CHANGED
|
@@ -462,12 +462,10 @@ var Novely = (() => {
|
|
|
462
462
|
const next = (i) => queue.slice(i + 1);
|
|
463
463
|
for (const [i, item] of queue.entries()) {
|
|
464
464
|
const [action, ...params] = item;
|
|
465
|
-
if (isUserRequiredAction(item) && !queue.slice(0, i + 1).some((action2) => isUserRequiredAction(action2))) {
|
|
466
|
-
keep.add(action);
|
|
467
|
-
}
|
|
468
465
|
if (options.skip.has(item) && item !== options.skipPreserve) {
|
|
469
466
|
continue;
|
|
470
467
|
}
|
|
468
|
+
keep.add(action);
|
|
471
469
|
if (action === "function" || action === "custom") {
|
|
472
470
|
if (action === "custom" && params[0].callOnlyLatest) {
|
|
473
471
|
const notLatest = next(i).some(([, func]) => {
|
|
@@ -1056,6 +1054,9 @@ var Novely = (() => {
|
|
|
1056
1054
|
let stored = await storage.get();
|
|
1057
1055
|
for (const migration of migrations) {
|
|
1058
1056
|
stored = migration(stored);
|
|
1057
|
+
if (DEV && !stored) {
|
|
1058
|
+
throw new Error("Migrations should return a value.");
|
|
1059
|
+
}
|
|
1059
1060
|
}
|
|
1060
1061
|
if (overrideLanguage || !stored.meta[0]) {
|
|
1061
1062
|
stored.meta[0] = getLanguageWithoutParameters();
|
|
@@ -1216,16 +1217,21 @@ var Novely = (() => {
|
|
|
1216
1217
|
return current;
|
|
1217
1218
|
};
|
|
1218
1219
|
const exit = (force = false, saving = true) => {
|
|
1219
|
-
|
|
1220
|
+
const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
|
|
1221
|
+
const stack = useStack(ctx);
|
|
1222
|
+
const current = stack.value;
|
|
1223
|
+
const isSaved = () => {
|
|
1224
|
+
const { saves } = storageData.get();
|
|
1225
|
+
const [currentPath, currentData] = stack.value;
|
|
1226
|
+
return saves.some(([path, data2, [date, type2]]) => type2 === "manual" && times.has(date) && dequal(path, currentPath) && dequal(data2, currentData));
|
|
1227
|
+
};
|
|
1228
|
+
if (interacted > 1 && !force && askBeforeExit && !isSaved()) {
|
|
1220
1229
|
renderer.ui.showExitPrompt();
|
|
1221
1230
|
return;
|
|
1222
1231
|
}
|
|
1223
|
-
const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
|
|
1224
1232
|
if (interacted > 0 && saving) {
|
|
1225
1233
|
save("auto");
|
|
1226
1234
|
}
|
|
1227
|
-
const stack = useStack(ctx);
|
|
1228
|
-
const current = stack.value;
|
|
1229
1235
|
stack.clear();
|
|
1230
1236
|
ctx.clear(EMPTY_SET, EMPTY_SET, { music: EMPTY_SET, sounds: EMPTY_SET }, noop);
|
|
1231
1237
|
renderer.ui.showScreen("mainmenu");
|
|
@@ -1723,6 +1729,9 @@ var Novely = (() => {
|
|
|
1723
1729
|
d: null,
|
|
1724
1730
|
c: null
|
|
1725
1731
|
};
|
|
1732
|
+
const getCurrentStorageData = () => {
|
|
1733
|
+
return coreData.get().dataLoaded ? klona(storageData.get()) : null;
|
|
1734
|
+
};
|
|
1726
1735
|
return {
|
|
1727
1736
|
/**
|
|
1728
1737
|
* Function to set game script
|
|
@@ -1807,7 +1816,16 @@ var Novely = (() => {
|
|
|
1807
1816
|
dataLoaded.cancel();
|
|
1808
1817
|
UIInstance.unmount();
|
|
1809
1818
|
unsubscribeFromBrowserVisibilityChange();
|
|
1810
|
-
}
|
|
1819
|
+
},
|
|
1820
|
+
/**
|
|
1821
|
+
* Funtion to get current storage data
|
|
1822
|
+
*
|
|
1823
|
+
* @example
|
|
1824
|
+
* ```ts
|
|
1825
|
+
* const currentStorageData = engine.getCurrentStorageData();
|
|
1826
|
+
* ```
|
|
1827
|
+
*/
|
|
1828
|
+
getCurrentStorageData
|
|
1811
1829
|
};
|
|
1812
1830
|
};
|
|
1813
1831
|
|