@novely/core 0.46.0 → 0.46.2

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.js CHANGED
@@ -688,10 +688,8 @@ var createUseStackFunction = (renderer) => {
688
688
  stack[stack.length - 1] = value;
689
689
  },
690
690
  back() {
691
- if (stack.length > 1) {
692
- stack.previous = stack.pop();
693
- ctx.meta.goingBack = true;
694
- }
691
+ stack.previous = stack.length > 1 ? stack.pop() : this.value;
692
+ ctx.meta.goingBack = true;
695
693
  },
696
694
  push(value) {
697
695
  stack.push(value);
@@ -1174,7 +1172,12 @@ var novely = ({
1174
1172
  };
1175
1173
  dataLoaded.promise.then(onDataLoadedPromise);
1176
1174
  const onStorageDataChange = (value) => {
1177
- if (coreData.get().dataLoaded) storage.set(value);
1175
+ if (!coreData.get().dataLoaded) return;
1176
+ const data2 = clone(value);
1177
+ for (const save2 of data2.saves) {
1178
+ save2[3] = [];
1179
+ }
1180
+ storage.set(data2);
1178
1181
  };
1179
1182
  const throttledOnStorageDataChange = throttle(onStorageDataChange, throttleTimeout);
1180
1183
  const throttledEmergencyOnStorageDataChange = throttle(() => {
@@ -1227,6 +1230,7 @@ var novely = ({
1227
1230
  if (!last) return add();
1228
1231
  current[2][0] = intime(Date.now());
1229
1232
  current[2][1] = type;
1233
+ current[3] = [];
1230
1234
  const isIdentical = dequal(last[0], current[0]) && dequal(last[1], current[1]);
1231
1235
  const isLastMadeInCurrentSession = times.has(last[2][0]);
1232
1236
  if (isLastMadeInCurrentSession && last[2][1] === "auto" && type === "manual") {
@@ -1477,10 +1481,13 @@ var novely = ({
1477
1481
  const getDialogOverview = () => {
1478
1482
  const { value: save2 } = useStack(MAIN_CONTEXT_KEY);
1479
1483
  const stateSnapshots = save2[3];
1484
+ if (stateSnapshots.length == 0) {
1485
+ return [];
1486
+ }
1480
1487
  const { queue } = getActionsFromPath(story, save2[0], false);
1481
1488
  const [lang] = storageData.get().meta;
1482
- const dialogItem = [];
1483
- for (let p = 0, i = 0; i < queue.length; i++) {
1489
+ const dialogItems = [];
1490
+ for (let p = 0, a = stateSnapshots.length, i = queue.length - 1; a > 0; i--) {
1484
1491
  const action2 = queue[i];
1485
1492
  if (action2[0] === "dialog") {
1486
1493
  const [_, name, text] = action2;
@@ -1494,15 +1501,16 @@ var novely = ({
1494
1501
  break;
1495
1502
  }
1496
1503
  }
1497
- dialogItem.push({
1504
+ dialogItems.push({
1498
1505
  name,
1499
1506
  text,
1500
1507
  voice
1501
1508
  });
1502
1509
  p = i;
1510
+ a--;
1503
1511
  }
1504
1512
  }
1505
- const entries = dialogItem.map(({ name, text, voice }, i) => {
1513
+ const entries = dialogItems.reverse().map(({ name, text, voice }, i) => {
1506
1514
  const state = stateSnapshots[i];
1507
1515
  const audioSource = isString(voice) ? voice : isAsset(voice) ? voice : voice == void 0 ? voice : voice[lang];
1508
1516
  name = name ? getCharacterName(name) : "";