narrat 0.11.0 → 0.11.3

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.
@@ -1,4 +1,4 @@
1
- import { SkillData } from '@/types/config';
1
+ import { SkillData } from '@/config';
2
2
  import { SkillsState } from '@/types/vuex';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  close: any;
@@ -1,4 +1,4 @@
1
- import { HudStatConfig } from '@/types/config';
1
+ import { HudStatConfig } from '@/config';
2
2
  import { HudStatsState } from 'vue';
3
3
  declare const _default: import("vue").DefineComponent<{}, {}, void, {
4
4
  statsConfig(): {
package/lib/config.d.ts CHANGED
@@ -1,5 +1,104 @@
1
1
  import { Commit } from 'vuex';
2
- import { Config } from './types/config';
3
2
  export declare function setConfig(conf: Config): void;
4
3
  export declare function getConfig(): Config;
5
- export declare function getSkillConfig(commit: Commit, id: string): import("./types/config").SkillData;
4
+ export declare function getSkillConfig(commit: Commit, id: string): SkillData;
5
+ export interface Config {
6
+ gameTitle: string;
7
+ images: {
8
+ [key: string]: string;
9
+ };
10
+ layout: {
11
+ backgrounds: {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ dialogBottomPadding: number;
16
+ minTextWidth: number;
17
+ mobileDialogHeightPercentage: number;
18
+ verticalLayoutThreshold: number;
19
+ portraits: {
20
+ width: number;
21
+ height: number;
22
+ };
23
+ };
24
+ screens: {
25
+ [key: string]: {
26
+ background: string;
27
+ buttons: string[];
28
+ };
29
+ };
30
+ buttons: {
31
+ [key: string]: ButtonConfig;
32
+ };
33
+ skills: {
34
+ [key: string]: SkillData;
35
+ };
36
+ skillOptions: {
37
+ xpPerLevel: number;
38
+ };
39
+ skillChecks: {
40
+ rollRange: number;
41
+ skillMultiplier: number;
42
+ failureChance: number;
43
+ difficultyText: Array<[number, string]>;
44
+ };
45
+ scripts: string[];
46
+ audio: {
47
+ [key: string]: AudioConfig;
48
+ };
49
+ audioOptions: {
50
+ volume: number;
51
+ defaultMusic?: string;
52
+ musicFadeInTime: number;
53
+ musicFadeInDelay: number;
54
+ musicFadeOutTime: number;
55
+ };
56
+ sound?: {
57
+ [key: string]: AudioConfig;
58
+ };
59
+ music?: {
60
+ [key: string]: AudioConfig;
61
+ };
62
+ notifications: {
63
+ timeOnScreen: number;
64
+ alsoPrintInDialogue?: boolean;
65
+ };
66
+ hudStats: {
67
+ [key: string]: HudStatConfig;
68
+ };
69
+ }
70
+ export interface HudStatConfig {
71
+ name: string;
72
+ icon: string;
73
+ startingValue: number;
74
+ minValue?: number;
75
+ maxValue?: number;
76
+ }
77
+ export interface AudioConfig {
78
+ src: string;
79
+ path?: string;
80
+ volume?: number;
81
+ rate?: number;
82
+ html5?: boolean;
83
+ }
84
+ export interface MusicConfig extends AudioConfig {
85
+ loop?: boolean;
86
+ }
87
+ export interface ButtonConfig {
88
+ enabled: boolean;
89
+ background: string;
90
+ position: {
91
+ left: number;
92
+ top: number;
93
+ width: number;
94
+ height: number;
95
+ };
96
+ action: string;
97
+ }
98
+ export interface SkillData {
99
+ name: string;
100
+ description: string;
101
+ startingLevel: number;
102
+ hidden?: boolean;
103
+ icon: string;
104
+ }
@@ -1,2 +1,2 @@
1
- import { Config } from './types/config';
1
+ import { Config } from './config';
2
2
  export declare const defaultConfig: Config;
@@ -0,0 +1 @@
1
+ export { getConfig } from '../config';
@@ -0,0 +1,2 @@
1
+ import { aspectRatioFit } from '../utils/helpers';
2
+ export { aspectRatioFit };
@@ -0,0 +1,22 @@
1
+ import { State } from 'vue';
2
+ import { ActionContext } from 'vuex';
3
+ import { NarratPlugin } from '../plugins/NarratPlugin';
4
+ import { CommandPlugin, generateParser } from '../vm/commands/command-plugin';
5
+ import type { CommandRunner } from '../vm/commands/command-plugin';
6
+ export declare type NarratLifecycleHook = <T extends [...any[]]>(...args: T) => void;
7
+ declare type NarratPluginObject = {
8
+ onPageLoaded?: NarratLifecycleHook;
9
+ onNarratSetup?: NarratLifecycleHook;
10
+ onAppMounted?: NarratLifecycleHook;
11
+ onAssetsLoaded?: NarratLifecycleHook;
12
+ onGameSetup?: NarratLifecycleHook;
13
+ onGameStart?: NarratLifecycleHook;
14
+ onGameMounted?: NarratLifecycleHook;
15
+ onGameUnmounted?: NarratLifecycleHook;
16
+ customCommands?: CommandPlugin[];
17
+ };
18
+ declare function registerPlugin(plugin: NarratPluginObject): void;
19
+ declare function addCommand(command: CommandPlugin): void;
20
+ export declare type NarratActionContext = ActionContext<State, State>;
21
+ export { CommandRunner };
22
+ export { CommandPlugin, NarratPluginObject, NarratPlugin, registerPlugin, addCommand, generateParser, };
package/lib/index.d.ts CHANGED
@@ -1,20 +1,23 @@
1
1
  import 'es6-promise/auto';
2
2
  import './/sass/main.css';
3
- import './lib';
3
+ import { App, State } from 'vue';
4
4
  import { GameConfig } from './types/app-types';
5
- import * as plugins from './plugins';
6
- import * as display from './display';
7
- import * as config from './config';
5
+ import { Store } from 'vuex';
8
6
  export interface AppOptions {
9
7
  logging: boolean;
10
8
  debug: boolean;
11
9
  }
12
10
  export declare function startApp(config: GameConfig, options: AppOptions): Promise<void>;
13
- export { plugins, config, display };
14
- declare const _default: {
15
- startApp: typeof startApp;
16
- plugins: typeof plugins;
17
- display: typeof display;
18
- config: typeof config;
11
+ export declare type Narrat = {
12
+ store: Store<State>;
13
+ app: App;
14
+ state: State;
19
15
  };
20
- export default _default;
16
+ declare global {
17
+ export interface Window {
18
+ narrat: Narrat;
19
+ }
20
+ }
21
+ export * from './exports/plugins';
22
+ export * from './exports/display';
23
+ export * from './config';
package/lib/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version: 0.11.0 - June 15, 2022 15:25:13
1
+ // Version: 0.11.3 - June 15, 2022 16:22:12
2
2
  import 'es6-promise/auto';
3
3
  import { ref, reactive, readonly, defineComponent, openBlock, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, Fragment, renderList, normalizeClass, createBlock, Transition, withCtx, renderSlot, createTextVNode, resolveComponent, withDirectives, vModelText, toDisplayString, TransitionGroup, createVNode, createApp } from 'vue';
4
4
  import { createLogger, createStore } from 'vuex';
@@ -339,13 +339,6 @@ function getSkillConfig(commit, id) {
339
339
  return skill;
340
340
  }
341
341
 
342
- var config$2 = /*#__PURE__*/Object.freeze({
343
- __proto__: null,
344
- setConfig: setConfig,
345
- getConfig: getConfig,
346
- getSkillConfig: getSkillConfig
347
- });
348
-
349
342
  var script$1 = defineComponent({
350
343
  props: {
351
344
  pictureUrl: String,
@@ -8750,20 +8743,6 @@ function addCommand(command) {
8750
8743
  vm$1.addCommand(command);
8751
8744
  }
8752
8745
 
8753
- var plugins = /*#__PURE__*/Object.freeze({
8754
- __proto__: null,
8755
- CommandPlugin: CommandPlugin,
8756
- NarratPlugin: NarratPlugin,
8757
- registerPlugin: registerPlugin,
8758
- addCommand: addCommand,
8759
- generateParser: generateParser
8760
- });
8761
-
8762
- var display = /*#__PURE__*/Object.freeze({
8763
- __proto__: null,
8764
- aspectRatioFit: aspectRatioFit
8765
- });
8766
-
8767
8746
  let app;
8768
8747
  let store$2;
8769
8748
  vm$1.callHook('onPageLoaded');
@@ -8772,7 +8751,7 @@ async function startApp(config, options) {
8772
8751
  logManager.setupDebugger(options.debug);
8773
8752
  const configFile = await getFile('data/config.json');
8774
8753
  setConfig(JSON.parse(configFile));
8775
- console.log('%c Narrat game engine – 0.11.0 - June 15, 2022 15:25:13', 'background: #222; color: #bada55');
8754
+ console.log('%c Narrat game engine – 0.11.3 - June 15, 2022 16:22:12', 'background: #222; color: #bada55');
8776
8755
  vm$1.callHook('onNarratSetup');
8777
8756
  const storeSetup = setupStore(options);
8778
8757
  store$2 = storeSetup.store;
@@ -8811,14 +8790,7 @@ async function startApp(config, options) {
8811
8790
  });
8812
8791
  }
8813
8792
  startGameLoop(store$2);
8814
- }
8815
- var index = {
8816
- startApp,
8817
- plugins,
8818
- display,
8819
- config: config$2,
8820
- };
8793
+ }
8821
8794
 
8822
- export default index;
8823
- export { config$2 as config, display, plugins, startApp };
8795
+ export { CommandPlugin, NarratPlugin, addCommand, aspectRatioFit, generateParser, getConfig, getSkillConfig, registerPlugin, setConfig, startApp };
8824
8796
  //# sourceMappingURL=index.esm.js.map
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version: 0.11.0 - June 15, 2022 15:25:13
1
+ // Version: 0.11.3 - June 15, 2022 16:22:12
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -343,13 +343,6 @@ function getSkillConfig(commit, id) {
343
343
  return skill;
344
344
  }
345
345
 
346
- var config$2 = /*#__PURE__*/Object.freeze({
347
- __proto__: null,
348
- setConfig: setConfig,
349
- getConfig: getConfig,
350
- getSkillConfig: getSkillConfig
351
- });
352
-
353
346
  var script$1 = vue.defineComponent({
354
347
  props: {
355
348
  pictureUrl: String,
@@ -8754,20 +8747,6 @@ function addCommand(command) {
8754
8747
  vm$1.addCommand(command);
8755
8748
  }
8756
8749
 
8757
- var plugins = /*#__PURE__*/Object.freeze({
8758
- __proto__: null,
8759
- CommandPlugin: CommandPlugin,
8760
- NarratPlugin: NarratPlugin,
8761
- registerPlugin: registerPlugin,
8762
- addCommand: addCommand,
8763
- generateParser: generateParser
8764
- });
8765
-
8766
- var display = /*#__PURE__*/Object.freeze({
8767
- __proto__: null,
8768
- aspectRatioFit: aspectRatioFit
8769
- });
8770
-
8771
8750
  let app;
8772
8751
  let store$2;
8773
8752
  vm$1.callHook('onPageLoaded');
@@ -8776,7 +8755,7 @@ async function startApp(config, options) {
8776
8755
  logManager.setupDebugger(options.debug);
8777
8756
  const configFile = await getFile('data/config.json');
8778
8757
  setConfig(JSON.parse(configFile));
8779
- console.log('%c Narrat game engine – 0.11.0 - June 15, 2022 15:25:13', 'background: #222; color: #bada55');
8758
+ console.log('%c Narrat game engine – 0.11.3 - June 15, 2022 16:22:12', 'background: #222; color: #bada55');
8780
8759
  vm$1.callHook('onNarratSetup');
8781
8760
  const storeSetup = setupStore(options);
8782
8761
  store$2 = storeSetup.store;
@@ -8815,17 +8794,16 @@ async function startApp(config, options) {
8815
8794
  });
8816
8795
  }
8817
8796
  startGameLoop(store$2);
8818
- }
8819
- var index = {
8820
- startApp,
8821
- plugins,
8822
- display,
8823
- config: config$2,
8824
- };
8797
+ }
8825
8798
 
8826
- exports.config = config$2;
8827
- exports.default = index;
8828
- exports.display = display;
8829
- exports.plugins = plugins;
8799
+ exports.CommandPlugin = CommandPlugin;
8800
+ exports.NarratPlugin = NarratPlugin;
8801
+ exports.addCommand = addCommand;
8802
+ exports.aspectRatioFit = aspectRatioFit;
8803
+ exports.generateParser = generateParser;
8804
+ exports.getConfig = getConfig;
8805
+ exports.getSkillConfig = getSkillConfig;
8806
+ exports.registerPlugin = registerPlugin;
8807
+ exports.setConfig = setConfig;
8830
8808
  exports.startApp = startApp;
8831
8809
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { NarratPluginObject } from '@/types/narrat';
1
+ import { NarratPluginObject } from '@/exports/plugins';
2
2
  export declare class NarratPlugin implements NarratPluginObject {
3
3
  onPageLoaded(): void;
4
4
  onNarratSetup(): void;
package/lib/plugins.d.ts CHANGED
@@ -1,9 +1,22 @@
1
1
  import { State } from 'vue';
2
2
  import { ActionContext } from 'vuex';
3
3
  import { NarratPlugin } from './plugins/NarratPlugin';
4
- import { NarratPluginObject } from './types/narrat';
5
- import { CommandPlugin, CommandRunner, generateParser } from './vm/commands/command-plugin';
4
+ import { CommandPlugin, generateParser } from './vm/commands/command-plugin';
5
+ import type { CommandRunner } from './vm/commands/command-plugin';
6
+ export declare type NarratLifecycleHook = <T extends [...any[]]>(...args: T) => void;
7
+ declare type NarratPluginObject = {
8
+ onPageLoaded?: NarratLifecycleHook;
9
+ onNarratSetup?: NarratLifecycleHook;
10
+ onAppMounted?: NarratLifecycleHook;
11
+ onAssetsLoaded?: NarratLifecycleHook;
12
+ onGameSetup?: NarratLifecycleHook;
13
+ onGameStart?: NarratLifecycleHook;
14
+ onGameMounted?: NarratLifecycleHook;
15
+ onGameUnmounted?: NarratLifecycleHook;
16
+ customCommands?: CommandPlugin[];
17
+ };
6
18
  declare function registerPlugin(plugin: NarratPluginObject): void;
7
19
  declare function addCommand(command: CommandPlugin): void;
8
20
  export declare type NarratActionContext = ActionContext<State, State>;
9
- export { CommandPlugin, CommandRunner, NarratPluginObject, NarratPlugin, registerPlugin, addCommand, generateParser, };
21
+ export { CommandRunner };
22
+ export { CommandPlugin, NarratPluginObject, NarratPlugin, registerPlugin, addCommand, generateParser, };
@@ -0,0 +1,4 @@
1
+ export interface GameConfig {
2
+ charactersPath: string;
3
+ configPath: string;
4
+ }
@@ -0,0 +1,27 @@
1
+ export interface CharactersConfigFile {
2
+ config: {
3
+ imagesPath: string;
4
+ };
5
+ characters: {
6
+ [key: string]: CharacterData;
7
+ };
8
+ }
9
+ export interface CharacterData {
10
+ sprites?: {
11
+ [key: string]: string;
12
+ };
13
+ name: string;
14
+ style?: DialogStyle;
15
+ }
16
+ export interface DialogStyle {
17
+ color?: string;
18
+ boxCss?: {
19
+ [key: string]: any;
20
+ };
21
+ nameCss?: {
22
+ [key: string]: any;
23
+ };
24
+ textCss?: {
25
+ [key: string]: any;
26
+ };
27
+ }
@@ -0,0 +1,9 @@
1
+ import { DialogChoice } from './vuex';
2
+ export interface DialogBoxParameters {
3
+ title: string;
4
+ text: string;
5
+ styleId: string;
6
+ choices: DialogChoice[];
7
+ old: boolean;
8
+ interactive: boolean;
9
+ }
@@ -0,0 +1,18 @@
1
+ import { ButtonsState, HudStatsState } from 'vue';
2
+ import { DataState, DialogKey, SkillCheckState, SkillsState } from './vuex';
3
+ export interface GameSave {
4
+ data: DataState;
5
+ skills: SkillsState;
6
+ dialog: DialogKey[];
7
+ lastLabel: string;
8
+ buttons: ButtonsState;
9
+ skillChecks: {
10
+ [key: string]: SkillCheckState;
11
+ };
12
+ playTime: number;
13
+ hudStats: HudStatsState;
14
+ audio: {
15
+ currentMusic?: string;
16
+ };
17
+ currentScreen: string;
18
+ }
@@ -0,0 +1,79 @@
1
+ declare namespace Parser {
2
+ interface IfOptions {
3
+ condition: string;
4
+ success: Branch;
5
+ failure?: Branch;
6
+ }
7
+ interface ChoiceOptions {
8
+ prompt: Command;
9
+ choices: ChoicePrompt[];
10
+ }
11
+ interface ChoicePrompt {
12
+ choice: string;
13
+ branch: Branch;
14
+ condition?: string;
15
+ skillCheck?: SkillCheckOptions;
16
+ index: number;
17
+ }
18
+ interface PlayOptions {
19
+ mode: 'sound' | 'music';
20
+ audio: string;
21
+ }
22
+ interface StopOptions {
23
+ mode: 'sound' | 'music';
24
+ audio?: string;
25
+ }
26
+ interface SkillCheckOptions {
27
+ id: string;
28
+ skill: string;
29
+ value: number;
30
+ hideAfterRoll: boolean;
31
+ success: {
32
+ text: string;
33
+ branch: Branch;
34
+ };
35
+ failure: {
36
+ text: string;
37
+ branch?: Branch;
38
+ };
39
+ }
40
+ interface JumpOptions {
41
+ label: string;
42
+ }
43
+ interface WaitOptions {
44
+ duration: number;
45
+ }
46
+ interface IfOptions {
47
+ branch: Branch;
48
+ }
49
+ interface TextOptions {
50
+ text: string;
51
+ }
52
+ interface SetScreenOption {
53
+ screen: string;
54
+ }
55
+ interface EmptyOptions {
56
+ }
57
+ type CommandOptions = IfOptions | JumpOptions | EmptyOptions | TextOptions | ChoiceOptions | SetScreenOption | PlayOptions | StopOptions | WaitOptions;
58
+ interface Command {
59
+ code: string;
60
+ args: string[];
61
+ operator: string;
62
+ commandType: string;
63
+ options: CommandOptions;
64
+ fileName: string;
65
+ line: number;
66
+ }
67
+ type Branch = Command[];
68
+ interface ParsedScript {
69
+ [key: string]: Parser.Branch;
70
+ }
71
+ interface Line {
72
+ code: string;
73
+ indentation: number;
74
+ line: number;
75
+ operator: string;
76
+ args: any[];
77
+ branch?: Line[];
78
+ }
79
+ }
@@ -1,4 +1,4 @@
1
- import { Config, MusicConfig, AudioConfig } from '@/types/config';
1
+ import { Config, MusicConfig, AudioConfig } from '../config';
2
2
  import { Howl } from 'howler';
3
3
  import { State } from 'vue';
4
4
  import { ActionContext, Commit } from 'vuex';
@@ -1,4 +1,4 @@
1
- import { Config } from '@/types/config';
1
+ import { Config } from '../config';
2
2
  export declare const images: {
3
3
  [key: string]: HTMLImageElement;
4
4
  };
package/lib/vm/vm.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ActionContext } from 'vuex';
2
2
  import { State } from 'vue';
3
3
  import { DialogChoice } from '@/types/vuex';
4
4
  import { CommandPlugin } from './commands/command-plugin';
5
- import { NarratPluginObject } from '@/types/narrat';
5
+ import { NarratPluginObject } from '@/exports/plugins';
6
6
  export declare function runLine(context: ActionContext<State, State>): Promise<void>;
7
7
  export declare class VM {
8
8
  plugins: NarratPluginObject[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "narrat",
3
- "version": "0.11.0",
3
+ "version": "0.11.3",
4
4
  "description": "narrat narrative engine",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",