@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.d.ts CHANGED
@@ -55,8 +55,6 @@ declare const KK: Record<BaseTranslationStrings, string>;
55
55
  declare const JP: Record<BaseTranslationStrings, string>;
56
56
 
57
57
  type CharacterHandle = {
58
- canvas: HTMLCanvasElement;
59
- ctx: CanvasRenderingContext2D;
60
58
  emotion: (emotion: string, render: boolean) => void;
61
59
  append: (className?: string, style?: string, restoring?: boolean) => void;
62
60
  remove: (className?: string, style?: string, duration?: number, restoring?: boolean) => Promise<void>;
@@ -1003,4 +1001,4 @@ declare const extendAction: <Part0 extends Record<string, (...args: any[]) => Va
1003
1001
  */
1004
1002
  declare const asset: (...variants: string[]) => NovelyAsset;
1005
1003
 
1006
- export { type ActionChoiceChoice, type ActionChoiceChoiceObject, type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterAssetSizes, type CharacterHandle, type CharactersData, type ChoiceCheckFunction, type ChoiceCheckFunctionProps, type ChoiceOnSelectFunction, type ChoiceOnSelectFunctionProps, type ChoiceParams, type ConditionCheckFunction, type ConditionParams, type Context, type CoreData, type CustomActionHandle, type CustomHandler, type CustomHandlerFunction, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type CustomHandlerInfo, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, type FunctionParams, type FunctionableValue, type GetActionParameters, type InputHandler, JP, KK, type Lang, type NovelyInit, type NovelyScreen, type NovelyStorage, type Path, type PluralType, type Pluralization, RU, type Renderer, type RendererInit, type RendererInitPreviewReturn, type Save, type Stack, type StackHolder, type State, type StateFunction, type StorageData, type StorageMeta, type Stored, type Story, type TextContent, type Thenable, type TranslationActions, type TypeEssentials, type TypewriterSpeed, type ValidAction, asset, extendAction, localStorageStorage, novely };
1004
+ export { type ActionChoiceChoice, type ActionChoiceChoiceObject, type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterAssetSizes, type CharacterHandle, type CharactersData, type ChoiceCheckFunction, type ChoiceCheckFunctionProps, type ChoiceOnSelectFunction, type ChoiceOnSelectFunctionProps, type ChoiceParams, type ConditionCheckFunction, type ConditionParams, type Context, type CoreData, type CustomActionHandle, type CustomHandler, type CustomHandlerFunction, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type CustomHandlerInfo, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, type FunctionParams, type FunctionableValue, type GetActionParameters, type InputHandler, JP, KK, type Lang, type NovelyAsset, type NovelyInit, type NovelyScreen, type NovelyStorage, type Path, type PluralType, type Pluralization, RU, type Renderer, type RendererInit, type RendererInitPreviewReturn, type Save, type Stack, type StackHolder, type State, type StateFunction, type StorageData, type StorageMeta, type Stored, type Story, type TextContent, type Thenable, type TranslationActions, type TypeEssentials, type TypewriterSpeed, type ValidAction, asset, extendAction, localStorageStorage, novely };
@@ -1054,10 +1054,10 @@ var Novely = (() => {
1054
1054
  });
1055
1055
  };
1056
1056
  var flatStory = (story) => {
1057
- const entries = Object.entries(story).map(([name, items]) => {
1058
- return [name, flatActions(items)];
1059
- });
1060
- return Object.fromEntries(entries);
1057
+ for (const key in story) {
1058
+ story[key] = flatActions(story[key]);
1059
+ }
1060
+ return story;
1061
1061
  };
1062
1062
 
1063
1063
  // src/browser.ts
@@ -1513,7 +1513,12 @@ var Novely = (() => {
1513
1513
  };
1514
1514
  dataLoaded.promise.then(onDataLoadedPromise);
1515
1515
  const onStorageDataChange = (value) => {
1516
- if (coreData.get().dataLoaded) storage.set(value);
1516
+ if (!coreData.get().dataLoaded) return;
1517
+ const data2 = clone(value);
1518
+ for (const save2 of data2.saves) {
1519
+ save2[3] = [];
1520
+ }
1521
+ storage.set(data2);
1517
1522
  };
1518
1523
  const throttledOnStorageDataChange = throttle(onStorageDataChange, throttleTimeout);
1519
1524
  const throttledEmergencyOnStorageDataChange = throttle(() => {
@@ -1566,6 +1571,7 @@ var Novely = (() => {
1566
1571
  if (!last) return add();
1567
1572
  current[2][0] = intime(Date.now());
1568
1573
  current[2][1] = type;
1574
+ current[3] = [];
1569
1575
  const isIdentical = dequal(last[0], current[0]) && dequal(last[1], current[1]);
1570
1576
  const isLastMadeInCurrentSession = times.has(last[2][0]);
1571
1577
  if (isLastMadeInCurrentSession && last[2][1] === "auto" && type === "manual") {
@@ -1816,10 +1822,13 @@ var Novely = (() => {
1816
1822
  const getDialogOverview = () => {
1817
1823
  const { value: save2 } = useStack(MAIN_CONTEXT_KEY);
1818
1824
  const stateSnapshots = save2[3];
1825
+ if (stateSnapshots.length == 0) {
1826
+ return [];
1827
+ }
1819
1828
  const { queue } = getActionsFromPath(story, save2[0], false);
1820
1829
  const [lang] = storageData.get().meta;
1821
- const dialogItem = [];
1822
- for (let p = 0, i = 0; i < queue.length; i++) {
1830
+ const dialogItems = [];
1831
+ for (let p = 0, a = stateSnapshots.length, i = queue.length - 1; a > 0; i--) {
1823
1832
  const action2 = queue[i];
1824
1833
  if (action2[0] === "dialog") {
1825
1834
  const [_, name, text] = action2;
@@ -1833,15 +1842,16 @@ var Novely = (() => {
1833
1842
  break;
1834
1843
  }
1835
1844
  }
1836
- dialogItem.push({
1845
+ dialogItems.push({
1837
1846
  name,
1838
1847
  text,
1839
1848
  voice
1840
1849
  });
1841
1850
  p = i;
1851
+ a--;
1842
1852
  }
1843
1853
  }
1844
- const entries = dialogItem.map(({ name, text, voice }, i) => {
1854
+ const entries = dialogItems.reverse().map(({ name, text, voice }, i) => {
1845
1855
  const state = stateSnapshots[i];
1846
1856
  const audioSource = isString(voice) ? voice : isAsset(voice) ? voice : voice == void 0 ? voice : voice[lang];
1847
1857
  name = name ? getCharacterName(name) : "";