@novely/core 0.29.2 → 0.30.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 +42 -12
- package/dist/index.global.js +18 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/package.json +63 -63
package/dist/index.js
CHANGED
|
@@ -506,7 +506,7 @@ var store = (current, subscribers = /* @__PURE__ */ new Set()) => {
|
|
|
506
506
|
return { subscribe, update, set, get };
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
-
//
|
|
509
|
+
// ../../node_modules/.pnpm/@novely+deepmerge@0.0.0/node_modules/@novely/deepmerge/dist/index.js
|
|
510
510
|
var { isArray } = Array;
|
|
511
511
|
var { hasOwnProperty, propertyIsEnumerable, getOwnPropertySymbols } = Object;
|
|
512
512
|
var propertyIsOnObject = (object, property) => {
|
|
@@ -517,9 +517,7 @@ var propertyIsOnObject = (object, property) => {
|
|
|
517
517
|
}
|
|
518
518
|
};
|
|
519
519
|
var propertyIsUnsafe = (target, key) => {
|
|
520
|
-
return propertyIsOnObject(target, key) &&
|
|
521
|
-
!(hasOwnProperty.call(target, key) && // unsafe if they exist up the prototype chain,
|
|
522
|
-
propertyIsEnumerable.call(target, key));
|
|
520
|
+
return propertyIsOnObject(target, key) && !(hasOwnProperty.call(target, key) && propertyIsEnumerable.call(target, key));
|
|
523
521
|
};
|
|
524
522
|
var getEnumerableOwnPropertySymbols = (target) => {
|
|
525
523
|
if (!getOwnPropertySymbols)
|
|
@@ -695,6 +693,7 @@ import pLimit from "p-limit";
|
|
|
695
693
|
import { DEV as DEV2 } from "esm-env";
|
|
696
694
|
var novely = ({
|
|
697
695
|
characters,
|
|
696
|
+
defaultEmotions = {},
|
|
698
697
|
storage = localStorageStorage({ key: "novely-game-storage" }),
|
|
699
698
|
storageDelay = Promise.resolve(),
|
|
700
699
|
renderer: createRenderer,
|
|
@@ -932,6 +931,12 @@ var novely = ({
|
|
|
932
931
|
};
|
|
933
932
|
let interacted = 0;
|
|
934
933
|
const restore = async (save2) => {
|
|
934
|
+
if (isEmpty(story)) {
|
|
935
|
+
if (DEV2) {
|
|
936
|
+
throw new Error("Story is empty. You should call an `enine.script` function [https://novely.pages.dev/guide/story.html]");
|
|
937
|
+
}
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
935
940
|
if (!coreData.get().dataLoaded)
|
|
936
941
|
return;
|
|
937
942
|
let latest = save2 || storageData.get().saves.at(-1);
|
|
@@ -1052,6 +1057,8 @@ var novely = ({
|
|
|
1052
1057
|
return translation[lang].internal[key];
|
|
1053
1058
|
};
|
|
1054
1059
|
const preview = async (save2, name) => {
|
|
1060
|
+
if (isEmpty(story))
|
|
1061
|
+
return;
|
|
1055
1062
|
const [path, data2] = save2;
|
|
1056
1063
|
const { queue } = getActionsFromPath(story, path, true);
|
|
1057
1064
|
const ctx = renderer.getContext(name);
|
|
@@ -1204,6 +1211,12 @@ var novely = ({
|
|
|
1204
1211
|
push();
|
|
1205
1212
|
},
|
|
1206
1213
|
showCharacter({ ctx, push }, [character, emotion, className, style]) {
|
|
1214
|
+
emotion ??= defaultEmotions[character];
|
|
1215
|
+
if (DEV2 && !emotion) {
|
|
1216
|
+
throw new Error(`Attemp to show character "${character}" without emotion provided.`);
|
|
1217
|
+
}
|
|
1218
|
+
if (!emotion)
|
|
1219
|
+
return;
|
|
1207
1220
|
if (DEV2 && !characters[character].emotions[emotion]) {
|
|
1208
1221
|
throw new Error(`Attempt to show character "${character}" with unknown emotion "${emotion}"`);
|
|
1209
1222
|
}
|
|
@@ -1341,11 +1354,7 @@ var novely = ({
|
|
|
1341
1354
|
end({ ctx }) {
|
|
1342
1355
|
if (ctx.meta.preview)
|
|
1343
1356
|
return;
|
|
1344
|
-
|
|
1345
|
-
ctx.clear(EMPTY_SET, EMPTY_SET, { music: EMPTY_SET, sounds: EMPTY_SET }, noop);
|
|
1346
|
-
renderer.ui.showScreen("mainmenu");
|
|
1347
|
-
interactivity(false);
|
|
1348
|
-
times.clear();
|
|
1357
|
+
exit(true);
|
|
1349
1358
|
},
|
|
1350
1359
|
input({ ctx, data: data2, forward }, [question, onInput, setup]) {
|
|
1351
1360
|
ctx.input(
|