narrat 3.4.0 → 3.5.1

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.
Files changed (34) hide show
  1. package/dist/components/hud.vue.d.ts +1 -1
  2. package/dist/components/saves/save-slot-ui.vue.d.ts +10 -11
  3. package/dist/config/common-config.d.ts +148 -0
  4. package/dist/config/config-input.d.ts +1494 -108
  5. package/dist/config/config-output.d.ts +5 -321
  6. package/dist/config.d.ts +14 -9
  7. package/dist/demo/themes-demo.d.ts +1 -0
  8. package/dist/examples/default/config/defaultGameConfig.d.ts +2 -0
  9. package/dist/examples/default/scripts/defaultGameScripts.d.ts +1 -0
  10. package/dist/examples/demo/scripts.d.ts +2 -2
  11. package/dist/exports/config.d.ts +1 -1
  12. package/dist/exports/exports.d.ts +1 -0
  13. package/dist/exports/plugins-list.d.ts +3 -0
  14. package/dist/exports/plugins.d.ts +1 -69
  15. package/dist/exports/utils.d.ts +1 -0
  16. package/dist/hmr/hmr.d.ts +3 -1
  17. package/dist/narrat.es.js +20692 -20482
  18. package/dist/narrat.es.js.map +1 -1
  19. package/dist/narrat.umd.js +134 -133
  20. package/dist/narrat.umd.js.map +1 -1
  21. package/dist/plugins/narrat-themes/NarratThemesPlugin.d.ts +41 -0
  22. package/dist/plugins/narrat-themes/fun-theme/index.d.ts +2 -0
  23. package/dist/plugins/narrat-themes/index.d.ts +2 -0
  24. package/dist/plugins/narrat-themes/text-only/index.d.ts +2 -0
  25. package/dist/plugins/plugins.d.ts +69 -0
  26. package/dist/stores/config-store.d.ts +12 -3
  27. package/dist/stores/main-store.d.ts +3279 -1875
  28. package/dist/stores/settings-store.d.ts +11 -11
  29. package/dist/style.css +1 -1
  30. package/dist/types/app-types.d.ts +39 -6
  31. package/dist/utils/data-helpers.d.ts +249 -141
  32. package/dist/utils/type-utils.d.ts +3 -0
  33. package/package.json +3 -2
  34. package/dist/examples/default/scripts.d.ts +0 -2
@@ -1,347 +1,31 @@
1
1
  import { AudioConfig } from '../config/audio-config';
2
- import { DebuggingConfig, DialogPanelConfig, InteractionTagsConfig, MenuButtonsConfig, NotificationsConfig, SavesConfig, SplashScreenConfig, TransitionsConfig, HudStatsConfig } from '../config/common-config';
2
+ import { CommonConfig } from '../config/common-config';
3
3
  import { ItemsConfig } from '../config/items-config';
4
4
  import { QuestsConfig } from '../config/quests-config';
5
5
  import { ScreensConfig } from '../config/screens-config';
6
6
  import { SkillsConfig } from '../config/skills-config';
7
7
  import { ButtonsConfig } from './buttons-config';
8
8
  import { CharactersFilesConfig } from './characters-config';
9
- import { LayoutConfig } from './layout-config';
10
9
  import { TooltipsConfig } from './tooltips-config';
11
10
  import { AchievementsConfig } from './achievements-config';
12
11
  import { SkillChecksConfig } from './skillchecks-config';
13
- import { SettingsConfig } from './settings-config';
14
12
  import { ChoicesConfig } from './choices-config';
15
13
  import { AnimationsConfig } from './animations-config';
