@novely/solid-renderer 0.31.0 → 0.32.1
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/index.jsx +67 -104
- package/package.json +3 -3
package/dist/index.jsx
CHANGED
|
@@ -4238,15 +4238,6 @@ var memo = (input, cb) => {
|
|
|
4238
4238
|
});
|
|
4239
4239
|
return $memoized;
|
|
4240
4240
|
};
|
|
4241
|
-
var getClonedOldValue = (atom2) => {
|
|
4242
|
-
let oldValue;
|
|
4243
|
-
try {
|
|
4244
|
-
oldValue = structuredClone(atom2.value);
|
|
4245
|
-
} catch {
|
|
4246
|
-
oldValue = { ...atom2.value };
|
|
4247
|
-
}
|
|
4248
|
-
return oldValue;
|
|
4249
|
-
};
|
|
4250
4241
|
var usePath = (atomValue, getPath2) => {
|
|
4251
4242
|
const targets = /* @__PURE__ */ new Set();
|
|
4252
4243
|
const path = [];
|
|
@@ -4286,7 +4277,7 @@ var deepAtom = (init) => {
|
|
|
4286
4277
|
if (newValue === value) {
|
|
4287
4278
|
return newValue;
|
|
4288
4279
|
}
|
|
4289
|
-
const
|
|
4280
|
+
const oldValue = $atom.value;
|
|
4290
4281
|
const fakedPath = {
|
|
4291
4282
|
split: () => {
|
|
4292
4283
|
return {
|
|
@@ -4296,8 +4287,8 @@ var deepAtom = (init) => {
|
|
|
4296
4287
|
};
|
|
4297
4288
|
}
|
|
4298
4289
|
};
|
|
4299
|
-
$atom.value =
|
|
4300
|
-
$atom.notify(
|
|
4290
|
+
$atom.value = setPath($atom.value, fakedPath, newValue);
|
|
4291
|
+
$atom.notify(oldValue, path.join("."));
|
|
4301
4292
|
return newValue;
|
|
4302
4293
|
};
|
|
4303
4294
|
return $atom;
|
|
@@ -4715,12 +4706,22 @@ var handleBackgroundAction = ($contextState, background, onChange) => {
|
|
|
4715
4706
|
const { clear } = $contextState.get().background;
|
|
4716
4707
|
clear && clear();
|
|
4717
4708
|
if (typeof background === "string") {
|
|
4718
|
-
$contextState.mutate((s) => s.background
|
|
4709
|
+
$contextState.mutate((s) => s.background, (prev) => {
|
|
4710
|
+
return {
|
|
4711
|
+
...prev,
|
|
4712
|
+
background
|
|
4713
|
+
};
|
|
4714
|
+
});
|
|
4719
4715
|
onChange?.(background);
|
|
4720
4716
|
return;
|
|
4721
4717
|
}
|
|
4722
4718
|
const { dispose: dispose2 } = useBackground(background, (value) => {
|
|
4723
|
-
$contextState.mutate((s) => s.background
|
|
4719
|
+
$contextState.mutate((s) => s.background, (prev) => {
|
|
4720
|
+
return {
|
|
4721
|
+
...prev,
|
|
4722
|
+
background: value
|
|
4723
|
+
};
|
|
4724
|
+
});
|
|
4724
4725
|
onChange?.(value);
|
|
4725
4726
|
});
|
|
4726
4727
|
$contextState.mutate((s) => s.background.clear, () => dispose2);
|
|
@@ -4746,7 +4747,7 @@ var handleChoiceAction = ($contextState, label, choices, resolve) => {
|
|
|
4746
4747
|
{ choices, label, resolve, visible: true }
|
|
4747
4748
|
);
|
|
4748
4749
|
};
|
|
4749
|
-
var handleClearAction = ($rendererState, $contextState, context, keep, keepCharacters) => {
|
|
4750
|
+
var handleClearAction = ($rendererState, $contextState, options, context, keep, keepCharacters) => {
|
|
4750
4751
|
$rendererState.mutate((s) => s.exitPromptShown, false);
|
|
4751
4752
|
if (!keep.has("showBackground")) {
|
|
4752
4753
|
$contextState.mutate((s) => s.background.background, "#000");
|
|
@@ -4802,72 +4803,53 @@ var handleClearAction = ($rendererState, $contextState, context, keep, keepChara
|
|
|
4802
4803
|
);
|
|
4803
4804
|
}
|
|
4804
4805
|
}
|
|
4805
|
-
for (const [id,
|
|
4806
|
-
if (!
|
|
4806
|
+
for (const [id, obj] of Object.entries(custom)) {
|
|
4807
|
+
if (!obj)
|
|
4807
4808
|
continue;
|
|
4808
|
-
if (context.meta.goingBack &&
|
|
4809
|
+
if (context.meta.goingBack && obj.fn.skipClearOnGoingBack)
|
|
4809
4810
|
continue;
|
|
4810
|
-
|
|
4811
|
+
options.clearCustomAction(context, obj.fn);
|
|
4811
4812
|
$contextState.mutate((s) => s.custom[id], void 0);
|
|
4812
4813
|
}
|
|
4813
4814
|
};
|
|
4814
|
-
var handleCustomAction = ($contextState,
|
|
4815
|
-
|
|
4816
|
-
const cached = $contextState.get().custom[fn.key];
|
|
4817
|
-
if (cached) {
|
|
4818
|
-
return cached.getReturn;
|
|
4819
|
-
}
|
|
4820
|
-
let clear = () => {
|
|
4821
|
-
};
|
|
4822
|
-
let store = {};
|
|
4823
|
-
const clearManager = () => {
|
|
4824
|
-
clear();
|
|
4825
|
-
$contextState.mutate((s) => s.custom[fn.key], void 0);
|
|
4826
|
-
};
|
|
4827
|
-
const createElement2 = () => {
|
|
4828
|
-
const div = document.createElement("div");
|
|
4829
|
-
div.setAttribute("data-id", fn.key);
|
|
4830
|
-
return div;
|
|
4831
|
-
};
|
|
4832
|
-
const element = insert2 ? createElement2() : null;
|
|
4833
|
-
const getReturn = {
|
|
4834
|
-
root: context.root,
|
|
4835
|
-
element,
|
|
4836
|
-
remove: clearManager,
|
|
4837
|
-
data(data) {
|
|
4838
|
-
return data ? store = data : store;
|
|
4839
|
-
},
|
|
4840
|
-
clear(cb) {
|
|
4841
|
-
clear = cb;
|
|
4842
|
-
},
|
|
4843
|
-
__internals: {
|
|
4844
|
-
ctx: context
|
|
4845
|
-
}
|
|
4846
|
-
};
|
|
4815
|
+
var handleCustomAction = ($contextState, fn) => {
|
|
4816
|
+
if (!$contextState.get().custom[fn.key]) {
|
|
4847
4817
|
$contextState.mutate(
|
|
4848
4818
|
(s) => s.custom[fn.key],
|
|
4849
4819
|
{
|
|
4850
|
-
dom: element,
|
|
4851
4820
|
fn,
|
|
4852
|
-
|
|
4853
|
-
clear:
|
|
4821
|
+
node: null,
|
|
4822
|
+
clear: noop
|
|
4854
4823
|
}
|
|
4855
4824
|
);
|
|
4856
|
-
|
|
4825
|
+
}
|
|
4826
|
+
return {
|
|
4827
|
+
setMountElement(node) {
|
|
4828
|
+
$contextState.mutate(
|
|
4829
|
+
(s) => s.custom[fn.key],
|
|
4830
|
+
(state) => {
|
|
4831
|
+
return {
|
|
4832
|
+
...state,
|
|
4833
|
+
node
|
|
4834
|
+
};
|
|
4835
|
+
}
|
|
4836
|
+
);
|
|
4837
|
+
},
|
|
4838
|
+
setClear(clear) {
|
|
4839
|
+
$contextState.mutate(
|
|
4840
|
+
(s) => s.custom[fn.key],
|
|
4841
|
+
(state) => {
|
|
4842
|
+
return {
|
|
4843
|
+
...state,
|
|
4844
|
+
clear
|
|
4845
|
+
};
|
|
4846
|
+
}
|
|
4847
|
+
);
|
|
4848
|
+
},
|
|
4849
|
+
remove() {
|
|
4850
|
+
$contextState.mutate((s) => s.custom[fn.key], void 0);
|
|
4851
|
+
}
|
|
4857
4852
|
};
|
|
4858
|
-
const result = fn({
|
|
4859
|
-
...context.meta,
|
|
4860
|
-
lang: options.storageData.get().meta[0],
|
|
4861
|
-
get,
|
|
4862
|
-
state: options.getStateFunction(context.id)
|
|
4863
|
-
});
|
|
4864
|
-
result ? result.then(resolve) : resolve();
|
|
4865
|
-
return result;
|
|
4866
|
-
};
|
|
4867
|
-
var handleClearCustomAction = ($contextState, fn) => {
|
|
4868
|
-
const data = $contextState.get().custom[fn.key];
|
|
4869
|
-
if (data)
|
|
4870
|
-
data.clear();
|
|
4871
4853
|
};
|
|
4872
4854
|
var handleClearBlockingActions = ($contextState, preserve) => {
|
|
4873
4855
|
const current = $contextState.get();
|
|
@@ -5697,7 +5679,7 @@ var Save = (props) => {
|
|
|
5697
5679
|
if (!custom)
|
|
5698
5680
|
continue;
|
|
5699
5681
|
try {
|
|
5700
|
-
custom.
|
|
5682
|
+
options.clearCustomAction(context, custom.fn);
|
|
5701
5683
|
} catch {
|
|
5702
5684
|
}
|
|
5703
5685
|
}
|
|
@@ -6331,7 +6313,7 @@ var Game = (props) => {
|
|
|
6331
6313
|
get each() {
|
|
6332
6314
|
return customs();
|
|
6333
6315
|
},
|
|
6334
|
-
children: (value) => value.
|
|
6316
|
+
children: (value) => value.node
|
|
6335
6317
|
}));
|
|
6336
6318
|
addEventListener2(_el$27, "keydown", onKey(TextWriter.clear, " "), true);
|
|
6337
6319
|
addEventListener2(_el$27, "keypress", onKey(TextWriter.clear, "Enter"));
|
|
@@ -6922,11 +6904,9 @@ var createRootComponent = ({
|
|
|
6922
6904
|
var SHOW_ARBITARY_CHARACTER = Symbol();
|
|
6923
6905
|
var createShowArbitraryCharacterAction = (_) => {
|
|
6924
6906
|
const showArbitraryCharacter = (params) => {
|
|
6925
|
-
const handler = ({
|
|
6926
|
-
const
|
|
6927
|
-
|
|
6928
|
-
const handle = ctx.character(params.id);
|
|
6929
|
-
handle.append(params.classes, params.style, ctx.meta.restoring);
|
|
6907
|
+
const handler = ({ rendererContext }) => {
|
|
6908
|
+
const handle = rendererContext.character(params.id);
|
|
6909
|
+
handle.append(params.classes, params.style, rendererContext.meta.restoring);
|
|
6930
6910
|
handle.emotion(params.emotion, true);
|
|
6931
6911
|
const extension = ((e) => Array.isArray(e) ? e : [e])(params.extendWith());
|
|
6932
6912
|
canvasDrawImages(handle.canvas, handle.ctx, extension.map((src) => PRELOADED_IMAGE_MAP.get(src) || createImage(src)));
|
|
@@ -7059,29 +7039,15 @@ var createSolidRenderer = ({
|
|
|
7059
7039
|
});
|
|
7060
7040
|
},
|
|
7061
7041
|
animate(timeout, classes) {
|
|
7062
|
-
const
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
if (!target2)
|
|
7070
|
-
return;
|
|
7071
|
-
const classNames = classes.filter((className2) => !target2.classList.contains(className2));
|
|
7072
|
-
target2.classList.add(...classNames);
|
|
7073
|
-
const removeClassNames = () => {
|
|
7074
|
-
target2.classList.remove(...classNames);
|
|
7075
|
-
};
|
|
7076
|
-
const timeoutId = setTimeout(removeClassNames, timeout);
|
|
7077
|
-
clear(() => {
|
|
7078
|
-
removeClassNames();
|
|
7079
|
-
clearTimeout(timeoutId);
|
|
7080
|
-
});
|
|
7042
|
+
const target2 = this.canvas;
|
|
7043
|
+
if (!target2)
|
|
7044
|
+
return;
|
|
7045
|
+
const classNames = classes.filter((className2) => !target2.classList.contains(className2));
|
|
7046
|
+
target2.classList.add(...classNames);
|
|
7047
|
+
const removeClassNames = () => {
|
|
7048
|
+
target2.classList.remove(...classNames);
|
|
7081
7049
|
};
|
|
7082
|
-
|
|
7083
|
-
context.custom(handler, () => {
|
|
7084
|
-
});
|
|
7050
|
+
setTimeout(removeClassNames, timeout);
|
|
7085
7051
|
}
|
|
7086
7052
|
};
|
|
7087
7053
|
useShared(name).characters[character] = characterHandle;
|
|
@@ -7094,18 +7060,15 @@ var createSolidRenderer = ({
|
|
|
7094
7060
|
handleChoiceAction($contextState, label, choices, resolve);
|
|
7095
7061
|
},
|
|
7096
7062
|
clear(keep, keepCharacters, keepAudio, resolve) {
|
|
7097
|
-
handleClearAction($rendererState, $contextState, context, keep, keepCharacters);
|
|
7063
|
+
handleClearAction($rendererState, $contextState, options, context, keep, keepCharacters);
|
|
7098
7064
|
audio.clear(keepAudio);
|
|
7099
7065
|
resolve();
|
|
7100
7066
|
},
|
|
7101
7067
|
input(label, onInput, setup, resolve) {
|
|
7102
7068
|
handleInputAction($contextState, options, context, label, onInput, setup, resolve);
|
|
7103
7069
|
},
|
|
7104
|
-
custom(fn
|
|
7105
|
-
return handleCustomAction($contextState,
|
|
7106
|
-
},
|
|
7107
|
-
clearCustom(fn) {
|
|
7108
|
-
handleClearCustomAction($contextState, fn);
|
|
7070
|
+
custom(fn) {
|
|
7071
|
+
return handleCustomAction($contextState, fn);
|
|
7109
7072
|
},
|
|
7110
7073
|
clearBlockingActions(name2) {
|
|
7111
7074
|
handleClearBlockingActions($contextState, name2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/solid-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
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.35.0",
|
|
23
|
+
"@novely/renderer-toolkit": "0.6.1",
|
|
24
24
|
"@novely/typewriter": "0.5.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|