@novely/core 0.46.0-next.4 → 0.46.1

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
@@ -715,10 +715,10 @@ var flatActions = (item) => {
715
715
  });
716
716
  };
717
717
  var flatStory = (story) => {
718
- const entries = Object.entries(story).map(([name, items]) => {
719
- return [name, flatActions(items)];
720
- });
721
- return Object.fromEntries(entries);
718
+ for (const key in story) {
719
+ story[key] = flatActions(story[key]);
720
+ }
721
+ return story;
722
722
  };
723
723
 
724
724
  // src/browser.ts
@@ -1174,7 +1174,12 @@ var novely = ({
1174
1174
  };
1175
1175
  dataLoaded.promise.then(onDataLoadedPromise);
1176
1176
  const onStorageDataChange = (value) => {
1177
- if (coreData.get().dataLoaded) storage.set(value);
1177
+ if (!coreData.get().dataLoaded) return;
1178
+ const data2 = clone(value);
1179
+ for (const save2 of data2.saves) {
1180
+ save2[3] = [];
1181
+ }
1182
+ storage.set(data2);
1178
1183
  };
1179
1184
  const throttledOnStorageDataChange = throttle(onStorageDataChange, throttleTimeout);
1180
1185
  const throttledEmergencyOnStorageDataChange = throttle(() => {
@@ -1227,6 +1232,7 @@ var novely = ({
1227
1232
  if (!last) return add();
1228
1233
  current[2][0] = intime(Date.now());
1229
1234
  current[2][1] = type;
1235
+ current[3] = [];
1230
1236
  const isIdentical = dequal(last[0], current[0]) && dequal(last[1], current[1]);
1231
1237
  const isLastMadeInCurrentSession = times.has(last[2][0]);
1232
1238
  if (isLastMadeInCurrentSession && last[2][1] === "auto" && type === "manual") {
@@ -1477,10 +1483,13 @@ var novely = ({
1477
1483
  const getDialogOverview = () => {
1478
1484
  const { value: save2 } = useStack(MAIN_CONTEXT_KEY);
1479
1485
  const stateSnapshots = save2[3];
1486
+ if (stateSnapshots.length == 0) {
1487
+ return [];
1488
+ }
1480
1489
  const { queue } = getActionsFromPath(story, save2[0], false);
1481
1490
  const [lang] = storageData.get().meta;
1482
- const dialogItem = [];
1483
- for (let p = 0, i = 0; i < queue.length; i++) {
1491
+ const dialogItems = [];
1492
+ for (let p = 0, a = stateSnapshots.length, i = queue.length - 1; a > 0; i--) {
1484
1493
  const action2 = queue[i];
1485
1494
  if (action2[0] === "dialog") {
1486
1495
  const [_, name, text] = action2;
@@ -1494,15 +1503,16 @@ var novely = ({
1494
1503
  break;
1495
1504
  }
1496
1505
  }
1497
- dialogItem.push({
1506
+ dialogItems.push({
1498
1507
  name,
1499
1508
  text,
1500
1509
  voice
1501
1510
  });
1502
1511
  p = i;
1512
+ a--;
1503
1513
  }
1504
1514
  }
1505
- const entries = dialogItem.map(({ name, text, voice }, i) => {
1515
+ const entries = dialogItems.reverse().map(({ name, text, voice }, i) => {
1506
1516
  const state = stateSnapshots[i];
1507
1517
  const audioSource = isString(voice) ? voice : isAsset(voice) ? voice : voice == void 0 ? voice : voice[lang];
1508
1518
  name = name ? getCharacterName(name) : "";