@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.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 };
@@ -1027,10 +1027,8 @@ var Novely = (() => {
1027
1027
  stack[stack.length - 1] = value;
1028
1028
  },
1029
1029
  back() {
1030
- if (stack.length > 1) {
1031
- stack.previous = stack.pop();
1032
- ctx.meta.goingBack = true;
1033
- }
1030
+ stack.previous = stack.length > 1 ? stack.pop() : this.value;
1031
+ ctx.meta.goingBack = true;
1034
1032
  },
1035
1033
  push(value) {
1036
1034
  stack.push(value);
@@ -1513,7 +1511,12 @@ var Novely = (() => {
1513
1511
  };
1514
1512
  dataLoaded.promise.then(onDataLoadedPromise);
1515
1513
  const onStorageDataChange = (value) => {
1516
- if (coreData.get().dataLoaded) storage.set(value);
1514
+ if (!coreData.get().dataLoaded) return;
1515
+ const data2 = clone(value);
1516
+ for (const save2 of data2.saves) {
1517
+ save2[3] = [];
1518
+ }
1519
+ storage.set(data2);
1517
1520
  };
1518
1521
  const throttledOnStorageDataChange = throttle(onStorageDataChange, throttleTimeout);
1519
1522
  const throttledEmergencyOnStorageDataChange = throttle(() => {
@@ -1566,6 +1569,7 @@ var Novely = (() => {
1566
1569
  if (!last) return add();
1567
1570
  current[2][0] = intime(Date.now());
1568
1571
  current[2][1] = type;
1572
+ current[3] = [];
1569
1573
  const isIdentical = dequal(last[0], current[0]) && dequal(last[1], current[1]);
1570
1574
  const isLastMadeInCurrentSession = times.has(last[2][0]);
1571
1575
  if (isLastMadeInCurrentSession && last[2][1] === "auto" && type === "manual") {
@@ -1816,10 +1820,13 @@ var Novely = (() => {
1816
1820
  const getDialogOverview = () => {
1817
1821
  const { value: save2 } = useStack(MAIN_CONTEXT_KEY);
1818
1822
  const stateSnapshots = save2[3];
1823
+ if (stateSnapshots.length == 0) {
1824
+ return [];
1825
+ }
1819
1826
  const { queue } = getActionsFromPath(story, save2[0], false);
1820
1827
  const [lang] = storageData.get().meta;
1821
- const dialogItem = [];
1822
- for (let p = 0, i = 0; i < queue.length; i++) {
1828
+ const dialogItems = [];
1829
+ for (let p = 0, a = stateSnapshots.length, i = queue.length - 1; a > 0; i--) {
1823
1830
  const action2 = queue[i];
1824
1831
  if (action2[0] === "dialog") {
1825
1832
  const [_, name, text] = action2;
@@ -1833,15 +1840,16 @@ var Novely = (() => {
1833
1840
  break;
1834
1841
  }
1835
1842
  }
1836
- dialogItem.push({
1843
+ dialogItems.push({
1837
1844
  name,
1838
1845
  text,
1839
1846
  voice
1840
1847
  });
1841
1848
  p = i;
1849
+ a--;
1842
1850
  }
1843
1851
  }
1844
- const entries = dialogItem.map(({ name, text, voice }, i) => {
1852
+ const entries = dialogItems.reverse().map(({ name, text, voice }, i) => {
1845
1853
  const state = stateSnapshots[i];
1846
1854
  const audioSource = isString(voice) ? voice : isAsset(voice) ? voice : voice == void 0 ? voice : voice[lang];
1847
1855
  name = name ? getCharacterName(name) : "";