@novely/solid-renderer 0.32.1 → 0.33.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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ValidAction, Character, Lang } from "@novely/core";
|
|
2
|
+
type ShowArbitraryCharacterParams<$Characters extends Record<string, Character<Lang>>, $Character extends keyof $Characters> = {
|
|
3
|
+
id: $Character & string;
|
|
4
|
+
emotion: keyof $Characters[$Character]['emotions'] & string;
|
|
5
|
+
extendWith: () => string | string[];
|
|
6
|
+
classes?: string;
|
|
7
|
+
style?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const createShowArbitraryCharacterAction: <$Characters extends Record<string, Character>>(_: $Characters) => <$Character extends keyof $Characters>(params: ShowArbitraryCharacterParams<$Characters, $Character>) => ValidAction;
|
|
10
|
+
export { createShowArbitraryCharacterAction };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ValidAction } from "@novely/core";
|
|
2
|
+
type ShowImageParams = {
|
|
3
|
+
z?: number;
|
|
4
|
+
in?: string;
|
|
5
|
+
class?: string;
|
|
6
|
+
style?: string;
|
|
7
|
+
position?: string;
|
|
8
|
+
await?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const showImage: (source: string, params?: ShowImageParams) => ValidAction;
|
|
11
|
+
type HideImageParams = {
|
|
12
|
+
out?: string;
|
|
13
|
+
await?: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const hideImage: (source: string, params?: HideImageParams) => ValidAction;
|
|
16
|
+
export { showImage, hideImage };
|
package/dist/custom-actions.d.ts
CHANGED
|
@@ -7,4 +7,18 @@ type ShowArbitraryCharacterParams<$Characters extends Record<string, Character<L
|
|
|
7
7
|
style?: string;
|
|
8
8
|
};
|
|
9
9
|
declare const createShowArbitraryCharacterAction: <$Characters extends Record<string, Character>>(_: $Characters) => <$Character extends keyof $Characters>(params: ShowArbitraryCharacterParams<$Characters, $Character>) => ValidAction;
|
|
10
|
-
|
|
10
|
+
type ShowImageParams = {
|
|
11
|
+
z?: number;
|
|
12
|
+
in?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
style?: string;
|
|
15
|
+
position?: string;
|
|
16
|
+
await?: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare const showImage: (source: string, params?: ShowImageParams) => ValidAction;
|
|
19
|
+
type HideImageParams = {
|
|
20
|
+
out?: string;
|
|
21
|
+
await?: boolean;
|
|
22
|
+
};
|
|
23
|
+
declare const hideImage: (source: string, params?: HideImageParams) => ValidAction;
|
|
24
|
+
export { createShowArbitraryCharacterAction, showImage, hideImage };
|
package/dist/index.jsx
CHANGED
|
@@ -4724,7 +4724,12 @@ var handleBackgroundAction = ($contextState, background, onChange) => {
|
|
|
4724
4724
|
});
|
|
4725
4725
|
onChange?.(value);
|
|
4726
4726
|
});
|
|
4727
|
-
$contextState.mutate((s) => s.background
|
|
4727
|
+
$contextState.mutate((s) => s.background, (prev) => {
|
|
4728
|
+
return {
|
|
4729
|
+
...prev,
|
|
4730
|
+
clear: dispose2
|
|
4731
|
+
};
|
|
4732
|
+
});
|
|
4728
4733
|
};
|
|
4729
4734
|
var handleDialogAction = ($contextState, content, name, character, emotion, resolve) => {
|
|
4730
4735
|
$contextState.mutate(
|
|
@@ -6115,14 +6120,14 @@ var Game = (props) => {
|
|
|
6115
6120
|
setControlPanelMenuExpanded(false);
|
|
6116
6121
|
}
|
|
6117
6122
|
});
|
|
6118
|
-
const bg =
|
|
6123
|
+
const bg = () => {
|
|
6119
6124
|
const bg2 = background().background;
|
|
6120
6125
|
const isImage = isCSSImage(bg2);
|
|
6121
6126
|
return {
|
|
6122
6127
|
"background-image": isImage ? bg2 : void 0,
|
|
6123
6128
|
"background-color": isImage ? void 0 : bg2
|
|
6124
6129
|
};
|
|
6125
|
-
}
|
|
6130
|
+
};
|
|
6126
6131
|
const charactersCount = createMemo(() => {
|
|
6127
6132
|
return Object.values(characters()).reduce((acc, c) => {
|
|
6128
6133
|
if (c && c.visible) {
|
|
@@ -6144,17 +6149,18 @@ var Game = (props) => {
|
|
|
6144
6149
|
return _el$33;
|
|
6145
6150
|
})();
|
|
6146
6151
|
},
|
|
6152
|
+
keyed: true,
|
|
6147
6153
|
children: (src) => {
|
|
6148
|
-
let img = PRELOADED_IMAGE_MAP.get(src
|
|
6154
|
+
let img = PRELOADED_IMAGE_MAP.get(src);
|
|
6149
6155
|
if (img) {
|
|
6150
|
-
const
|
|
6151
|
-
return Object.assign(
|
|
6156
|
+
const image = img.isConnected ? img.cloneNode(true) : img;
|
|
6157
|
+
return Object.assign(image, {
|
|
6152
6158
|
className: "background"
|
|
6153
6159
|
});
|
|
6154
6160
|
}
|
|
6155
|
-
img = createImage(src
|
|
6161
|
+
img = createImage(src);
|
|
6156
6162
|
img.addEventListener("load", () => {
|
|
6157
|
-
PRELOADED_IMAGE_MAP.set(src
|
|
6163
|
+
PRELOADED_IMAGE_MAP.set(src, img);
|
|
6158
6164
|
});
|
|
6159
6165
|
return Object.assign(img, {
|
|
6160
6166
|
className: "background"
|
|
@@ -6539,7 +6545,7 @@ var Saves = () => {
|
|
|
6539
6545
|
const [loadingAllowed, setLoadingAllowed] = createSignal([]);
|
|
6540
6546
|
const [previewCompleted, setPreviewCompleted] = createSignal([]);
|
|
6541
6547
|
const [observedTargets, setObservedTargets] = createSignal([]);
|
|
6542
|
-
const saves = () => storageData().saves;
|
|
6548
|
+
const saves = () => storageData().saves.slice().reverse();
|
|
6543
6549
|
const language = () => storageData().meta[0];
|
|
6544
6550
|
const processed = /* @__PURE__ */ new Set();
|
|
6545
6551
|
onMount(() => {
|
|
@@ -6900,7 +6906,7 @@ var createRootComponent = ({
|
|
|
6900
6906
|
return Root;
|
|
6901
6907
|
};
|
|
6902
6908
|
|
|
6903
|
-
// src/custom-actions.ts
|
|
6909
|
+
// src/custom-actions/show-arbitrary-character.ts
|
|
6904
6910
|
var SHOW_ARBITARY_CHARACTER = Symbol();
|
|
6905
6911
|
var createShowArbitraryCharacterAction = (_) => {
|
|
6906
6912
|
const showArbitraryCharacter = (params) => {
|
|
@@ -6919,8 +6925,100 @@ var createShowArbitraryCharacterAction = (_) => {
|
|
|
6919
6925
|
return showArbitraryCharacter;
|
|
6920
6926
|
};
|
|
6921
6927
|
|
|
6928
|
+
// src/custom-actions/show-hide-image.ts
|
|
6929
|
+
var SHOW_IMAGE = Symbol();
|
|
6930
|
+
var showImage = (source, params = {}) => {
|
|
6931
|
+
const handler = ({ getDomNodes, clear, flags, data }) => {
|
|
6932
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
6933
|
+
const { element } = getDomNodes(true);
|
|
6934
|
+
{
|
|
6935
|
+
element.style.cssText += `position: fixed; inset: 0;`;
|
|
6936
|
+
element.style.zIndex = String(params.z || 1);
|
|
6937
|
+
}
|
|
6938
|
+
const image = document.createElement("img");
|
|
6939
|
+
{
|
|
6940
|
+
image.src = source;
|
|
6941
|
+
image.className = params.class || "";
|
|
6942
|
+
image.style.cssText = params.style || "";
|
|
6943
|
+
image.style.cssText += `object-fit: cover; object-position: ${params.position || "50% 50%"}; width: 100vw; height: 100vh;`;
|
|
6944
|
+
}
|
|
6945
|
+
element.appendChild(image);
|
|
6946
|
+
data({
|
|
6947
|
+
image,
|
|
6948
|
+
in: params.in
|
|
6949
|
+
});
|
|
6950
|
+
let clearAnimation = noop;
|
|
6951
|
+
if (params.in && !flags.preview) {
|
|
6952
|
+
const classes = params.in.split(" ");
|
|
6953
|
+
image.classList.add(...classes);
|
|
6954
|
+
clearAnimation = () => {
|
|
6955
|
+
image.classList.remove(...classes);
|
|
6956
|
+
if (params.await) {
|
|
6957
|
+
resolve();
|
|
6958
|
+
}
|
|
6959
|
+
};
|
|
6960
|
+
image.addEventListener("animationend", clearAnimation, { once: true });
|
|
6961
|
+
}
|
|
6962
|
+
clear(() => {
|
|
6963
|
+
data({});
|
|
6964
|
+
clearAnimation();
|
|
6965
|
+
image.remove();
|
|
6966
|
+
});
|
|
6967
|
+
if (!params.await) {
|
|
6968
|
+
resolve();
|
|
6969
|
+
}
|
|
6970
|
+
return promise;
|
|
6971
|
+
};
|
|
6972
|
+
handler.id = SHOW_IMAGE;
|
|
6973
|
+
handler.key = source;
|
|
6974
|
+
handler.assets = [source];
|
|
6975
|
+
handler.skipOnRestore = (getNext) => {
|
|
6976
|
+
return getNext().some(([name, fn]) => name === "custom" && fn.key === source);
|
|
6977
|
+
};
|
|
6978
|
+
return ["custom", handler];
|
|
6979
|
+
};
|
|
6980
|
+
var hideImage = (source, params = {}) => {
|
|
6981
|
+
const handler = async ({ data }) => {
|
|
6982
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
6983
|
+
const { image, in: inClasses } = data();
|
|
6984
|
+
if (!image) {
|
|
6985
|
+
resolve();
|
|
6986
|
+
return promise;
|
|
6987
|
+
}
|
|
6988
|
+
if (inClasses) {
|
|
6989
|
+
const classes = inClasses.split(" ");
|
|
6990
|
+
image.classList.remove(...classes);
|
|
6991
|
+
}
|
|
6992
|
+
if (params.out) {
|
|
6993
|
+
const classes = params.out.split(" ");
|
|
6994
|
+
image.classList.add(...classes);
|
|
6995
|
+
const onAnimationEnd = () => {
|
|
6996
|
+
image.classList.remove(...classes);
|
|
6997
|
+
if (params.await) {
|
|
6998
|
+
resolve();
|
|
6999
|
+
}
|
|
7000
|
+
};
|
|
7001
|
+
image.addEventListener("animationend", onAnimationEnd, { once: true });
|
|
7002
|
+
if (!params.await) {
|
|
7003
|
+
resolve();
|
|
7004
|
+
}
|
|
7005
|
+
} else {
|
|
7006
|
+
resolve();
|
|
7007
|
+
}
|
|
7008
|
+
return promise;
|
|
7009
|
+
};
|
|
7010
|
+
handler.id = SHOW_IMAGE;
|
|
7011
|
+
handler.key = source;
|
|
7012
|
+
handler.assets = [source];
|
|
7013
|
+
handler.skipOnRestore = (getNext) => {
|
|
7014
|
+
return getNext().some(([name, fn]) => name === "custom" && fn.key === source);
|
|
7015
|
+
};
|
|
7016
|
+
return ["custom", handler];
|
|
7017
|
+
};
|
|
7018
|
+
|
|
6922
7019
|
// src/renderer.tsx
|
|
6923
7020
|
var _tmpl$31 = /* @__PURE__ */ template(`<canvas>`);
|
|
7021
|
+
var _tmpl$211 = /* @__PURE__ */ template(`<link rel="preload" as="image">`);
|
|
6924
7022
|
var {
|
|
6925
7023
|
preloadAudioBlocking
|
|
6926
7024
|
} = createAudioMisc();
|
|
@@ -6959,6 +7057,8 @@ var createSolidRenderer = ({
|
|
|
6959
7057
|
root: root(),
|
|
6960
7058
|
background(background) {
|
|
6961
7059
|
handleBackgroundAction($contextState, background, (bg) => {
|
|
7060
|
+
if (!isCSSImage(bg))
|
|
7061
|
+
return;
|
|
6962
7062
|
renderer.misc.preloadImage(bg);
|
|
6963
7063
|
});
|
|
6964
7064
|
},
|
|
@@ -7038,16 +7138,18 @@ var createSolidRenderer = ({
|
|
|
7038
7138
|
});
|
|
7039
7139
|
});
|
|
7040
7140
|
},
|
|
7041
|
-
animate(
|
|
7141
|
+
animate(classes) {
|
|
7042
7142
|
const target2 = this.canvas;
|
|
7043
7143
|
if (!target2)
|
|
7044
7144
|
return;
|
|
7045
7145
|
const classNames = classes.filter((className2) => !target2.classList.contains(className2));
|
|
7046
7146
|
target2.classList.add(...classNames);
|
|
7047
|
-
const
|
|
7147
|
+
const onAnimationEnd = () => {
|
|
7048
7148
|
target2.classList.remove(...classNames);
|
|
7049
7149
|
};
|
|
7050
|
-
|
|
7150
|
+
target2.addEventListener("animationend", onAnimationEnd, {
|
|
7151
|
+
once: true
|
|
7152
|
+
});
|
|
7051
7153
|
}
|
|
7052
7154
|
};
|
|
7053
7155
|
useShared(name).characters[character] = characterHandle;
|
|
@@ -7148,6 +7250,12 @@ var createSolidRenderer = ({
|
|
|
7148
7250
|
},
|
|
7149
7251
|
preloadImageBlocking: (src) => {
|
|
7150
7252
|
const img = createImage(src);
|
|
7253
|
+
document.head.appendChild((() => {
|
|
7254
|
+
const _el$2 = _tmpl$211();
|
|
7255
|
+
setAttribute(_el$2, "href", src);
|
|
7256
|
+
return _el$2;
|
|
7257
|
+
})());
|
|
7258
|
+
return Promise.resolve();
|
|
7151
7259
|
return new Promise((resolve) => {
|
|
7152
7260
|
const done = () => {
|
|
7153
7261
|
PRELOADED_IMAGE_MAP.set(src, img);
|
|
@@ -7164,7 +7272,9 @@ var createSolidRenderer = ({
|
|
|
7164
7272
|
preloadAudioBlocking
|
|
7165
7273
|
},
|
|
7166
7274
|
actions: {
|
|
7167
|
-
showArbitraryCharacter: createShowArbitraryCharacterAction(options.characters)
|
|
7275
|
+
showArbitraryCharacter: createShowArbitraryCharacterAction(options.characters),
|
|
7276
|
+
showImage,
|
|
7277
|
+
hideImage
|
|
7168
7278
|
}
|
|
7169
7279
|
};
|
|
7170
7280
|
return renderer;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -29,6 +29,18 @@ declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGo
|
|
|
29
29
|
classes?: string | undefined;
|
|
30
30
|
style?: string | undefined;
|
|
31
31
|
}) => import("@novely/core").ValidAction;
|
|
32
|
+
showImage: (source: string, params?: {
|
|
33
|
+
z?: number | undefined;
|
|
34
|
+
in?: string | undefined;
|
|
35
|
+
class?: string | undefined;
|
|
36
|
+
style?: string | undefined;
|
|
37
|
+
position?: string | undefined;
|
|
38
|
+
await?: boolean | undefined;
|
|
39
|
+
}) => import("@novely/core").ValidAction;
|
|
40
|
+
hideImage: (source: string, params?: {
|
|
41
|
+
out?: string | undefined;
|
|
42
|
+
await?: boolean | undefined;
|
|
43
|
+
}) => import("@novely/core").ValidAction;
|
|
32
44
|
};
|
|
33
45
|
};
|
|
34
46
|
registerScreen(name: string, screen: StateScreen): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/solid-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"retrieved": "^0.1.0",
|
|
20
20
|
"solid-js": "1.8.17",
|
|
21
21
|
"solid-transition-group": "^0.2.3",
|
|
22
|
-
"@novely/core": "0.
|
|
23
|
-
"@novely/renderer-toolkit": "0.
|
|
22
|
+
"@novely/core": "0.36.0",
|
|
23
|
+
"@novely/renderer-toolkit": "0.7.0",
|
|
24
24
|
"@novely/typewriter": "0.5.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|