@novely/solid-renderer 0.38.0 → 0.39.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
@@ -623,19 +623,6 @@ function createProvider(id, options) {
623
623
  return res;
624
624
  };
625
625
  }
626
- function from(producer) {
627
- const [s, set] = createSignal(void 0, {
628
- equals: false
629
- });
630
- if ("subscribe" in producer) {
631
- const unsub = producer.subscribe((v) => set(() => v));
632
- onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
633
- } else {
634
- const clean2 = producer(set);
635
- onCleanup(clean2);
636
- }
637
- return s;
638
- }
639
626
  var FALLBACK = Symbol("fallback");
640
627
  function dispose(d) {
641
628
  for (let i = 0; i < d.length; i++) d[i]();
@@ -2882,6 +2869,7 @@ var handleInputAction = ($contextState, options, context, label, onInput, setup,
2882
2869
  const input = document.createElement("input");
2883
2870
  input.setAttribute("type", "text");
2884
2871
  input.setAttribute("name", "novely-input");
2872
+ input.setAttribute("id", "novely-input");
2885
2873
  input.setAttribute("required", "true");
2886
2874
  input.setAttribute("autocomplete", "off");
2887
2875
  !context.meta.preview && input.addEventListener("input", onInputHandler);
@@ -3079,6 +3067,13 @@ var createRetrieved = (fn) => {
3079
3067
  return value;
3080
3068
  };
3081
3069
  };
3070
+ var from = (producer) => {
3071
+ const [s, set] = createSignal(producer.get(), {
3072
+ equals: false
3073
+ });
3074
+ onCleanup(producer.subscribe(set));
3075
+ return s;
3076
+ };
3082
3077
 
3083
3078
  // src/hooks/useMedia.ts
3084
3079
  var useMedia = (media) => {
@@ -4145,27 +4140,19 @@ function destructure(source, options) {
4145
4140
  // src/screens/game.tsx
4146
4141
  var _tmpl$27 = /* @__PURE__ */ template(`<div class="action-dialog-person">`);
4147
4142
  var _tmpl$28 = /* @__PURE__ */ template(`<span class="dialog-label">`);
4148
- var _tmpl$34 = /* @__PURE__ */ template(`<label for="novely-input" class="input-dialog-label"><span class="input-dialog-label-text">`);
4149
- var _tmpl$44 = /* @__PURE__ */ template(`<span class="input-dialog-label-text input-dialog-label__error" aria-live="polite" aria-atomic="true">`);
4150
- var _tmpl$53 = /* @__PURE__ */ template(`<button type="submit" class="button dialog-input__button">`);
4151
- var _tmpl$62 = /* @__PURE__ */ template(`<div class="exit-dialog-buttons"><button type="button" class="button"></button><button type="button" class="button">`);
4152
- var _tmpl$72 = /* @__PURE__ */ template(`<button type="button" class="button control-panel__button">`);
4153
- var _tmpl$82 = /* @__PURE__ */ template(`<span class="control-panel-container-fix" aria-hidden="true">&#8203;`);
4154
- var _tmpl$92 = /* @__PURE__ */ template(`<div class="control-panel-container-backdrop">`);
4155
- var _tmpl$102 = /* @__PURE__ */ template(`<div class="control-panel"><div role="menubar" class="control-panel-container">`);
4156
- var _tmpl$112 = /* @__PURE__ */ template(`<div><div class="characters"></div><div class="action-dialog"><div class="action-dialog-container" role="button" tabindex="0"><div class="action-dialog-content"></div></div></div><div></div><div class="action-text" role="button" tabindex="0">`);
4157
- var _tmpl$122 = /* @__PURE__ */ template(`<button type="button" class="button">`);
4143
+ var _tmpl$34 = /* @__PURE__ */ template(`<div class="choice-dialog__choices">`);
4144
+ var _tmpl$44 = /* @__PURE__ */ template(`<label for="novely-input" class="input-dialog__text input-dialog__label">`);
4145
+ var _tmpl$53 = /* @__PURE__ */ template(`<span class="input-dialog__text input-dialog__error" aria-live="polite" aria-atomic="true">`);
4146
+ var _tmpl$62 = /* @__PURE__ */ template(`<button type="submit" class="button dialog-input__button">`);
4147
+ var _tmpl$72 = /* @__PURE__ */ template(`<div class="exit-dialog-buttons"><button type="button" class="button"></button><button type="button" class="button">`);
4148
+ var _tmpl$82 = /* @__PURE__ */ template(`<button type="button" class="button control-panel__button">`);
4149
+ var _tmpl$92 = /* @__PURE__ */ template(`<span class="control-panel-container-fix" aria-hidden="true">&#8203;`);
4150
+ var _tmpl$102 = /* @__PURE__ */ template(`<div class="control-panel-container-backdrop">`);
4151
+ var _tmpl$112 = /* @__PURE__ */ template(`<div class="control-panel"><div role="menubar" class="control-panel-container">`);
4152
+ var _tmpl$122 = /* @__PURE__ */ template(`<div><div class="characters"></div><div class="action-dialog"><div class="action-dialog-container" role="button" tabindex="0"><div class="action-dialog-content"></div></div></div><div></div><div class="action-text" role="button" tabindex="0">`);
4153
+ var _tmpl$132 = /* @__PURE__ */ template(`<button type="button" class="button choice-dialog__choice"><span>`);
4158
4154
  var Game = (props) => {
4159
4155
  const data = useData();
4160
- const {
4161
- $contextState
4162
- } = props;
4163
- const contextState = () => {
4164
- const accessor = from($contextState);
4165
- return () => {
4166
- return accessor();
4167
- };
4168
- };
4169
4156
  const {
4170
4157
  text,
4171
4158
  dialog,
@@ -4174,7 +4161,7 @@ var Game = (props) => {
4174
4161
  input,
4175
4162
  background,
4176
4163
  custom
4177
- } = destructure(contextState());
4164
+ } = destructure(from(props.$contextState));
4178
4165
  const rendererState = from(data.$rendererState);
4179
4166
  const exitPromptShown = () => rendererState().exitPromptShown;
4180
4167
  const {
@@ -4238,7 +4225,7 @@ var Game = (props) => {
4238
4225
  }, 0);
4239
4226
  });
4240
4227
  return (() => {
4241
- const _el$ = _tmpl$112(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$6 = _el$4.firstChild, _el$16 = _el$3.nextSibling, _el$17 = _el$16.nextSibling;
4228
+ const _el$ = _tmpl$122(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$6 = _el$4.firstChild, _el$16 = _el$3.nextSibling, _el$17 = _el$16.nextSibling;
4242
4229
  insert(_el$, createComponent(Canvas, {
4243
4230
  "class": "background",
4244
4231
  resize: false,
@@ -4363,23 +4350,45 @@ var Game = (props) => {
4363
4350
  _v$2: void 0
4364
4351
  });
4365
4352
  return _el$7;
4366
- })(), createComponent(For, {
4367
- get each() {
4368
- return choice().choices;
4369
- },
4370
- children: ([text2, active], i) => {
4371
- const disabled = !active;
4372
- const index = i();
4373
- return (() => {
4374
- const _el$23 = _tmpl$122();
4375
- _el$23.$$click = onChoicesButtonClick;
4376
- _el$23.$$clickData = [disabled, index];
4377
- setAttribute(_el$23, "aria-disabled", disabled);
4378
- insert(_el$23, text2);
4379
- return _el$23;
4380
- })();
4381
- }
4382
- })];
4353
+ })(), (() => {
4354
+ const _el$8 = _tmpl$34();
4355
+ insert(_el$8, createComponent(For, {
4356
+ get each() {
4357
+ return choice().choices;
4358
+ },
4359
+ children: ([text2, active, visible, image], i) => {
4360
+ const disabled = !active;
4361
+ const index = i();
4362
+ return createComponent(Show, {
4363
+ when: visible,
4364
+ get children() {
4365
+ const _el$23 = _tmpl$132(), _el$24 = _el$23.firstChild;
4366
+ _el$23.$$click = onChoicesButtonClick;
4367
+ _el$23.$$clickData = [disabled, index];
4368
+ setAttribute(_el$23, "aria-disabled", disabled);
4369
+ insert(_el$24, text2);
4370
+ insert(_el$23, createComponent(Show, {
4371
+ when: image !== "",
4372
+ get children() {
4373
+ return createComponent(Canvas, {
4374
+ "class": "choice-dialog__choice-image",
4375
+ resize: false,
4376
+ render: async (canvas, ctx) => {
4377
+ const img = await imagePreloadWithCaching(image);
4378
+ canvas.width = img.width;
4379
+ canvas.height = img.height;
4380
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
4381
+ }
4382
+ });
4383
+ }
4384
+ }), null);
4385
+ return _el$23;
4386
+ }
4387
+ });
4388
+ }
4389
+ }));
4390
+ return _el$8;
4391
+ })()];
4383
4392
  }
4384
4393
  }), _el$16);
