@novely/solid-renderer 0.32.2 → 0.34.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
|
@@ -5650,32 +5650,39 @@ var Save = (props) => {
|
|
|
5650
5650
|
context.root = contentDocument.body;
|
|
5651
5651
|
setIframeLoaded(true);
|
|
5652
5652
|
};
|
|
5653
|
-
createEffect(() => {
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5653
|
+
createEffect(async () => {
|
|
5654
|
+
const ready = props.observed && iframeLoaded() && !previewStarted();
|
|
5655
|
+
if (!ready)
|
|
5656
|
+
return;
|
|
5657
|
+
setPreviewStarted(true);
|
|
5658
|
+
setTimeout(() => {
|
|
5659
|
+
previewDone();
|
|
5660
|
+
}, 1e3);
|
|
5661
|
+
try {
|
|
5662
|
+
await options.preview(props.save, KEY);
|
|
5663
|
+
const background = useContextState(KEY).get().background.background;
|
|
5664
|
+
if (!background || !isCSSImage(background)) {
|
|
5665
|
+
return previewDone();
|
|
5666
|
+
}
|
|
5667
|
+
if (PRELOADED_IMAGE_MAP.has(background)) {
|
|
5668
|
+
return previewDone();
|
|
5669
|
+
}
|
|
5670
|
+
const backgroundElement = context.root.querySelector("img.background");
|
|
5671
|
+
if (!backgroundElement) {
|
|
5672
|
+
return previewDone();
|
|
5673
|
+
}
|
|
5674
|
+
if (backgroundElement.complete && backgroundElement.naturalHeight !== 0) {
|
|
5675
|
+
return previewDone();
|
|
5676
|
+
}
|
|
5677
|
+
const onLoadingStatusChange = () => {
|
|
5678
|
+
backgroundElement.removeEventListener("load", onLoadingStatusChange);
|
|
5679
|
+
backgroundElement.removeEventListener("error", onLoadingStatusChange);
|
|
5680
|
+
previewDone();
|
|
5681
|
+
};
|
|
5682
|
+
backgroundElement.addEventListener("load", onLoadingStatusChange);
|
|
5683
|
+
backgroundElement.addEventListener("error", onLoadingStatusChange);
|
|
5684
|
+
} catch {
|
|
5685
|
+
return previewDone();
|
|
5679
5686
|
}
|
|
5680
5687
|
});
|
|
5681
5688
|
onCleanup(() => {
|
|
@@ -6153,8 +6160,8 @@ var Game = (props) => {
|
|
|
6153
6160
|
children: (src) => {
|
|
6154
6161
|
let img = PRELOADED_IMAGE_MAP.get(src);
|
|
6155
6162
|
if (img) {
|
|
6156
|
-
const
|
|
6157
|
-
return Object.assign(
|
|
6163
|
+
const image = img.isConnected ? img.cloneNode(true) : img;
|
|
6164
|
+
return Object.assign(image, {
|
|
6158
6165
|
className: "background"
|
|
6159
6166
|
});
|
|
6160
6167
|
}
|
|
@@ -6906,7 +6913,7 @@ var createRootComponent = ({
|
|
|
6906
6913
|
return Root;
|
|
6907
6914
|
};
|
|
6908
6915
|
|
|
6909
|
-
// src/custom-actions.ts
|
|
6916
|
+
// src/custom-actions/show-arbitrary-character.ts
|
|
6910
6917
|
var SHOW_ARBITARY_CHARACTER = Symbol();
|
|
6911
6918
|
var createShowArbitraryCharacterAction = (_) => {
|
|
6912
6919
|
const showArbitraryCharacter = (params) => {
|
|
@@ -6925,6 +6932,99 @@ var createShowArbitraryCharacterAction = (_) => {
|
|
|
6925
6932
|
return showArbitraryCharacter;
|
|
6926
6933
|
};
|
|
6927
6934
|
|
|
6935
|
+
// src/custom-actions/show-hide-image.ts
|
|
6936
|
+
var SHOW_IMAGE = Symbol();
|
|
6937
|
+
var showImage = (source, params = {}) => {
|
|
6938
|
+
const handler = ({ getDomNodes, clear, flags, data, rendererContext }) => {
|
|
6939
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
6940
|
+
const { element } = getDomNodes(true);
|
|
6941
|
+
{
|
|
6942
|
+
element.style.cssText += `position: fixed; inset: 0;`;
|
|
6943
|
+
element.style.zIndex = String(params.z || 1);
|
|
6944
|
+
}
|
|
6945
|
+
const image = document.createElement("img");
|
|
6946
|
+
{
|
|
6947
|
+
image.src = source;
|
|
6948
|
+
image.className = params.class || "";
|
|
6949
|
+
image.style.cssText = params.style || "";
|
|
6950
|
+
image.style.cssText += `object-fit: cover; object-position: ${params.position || "50% 50%"}; width: 100vw; height: 100vh;`;
|
|
6951
|
+
}
|
|
6952
|
+
element.appendChild(image);
|
|
6953
|
+
data({
|
|
6954
|
+
image,
|
|
6955
|
+
in: params.in
|
|
6956
|
+
});
|
|
6957
|
+
let clearAnimation = noop;
|
|
6958
|
+
if (params.in && !flags.preview) {
|
|
6959
|
+
const classes = params.in.split(" ");
|
|
6960
|
+
image.classList.add(...classes);
|
|
6961
|
+
clearAnimation = () => {
|
|
6962
|
+
image.classList.remove(...classes);
|
|
6963
|
+
if (params.await) {
|
|
6964
|
+
rendererContext.clearBlockingActions(void 0);
|
|
6965
|
+
resolve();
|
|
6966
|
+
}
|
|
6967
|
+
};
|
|
6968
|
+
image.addEventListener("animationend", clearAnimation, { once: true });
|
|
6969
|
+
}
|
|
6970
|
+
clear(() => {
|
|
6971
|
+
data({});
|
|
6972
|
+
clearAnimation();
|
|
6973
|
+
image.remove();
|
|
6974
|
+
});
|
|
6975
|
+
if (!params.await) {
|
|
6976
|
+
resolve();
|
|
6977
|
+
}
|
|
6978
|
+
return promise;
|
|
6979
|
+
};
|
|
6980
|
+
handler.id = SHOW_IMAGE;
|
|
6981
|
+
handler.key = source;
|
|
6982
|
+
handler.assets = [source];
|
|
6983
|
+
handler.skipOnRestore = (getNext) => {
|
|
6984
|
+
return getNext().some(([name, fn]) => name === "custom" && fn.key === source);
|
|
6985
|
+
};
|
|
6986
|
+
return ["custom", handler];
|
|
6987
|
+
};
|
|
6988
|
+
var hideImage = (source, params = {}) => {
|
|
6989
|
+
const handler = async ({ data, rendererContext }) => {
|
|
6990
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
6991
|
+
const { image, in: inClasses } = data();
|
|
6992
|
+
if (!image) {
|
|
6993
|
+
resolve();
|
|
6994
|
+
return promise;
|
|
6995
|
+
}
|
|
6996
|
+
if (inClasses) {
|
|
6997
|
+
const classes = inClasses.split(" ");
|
|
6998
|
+
image.classList.remove(...classes);
|
|
6999
|
+
}
|
|
7000
|
+
if (params.out) {
|
|
7001
|
+
const classes = params.out.split(" ");
|
|
7002
|
+
image.classList.add(...classes);
|
|
7003
|
+
const onAnimationEnd = () => {
|
|
7004
|
+
image.classList.remove(...classes);
|
|
7005
|
+
if (params.await) {
|
|
7006
|
+
rendererContext.clearBlockingActions(void 0);
|
|
7007
|
+
resolve();
|
|
7008
|
+
}
|
|
7009
|
+
};
|
|
7010
|
+
image.addEventListener("animationend", onAnimationEnd, { once: true });
|
|
7011
|
+
if (!params.await) {
|
|
7012
|
+
resolve();
|
|
7013
|
+
}
|
|
7014
|
+
} else {
|
|
7015
|
+
resolve();
|
|
7016
|
+
}
|
|
7017
|
+
return promise;
|
|
7018
|
+
};
|
|
7019
|
+
handler.id = SHOW_IMAGE;
|
|
7020
|
+
handler.key = source;
|
|
7021
|
+
handler.assets = [source];
|
|
7022
|
+
handler.skipOnRestore = (getNext) => {
|
|
7023
|
+
return getNext().some(([name, fn]) => name === "custom" && fn.key === source);
|
|
7024
|
+
};
|
|
7025
|
+
return ["custom", handler];
|
|
7026
|
+
};
|
|
7027
|
+
|
|
6928
7028
|
// src/renderer.tsx
|
|
6929
7029
|
var _tmpl$31 = /* @__PURE__ */ template(`<canvas>`);
|
|
6930
7030
|
var {
|
|
@@ -7046,16 +7146,18 @@ var createSolidRenderer = ({
|
|
|
7046
7146
|
});
|
|
7047
7147
|
});
|
|
7048
7148
|
},
|
|
7049
|
-
animate(
|
|
7149
|
+
animate(classes) {
|
|
7050
7150
|
const target2 = this.canvas;
|
|
7051
7151
|
if (!target2)
|
|
7052
7152
|
return;
|
|
7053
7153
|
const classNames = classes.filter((className2) => !target2.classList.contains(className2));
|
|
7054
7154
|
target2.classList.add(...classNames);
|
|
7055
|
-
const
|
|
7155
|
+
const onAnimationEnd = () => {
|
|
7056
7156
|
target2.classList.remove(...classNames);
|
|
7057
7157
|
};
|
|
7058
|
-
|
|
7158
|
+
target2.addEventListener("animationend", onAnimationEnd, {
|
|
7159
|
+
once: true
|
|
7160
|
+
});
|
|
7059
7161
|
}
|
|
7060
7162
|
};
|
|
7061
7163
|
useShared(name).characters[character] = characterHandle;
|
|
@@ -7172,7 +7274,9 @@ var createSolidRenderer = ({
|
|
|
7172
7274
|
preloadAudioBlocking
|
|
7173
7275
|
},
|
|
7174
7276
|
actions: {
|
|
7175
|
-
showArbitraryCharacter: createShowArbitraryCharacterAction(options.characters)
|
|
7277
|
+
showArbitraryCharacter: createShowArbitraryCharacterAction(options.characters),
|
|
7278
|
+
showImage,
|
|
7279
|
+
hideImage
|
|
7176
7280
|
}
|
|
7177
7281
|
};
|
|
7178
7282
|
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.34.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": {
|