narrat 3.4.0 → 3.5.0

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,40 @@
1
+ import { Config } from '../../config/config-output';
2
+ import { NarratPlugin } from '../NarratPlugin';
3
+ import { CommandPlugin } from '../../vm/commands/command-plugin';
4
+ export type BaseTheme = {
5
+ id: string;
6
+ extendedConfig?: Partial<Config>;
7
+ };
8
+ export type InlineTheme = BaseTheme & {
9
+ css: string;
10
+ };
11
+ export type ExternalTheme = BaseTheme & {
12
+ cssPath: string;
13
+ };
14
+ export type Theme = InlineTheme | ExternalTheme;
15
+ export interface NarratThemesPluginOptions {
16
+ defaultTheme?: string;
17
+ themes?: Theme[];
18
+ }
19
+ export type ThemeTag = HTMLLinkElement | HTMLStyleElement;
20
+ export declare class NarratThemesPlugin extends NarratPlugin {
21
+ defaultTheme?: string;
22
+ themes: Theme[];
23
+ activeTheme?: {
24
+ id: string;
25
+ themeTag: ThemeTag;
26
+ };
27
+ customCommands: CommandPlugin<any>[];
28
+ initialConfig: Config;
29
+ constructor(options?: NarratThemesPluginOptions);
30
+ onNarratSetup(): void;
31
+ addTheme(theme: Theme): void;
32
+ createChangeThemeCommand(): CommandPlugin<any>;
33
+ changeTheme(themeId: string): void;
34
+ findTheme(themeId: string): Theme;
35
+ setTheme(theme: Theme): void;
36
+ createThemeTag(theme: Theme): ThemeTag;
37
+ isInlineTheme(theme: Theme): theme is InlineTheme;
38
+ isExternalTheme(theme: Theme): theme is ExternalTheme;
39
+ removeCurrentTheme(): void;
40
+ }
@@ -0,0 +1,2 @@
1
+ import { Theme } from '../NarratThemesPlugin';
2
+ export declare const funTheme: Theme;
@@ -0,0 +1,2 @@
1
+ export * from './fun-theme';
2
+ export * from './text-only';
@@ -0,0 +1,2 @@
1
+ import { Theme } from '../NarratThemesPlugin';
2
+ export declare const textOnlyTheme: Theme;
@@ -0,0 +1,69 @@
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, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "narrat",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "narrat narrative engine",
5
5
  "main": "dist/narrat.umd.js",
6
6
  "module": "dist/narrat.es.js",