@novely/solid-renderer 0.48.0 → 0.50.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.
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
interface TypewriterProps {
|
|
1
|
+
import type { VoidComponent } from 'solid-js';
|
|
2
|
+
type TypewriterProps = {
|
|
4
3
|
content: string | undefined;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ended: (prefersReducedMotion: boolean) => void;
|
|
8
|
-
attributes?: JSX.HTMLAttributes<HTMLSpanElement>;
|
|
9
|
-
}
|
|
10
|
-
interface CreateTypewriterOptions {
|
|
4
|
+
};
|
|
5
|
+
type CreateTypewriterOptions = {
|
|
11
6
|
resolve: () => void;
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
ignore: () => boolean;
|
|
8
|
+
onComplete: (prm: boolean, click: () => void) => void;
|
|
9
|
+
};
|
|
10
|
+
declare const createTypewriter: ({ ignore, onComplete, resolve }: CreateTypewriterOptions) => {
|
|
14
11
|
Typewriter: VoidComponent<TypewriterProps>;
|
|
15
|
-
|
|
16
|
-
state: import("solid-js").Accessor<"processing" | "done" | "idle">;
|
|
12
|
+
click: () => void;
|
|
17
13
|
};
|
|
18
14
|
export { createTypewriter };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const TEXT_SPEED_MAP: {
|
|
2
|
+
Slow: () => number;
|
|
3
|
+
Medium: () => number;
|
|
4
|
+
Fast: () => number;
|
|
5
|
+
Auto: () => number;
|
|
6
|
+
};
|
|
3
7
|
export { TEXT_SPEED_MAP };
|
package/dist/index.jsx
CHANGED
|
@@ -1140,7 +1140,7 @@ var SVGNamespace = {
|
|
|
1140
1140
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
1141
1141
|
};
|
|
1142
1142
|
function reconcileArrays(parentNode, a, b) {
|
|
1143
|
-
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = a[aEnd - 1].nextSibling,
|
|
1143
|
+
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = a[aEnd - 1].nextSibling, map = null;
|
|
1144
1144
|
while (aStart < aEnd || bStart < bEnd) {
|
|
1145
1145
|
if (a[aStart] === b[bStart]) {
|
|
1146
1146
|
aStart++;
|
|
@@ -1156,7 +1156,7 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
1156
1156
|
while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
|
|
1157
1157
|
} else if (bEnd === bStart) {
|
|
1158
1158
|
while (aStart < aEnd) {
|
|
1159
|
-
if (!
|
|
1159
|
+
if (!map || !map.has(a[aStart])) a[aStart].remove();
|
|
1160
1160
|
aStart++;
|
|
1161
1161
|
}
|
|
1162
1162
|
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
@@ -1165,17 +1165,17 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
1165
1165
|
parentNode.insertBefore(b[--bEnd], node);
|
|
1166
1166
|
a[aEnd] = b[bEnd];
|
|
1167
1167
|
} else {
|
|
1168
|
-
if (!
|
|
1169
|
-
|
|
1168
|
+
if (!map) {
|
|
1169
|
+
map = /* @__PURE__ */ new Map();
|
|
1170
1170
|
let i = bStart;
|
|
1171
|
-
while (i < bEnd)
|
|
1171
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
1172
1172
|
}
|
|
1173
|
-
const index =
|
|
1173
|
+
const index = map.get(a[aStart]);
|
|
1174
1174
|
if (index != null) {
|
|
1175
1175
|
if (bStart < index && index < bEnd) {
|
|
1176
1176
|
let i = aStart, sequence = 1, t;
|
|
1177
1177
|
while (++i < aEnd && i < bEnd) {
|
|
1178
|
-
if ((t =
|
|
1178
|
+
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
|
|
1179
1179
|
sequence++;
|
|
1180
1180
|
}
|
|
1181
1181
|
if (sequence > index - bStart) {
|
|
@@ -1984,7 +1984,7 @@ function validateConcurrency(concurrency) {
|
|
|
1984
1984
|
}
|
|
1985
1985
|
}
|
|
1986
1986
|
|
|
1987
|
-
// ../../node_modules/.pnpm/simple-web-audio@0.
|
|
1987
|
+
// ../../node_modules/.pnpm/simple-web-audio@0.9.0_postcss@8.5.1/node_modules/simple-web-audio/dist/index.mjs
|
|
1988
1988
|
var waitForInteraction = (() => {
|
|
1989
1989
|
const { promise, resolve } = Promise.withResolvers();
|
|
1990
1990
|
const onUserInteraction = () => {
|
|
@@ -1998,32 +1998,6 @@ var waitForInteraction = (() => {
|
|
|
1998
1998
|
return promise;
|
|
1999
1999
|
};
|
|
2000
2000
|
})();
|
|
2001
|
-
var BLUR_HANDLERS = /* @__PURE__ */ new Set();
|
|
2002
|
-
var FOCUS_HANDLERS = /* @__PURE__ */ new Set();
|
|
2003
|
-
var registerEventListeners = (listeners) => {
|
|
2004
|
-
BLUR_HANDLERS.add(listeners.blur);
|
|
2005
|
-
FOCUS_HANDLERS.add(listeners.focus);
|
|
2006
|
-
return () => {
|
|
2007
|
-
BLUR_HANDLERS.delete(listeners.blur);
|
|
2008
|
-
FOCUS_HANDLERS.delete(listeners.focus);
|
|
2009
|
-
};
|
|
2010
|
-
};
|
|
2011
|
-
addEventListener("focus", function(event) {
|
|
2012
|
-
for (const handler of FOCUS_HANDLERS) {
|
|
2013
|
-
try {
|
|
2014
|
-
handler.call(this.document, event);
|
|
2015
|
-
} catch {
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
});
|
|
2019
|
-
addEventListener("blur", function(event) {
|
|
2020
|
-
for (const handler of BLUR_HANDLERS) {
|
|
2021
|
-
try {
|
|
2022
|
-
handler.call(this.document, event);
|
|
2023
|
-
} catch {
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
});
|
|
2027
2001
|
var createQueue = (queue, stopped = false) => {
|
|
2028
2002
|
const limit = pLimit(1);
|
|
2029
2003
|
const run = async () => {
|
|
@@ -2149,21 +2123,6 @@ var createAudio = (options) => {
|
|
|
2149
2123
|
setAudioData,
|
|
2150
2124
|
connectSources
|
|
2151
2125
|
]);
|
|
2152
|
-
let resume = false;
|
|
2153
|
-
const unregister = registerEventListeners({
|
|
2154
|
-
focus: () => {
|
|
2155
|
-
if (!options.pauseOnBlur || !resume || state.destroyed) return;
|
|
2156
|
-
resume = false;
|
|
2157
|
-
queue.queue.push(playAudio);
|
|
2158
|
-
queue.execute();
|
|
2159
|
-
},
|
|
2160
|
-
blur: () => {
|
|
2161
|
-
if (!options.pauseOnBlur || !state.playing || state.destroyed) return;
|
|
2162
|
-
resume = true;
|
|
2163
|
-
queue.queue.push(pauseAudio);
|
|
2164
|
-
queue.execute();
|
|
2165
|
-
}
|
|
2166
|
-
});
|
|
2167
2126
|
const state = {
|
|
2168
2127
|
started: false,
|
|
2169
2128
|
playing: false,
|
|
@@ -2237,7 +2196,6 @@ var createAudio = (options) => {
|
|
|
2237
2196
|
},
|
|
2238
2197
|
async destroy() {
|
|
2239
2198
|
if (state.destroyed) return;
|
|
2240
|
-
unregister();
|
|
2241
2199
|
queue.queue = [
|
|
2242
2200
|
pauseAudio,
|
|
2243
2201
|
disconnectAudio
|
|
@@ -2452,6 +2410,7 @@ var TYPE_META_MAP = {
|
|
|
2452
2410
|
voice: 4
|
|
2453
2411
|
};
|
|
2454
2412
|
var createAudio2 = (storageData) => {
|
|
2413
|
+
let started = false;
|
|
2455
2414
|
const store = {
|
|
2456
2415
|
music: {},
|
|
2457
2416
|
sound: {},
|
|
@@ -2466,22 +2425,35 @@ var createAudio2 = (storageData) => {
|
|
|
2466
2425
|
if (cached) return cached;
|
|
2467
2426
|
const audio = createAudio({
|
|
2468
2427
|
src,
|
|
2469
|
-
volume: getVolume(type)
|
|
2470
|
-
pauseOnBlur: true
|
|
2428
|
+
volume: getVolume(type)
|
|
2471
2429
|
});
|
|
2472
2430
|
store[kind][src] = audio;
|
|
2473
2431
|
return audio;
|
|
2474
2432
|
};
|
|
2475
|
-
|
|
2433
|
+
const cleanup = /* @__PURE__ */ new Set();
|
|
2434
|
+
let voiceCleanup = noop;
|
|
2476
2435
|
const context = {
|
|
2477
|
-
music(src, method) {
|
|
2436
|
+
music(src, paused, method) {
|
|
2478
2437
|
const resource = getAudio(method, src);
|
|
2479
2438
|
this.start();
|
|
2439
|
+
const unsubscribe = paused.subscribe((paused2) => {
|
|
2440
|
+
if (paused2) {
|
|
2441
|
+
resource.pause();
|
|
2442
|
+
} else {
|
|
2443
|
+
resource.play();
|
|
2444
|
+
}
|
|
2445
|
+
});
|
|
2446
|
+
cleanup.add(unsubscribe);
|
|
2480
2447
|
return {
|
|
2481
2448
|
pause() {
|
|
2482
2449
|
resource.pause();
|
|
2483
2450
|
},
|
|
2484
2451
|
play(loop) {
|
|
2452
|
+
if (resource.playing) {
|
|
2453
|
+
resource.volume = getVolume(method);
|
|
2454
|
+
resource.loop = loop;
|
|
2455
|
+
return;
|
|
2456
|
+
}
|
|
2485
2457
|
resource.reset().then(() => {
|
|
2486
2458
|
resource.volume = getVolume(method);
|
|
2487
2459
|
resource.loop = loop;
|
|
@@ -2493,21 +2465,31 @@ var createAudio2 = (storageData) => {
|
|
|
2493
2465
|
}
|
|
2494
2466
|
};
|
|
2495
2467
|
},
|
|
2496
|
-
voice(source) {
|
|
2468
|
+
voice(source, paused) {
|
|
2497
2469
|
this.start();
|
|
2498
2470
|
this.voiceStop();
|
|
2499
2471
|
const resource = store.voice = getAudio("voice", source);
|
|
2500
2472
|
resource.volume = getVolume("voice");
|
|
2501
2473
|
resource.play();
|
|
2474
|
+
voiceCleanup = paused.subscribe((paused2) => {
|
|
2475
|
+
if (paused2) {
|
|
2476
|
+
resource.pause();
|
|
2477
|
+
} else {
|
|
2478
|
+
resource.play();
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2502
2481
|
},
|
|
2503
2482
|
voiceStop() {
|
|
2504
2483
|
if (!store.voice) return;
|
|
2505
2484
|
store.voice.stop();
|
|
2485
|
+
voiceCleanup();
|
|
2506
2486
|
store.voice = void 0;
|
|
2487
|
+
voiceCleanup = noop;
|
|
2507
2488
|
},
|
|
2508
2489
|
start() {
|
|
2509
|
-
if (
|
|
2510
|
-
|
|
2490
|
+
if (started) return;
|
|
2491
|
+
started = true;
|
|
2492
|
+
const unsubscribe = storageData.subscribe(() => {
|
|
2511
2493
|
for (const type of ["music", "sound", "voice"]) {
|
|
2512
2494
|
const volume = getVolume(type);
|
|
2513
2495
|
if (type === "music" || type === "sound") {
|
|
@@ -2521,19 +2503,21 @@ var createAudio2 = (storageData) => {
|
|
|
2521
2503
|
}
|
|
2522
2504
|
}
|
|
2523
2505
|
});
|
|
2506
|
+
cleanup.add(unsubscribe);
|
|
2524
2507
|
},
|
|
2525
2508
|
clear() {
|
|
2526
2509
|
const musics = Object.values(store.music);
|
|
2527
2510
|
const sounds = Object.values(store.sound);
|
|
2528
2511
|
for (const music of [...musics, ...sounds]) {
|
|
2529
|
-
music
|
|
2512
|
+
if (!music) continue;
|
|
2513
|
+
music.stop();
|
|
2530
2514
|
}
|
|
2531
2515
|
this.voiceStop();
|
|
2532
2516
|
},
|
|
2533
2517
|
destroy() {
|
|
2534
|
-
|
|
2518
|
+
cleanup.forEach((fn) => fn());
|
|
2535
2519
|
this.clear();
|
|
2536
|
-
|
|
2520
|
+
started = false;
|
|
2537
2521
|
}
|
|
2538
2522
|
};
|
|
2539
2523
|
const clear = (keepAudio) => {
|
|
@@ -3732,186 +3716,238 @@ var Save = (props) => {
|
|
|
3732
3716
|
};
|
|
3733
3717
|
delegateEvents(["click", "keydown", "keyup"]);
|
|
3734
3718
|
|
|
3735
|
-
//
|
|
3736
|
-
var
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
el.childNodes.forEach((child) => {
|
|
3742
|
-
if (child.nodeName === "#text") items.push(child);
|
|
3743
|
-
else items.push(...collectTextNodes(child));
|
|
3744
|
-
});
|
|
3745
|
-
return items;
|
|
3719
|
+
// src/constants.ts
|
|
3720
|
+
var TEXT_SPEED_MAP = {
|
|
3721
|
+
Slow: () => 450,
|
|
3722
|
+
Medium: () => 300,
|
|
3723
|
+
Fast: () => 150,
|
|
3724
|
+
Auto: () => Math.random() * (450 - 150) + 150
|
|
3746
3725
|
};
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3726
|
+
|
|
3727
|
+
// src/components/Typewriter.tsx
|
|
3728
|
+
var _tmpl$8 = /* @__PURE__ */ template(`<span>`);
|
|
3729
|
+
var PRM = matchMedia("(prefers-reduced-motion: reduce)");
|
|
3730
|
+
var createRandomId = /* @__PURE__ */ (() => {
|
|
3731
|
+
let i = 0;
|
|
3732
|
+
return () => {
|
|
3733
|
+
return "nrid" + i++ + Math.random().toString(26).slice(2);
|
|
3734
|
+
};
|
|
3735
|
+
})();
|
|
3736
|
+
var Writer = class Writer2 {
|
|
3737
|
+
constructor(node, input, getDuration, endedCallback) {
|
|
3738
|
+
this.completed = false;
|
|
3739
|
+
this.input = input;
|
|
3740
|
+
this.current = 0;
|
|
3741
|
+
this.animation = null;
|
|
3742
|
+
this.endedCallback = endedCallback;
|
|
3743
|
+
this.getDuration = getDuration;
|
|
3744
|
+
this.node = node;
|
|
3745
|
+
this.node.innerHTML = input;
|
|
3746
|
+
this.segments = [];
|
|
3747
|
+
if (input === "") {
|
|
3748
|
+
this.completed = true;
|
|
3749
|
+
this.endedCallback();
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
if (PRM.matches) {
|
|
3753
|
+
this.completed = true;
|
|
3754
|
+
this.endedCallback();
|
|
3755
|
+
return;
|
|
3753
3756
|
}
|
|
3757
|
+
this.searchNodeForSegments(this.node);
|
|
3758
|
+
this.breakSegments();
|
|
3754
3759
|
}
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
const nodes = collectTextNodes(node).map((child) => {
|
|
3760
|
-
const letters = map(child.textContent, (char, prev) => {
|
|
3761
|
-
if (char === " " && prev) {
|
|
3762
|
-
prev.textContent += " ";
|
|
3763
|
-
return void 0;
|
|
3760
|
+
searchNodeForSegments(node) {
|
|
3761
|
+
for (const child of Array.from(node.childNodes)) {
|
|
3762
|
+
if (child.nodeName === "#text") {
|
|
3763
|
+
this.segments.push(child);
|
|
3764
3764
|
} else {
|
|
3765
|
-
|
|
3766
|
-
text2.textContent = char;
|
|
3767
|
-
text2.style.opacity = "0";
|
|
3768
|
-
return text2;
|
|
3765
|
+
this.searchNodeForSegments(child);
|
|
3769
3766
|
}
|
|
3770
|
-
});
|
|
3771
|
-
child.replaceWith(...letters);
|
|
3772
|
-
return letters;
|
|
3773
|
-
});
|
|
3774
|
-
let current = 0;
|
|
3775
|
-
let pos = 0;
|
|
3776
|
-
let end = false;
|
|
3777
|
-
let frame;
|
|
3778
|
-
const enqueue = () => {
|
|
3779
|
-
frame = requestAnimationFrame(queue);
|
|
3780
|
-
};
|
|
3781
|
-
const dequeue = () => {
|
|
3782
|
-
cancelAnimationFrame(frame);
|
|
3783
|
-
};
|
|
3784
|
-
let timeout = 0;
|
|
3785
|
-
let start = 0;
|
|
3786
|
-
let container;
|
|
3787
|
-
const queue = (time) => {
|
|
3788
|
-
if (time >= start + timeout) {
|
|
3789
|
-
start = time;
|
|
3790
|
-
timeout = speed();
|
|
3791
|
-
process2();
|
|
3792
|
-
} else if (end) {
|
|
3793
|
-
dequeue();
|
|
3794
|
-
} else {
|
|
3795
|
-
enqueue();
|
|
3796
3767
|
}
|
|
3797
|
-
}
|
|
3798
|
-
|
|
3799
|
-
const
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3768
|
+
}
|
|
3769
|
+
makeSegmentNode(content) {
|
|
3770
|
+
const span = document.createElement("span");
|
|
3771
|
+
span.textContent = content;
|
|
3772
|
+
span.style.opacity = "0";
|
|
3773
|
+
return span;
|
|
3774
|
+
}
|
|
3775
|
+
breakSegments() {
|
|
3776
|
+
const segments = [];
|
|
3777
|
+
for (const segment of this.segments) {
|
|
3778
|
+
if (!segment.textContent) {
|
|
3779
|
+
segments.push(segment);
|
|
3780
|
+
continue;
|
|
3808
3781
|
}
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
ended && ended();
|
|
3782
|
+
const parts = segment.textContent.split(" ").map((content, index, array) => {
|
|
3783
|
+
const end = index === array.length - 1;
|
|
3784
|
+
const string = end ? content : content + " ";
|
|
3785
|
+
return this.makeSegmentNode(string);
|
|
3786
|
+
});
|
|
3787
|
+
segment.replaceWith(...parts);
|
|
3788
|
+
segments.push(...parts);
|
|
3817
3789
|
}
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3790
|
+
this.segments = segments;
|
|
3791
|
+
}
|
|
3792
|
+
adjustDuration(content, duration) {
|
|
3793
|
+
if (content.length === 1) {
|
|
3794
|
+
return duration / 3;
|
|
3795
|
+
}
|
|
3796
|
+
if (content.length <= 3) {
|
|
3797
|
+
return duration / 2;
|
|
3798
|
+
}
|
|
3799
|
+
return duration;
|
|
3800
|
+
}
|
|
3801
|
+
createAnimation(element, duration) {
|
|
3802
|
+
const id = createRandomId();
|
|
3803
|
+
const style3 = document.createElement("style");
|
|
3804
|
+
document.head.appendChild(style3);
|
|
3805
|
+
style3.innerHTML = `@keyframes a${id} { from { opacity: 0; } to { opacity: 1; } } #${id} { animation: a${id} ${duration}ms linear; }`;
|
|
3806
|
+
element.id = id;
|
|
3807
|
+
return {
|
|
3808
|
+
remove: () => {
|
|
3809
|
+
style3.remove();
|
|
3810
|
+
},
|
|
3811
|
+
pause: () => {
|
|
3812
|
+
element.style.animationPlayState = "paused";
|
|
3813
|
+
},
|
|
3814
|
+
resume: () => {
|
|
3815
|
+
element.style.animationPlayState = "initial";
|
|
3816
|
+
},
|
|
3817
|
+
finish: () => {
|
|
3818
|
+
element.style.animationDuration = "0s";
|
|
3829
3819
|
}
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3820
|
+
};
|
|
3821
|
+
}
|
|
3822
|
+
play() {
|
|
3823
|
+
if (this.completed) return;
|
|
3824
|
+
if (this.current >= this.segments.length) {
|
|
3825
|
+
this.endedCallback();
|
|
3826
|
+
this.completed = true;
|
|
3827
|
+
}
|
|
3828
|
+
const element = this.segments[this.current];
|
|
3829
|
+
if (element instanceof HTMLSpanElement) {
|
|
3830
|
+
const duration = this.adjustDuration(element.textContent || "", this.getDuration());
|
|
3831
|
+
const animation = this.createAnimation(element, duration);
|
|
3832
|
+
element.addEventListener("animationend", () => {
|
|
3833
|
+
animation.remove();
|
|
3834
|
+
this.animation = null;
|
|
3835
|
+
element.replaceWith(document.createTextNode(element.textContent || ""));
|
|
3836
|
+
this.current++;
|
|
3837
|
+
this.play();
|
|
3838
|
+
}, {
|
|
3839
|
+
once: true
|
|
3840
|
+
});
|
|
3841
|
+
this.animation = animation;
|
|
3840
3842
|
}
|
|
3841
|
-
}
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3843
|
+
}
|
|
3844
|
+
pause() {
|
|
3845
|
+
if (this.animation) {
|
|
3846
|
+
this.animation.pause();
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
resume() {
|
|
3850
|
+
if (this.animation) {
|
|
3851
|
+
this.animation.resume();
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
complete() {
|
|
3855
|
+
if (this.completed) return;
|
|
3856
|
+
if (this.animation) {
|
|
3857
|
+
this.animation.finish();
|
|
3858
|
+
this.animation.remove();
|
|
3859
|
+
this.animation = null;
|
|
3860
|
+
}
|
|
3861
|
+
this.node.innerHTML = this.input;
|
|
3862
|
+
this.completed = true;
|
|
3863
|
+
this.endedCallback();
|
|
3864
|
+
}
|
|
3865
|
+
destroy() {
|
|
3866
|
+
if (this.animation) {
|
|
3867
|
+
this.animation.finish();
|
|
3868
|
+
this.animation.remove();
|
|
3869
|
+
this.animation = null;
|
|
3870
|
+
}
|
|
3871
|
+
this.node.innerHTML = "";
|
|
3872
|
+
}
|
|
3873
|
+
setDurationFunction(fn) {
|
|
3874
|
+
this.getDuration = fn;
|
|
3875
|
+
}
|
|
3850
3876
|
};
|
|
3851
|
-
|
|
3852
|
-
// src/components/Typewriter.tsx
|
|
3853
|
-
var _tmpl$8 = /* @__PURE__ */ template(`<span>`);
|
|
3854
|
-
var PRM = matchMedia("(prefers-reduced-motion: reduce)");
|
|
3855
3877
|
var createTypewriter = ({
|
|
3878
|
+
ignore,
|
|
3879
|
+
onComplete,
|
|
3856
3880
|
resolve
|
|
3857
3881
|
}) => {
|
|
3858
|
-
let
|
|
3859
|
-
let typewriter2;
|
|
3882
|
+
let typewriter;
|
|
3860
3883
|
const [state, setState] = createSignal("idle");
|
|
3884
|
+
const click = () => {
|
|
3885
|
+
if (!typewriter) return;
|
|
3886
|
+
if (typewriter.completed) {
|
|
3887
|
+
setState("idle");
|
|
3888
|
+
resolve();
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
typewriter.complete();
|
|
3892
|
+
setState("done");
|
|
3893
|
+
};
|
|
3861
3894
|
const Typewriter = (props) => {
|
|
3895
|
+
const data = useData();
|
|
3896
|
+
const duration = createMemo(() => data.storageData().meta[1]);
|
|
3897
|
+
const paused = createMemo(() => data.coreData().paused || !data.coreData().focused);
|
|
3898
|
+
const getDurationFunction = () => {
|
|
3899
|
+
return TEXT_SPEED_MAP[untrack(duration)];
|
|
3900
|
+
};
|
|
3862
3901
|
let node;
|
|
3863
3902
|
createEffect(() => {
|
|
3864
3903
|
const text = props.content;
|
|
3865
|
-
|
|
3904
|
+
typewriter?.destroy();
|
|
3866
3905
|
setState("idle");
|
|
3867
3906
|
if (!text) return;
|
|
3868
3907
|
if (!node) return;
|
|
3869
|
-
if (
|
|
3908
|
+
if (untrack(ignore)) {
|
|
3870
3909
|
node.innerHTML = text;
|
|
3871
|
-
bypassed = true;
|
|
3872
3910
|
setState("done");
|
|
3873
3911
|
return;
|
|
3874
3912
|
}
|
|
3875
3913
|
setState("processing");
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
untrack(() => props.ended(PRM.matches));
|
|
3882
|
-
},
|
|
3883
|
-
speed: TEXT_SPEED_MAP[untrack(() => props.speed)]
|
|
3914
|
+
typewriter = new Writer(node, text, getDurationFunction(), () => {
|
|
3915
|
+
setState("done");
|
|
3916
|
+
untrack(() => {
|
|
3917
|
+
onComplete(PRM.matches, click);
|
|
3918
|
+
});
|
|
3884
3919
|
});
|
|
3885
|
-
|
|
3920
|
+
typewriter.play();
|
|
3921
|
+
});
|
|
3922
|
+
createEffect(() => {
|
|
3923
|
+
duration();
|
|
3924
|
+
typewriter?.setDurationFunction(getDurationFunction());
|
|
3925
|
+
});
|
|
3926
|
+
createEffect(() => {
|
|
3927
|
+
paused();
|
|
3928
|
+
if (!typewriter) return;
|
|
3929
|
+
if (typewriter.completed) return;
|
|
3930
|
+
if (paused()) {
|
|
3931
|
+
typewriter.pause();
|
|
3932
|
+
} else {
|
|
3933
|
+
typewriter.resume();
|
|
3934
|
+
}
|
|
3886
3935
|
});
|
|
3887
3936
|
onCleanup(() => {
|
|
3888
3937
|
setState("idle");
|
|
3889
|
-
|
|
3890
|
-
bypassed = false;
|
|
3938
|
+
typewriter?.destroy();
|
|
3891
3939
|
});
|
|
3892
3940
|
return (() => {
|
|
3893
3941
|
var _el$ = _tmpl$8();
|
|
3894
3942
|
var _ref$ = node;
|
|
3895
3943
|
typeof _ref$ === "function" ? use(_ref$, _el$) : node = _el$;
|
|
3896
|
-
|
|
3944
|
+
createRenderEffect(() => setAttribute(_el$, "title", state() === "idle" ? void 0 : data.t(state() === "processing" ? "CompleteText" : "GoForward")));
|
|
3897
3945
|
return _el$;
|
|
3898
3946
|
})();
|
|
3899
3947
|
};
|
|
3900
|
-
const clear = () => {
|
|
3901
|
-
const reduced = PRM.matches;
|
|
3902
|
-
const written = typewriter2 && typewriter2.end();
|
|
3903
|
-
if (reduced || written || bypassed) {
|
|
3904
|
-
bypassed = false;
|
|
3905
|
-
setState("idle");
|
|
3906
|
-
resolve();
|
|
3907
|
-
} else {
|
|
3908
|
-
setState("done");
|
|
3909
|
-
}
|
|
3910
|
-
};
|
|
3911
3948
|
return {
|
|
3912
3949
|
Typewriter,
|
|
3913
|
-
|
|
3914
|
-
state
|
|
3950
|
+
click
|
|
3915
3951
|
};
|
|
3916
3952
|
};
|
|
3917
3953
|
|
|
@@ -4247,26 +4283,36 @@ var Game = (props) => {
|
|
|
4247
4283
|
const customs = () => {
|
|
4248
4284
|
return Object.values(custom());
|
|
4249
4285
|
};
|
|
4250
|
-
const
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4286
|
+
const TextWriter = createTypewriter({
|
|
4287
|
+
resolve() {
|
|
4288
|
+
text().resolve?.();
|
|
4289
|
+
},
|
|
4290
|
+
ignore: () => {
|
|
4291
|
+
return skipTypewriterWhenGoingBack && context.meta.goingBack || Boolean(props.isPreview);
|
|
4292
|
+
},
|
|
4293
|
+
onComplete: (prm, click) => {
|
|
4294
|
+
if (!auto()) return;
|
|
4255
4295
|
if (prm) {
|
|
4256
4296
|
setAuto(false);
|
|
4257
4297
|
} else {
|
|
4258
|
-
|
|
4298
|
+
click();
|
|
4259
4299
|
}
|
|
4260
|
-
};
|
|
4261
|
-
};
|
|
4262
|
-
const TextWriter = createTypewriter({
|
|
4263
|
-
resolve() {
|
|
4264
|
-
text().resolve?.();
|
|
4265
4300
|
}
|
|
4266
4301
|
});
|
|
4267
4302
|
const DialogWriter = createTypewriter({
|
|
4268
4303
|
resolve() {
|
|
4269
4304
|
dialog().resolve?.();
|
|
4305
|
+
},
|
|
4306
|
+
ignore: () => {
|
|
4307
|
+
return skipTypewriterWhenGoingBack && context.meta.goingBack || Boolean(props.isPreview);
|
|
4308
|
+
},
|
|
4309
|
+
onComplete: (prm, click) => {
|
|
4310
|
+
if (!auto()) return;
|
|
4311
|
+
if (prm) {
|
|
4312
|
+
setAuto(false);
|
|
4313
|
+
} else {
|
|
4314
|
+
click();
|
|
4315
|
+
}
|
|
4270
4316
|
}
|
|
4271
4317
|
});
|
|
4272
4318
|
const controlPanelMenuID = createUniqueId();
|
|
@@ -4329,9 +4375,9 @@ var Game = (props) => {
|
|
|
4329
4375
|
return mood();
|
|
4330
4376
|
}
|
|
4331
4377
|
}), _el$5);
|
|
4332
|
-
addEventListener2(_el$5, "keydown", onKey(DialogWriter.
|
|
4333
|
-
addEventListener2(_el$5, "keypress", onKey(DialogWriter.
|
|
4334
|
-
addEventListener2(_el$5, "click", DialogWriter.
|
|
4378
|
+
addEventListener2(_el$5, "keydown", onKey(DialogWriter.click, " "), true);
|
|
4379
|
+
addEventListener2(_el$5, "keypress", onKey(DialogWriter.click, "Enter"));
|
|
4380
|
+
addEventListener2(_el$5, "click", DialogWriter.click, true);
|
|
4335
4381
|
insert(_el$5, createComponent(Show, {
|
|
4336
4382
|
get when() {
|
|
4337
4383
|
return dialog().miniature.emotion;
|
|
@@ -4360,22 +4406,8 @@ var Game = (props) => {
|
|
|
4360
4406
|
}
|
|
4361
4407
|
}), _el$7);
|
|
4362
4408
|
insert(_el$7, createComponent(DialogWriter.Typewriter, {
|
|
4363
|
-
get attributes() {
|
|
4364
|
-
return {
|
|
4365
|
-
title: DialogWriter.state() === "idle" ? void 0 : data.t(DialogWriter.state() === "processing" ? "CompleteText" : "GoForward")
|
|
4366
|
-
};
|
|
4367
|
-
},
|
|
4368
4409
|
get content() {
|
|
4369
4410
|
return dialog().content;
|
|
4370
|
-
},
|
|
4371
|
-
get ignore() {
|
|
4372
|
-
return skipTypewriterWhenGoingBack && context.meta.goingBack || Boolean(props.isPreview);
|
|
4373
|
-
},
|
|
4374
|
-
get speed() {
|
|
4375
|
-
return speed();
|
|
4376
|
-
},
|
|
4377
|
-
get ended() {
|
|
4378
|
-
return onWriterEnd(DialogWriter.clear);
|
|
4379
4411
|
}
|
|
4380
4412
|
}));
|
|
4381
4413
|
insert(_el$, createComponent(Modal, {
|
|
@@ -4505,26 +4537,12 @@ var Game = (props) => {
|
|
|
4505
4537
|
},
|
|
4506
4538
|
children: (value) => value.node
|
|
4507
4539
|
}));
|
|
4508
|
-
addEventListener2(_el$18, "keydown", onKey(TextWriter.
|
|
4509
|
-
addEventListener2(_el$18, "keypress", onKey(TextWriter.
|
|
4510
|
-
addEventListener2(_el$18, "click", TextWriter.
|
|
4540
|
+
addEventListener2(_el$18, "keydown", onKey(TextWriter.click, " "), true);
|
|
4541
|
+
addEventListener2(_el$18, "keypress", onKey(TextWriter.click, "Enter"));
|
|
4542
|
+
addEventListener2(_el$18, "click", TextWriter.click, true);
|
|
4511
4543
|
insert(_el$18, createComponent(TextWriter.Typewriter, {
|
|
4512
|
-
get attributes() {
|
|
4513
|
-
return {
|
|
4514
|
-
title: TextWriter.state() === "idle" ? void 0 : data.t(TextWriter.state() === "processing" ? "CompleteText" : "GoForward")
|
|
4515
|
-
};
|
|
4516
|
-
},
|
|
4517
4544
|
get content() {
|
|
4518
4545
|
return text().content;
|
|
4519
|
-
},
|
|
4520
|
-
get ignore() {
|
|
4521
|
-
return skipTypewriterWhenGoingBack && context.meta.goingBack || Boolean(props.isPreview);
|
|
4522
|
-
},
|
|
4523
|
-
get speed() {
|
|
4524
|
-
return speed();
|
|
4525
|
-
},
|
|
4526
|
-
get ended() {
|
|
4527
|
-
return onWriterEnd(TextWriter.clear);
|
|
4528
4546
|
}
|
|
4529
4547
|
}));
|
|
4530
4548
|
insert(_el$, createComponent(Show, {
|
|
@@ -4918,10 +4936,7 @@ var Settings = (props) => {
|
|
|
4918
4936
|
value
|
|
4919
4937
|
}
|
|
4920
4938
|
}) => {
|
|
4921
|
-
|
|
4922
|
-
prev.meta[0] = value;
|
|
4923
|
-
return prev;
|
|
4924
|
-
});
|
|
4939
|
+
options.setLanguage(value);
|
|
4925
4940
|
};
|
|
4926
4941
|
const onSpeedSelect = ({
|
|
4927
4942
|
currentTarget: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/solid-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
"typescript": "^5.7.3"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@novely/core": ">=0.51.0",
|
|
18
19
|
"@solid-primitives/destructure": "^0.2.0",
|
|
19
20
|
"clsx": "^2.1.1",
|
|
20
21
|
"es-toolkit": "^1.31.0",
|
|
21
22
|
"solid-js": "~1.9.4",
|
|
22
23
|
"solid-transition-group": "^0.2.3",
|
|
23
|
-
"@novely/
|
|
24
|
-
"@novely/renderer-toolkit": "0.12.1",
|
|
25
|
-
"@novely/typewriter": "0.5.1"
|
|
24
|
+
"@novely/renderer-toolkit": "0.13.0"
|
|
26
25
|
},
|
|
27
26
|
"peerDependencies": {
|
|
28
27
|
"@novely/core": "*",
|