@novely/core 0.30.1 → 0.30.3

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
@@ -477,9 +477,7 @@ type ValidAction = ['choice', number] | ['clear', Set<keyof DefaultActionProxy>?
477
477
  type Story = Record<string, ValidAction[]>;
478
478
  type TextContent<L extends string, S extends State> = string | ((state: S) => string) | Record<L, string | ((state: S) => string)>;
479
479
  type FunctionableValue<T> = T | (() => T);
480
- type CustomHandlerGetResultDataFunction = {
481
- (data?: Record<string, unknown>): Record<string, unknown>;
482
- };
480
+ type CustomHandlerGetResultDataFunction = (data?: Record<string, unknown>) => Record<string, unknown>;
483
481
  type CustomHandlerGetResult<I extends boolean> = {
484
482
  delete: () => void;
485
483
  /**
@@ -568,9 +566,7 @@ type ChoiceCheckFunctionProps<L extends string, S extends State> = {
568
566
  */
569
567
  state: S;
570
568
  };
571
- type ChoiceCheckFunction<L extends string, S extends State> = {
572
- (props: ChoiceCheckFunctionProps<L, S>): boolean;
573
- };
569
+ type ChoiceCheckFunction<L extends string, S extends State> = (props: ChoiceCheckFunctionProps<L, S>) => boolean;
574
570
  type ConditionCheckFunction<S extends State, R extends string | true | false> = (state: S) => R;
575
571
  type FunctionAction<L extends string, S extends State> = (props: FunctionActionProps<L, S>) => Thenable<void>;
576
572
  type ActionInputSetup = (input: HTMLInputElement, cleanup: (cb: () => void) => void) => void;
@@ -609,9 +605,7 @@ type ActionProxy<Characters extends Record<string, Character>, Languages extends
609
605
  */
610
606
  stopVoice: () => ValidAction;
611
607
  jump: (scene: string) => ValidAction;
612
- showCharacter: {
613
- <C extends keyof Characters>(character: C, emotion?: keyof Characters[C]['emotions'], className?: string, style?: string): ValidAction;
614
- };
608
+ showCharacter: <C extends keyof Characters>(character: C, emotion?: keyof Characters[C]['emotions'], className?: string, style?: string) => ValidAction;
615
609
  hideCharacter: (character: keyof Characters, className?: string, style?: string, duration?: number) => ValidAction;
616
610
  animateCharacter: (character: keyof Characters, timeout: number, ...classes: string[]) => ValidAction;
617
611
  wait: (time: number | ((state: State) => number)) => ValidAction;
@@ -281,7 +281,7 @@ var Novely = (() => {
281
281
  }
282
282
  fn.apply(this, args);
283
283
  throttled = true;
284
- setTimeout(function() {
284
+ setTimeout(() => {
285
285
  throttled = false;
286
286
  if (savedArgs) {
287
287
  wrapper.apply(savedThis, savedArgs);
@@ -891,8 +891,8 @@ var Novely = (() => {
891
891
  renderer: createRenderer,
892
892
  initialScreen = "mainmenu",
893
893
  translation,
894
- state: defaultState,
895
- data: defaultData,
894
+ state: defaultState = {},
895
+ data: defaultData = {},
896
896
  autosaves = true,
897
897
  migrations = [],
898
898
  throttleTimeout = 799,
@@ -913,8 +913,6 @@ var Novely = (() => {
913
913
  const ASSETS_TO_PRELOAD = /* @__PURE__ */ new Set();
914
914
  const dataLoaded = createControlledPromise();
915
915
  let initialScreenWasShown = false;
916
- defaultData ||= {};
917
- defaultState ||= {};
918
916
  const intime = (value) => {
919
917
  return times.add(value), value;
920
918
  };
@@ -1211,13 +1209,13 @@ var Novely = (() => {
1211
1209
  }
1212
1210
  return current;
1213
1211
  };
1214
- const exit = (force = false) => {
1212
+ const exit = (force = false, saving = true) => {
1215
1213
  if (interacted > 1 && !force && askBeforeExit) {
1216
1214
  renderer.ui.showExitPrompt();
1217
1215
  return;
1218
1216
  }
1219
1217
  const ctx = renderer.getContext(MAIN_CONTEXT_KEY);
1220
- if (interacted > 0) {
1218
+ if (interacted > 0 && saving) {
1221
1219
  save("auto");
1222
1220
  }
1223
1221
  const stack = useStack(ctx);
@@ -1546,7 +1544,7 @@ var Novely = (() => {
1546
1544
  end({ ctx }) {
1547
1545
  if (ctx.meta.preview)
1548
1546
  return;
1549
- exit(true);
1547
+ exit(true, false);
1550
1548
  },
1551
1549
  input({ ctx, data: data2, forward }, [question, onInput, setup]) {
1552
1550
  ctx.input(
@@ -1815,7 +1813,7 @@ var Novely = (() => {
1815
1813
  Remove: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
1816
1814
  LoadASaveFrom: "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u043E\u0442",
1817
1815
  DeleteASaveFrom: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u043E\u0442",
1818
- TextSpeed: "\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C \u0422\u0435\u043A\u0441\u0442\u0430",
1816
+ TextSpeed: "\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C \u0442\u0435\u043A\u0441\u0442\u0430",
1819
1817
  TextSpeedSlow: "\u041C\u0435\u0434\u043B\u0435\u043D\u043D\u0430\u044F",
1820
1818
  TextSpeedMedium: "\u0421\u0440\u0435\u0434\u043D\u044F\u044F",
1821
1819
  TextSpeedFast: "\u0411\u044B\u0441\u0442\u0440\u0430\u044F",