narrat 0.10.0 → 0.11.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.
@@ -0,0 +1,11 @@
1
+ import { NarratPluginObject } from '@/plugins';
2
+ export declare class NarratPlugin implements NarratPluginObject {
3
+ onPageLoaded(): void;
4
+ onNarratSetup(): void;
5
+ onAppMounted(): void;
6
+ onAssetsLoaded(): void;
7
+ onGameSetup(): void;
8
+ onGameStart(): void;
9
+ onGameMounted(): void;
10
+ onGameDismounted(): void;
11
+ }
@@ -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, };
@@ -1,4 +1,4 @@
1
- import { ParserContext } from '@/renpy/renpy-parser';
1
+ import { ParserContext } from '@/vm/vm-parser';
2
2
  import { Commit } from 'vuex';
3
3
  export declare function parserError(commit: Commit, ctx: ParserContext, line: number, text: string): void;
4
4
  export declare function error(commit: Commit, text: string): void;
@@ -1,4 +1,4 @@
1
- import { SkillCheckParams } from '@/renpy/renpy-helpers';
1
+ import { SkillCheckParams } from '@/vm/vm-helpers';
2
2
  import { SkillCheckState } from '@/types/vuex';
3
3
  import { State } from 'vue';
4
4
  import { ActionContext } from 'vuex';
