narrat 1.3.1 → 2.0.0-rc2

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 (45) hide show
  1. package/lib/app.vue.d.ts +27 -52
  2. package/lib/components/debug/debug-menu.vue.d.ts +1 -1
  3. package/lib/config.d.ts +7 -0
  4. package/lib/exports/plugins.d.ts +4 -4
  5. package/lib/index.d.ts +1 -4
  6. package/lib/index.esm.js +1544 -928
  7. package/lib/index.js +1544 -928
  8. package/lib/plugins/NarratPlugin.d.ts +1 -1
  9. package/lib/stores/hud-stats-store.d.ts +2 -0
  10. package/lib/stores/inventory-store.d.ts +2 -1
  11. package/lib/stores/main-store.d.ts +90 -110
  12. package/lib/stores/quest-log.d.ts +4 -1
  13. package/lib/stores/skills.d.ts +7 -4
  14. package/lib/stores/vm-store.d.ts +97 -104
  15. package/lib/types/parser.d.ts +32 -18
  16. package/lib/utils/audio-loader.d.ts +1 -0
  17. package/lib/utils/data-helpers.d.ts +5 -0
  18. package/lib/utils/logger.d.ts +1 -2
  19. package/lib/utils/skillchecks.d.ts +0 -3
  20. package/lib/utils/string-helpers.d.ts +2 -0
  21. package/lib/vm/commands/add.d.ts +5 -3
  22. package/lib/vm/commands/arithmetic-commands.d.ts +17 -0
  23. package/lib/vm/commands/audio-commands.d.ts +8 -0
  24. package/lib/vm/commands/choice.d.ts +36 -4
  25. package/lib/vm/commands/clear_dialog.d.ts +2 -3
  26. package/lib/vm/commands/command-helpers.d.ts +2 -0
  27. package/lib/vm/commands/command-plugin.d.ts +17 -8
  28. package/lib/vm/commands/flow-commands.d.ts +14 -0
  29. package/lib/vm/commands/if.d.ts +9 -1
  30. package/lib/vm/commands/inventory-commands.d.ts +14 -4
  31. package/lib/vm/commands/jump.d.ts +6 -1
  32. package/lib/vm/commands/logic-command.d.ts +42 -0
  33. package/lib/vm/commands/notify.d.ts +3 -1
  34. package/lib/vm/commands/quest-commands.d.ts +29 -4
  35. package/lib/vm/commands/screen-commands.d.ts +8 -0
  36. package/lib/vm/commands/set.d.ts +5 -1
  37. package/lib/vm/commands/skill-commands.d.ts +33 -0
  38. package/lib/vm/commands/stats-commands.d.ts +12 -0
  39. package/lib/vm/commands/string-commands.d.ts +9 -0
  40. package/lib/vm/commands/text.d.ts +13 -2
  41. package/lib/vm/commands/wait.d.ts +3 -1
  42. package/lib/vm/vm-helpers.d.ts +6 -6
  43. package/lib/vm/vm-parser.d.ts +10 -1
  44. package/lib/vm/vm.d.ts +8 -6
  45. package/package.json +11 -7
package/lib/app.vue.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PropType } from 'vue';
2
2
  import { DialogBoxParameters } from './types/dialog-box-types';
3
3
  import { GameConfig } from './types/app-types';
4
- import { AppOptions } from '.';
4
+ import { AppOptions } from './config';
5
5
  import { Parser } from './types/parser';
6
6
  import { DialogKey } from './stores/dialog-store';
