@novely/core 0.45.1 → 0.45.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 +33 -31
- package/dist/index.global.js +622 -612
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +345 -335
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
get: () =>
|
|
6
|
-
set: (data: StorageData) => Promise<void>;
|
|
1
|
+
type Stored<T> = {
|
|
2
|
+
subscribe: (cb: (value: T) => void) => () => void;
|
|
3
|
+
update: (fn: (prev: T) => T) => void;
|
|
4
|
+
set: (val: T) => void;
|
|
5
|
+
get: () => T;
|
|
7
6
|
};
|
|
8
|
-
declare const localStorageStorage: (options: LocalStorageStorageSettings) => NovelyStorage;
|
|
9
|
-
|
|
10
|
-
type PluralType = Intl.LDMLPluralRule;
|
|
11
|
-
type Pluralization = Partial<Record<PluralType, string>>;
|
|
12
|
-
type AllowedContent = string | ((state: State | Data) => string | string[]) | string[] | (string | ((state: State | Data) => string | string[]))[];
|
|
13
|
-
type TranslationActions = Partial<Record<string, (str: string) => string>>;
|
|
14
7
|
|
|
15
8
|
declare const RU: {
|
|
16
9
|
NewGame: string;
|
|
@@ -59,13 +52,6 @@ declare const KK: Record<BaseTranslationStrings, string>;
|
|
|
59
52
|
*/
|
|
60
53
|
declare const JP: Record<BaseTranslationStrings, string>;
|
|
61
54
|
|
|
62
|
-
type Stored<T> = {
|
|
63
|
-
subscribe: (cb: (value: T) => void) => () => void;
|
|
64
|
-
update: (fn: (prev: T) => T) => void;
|
|
65
|
-
set: (val: T) => void;
|
|
66
|
-
get: () => T;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
55
|
interface CharacterHandle {
|
|
70
56
|
canvas: HTMLCanvasElement;
|
|
71
57
|
ctx: CanvasRenderingContext2D;
|
|
@@ -101,7 +87,13 @@ type Context = {
|
|
|
101
87
|
character: (character: string) => CharacterHandle;
|
|
102
88
|
background: (background: Record<string, string>) => void;
|
|
103
89
|
dialog: (content: string, name: string, character: string | undefined, emotion: string | undefined, resolve: () => void) => void;
|
|
104
|
-
choices: (question: string, choices: [
|
|
90
|
+
choices: (question: string, choices: [
|
|
91
|
+
name: string,
|
|
92
|
+
active: Stored<boolean>,
|
|
93
|
+
visible: Stored<boolean>,
|
|
94
|
+
onselect: () => void,
|
|
95
|
+
image: string
|
|
96
|
+
][], resolve: (selected: number) => void) => void;
|
|
105
97
|
input: (question: string, onInput: (meta: ActionInputOnInputMeta<Lang, State>) => void, setup: ActionInputSetup, resolve: () => void) => void;
|
|
106
98
|
clear: (keep: Set<keyof DefaultActionProxy>, keepCharacters: Set<string>, keepAudio: {
|
|
107
99
|
music: Set<string>;
|
|
@@ -237,14 +229,28 @@ type RendererInit<$Language extends Lang, $Characters extends Record<string, Cha
|
|
|
237
229
|
getLanguageDisplayName: (lang: Lang) => string;
|
|
238
230
|
getCharacterColor: (character: string) => string;
|
|
239
231
|
getCharacterAssets: (character: string, emotion: string) => string[];
|
|
240
|
-
getResourseType: (url: string) => Promise<
|
|
232
|
+
getResourseType: (url: string) => Promise<'image' | 'audio' | 'other'>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
type LocalStorageStorageSettings = {
|
|
236
|
+
key: string;
|
|
237
|
+
};
|
|
238
|
+
type NovelyStorage = {
|
|
239
|
+
get: () => Promise<StorageData>;
|
|
240
|
+
set: (data: StorageData) => Promise<void>;
|
|
241
241
|
};
|
|
242
|
+
declare const localStorageStorage: (options: LocalStorageStorageSettings) => NovelyStorage;
|
|
243
|
+
|
|
244
|
+
type PluralType = Intl.LDMLPluralRule;
|
|
245
|
+
type Pluralization = Partial<Record<PluralType, string>>;
|
|
246
|
+
type AllowedContent = string | ((state: State | Data) => string | string[]) | string[] | (string | ((state: State | Data) => string | string[]))[];
|
|
247
|
+
type TranslationActions = Partial<Record<string, (str: string) => string>>;
|
|
242
248
|
|
|
243
249
|
declare const getLanguage: (languages: string[]) => string;
|
|
244
250
|
|
|
245
251
|
type NovelyAsset = {
|
|
246
252
|
readonly source: string;
|
|
247
|
-
readonly type:
|
|
253
|
+
readonly type: 'audio' | 'image';
|
|
248
254
|
};
|
|
249
255
|
type Thenable<T> = T | Promise<T>;
|
|
250
256
|
type PathItem = [null, number | string] | ['jump', string] | ['choice', number] | ['choice:exit'] | ['condition', string] | ['condition:exit'] | ['exit'] | ['block', string] | ['block:exit'];
|
|
@@ -254,11 +260,7 @@ type Data = Record<string, any>;
|
|
|
254
260
|
type SaveDate = number;
|
|
255
261
|
type SaveType = 'manual' | 'auto';
|
|
256
262
|
type SaveMeta = [date: SaveDate, type: SaveType];
|
|
257
|
-
type Save<S extends State = State> = [
|
|
258
|
-
path: Path,
|
|
259
|
-
state: S,
|
|
260
|
-
meta: SaveMeta
|
|
261
|
-
];
|
|
263
|
+
type Save<S extends State = State> = [path: Path, state: S, meta: SaveMeta];
|
|
262
264
|
type Lang = string;
|
|
263
265
|
type TypewriterSpeed = 'Slow' | 'Medium' | 'Fast' | 'Auto';
|
|
264
266
|
type SoundVolume = number;
|
|
@@ -313,7 +315,7 @@ type TranslationDescription = {
|
|
|
313
315
|
actions?: TranslationActions;
|
|
314
316
|
};
|
|
315
317
|
type DefaultEmotions<$Characters extends Record<string, Character<Lang>>> = {
|
|
316
|
-
[Character in keyof $Characters]?:
|
|
318
|
+
[Character in keyof $Characters]?: keyof $Characters[Character]['emotions'] & string;
|
|
317
319
|
};
|
|
318
320
|
type CharacterAssetSizes<$Characters extends Record<string, Character<Lang>>> = {
|
|
319
321
|
[Character in keyof $Characters]?: {
|
|
@@ -563,7 +565,7 @@ type Character<$Lang extends Lang = string> = {
|
|
|
563
565
|
type ValidAction = ['choice', string | undefined, ...[string, unknown[], (() => boolean)?, (() => boolean)?, string?][]] | ['clear', Set<keyof DefaultActionProxy>?, Set<string>?, {
|
|
564
566
|
music: Set<string>;
|
|
565
567
|
sounds: Set<string>;
|
|
566
|
-
}?] | ['condition', (state: State) => boolean, Record<string, ValidAction[]>] | ['dialog', string | undefined, TextContent<string, State>, string | undefined] | ['end'] | ['showBackground', string | NovelyAsset | BackgroundImage] | ['playMusic', string | NovelyAsset] | ['stopMusic', string | NovelyAsset] | ['pauseMusic', string | NovelyAsset] | ['playSound', audio: string | NovelyAsset, loop?: boolean] | ['pauseSound', string | NovelyAsset] | ['stopSound', string | NovelyAsset] | ['voice', string | NovelyAsset | Record<string, string | NovelyAsset>] | ['stopVoice'] | ['jump', string] | ['showCharacter', string, keyof Character['emotions'], string?, string?] | ['hideCharacter', string, string?, string?, number?] | ['animateCharacter', string, number, ...string[]] | ['wait',
|
|
568
|
+
}?] | ['condition', (state: State) => boolean, Record<string, ValidAction[]>] | ['dialog', string | undefined, TextContent<string, State>, string | undefined] | ['end'] | ['showBackground', string | NovelyAsset | BackgroundImage] | ['playMusic', string | NovelyAsset] | ['stopMusic', string | NovelyAsset] | ['pauseMusic', string | NovelyAsset] | ['playSound', audio: string | NovelyAsset, loop?: boolean] | ['pauseSound', string | NovelyAsset] | ['stopSound', string | NovelyAsset] | ['voice', string | NovelyAsset | Record<string, string | NovelyAsset>] | ['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[];
|
|
567
569
|
type Story = Record<string, ValidAction[]>;
|
|
568
570
|
type TextContent<L extends string, S extends State> = string | ((state: S) => string) | Record<L, string | ((state: S) => string)>;
|
|
569
571
|
type FunctionableValue<T> = T | (() => T);
|
|
@@ -657,7 +659,7 @@ type CustomHandlerInfo = CustomHandlerCalling & {
|
|
|
657
659
|
/**
|
|
658
660
|
* Assets (pictures, audio files) used by action
|
|
659
661
|
*/
|
|
660
|
-
assets?: string[];
|
|
662
|
+
assets?: (NovelyAsset | string)[];
|
|
661
663
|
/**
|
|
662
664
|
* When true interacting with it will be saved in history
|
|
663
665
|
*/
|
|
@@ -885,7 +887,7 @@ declare const novely: <$Language extends string, $Characters extends Record<stri
|
|
|
885
887
|
* @example
|
|
886
888
|
* ```ts
|
|
887
889
|
* import type { ConditionParams, StateFunction } from '@novely/core';
|
|
888
|
-
|
|
890
|
+
*
|
|
889
891
|
* const conditionCheck = (state: StateFunction<ConditionParams<typeof engine.typeEssintials>>) => {
|
|
890
892
|
* return state.age >= 18;
|
|
891
893
|
* }
|