@@ -0,0 +1,3 @@
1
+ import { CommandPlugin, CommandRunner } from './command-plugin';
2
+ export declare const add: CommandRunner;
3
+ export declare const addPlugin: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const addLevelPlugin: CommandPlugin;
@@ -0,0 +1,3 @@
1
+ import { CommandPlugin, CommandRunner } from './command-plugin';
2
+ export declare const addStatRunner: CommandRunner;
3
+ export declare const addStatPlugin: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const addXpPlugin: CommandPlugin;
@@ -0,0 +1,6 @@
1
+ import { State } from 'vue';
2
+ import { ActionContext } from 'vuex';
3
+ import { CommandPlugin, CommandRunner } from './command-plugin';
4
+ export declare const choice: CommandRunner;
5
+ export declare function runChoice(context: ActionContext<State, State>, cmd: Parser.Command): Promise<void>;
6
+ export declare const choicePlugin: CommandPlugin;
@@ -0,0 +1,3 @@
1
+ import { CommandPlugin, CommandRunner } from './command-plugin';
2
+ export declare const clearDialog: CommandRunner;
3
+ export declare const clearDialogPlugin: CommandPlugin;
@@ -0,0 +1,22 @@
1
+ import { DialogChoice } from '@/types/vuex';
2
+ import { State } from 'vue';
3
+ import { ActionContext } from 'vuex';
4
+ import { ParserContext } from '../vm-parser';
5
+ export declare type CommandRunner = (context: ActionContext<State, State>, cmd: Parser.Command, choices?: DialogChoice[]) => Promise<void>;
6
+ export declare type CommandParserFunction = (ctx: CommandParsingContext) => void;
7
+ export declare type ProcessCommandsFunction = (ctx: ParserContext, lines: Parser.Line[], parentLine: Parser.Line | undefined) => Parser.Branch;
8
+ export interface CommandParsingContext {
9
+ parserContext: ParserContext;
10
+ processCommandsFunction: ProcessCommandsFunction;
11
+ line: Parser.Line;
12
+ command: Partial<Parser.Command>;
13
+ lines: Parser.Line[];
14
+ currentLine: number;
15
+ }
16
+ export declare class CommandPlugin {
17
+ keyword: string;
18
+ runner: CommandRunner;
19
+ parser: CommandParserFunction;
20
+ constructor(keyword: string, runner: CommandRunner, parser: CommandParserFunction);
21
+ }
22
+ export declare function generateParser(keyword: string): (ctx: CommandParsingContext) => void;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const ifCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { VM } from '../vm';
2
+ export declare function registerBaseCommands(vm: VM): void;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const jumpCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const notifyPlugin: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const pauseCommand: CommandPlugin;
@@ -0,0 +1,3 @@
1
+ import { CommandPlugin, CommandRunner } from './command-plugin';
2
+ export declare const play: CommandRunner;
3
+ export declare const playCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const setCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const setButtonCommand: CommandPlugin;
@@ -0,0 +1,3 @@
1
+ import { CommandPlugin, CommandRunner } from './command-plugin';
2
+ export declare const setScreen: CommandRunner;
3
+ export declare const setScreenCommand: CommandPlugin;
@@ -0,0 +1,3 @@
1
+ import { CommandPlugin, CommandRunner } from './command-plugin';
2
+ export declare const setStat: CommandRunner;
3
+ export declare const setStatCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const stopCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const talkCommand: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const textCommandPlugin: CommandPlugin;
@@ -0,0 +1,2 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const waitCommand: CommandPlugin;
@@ -0,0 +1,17 @@
1
+ import { AddDialogParams } from '@/store';
2
+ import { State } from 'vue';
3
+ import { ActionContext, Commit } from 'vuex';
4
+ export declare function processSkillCheck(ctx: ActionContext<State, State>, skillcheck: Parser.SkillCheckOptions): boolean;
5
+ export interface SkillCheckParams {
6
+ skill: string;
7
+ value: number;
8
+ id: string;
9
+ success?: string;
10
+ failure?: string;
11
+ }
12
+ export declare function runSkillCheck(ctx: ActionContext<State, State>, params: SkillCheckParams): boolean;
13
+ export declare function runConditionCommand(ctx: ActionContext<State, State>, command: Parser.Command): Parser.Branch | undefined;
14
+ export declare function writeText(ctx: ActionContext<State, State>, text: string): void;
15
+ export declare function runCondition(ctx: ActionContext<State, State>, condition: string): boolean;
16
+ export declare function textCommand(commit: Commit, dialog: AddDialogParams): Promise<void>;
17
+ export declare function getLine(lines: Parser.Line[], index: number): Parser.Line;
@@ -0,0 +1,9 @@
1
+ import { ProcessCommandsFunction } from './commands/command-plugin';
2
+ export declare type ParserErrorHandler = (ctx: ParserContext, line: number, text: string) => void;
3
+ export interface ParserContext {
4
+ fileName: string;
5
+ error: (line: number, text: string) => void;
6
+ processCommandsFunction: ProcessCommandsFunction;
7
+ indentSize: number;
8
+ }
9
+ export declare function parseScript(errorHandler: ParserErrorHandler, code: string, fileName: string): Parser.ParsedScript;
package/lib/vm/vm.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { ActionContext } from 'vuex';
2
+ import { State } from 'vue';
3
+ import { DialogChoice } from '@/types/vuex';
4
+ import { CommandPlugin } from './commands/command-plugin';
5
+ import { NarratPluginObject } from '@/plugins';
6
+ export declare function runLine(context: ActionContext<State, State>): Promise<void>;
7
+ export declare class VM {
8
+ plugins: NarratPluginObject[];
9
+ commands: {
10
+ [key: string]: CommandPlugin;
11
+ };
12
+ addCommand(command: CommandPlugin): void;
13
+ addPlugin(plugin: NarratPluginObject): void;
14
+ callHook(hookName: string, ...args: any[]): void;
15
+ }
16
+ export declare const vm: VM;
17
+ export declare function runCommand(context: ActionContext<State, State>, cmd: Parser.Command, choices?: DialogChoice[]): Promise<void>;
18
+ export declare function playerAnswered(context: ActionContext<State, State>, choiceIndex: number): Promise<void>;
19
+ export declare function nextLine(ctx: ActionContext<State, State>): Promise<any>;
20
+ export declare function finishGame({ commit, state }: ActionContext<State, State>): void;
package/package.json CHANGED
@@ -1,85 +1,85 @@
1
- {
2
- "name": "narrat",
3
- "version": "0.10.0",
4
- "description": "narrat narrative engine",
5
- "main": "lib/index.js",
6
- "module": "lib/index.esm.js",
7
- "files": [
8
- "lib/"
9
- ],
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1",
12
- "start": "snowpack dev",
13
- "version": "npm run build",
14
- "build": "cross-env NODE_ENV=production rollup -c",
15
- "build-demo": "snowpack build",
16
- "lint": "eslint src --ext=.js,.jsx,.ts,.tsx",
17
- "preversion": "npm run build && npm run lint",
18
- "postversion": "git push && git push --tags"
19
- },
20
- "keywords": [
21
- "game"
22
- ],
23
- "author": "Liana Pigeot <liana.pigeot@protonmail.com>",
24
- "license": "MIT",
25
- "devDependencies": {
26
- "@babel/core": "^7.12.10",
27
- "@babel/preset-env": "^7.12.11",
28
- "@rollup/plugin-commonjs": "^16.0.0",
29
- "@rollup/plugin-node-resolve": "^10.0.0",
30
- "@rollup/plugin-typescript": "^8.2.5",
31
- "@snowpack/plugin-postcss": "^1.4.3",
32
- "@snowpack/plugin-sass": "^1.4.0",
33
- "@snowpack/plugin-typescript": "^1.2.1",
34
- "@snowpack/plugin-vue": "^2.6.2",
35
- "@types/howler": "^2.2.3",
36
- "@typescript-eslint/eslint-plugin": "^4.28.3",
37
- "@typescript-eslint/parser": "^4.28.3",
38
- "@vue/compiler-sfc": "^3.0.4",
39
- "babel-loader": "^8.2.2",
40
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
41
- "babel-preset-vue": "^2.0.2",
42
- "cross-env": "^7.0.3",
43
- "css-loader": "^5.0.1",
44
- "es6-promise": "^4.2.8",
45
- "eslint": "^7.30.0",
46
- "eslint-config-airbnb-base": "^14.2.1",
47
- "eslint-config-prettier": "^8.3.0",
48
- "eslint-config-standard": "^16.0.3",
49
- "eslint-import-resolver-typescript": "^2.4.0",
50
- "eslint-plugin-import": "^2.23.4",
51
- "eslint-plugin-node": "^11.1.0",
52
- "eslint-plugin-promise": "^5.1.0",
53
- "eslint-plugin-vue": "^7.13.0",
54
- "postcss": "^8.2.1",
55
- "postcss-cli": "^8.3.1",
56
- "prettier": "2.3.2",
57
- "rollup": "^2.35.1",
58
- "rollup-plugin-analyzer": "^4.0.0",
59
- "rollup-plugin-inject-process-env": "^1.3.1",
60
- "rollup-plugin-paths": "^0.0.4",
61
- "rollup-plugin-peer-deps-external": "^2.2.4",
62
- "rollup-plugin-postcss": "^4.0.0",
63
- "rollup-plugin-typescript2": "^0.30.0",
64
- "rollup-plugin-version-injector": "^1.3.0",
65
- "rollup-plugin-vue": "^6.0.0-beta.11",
66
- "snowpack": "^3.8.6",
67
- "tailwindcss": "^2.0.2",
68
- "typescript": "^4.2.3",
69
- "vue": "^3.2.2",
70
- "vuex": "^4.0.0-rc.2"
71
- },
72
- "peerDependencies": {
73
- "es6-promise": "^4.2.8",
74
- "vue": "^3.0.4",
75
- "vuex": "^4.0.0-rc.2"
76
- },
77
- "dependencies": {
78
- "autoprefixer": "^10.2.6",
79
- "deepmerge": "^4.2.2",
80
- "fuse.js": "^6.6.2",
81
- "howler": "^2.2.3",
82
- "svelte-jsoneditor": "^0.3.58",
83
- "vue3-mq": "^3.0.0"
84
- }
85
- }
1
+ {
2
+ "name": "narrat",
3
+ "version": "0.11.2",
4
+ "description": "narrat narrative engine",
5
+ "main": "lib/index.js",
6
+ "module": "lib/index.esm.js",
7
+ "files": [
8
+ "lib/"
9
+ ],
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "start": "snowpack dev",
13
+ "version": "npm run build",
14
+ "build": "cross-env NODE_ENV=production rollup -c",
15
+ "build-demo": "snowpack build",
16
+ "lint": "eslint src --ext=.js,.jsx,.ts,.tsx",
17
+ "preversion": "npm run build && npm run lint",
18
+ "postversion": "git push && git push --tags"
19
+ },
20
+ "keywords": [
21
+ "game"
22
+ ],
23
+ "author": "Liana Pigeot <liana.pigeot@protonmail.com>",
24
+ "license": "MIT",
25
+ "devDependencies": {
26
+ "@babel/core": "^7.12.10",
27
+ "@babel/preset-env": "^7.12.11",
28
+ "@rollup/plugin-commonjs": "^16.0.0",
29
+ "@rollup/plugin-node-resolve": "^10.0.0",
30
+ "@rollup/plugin-typescript": "^8.2.5",
31
+ "@snowpack/plugin-postcss": "^1.4.3",
32
+ "@snowpack/plugin-sass": "^1.4.0",
33
+ "@snowpack/plugin-typescript": "^1.2.1",
34
+ "@snowpack/plugin-vue": "^2.6.2",
35
+ "@types/howler": "^2.2.3",
36
+ "@typescript-eslint/eslint-plugin": "^4.28.3",
37
+ "@typescript-eslint/parser": "^4.28.3",
38
+ "@vue/compiler-sfc": "^3.0.4",
39
+ "babel-loader": "^8.2.2",
40
+ "babel-plugin-syntax-dynamic-import": "^6.18.0",
41
+ "babel-preset-vue": "^2.0.2",
42
+ "cross-env": "^7.0.3",
43
+ "css-loader": "^5.0.1",
44
+ "es6-promise": "^4.2.8",
45
+ "eslint": "^7.30.0",
46
+ "eslint-config-airbnb-base": "^14.2.1",
47
+ "eslint-config-prettier": "^8.3.0",
48
+ "eslint-config-standard": "^16.0.3",
49
+ "eslint-import-resolver-typescript": "^2.4.0",
50
+ "eslint-plugin-import": "^2.23.4",
51
+ "eslint-plugin-node": "^11.1.0",
52
+ "eslint-plugin-promise": "^5.1.0",
53
+ "eslint-plugin-vue": "^7.13.0",
54
+ "postcss": "^8.2.1",
55
+ "postcss-cli": "^8.3.1",
56
+ "prettier": "2.3.2",
57
+ "rollup": "^2.35.1",
58
+ "rollup-plugin-analyzer": "^4.0.0",
59
+ "rollup-plugin-inject-process-env": "^1.3.1",
60
+ "rollup-plugin-paths": "^0.0.4",
61
+ "rollup-plugin-peer-deps-external": "^2.2.4",
62
+ "rollup-plugin-postcss": "^4.0.0",
63
+ "rollup-plugin-typescript2": "^0.30.0",
64
+ "rollup-plugin-version-injector": "^1.3.0",
65
+ "rollup-plugin-vue": "^6.0.0-beta.11",
66
+ "snowpack": "^3.8.6",
67
+ "tailwindcss": "^2.0.2",
68
+ "typescript": "^4.2.3",
69
+ "vue": "^3.2.2",
70
+ "vuex": "^4.0.0-rc.2"
71
+ },
72
+ "peerDependencies": {
73
+ "es6-promise": "^4.2.8",
74
+ "vue": "^3.0.4",
75
+ "vuex": "^4.0.0-rc.2"
76
+ },
77
+ "dependencies": {
78
+ "autoprefixer": "^10.2.6",
79
+ "deepmerge": "^4.2.2",
80
+ "fuse.js": "^6.6.2",
81
+ "howler": "^2.2.3",
82
+ "svelte-jsoneditor": "^0.3.58",
83
+ "vue3-mq": "^3.0.0"
84
+ }
85
+ }