@novely/solid-renderer 0.49.0 → 0.51.0-next.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/components/Root.d.ts +1 -2
- package/dist/components/Typewriter.d.ts +9 -13
- package/dist/constants.d.ts +6 -2
- package/dist/hooks/createComputedWithMemory.d.ts +3 -0
- package/dist/hooks/previous-value.d.ts +6 -0
- package/dist/hooks/usePrevious.d.ts +3 -0
- package/dist/index.jsx +229 -200
- package/dist/renderer.d.ts +41 -2
- package/dist/screens/game.d.ts +0 -1
- package/dist/types.d.ts +0 -5
- package/package.json +2 -3
|
@@ -11,7 +11,6 @@ type CreateRootComponentOpts = {
|
|
|
11
11
|
renderer: Renderer;
|
|
12
12
|
fullscreen: boolean;
|
|
13
13
|
emitter: Emitter<EmitterEventsMap>;
|
|
14
|
-
skipTypewriterWhenGoingBack: boolean;
|
|
15
14
|
controls: 'inside' | 'outside';
|
|
16
15
|
showAudioSettings: boolean;
|
|
17
16
|
rendererContext: Context;
|
|
@@ -20,5 +19,5 @@ type CreateRootComponentOpts = {
|
|
|
20
19
|
$rendererState: DeepAtom<RendererStateStore<RendererStoreExtension>>;
|
|
21
20
|
audio: ReturnType<typeof createAudio>;
|
|
22
21
|
};
|
|
23
|
-
declare const createRootComponent: ({ $rendererState, $contextState, coreOptions, setRoot, renderer, showAudioSettings, fullscreen, emitter, controls,
|
|
22
|
+
declare const createRootComponent: ({ $rendererState, $contextState, coreOptions, setRoot, renderer, showAudioSettings, fullscreen, emitter, controls, rendererContext, audio, }: CreateRootComponentOpts) => Component;
|
|
24
23
|
export { createRootComponent };
|
|
@@ -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.9.0_postcss@8.5.
|
|
1987
|
+
// ../../node_modules/.pnpm/simple-web-audio@0.9.0_postcss@8.5.3/node_modules/simple-web-audio/dist/index.mjs
|
|
1988
1988
|
var waitForInteraction = (() => {
|
|
1989
1989
|
const { promise, resolve } = Promise.withResolvers();
|
|
1990
1990
|
const onUserInteraction = () => {
|
|
@@ -3682,7 +3682,6 @@ var Save = (props) => {
|
|
|
3682
3682
|
get children() {
|
|
3683
3683
|
return createComponent(Game, {
|
|
3684
3684
|
controls: "outside",
|
|
3685
|
-
skipTypewriterWhenGoingBack: true,
|
|
3686
3685
|
$contextState,
|
|
3687
3686
|
context,
|
|
3688
3687
|
get store() {
|
|
@@ -3716,186 +3715,238 @@ var Save = (props) => {
|
|
|
3716
3715
|
};
|
|
3717
3716
|
delegateEvents(["click", "keydown", "keyup"]);
|
|
3718
3717
|
|
|
3719
|
-
//
|
|
3720
|
-
var
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
el.childNodes.forEach((child) => {
|
|
3726
|
-
if (child.nodeName === "#text") items.push(child);
|
|
3727
|
-
else items.push(...collectTextNodes(child));
|
|
3728
|
-
});
|
|
3729
|
-
return items;
|
|
3718
|
+
// src/constants.ts
|
|
3719
|
+
var TEXT_SPEED_MAP = {
|
|
3720
|
+
Slow: () => 450,
|
|
3721
|
+
Medium: () => 300,
|
|
3722
|
+
Fast: () => 150,
|
|
3723
|
+
Auto: () => Math.random() * (450 - 150) + 150
|
|
3730
3724
|
};
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3725
|
+
|
|
3726
|
+
// src/components/Typewriter.tsx
|
|
3727
|
+
var _tmpl$8 = /* @__PURE__ */ template(`<span>`);
|
|
3728
|
+
var PRM = matchMedia("(prefers-reduced-motion: reduce)");
|
|
3729
|
+
var createRandomId = /* @__PURE__ */ (() => {
|
|
3730
|
+
let i = 0;
|
|
3731
|
+
return () => {
|
|
3732
|
+
return "nrid" + i++ + Math.random().toString(26).slice(2);
|
|
3733
|
+
};
|
|
3734
|
+
})();
|
|
3735
|
+
var Writer = class Writer2 {
|
|
3736
|
+
constructor(node, input, getDuration, endedCallback) {
|
|
3737
|
+
this.completed = false;
|
|
3738
|
+
this.input = input;
|
|
3739
|
+
this.current = 0;
|
|
3740
|
+
this.animation = null;
|
|
3741
|
+
this.endedCallback = endedCallback;
|
|
3742
|
+
this.getDuration = getDuration;
|
|
3743
|
+
this.node = node;
|
|
3744
|
+
this.node.innerHTML = input;
|
|
3745
|
+
this.segments = [];
|
|
3746
|
+
if (input === "") {
|
|
3747
|
+
this.completed = true;
|
|
3748
|
+
this.endedCallback();
|
|
3749
|
+
return;
|
|
3737
3750
|
}
|
|
3751
|
+
if (PRM.matches) {
|
|
3752
|
+
this.completed = true;
|
|
3753
|
+
this.endedCallback();
|
|
3754
|
+
return;
|
|
3755
|
+
}
|
|
3756
|
+
this.searchNodeForSegments(this.node);
|
|
3757
|
+
this.breakSegments();
|
|
3738
3758
|
}
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
const nodes = collectTextNodes(node).map((child) => {
|
|
3744
|
-
const letters = map(child.textContent, (char, prev) => {
|
|
3745
|
-
if (char === " " && prev) {
|
|
3746
|
-
prev.textContent += " ";
|
|
3747
|
-
return void 0;
|
|
3759
|
+
searchNodeForSegments(node) {
|
|
3760
|
+
for (const child of Array.from(node.childNodes)) {
|
|
3761
|
+
if (child.nodeName === "#text") {
|
|
3762
|
+
this.segments.push(child);
|
|
3748
3763
|
} else {
|
|
3749
|
-
|
|
3750
|
-
text2.textContent = char;
|
|
3751
|
-
text2.style.opacity = "0";
|
|
3752
|
-
return text2;
|
|
3764
|
+
this.searchNodeForSegments(child);
|
|
3753
3765
|
}
|
|
3754
|
-
});
|
|
3755
|
-
child.replaceWith(...letters);
|
|
3756
|
-
return letters;
|
|
3757
|
-
});
|
|
3758
|
-
let current = 0;
|
|
3759
|
-
let pos = 0;
|
|
3760
|
-
let end = false;
|
|
3761
|
-
let frame;
|
|
3762
|
-
const enqueue = () => {
|
|
3763
|
-
frame = requestAnimationFrame(queue);
|
|
3764
|
-
};
|
|
3765
|
-
const dequeue = () => {
|
|
3766
|
-
cancelAnimationFrame(frame);
|
|
3767
|
-
};
|
|
3768
|
-
let timeout = 0;
|
|
3769
|
-
let start = 0;
|
|
3770
|
-
let container;
|
|
3771
|
-
const queue = (time) => {
|
|
3772
|
-
if (time >= start + timeout) {
|
|
3773
|
-
start = time;
|
|
3774
|
-
timeout = speed();
|
|
3775
|
-
process2();
|
|
3776
|
-
} else if (end) {
|
|
3777
|
-
dequeue();
|
|
3778
|
-
} else {
|
|
3779
|
-
enqueue();
|
|
3780
3766
|
}
|
|
3781
|
-
}
|
|
3782
|
-
|
|
3783
|
-
const
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3767
|
+
}
|
|
3768
|
+
makeSegmentNode(content) {
|
|
3769
|
+
const span = document.createElement("span");
|
|
3770
|
+
span.textContent = content;
|
|
3771
|
+
span.style.opacity = "0";
|
|
3772
|
+
return span;
|
|
3773
|
+
}
|
|
3774
|
+
breakSegments() {
|
|
3775
|
+
const segments = [];
|
|
3776
|
+
for (const segment of this.segments) {
|
|
3777
|
+
if (!segment.textContent) {
|
|
3778
|
+
segments.push(segment);
|
|
3779
|
+
continue;
|
|
3792
3780
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
ended && ended();
|
|
3781
|
+
const parts = segment.textContent.split(" ").map((content, index, array) => {
|
|
3782
|
+
const end = index === array.length - 1;
|
|
3783
|
+
const string = end ? content : content + " ";
|
|
3784
|
+
return this.makeSegmentNode(string);
|
|
3785
|
+
});
|
|
3786
|
+
segment.replaceWith(...parts);
|
|
3787
|
+
segments.push(...parts);
|
|
3801
3788
|
}
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3789
|
+
this.segments = segments;
|
|
3790
|
+
}
|
|
3791
|
+
adjustDuration(content, duration) {
|
|
3792
|
+
if (content.length === 1) {
|
|
3793
|
+
return duration / 3;
|
|
3794
|
+
}
|
|
3795
|
+
if (content.length <= 3) {
|
|
3796
|
+
return duration / 2;
|
|
3797
|
+
}
|
|
3798
|
+
return duration;
|
|
3799
|
+
}
|
|
3800
|
+
createAnimation(element, duration) {
|
|
3801
|
+
const id = createRandomId();
|
|
3802
|
+
const style3 = document.createElement("style");
|
|
3803
|
+
document.head.appendChild(style3);
|
|
3804
|
+
style3.innerHTML = `@keyframes a${id} { from { opacity: 0; } to { opacity: 1; } } #${id} { animation: a${id} ${duration}ms linear; }`;
|
|
3805
|
+
element.id = id;
|
|
3806
|
+
return {
|
|
3807
|
+
remove: () => {
|
|
3808
|
+
style3.remove();
|
|
3809
|
+
},
|
|
3810
|
+
pause: () => {
|
|
3811
|
+
element.style.animationPlayState = "paused";
|
|
3812
|
+
},
|
|
3813
|
+
resume: () => {
|
|
3814
|
+
element.style.animationPlayState = "initial";
|
|
3815
|
+
},
|
|
3816
|
+
finish: () => {
|
|
3817
|
+
element.style.animationDuration = "0s";
|
|
3813
3818
|
}
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3821
|
+
play() {
|
|
3822
|
+
if (this.completed) return;
|
|
3823
|
+
if (this.current >= this.segments.length) {
|
|
3824
|
+
this.endedCallback();
|
|
3825
|
+
this.completed = true;
|
|
3826
|
+
}
|
|
3827
|
+
const element = this.segments[this.current];
|
|
3828
|
+
if (element instanceof HTMLSpanElement) {
|
|
3829
|
+
const duration = this.adjustDuration(element.textContent || "", this.getDuration());
|
|
3830
|
+
const animation = this.createAnimation(element, duration);
|
|
3831
|
+
element.addEventListener("animationend", () => {
|
|
3832
|
+
animation.remove();
|
|
3833
|
+
this.animation = null;
|
|
3834
|
+
element.replaceWith(document.createTextNode(element.textContent || ""));
|
|
3835
|
+
this.current++;
|
|
3836
|
+
this.play();
|
|
3837
|
+
}, {
|
|
3838
|
+
once: true
|
|
3839
|
+
});
|
|
3840
|
+
this.animation = animation;
|
|
3824
3841
|
}
|
|
3825
|
-
}
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3842
|
+
}
|
|
3843
|
+
pause() {
|
|
3844
|
+
if (this.animation) {
|
|
3845
|
+
this.animation.pause();
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
resume() {
|
|
3849
|
+
if (this.animation) {
|
|
3850
|
+
this.animation.resume();
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
complete() {
|
|
3854
|
+
if (this.completed) return;
|
|
3855
|
+
if (this.animation) {
|
|
3856
|
+
this.animation.finish();
|
|
3857
|
+
this.animation.remove();
|
|
3858
|
+
this.animation = null;
|
|
3859
|
+
}
|
|
3860
|
+
this.node.innerHTML = this.input;
|
|
3861
|
+
this.completed = true;
|
|
3862
|
+
this.endedCallback();
|
|
3863
|
+
}
|
|
3864
|
+
destroy() {
|
|
3865
|
+
if (this.animation) {
|
|
3866
|
+
this.animation.finish();
|
|
3867
|
+
this.animation.remove();
|
|
3868
|
+
this.animation = null;
|
|
3869
|
+
}
|
|
3870
|
+
this.node.innerHTML = "";
|
|
3871
|
+
}
|
|
3872
|
+
setDurationFunction(fn) {
|
|
3873
|
+
this.getDuration = fn;
|
|
3874
|
+
}
|
|
3834
3875
|
};
|
|
3835
|
-
|
|
3836
|
-
// src/components/Typewriter.tsx
|
|
3837
|
-
var _tmpl$8 = /* @__PURE__ */ template(`<span>`);
|
|
3838
|
-
var PRM = matchMedia("(prefers-reduced-motion: reduce)");
|
|
3839
3876
|
var createTypewriter = ({
|
|
3877
|
+
ignore,
|
|
3878
|
+
onComplete,
|
|
3840
3879
|
resolve
|
|
3841
3880
|
}) => {
|
|
3842
|
-
let
|
|
3843
|
-
let typewriter2;
|
|
3881
|
+
let typewriter;
|
|
3844
3882
|
const [state, setState] = createSignal("idle");
|
|
3883
|
+
const click = () => {
|
|
3884
|
+
if (!typewriter) return;
|
|
3885
|
+
if (typewriter.completed) {
|
|
3886
|
+
setState("idle");
|
|
3887
|
+
resolve();
|
|
3888
|
+
return;
|
|
3889
|
+
}
|
|
3890
|
+
typewriter.complete();
|
|
3891
|
+
setState("done");
|
|
3892
|
+
};
|
|
3845
3893
|
const Typewriter = (props) => {
|
|
3894
|
+
const data = useData();
|
|
3895
|
+
const duration = createMemo(() => data.storageData().meta[1]);
|
|
3896
|
+
const paused = createMemo(() => data.coreData().paused || !data.coreData().focused);
|
|
3897
|
+
const getDurationFunction = () => {
|
|
3898
|
+
return TEXT_SPEED_MAP[untrack(duration)];
|
|
3899
|
+
};
|
|
3846
3900
|
let node;
|
|
3847
3901
|
createEffect(() => {
|
|
3848
3902
|
const text = props.content;
|
|
3849
|
-
|
|
3903
|
+
typewriter?.destroy();
|
|
3850
3904
|
setState("idle");
|
|
3851
3905
|
if (!text) return;
|
|
3852
3906
|
if (!node) return;
|
|
3853
|
-
if (
|
|
3907
|
+
if (untrack(ignore)) {
|
|
3854
3908
|
node.innerHTML = text;
|
|
3855
|
-
bypassed = true;
|
|
3856
3909
|
setState("done");
|
|
3857
3910
|
return;
|
|
3858
3911
|
}
|
|
3859
3912
|
setState("processing");
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
untrack(() => props.ended(PRM.matches));
|
|
3866
|
-
},
|
|
3867
|
-
speed: TEXT_SPEED_MAP[untrack(() => props.speed)]
|
|
3913
|
+
typewriter = new Writer(node, text, getDurationFunction(), () => {
|
|
3914
|
+
setState("done");
|
|
3915
|
+
untrack(() => {
|
|
3916
|
+
onComplete(PRM.matches, click);
|
|
3917
|
+
});
|
|
3868
3918
|
});
|
|
3869
|
-
|
|
3919
|
+
typewriter.play();
|
|
3920
|
+
});
|
|
3921
|
+
createEffect(() => {
|
|
3922
|
+
duration();
|
|
3923
|
+
typewriter?.setDurationFunction(getDurationFunction());
|
|
3924
|
+
});
|
|
3925
|
+
createEffect(() => {
|
|
3926
|
+
paused();
|
|
3927
|
+
if (!typewriter) return;
|
|
3928
|
+
if (typewriter.completed) return;
|
|
3929
|
+
if (paused()) {
|
|
3930
|
+
typewriter.pause();
|
|
3931
|
+
} else {
|
|
3932
|
+
typewriter.resume();
|
|
3933
|
+
}
|
|
3870
3934
|
});
|
|
3871
3935
|
onCleanup(() => {
|
|
3872
3936
|
setState("idle");
|
|
3873
|
-
|
|
3874
|
-
bypassed = false;
|
|
3937
|
+
typewriter?.destroy();
|
|
3875
3938
|
});
|
|
3876
3939
|
return (() => {
|
|
3877
3940
|
var _el$ = _tmpl$8();
|
|
3878
3941
|
var _ref$ = node;
|
|
3879
3942
|
typeof _ref$ === "function" ? use(_ref$, _el$) : node = _el$;
|
|
3880
|
-
|
|
3943
|
+
createRenderEffect(() => setAttribute(_el$, "title", state() === "idle" ? void 0 : data.t(state() === "processing" ? "CompleteText" : "GoForward")));
|
|
3881
3944
|
return _el$;
|
|
3882
3945
|
})();
|
|
3883
3946
|
};
|
|
3884
|
-
const clear = () => {
|
|
3885
|
-
const reduced = PRM.matches;
|
|
3886
|
-
const written = typewriter2 && typewriter2.end();
|
|
3887
|
-
if (reduced || written || bypassed) {
|
|
3888
|
-
bypassed = false;
|
|
3889
|
-
setState("idle");
|
|
3890
|
-
resolve();
|
|
3891
|
-
} else {
|
|
3892
|
-
setState("done");
|
|
3893
|
-
}
|
|
3894
|
-
};
|
|
3895
3947
|
return {
|
|
3896
3948
|
Typewriter,
|
|
3897
|
-
|
|
3898
|
-
state
|
|
3949
|
+
click
|
|
3899
3950
|
};
|
|
3900
3951
|
};
|
|
3901
3952
|
|
|
@@ -4215,8 +4266,7 @@ var Game = (props) => {
|
|
|
4215
4266
|
const {
|
|
4216
4267
|
store,
|
|
4217
4268
|
context,
|
|
4218
|
-
controls
|
|
4219
|
-
skipTypewriterWhenGoingBack
|
|
4269
|
+
controls
|
|
4220
4270
|
} = props;
|
|
4221
4271
|
const [auto, setAuto] = createSignal(false);
|
|
4222
4272
|
const onInputButtonClick = () => {
|
|
@@ -4231,26 +4281,36 @@ var Game = (props) => {
|
|
|
4231
4281
|
const customs = () => {
|
|
4232
4282
|
return Object.values(custom());
|
|
4233
4283
|
};
|
|
4234
|
-
const
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4284
|
+
const TextWriter = createTypewriter({
|
|
4285
|
+
resolve() {
|
|
4286
|
+
text().resolve?.();
|
|
4287
|
+
},
|
|
4288
|
+
ignore: () => {
|
|
4289
|
+
return context.meta.goingBack || Boolean(props.isPreview);
|
|
4290
|
+
},
|
|
4291
|
+
onComplete: (prm, click) => {
|
|
4292
|
+
if (!auto()) return;
|
|
4239
4293
|
if (prm) {
|
|
4240
4294
|
setAuto(false);
|
|
4241
4295
|
} else {
|
|
4242
|
-
|
|
4296
|
+
click();
|
|
4243
4297
|
}
|
|
4244
|
-
};
|
|
4245
|
-
};
|
|
4246
|
-
const TextWriter = createTypewriter({
|
|
4247
|
-
resolve() {
|
|
4248
|
-
text().resolve?.();
|
|
4249
4298
|
}
|
|
4250
4299
|
});
|
|
4251
4300
|
const DialogWriter = createTypewriter({
|
|
4252
4301
|
resolve() {
|
|
4253
4302
|
dialog().resolve?.();
|
|
4303
|
+
},
|
|
4304
|
+
ignore: () => {
|
|
4305
|
+
return context.meta.goingBack || Boolean(props.isPreview);
|
|
4306
|
+
},
|
|
4307
|
+
onComplete: (prm, click) => {
|
|
4308
|
+
if (!auto()) return;
|
|
4309
|
+
if (prm) {
|
|
4310
|
+
setAuto(false);
|
|
4311
|
+
} else {
|
|
4312
|
+
click();
|
|
4313
|
+
}
|
|
4254
4314
|
}
|
|
4255
4315
|
});
|
|
4256
4316
|
const controlPanelMenuID = createUniqueId();
|
|
@@ -4313,9 +4373,9 @@ var Game = (props) => {
|
|
|
4313
4373
|
return mood();
|
|
4314
4374
|
}
|
|
4315
4375
|
}), _el$5);
|
|
4316
|
-
addEventListener2(_el$5, "keydown", onKey(DialogWriter.
|
|
4317
|
-
addEventListener2(_el$5, "keypress", onKey(DialogWriter.
|
|
4318
|
-
addEventListener2(_el$5, "click", DialogWriter.
|
|
4376
|
+
addEventListener2(_el$5, "keydown", onKey(DialogWriter.click, " "), true);
|
|
4377
|
+
addEventListener2(_el$5, "keypress", onKey(DialogWriter.click, "Enter"));
|
|
4378
|
+
addEventListener2(_el$5, "click", DialogWriter.click, true);
|
|
4319
4379
|
insert(_el$5, createComponent(Show, {
|
|
4320
4380
|
get when() {
|
|
4321
4381
|
return dialog().miniature.emotion;
|
|
@@ -4344,22 +4404,8 @@ var Game = (props) => {
|
|
|
4344
4404
|
}
|
|
4345
4405
|
}), _el$7);
|
|
4346
4406
|
insert(_el$7, createComponent(DialogWriter.Typewriter, {
|
|
4347
|
-
get attributes() {
|
|
4348
|
-
return {
|
|
4349
|
-
title: DialogWriter.state() === "idle" ? void 0 : data.t(DialogWriter.state() === "processing" ? "CompleteText" : "GoForward")
|
|
4350
|
-
};
|
|
4351
|
-
},
|
|
4352
4407
|
get content() {
|
|
4353
4408
|
return dialog().content;
|
|
4354
|
-
},
|
|
4355
|
-
get ignore() {
|
|
4356
|
-
return skipTypewriterWhenGoingBack && context.meta.goingBack || Boolean(props.isPreview);
|
|
4357
|
-
},
|
|
4358
|
-
get speed() {
|
|
4359
|
-
return speed();
|
|
4360
|
-
},
|
|
4361
|
-
get ended() {
|
|
4362
|
-
return onWriterEnd(DialogWriter.clear);
|
|
4363
4409
|
}
|
|
4364
4410
|
}));
|
|
4365
4411
|
insert(_el$, createComponent(Modal, {
|
|
@@ -4489,26 +4535,12 @@ var Game = (props) => {
|
|
|
4489
4535
|
},
|
|
4490
4536
|
children: (value) => value.node
|
|
4491
4537
|
}));
|
|
4492
|
-
addEventListener2(_el$18, "keydown", onKey(TextWriter.
|
|
4493
|
-
addEventListener2(_el$18, "keypress", onKey(TextWriter.
|
|
4494
|
-
addEventListener2(_el$18, "click", TextWriter.
|
|
4538
|
+
addEventListener2(_el$18, "keydown", onKey(TextWriter.click, " "), true);
|
|
4539
|
+
addEventListener2(_el$18, "keypress", onKey(TextWriter.click, "Enter"));
|
|
4540
|
+
addEventListener2(_el$18, "click", TextWriter.click, true);
|
|
4495
4541
|
insert(_el$18, createComponent(TextWriter.Typewriter, {
|
|
4496
|
-
get attributes() {
|
|
4497
|
-
return {
|
|
4498
|
-
title: TextWriter.state() === "idle" ? void 0 : data.t(TextWriter.state() === "processing" ? "CompleteText" : "GoForward")
|
|
4499
|
-
};
|
|
4500
|
-
},
|
|
4501
4542
|
get content() {
|
|
4502
4543
|
return text().content;
|
|
4503
|
-
},
|
|
4504
|
-
get ignore() {
|
|
4505
|
-
return skipTypewriterWhenGoingBack && context.meta.goingBack || Boolean(props.isPreview);
|
|
4506
|
-
},
|
|
4507
|
-
get speed() {
|
|
4508
|
-
return speed();
|
|
4509
|
-
},
|
|
4510
|
-
get ended() {
|
|
4511
|
-
return onWriterEnd(TextWriter.clear);
|
|
4512
4544
|
}
|
|
4513
4545
|
}));
|
|
4514
4546
|
insert(_el$, createComponent(Show, {
|
|
@@ -5044,7 +5076,6 @@ var createRootComponent = ({
|
|
|
5044
5076
|
fullscreen,
|
|
5045
5077
|
emitter,
|
|
5046
5078
|
controls,
|
|
5047
|
-
skipTypewriterWhenGoingBack,
|
|
5048
5079
|
rendererContext,
|
|
5049
5080
|
audio
|
|
5050
5081
|
}) => {
|
|
@@ -5100,7 +5131,6 @@ var createRootComponent = ({
|
|
|
5100
5131
|
$contextState,
|
|
5101
5132
|
context: rendererContext,
|
|
5102
5133
|
controls,
|
|
5103
|
-
skipTypewriterWhenGoingBack,
|
|
5104
5134
|
get store() {
|
|
5105
5135
|
return useShared(coreOptions.mainContextKey);
|
|
5106
5136
|
}
|
|
@@ -5332,10 +5362,9 @@ var createEmitter = () => {
|
|
|
5332
5362
|
var {
|
|
5333
5363
|
preloadAudioBlocking
|
|
5334
5364
|
} = createAudioMisc();
|
|
5335
|
-
var
|
|
5365
|
+
var createRenderer = ({
|
|
5336
5366
|
fullscreen = false,
|
|
5337
5367
|
controls = "outside",
|
|
5338
|
-
skipTypewriterWhenGoingBack = true,
|
|
5339
5368
|
target = document.body,
|
|
5340
5369
|
showAudioSettings = true
|
|
5341
5370
|
} = {}) => {
|
|
@@ -5557,7 +5586,6 @@ var createSolidRenderer = ({
|
|
|
5557
5586
|
fullscreen,
|
|
5558
5587
|
emitter,
|
|
5559
5588
|
controls,
|
|
5560
|
-
skipTypewriterWhenGoingBack,
|
|
5561
5589
|
showAudioSettings,
|
|
5562
5590
|
rendererContext: renderer.getContext(options.mainContextKey),
|
|
5563
5591
|
coreOptions: options,
|
|
@@ -5594,6 +5622,7 @@ var createSolidRenderer = ({
|
|
|
5594
5622
|
}
|
|
5595
5623
|
};
|
|
5596
5624
|
};
|
|
5625
|
+
var createSolidRenderer = createRenderer;
|
|
5597
5626
|
export {
|
|
5598
5627
|
createSolidRenderer
|
|
5599
5628
|
};
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Character, Context, Lang, RendererInit } from '@novely/core';
|
|
2
2
|
import type { CreateSolidRendererOptions, EmitterEventsMap, SolidRendererStore, StateMainmenuItem, StateScreen, StateScreens } from './types';
|
|
3
|
-
declare const
|
|
3
|
+
declare const createRenderer: ({ fullscreen, controls, target, showAudioSettings, }?: CreateSolidRendererOptions) => {
|
|
4
4
|
emitter: import("./emitter").Emitter<EmitterEventsMap>;
|
|
5
5
|
renderer<$Language extends Lang, $Characters extends Record<string, Character<$Language>>>(options: RendererInit<$Language, $Characters>): {
|
|
6
6
|
getContext: (key: string) => Context;
|
|
@@ -36,5 +36,44 @@ declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGo
|
|
|
36
36
|
registerScreen(name: string, screen: StateScreen): void;
|
|
37
37
|
registerMainmenuItem(fn: StateMainmenuItem): void;
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated import `createRenderer` instead
|
|
41
|
+
*/
|
|
42
|
+
export declare const createSolidRenderer: ({ fullscreen, controls, target, showAudioSettings, }?: CreateSolidRendererOptions) => {
|
|
43
|
+
emitter: import("./emitter").Emitter<EmitterEventsMap>;
|
|
44
|
+
renderer<$Language extends Lang, $Characters extends Record<string, Character<$Language>>>(options: RendererInit<$Language, $Characters>): {
|
|
45
|
+
getContext: (key: string) => Context;
|
|
46
|
+
removeContext(name: string): void;
|
|
47
|
+
ui: {
|
|
48
|
+
showScreen(name: import("@novely/core").NovelyScreen): void;
|
|
49
|
+
getScreen(): import("@novely/core").NovelyScreen;
|
|
50
|
+
showLoading(): void;
|
|
51
|
+
hideLoading(): void;
|
|
52
|
+
showExitPrompt(): void;
|
|
53
|
+
start: () => {
|
|
54
|
+
unmount: () => void;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
misc: {
|
|
58
|
+
preloadImage: <T extends string>(src: T) => T;
|
|
59
|
+
preloadImageBlocking: (src: string) => Promise<void>;
|
|
60
|
+
preloadAudioBlocking: (source: string) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
actions: {
|
|
63
|
+
showImage: (asset: import("@novely/core").NovelyAsset, { classesBase, classesIn, wait }?: {
|
|
64
|
+
classesBase?: string;
|
|
65
|
+
classesIn?: string;
|
|
66
|
+
wait?: boolean;
|
|
67
|
+
}) => import("@novely/core").ValidAction;
|
|
68
|
+
hideImage: (asset: import("@novely/core").NovelyAsset, { classesOut, wait }?: {
|
|
69
|
+
classesOut?: string;
|
|
70
|
+
wait?: boolean;
|
|
71
|
+
}) => import("@novely/core").ValidAction;
|
|
72
|
+
setMood: (mood: string | import("@novely/core").TextContent<Lang, import("@novely/core").State>) => import("@novely/core").ValidAction;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
registerScreen(name: string, screen: StateScreen): void;
|
|
76
|
+
registerMainmenuItem(fn: StateMainmenuItem): void;
|
|
77
|
+
};
|
|
78
|
+
export { createRenderer };
|
|
40
79
|
export type { StateScreen, StateScreens, SolidRendererStore };
|
package/dist/screens/game.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -29,11 +29,6 @@ type CreateSolidRendererOptions = {
|
|
|
29
29
|
* @default "outside"
|
|
30
30
|
*/
|
|
31
31
|
controls?: 'inside' | 'outside';
|
|
32
|
-
/**
|
|
33
|
-
* When `goingBack` typewriter effect won't be applied
|
|
34
|
-
* @default true
|
|
35
|
-
*/
|
|
36
|
-
skipTypewriterWhenGoingBack?: boolean;
|
|
37
32
|
/**
|
|
38
33
|
* Where Novely will be mounted
|
|
39
34
|
* @default document.body
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/solid-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"es-toolkit": "^1.31.0",
|
|
22
22
|
"solid-js": "~1.9.4",
|
|
23
23
|
"solid-transition-group": "^0.2.3",
|
|
24
|
-
"@novely/renderer-toolkit": "0.13.0"
|
|
25
|
-
"@novely/typewriter": "0.5.1"
|
|
24
|
+
"@novely/renderer-toolkit": "0.13.0"
|
|
26
25
|
},
|
|
27
26
|
"peerDependencies": {
|
|
28
27
|
"@novely/core": "*",
|