@novely/solid-renderer 0.15.0 → 0.16.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,185 @@
1
+ /// <reference types="howler" />
2
+ import type { ValidAction, CustomHandler, CustomHandlerGetResult, CharacterHandle, NovelyScreen, Context } from '@novely/core';
3
+ import type { JSX } from 'solid-js';
4
+ import type { MountableElement } from 'solid-js/web';
5
+ interface StateCharacter {
6
+ /**
7
+ * `element.style`
8
+ */
9
+ style: string;
10
+ /**
11
+ * Показывать ли элемент
12
+ */
13
+ visible: boolean;
14
+ /**
15
+ * `id` для `setTimeout`, который отвечает за `duration` в `hideCharacter`
16
+ */
17
+ timeoutId: number;
18
+ }
19
+ interface StateDialog {
20
+ /**
21
+ * Контент диалога
22
+ */
23
+ content: string;
24
+ /**
25
+ * Мини-персонаж
26
+ */
27
+ character?: string;
28
+ /**
29
+ * Эмоция мини-персонажа
30
+ */
31
+ emotion?: string;
32
+ /**
33
+ * Должен ли диалог быть показан
34
+ */
35
+ visible: boolean;
36
+ /**
37
+ * Имя персонажа
38
+ */
39
+ name: string;
40
+ /**
41
+ * Функция `resolve`
42
+ */
43
+ resolve?: () => void;
44
+ }
45
+ interface StateChoices {
46
+ /**
47
+ * Функция `resolve`
48
+ * @param selected `index` выбранного
49
+ */
50
+ resolve?: (selected: number) => void;
51
+ /**
52
+ * Вопрос (а что выбирать)
53
+ */
54
+ question: string;
55
+ /**
56
+ * Выборы
57
+ */
58
+ choices: ([string, ValidAction[]] | [string, ValidAction[], () => boolean])[];
59
+ /**
60
+ * Должен ли отображаться диалог
61
+ */
62
+ visible: boolean;
63
+ }
64
+ interface StateInput {
65
+ /**
66
+ * Вопрос (что делает этот input)
67
+ */
68
+ question: string;
69
+ /**
70
+ * Элемент `input`
71
+ */
72
+ element?: HTMLInputElement;
73
+ /**
74
+ * Должен ли отображаться диалог с `input`
75
+ */
76
+ visible: boolean;
77
+ /**
78
+ * Функция `resolve`
79
+ */
80
+ resolve?: () => void;
81
+ /**
82
+ * Запускается для очистки результата setup
83
+ */
84
+ cleanup?: () => void;
85
+ /**
86
+ * Ошибка
87
+ */
88
+ error: string;
89
+ }
90
+ interface StateText {
91
+ /**
92
+ * Текст
93
+ */
94
+ content: string;
95
+ /**
96
+ * Функция `resolve`
97
+ */
98
+ resolve?: () => void;
99
+ }
100
+ type StateLayers = Record<string, {
101
+ value: CustomHandlerGetResult<boolean>;
102
+ fn: CustomHandler;
103
+ clear: () => void;
104
+ dom: null | HTMLDivElement;
105
+ } | undefined>;
106
+ type StateScreen = () => {
107
+ mount(): Element | JSX.Element;
108
+ unmount?(): void;
109
+ };
110
+ type StateScreens = Record<string, StateScreen>;
111
+ type PossibleScreen = NovelyScreen | (string & Record<never, never>);
112
+ type StateMainmenuItem = (goto: (name: PossibleScreen) => void) => JSX.ButtonHTMLAttributes<HTMLButtonElement>;
113
+ type StateMainmenuItems = StateMainmenuItem[];
114
+ type StateMeta = {
115
+ restoring: boolean;
116
+ preview: boolean;
117
+ goingBack: boolean;
118
+ };
119
+ type AtContextState = {
120
+ background: string;
121
+ characters: Record<string, StateCharacter>;
122
+ dialog: StateDialog;
123
+ choices: StateChoices;
124
+ input: StateInput;
125
+ layers: StateLayers;
126
+ text: StateText;
127
+ meta: StateMeta;
128
+ store: SolidRendererStore;
129
+ };
130
+ type GlobalState = {
131
+ screens: StateScreens;
132
+ mainmenu: {
133
+ items: StateMainmenuItems;
134
+ };
135
+ screen: PossibleScreen;
136
+ exitPromptShown: boolean;
137
+ };
138
+ type SolidRendererStore = {
139
+ dialogRef?: HTMLParagraphElement;
140
+ textRef?: HTMLParagraphElement;
141
+ characters: Record<string, CharacterHandle>;
142
+ audio: {
143
+ music: Partial<Record<string, Howl>>;
144
+ sound: Partial<Record<string, Howl>>;
145
+ voices: Partial<Record<string, Howl>>;
146
+ voice?: Howl;
147
+ resumeList: Howl[];
148
+ onDocumentVisibilityChangeListener?: () => void;
149
+ };
150
+ };
151
+ type CreateSolidRendererOptions = {
152
+ /**
153
+ * Enter fullscreen mode when opening a game, exit when opening main-menu
154
+ * @default false
155
+ */
156
+ fullscreen?: boolean;
157
+ /**
158
+ * Controls position
159
+ * @default "outside"
160
+ */
161
+ controls?: 'inside' | 'outside';
162
+ /**
163
+ * When `goingBack` typewriter effect won't be applied
164
+ * @default true
165
+ */
166
+ skipTypewriterWhenGoingBack?: boolean;
167
+ /**
168
+ * Where Novely will be mounted
169
+ * @default document.body
170
+ */
171
+ target?: MountableElement;
172
+ /**
173
+ * In the settings screen languages will be shown in it's own language instead of selected language
174
+ * @default true
175
+ */
176
+ useNativeLanguageNames?: boolean;
177
+ };
178
+ type EmitterEventsMap = {
179
+ 'screen:change': PossibleScreen | 'loading';
180
+ };
181
+ type SolidContext = Omit<Context, 'store' | 'setStore'> & {
182
+ store: SolidRendererStore;
183
+ setStore: (fn: (value: SolidRendererStore) => void) => void;
184
+ };
185
+ export type { EmitterEventsMap, AtContextState, GlobalState, StateCharacter, StateChoices, StateDialog, StateInput, StateText, StateLayers, StateScreen, StateScreens, PossibleScreen, StateMainmenuItem, StateMainmenuItems, SolidRendererStore, CreateSolidRendererOptions, SolidContext };
package/dist/utils.d.ts CHANGED
@@ -11,5 +11,7 @@ declare const onKey: (cb: (event: KeyboardEvent) => void, ...keys: string[]) =>
11
11
  declare const toMedia: (media: 'portrait' | 'landscape' | (string & Record<never, never>)) => string;
