@novely/solid-renderer 0.29.1-beta.5 → 0.29.1-beta.7

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,3 @@
1
+ import type { FlowComponent } from 'solid-js';
2
+ declare const ShadowRoot: FlowComponent;
3
+ export { ShadowRoot };
package/dist/index.jsx CHANGED
@@ -3828,6 +3828,48 @@ function cleanChildren(parent, current, marker, replacement) {
3828
3828
  }
3829
3829
  var RequestContext = Symbol();
3830
3830
  var isServer = false;
3831
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3832
+ function createElement(tagName, isSVG = false) {
3833
+ return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
3834
+ }
3835
+ function Portal(props) {
3836
+ const { useShadow } = props, marker = document.createTextNode(""), mount = () => props.mount || document.body, owner = getOwner();
3837
+ let content;
3838
+ let hydrating = !!sharedConfig.context;
3839
+ createEffect(
3840
+ () => {
3841
+ if (hydrating)
3842
+ getOwner().user = hydrating = false;
3843
+ content || (content = runWithOwner(owner, () => createMemo(() => props.children)));
3844
+ const el = mount();
3845
+ if (el instanceof HTMLHeadElement) {
3846
+ const [clean2, setClean] = createSignal(false);
3847
+ const cleanup = () => setClean(true);
3848
+ createRoot((dispose2) => insert(el, () => !clean2() ? content() : dispose2(), null));
3849
+ onCleanup(cleanup);
3850
+ } else {
3851
+ const container = createElement(props.isSVG ? "g" : "div", props.isSVG), renderRoot = useShadow && container.attachShadow ? container.attachShadow({
3852
+ mode: "open"
3853
+ }) : container;
3854
+ Object.defineProperty(container, "_$host", {
3855
+ get() {
3856
+ return marker.parentNode;
3857
+ },
3858
+ configurable: true
3859
+ });
3860
+ insert(renderRoot, content);
3861
+ el.appendChild(container);
3862
+ props.ref && props.ref(container);
3863
+ onCleanup(() => el.removeChild(container));
3864
+ }
3865
+ },
3866
+ void 0,
3867
+ {
3868
+ render: !hydrating
3869
+ }
3870
+ );
3871
+ return marker;
3872
+ }
3831
3873
 
3832
3874
  // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/task/index.js
3833
3875
  var tasks = 0;
@@ -4754,12 +4796,12 @@ var handleCustomAction = ($contextState, options, context, fn, resolve) => {
4754
4796
  clear();
4755
4797
  $contextState.mutate((s) => s.custom[fn.key], void 0);
4756
4798
  };