16
14
  export interface Config {
17
- baseAssetsPath: string;
18
- baseDataPath: string;
19
- gameTitle: string;
20
- saveFileName: string;
21
- images: {
22
- [key: string]: string;
23
- };
24
- layout: LayoutConfig;
25
- settings: SettingsConfig;
26
- gameFlow: {
27
- labelToJumpOnScriptEnd?: string;
28
- };
29
- dialogPanel: DialogPanelConfig;
30
- splashScreens: SplashScreenConfig;
15
+ common: CommonConfig;
31
16
  screens: ScreensConfig;
32
17
  buttons: ButtonsConfig;
33
18
  skills: SkillsConfig;
34
19
  skillChecks: SkillChecksConfig;
35
20
  scripts: string[];
36
21
  audio: AudioConfig;
37
- notifications: NotificationsConfig;
38
- tooltips: TooltipsConfig;
39
- hudStats: HudStatsConfig;
40
22
  items: ItemsConfig;
41
23
  achievements: AchievementsConfig;
42
- interactionTags: InteractionTagsConfig;
43
24
  quests: QuestsConfig;
44
- transitions: TransitionsConfig;
45
- menuButtons: MenuButtonsConfig;
46
- debugging: DebuggingConfig;
47
- saves: SavesConfig;
48
25
  characters: CharactersFilesConfig;
49
- choices: ChoicesConfig;
50
26
  animations: AnimationsConfig;
27
+ tooltips: TooltipsConfig;
28
+ choices: ChoicesConfig;
51
29
  }
