@novely/solid-renderer 0.21.0 → 0.22.1
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.
- package/dist/components/Character.d.ts +2 -2
- package/dist/components/Root.d.ts +21 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/context/index.d.ts +11 -12
- package/dist/context-state.d.ts +2 -0
- package/dist/index.jsx +1094 -973
- package/dist/renderer.d.ts +20 -4
- package/dist/screens/game.d.ts +4 -6
- package/dist/screens/settings.d.ts +0 -1
- package/dist/shared.d.ts +3 -1
- package/dist/store.d.ts +2 -3
- package/dist/styles/index.css +2 -4
- package/dist/types.d.ts +6 -146
- package/dist/utils.d.ts +1 -11
- package/package.json +2 -3
package/dist/renderer.d.ts
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RendererInit, Context } from '@novely/core';
|
|
2
2
|
import type { StateScreen, StateScreens, StateMainmenuItem, SolidRendererStore, CreateSolidRendererOptions, EmitterEventsMap } from './types';
|
|
3
|
-
import { Howl } from '
|
|
4
|
-
declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGoingBack,
|
|
3
|
+
import { Howl } from '@novely/renderer-toolkit';
|
|
4
|
+
declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGoingBack, target, }?: CreateSolidRendererOptions) => {
|
|
5
5
|
emitter: import("./emitter").Emitter<EmitterEventsMap>;
|
|
6
|
-
renderer(
|
|
6
|
+
renderer(options: RendererInit): {
|
|
7
|
+
getContext: (key: string) => Context;
|
|
8
|
+
removeContext(name: string): void;
|
|
9
|
+
ui: {
|
|
10
|
+
showScreen(name: import("@novely/core").NovelyScreen): void;
|
|
11
|
+
getScreen(): import("@novely/core").NovelyScreen;
|
|
12
|
+
showExitPrompt(): void;
|
|
13
|
+
start: () => {
|
|
14
|
+
unmount: () => void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
misc: {
|
|
18
|
+
preloadImage: <T extends string>(image: T) => T;
|
|
19
|
+
preloadImageBlocking: (image: string) => Promise<any>;
|
|
20
|
+
preloadAudioBlocking: (source: string) => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
7
23
|
registerScreen(name: string, screen: StateScreen): void;
|
|
8
24
|
registerMainmenuItem(fn: StateMainmenuItem): void;
|
|
9
25
|
};
|
package/dist/screens/game.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from '@novely/core';
|
|
2
2
|
import type { VoidComponent } from 'solid-js';
|
|
3
|
-
import type { SetStoreFunction } from 'solid-js/store';
|
|
4
3
|
import type { SolidRendererStore } from '../renderer';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ContextStateStore, DeepMapStore } from '@novely/renderer-toolkit';
|
|
6
5
|
interface GameProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
context: ReturnType<Renderer['getContext']>;
|
|
6
|
+
context: Context;
|
|
7
|
+
$contextState: DeepMapStore<ContextStateStore>;
|
|
10
8
|
store: SolidRendererStore;
|
|
11
9
|
controls: 'inside' | 'outside';
|
|
12
10
|
skipTypewriterWhenGoingBack: boolean;
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { SolidRendererStore } from './types';
|
|
1
2
|
declare const PRELOADED_IMAGE_MAP: Map<string, HTMLImageElement>;
|
|
2
|
-
|
|
3
|
+
declare const useShared: (id: string) => SolidRendererStore, removeShared: (id: string) => void;
|
|
4
|
+
export { PRELOADED_IMAGE_MAP, useShared, removeShared };
|
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AtContextState
|
|
1
|
+
import type { AtContextState } from './types';
|
|
2
2
|
import type { SetStoreFunction } from 'solid-js/store';
|
|
3
3
|
declare const createContextState: () => {
|
|
4
4
|
state: AtContextState;
|
|
@@ -9,5 +9,4 @@ declare const useContextState: (name: string) => {
|
|
|
9
9
|
setState: SetStoreFunction<AtContextState>;
|
|
10
10
|
remove: () => void;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
export { createContextState, createGlobalState, useContextState };
|
|
12
|
+
export { createContextState, useContextState };
|
package/dist/styles/index.css
CHANGED
|
@@ -766,7 +766,7 @@
|
|
|
766
766
|
border-radius: var(--novely-saves-list-border-radius, .875rem);
|
|
767
767
|
background-color: var(--novely-saves-list-background-color, #ffffff57);
|
|
768
768
|
grid-template-columns: repeat(auto-fit, minmax(22vmin, 30%));
|
|
769
|
-
place-content: flex-start
|
|
769
|
+
place-content: flex-start space-between;
|
|
770
770
|
gap: 1rem;
|
|
771
771
|
width: 100%;
|
|
772
772
|
height: 80%;
|
|
@@ -778,9 +778,6 @@
|
|
|
778
778
|
overflow-y: scroll;
|
|
779
779
|
touch-action: auto !important;
|
|
780
780
|
}
|
|
781
|
-
.saves__list-few {
|
|
782
|
-
justify-content: flex-start;
|
|
783
|
-
}
|
|
784
781
|
.saves__list::-webkit-scrollbar {
|
|
785
782
|
width: var(--novely-saves-list-border-width, .875rem);
|
|
786
783
|
}
|
|
@@ -800,6 +797,7 @@
|
|
|
800
797
|
}
|
|
801
798
|
.saves__list--empty {
|
|
802
799
|
color: var(--novely-saves-list-empty-color, black);
|
|
800
|
+
justify-content: center;
|
|
803
801
|
align-items: center;
|
|
804
802
|
display: flex;
|
|
805
803
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,108 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ValidAction, CustomHandler, CustomHandlerGetResult, CharacterHandle, NovelyScreen, Context } from '@novely/core';
|
|
1
|
+
import type { CharacterHandle, NovelyScreen } from '@novely/core';
|
|
3
2
|
import type { JSX } from 'solid-js';
|
|
4
3
|
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: ReturnType<typeof setTimeout>;
|
|
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[], 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
4
|
type StateScreen = () => {
|
|
107
5
|
mount(): Element | JSX.Element;
|
|
108
6
|
unmount?(): void;
|
|
@@ -111,46 +9,8 @@ type StateScreens = Record<string, StateScreen>;
|
|
|
111
9
|
type PossibleScreen = NovelyScreen | (string & Record<never, never>);
|
|
112
10
|
type StateMainmenuItem = (goto: (name: PossibleScreen) => void) => JSX.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
113
11
|
type StateMainmenuItems = StateMainmenuItem[];
|
|
114
|
-
type StateMeta = {
|
|
115
|
-
restoring: boolean;
|
|
116
|
-
preview: boolean;
|
|
117
|
-
goingBack: boolean;
|
|
118
|
-
};
|
|
119
|
-
type AtContextState = {
|
|
120
|
-
disposeBackground: undefined | (() => void);
|
|
121
|
-
/**
|
|
122
|
-
* Background that should be rendered
|
|
123
|
-
*/
|
|
124
|
-
background: string;
|
|
125
|
-
characters: Record<string, StateCharacter>;
|
|
126
|
-
dialog: StateDialog;
|
|
127
|
-
choices: StateChoices;
|
|
128
|
-
input: StateInput;
|
|
129
|
-
layers: StateLayers;
|
|
130
|
-
text: StateText;
|
|
131
|
-
meta: StateMeta;
|
|
132
|
-
store: SolidRendererStore;
|
|
133
|
-
};
|
|
134
|
-
type GlobalState = {
|
|
135
|
-
screens: StateScreens;
|
|
136
|
-
mainmenu: {
|
|
137
|
-
items: StateMainmenuItems;
|
|
138
|
-
};
|
|
139
|
-
screen: PossibleScreen;
|
|
140
|
-
exitPromptShown: boolean;
|
|
141
|
-
};
|
|
142
12
|
type SolidRendererStore = {
|
|
143
|
-
dialogRef?: HTMLParagraphElement;
|
|
144
|
-
textRef?: HTMLParagraphElement;
|
|
145
13
|
characters: Record<string, CharacterHandle>;
|
|
146
|
-
audio: {
|
|
147
|
-
music: Partial<Record<string, Howl>>;
|
|
148
|
-
sound: Partial<Record<string, Howl>>;
|
|
149
|
-
voices: Partial<Record<string, Howl>>;
|
|
150
|
-
voice?: Howl;
|
|
151
|
-
resumeList: Howl[];
|
|
152
|
-
onDocumentVisibilityChangeListener?: () => void;
|
|
153
|
-
};
|
|
154
14
|
};
|
|
155
15
|
type CreateSolidRendererOptions = {
|
|
156
16
|
/**
|
|
@@ -180,10 +40,10 @@ type CreateSolidRendererOptions = {
|
|
|
180
40
|
useNativeLanguageNames?: boolean;
|
|
181
41
|
};
|
|
182
42
|
type EmitterEventsMap = {
|
|
183
|
-
'screen:change': PossibleScreen
|
|
43
|
+
'screen:change': PossibleScreen;
|
|
184
44
|
};
|
|
185
|
-
type
|
|
186
|
-
|
|
187
|
-
|
|
45
|
+
type RendererStoreExtension = {
|
|
46
|
+
screens: Record<string, StateScreen>;
|
|
47
|
+
mainmenu: StateMainmenuItems;
|
|
188
48
|
};
|
|
189
|
-
export type { EmitterEventsMap,
|
|
49
|
+
export type { EmitterEventsMap, StateScreen, StateScreens, PossibleScreen, StateMainmenuItem, StateMainmenuItems, SolidRendererStore, CreateSolidRendererOptions, RendererStoreExtension };
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,17 +11,7 @@ declare const createImage: (src: string) => HTMLImageElement;
|
|
|
11
11
|
*/
|
|
12
12
|
declare const canvasDrawImages: (canvas: HTMLCanvasElement | undefined, ctx: CanvasRenderingContext2D | undefined, images: HTMLImageElement[]) => readonly [HTMLCanvasElement, CanvasRenderingContext2D];
|
|
13
13
|
declare const url: <T extends string>(str: T) => `url(${T})`;
|
|
14
|
-
declare const escape: (str: string) => string;
|
|
15
14
|
declare const onKey: (cb: (event: KeyboardEvent) => void, ...keys: string[]) => (e: KeyboardEvent) => void;
|
|
16
|
-
declare const toMedia: (media: 'portrait' | 'landscape' | (string & Record<never, never>)) => string;
|
|
17
15
|
declare const simple: <T extends unknown[], R>(fn: (...args: T) => R) => (...args: T) => R;
|
|
18
|
-
declare const vibrationPossible: () => boolean;
|
|
19
|
-
declare const vibrate: (pattern: VibratePattern) => void;
|
|
20
16
|
declare const getDocumentStyles: () => string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Remove all listeners
|
|
24
|
-
*/
|
|
25
|
-
dispose(): void;
|
|
26
|
-
};
|
|
27
|
-
export { isCSSImage, canvasDrawImages, url, createImage, capitalize, escape, onKey, toMedia, findLast, simple, vibrationPossible, vibrate, getDocumentStyles, useBackground };
|
|
17
|
+
export { isCSSImage, canvasDrawImages, url, createImage, capitalize, onKey, findLast, simple, getDocumentStyles, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/solid-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,15 +14,14 @@
|
|
|
14
14
|
"build": "node ./build.js && tsc"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@types/howler": "^2.2.11",
|
|
18
17
|
"esbuild": "^0.19.2",
|
|
19
18
|
"esbuild-plugin-solid": "^0.5.0",
|
|
20
19
|
"typescript": "^5.2.2"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
22
|
"@novely/core": "*",
|
|
23
|
+
"@novely/renderer-toolkit": "*",
|
|
24
24
|
"@novely/typewriter": "*",
|
|
25
|
-
"howler": "^2.2.4",
|
|
26
25
|
"retrieved": "^0.1.0",
|
|
27
26
|
"solid-js": "1.8.5"
|
|
28
27
|
},
|