@novely/core 0.28.3 → 0.29.0

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
@@ -86,7 +86,7 @@ interface CharacterHandle {
86
86
  type AudioHandle = {
87
87
  stop: () => void;
88
88
  pause: () => void;
89
- play: () => void;
89
+ play: (loop: boolean) => void;
90
90
  };
91
91
  type Context = {
92
92
  id: string;
@@ -108,7 +108,7 @@ type Context = {
108
108
  audio: {
109
109
  voice: (source: string) => void;
110
110
  voiceStop: () => void;
111
- music: (source: string, method: 'music' | 'sound', loop?: boolean) => AudioHandle;
111
+ music: (source: string, method: 'music' | 'sound') => AudioHandle;
112
112
  /**
113
113
  * Stop all sounds
114
114
  */
@@ -418,7 +418,7 @@ type StateFunction<S extends State> = {
418
418
  type ValidAction = ['choice', number] | ['clear', Set<keyof DefaultActionProxy>?, Set<string>?, {
419
419
  music: Set<string>;
420
420
  sounds: Set<string>;
421
- }?] | ['condition', (state: State) => boolean, Record<string, ValidAction[]>] | ['dialog', string | undefined, TextContent<string, State>, string | undefined] | ['say', string, TextContent<string, State>] | ['end'] | ['showBackground', string | NonEmptyRecord<BackgroundImage>] | ['playMusic', string] | ['stopMusic', string] | ['playSound', audio: string, loop?: boolean] | ['voice', string] | ['stopVoice'] | ['jump', string] | ['showCharacter', string, keyof Character['emotions'], string?, string?] | ['hideCharacter', string, string?, string?, number?] | ['animateCharacter', string, number, ...string[]] | ['wait', (number | ((state: State) => number))] | ['function', FunctionAction<string, State>] | ['input', string, (meta: ActionInputOnInputMeta<string, State>) => void, ActionInputSetup?] | ['custom', CustomHandler<string, State>] | ['vibrate', ...number[]] | ['next'] | ['text', ...TextContent<string, State>[]] | ['exit'] | ['preload', string] | ['block', string] | ValidAction[];
421
+ }?] | ['condition', (state: State) => boolean, Record<string, ValidAction[]>] | ['dialog', string | undefined, TextContent<string, State>, string | undefined] | ['say', string, TextContent<string, State>] | ['end'] | ['showBackground', string | NonEmptyRecord<BackgroundImage>] | ['playMusic', string] | ['stopMusic', string] | ['pauseMusic', string] | ['playSound', audio: string, loop?: boolean] | ['pauseSound', string] | ['stopSound', string] | ['voice', string] | ['stopVoice'] | ['jump', string] | ['showCharacter', string, keyof Character['emotions'], string?, string?] | ['hideCharacter', string, string?, string?, number?] | ['animateCharacter', string, number, ...string[]] | ['wait', (number | ((state: State) => number))] | ['function', FunctionAction<string, State>] | ['input', string, (meta: ActionInputOnInputMeta<string, State>) => void, ActionInputSetup?] | ['custom', CustomHandler<string, State>] | ['vibrate', ...number[]] | ['next'] | ['text', ...TextContent<string, State>[]] | ['exit'] | ['preload', string] | ['block', string] | ValidAction[];
422
422
  type Story = Record<string, ValidAction[]>;
423
423
  type TextContent<L extends string, S extends State> = string | ((state: S) => string) | Record<L, string | ((state: S) => string)>;
424
424
  type FunctionableValue<T> = T | (() => T);
@@ -538,8 +538,10 @@ type ActionProxy<Characters extends Record<string, Character>, Languages extends
538
538
  end: () => ValidAction;
539
539
  showBackground: <T extends string | BackgroundImage>(background: T extends string ? T : T extends Record<PropertyKey, unknown> ? NonEmptyRecord<T> : never) => ValidAction;
540
540
  playMusic: (audio: string) => ValidAction;
541
+ pauseMusic: (audio: string) => ValidAction;
541
542
  stopMusic: (audio: string) => ValidAction;
542
543
  playSound: (audio: string, loop?: boolean) => ValidAction;
544
+ pauseSound: (audio: string) => ValidAction;
543
545
  stopSound: (audio: string) => ValidAction;
544
546
  /**
545
547
  * Plays voice
@@ -1323,7 +1323,11 @@ var Novely = (() => {
1323
1323
  push();
1324
1324
  },
1325
1325
  playMusic({ ctx, push }, [source]) {
1326
- ctx.audio.music(source, "music", true).play();
1326
+ ctx.audio.music(source, "music").play(true);
1327
+ push();
1328
+ },
1329
+ pauseMusic({ ctx, push }, [source]) {
1330
+ ctx.audio.music(source, "music").pause();
1327
1331
  push();
1328
1332
  },
1329
1333
  stopMusic({ ctx, push }, [source]) {
@@ -1331,7 +1335,11 @@ var Novely = (() => {
1331
1335
  push();
1332
1336
  },
1333
1337
  playSound({ ctx, push }, [source, loop]) {
1334
- ctx.audio.music(source, "sound", loop || false).play();
1338
+ ctx.audio.music(source, "sound").play(loop || false);
1339
+ push();
1340
+ },
1341
+ pauseSound({ ctx, push }, [source]) {
1342
+ ctx.audio.music(source, "sound").pause();
1335
1343
  push();
1336
1344
  },
1337
1345
  stopSound({ ctx, push }, [source]) {