7
7
  declare const _default: import("vue").DefineComponent<{
@@ -22,56 +22,32 @@ declare const _default: import("vue").DefineComponent<{
22
22
  }[]>;
23
23
  stack: import("vue").ComputedRef<{
24
24
  currentIndex: number;
25
- branch: {
26
- code: string;
27
- args: string[];
28
- operator: string;
29
- commandType: string;
30
- options: Parser.EmptyOptions | {
31
- condition: string;
32
- success: any[];
33
- failure?: any[];
34
- } | {
35
- label: string;
36
- } | {
37
- text: string;
38
- } | {
39
- prompt: any;
40
- choices: {
41
- choice: string;
42
- branch: any[];
43
- condition?: string;
44
- skillCheck?: {
45
- id: string;
46
- skill: string;
47
- value: number;
48
- hideAfterRoll: boolean;
49
- success: {
50
- text: string;
51
- branch: any[];
52
- };
53
- failure: {
54
- text: string;
55
- branch?: any[];
56
- };
57
- };
58
- index: number;
59
- }[];
60
- } | {
61
- screen: string;
62
- } | {
63
- mode: "sound" | "music";
64
- audio: string;
65
- } | {
66
- mode: "sound" | "music";
67
- audio?: string;
68
- } | {
69
- duration: number;
70
- };
71
- fileName: string;
72
- line: number;
73
- }[];
25
+ branchData: {
26
+ branch: {
27
+ code: string;
28
+ command: {
29
+ commandType: string;
30
+ operator: string;
31
+ args: (Parser.Primitive | {
32
+ code: string;
33
+ command: any;
34
+ fileName: string;
35
+ line: number;
36
+ })[];
37
+ options: Parser.DefaultArg;
38
+ staticOptions?: unknown;
39
+ };
40
+ fileName: string;
41
+ line: number;
42
+ }[];
43
+ args?: string[];
44
+ };
74
45
  label: string;
46
+ scope: {
47
+ [key: string]: any;
48
+ };
49
+ onComplete?: (result: any) => void;
50
+ returnValue: any;
75
51
  }[]>;
76
52
  modal: import("vue").ComputedRef<string | false>;
77
53
  flowState: import("vue").ComputedRef<"menu" | "playing">;
@@ -85,7 +61,6 @@ declare const _default: import("vue").DefineComponent<{
85
61
  }, {
86
62
  dialogLength(): number;
87
63
  lastDialog(): DialogKey | undefined;
88
- command(): Parser.Command;
89
64
  picture(): string | undefined;
90
65
  backgroundStyle(): any;
91
66
  layoutWidth(): number;
@@ -106,7 +81,7 @@ declare const _default: import("vue").DefineComponent<{
106
81
  gameStyle(): any;
107
82
  screenRatio(): number;
108
83
  dialogContainerStyle(): any;
109
- currentLine: () => Parser.Command;
84
+ currentLine: () => Parser.ParsedExpression<Parser.DefaultArg, undefined>;
110
85
  screenWidth: () => number;
111
86
  screenHeight: () => number;
112
87
  canvasWidth: () => number;
@@ -40,7 +40,7 @@ declare const _default: import("vue").DefineComponent<{}, {
40
40
  onSearchInput(): void;
41
41
  save(): void;
42
42
  wordCount(): void;
43
- countWordsInScriptLine(scriptLine: Parser.Command): number;
43
+ countWordsInScriptLine(scriptLine: Parser.ParsedExpression): number;
44
44
  countWordsInString(string: string): number;
45
45
  countWordsInScriptBranch(branch: Parser.Branch): number;
46
46
  getPlayTimeString(): string;
package/lib/config.d.ts CHANGED
@@ -4,6 +4,10 @@ export declare function getSkillConfig(id: string): SkillData;
4
4
  export declare function getItemConfig(id: string): ItemData;
5
5
  export declare function getQuestConfig(questId: string): QuestData;
6
6
  export declare function getObjectiveConfig(quest: string, objectiveId: string): ObjectiveData;
7
+ export interface AppOptions {
8
+ logging: boolean;
9
+ debug: boolean;
10
+ }
7
11
  export interface Config {
8
12
  gameTitle: string;
9
13
  images: {
@@ -79,6 +83,9 @@ export interface Config {
79
83
  quests: {
80
84
  [key: string]: QuestData;
81
85
  };
86
+ audioTriggers: {
87
+ [key: string]: string;
88
+ };
82
89
  }
83
90
  export interface QuestData {
84
91
  title: string;
@@ -2,7 +2,7 @@ import { NarratPlugin } from '../plugins/NarratPlugin';
2
2
  import { CommandPlugin, generateParser } from '../vm/commands/command-plugin';
3
3
  import type { CommandRunner } from '../vm/commands/command-plugin';
4
4
  export declare type NarratLifecycleHook = <T extends [...any[]]>(...args: T) => void;
5
- declare type NarratPluginObject = {
5
+ declare type NarratPluginObject<T> = {
6
6
  onPageLoaded?: NarratLifecycleHook;
7
7
  onNarratSetup?: NarratLifecycleHook;
8
8
  onAppMounted?: NarratLifecycleHook;
@@ -11,9 +11,9 @@ declare type NarratPluginObject = {
11
11
  onGameStart?: NarratLifecycleHook;
12
12
  onGameMounted?: NarratLifecycleHook;
13
13
  onGameUnmounted?: NarratLifecycleHook;
14
- customCommands?: CommandPlugin[];
14
+ customCommands?: CommandPlugin<T>[];
15
15
  };
16
- declare function registerPlugin(plugin: NarratPluginObject): void;
17
- declare function addCommand(command: CommandPlugin): void;
16
+ declare function registerPlugin<T>(plugin: NarratPluginObject<T>): void;
17
+ declare function addCommand<T>(command: CommandPlugin<T>): void;
18
18
  export { CommandRunner };
19
19
  export { CommandPlugin, NarratPluginObject, NarratPlugin, registerPlugin, addCommand, generateParser, };
package/lib/index.d.ts CHANGED
@@ -2,10 +2,7 @@ import 'es6-promise/auto';
2
2
  import './/sass/main.css';
3
3
  import { App } from 'vue';
4
4
  import { GameConfig } from './types/app-types';
5
- export interface AppOptions {
6
- logging: boolean;
7
- debug: boolean;
8
- }
5
+ import { AppOptions } from './config';
9
6
  export declare function startApp(config: GameConfig, options: AppOptions): Promise<void>;
10
7
  export declare type Narrat = {
11
8
  app: App;