@novely/solid-renderer 0.29.1-beta.7 → 0.30.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.
Files changed (2) hide show
  1. package/dist/index.jsx +49 -11
  2. package/package.json +3 -3
package/dist/index.jsx CHANGED
@@ -4687,6 +4687,30 @@ var useBackground = (obj, set) => {
4687
4687
  }
4688
4688
  };
4689
4689
  };
4690
+ var allEmpty = (target) => {
4691
+ if (typeof target === "string") {
4692
+ return target == "";
4693
+ }
4694
+ if (typeof target === "number") {
4695
+ return target == 0;
4696
+ }
4697
+ if (!target) {
4698
+ return true;
4699
+ }
4700
+ if (Array.isArray(target) && target.length > 0) {
4701
+ for (const inner of target) {
4702
+ if (!allEmpty(inner)) {
4703
+ return false;
4704
+ }
4705
+ }
4706
+ }
4707
+ for (const value of Object.values(target)) {
4708
+ if (!allEmpty(value)) {
4709
+ return false;
4710
+ }
4711
+ }
4712
+ return true;
4713
+ };
4690
4714
  var handleBackgroundAction = ($contextState, background, onChange) => {
4691
4715
  const { clear } = $contextState.get().background;
4692
4716
  clear && clear();
@@ -4841,8 +4865,9 @@ var handleClearCustomAction = ($contextState, fn) => {
4841
4865
  if (data)
4842
4866
  data.clear();
4843
4867
  };
4844
- var handleClearActionAction = ($contextState, preserve) => {
4845
- if (preserve !== "choice") {
4868
+ var handleClearBlockingActions = ($contextState, preserve) => {
4869
+ const current = $contextState.get();
4870
+ if (preserve !== "choice" && !allEmpty(current.choice)) {
4846
4871
  $contextState.mutate(
4847
4872
  (s) => s.choice,
4848
4873
  {
@@ -4852,7 +4877,7 @@ var handleClearActionAction = ($contextState, preserve) => {
4852
4877
  }
4853
4878
  );
4854
4879
  }
4855
- if (preserve !== "input") {
4880
+ if (preserve !== "input" && !allEmpty(current.input)) {
4856
4881
  $contextState.mutate(
4857
4882
  (s) => s.input,
4858
4883
  {
@@ -4863,10 +4888,10 @@ var handleClearActionAction = ($contextState, preserve) => {
4863
4888
  }
4864
4889
  );
4865
4890
  }
4866
- if (preserve !== "text") {
4891
+ if (preserve !== "text" && !allEmpty(current.text)) {
4867
4892
  $contextState.mutate((s) => s.text, { content: "" });
4868
4893
  }
4869
- if (preserve !== "dialog") {
4894
+ if (preserve !== "dialog" && !allEmpty(current.dialog)) {
4870
4895
  $contextState.mutate(
4871
4896
  (s) => s.dialog,
4872
4897
  {
@@ -6995,20 +7020,33 @@ var createSolidRenderer = ({
6995
7020
  },
6996
7021
  remove(className2, style2, duration, restoring) {
6997
7022
  return new Promise((resolve) => {
7023
+ const hide = () => {
7024
+ $contextState.mutate((s) => s.characters[character], (prev) => {
7025
+ return {
7026
+ ...prev,
7027
+ visible: false
7028
+ };
7029
+ });
7030
+ };
6998
7031
  if (restoring) {
6999
- $contextState.mutate((s) => s.characters[character].visible, false);
7032
+ hide();
7000
7033
  resolve();
7001
7034
  return;
7002
7035
  }
7003
7036
  const timeoutId = setTimeout(() => {
7004
- $contextState.mutate((s) => s.characters[character].visible, false);
7037
+ hide();
7005
7038
  resolve();
7006
7039
  }, duration);
7007
7040
  if (className2) {
7008
7041
  chars[character].canvas.className = className2;
7009
7042
  }
7010
- $contextState.mutate((s) => s.characters[character].style, style2);
7011
- $contextState.mutate((s) => s.characters[character].hideTimeoutId, timeoutId);
7043
+ $contextState.mutate((s) => s.characters[character], (prev) => {
7044
+ return {
7045
+ ...prev,
7046
+ style: style2,
7047
+ hideTimeoutId: timeoutId
7048
+ };
7049
+ });
7012
7050
  });
7013
7051
  },
7014
7052
  animate(timeout, classes) {
@@ -7060,8 +7098,8 @@ var createSolidRenderer = ({
7060
7098
  clearCustom(fn) {
7061
7099
  handleClearCustomAction($contextState, fn);
7062
7100
  },
7063
- clearAction(name2) {
7064
- handleClearActionAction($contextState, name2);
7101
+ clearBlockingActions(name2) {
7102
+ handleClearBlockingActions($contextState, name2);
7065
7103
  },
7066
7104
  vibrate(pattern) {
7067
7105
  handleVibrateAction(pattern);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.29.1-beta.7",
3
+ "version": "0.30.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.33.0-beta.2",
23
- "@novely/renderer-toolkit": "0.4.0-beta.0",
22
+ "@novely/core": "0.33.0",
23
+ "@novely/renderer-toolkit": "0.4.0",
24
24
  "@novely/typewriter": "0.5.1"
25
25
  },
26
26
  "peerDependencies": {