52
- export declare const defaultConfig: {
53
- baseAssetsPath: string;
54
- baseDataPath: string;
55
- gameTitle: string;
56
- saveFileName: string;
57
- images: {};
58
- layout: {
59
- minTextWidth?: number | undefined;
60
- defaultFontSize?: number | undefined;
61
- backgrounds: {
62
- width: number;
63
- height: number;
64
- };
65
- dialogBottomPadding: string | number;
66
- verticalLayoutThreshold: number;
67
- portraits: {
68
- offset?: {
69
- landscape?: {
70
- right: number;
71
- bottom: number;
72
- } | undefined;
73
- portrait?: {
74
- right: number;
75
- bottom: number;
76
- } | undefined;
77
- } | undefined;
78
- width: number;
79
- height: number;
80
- };
81
- };
82
- settings: {};
83
- gameFlow: {};
84
- dialogPanel: {
85
- overlayMode: boolean;
86
- rightOffset: number;
87
- bottomOffset: number;
88
- width: number;
89
- height: number;
90
- textSpeed: number;
91
- animateText: boolean;
92
- timeBetweenLines: number;
93
- showDuringTransition: boolean;
94
- showAfterScriptEnd: boolean;
95
- };
96
- splashScreens: {};
97
- screens: {
98
- screens: Record<string, {
99
- video?: {
100
- loop?: boolean | undefined;
101
- muted?: boolean | undefined;
102
- } | undefined;
103
- buttons?: (string | ({
104
- text?: string | undefined;
105
- background?: string | undefined;
106
- cssClass?: string | undefined;
107
- anchor?: {
108
- x: number;
109
- y: number;
110
- } | undefined;
111
- action?: string | undefined;
112
- actionType?: string | undefined;
113
- scriptClickable?: boolean | undefined;
114
- tag?: string | undefined;
115
- enabled: boolean;
116
- position: {
117
- width?: number | undefined;
118
- height?: number | undefined;
119
- left: number;
120
- top: number;
121
- };
122
- } & {
123
- id: string;
124
- }))[] | undefined;
125
- background: string;
126
- }>;
127
- };
128
- buttons: {
129
- clickableDuringScriptsByDefault?: boolean | undefined;
130
- buttons: Record<string, {
131
- text?: string | undefined;
132
- background?: string | undefined;
133
- cssClass?: string | undefined;
134
- anchor?: {
135
- x: number;
136
- y: number;
137
- } | undefined;
138
- action?: string | undefined;
139
- actionType?: string | undefined;
140
- scriptClickable?: boolean | undefined;
141
- tag?: string | undefined;
142
- enabled: boolean;
143
- position: {
144
- width?: number | undefined;
145
- height?: number | undefined;
146
- left: number;
147
- top: number;
148
- };
149
- }>;
150
- };
151
- skills: {
152
- skills: Record<string, {
153
- hidden?: boolean | undefined;
154
- name: string;
155
- description: string;
156
- startingLevel: number;
157
- icon: string;
158
- }>;
159
- skillOptions: {
160
- xpPerLevel: number;
161
- notifyLevelUp: boolean;
162
- };
163
- };
164
- skillChecks: {
165
- options: {
166
- extraDicePerLevel?: number | undefined;
167
- finalRollIsHighest?: boolean | undefined;
168
- finalRollIsLowest?: boolean | undefined;
169
- failOnRollsEqualToThreshold?: boolean | undefined;
170
- diceRange: [number, number];
171
- diceCount: number;
172
- difficultyText: [number, string][];
173
- extraPointsPerLevel: number;
174
- successOnRollsBelowThreshold: boolean;
175
- showDifficultyText: boolean;
176
- showDifficultyNumber: boolean;
177
- showDifficultyWithoutModifiers: boolean;
178
- };
179
- skillChecks: Record<string, {
180
- winsNeeded?: number | undefined;
181
- hideAfterRoll?: boolean | undefined;
182
- repeatable?: boolean | undefined;
183
- skill: string;
184
- difficulty: number;
185
- }>;
186
- };
187
- scripts: never[];
188
- audio: AudioConfig;
189
- notifications: {
190
- timeOnScreen: number;
191
- alsoPrintInDialogue: boolean;
192
- };
193
- tooltips: {
194
- options: {
195
- delay?: number | undefined;
196
- screenEdgesMinimumMargin?: number | undefined;
197
- styling?: {
198
- cssClass?: string | undefined;
199
- textCssClass?: string | undefined;
200
- titleCssClass?: string | undefined;
201
- } | undefined;
202
- width: number;
203
- keywordsPrefix: string;
204
- };
205
- tooltips: {
206
- styling?: {
207
- cssClass?: string | undefined;
208
- textCssClass?: string | undefined;
209
- titleCssClass?: string | undefined;
210
- } | undefined;
211
- title: string;
212
- description: string;
213
- keywords: string[];
214
- }[];
215
- };
216
- hudStats: {};
217
- achievements: {
218
- secretAchievements?: {
219
- censorDescription?: boolean | undefined;
220
- censorName?: boolean | undefined;
221
- hideUntilObtained?: boolean | undefined;
222
- } | undefined;
223
- categories: {
224
- title: string;
225
- id: string;
226
- }[];
227
- achievements: Record<string, {
228
- icon?: string | undefined;
229
- category?: string | undefined;
230
- lockedIcon?: string | undefined;
231
- secret?: boolean | undefined;
232
- name: string;
233
- description: string;
234
- }>;
235
- defaultAchievementIcon: string;
236
- notifyNewAchievements: boolean;
237
- };
238
- items: {
239
- categories: {
240
- title: string;
241
- id: string;
242
- }[];
243
- items: Record<string, {
244
- tag?: string | undefined;
245
- onUse?: {
246
- label: string;
247
- action: string;
248
- } | undefined;
249
- category?: string | undefined;
250
- showIfEmpty?: boolean | undefined;
251
- name: string;
252
- description: string;
253
- icon: string;
254
- }>;
255
- };
256
- interactionTags: {
257
- default: {
258
- onlyInteractOutsideOfScripts: boolean;
259
- };
260
- };
261
- quests: {
262
- categories: {
263
- title: string;
264
- id: string;
265
- }[];
266
- quests: Record<string, {
267
- category?: string | undefined;
268
- succeededDescription?: string | undefined;
269
- failedDescription?: string | undefined;
270
- endings?: Record<string, {
271
- description: string;
272
- success: boolean;
273
- }> | undefined;
274
- title: string;
275
- description: string;
276
- objectives: Record<string, {
277
- hidden?: boolean | undefined;
278
- succeededDescription?: string | undefined;
279
- failedDescription?: string | undefined;
280
- description: string;
281
- }>;
282
- }>;
283
- };
284
- transitions: {};
285
- menuButtons: {};
286
- debugging: {
287
- showScriptFinishedMessage: boolean;
288
- };
289
- saves: {
290
- mode: string;
291
- slots: number;
292
- };
293
- characters: {
294
- config: {
295
- playerCharacter?: string | undefined;
296
- gameCharacter?: string | undefined;
297
- imagesPath: string;
298
- };
299
- characters: Record<string, {
300
- style?: {
301
- portraitCssClass?: string | undefined;
302
- color?: string | undefined;
303
- boxCss?: Record<string, any> | undefined;
304
- nameCss?: Record<string, any> | undefined;
305
- textCss?: Record<string, any> | undefined;
306
- } | undefined;
307
- sprites?: Record<string, string | {
308
- loop?: boolean | undefined;
309
- width?: number | undefined;
310
- height?: number | undefined;
311
- autoplay?: boolean | undefined;
312
- muted?: boolean | undefined;
313
- video: string;
314
- } | {
315
- width?: number | undefined;
316
- height?: number | undefined;
317
- image: string;
318
- }> | undefined;
319
- name: string;
320
- }>;
321
- };
322
- choices: {
323
- choiceTextTemplate: string;
324
- choicePrompts: Record<string, {
325
- cssClass?: string | undefined;
326
- textTemplate?: string | undefined;
327
- }>;
328
- };
329
- animations: {
330
- animations: Record<string, {
331
- options?: {
332
- fill?: string | undefined;
333
- delay?: number | undefined;
334
- duration?: number | undefined;
335
- direction?: string | undefined;
336
- easing?: string | undefined;
337
- endDelay?: number | undefined;
338
- iterationStart?: number | undefined;
339
- iterations?: number | undefined;
340
- keyframes?: any;
341
- } | undefined;
342
- keyframes: string | any[];
343
- }>;
344
- keyframes: Record<string, any[]>;
345
- };
346
- };
30
+ export declare const defaultConfig: Config;
347
31
  export declare const defaultConfigTyped: Config;