12
12
  declare const findLast: <T>(array: T[], fn: (item: T) => boolean) => T | undefined;
13
13
  declare const simple: <T extends unknown[], R>(fn: (...args: T) => R) => (...args: T) => R;
14
- declare const createCanVibrate: () => () => boolean;
15
- export { isCSSImage, canvasDrawImages, url, createImage, capitalize, escape, onKey, toMedia, findLast, simple, createCanVibrate, };
14
+ declare const vibrationPossible: () => boolean;
15
+ declare const vibrate: (pattern: VibratePattern) => void;
16
+ declare const getDocumentStyles: () => string;
17
+ export { isCSSImage, canvasDrawImages, url, createImage, capitalize, escape, onKey, toMedia, findLast, simple, vibrationPossible, vibrate, getDocumentStyles };
package/package.json CHANGED
@@ -1,56 +1,57 @@
1
1
  {
2
- "name": "@novely/solid-renderer",
3
- "version": "0.15.0",
4
- "type": "module",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "types": "./dist/index.d.ts",
9
- "main": "./dist/index.jsx",
10
- "module": "./dist/index.jsx",
11
- "sideEffects": false,
12
- "devDependencies": {
13
- "@types/howler": "^2.2.11",
14
- "esbuild": "^0.19.2",
15
- "esbuild-plugin-solid": "^0.5.0",
16
- "typescript": "^5.2.2"
17
- },
18
- "dependencies": {
19
- "@novely/core": "*",
20
- "@novely/typewriter": "*",
21
- "howler": "^2.2.4",
22
- "solid-js": "1.8.5"
23
- },
24
- "peerDependencies": {
25
- "@novely/core": "*",
26
- "solid-js": "*"
27
- },
28
- "license": "ISC",
29
- "bugs": {
30
- "url": "https://github.com/yhdgms1/novely/issues"
31
- },
32
- "homepage": "https://github.com/yhdgms1/novely/tree/main/packages/solid-renderer",
33
- "keywords": [
34
- "novely",
35
- "solid-js",
36
- "solid",
37
- "renderer",
38
- "novel"
39
- ],
40
- "author": {
41
- "name": "Artemiy Schukin",
42
- "url": "https://github.com/yhdgms1"
43
- },
44
- "contributors": [],
45
- "repository": {
46
- "type": "git",
47
- "url": "git+https://github.com/yhdgms1/novely.git"
48
- },
49
- "files": [
50
- "dist/*"
51
- ],
52
- "scripts": {
53
- "dev": "node ./build.js --watch",
54
- "build": "node ./build.js && tsc"
55
- }
56
- }
2
+ "name": "@novely/solid-renderer",
3
+ "version": "0.16.0",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "types": "./dist/index.d.ts",
9
+ "main": "./dist/index.jsx",
10
+ "module": "./dist/index.jsx",
11
+ "sideEffects": false,
12
+ "scripts": {
13
+ "dev": "node ./build.js --watch",
14
+ "build": "node ./build.js && tsc"
15
+ },
16
+ "devDependencies": {
17
+ "@types/howler": "^2.2.11",
18
+ "esbuild": "^0.19.2",
19
+ "esbuild-plugin-solid": "^0.5.0",
20
+ "typescript": "^5.2.2"
21
+ },
22
+ "dependencies": {
23
+ "@novely/core": "*",
24
+ "@novely/typewriter": "*",
25
+ "howler": "^2.2.4",
26
+ "retrieved": "^0.1.0",
27
+ "solid-js": "1.8.5"
28
+ },
29
+ "peerDependencies": {
30
+ "@novely/core": "*",
31
+ "solid-js": "*"
32
+ },
33
+ "license": "ISC",
34
+ "bugs": {
35
+ "url": "https://github.com/yhdgms1/novely/issues"
36
+ },
37
+ "homepage": "https://github.com/yhdgms1/novely/tree/main/packages/solid-renderer",
38
+ "keywords": [
39
+ "novely",
40
+ "solid-js",
41
+ "solid",
42
+ "renderer",
43
+ "novel"
44
+ ],
45
+ "author": {
46
+ "name": "Artemiy Schukin",
47
+ "url": "https://github.com/yhdgms1"
48
+ },
49
+ "contributors": [],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/yhdgms1/novely.git"
53
+ },
54
+ "files": [
55
+ "dist/*"
56
+ ]
57
+ }