@novely/solid-renderer 0.30.2 → 0.32.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.
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 oldMap = getClonedOldValue($atom);
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 = { ...setPath($atom.value, fakedPath, newValue) };
4300
- $atom.notify(oldMap, path.join("."));
4290
+ $atom.value = setPath($atom.value, fakedPath, newValue);
4291
+ $atom.notify(oldValue, path.join("."));
4301
4292
  return newValue;
4302
4293
  };
4303
4294
  return $atom;
@@ -4746,7 +4737,7 @@ var handleChoiceAction = ($contextState, label, choices, resolve) => {
4746
4737
  { choices, label, resolve, visible: true }
4747
4738
  );
4748
4739
  };
4749
- var handleClearAction = ($rendererState, $contextState, context, keep, keepCharacters) => {
4740
+ var handleClearAction = ($rendererState, $contextState, options, context, keep, keepCharacters) => {
4750
4741
  $rendererState.mutate((s) => s.exitPromptShown, false);
4751
4742
  if (!keep.has("showBackground")) {
4752
4743
  $contextState.mutate((s) => s.background.background, "#000");
@@ -4761,6 +4752,10 @@ var handleClearAction = ($rendererState, $contextState, context, keep, keepChara
4761
4752
  }
4762
4753
  );
4763
4754
  }
4755
+ const inputCleanup = $contextState.get().input.cleanup;
4756
+ if (inputCleanup) {
4757
+ inputCleanup();
4758
+ }
4764
4759
  if (!keep.has("input")) {
4765
4760
  $contextState.mutate(
4766
4761
  (s) => s.input,
@@ -4798,72 +4793,53 @@ var handleClearAction = ($rendererState, $contextState, context, keep, keepChara
4798
4793
  );
4799
4794
  }
4800
4795
  }
4801
- for (const [id, handler] of Object.entries(custom)) {
4802
- if (!handler)
4796
+ for (const [id, obj] of Object.entries(custom)) {
4797
+ if (!obj)
4803
4798
  continue;
4804
- if (context.meta.goingBack && handler.fn.skipClearOnGoingBack)
4799
+ if (context.meta.goingBack && obj.fn.skipClearOnGoingBack)
4805
4800
  continue;
4806
- handler.clear();
4801
+ options.clearCustomAction(context, obj.fn);
4807
4802
  $contextState.mutate((s) => s.custom[id], void 0);
4808
4803
  }
4809
4804
  };
4810
- var handleCustomAction = ($contextState, options, context, fn, resolve) => {
4811
- const get = (insert2 = true) => {
4812
- const cached = $contextState.get().custom[fn.key];
4813
- if (cached) {
4814
- return cached.getReturn;
4815
- }
4816
- let clear = () => {
4817
- };
4818
- let store = {};
4819
- const clearManager = () => {
4820
- clear();
4821
- $contextState.mutate((s) => s.custom[fn.key], void 0);
4822
- };
4823
- const createElement2 = () => {
4824
- const div = document.createElement("div");
4825
- div.setAttribute("data-id", fn.key);
4826
- return div;
4827
- };
4828
- const element = insert2 ? createElement2() : null;
4829
- const getReturn = {
4830
- root: context.root,
4831
- element,
4832
- remove: clearManager,
4833
- data(data) {
4834
- return data ? store = data : store;
4835
- },
4836
- clear(cb) {
4837
- clear = cb;
4838
- },
4839
- __internals: {
4840
- ctx: context
4841
- }
4842
- };
4805
+ var handleCustomAction = ($contextState, fn) => {
4806
+ if (!$contextState.get().custom[fn.key]) {
4843
4807
  $contextState.mutate(
4844
4808
  (s) => s.custom[fn.key],
4845
4809
  {
4846
- dom: element,
4847
4810
  fn,
4848
- getReturn,
4849
- clear: clearManager
4811
+ node: null,
4812
+ clear: noop
4850
4813
  }
4851
4814
  );
4852
- return getReturn;
4815
+ }
4816
+ return {
4817
+ setMountElement(node) {
4818
+ $contextState.mutate(
4819
+ (s) => s.custom[fn.key],
4820
+ (state) => {
4821
+ return {
4822
+ ...state,
4823
+ node
4824
+ };
4825
+ }
4826
+ );
4827
+ },
4828
+ setClear(clear) {
4829
+ $contextState.mutate(
4830
+ (s) => s.custom[fn.key],
4831
+ (state) => {
4832
+ return {
4833
+ ...state,
4834
+ clear
4835
+ };
4836
+ }
4837
+ );
4838
+ },
4839
+ remove() {
4840
+ $contextState.mutate((s) => s.custom[fn.key], void 0);
4841
+ }
4853
4842
  };
4854
- const result = fn({
4855
- ...context.meta,
4856
- lang: options.storageData.get().meta[0],
4857
- get,
4858
- state: options.getStateFunction(context.id)
4859
- });
4860
- result ? result.then(resolve) : resolve();
4861
- return result;
4862
- };
4863
- var handleClearCustomAction = ($contextState, fn) => {
4864
- const data = $contextState.get().custom[fn.key];
4865
- if (data)
4866
- data.clear();
4867
4843
  };
4868
4844
  var handleClearBlockingActions = ($contextState, preserve) => {
4869
4845
  const current = $contextState.get();
@@ -4931,7 +4907,6 @@ var handleInputAction = ($contextState, options, context, label, onInput, setup,
4931
4907
  input.setAttribute("required", "true");
4932
4908
  input.setAttribute("autocomplete", "off");
4933
4909
  !context.meta.preview && input.addEventListener("input", onInputHandler);
4934
- setup(input, (callback) => $contextState.mutate((s) => s.input.cleanup, () => callback));
4935
4910
  $contextState.mutate(
4936
4911
  (s) => s.input,
4937
4912
  {
@@ -4939,6 +4914,7 @@ var handleInputAction = ($contextState, options, context, label, onInput, setup,
4939
4914
  label,
4940
4915
  error: "",
4941
4916
  visible: true,
4917
+ cleanup: setup(input) || noop,
4942
4918
  resolve
4943
4919
  }
4944
4920
  );
@@ -5693,7 +5669,7 @@ var Save = (props) => {
5693
5669
  if (!custom)
5694
5670
  continue;
5695
5671
  try {
5696
- custom.clear();
5672
+ options.clearCustomAction(context, custom.fn);
5697
5673
  } catch {
5698
5674
  }
5699
5675
  }
@@ -6044,7 +6020,7 @@ function destructure(source, options) {
6044
6020
  // src/screens/game.tsx
6045
6021
  var _tmpl$19 = /* @__PURE__ */ template(`<div class="action-dialog-person">`);
6046
6022
  var _tmpl$25 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-panel"><span class="dialog-panel-label">`);
6047
- var _tmpl$34 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-panel input-dialog-panel"><label for="novely-input" class="input-dialog-label"><span></span><span aria-live="polite" aria-atomic="true"></span></label><button type="submit" class="button dialog-input__button">`);
6023
+ var _tmpl$34 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-panel input-dialog-panel"><label for="novely-input" class="input-dialog-label"><span class="input-dialog-label-text"></span></label><span class="input-dialog-label-text input-dialog-label__error" aria-live="polite" aria-atomic="true"></span><button type="submit" class="button dialog-input__button">`);
6048
6024
  var _tmpl$44 = /* @__PURE__ */ template(`<div class="dialog-container"><span class="dialog-fix" aria-hidden="true">&#8203;</span><div class="dialog-backdrop"></div><div class="dialog-panel exit-dialog-panel"><span class="dialog-panel-label"></span><div class="exit-dialog-panel-buttons"><button type="button" class="button"></button><button type="button" class="button">`);
6049
6025
  var _tmpl$53 = /* @__PURE__ */ template(`<button type="button" class="button control-panel__button">`);
6050
6026
  var _tmpl$62 = /* @__PURE__ */ template(`<span class="control-panel-container-fix" aria-hidden="true">&#8203;`);
@@ -6295,9 +6271,9 @@ var Game = (props) => {
6295
6271
  isOpen: () => input().visible,
6296
6272
  trapFocus: () => !props.isPreview && !rendererState().exitPromptShown,
6297
6273
  get children() {
6298
- const _el$11 = _tmpl$34(), _el$12 = _el$11.firstChild, _el$13 = _el$12.nextSibling, _el$14 = _el$13.firstChild, _el$15 = _el$14.firstChild, _el$16 = _el$15.nextSibling, _el$17 = _el$14.nextSibling;
6274
+ const _el$11 = _tmpl$34(), _el$12 = _el$11.firstChild, _el$13 = _el$12.nextSibling, _el$14 = _el$13.firstChild, _el$15 = _el$14.firstChild, _el$16 = _el$14.nextSibling, _el$17 = _el$16.nextSibling;
6299
6275
  insert(_el$15, () => input().label);
6300
- insert(_el$14, () => input().element, _el$16);
6276
+ insert(_el$14, () => input().element, null);
6301
6277
  insert(_el$16, () => input().error);
6302
6278
  _el$17.$$click = onInputButtonClick;
6303
6279
  insert(_el$17, () => data.t("Sumbit"));
@@ -6327,7 +6303,7 @@ var Game = (props) => {
6327
6303
  get each() {
6328
6304
  return customs();
6329
6305
  },
6330
- children: (value) => value.dom
6306
+ children: (value) => value.node
6331
6307
  }));
6332
6308
  addEventListener2(_el$27, "keydown", onKey(TextWriter.clear, " "), true);
6333
6309
  addEventListener2(_el$27, "keypress", onKey(TextWriter.clear, "Enter"));
@@ -6918,11 +6894,9 @@ var createRootComponent = ({
6918
6894
  var SHOW_ARBITARY_CHARACTER = Symbol();
6919
6895
  var createShowArbitraryCharacterAction = (_) => {
6920
6896
  const showArbitraryCharacter = (params) => {
6921
- const handler = ({ get }) => {
6922
- const { __internals } = get(false);
6923
- const { ctx } = __internals;
6924
- const handle = ctx.character(params.id);
6925
- handle.append(params.classes, params.style, ctx.meta.restoring);
6897
+ const handler = ({ rendererContext }) => {
6898
+ const handle = rendererContext.character(params.id);
6899
+ handle.append(params.classes, params.style, rendererContext.meta.restoring);
6926
6900
  handle.emotion(params.emotion, true);
6927
6901
  const extension = ((e) => Array.isArray(e) ? e : [e])(params.extendWith());
6928
6902
  canvasDrawImages(handle.canvas, handle.ctx, extension.map((src) => PRELOADED_IMAGE_MAP.get(src) || createImage(src)));
@@ -7055,29 +7029,15 @@ var createSolidRenderer = ({
7055
7029
  });
7056
7030
  },
7057
7031
  animate(timeout, classes) {
7058
- const handler = ({
7059
- get
7060
- }) => {
7061
- const {
7062
- clear
7063
- } = get(false);
7064
- const target2 = this.canvas;
7065
- if (!target2)
7066
- return;
7067
- const classNames = classes.filter((className2) => !target2.classList.contains(className2));
7068
- target2.classList.add(...classNames);
7069
- const removeClassNames = () => {
7070
- target2.classList.remove(...classNames);
7071
- };
7072
- const timeoutId = setTimeout(removeClassNames, timeout);
7073
- clear(() => {
7074
- removeClassNames();
7075
- clearTimeout(timeoutId);
7076
- });
7032
+ const target2 = this.canvas;
7033
+ if (!target2)
7034
+ return;
7035
+ const classNames = classes.filter((className2) => !target2.classList.contains(className2));
7036
+ target2.classList.add(...classNames);
7037
+ const removeClassNames = () => {
7038
+ target2.classList.remove(...classNames);
7077
7039
  };
7078
- handler.key = "@@internal-animate-character";
7079
- context.custom(handler, () => {
7080
- });
7040
+ setTimeout(removeClassNames, timeout);
7081
7041
  }
7082
7042
  };
7083
7043
  useShared(name).characters[character] = characterHandle;
@@ -7090,18 +7050,15 @@ var createSolidRenderer = ({
7090
7050
  handleChoiceAction($contextState, label, choices, resolve);
7091
7051
  },
7092
7052
  clear(keep, keepCharacters, keepAudio, resolve) {
7093
- handleClearAction($rendererState, $contextState, context, keep, keepCharacters);
7053
+ handleClearAction($rendererState, $contextState, options, context, keep, keepCharacters);
7094
7054
  audio.clear(keepAudio);
7095
7055
  resolve();
7096
7056
  },
7097
7057
  input(label, onInput, setup, resolve) {
7098
7058
  handleInputAction($contextState, options, context, label, onInput, setup, resolve);
7099
7059
  },
7100
- custom(fn, resolve) {
7101
- return handleCustomAction($contextState, options, context, fn, resolve);
7102
- },
7103
- clearCustom(fn) {
7104
- handleClearCustomAction($contextState, fn);
7060
+ custom(fn) {
7061
+ return handleCustomAction($contextState, fn);
7105
7062
  },
7106
7063
  clearBlockingActions(name2) {
7107
7064
  handleClearBlockingActions($contextState, name2);
@@ -610,18 +610,35 @@
610
610
  font-size: 1.2375rem;
611
611
  display: flex;
612
612
  }
613
- .input-dialog-label > span {
613
+ .input-dialog-label-text {
614
614
  min-height: 1rem;
615
615
  -webkit-tap-highlight-color: #0000;
616
616
  -webkit-tap-highlight-color: transparent;
617
617
  -webkit-touch-callout: none;
618
+ text-align: center;
619
+ width: 40vw;
618
620
  min-height: 1lh;
619
621
  margin: .4rem 0;
622
+ font-size: 1.2375rem;
620
623
  }
621
624
  .input-dialog-label > input {
622
625
  min-width: min(10rem, 100%);
623
626
  max-width: 100%;
624
627
  }
628
+ .input-dialog-label:has(input[type=checkbox]) {
629
+ flex-direction: row;
630
+ gap: 1.25rem;
631
+ }
632
+ .input-dialog-label:has(input[type=checkbox]) .input-dialog-label-text {
633
+ width: auto;
634
+ }
635
+ .input-dialog-label > input[type=checkbox] {
636
+ min-width: unset;
637
+ }
638
+ .input-dialog-label__error {
639
+ min-height: 2rem;
640
+ min-height: 2lh;
641
+ }
625
642
  .input-dialog-panel {
626
643
  color: var(--novely-input-dialog-color, #fff);
627
644
  border: var(--novely-input-dialog-border-width, .18rem) solid var(--novely-input-dialog-border-color, #fff);
@@ -633,6 +650,30 @@
633
650
  background-size: var(--novely-input-dialog-background-size, 6.25rem 6.25rem);
634
651
  justify-content: center;
635
652
  align-items: center;
653
+ min-width: 35vw;
654
+ }
655
+ @media (max-aspect-ratio: .8) {
656
+ .input-dialog-label-text {
657
+ width: calc(100vw - .5rem);
658
+ }
659
+ .input-dialog-label__error {
660
+ min-height: 3rem;
661
+ min-height: 3lh;
662
+ }
663
+ }
664
+
665
+ /* src/styles/input-dialog/input/input.css */
666
+ input[name=novely-input] {
667
+ border: none;
668
+ border-radius: .25rem;
669
+ padding: .25rem;
670
+ display: block;
671
+ position: relative;
672
+ }
673
+ input[name=novely-input][type=text],
674
+ input[name=novely-input][type=number],
675
+ input[name=novely-input][type=password] {
676
+ box-shadow: 0 0 0 var(--input-box-shadow-spread-radius, .15rem) var(--novely-input-border-color, #ffc7df);
636
677
  }
637
678
 
638
679
  /* src/styles/input-dialog/button/button.css */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.30.2",
3
+ "version": "0.32.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -19,9 +19,9 @@
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.3",
23
- "@novely/renderer-toolkit": "0.4.0",
24
- "@novely/typewriter": "0.5.1"
22
+ "@novely/core": "0.35.0",
23
+ "@novely/typewriter": "0.5.1",
24
+ "@novely/renderer-toolkit": "0.6.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@novely/core": "*",