package/dist/config.d.ts CHANGED
@@ -2,10 +2,15 @@ import { AppOptions } from './types/app-types';
2
2
  import { Config } from './config/config-output';
3
3
  import { ScreenConfig } from './config/screens-config';
4
4
  import { ButtonConfig } from './config/buttons-config';
5
- import { ConfigInput } from './config/config-input';
5
+ import { CommonConfig } from './config/common-config';
6
+ import { ConfigInput, ConfigInputWithCommon, ConfigInputWithoutCommon } from './config/config-input';
7
+ export declare function extendBaseConfig(newConfig: Config, configInput: ConfigInputWithCommon): Promise<void>;
8
+ export declare function copyValue<T>(value: T, base?: T): T;
9
+ export declare function addOldBaseConfig(newConfig: Config, configInput: ConfigInputWithoutCommon): Promise<void>;
6
10
  export declare function setupConfig(configInput: ConfigInput): Promise<Config>;
7
11
  export declare function loadConfig(options: AppOptions): Promise<Config>;
8
12
  export declare function getConfig(): Config;
13
+ export declare function getCommonConfig(): CommonConfig;
9
14
  export declare function audioConfig(): import("./config/audio-config").AudioConfig;
10
15
  export declare function audioFileConfig(key: string): {
11
16
  path?: string | undefined;
@@ -65,11 +70,11 @@ export declare function itemsConfig(): {
65
70
  id: string;
66
71
  }[];
67
72
  items: Record<string, {
68
- tag?: string | undefined;
69
73
  onUse?: {
70
74
  label: string;
71
75
  action: string;
72
76
  } | undefined;
77
+ tag?: string | undefined;
73
78
  category?: string | undefined;
74
79
  showIfEmpty?: boolean | undefined;
75
80
  name: string;
@@ -108,16 +113,16 @@ export declare function screensConfig(): {
108
113
  } | undefined;
109
114
  buttons?: (string | ({
110
115
  text?: string | undefined;
116
+ action?: string | undefined;
117
+ tag?: string | undefined;
111
118
  background?: string | undefined;
112
119
  cssClass?: string | undefined;
113
120
  anchor?: {
114
121
  x: number;
115
122
  y: number;
116
123
  } | undefined;
117
- action?: string | undefined;
118
124
  actionType?: string | undefined;
119
125
  scriptClickable?: boolean | undefined;
120
- tag?: string | undefined;
121
126
  enabled: boolean;
122
127
  position: {
123
128
  width?: number | undefined;
@@ -135,16 +140,16 @@ export declare function buttonsConfig(): {
135
140
  clickableDuringScriptsByDefault?: boolean | undefined;
136
141
  buttons: Record<string, {
137
142
  text?: string | undefined;
143
+ action?: string | undefined;
144
+ tag?: string | undefined;
138
145
  background?: string | undefined;
139
146
  cssClass?: string | undefined;
140
147
  anchor?: {
141
148
  x: number;
142
149
  y: number;
143
150
  } | undefined;
144
- action?: string | undefined;
145
151
  actionType?: string | undefined;
146
152
  scriptClickable?: boolean | undefined;
147
- tag?: string | undefined;
148
153
  enabled: boolean;
149
154
  position: {
150
155
  width?: number | undefined;
@@ -214,6 +219,7 @@ export declare function choicesConfig(): {
214
219
  }>;
215
220
  };
216
221
  export declare function animationsConfig(): {
222
+ keyframes: Record<string, any[]>;
217
223
  animations: Record<string, {
218
224
  options?: {
219
225
  fill?: string | undefined;
@@ -228,7 +234,6 @@ export declare function animationsConfig(): {
228
234
  } | undefined;
229
235
  keyframes: string | any[];
230
236
  }>;
231
- keyframes: Record<string, any[]>;
232
237
  };
233
238
  export declare function getChoicePromptConfig(flag: string): {
234
239
  cssClass?: string | undefined;
@@ -266,11 +271,11 @@ export declare function getSplitConfigUrl(basePath: string, url: string): string
266
271
  export declare function getDataUrl(dataPath: string): string;
267
272
  export declare function getButtonConfig(button: string): ButtonConfig;
268
273
  export declare function getItemConfig(id: string): {
269
- tag?: string | undefined;
270
274
  onUse?: {
271
275
  label: string;
272
276
  action: string;
273
277
  } | undefined;
278
+ tag?: string | undefined;
274
279
  category?: string | undefined;
275
280
  showIfEmpty?: boolean | undefined;
276
281
  name: string;
@@ -287,6 +292,7 @@ export declare function getAchievementsConfig(): {
287
292
  title: string;
288
293
  id: string;
289
294
  }[];
295
+ defaultAchievementIcon: string;
290
296
  achievements: Record<string, {
291
297
  icon?: string | undefined;
292
298
  category?: string | undefined;
@@ -295,7 +301,6 @@ export declare function getAchievementsConfig(): {
295
301
  name: string;
296
302
  description: string;
297
303
  }>;
298
- defaultAchievementIcon: string;
299
304
  notifyNewAchievements: boolean;
300
305
  };
301
306
  export declare function getAchievementConfig(id: string): {
@@ -0,0 +1 @@
1
+ export declare function setupThemesDemo(): void;
@@ -0,0 +1,2 @@
1
+ import { ModuleConfigInput } from '../../../config/config-input';
2
+ export declare const defaultGameConfigs: ModuleConfigInput;
@@ -0,0 +1 @@
1
+ export declare const defaultGameScripts: any[];
@@ -1,2 +1,2 @@
1
- declare const _default: any[];
2
- export default _default;
1
+ export declare const demoScripts: any[];
2
+ export declare const demoYamls: NarratYaml[];
@@ -1,4 +1,4 @@
1
- export { getConfig } from '../config';
1
+ export { getCommonConfig as getConfig } from '../config';
2
2
  export type { Config } from '../config/config-output';
3
3
  export * from '../config/config-input';
4
4
  export { audioConfig, skillsConfig, itemsConfig, questsConfig, screensConfig, buttonsConfig, tooltipsConfig, charactersConfig, getSkillConfig, getImageUrl, getAssetUrl, getSplitConfigUrl, getDataUrl, getButtonConfig, getScreenConfig, getItemConfig, getQuestConfig, getObjectiveConfig, } from '../config';
@@ -8,3 +8,4 @@ export * from '../exports/others';
8
8
  export * from '../exports/components';
9
9
  export * from '../exports/utils';
10
10
  export * from '../exports/optionals';
11
+ export * from '../exports/plugins-list';
@@ -0,0 +1,3 @@
1
+ export * from '../plugins/narrat-themes/NarratThemesPlugin';
2
+ export * from '../plugins/godot-plugin';
3
+ export * from '../plugins/narrat-themes';
@@ -1,69 +1 @@
1
- import { NarratPlugin } from '../plugins/NarratPlugin';
2
- import { CommandPlugin, generateParser } from '../vm/commands/command-plugin';
3
- import type { CommandRunner } from '../vm/commands/command-plugin';
4
- import { StoreDefinition } from 'pinia';
5
- import { MenuState, MenuTabState } from '../stores/menu-store';
6
- import { CustomSetting } from '../config/settings-config';
7
- export type NarratLifecycleHook = <T extends [...any[]]>(...args: T) => void;
8
- export interface NarratCustomStoreActions {
9
- save?: () => any;
10
- load?: (data: any) => void;
11
- setup?: () => Promise<void>;
12
- start?: () => void;
13
- reset: () => void;
14
- }
15
- export type UseCustomStore = StoreDefinition<string, any, any, NarratCustomStoreActions>;
16
- export interface CustomStores {
17
- [key: string]: UseCustomStore;
18
- }
19
- export interface CustomMenuButton {
20
- menuId: string;
21
- config: MenuState;
22
- components: {
23
- [key: string]: any;
24
- };
25
- }
26
- export interface CustomMenuTab {
27
- menuId: string;
28
- config: MenuTabState;
29
- component: any;
30
- }
31
- export type NarratPluginObject<T> = {
32
- pluginId: string;
33
- onPageLoaded?: NarratLifecycleHook;
34
- onNarratSetup?: NarratLifecycleHook;
35
- onAppMounted?: NarratLifecycleHook;
36
- onAssetsLoaded?: NarratLifecycleHook;
37
- onGameSetup?: NarratLifecycleHook;
38
- onGameStart?: NarratLifecycleHook;
39
- onGameMounted?: NarratLifecycleHook;
40
- onGameUnmounted?: NarratLifecycleHook;
41
- customCommands?: CommandPlugin<T>[];
42
- customStores?: CustomStores;
43
- customMenuButtons?: CustomMenuButton[];
44
- customMenuTabs?: CustomMenuTab[];
45
- startMenuButtons?: CustomStartMenuButton[];
46
- customSettings?: Record<string, CustomSetting>;
47
- save?: () => any;
48
- load?: (data: any) => void;
49
- reset?: () => void;
50
- loadingPromises?: Promise<any>[];
51
- };
52
- /**
53
- * Custom buttons that get added to the start menu (where the New Game etc buttons are)
54
- * Action option is to provide a function to run on click
55
- * popupComponent option is to provide a component to display in a modal window on click (for custom pieces of UI)
56
- */
57
- export interface CustomStartMenuButton {
58
- id: string;
59
- text: string;
60
- action?: () => void;
61
- popupComponent?: {
62
- name: string;
63
- component: any;
64
- };
65
- }
66
- declare function registerPlugin<T>(plugin: NarratPluginObject<T>): void;
67
- declare function addCommand<T>(command: CommandPlugin<T>): void;
68
- export { CommandRunner };
69
- export { CommandPlugin, NarratPlugin, registerPlugin, addCommand, generateParser, };
1
+ export * from '../plugins/plugins';
@@ -12,3 +12,4 @@ export type { Vector2 } from '../utils/Vector2';
12
12
  export { gameloop } from '../utils/gameloop';
13
13
  export { debounce } from '../utils/debounce';
14
14
  export * from '../utils/construct-narrat';
15
+ export * from '../utils/type-utils';
package/dist/hmr/hmr.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { NarratScript } from '../types/app-types';
1
+ import { NarratScript, NarratYaml } from '../types/app-types';
2
2
  import { ModuleNamespace } from 'vite/types/hot';
3
+ export declare function isModuleValid(newModule: ModuleNamespace | undefined): newModule is ModuleNamespace;
3
4
  export declare function handleHMR(newModule: ModuleNamespace | undefined): void;
4
5
  export declare function isNarratScript(scriptModule: any): scriptModule is NarratScript;
6
+ export declare function isNarratYaml(scriptModule: any): scriptModule is NarratYaml;