4757
- const createElement = () => {
4799
+ const createElement2 = () => {
4758
4800
  const div = document.createElement("div");
4759
4801
  div.setAttribute("data-id", fn.key);
4760
4802
  return div;
4761
4803
  };
4762
- const element = insert2 ? createElement() : null;
4804
+ const element = insert2 ? createElement2() : null;
4763
4805
  const getReturn = {
4764
4806
  root: context.root,
4765
4807
  element,
@@ -4799,6 +4841,43 @@ var handleClearCustomAction = ($contextState, fn) => {
4799
4841
  if (data)
4800
4842
  data.clear();
4801
4843
  };
4844
+ var handleClearActionAction = ($contextState, preserve) => {
4845
+ if (preserve !== "choice") {
4846
+ $contextState.mutate(
4847
+ (s) => s.choice,
4848
+ {
4849
+ choices: [],
4850
+ visible: false,
4851
+ label: ""
4852
+ }
4853
+ );
4854
+ }
4855
+ if (preserve !== "input") {
4856
+ $contextState.mutate(
4857
+ (s) => s.input,
4858
+ {
4859
+ element: null,
4860
+ label: "",
4861
+ visible: false,
4862
+ error: ""
4863
+ }
4864
+ );
4865
+ }
4866
+ if (preserve !== "text") {
4867
+ $contextState.mutate((s) => s.text, { content: "" });
4868
+ }
4869
+ if (preserve !== "dialog") {
4870
+ $contextState.mutate(
4871
+ (s) => s.dialog,
4872
+ {
4873
+ visible: false,
4874
+ content: "",
4875
+ name: "",
4876
+ miniature: {}
4877
+ }
4878
+ );
4879
+ }
4880
+ };
4802
4881
  var handleTextAction = ($contextState, content, resolve) => {
4803
4882
  $contextState.mutate((s) => s.text, { content, resolve });
4804
4883
  };
@@ -5496,7 +5575,7 @@ var createRetrieved = (fn) => {
5496
5575
 
5497
5576
  // src/components/Save.tsx
5498
5577
  var _tmpl$17 = /* @__PURE__ */ template(`<div class="saves__list-item__overlay">`);
5499
- var _tmpl$24 = /* @__PURE__ */ template(`<iframe loading="lazy" tabindex="-1" class="saves__list-item__iframe">`);
5578
+ var _tmpl$24 = /* @__PURE__ */ template(`<iframe tabindex="-1" class="saves__list-item__iframe" src="about:blank">`);
5500
5579
  var _tmpl$33 = /* @__PURE__ */ template(`<li class="saves__list-item"><div class="saves__list-item__load" role="button" tabindex="0"></div><div class="saves__list-item__description"><div></div><div></div></div><button type="reset" class="button saves__button-reset"><span>`);
5501
5580
  var _tmpl$43 = /* @__PURE__ */ template(`<div class="saves__list-item__iframe">`);
5502
5581
  var CURRENT_DATE = /* @__PURE__ */ new Date();
@@ -5525,18 +5604,6 @@ var Save = (props) => {
5525
5604
  const KEY = `save-${timestamp}-${type}`;
5526
5605
  const $contextState = useContextState(KEY);
5527
5606
  const context = getContext2(KEY);
5528
- const game = createMemo(() => {
5529
- return createComponent(Game, {
5530
- controls: "outside",
5531
- skipTypewriterWhenGoingBack: true,
5532
- $contextState,
5533
- context,
5534
- get store() {
5535
- return useShared(KEY);
5536
- },
5537
- isPreview: true
5538
- });
5539
- });
5540
5607
  const year = date.getFullYear();
5541
5608
  const stringDate = () => capitalize(date.toLocaleDateString(props.language, {
5542
5609
  year: year === CURRENT_YEAR ? void 0 : "numeric",
@@ -5564,7 +5631,6 @@ var Save = (props) => {
5564
5631
  return;
5565
5632
  contentDocument.head.insertAdjacentHTML("beforeend", `<style>:root { font-size: 30%; background: black; cursor: pointer; } * { pointer-events: none; } *, *::before, *::after { animation-play-state: paused !important; }</style><style>${stylesheet()}</style>`);
5566
5633
  context.root = contentDocument.body;
5567
- context.root.appendChild(game());
5568
5634
  setIframeLoaded(true);
5569
5635
  };
5570
5636
  createEffect(() => {
@@ -5595,18 +5661,7 @@ var Save = (props) => {
5595
5661
  });
5596
5662
  }
5597
5663
  });
5598
- createEffect(() => {
5599
- const iframeElement = iframe();
5600
- if (!iframeElement)
5601
- return;
5602
- iframeElement.setAttribute("src", "about:blank");
5603
- iframeElement.addEventListener("load", onIframeLoaded);
5604
- });
5605
5664
  onCleanup(() => {
5606
- const iframeElement = iframe();
5607
- if (iframeElement) {
5608
- iframeElement.removeEventListener("load", onIframeLoaded);
5609
- }
5610
5665
  const state = useContextState(KEY);
5611
5666
  for (const custom of Object.values(state.get().custom)) {
5612
5667
  if (!custom)
@@ -5659,9 +5714,43 @@ var Save = (props) => {
5659
5714
  return _tmpl$43();
5660
5715
  },
5661
5716
  get children() {
5662
- const _el$4 = _tmpl$24();
5663
- use(setIframe, _el$4);
5664
- return _el$4;
5717
+ return [(() => {
5718
+ const _el$4 = _tmpl$24();
5719
+ _el$4.addEventListener("load", () => {
5720
+ onIframeLoaded();
5721
+ });
5722
+ use(setIframe, _el$4);
5723
+ setAttribute(
5724
+ _el$4,
5725
+ "loading",
5726
+ void 0
5727
+ /** "lazy" is broken on Firefox Mobile as of now (06.05.2024) */
5728
+ );
5729
+ return _el$4;
5730
+ })(), createComponent(Show, {
5731
+ get when() {
5732
+ return iframeLoaded();
5733
+ },
5734
+ get children() {
5735
+ return createComponent(Portal, {
5736
+ get mount() {
5737
+ return context.root;
5738
+ },
5739
+ get children() {
5740
+ return createComponent(Game, {
5741
+ controls: "outside",
5742
+ skipTypewriterWhenGoingBack: true,
5743
+ $contextState,
5744
+ context,
5745
+ get store() {
5746
+ return useShared(KEY);
5747
+ },
5748
+ isPreview: true
5749
+ });
5750
+ }
5751
+ });
5752
+ }
5753
+ })];
5665
5754
  }
5666
5755
  }), null);
5667
5756
  setAttribute(_el$6, "aria-hidden", true);
@@ -5959,14 +6048,7 @@ var Game = (props) => {
5959
6048
  const onChoicesButtonClick = ([disabled, i]) => {
5960
6049
  if (disabled)
5961
6050
  return;
5962
- const resolve = choice().resolve;
5963
- $contextState.setKey("choice", {
5964
- choices: [],
5965
- visible: false,
5966
- resolve: void 0,
5967
- label: ""
5968
- });
5969
- resolve(i);
6051
+ choice().resolve?.(i);
5970
6052
  };
5971
6053
  const onInputButtonClick = () => {
5972
6054
  if (input().error)
@@ -5975,14 +6057,6 @@ var Game = (props) => {
5975
6057
  resolve,
5976
6058
  cleanup
5977
6059
  } = input();
5978
- $contextState.setKey("input", {
5979
- element: null,
5980
- label: "",
5981
- error: "",
5982
- visible: false,
5983
- cleanup: void 0,
5984
- resolve: void 0
5985
- });
5986
6060
  cleanup?.();
5987
6061
  resolve?.();
5988
6062
  };
@@ -6004,24 +6078,12 @@ var Game = (props) => {
6004
6078
  };
6005
6079
  const TextWriter = createTypewriter({
6006
6080
  resolve() {
6007
- const resolve = text().resolve;
6008
- $contextState.setKey("text", {
6009
- content: ""
6010
- });
6011
- resolve();
6081
+ text().resolve?.();
6012
6082
  }
6013
6083
  });
6014
6084
  const DialogWriter = createTypewriter({
6015
6085
  resolve() {
6016
- const resolve = dialog().resolve;
6017
- $contextState.setKey("dialog", {
6018
- content: "",
6019
- name: "",
6020
- miniature: {},
6021
- visible: false,
6022
- resolve: void 0
6023
- });
6024
- resolve();
6086
+ dialog().resolve?.();
6025
6087
  }
6026
6088
  });
6027
6089
  const controlPanelMenuID = createUniqueId();
@@ -6998,6 +7060,9 @@ var createSolidRenderer = ({
6998
7060
  clearCustom(fn) {
6999
7061
  handleClearCustomAction($contextState, fn);
7000
7062
  },
7063
+ clearAction(name2) {
7064
+ handleClearActionAction($contextState, name2);
7065
+ },
7001
7066
  vibrate(pattern) {
7002
7067
  handleVibrateAction(pattern);
7003
7068
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.29.1-beta.5",
3
+ "version": "0.29.1-beta.7",
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.0",
23
- "@novely/renderer-toolkit": "0.3.2",
22
+ "@novely/core": "0.33.0-beta.2",
23
+ "@novely/renderer-toolkit": "0.4.0-beta.0",
24
24
  "@novely/typewriter": "0.5.1"
25
25
  },
26
26
  "peerDependencies": {