@novely/solid-renderer 0.13.0 → 0.14.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.jsx +53 -56
- package/dist/renderer.d.ts +5 -7
- package/package.json +55 -55
package/dist/index.jsx
CHANGED
|
@@ -5183,11 +5183,10 @@ var createSolidRenderer = ({
|
|
|
5183
5183
|
const store = {
|
|
5184
5184
|
characters: {},
|
|
5185
5185
|
audio: {
|
|
5186
|
-
music: {
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
voice: {}
|
|
5186
|
+
music: {},
|
|
5187
|
+
sound: {},
|
|
5188
|
+
voices: {},
|
|
5189
|
+
resumeList: []
|
|
5191
5190
|
}
|
|
5192
5191
|
};
|
|
5193
5192
|
const getVolume = (type) => {
|
|
@@ -5198,6 +5197,14 @@ var createSolidRenderer = ({
|
|
|
5198
5197
|
};
|
|
5199
5198
|
return options.$.get().meta[TYPE_META_MAP[type]];
|
|
5200
5199
|
};
|
|
5200
|
+
const getHowl = (type, src, loop) => {
|
|
5201
|
+
const kind = type === "voice" ? "voices" : type;
|
|
5202
|
+
return store.audio[kind][src] ||= new import_howler.Howl({
|
|
5203
|
+
src,
|
|
5204
|
+
volume: getVolume(type),
|
|
5205
|
+
loop
|
|
5206
|
+
});
|
|
5207
|
+
};
|
|
5201
5208
|
let characters;
|
|
5202
5209
|
let renderer;
|
|
5203
5210
|
let options;
|
|
@@ -5222,16 +5229,17 @@ var createSolidRenderer = ({
|
|
|
5222
5229
|
}
|
|
5223
5230
|
});
|
|
5224
5231
|
options.$.subscribe(() => {
|
|
5225
|
-
for (const type of ["music", "voice"]) {
|
|
5232
|
+
for (const type of ["music", "sound", "voice"]) {
|
|
5226
5233
|
const volume = getVolume(type);
|
|
5227
|
-
if (type === "music") {
|
|
5228
|
-
for (const howl of Object.values(store.audio[type]
|
|
5234
|
+
if (type === "music" || type === "sound") {
|
|
5235
|
+
for (const howl of Object.values(store.audio[type])) {
|
|
5229
5236
|
if (!howl)
|
|
5230
5237
|
continue;
|
|
5231
5238
|
howl.fade(howl.volume(), volume, 150);
|
|
5232
5239
|
}
|
|
5233
|
-
}
|
|
5234
|
-
|
|
5240
|
+
}
|
|
5241
|
+
if (type === "voice") {
|
|
5242
|
+
const howl = store.audio.voice;
|
|
5235
5243
|
if (howl) {
|
|
5236
5244
|
howl.fade(howl.volume(), volume, 150);
|
|
5237
5245
|
}
|
|
@@ -5533,78 +5541,71 @@ var createSolidRenderer = ({
|
|
|
5533
5541
|
};
|
|
5534
5542
|
},
|
|
5535
5543
|
audio: {
|
|
5536
|
-
music(
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
stop() {
|
|
5555
|
-
resource.fade(getVolume(method), 0, 300);
|
|
5556
|
-
resource.once("fade", resource.stop);
|
|
5557
|
-
}
|
|
5558
|
-
};
|
|
5559
|
-
}
|
|
5560
|
-
return null;
|
|
5544
|
+
music(src, method, loop = method === "music") {
|
|
5545
|
+
const resource = getHowl(method, src, loop);
|
|
5546
|
+
resource.loop(loop);
|
|
5547
|
+
this.start();
|
|
5548
|
+
return {
|
|
5549
|
+
pause() {
|
|
5550
|
+
resource.fade(getVolume(method), 0, 300);
|
|
5551
|
+
resource.once("fade", resource.pause);
|
|
5552
|
+
},
|
|
5553
|
+
play() {
|
|
5554
|
+
resource.play();
|
|
5555
|
+
resource.fade(0, getVolume(method), 300);
|
|
5556
|
+
},
|
|
5557
|
+
stop() {
|
|
5558
|
+
resource.fade(getVolume(method), 0, 300);
|
|
5559
|
+
resource.once("fade", resource.stop);
|
|
5560
|
+
}
|
|
5561
|
+
};
|
|
5561
5562
|
},
|
|
5562
5563
|
voice(source) {
|
|
5563
5564
|
this.start();
|
|
5564
5565
|
this.voiceStop();
|
|
5565
|
-
store.audio.voice
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
volume: getVolume("voice"),
|
|
5569
|
-
onend() {
|
|
5570
|
-
store.audio.voice.current = void 0;
|
|
5571
|
-
}
|
|
5566
|
+
const resource = store.audio.voice = getHowl("voice", source, false);
|
|
5567
|
+
resource.once("end", () => {
|
|
5568
|
+
store.audio.voice = void 0;
|
|
5572
5569
|
});
|
|
5570
|
+
resource.play();
|
|
5573
5571
|
},
|
|
5574
5572
|
voiceStop() {
|
|
5575
|
-
const currentVoice = store.audio.voice
|
|
5573
|
+
const currentVoice = store.audio.voice;
|
|
5576
5574
|
if (currentVoice) {
|
|
5577
5575
|
currentVoice.stop();
|
|
5578
|
-
store.audio.
|
|
5576
|
+
store.audio.resumeList = store.audio.resumeList.filter((howl) => howl !== currentVoice);
|
|
5579
5577
|
}
|
|
5580
5578
|
},
|
|
5581
5579
|
start() {
|
|
5582
5580
|
if (!store.audio.onDocumentVisibilityChangeListener) {
|
|
5583
5581
|
const onDocumentVisibilityChange = () => {
|
|
5584
5582
|
if (document.visibilityState === "hidden") {
|
|
5585
|
-
for (const howl of Object.values(store.audio.music
|
|
5583
|
+
for (const howl of Object.values(store.audio.music)) {
|
|
5586
5584
|
if (howl && howl.playing()) {
|
|
5587
|
-
store.audio.
|
|
5585
|
+
store.audio.resumeList.push(howl);
|
|
5588
5586
|
howl.pause();
|
|
5589
5587
|
}
|
|
5590
5588
|
}
|
|
5591
|
-
const currentVoice = store.audio.voice
|
|
5589
|
+
const currentVoice = store.audio.voice;
|
|
5592
5590
|
if (currentVoice && currentVoice.playing()) {
|
|
5593
|
-
store.audio.
|
|
5591
|
+
store.audio.resumeList.push(currentVoice);
|
|
5594
5592
|
currentVoice.pause();
|
|
5595
5593
|
}
|
|
5596
5594
|
} else {
|
|
5597
|
-
for (const howl of store.audio.
|
|
5595
|
+
for (const howl of store.audio.resumeList) {
|
|
5598
5596
|
howl.play();
|
|
5599
5597
|
}
|
|
5600
|
-
store.audio.
|
|
5598
|
+
store.audio.resumeList = [];
|
|
5601
5599
|
}
|
|
5602
5600
|
};
|
|
5603
5601
|
document.addEventListener("visibilitychange", store.audio.onDocumentVisibilityChangeListener = onDocumentVisibilityChange);
|
|
5604
5602
|
}
|
|
5605
5603
|
},
|
|
5606
5604
|
clear() {
|
|
5607
|
-
|
|
5605
|
+
const musics = Object.values(store.audio.music);
|
|
5606
|
+
const sounds = Object.values(store.audio.sound);
|
|
5607
|
+
const all = [...musics, ...sounds, store.audio.voice];
|
|
5608
|
+
for (const music of all) {
|
|
5608
5609
|
if (!music)
|
|
5609
5610
|
continue;
|
|
5610
5611
|
music.stop();
|
|
@@ -5716,11 +5717,7 @@ var createSolidRenderer = ({
|
|
|
5716
5717
|
if (getVolume(type) === 0)
|
|
5717
5718
|
return Promise.resolve();
|
|
5718
5719
|
return new Promise((resolve) => {
|
|
5719
|
-
const howl =
|
|
5720
|
-
src: source,
|
|
5721
|
-
volume: getVolume(type),
|
|
5722
|
-
loop: true
|
|
5723
|
-
});
|
|
5720
|
+
const howl = getHowl(type, source, false);
|
|
5724
5721
|
if (howl.state() === "loaded") {
|
|
5725
5722
|
resolve();
|
|
5726
5723
|
return;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -138,13 +138,11 @@ interface SolidRendererStore extends RendererStore {
|
|
|
138
138
|
dialogRef?: HTMLParagraphElement;
|
|
139
139
|
textRef?: HTMLParagraphElement;
|
|
140
140
|
audio: {
|
|
141
|
-
music:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
current?: Howl;
|
|
147
|
-
};
|
|
141
|
+
music: Partial<Record<string, Howl>>;
|
|
142
|
+
sound: Partial<Record<string, Howl>>;
|
|
143
|
+
voices: Partial<Record<string, Howl>>;
|
|
144
|
+
voice?: Howl;
|
|
145
|
+
resumeList: Howl[];
|
|
148
146
|
onDocumentVisibilityChangeListener?: () => void;
|
|
149
147
|
};
|
|
150
148
|
}
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
2
|
+
"name": "@novely/solid-renderer",
|
|
3
|
+
"version": "0.14.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
|
+
}
|