@kawaijs/renderer-dom 0.1.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.
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/renderer.d.ts +34 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +304 -0
- package/dist/renderer.js.map +1 -0
- package/package.json +42 -0
- package/src/theme.css +306 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './renderer.js';
|
|
2
|
+
import type { StoryPackage } from '@kawaijs/ast';
|
|
3
|
+
import { StoryVM } from '@kawaijs/runtime';
|
|
4
|
+
import { DOMRenderer, type DOMRendererOptions } from './renderer.js';
|
|
5
|
+
/**
|
|
6
|
+
* High-level helper to initialize and mount a visual novel into the DOM.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mountKawaApp(story: StoryPackage, container: HTMLElement, options?: Omit<DOMRendererOptions, 'container'>): {
|
|
9
|
+
vm: StoryVM;
|
|
10
|
+
renderer: DOMRenderer;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAC9C;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,WAAW,CAAA;CAAE,CASxC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './renderer.js';
|
|
2
|
+
import { StoryVM } from '@kawaijs/runtime';
|
|
3
|
+
import { DOMRenderer } from './renderer.js';
|
|
4
|
+
/**
|
|
5
|
+
* High-level helper to initialize and mount a visual novel into the DOM.
|
|
6
|
+
*/
|
|
7
|
+
export function mountKawaApp(story, container, options) {
|
|
8
|
+
const vm = new StoryVM(story);
|
|
9
|
+
const renderer = new DOMRenderer(vm, {
|
|
10
|
+
container,
|
|
11
|
+
...options
|
|
12
|
+
});
|
|
13
|
+
vm.start();
|
|
14
|
+
return { vm, renderer };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAA2B,MAAM,eAAe,CAAC;AAErE;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAmB,EACnB,SAAsB,EACtB,OAA+C;IAE/C,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,EAAE,EAAE;QACnC,SAAS;QACT,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,EAAE,CAAC,KAAK,EAAE,CAAC;IACX,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { StoryVM } from '@kawaijs/runtime';
|
|
2
|
+
export interface DOMRendererOptions {
|
|
3
|
+
container: HTMLElement;
|
|
4
|
+
typewriterSpeed?: number;
|
|
5
|
+
assetResolver?: (path: string, type: 'background' | 'character' | 'audio') => string;
|
|
6
|
+
}
|
|
7
|
+
export declare class DOMRenderer {
|
|
8
|
+
private readonly vm;
|
|
9
|
+
private readonly container;
|
|
10
|
+
private readonly typewriterSpeed;
|
|
11
|
+
private readonly assetResolver;
|
|
12
|
+
private rootEl;
|
|
13
|
+
private backgroundEl;
|
|
14
|
+
private charactersEl;
|
|
15
|
+
private dialogueBoxEl;
|
|
16
|
+
private speakerTagEl;
|
|
17
|
+
private dialogueTextEl;
|
|
18
|
+
private choiceContainerEl;
|
|
19
|
+
private backBtnEl;
|
|
20
|
+
private currentTypewriterInterval;
|
|
21
|
+
private isTypewriting;
|
|
22
|
+
private fullCurrentText;
|
|
23
|
+
private unsubscribeVMState?;
|
|
24
|
+
constructor(vm: StoryVM, options: DOMRendererOptions);
|
|
25
|
+
destroy(): void;
|
|
26
|
+
private buildDOM;
|
|
27
|
+
private bindEvents;
|
|
28
|
+
private handleUserAdvance;
|
|
29
|
+
private render;
|
|
30
|
+
private startTypewriter;
|
|
31
|
+
private finishTypewriter;
|
|
32
|
+
private showHistoryModal;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,WAAW,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,OAAO,KAAK,MAAM,CAAC;CACtF;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuE;IAErG,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,SAAS,CAAqB;IAEtC,OAAO,CAAC,yBAAyB,CAAuB;IACxD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,kBAAkB,CAAC,CAAa;gBAE5B,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB;IAiB7C,OAAO,IAAI,IAAI;IAUtB,OAAO,CAAC,QAAQ;IAgGhB,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,MAAM;IAqFd,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAwDzB"}
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
export class DOMRenderer {
|
|
2
|
+
vm;
|
|
3
|
+
container;
|
|
4
|
+
typewriterSpeed;
|
|
5
|
+
assetResolver;
|
|
6
|
+
rootEl;
|
|
7
|
+
backgroundEl;
|
|
8
|
+
charactersEl;
|
|
9
|
+
dialogueBoxEl;
|
|
10
|
+
speakerTagEl;
|
|
11
|
+
dialogueTextEl;
|
|
12
|
+
choiceContainerEl;
|
|
13
|
+
backBtnEl;
|
|
14
|
+
currentTypewriterInterval = null;
|
|
15
|
+
isTypewriting = false;
|
|
16
|
+
fullCurrentText = '';
|
|
17
|
+
unsubscribeVMState;
|
|
18
|
+
constructor(vm, options) {
|
|
19
|
+
this.vm = vm;
|
|
20
|
+
this.container = options.container;
|
|
21
|
+
this.typewriterSpeed = options.typewriterSpeed ?? 20;
|
|
22
|
+
this.assetResolver = options.assetResolver ?? ((path) => path);
|
|
23
|
+
this.buildDOM();
|
|
24
|
+
this.bindEvents();
|
|
25
|
+
this.unsubscribeVMState = this.vm.onStateChange((state) => {
|
|
26
|
+
this.render(state);
|
|
27
|
+
});
|
|
28
|
+
// Render current initial state
|
|
29
|
+
this.render(this.vm.getState());
|
|
30
|
+
}
|
|
31
|
+
destroy() {
|
|
32
|
+
if (this.unsubscribeVMState) {
|
|
33
|
+
this.unsubscribeVMState();
|
|
34
|
+
}
|
|
35
|
+
if (this.currentTypewriterInterval) {
|
|
36
|
+
clearInterval(this.currentTypewriterInterval);
|
|
37
|
+
}
|
|
38
|
+
this.container.innerHTML = '';
|
|
39
|
+
}
|
|
40
|
+
buildDOM() {
|
|
41
|
+
this.container.innerHTML = '';
|
|
42
|
+
this.rootEl = document.createElement('div');
|
|
43
|
+
this.rootEl.className = 'kawa-root';
|
|
44
|
+
const stageEl = document.createElement('div');
|
|
45
|
+
stageEl.className = 'kawa-stage';
|
|
46
|
+
this.backgroundEl = document.createElement('div');
|
|
47
|
+
this.backgroundEl.className = 'kawa-background';
|
|
48
|
+
this.charactersEl = document.createElement('div');
|
|
49
|
+
this.charactersEl.className = 'kawa-characters';
|
|
50
|
+
const uiLayerEl = document.createElement('div');
|
|
51
|
+
uiLayerEl.className = 'kawa-ui-layer';
|
|
52
|
+
// Choice Container
|
|
53
|
+
this.choiceContainerEl = document.createElement('div');
|
|
54
|
+
this.choiceContainerEl.className = 'kawa-choice-container';
|
|
55
|
+
this.choiceContainerEl.style.display = 'none';
|
|
56
|
+
// Dialogue Box
|
|
57
|
+
this.dialogueBoxEl = document.createElement('div');
|
|
58
|
+
this.dialogueBoxEl.className = 'kawa-dialogue-box';
|
|
59
|
+
this.speakerTagEl = document.createElement('div');
|
|
60
|
+
this.speakerTagEl.className = 'kawa-speaker-tag';
|
|
61
|
+
this.dialogueTextEl = document.createElement('div');
|
|
62
|
+
this.dialogueTextEl.className = 'kawa-dialogue-text';
|
|
63
|
+
const indicatorEl = document.createElement('div');
|
|
64
|
+
indicatorEl.className = 'kawa-continue-indicator';
|
|
65
|
+
indicatorEl.innerHTML = '▼';
|
|
66
|
+
this.dialogueBoxEl.appendChild(this.speakerTagEl);
|
|
67
|
+
this.dialogueBoxEl.appendChild(this.dialogueTextEl);
|
|
68
|
+
this.dialogueBoxEl.appendChild(indicatorEl);
|
|
69
|
+
// Quick Menu
|
|
70
|
+
const quickMenuEl = document.createElement('nav');
|
|
71
|
+
quickMenuEl.className = 'kawa-quick-menu';
|
|
72
|
+
this.backBtnEl = document.createElement('button');
|
|
73
|
+
this.backBtnEl.className = 'kawa-btn';
|
|
74
|
+
this.backBtnEl.textContent = 'Back';
|
|
75
|
+
const histBtn = document.createElement('button');
|
|
76
|
+
histBtn.className = 'kawa-btn';
|
|
77
|
+
histBtn.textContent = 'History';
|
|
78
|
+
histBtn.addEventListener('click', (e) => {
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
this.showHistoryModal();
|
|
81
|
+
});
|
|
82
|
+
const saveBtn = document.createElement('button');
|
|
83
|
+
saveBtn.className = 'kawa-btn';
|
|
84
|
+
saveBtn.textContent = 'Save';
|
|
85
|
+
saveBtn.addEventListener('click', async (e) => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
await this.vm.save('1');
|
|
88
|
+
alert('Game saved to Slot 1!');
|
|
89
|
+
});
|
|
90
|
+
const loadBtn = document.createElement('button');
|
|
91
|
+
loadBtn.className = 'kawa-btn';
|
|
92
|
+
loadBtn.textContent = 'Load';
|
|
93
|
+
loadBtn.addEventListener('click', async (e) => {
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
const loaded = await this.vm.load('1');
|
|
96
|
+
if (loaded) {
|
|
97
|
+
alert('Game loaded from Slot 1!');
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
alert('No save found in Slot 1.');
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
quickMenuEl.appendChild(this.backBtnEl);
|
|
104
|
+
quickMenuEl.appendChild(histBtn);
|
|
105
|
+
quickMenuEl.appendChild(saveBtn);
|
|
106
|
+
quickMenuEl.appendChild(loadBtn);
|
|
107
|
+
uiLayerEl.appendChild(this.choiceContainerEl);
|
|
108
|
+
uiLayerEl.appendChild(this.dialogueBoxEl);
|
|
109
|
+
uiLayerEl.appendChild(quickMenuEl);
|
|
110
|
+
stageEl.appendChild(this.backgroundEl);
|
|
111
|
+
stageEl.appendChild(this.charactersEl);
|
|
112
|
+
stageEl.appendChild(uiLayerEl);
|
|
113
|
+
this.rootEl.appendChild(stageEl);
|
|
114
|
+
this.container.appendChild(this.rootEl);
|
|
115
|
+
}
|
|
116
|
+
bindEvents() {
|
|
117
|
+
// Clicking on dialogue advances or finishes typewriter
|
|
118
|
+
this.dialogueBoxEl.addEventListener('click', () => {
|
|
119
|
+
this.handleUserAdvance();
|
|
120
|
+
});
|
|
121
|
+
this.backBtnEl.addEventListener('click', (e) => {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
this.vm.rollback();
|
|
124
|
+
});
|
|
125
|
+
// Keyboard controls
|
|
126
|
+
window.addEventListener('keydown', (e) => {
|
|
127
|
+
if (e.code === 'Space' || e.code === 'Enter') {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
this.handleUserAdvance();
|
|
130
|
+
}
|
|
131
|
+
else if (e.code === 'Backspace') {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
this.vm.rollback();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
handleUserAdvance() {
|
|
138
|
+
if (this.isTypewriting) {
|
|
139
|
+
// Instantly finish text
|
|
140
|
+
this.finishTypewriter();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.vm.next();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
render(state) {
|
|
147
|
+
// Update rollback button state
|
|
148
|
+
this.backBtnEl.disabled = !this.vm.canRollback();
|
|
149
|
+
// Render background
|
|
150
|
+
if (state.visual.background) {
|
|
151
|
+
const bgUrl = this.assetResolver(state.visual.background, 'background');
|
|
152
|
+
this.backgroundEl.style.backgroundImage = `url("${bgUrl}")`;
|
|
153
|
+
this.backgroundEl.style.opacity = '1';
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this.backgroundEl.style.opacity = '0';
|
|
157
|
+
}
|
|
158
|
+
// Render character sprites
|
|
159
|
+
this.charactersEl.innerHTML = '';
|
|
160
|
+
for (const [charId, charState] of Object.entries(state.visual.characters)) {
|
|
161
|
+
const spriteDiv = document.createElement('div');
|
|
162
|
+
const posClass = `kawa-pos-${charState.position ?? 'center'}`;
|
|
163
|
+
spriteDiv.className = `kawa-sprite ${posClass}`;
|
|
164
|
+
spriteDiv.dataset.character = charId;
|
|
165
|
+
if (charState.expression) {
|
|
166
|
+
spriteDiv.dataset.expression = charState.expression;
|
|
167
|
+
}
|
|
168
|
+
const img = document.createElement('img');
|
|
169
|
+
const expr = charState.expression ? `_${charState.expression}` : '';
|
|
170
|
+
img.src = this.assetResolver(`${charId}${expr}.png`, 'character');
|
|
171
|
+
img.alt = `${charId} ${charState.expression ?? ''}`;
|
|
172
|
+
img.onerror = () => {
|
|
173
|
+
// Fallback placeholder sprite if image is missing
|
|
174
|
+
img.style.display = 'none';
|
|
175
|
+
spriteDiv.style.width = '200px';
|
|
176
|
+
spriteDiv.style.height = '400px';
|
|
177
|
+
spriteDiv.style.background = 'rgba(244, 63, 94, 0.4)';
|
|
178
|
+
spriteDiv.style.border = '2px dashed #f43f5e';
|
|
179
|
+
spriteDiv.style.borderRadius = '16px';
|
|
180
|
+
spriteDiv.style.display = 'flex';
|
|
181
|
+
spriteDiv.style.alignItems = 'center';
|
|
182
|
+
spriteDiv.style.justifyContent = 'center';
|
|
183
|
+
spriteDiv.textContent = `${charId} (${charState.expression ?? 'normal'})`;
|
|
184
|
+
};
|
|
185
|
+
spriteDiv.appendChild(img);
|
|
186
|
+
this.charactersEl.appendChild(spriteDiv);
|
|
187
|
+
}
|
|
188
|
+
// Render dialogue
|
|
189
|
+
if (state.dialogue) {
|
|
190
|
+
this.dialogueBoxEl.style.display = 'block';
|
|
191
|
+
if (state.dialogue.speakerDisplayName) {
|
|
192
|
+
this.speakerTagEl.style.display = 'inline-block';
|
|
193
|
+
this.speakerTagEl.textContent = state.dialogue.speakerDisplayName;
|
|
194
|
+
if (state.dialogue.speakerColor) {
|
|
195
|
+
this.speakerTagEl.style.backgroundColor = state.dialogue.speakerColor;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
this.speakerTagEl.style.display = 'none';
|
|
200
|
+
}
|
|
201
|
+
this.startTypewriter(state.dialogue.text);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this.dialogueBoxEl.style.display = 'none';
|
|
205
|
+
}
|
|
206
|
+
// Render choices
|
|
207
|
+
if (state.choices && state.choices.length > 0) {
|
|
208
|
+
this.choiceContainerEl.innerHTML = '';
|
|
209
|
+
this.choiceContainerEl.style.display = 'flex';
|
|
210
|
+
state.choices.forEach((choice, index) => {
|
|
211
|
+
const btn = document.createElement('button');
|
|
212
|
+
btn.className = 'kawa-choice-btn';
|
|
213
|
+
btn.textContent = choice.text;
|
|
214
|
+
btn.addEventListener('click', (e) => {
|
|
215
|
+
e.stopPropagation();
|
|
216
|
+
this.vm.choose(index);
|
|
217
|
+
});
|
|
218
|
+
this.choiceContainerEl.appendChild(btn);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.choiceContainerEl.style.display = 'none';
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
startTypewriter(text) {
|
|
226
|
+
if (this.currentTypewriterInterval) {
|
|
227
|
+
clearInterval(this.currentTypewriterInterval);
|
|
228
|
+
}
|
|
229
|
+
this.fullCurrentText = text;
|
|
230
|
+
if (this.typewriterSpeed <= 0) {
|
|
231
|
+
this.dialogueTextEl.textContent = text;
|
|
232
|
+
this.isTypewriting = false;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.isTypewriting = true;
|
|
236
|
+
let index = 0;
|
|
237
|
+
this.dialogueTextEl.textContent = '';
|
|
238
|
+
this.currentTypewriterInterval = window.setInterval(() => {
|
|
239
|
+
index += 1;
|
|
240
|
+
this.dialogueTextEl.textContent = this.fullCurrentText.slice(0, index);
|
|
241
|
+
if (index >= this.fullCurrentText.length) {
|
|
242
|
+
this.finishTypewriter();
|
|
243
|
+
}
|
|
244
|
+
}, this.typewriterSpeed);
|
|
245
|
+
}
|
|
246
|
+
finishTypewriter() {
|
|
247
|
+
if (this.currentTypewriterInterval) {
|
|
248
|
+
clearInterval(this.currentTypewriterInterval);
|
|
249
|
+
this.currentTypewriterInterval = null;
|
|
250
|
+
}
|
|
251
|
+
this.dialogueTextEl.textContent = this.fullCurrentText;
|
|
252
|
+
this.isTypewriting = false;
|
|
253
|
+
}
|
|
254
|
+
showHistoryModal() {
|
|
255
|
+
const existing = this.rootEl.querySelector('.kawa-modal-overlay');
|
|
256
|
+
if (existing)
|
|
257
|
+
existing.remove();
|
|
258
|
+
const overlay = document.createElement('div');
|
|
259
|
+
overlay.className = 'kawa-modal-overlay';
|
|
260
|
+
const card = document.createElement('div');
|
|
261
|
+
card.className = 'kawa-modal-card';
|
|
262
|
+
const header = document.createElement('div');
|
|
263
|
+
header.className = 'kawa-modal-header';
|
|
264
|
+
const title = document.createElement('div');
|
|
265
|
+
title.className = 'kawa-modal-title';
|
|
266
|
+
title.textContent = 'Dialogue History';
|
|
267
|
+
const closeBtn = document.createElement('button');
|
|
268
|
+
closeBtn.className = 'kawa-btn';
|
|
269
|
+
closeBtn.textContent = '✕ Close';
|
|
270
|
+
closeBtn.addEventListener('click', () => overlay.remove());
|
|
271
|
+
header.appendChild(title);
|
|
272
|
+
header.appendChild(closeBtn);
|
|
273
|
+
const body = document.createElement('div');
|
|
274
|
+
body.className = 'kawa-modal-body';
|
|
275
|
+
const entries = this.vm.getHistoryManager().getEntries();
|
|
276
|
+
if (entries.length === 0) {
|
|
277
|
+
const emptyMsg = document.createElement('div');
|
|
278
|
+
emptyMsg.textContent = 'No dialogue history yet.';
|
|
279
|
+
emptyMsg.style.opacity = '0.6';
|
|
280
|
+
body.appendChild(emptyMsg);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
for (const entry of entries) {
|
|
284
|
+
const item = document.createElement('div');
|
|
285
|
+
item.className = 'kawa-history-item';
|
|
286
|
+
if (entry.speakerDisplayName) {
|
|
287
|
+
const spk = document.createElement('div');
|
|
288
|
+
spk.className = 'kawa-history-speaker';
|
|
289
|
+
spk.textContent = entry.speakerDisplayName;
|
|
290
|
+
item.appendChild(spk);
|
|
291
|
+
}
|
|
292
|
+
const txt = document.createElement('div');
|
|
293
|
+
txt.textContent = entry.text;
|
|
294
|
+
item.appendChild(txt);
|
|
295
|
+
body.appendChild(item);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
card.appendChild(header);
|
|
299
|
+
card.appendChild(body);
|
|
300
|
+
overlay.appendChild(card);
|
|
301
|
+
this.rootEl.appendChild(overlay);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,WAAW;IACL,EAAE,CAAU;IACZ,SAAS,CAAc;IACvB,eAAe,CAAS;IACxB,aAAa,CAAuE;IAE7F,MAAM,CAAkB;IACxB,YAAY,CAAkB;IAC9B,YAAY,CAAkB;IAC9B,aAAa,CAAkB;IAC/B,YAAY,CAAkB;IAC9B,cAAc,CAAkB;IAChC,iBAAiB,CAAkB;IACnC,SAAS,CAAqB;IAE9B,yBAAyB,GAAkB,IAAI,CAAC;IAChD,aAAa,GAAG,K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
"version": "0.1.0",
|
|
4
|
+
"description": "Standard semantic DOM and CSS rendering engine for Kawaijs visual novels",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src/theme.css"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/biagio-scaglia/KawaiJS.git",
|
|
18
|
+
"directory": "packages/renderer-dom"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/biagio-scaglia/KawaiJS/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/biagio-scaglia/KawaiJS#readme",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"typecheck": "tsc --noEmit"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@kawaijs/ast": "^0.1.0",
|
|
30
|
+
"@kawaijs/runtime": "^0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"kawaijs",
|
|
34
|
+
"renderer",
|
|
35
|
+
"dom",
|
|
36
|
+
"css",
|
|
37
|
+
"visual-novel",
|
|
38
|
+
"renpy"
|
|
39
|
+
],
|
|
40
|
+
"author": "Biagio Scaglia",
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|
package/src/theme.css
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--kawa-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
3
|
+
--kawa-bg-color: #0b0f19;
|
|
4
|
+
--kawa-text-color: #f3f4f6;
|
|
5
|
+
--kawa-primary-accent: #f43f5e;
|
|
6
|
+
--kawa-dialogue-bg: rgba(15, 23, 42, 0.85);
|
|
7
|
+
--kawa-dialogue-border: rgba(244, 63, 94, 0.3);
|
|
8
|
+
--kawa-dialogue-radius: 12px;
|
|
9
|
+
--kawa-dialogue-padding: 24px 32px;
|
|
10
|
+
--kawa-speaker-bg: #f43f5e;
|
|
11
|
+
--kawa-speaker-color: #ffffff;
|
|
12
|
+
--kawa-speaker-radius: 6px;
|
|
13
|
+
--kawa-choice-bg: rgba(30, 41, 59, 0.9);
|
|
14
|
+
--kawa-choice-hover-bg: rgba(244, 63, 94, 0.85);
|
|
15
|
+
--kawa-choice-color: #ffffff;
|
|
16
|
+
--kawa-choice-border: 1px solid rgba(255, 255, 255, 0.15);
|
|
17
|
+
--kawa-choice-radius: 8px;
|
|
18
|
+
--kawa-choice-padding: 14px 28px;
|
|
19
|
+
--kawa-menu-btn-bg: rgba(15, 23, 42, 0.6);
|
|
20
|
+
--kawa-menu-btn-hover-bg: rgba(244, 63, 94, 0.8);
|
|
21
|
+
--kawa-stage-aspect-ratio: 16 / 9;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Base Reset & Root Container */
|
|
25
|
+
.kawa-root {
|
|
26
|
+
position: relative;
|
|
27
|
+
width: 100vw;
|
|
28
|
+
height: 100vh;
|
|
29
|
+
background-color: var(--kawa-bg-color);
|
|
30
|
+
color: var(--kawa-text-color);
|
|
31
|
+
font-family: var(--kawa-font-family);
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
user-select: none;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.kawa-root * {
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Stage & Aspect Ratio Box */
|
|
45
|
+
.kawa-stage {
|
|
46
|
+
position: relative;
|
|
47
|
+
width: 100%;
|
|
48
|
+
max-width: calc(100vh * (16 / 9));
|
|
49
|
+
aspect-ratio: var(--kawa-stage-aspect-ratio);
|
|
50
|
+
background-color: #000000;
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Background Scene Layer */
|
|
56
|
+
.kawa-background {
|
|
57
|
+
position: absolute;
|
|
58
|
+
inset: 0;
|
|
59
|
+
background-size: cover;
|
|
60
|
+
background-position: center;
|
|
61
|
+
background-repeat: no-repeat;
|
|
62
|
+
transition: opacity 0.4s ease-in-out, background-image 0.4s ease-in-out;
|
|
63
|
+
z-index: 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Characters Layer */
|
|
67
|
+
.kawa-characters {
|
|
68
|
+
position: absolute;
|
|
69
|
+
inset: 0;
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
z-index: 2;
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: flex-end;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.kawa-sprite {
|
|
77
|
+
position: absolute;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
height: 85%;
|
|
80
|
+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: flex-end;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.kawa-sprite img {
|
|
87
|
+
max-height: 100%;
|
|
88
|
+
width: auto;
|
|
89
|
+
object-fit: contain;
|
|
90
|
+
filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.kawa-sprite.kawa-pos-left {
|
|
94
|
+
left: 15%;
|
|
95
|
+
transform: translateX(-50%);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.kawa-sprite.kawa-pos-center {
|
|
99
|
+
left: 50%;
|
|
100
|
+
transform: translateX(-50%);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.kawa-sprite.kawa-pos-right {
|
|
104
|
+
left: 85%;
|
|
105
|
+
transform: translateX(-50%);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* UI Overlay Layer */
|
|
109
|
+
.kawa-ui-layer {
|
|
110
|
+
position: absolute;
|
|
111
|
+
inset: 0;
|
|
112
|
+
z-index: 10;
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
justify-content: flex-end;
|
|
116
|
+
padding: 32px 48px;
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Dialogue Box */
|
|
121
|
+
.kawa-dialogue-box {
|
|
122
|
+
position: relative;
|
|
123
|
+
width: 100%;
|
|
124
|
+
min-height: 140px;
|
|
125
|
+
background: var(--kawa-dialogue-bg);
|
|
126
|
+
backdrop-filter: blur(12px);
|
|
127
|
+
-webkit-backdrop-filter: blur(12px);
|
|
128
|
+
border: 1px solid var(--kawa-dialogue-border);
|
|
129
|
+
border-radius: var(--kawa-dialogue-radius);
|
|
130
|
+
padding: var(--kawa-dialogue-padding);
|
|
131
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
|
|
132
|
+
pointer-events: auto;
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
transition: transform 0.15s ease;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.kawa-dialogue-box:hover {
|
|
138
|
+
transform: translateY(-2px);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.kawa-speaker-tag {
|
|
142
|
+
display: inline-block;
|
|
143
|
+
font-weight: 700;
|
|
144
|
+
font-size: 1.1rem;
|
|
145
|
+
letter-spacing: 0.03em;
|
|
146
|
+
color: var(--kawa-speaker-color);
|
|
147
|
+
background-color: var(--kawa-speaker-bg);
|
|
148
|
+
padding: 4px 14px;
|
|
149
|
+
border-radius: var(--kawa-speaker-radius);
|
|
150
|
+
margin-bottom: 10px;
|
|
151
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.kawa-dialogue-text {
|
|
155
|
+
font-size: 1.15rem;
|
|
156
|
+
line-height: 1.65;
|
|
157
|
+
color: var(--kawa-text-color);
|
|
158
|
+
word-break: break-word;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.kawa-continue-indicator {
|
|
162
|
+
position: absolute;
|
|
163
|
+
right: 24px;
|
|
164
|
+
bottom: 16px;
|
|
165
|
+
font-size: 1rem;
|
|
166
|
+
color: var(--kawa-primary-accent);
|
|
167
|
+
animation: kawa-bounce 1.2s infinite ease-in-out;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@keyframes kawa-bounce {
|
|
171
|
+
0%, 100% { transform: translateY(0); }
|
|
172
|
+
50% { transform: translateY(4px); }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Choice Buttons Container */
|
|
176
|
+
.kawa-choice-container {
|
|
177
|
+
position: absolute;
|
|
178
|
+
top: 45%;
|
|
179
|
+
left: 50%;
|
|
180
|
+
transform: translate(-50%, -50%);
|
|
181
|
+
display: flex;
|
|
182
|
+
flex-direction: column;
|
|
183
|
+
gap: 14px;
|
|
184
|
+
width: 80%;
|
|
185
|
+
max-width: 500px;
|
|
186
|
+
pointer-events: auto;
|
|
187
|
+
z-index: 20;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.kawa-choice-btn {
|
|
191
|
+
background: var(--kawa-choice-bg);
|
|
192
|
+
backdrop-filter: blur(8px);
|
|
193
|
+
color: var(--kawa-choice-color);
|
|
194
|
+
border: var(--kawa-choice-border);
|
|
195
|
+
border-radius: var(--kawa-choice-radius);
|
|
196
|
+
padding: var(--kawa-choice-padding);
|
|
197
|
+
font-size: 1.05rem;
|
|
198
|
+
font-weight: 600;
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
201
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
202
|
+
text-align: center;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.kawa-choice-btn:hover {
|
|
206
|
+
background: var(--kawa-choice-hover-bg);
|
|
207
|
+
transform: translateY(-2px) scale(1.02);
|
|
208
|
+
box-shadow: 0 8px 20px rgba(244, 63, 94, 0.4);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.kawa-choice-btn:active {
|
|
212
|
+
transform: translateY(0) scale(0.99);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* Quick Menu Bar */
|
|
216
|
+
.kawa-quick-menu {
|
|
217
|
+
display: flex;
|
|
218
|
+
gap: 10px;
|
|
219
|
+
justify-content: flex-end;
|
|
220
|
+
margin-top: 10px;
|
|
221
|
+
pointer-events: auto;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.kawa-btn {
|
|
225
|
+
background: var(--kawa-menu-btn-bg);
|
|
226
|
+
color: #cbd5e1;
|
|
227
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
228
|
+
border-radius: 4px;
|
|
229
|
+
padding: 4px 12px;
|
|
230
|
+
font-size: 0.85rem;
|
|
231
|
+
font-weight: 500;
|
|
232
|
+
cursor: pointer;
|
|
233
|
+
transition: all 0.15s ease;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.kawa-btn:hover {
|
|
237
|
+
background: var(--kawa-menu-btn-hover-bg);
|
|
238
|
+
color: #ffffff;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.kawa-btn:disabled {
|
|
242
|
+
opacity: 0.4;
|
|
243
|
+
cursor: not-allowed;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* Modals (History, Save/Load) */
|
|
247
|
+
.kawa-modal-overlay {
|
|
248
|
+
position: absolute;
|
|
249
|
+
inset: 0;
|
|
250
|
+
background: rgba(0, 0, 0, 0.8);
|
|
251
|
+
backdrop-filter: blur(6px);
|
|
252
|
+
z-index: 100;
|
|
253
|
+
display: flex;
|
|
254
|
+
align-items: center;
|
|
255
|
+
justify-content: center;
|
|
256
|
+
pointer-events: auto;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.kawa-modal-card {
|
|
260
|
+
background: #1e293b;
|
|
261
|
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
262
|
+
border-radius: 12px;
|
|
263
|
+
width: 90%;
|
|
264
|
+
max-width: 600px;
|
|
265
|
+
max-height: 80%;
|
|
266
|
+
display: flex;
|
|
267
|
+
flex-direction: column;
|
|
268
|
+
padding: 24px;
|
|
269
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.kawa-modal-header {
|
|
273
|
+
display: flex;
|
|
274
|
+
justify-content: space-between;
|
|
275
|
+
align-items: center;
|
|
276
|
+
margin-bottom: 16px;
|
|
277
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
278
|
+
padding-bottom: 10px;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.kawa-modal-title {
|
|
282
|
+
font-size: 1.25rem;
|
|
283
|
+
font-weight: 700;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.kawa-modal-body {
|
|
287
|
+
overflow-y: auto;
|
|
288
|
+
flex: 1;
|
|
289
|
+
display: flex;
|
|
290
|
+
flex-direction: column;
|
|
291
|
+
gap: 12px;
|
|
292
|
+
padding-right: 8px;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.kawa-history-item {
|
|
296
|
+
padding: 8px 12px;
|
|
297
|
+
border-radius: 6px;
|
|
298
|
+
background: rgba(15, 23, 42, 0.6);
|
|
299
|
+
font-size: 0.95rem;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.kawa-history-speaker {
|
|
303
|
+
font-weight: 700;
|
|
304
|
+
color: var(--kawa-primary-accent);
|
|
305
|
+
margin-bottom: 2px;
|
|
306
|
+
}
|