@novely/solid-renderer 0.39.0 → 0.41.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,9 +1,10 @@
|
|
|
1
1
|
import type { Component } from 'solid-js';
|
|
2
2
|
import type { Renderer, RendererInit } from '@novely/core';
|
|
3
3
|
import type { Emitter } from '../emitter';
|
|
4
|
-
import type { RendererStateStore,
|
|
4
|
+
import type { RendererStateStore, DeepAtom } from '@novely/renderer-toolkit';
|
|
5
5
|
import type { EmitterEventsMap, RendererStoreExtension, SettingsIcons } from '../types';
|
|
6
6
|
import type { Context } from '@novely/core';
|
|
7
|
+
import type { IContextState } from '../context-state';
|
|
7
8
|
type CreateRootComponentOpts = {
|
|
8
9
|
setRoot: (root: HTMLDivElement) => void;
|
|
9
10
|
renderer: Renderer;
|
|
@@ -15,7 +16,7 @@ type CreateRootComponentOpts = {
|
|
|
15
16
|
showAudioSettings: boolean;
|
|
16
17
|
rendererContext: Context;
|
|
17
18
|
coreOptions: RendererInit<any, any>;
|
|
18
|
-
$contextState:
|
|
19
|
+
$contextState: IContextState;
|
|
19
20
|
$rendererState: DeepAtom<RendererStateStore<RendererStoreExtension>>;
|
|
20
21
|
};
|
|
21
22
|
declare const createRootComponent: ({ $rendererState, $contextState, coreOptions, setRoot, renderer, showAudioSettings, fullscreen, emitter, controls, skipTypewriterWhenGoingBack, settingsIcons, rendererContext }: CreateRootComponentOpts) => Component;
|
package/dist/context-state.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
declare const useContextState: (id: string) => import("@novely/renderer-toolkit").DeepAtom<import("@novely/renderer-toolkit").
|
|
1
|
+
declare const useContextState: (id: string) => import("@novely/renderer-toolkit").DeepAtom<import("@novely/renderer-toolkit").ContextStateStore<{
|
|
2
|
+
images: Record<string, HTMLImageElement | undefined>;
|
|
3
|
+
}>>, removeContextState: (id: string) => void;
|
|
4
|
+
type IContextState = ReturnType<typeof useContextState>;
|
|
2
5
|
export { useContextState, removeContextState };
|
|
6
|
+
export type { IContextState };
|
package/dist/index.jsx
CHANGED
|
@@ -2675,12 +2675,7 @@ var allEmpty = (target) => {
|
|
|
2675
2675
|
var handleBackgroundAction = ($contextState, background) => {
|
|
2676
2676
|
$contextState.get().background.clear?.();
|
|
2677
2677
|
const { dispose: dispose2 } = useBackground(background, (value) => {
|
|
2678
|
-
$contextState.mutate((s) => s.background,
|
|
2679
|
-
return {
|
|
2680
|
-
...prev,
|
|
2681
|
-
background: value
|
|
2682
|
-
};
|
|
2683
|
-
});
|
|
2678
|
+
$contextState.mutate((s) => s.background.background, value);
|
|
2684
2679
|
});
|
|
2685
2680
|
$contextState.mutate((s) => s.background.clear, () => dispose2);
|
|
2686
2681
|
};
|
|
@@ -2923,7 +2918,11 @@ var createEmitter = () => {
|
|
|
2923
2918
|
};
|
|
2924
2919
|
|
|
2925
2920
|
// src/context-state.ts
|
|
2926
|
-
var { useContextState, removeContextState } = createContextStateRoot()
|
|
2921
|
+
var { useContextState, removeContextState } = createContextStateRoot(() => {
|
|
2922
|
+
return {
|
|
2923
|
+
images: {}
|
|
2924
|
+
};
|
|
2925
|
+
});
|
|
2927
2926
|
|
|
2928
2927
|
// src/shared.ts
|
|
2929
2928
|
var PRELOADED_IMAGE_MAP = /* @__PURE__ */ new Map();
|
|
@@ -4149,7 +4148,7 @@ var _tmpl$82 = /* @__PURE__ */ template(`<button type="button" class="button con
|
|
|
4149
4148
|
var _tmpl$92 = /* @__PURE__ */ template(`<span class="control-panel-container-fix" aria-hidden="true">​`);
|
|
4150
4149
|
var _tmpl$102 = /* @__PURE__ */ template(`<div class="control-panel-container-backdrop">`);
|
|
4151
4150
|
var _tmpl$112 = /* @__PURE__ */ template(`<div class="control-panel"><div role="menubar" class="control-panel-container">`);
|
|
4152
|
-
var _tmpl$122 = /* @__PURE__ */ template(`<div><div class="characters"></div><div class="action-dialog"><div class="action-dialog-container" role="button" tabindex="0"><div class="action-dialog-content"></div></div></div><div></div><div class="action-text" role="button" tabindex="0">`);
|
|
4151
|
+
var _tmpl$122 = /* @__PURE__ */ template(`<div><div class="characters"></div><div class="action-dialog"><div class="action-dialog-container" role="button" tabindex="0"><div class="action-dialog-content"></div></div></div><div></div><div class="action-text" role="button" tabindex="0"></div><div class="action-image">`);
|
|
4153
4152
|
var _tmpl$132 = /* @__PURE__ */ template(`<button type="button" class="button choice-dialog__choice"><span>`);
|
|
4154
4153
|
var Game = (props) => {
|
|
4155
4154
|
const data = useData();
|
|
@@ -4160,7 +4159,8 @@ var Game = (props) => {
|
|
|
4160
4159
|
choice,
|
|
4161
4160
|
input,
|
|
4162
4161
|
background,
|
|
4163
|
-
custom
|
|
4162
|
+
custom,
|
|
4163
|
+
images
|
|
4164
4164
|
} = destructure(from(props.$contextState));
|
|
4165
4165
|
const rendererState = from(data.$rendererState);
|
|
4166
4166
|
const exitPromptShown = () => rendererState().exitPromptShown;
|
|
@@ -4171,10 +4171,6 @@ var Game = (props) => {
|
|
|
4171
4171
|
skipTypewriterWhenGoingBack
|
|
4172
4172
|
} = props;
|
|
4173
4173
|
const [auto, setAuto] = createSignal(false);
|
|
4174
|
-
const onChoicesButtonClick = ([disabled, i]) => {
|
|
4175
|
-
if (disabled) return;
|
|
4176
|
-
choice().resolve?.(i);
|
|
4177
|
-
};
|
|
4178
4174
|
const onInputButtonClick = () => {
|
|
4179
4175
|
if (input().error) return;
|
|
4180
4176
|
const {
|
|
@@ -4225,7 +4221,7 @@ var Game = (props) => {
|
|
|
4225
4221
|
}, 0);
|
|
4226
4222
|
});
|
|
4227
4223
|
return (() => {
|
|
4228
|
-
const _el$ = _tmpl$122(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$6 = _el$4.firstChild, _el$16 = _el$3.nextSibling, _el$17 = _el$16.nextSibling;
|
|
4224
|
+
const _el$ = _tmpl$122(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$6 = _el$4.firstChild, _el$16 = _el$3.nextSibling, _el$17 = _el$16.nextSibling, _el$23 = _el$17.nextSibling;
|
|
4229
4225
|
insert(_el$, createComponent(Canvas, {
|
|
4230
4226
|
"class": "background",
|
|
4231
4227
|
resize: false,
|
|
@@ -4356,18 +4352,22 @@ var Game = (props) => {
|
|
|
4356
4352
|
get each() {
|
|
4357
4353
|
return choice().choices;
|
|
4358
4354
|
},
|
|
4359
|
-
children: ([text2, active
|
|
4360
|
-
const
|
|
4355
|
+
children: ([text2, active$, visible$, onSelect, image], i) => {
|
|
4356
|
+
const active = from(active$);
|
|
4357
|
+
const visible = from(visible$);
|
|
4358
|
+
const disabled = () => !active();
|
|
4361
4359
|
const index = i();
|
|
4362
4360
|
return createComponent(Show, {
|
|
4363
4361
|
when: visible,
|
|
4364
4362
|
get children() {
|
|
4365
|
-
const _el$
|
|
4366
|
-
_el$
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4363
|
+
const _el$24 = _tmpl$132(), _el$25 = _el$24.firstChild;
|
|
4364
|
+
_el$24.$$click = async () => {
|
|
4365
|
+
await onSelect();
|
|
4366
|
+
if (disabled()) return;
|
|
4367
|
+
choice().resolve?.(index);
|
|
4368
|
+
};
|
|
4369
|
+
insert(_el$25, text2);
|
|
4370
|
+
insert(_el$24, createComponent(Show, {
|
|
4371
4371
|
when: image !== "",
|
|
4372
4372
|
get children() {
|
|
4373
4373
|
return createComponent(Canvas, {
|
|
@@ -4382,7 +4382,8 @@ var Game = (props) => {
|
|
|
4382
4382
|
});
|
|
4383
4383
|
}
|
|
4384
4384
|
}), null);
|
|
4385
|
-
|
|
4385
|
+
createRenderEffect(() => setAttribute(_el$24, "aria-disabled", disabled()));
|
|
4386
|
+
return _el$24;
|
|
4386
4387
|
}
|
|
4387
4388
|
});
|
|
4388
4389
|
}
|
|
@@ -4548,7 +4549,13 @@ var Game = (props) => {
|
|
|
4548
4549
|
});
|
|
4549
4550
|
return _el$18;
|
|
4550
4551
|
}
|
|
4551
|
-
}),
|
|
4552
|
+
}), _el$23);
|
|
4553
|
+
insert(_el$23, createComponent(For, {
|
|
4554
|
+
get each() {
|
|
4555
|
+
return Object.values(images());
|
|
4556
|
+
},
|
|
4557
|
+
children: (image) => image
|
|
4558
|
+
}));
|
|
4552
4559
|
createRenderEffect((_p$) => {
|
|
4553
4560
|
const _v$7 = `${props.className || ""} game`, _v$8 = !!props.isPreview, _v$9 = charactersCount(), _v$10 = !!dialog().visible, _v$11 = !dialog().visible, _v$12 = !(dialog().miniature.character && dialog().miniature.emotion), _v$13 = !dialog().content, _v$14 = !!props.isPreview, _v$15 = !!Boolean(text().content), _v$16 = !text().content;
|
|
4554
4561
|
_v$7 !== _p$._v$7 && className(_el$, _p$._v$7 = _v$7);
|
|
@@ -5057,42 +5064,39 @@ var createRootComponent = ({
|
|
|
5057
5064
|
// src/custom-actions/show-hide-image.ts
|
|
5058
5065
|
var SHOW_IMAGE = Symbol();
|
|
5059
5066
|
var showImage = (source, params = {}) => {
|
|
5060
|
-
const handler = ({
|
|
5067
|
+
const handler = ({ contextKey, clear, flags, data, rendererContext }) => {
|
|
5068
|
+
const ctx = useContextState(contextKey);
|
|
5061
5069
|
const { promise, resolve } = Promise.withResolvers();
|
|
5062
|
-
const { element } = getDomNodes(true);
|
|
5063
|
-
{
|
|
5064
|
-
element.style.cssText += `position: fixed; inset: 0;`;
|
|
5065
|
-
element.style.zIndex = String(params.z || 1);
|
|
5066
|
-
}
|
|
5067
5070
|
const image = document.createElement("img");
|
|
5068
5071
|
{
|
|
5069
5072
|
image.src = source;
|
|
5070
|
-
image.className = params.class || "";
|
|
5073
|
+
image.className = "action-image__image " + (params.class || "");
|
|
5071
5074
|
image.style.cssText = params.style || "";
|
|
5072
|
-
image.style.
|
|
5075
|
+
image.style.setProperty("--z-index", String(params.z || 1));
|
|
5073
5076
|
}
|
|
5074
|
-
|
|
5077
|
+
ctx.mutate((s) => s.images[source], image);
|
|
5078
|
+
const inClasses = (params.in || "").split(" ");
|
|
5075
5079
|
data({
|
|
5076
5080
|
image,
|
|
5077
|
-
|
|
5081
|
+
inClasses
|
|
5078
5082
|
});
|
|
5079
5083
|
let clearAnimation = noop;
|
|
5080
5084
|
if (params.in && !flags.preview) {
|
|
5081
|
-
|
|
5082
|
-
|
|
5085
|
+
image.classList.add(...inClasses);
|
|
5086
|
+
if (params.await) {
|
|
5087
|
+
rendererContext.clearBlockingActions(void 0);
|
|
5088
|
+
}
|
|
5083
5089
|
clearAnimation = () => {
|
|
5084
|
-
image.classList.remove(...
|
|
5085
|
-
|
|
5086
|
-
rendererContext.clearBlockingActions(void 0);
|
|
5087
|
-
resolve();
|
|
5088
|
-
}
|
|
5090
|
+
image.classList.remove(...inClasses);
|
|
5091
|
+
resolve();
|
|
5089
5092
|
};
|
|
5090
5093
|
image.addEventListener("animationend", clearAnimation, { once: true });
|
|
5094
|
+
} else {
|
|
5095
|
+
resolve();
|
|
5091
5096
|
}
|
|
5092
5097
|
clear(() => {
|
|
5093
5098
|
data({});
|
|
5094
5099
|
clearAnimation();
|
|
5095
|
-
image.remove();
|
|
5096
5100
|
});
|
|
5097
5101
|
if (!params.await) {
|
|
5098
5102
|
resolve();
|
|
@@ -5108,39 +5112,41 @@ var showImage = (source, params = {}) => {
|
|
|
5108
5112
|
return ["custom", handler];
|
|
5109
5113
|
};
|
|
5110
5114
|
var hideImage = (source, params = {}) => {
|
|
5111
|
-
const handler = async ({ data, rendererContext }) => {
|
|
5115
|
+
const handler = async ({ data, rendererContext, contextKey, flags }) => {
|
|
5116
|
+
const ctx = useContextState(contextKey);
|
|
5112
5117
|
const { promise, resolve } = Promise.withResolvers();
|
|
5113
|
-
const
|
|
5118
|
+
const done = () => {
|
|
5119
|
+
ctx.mutate((s) => s.images[source], void 0);
|
|
5120
|
+
resolve();
|
|
5121
|
+
};
|
|
5122
|
+
const { image, inClasses } = data();
|
|
5114
5123
|
if (!image) {
|
|
5115
5124
|
resolve();
|
|
5116
5125
|
return promise;
|
|
5117
5126
|
}
|
|
5118
5127
|
if (inClasses) {
|
|
5119
|
-
|
|
5120
|
-
image.classList.remove(...classes);
|
|
5128
|
+
image.classList.remove(...inClasses);
|
|
5121
5129
|
}
|
|
5122
|
-
if (params.out) {
|
|
5130
|
+
if (params.out && !flags.preview) {
|
|
5123
5131
|
const classes = params.out.split(" ");
|
|
5124
5132
|
image.classList.add(...classes);
|
|
5133
|
+
rendererContext.clearBlockingActions(void 0);
|
|
5125
5134
|
const onAnimationEnd = () => {
|
|
5126
5135
|
image.classList.remove(...classes);
|
|
5127
|
-
|
|
5128
|
-
rendererContext.clearBlockingActions(void 0);
|
|
5129
|
-
resolve();
|
|
5130
|
-
}
|
|
5136
|
+
done();
|
|
5131
5137
|
};
|
|
5132
5138
|
image.addEventListener("animationend", onAnimationEnd, { once: true });
|
|
5133
5139
|
if (!params.await) {
|
|
5134
|
-
|
|
5140
|
+
done();
|
|
5135
5141
|
}
|
|
5136
5142
|
} else {
|
|
5137
|
-
|
|
5143
|
+
done();
|
|
5138
5144
|
}
|
|
5139
5145
|
return promise;
|
|
5140
5146
|
};
|
|
5141
5147
|
handler.id = SHOW_IMAGE;
|
|
5142
5148
|
handler.key = source;
|
|
5143
|
-
handler.assets = [
|
|
5149
|
+
handler.assets = [];
|
|
5144
5150
|
handler.skipOnRestore = (getNext) => {
|
|
5145
5151
|
return getNext().some(([name, fn]) => name === "custom" && fn.key === source);
|
|
5146
5152
|
};
|
|
@@ -5217,7 +5223,7 @@ var createSolidRenderer = ({
|
|
|
5217
5223
|
canvas,
|
|
5218
5224
|
ctx: canvasContext,
|
|
5219
5225
|
emotions: {},
|
|
5220
|
-
|
|
5226
|
+
emotion(emotion, shouldRender) {
|
|
5221
5227
|
let stored = this.emotions[emotion];
|
|
5222
5228
|
if (!stored) {
|
|
5223
5229
|
stored = this.emotions[emotion] = options.getCharacterAssets(character, emotion).map((src) => imagePreloadWithCachingNotComplete(src));
|
package/dist/renderer.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGo
|
|
|
26
26
|
in?: string;
|
|
27
27
|
class?: string;
|
|
28
28
|
style?: string;
|
|
29
|
-
position?: string;
|
|
30
29
|
await?: boolean;
|
|
31
30
|
}) => import("@novely/core").ValidAction;
|
|
32
31
|
hideImage: (source: string, params?: {
|
package/dist/screens/game.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Context } from '@novely/core';
|
|
2
2
|
import type { VoidComponent } from 'solid-js';
|
|
3
3
|
import type { SolidRendererStore } from '../renderer';
|
|
4
|
-
import type {
|
|
4
|
+
import type { IContextState } from '../context-state';
|
|
5
5
|
interface GameProps {
|
|
6
6
|
context: Context;
|
|
7
|
-
$contextState:
|
|
7
|
+
$contextState: IContextState;
|
|
8
8
|
store: SolidRendererStore;
|
|
9
9
|
controls: 'inside' | 'outside';
|
|
10
10
|
skipTypewriterWhenGoingBack: boolean;
|
package/dist/styles/index.css
CHANGED
|
@@ -566,6 +566,28 @@
|
|
|
566
566
|
|
|
567
567
|
/* src/styles/action-dialog/index.css */
|
|
568
568
|
|
|
569
|
+
/* src/styles/custom-actions/image/image.css */
|
|
570
|
+
.action-image {
|
|
571
|
+
z-index: 1;
|
|
572
|
+
position: fixed;
|
|
573
|
+
top: 0;
|
|
574
|
+
bottom: 0;
|
|
575
|
+
left: 0;
|
|
576
|
+
right: 0;
|
|
577
|
+
}
|
|
578
|
+
.action-image__image {
|
|
579
|
+
z-index: var(--z-index, 1);
|
|
580
|
+
object-fit: cover;
|
|
581
|
+
object-position: 50% 50%;
|
|
582
|
+
width: 100vw;
|
|
583
|
+
height: 100vh;
|
|
584
|
+
position: absolute;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/* src/styles/custom-actions/image/index.css */
|
|
588
|
+
|
|
589
|
+
/* src/styles/custom-actions/index.css */
|
|
590
|
+
|
|
569
591
|
/* src/styles/dialog/dialog.css */
|
|
570
592
|
.dialog {
|
|
571
593
|
z-index: 25;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/solid-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"clsx": "^2.1.1",
|
|
20
20
|
"solid-js": "1.8.21",
|
|
21
21
|
"solid-transition-group": "^0.2.3",
|
|
22
|
-
"@novely/core": "0.
|
|
23
|
-
"@novely/renderer-toolkit": "0.
|
|
22
|
+
"@novely/core": "0.45.0",
|
|
23
|
+
"@novely/renderer-toolkit": "0.11.0",
|
|
24
24
|
"@novely/typewriter": "0.5.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|