@novely/solid-renderer 0.32.2 → 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
|
@@ -6153,8 +6153,8 @@ var Game = (props) => {
|
|
|
6153
6153
|
children: (src) => {
|
|
6154
6154
|
let img = PRELOADED_IMAGE_MAP.get(src);
|
|
6155
6155
|
if (img) {
|
|
6156
|
-
const
|
|
6157
|
-
return Object.assign(
|
|
6156
|
+
const image = img.isConnected ? img.cloneNode(true) : img;
|
|
6157
|
+
return Object.assign(image, {
|
|
6158
6158
|
className: "background"
|
|
6159
6159
|
});
|
|
6160
6160
|
}
|
|
@@ -6906,7 +6906,7 @@ var createRootComponent = ({
|
|
|
6906
6906
|
return Root;
|
|
6907
6907
|
};
|
|
6908
6908
|
|
|
6909
|
-
// src/custom-actions.ts
|
|
6909
|
+
// src/custom-actions/show-arbitrary-character.ts
|
|
6910
6910
|
var SHOW_ARBITARY_CHARACTER = Symbol();
|
|
6911
6911
|
var createShowArbitraryCharacterAction = (_) => {
|
|
6912
6912
|
const showArbitraryCharacter = (params) => {
|
|
@@ -6925,8 +6925,100 @@ var createShowArbitraryCharacterAction = (_) => {
|
|
|
6925
6925
|
return showArbitraryCharacter;
|
|
6926
6926
|
};
|
|
6927
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
|
+
|
|
6928
7019
|
// src/renderer.tsx
|
|
6929
7020
|
var _tmpl$31 = /* @__PURE__ */ template(`<canvas>`);
|
|
7021
|
+
var _tmpl$211 = /* @__PURE__ */ template(`<link rel="preload" as="image">`);
|
|
6930
7022
|
var {
|
|
6931
7023
|
preloadAudioBlocking
|
|
6932
7024
|
} = createAudioMisc();
|
|
@@ -7046,16 +7138,18 @@ var createSolidRenderer = ({
|
|
|
7046
7138
|
});
|
|
7047
7139
|
});
|
|
7048
7140
|
},
|
|
7049
|
-
animate(
|
|
7141
|
+
animate(classes) {
|
|
7050
7142
|
const target2 = this.canvas;
|
|
7051
7143
|
if (!target2)
|
|
7052
7144
|
return;
|
|
7053
7145
|
const classNames = classes.filter((className2) => !target2.classList.contains(className2));
|
|
7054
7146
|
target2.classList.add(...classNames);
|
|
7055
|
-
const
|
|
7147
|
+
const onAnimationEnd = () => {
|
|
7056
7148
|
target2.classList.remove(...classNames);
|
|
7057
7149
|
};
|
|
7058
|
-
|
|
7150
|
+
target2.addEventListener("animationend", onAnimationEnd, {
|
|
7151
|
+
once: true
|
|
7152
|
+
});
|
|
7059
7153
|
}
|
|
7060
7154
|
};
|
|
7061
7155
|
useShared(name).characters[character] = characterHandle;
|
|
@@ -7156,6 +7250,12 @@ var createSolidRenderer = ({
|
|
|
7156
7250
|
},
|
|
7157
7251
|
preloadImageBlocking: (src) => {
|
|
7158
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();
|
|
7159
7259
|
return new Promise((resolve) => {
|
|
7160
7260
|
const done = () => {
|
|
7161
7261
|
PRELOADED_IMAGE_MAP.set(src, img);
|
|
@@ -7172,7 +7272,9 @@ var createSolidRenderer = ({
|
|
|
7172
7272
|
preloadAudioBlocking
|
|
7173
7273
|
},
|
|
7174
7274
|
actions: {
|
|
7175
|
-
showArbitraryCharacter: createShowArbitraryCharacterAction(options.characters)
|
|
7275
|
+
showArbitraryCharacter: createShowArbitraryCharacterAction(options.characters),
|
|
7276
|
+
showImage,
|
|
7277
|
+
hideImage
|
|
7176
7278
|
}
|
|
7177
7279
|
};
|
|
7178
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.36.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": {
|