@novely/core 0.31.3 → 0.32.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 +13 -2
- package/dist/index.global.js +7 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -483,7 +483,7 @@ type Character<$Lang extends Lang = string> = {
|
|
|
483
483
|
type ValidAction = ['choice', number] | ['clear', Set<keyof DefaultActionProxy>?, Set<string>?, {
|
|
484
484
|
music: Set<string>;
|
|
485
485
|
sounds: Set<string>;
|
|
486
|
-
}?] | ['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[];
|
|
486
|
+
}?] | ['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 | Record<string, 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[];
|
|
487
487
|
type Story = Record<string, ValidAction[]>;
|
|
488
488
|
type TextContent<L extends string, S extends State> = string | ((state: S) => string) | Record<L, string | ((state: S) => string)>;
|
|
489
489
|
type FunctionableValue<T> = T | (() => T);
|
|
@@ -587,6 +587,7 @@ type ConditionCheckFunction<S extends State, R extends string | true | false> =
|
|
|
587
587
|
type FunctionAction<L extends string, S extends State> = (props: FunctionActionProps<L, S>) => Thenable<void>;
|
|
588
588
|
type ActionInputSetup = (input: HTMLInputElement, cleanup: (cb: () => void) => void) => void;
|
|
589
589
|
type BackgroundImage = Partial<Record<'portrait' | 'landscape' | 'all', string>> & Record<string, string>;
|
|
590
|
+
type VoiceAction<L extends Lang> = (params: string | Partial<Record<L, string>>) => ValidAction;
|
|
590
591
|
type ActionProxy<Characters extends Record<string, Character>, Languages extends Lang, S extends State> = {
|
|
591
592
|
choice: {
|
|
592
593
|
(...choices: [name: TextContent<Languages, S>, actions: ValidAction[], active?: ChoiceCheckFunction<Languages, S>][]): ValidAction;
|
|
@@ -614,8 +615,18 @@ type ActionProxy<Characters extends Record<string, Character>, Languages extends
|
|
|
614
615
|
stopSound: (audio: string) => ValidAction;
|
|
615
616
|
/**
|
|
616
617
|
* Plays voice
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```
|
|
621
|
+
* engine.script({
|
|
622
|
+
* start: [
|
|
623
|
+
* engine.action.voice('./rick-astley-never-gonna-give-you-up.mp3'),
|
|
624
|
+
* engine.action.say('Rick', 'Never gonna give you up'),
|
|
625
|
+
* ]
|
|
626
|
+
* })
|
|
627
|
+
* ```
|
|
617
628
|
*/
|
|
618
|
-
voice:
|
|
629
|
+
voice: VoiceAction<Languages>;
|
|
619
630
|
/**
|
|
620
631
|
* Stops currently playing voice
|
|
621
632
|
*/
|
package/dist/index.global.js
CHANGED
|
@@ -1405,7 +1405,13 @@ var Novely = (() => {
|
|
|
1405
1405
|
push();
|
|
1406
1406
|
},
|
|
1407
1407
|
voice({ ctx, push }, [source]) {
|
|
1408
|
-
|
|
1408
|
+
const [lang] = storageData.get().meta;
|
|
1409
|
+
const audioSource = isString(source) ? source : source[lang];
|
|
1410
|
+
if (!audioSource) {
|
|
1411
|
+
push();
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
ctx.audio.voice(audioSource);
|
|
1409
1415
|
push();
|
|
1410
1416
|
},
|
|
1411
1417
|
stopVoice({ ctx, push }) {
|