4385
4394
  insert(_el$, createComponent(Modal, {
@@ -4392,16 +4401,15 @@ var Game = (props) => {
4392
4401
  trapFocus: () => !props.isPreview && !exitPromptShown(),
4393
4402
  get children() {
4394
4403
  return [(() => {
4395
- const _el$8 = _tmpl$34(), _el$9 = _el$8.firstChild;
4404
+ const _el$9 = _tmpl$44();
4396
4405
  insert(_el$9, () => input().label);
4397
- insert(_el$8, () => input().element, null);
4398
- return _el$8;
4399
- })(), (() => {
4400
- const _el$10 = _tmpl$44();
4406
+ return _el$9;
4407
+ })(), createMemo(() => input().element), (() => {
4408
+ const _el$10 = _tmpl$53();
4401
4409
  insert(_el$10, () => input().error);
4402
4410
  return _el$10;
4403
4411
  })(), (() => {
4404
- const _el$11 = _tmpl$53();
4412
+ const _el$11 = _tmpl$62();
4405
4413
  _el$11.$$click = onInputButtonClick;
4406
4414
  insert(_el$11, () => data.t("Sumbit"));
4407
4415
  createRenderEffect(() => setAttribute(_el$11, "aria-disabled", Boolean(input().error)));
@@ -4420,7 +4428,7 @@ var Game = (props) => {
4420
4428
  insert(_el$12, () => data.t("ExitDialogWarning"));
4421
4429
  return _el$12;
4422
4430
  })(), (() => {
4423
- const _el$13 = _tmpl$62(), _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
4431
+ const _el$13 = _tmpl$72(), _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
4424
4432
  _el$14.$$click = () => {
4425
4433
  data.$rendererState.setKey("exitPromptShown", false);
4426
4434
  };
@@ -4467,7 +4475,7 @@ var Game = (props) => {
4467
4475
  return !props.isPreview;
4468
4476
  },
4469
4477
  get children() {
4470
- const _el$18 = _tmpl$102(), _el$22 = _el$18.firstChild;
4478
+ const _el$18 = _tmpl$112(), _el$22 = _el$18.firstChild;
4471
4479
  insert(_el$18, createComponent(Show, {
4472
4480
  get when() {
4473
4481
  return data.media.hyperWide();
@@ -4478,7 +4486,7 @@ var Game = (props) => {
4478
4486
  return !controlPanelMenuExpanded();
4479
4487
  },
4480
4488
  get children() {
4481
- const _el$19 = _tmpl$72();
4489
+ const _el$19 = _tmpl$82();
4482
4490
  _el$19.$$click = () => {
4483
4491
  setControlPanelMenuExpanded((prev) => !prev);
4484
4492
  };
@@ -4507,7 +4515,7 @@ var Game = (props) => {
4507
4515
  return createMemo(() => !!(data.media.hyperWide() && controlPanelMenuExpanded()))() && !exitPromptShown();
4508
4516
  },
4509
4517
  get children() {
4510
- return [_tmpl$82(), _tmpl$92()];
4518
+ return [_tmpl$92(), _tmpl$102()];
4511
4519
  }
4512
4520
  }), _el$22);
4513
4521
  use((element) => {
@@ -614,18 +614,34 @@
614
614
  border: none;
615
615
  }
616
616
 
617
- /* src/styles/choice-dialog/index.css */
618
-
619
- /* src/styles/input-dialog/input-dialog.css */
620
- .input-dialog-label {
617
+ /* src/styles/choice-dialog/choices.css */
618
+ .choice-dialog__choices {
621
619
  flex-direction: column;
622
- justify-content: center;
623
- align-items: center;
624
620
  width: 100%;
625
- font-size: 1.2375rem;
621
+ height: 100%;
622
+ display: flex;
623
+ }
624
+ .choice-dialog__choices:has(.choice-dialog__choice-image) {
625
+ flex-direction: row;
626
+ gap: .5rem;
627
+ }
628
+ .choice-dialog__choice {
629
+ flex-direction: column;
630
+ align-items: center;
626
631
  display: flex;
627
632
  }
628
- .input-dialog-label-text {
633
+ .choice-dialog__choice:has(.choice-dialog__choice-image) {
634
+ flex-grow: 1;
635
+ }
636
+ .choice-dialog__choice-image {
637
+ max-width: 25vw;
638
+ max-height: 25vh;
639
+ }
640
+
641
+ /* src/styles/choice-dialog/index.css */
642
+
643
+ /* src/styles/input-dialog/input-dialog.css */
644
+ .input-dialog__text {
629
645
  min-height: 1rem;
630
646
  -webkit-tap-highlight-color: #0000;
631
647
  -webkit-tap-highlight-color: transparent;
@@ -636,23 +652,13 @@
636
652
  margin: .4rem 0;
637
653
  font-size: 1.2375rem;
638
654
  }
639
- .input-dialog-label > input {
640
- min-width: min(10rem, 100%);
641
- max-width: 100%;
642
- }
643
- .input-dialog-label:has(input[type=checkbox]) {
644
- flex-direction: row;
645
- gap: 1.25rem;
646
- }
647
- .input-dialog-label:has(input[type=checkbox]) .input-dialog-label-text {
655
+ .input-dialog__label {
648
656
  width: auto;
657
+ margin-bottom: .6rem;
649
658
  }
650
- .input-dialog-label > input[type=checkbox] {
651
- min-width: unset;
652
- }
653
- .input-dialog-label__error {
654
- min-height: 2rem;
655
- min-height: 2lh;
659
+ .input-dialog__error {
660
+ min-height: 1rem;
661
+ min-height: 1lh;
656
662
  }
657
663
  .input-dialog {
658
664
  color: var(--novely-input-dialog-color, #fff);
@@ -668,10 +674,10 @@
668
674
  min-width: 35vw;
669
675
  }
670
676
  @media (max-aspect-ratio: .8) {
671
- .input-dialog-label-text {
677
+ .input-dialog__text {
672
678
  width: calc(100vw - .5rem);
673
679
  }
674
- .input-dialog-label__error {
680
+ .input-dialog__error {
675
681
  min-height: 3rem;
676
682
  min-height: 3lh;
677
683
  }
@@ -681,6 +687,8 @@
681
687
  input[name=novely-input] {
682
688
  border: none;
683
689
  border-radius: .25rem;
690
+ min-width: min(10rem, 100%);
691
+ max-width: 100%;
684
692
  padding: .25rem;
685
693
  display: block;
686
694
  position: relative;
@@ -689,6 +697,16 @@ input[name=novely-input][type=text],
689
697
  input[name=novely-input][type=number],
690
698
  input[name=novely-input][type=password] {
691
699
  box-shadow: 0 0 0 var(--input-box-shadow-spread-radius, .15rem) var(--novely-input-border-color, #ffc7df);
700
+ outline-offset: var(--input-box-shadow-spread-radius, .15rem);
701
+ }
702
+ input[name=novely-input][type=checkbox] {
703
+ min-width: unset;
704
+ }
705
+ @supports ((-webkit-appearance: none)) {
706
+ input[name=novely-input][type=number] {
707
+ -webkit-appearance: textfield;
708
+ appearance: textfield;
709
+ }
692
710
  }
693
711
 
694
712
  /* src/styles/input-dialog/button/button.css */
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { Atom } from '@novely/renderer-toolkit';
2
+ import type { Stored } from '@novely/core';
1
3
  declare const capitalize: (str: string) => string;
2
4
  declare const isCSSImage: (str: string) => boolean;
3
5
  declare const createImage: (src: string) => HTMLImageElement;
@@ -28,4 +30,8 @@ declare const getDocumentStyles: () => string;
28
30
  */
29
31
  declare const once: (fn: () => void) => () => void;
30
32
  declare const createRetrieved: <T>(fn: () => T) => () => T;
31
- export { createRetrieved, isCSSImage, canvasDrawImages, url, createImage, capitalize, onKey, simple, getDocumentStyles, once, imageLoaded, imagePreloadWithCaching, imagePreloadWithCachingNotComplete };
33
+ /**
34
+ * Like solid-js's from, but has initial value
35
+ */
36
+ declare const from: <T>(producer: Atom<T> | Stored<T>) => import("solid-js").Accessor<T>;
37
+ export { createRetrieved, isCSSImage, canvasDrawImages, url, createImage, capitalize, onKey, simple, getDocumentStyles, once, imageLoaded, imagePreloadWithCaching, imagePreloadWithCachingNotComplete, from };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -19,8 +19,8 @@
19
19
  "clsx": "^2.1.1",
20
20
  "solid-js": "1.8.21",
21
21
  "solid-transition-group": "^0.2.3",
22
- "@novely/core": "0.40.0",
23
- "@novely/renderer-toolkit": "0.9.0",
22
+ "@novely/core": "0.42.0",
23
+ "@novely/renderer-toolkit": "0.10.0",
24
24
  "@novely/typewriter": "0.5.1"
25
25
  },
26
26
  "peerDependencies": {