@novely/solid-renderer 0.25.0 → 0.26.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.
@@ -1,7 +1,7 @@
1
1
  import type { Component } from 'solid-js';
2
2
  import type { Emitter } from '../emitter';
3
3
  import type { RendererStateStore, ContextStateStore, DeepMapStore } from '@novely/renderer-toolkit';
4
- import type { EmitterEventsMap, RendererStoreExtension } from '../types';
4
+ import type { EmitterEventsMap, RendererStoreExtension, SettingsIcons } from '../types';
5
5
  import type { Context } from '@novely/core';
6
6
  import { Character, Renderer, RendererInit } from '@novely/core';
7
7
  type CreateRootComponentOpts = {
@@ -12,10 +12,11 @@ type CreateRootComponentOpts = {
12
12
  emitter: Emitter<EmitterEventsMap>;
13
13
  skipTypewriterWhenGoingBack: boolean;
14
14
  controls: 'inside' | 'outside';
15
+ settingsIcons: SettingsIcons;
15
16
  rendererContext: Context;
16
17
  coreOptions: RendererInit;
17
18
  $contextState: DeepMapStore<ContextStateStore<Record<PropertyKey, unknown>>>;
18
19
  $rendererState: DeepMapStore<RendererStateStore<RendererStoreExtension>>;
19
20
  };
20
- declare const createRootComponent: ({ $rendererState, $contextState, coreOptions, setRoot, characters, renderer, fullscreen, emitter, controls, skipTypewriterWhenGoingBack, rendererContext }: CreateRootComponentOpts) => Component;
21
+ declare const createRootComponent: ({ $rendererState, $contextState, coreOptions, setRoot, characters, renderer, fullscreen, emitter, controls, skipTypewriterWhenGoingBack, settingsIcons, rendererContext }: CreateRootComponentOpts) => Component;
21
22
  export { createRootComponent };
@@ -1,2 +1,2 @@
1
- declare const useContextState: (id: string) => import("@novely/renderer-toolkit").DeepMapStore<import("@novely/renderer-toolkit").ContextState>, removeContextState: (id: string) => void;
1
+ declare const useContextState: (id: string) => import("@novely/renderer-toolkit").DeepAtom<import("@novely/renderer-toolkit").ContextState>, removeContextState: (id: string) => void;
2
2
  export { useContextState, removeContextState };
package/dist/index.jsx CHANGED
@@ -3693,13 +3693,13 @@ function cleanChildren(parent, current, marker, replacement) {
3693
3693
  }
3694
3694
  var RequestContext = Symbol();
3695
3695
 
3696
- // ../../node_modules/.pnpm/nanostores@0.10.0/node_modules/nanostores/task/index.js
3696
+ // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/task/index.js
3697
3697
  var tasks = 0;
3698
3698
  function cleanTasks() {
3699
3699
  tasks = 0;
3700
3700
  }
3701
3701
 
3702
- // ../../node_modules/.pnpm/nanostores@0.10.0/node_modules/nanostores/clean-stores/index.js
3702
+ // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/clean-stores/index.js
3703
3703
  var clean = Symbol("clean");
3704
3704
  var cleanStores = (...stores) => {
3705
3705
  if (false) {
@@ -3718,7 +3718,7 @@ var cleanStores = (...stores) => {
3718
3718
  }
3719
3719
  };
3720
3720
 
3721
- // ../../node_modules/.pnpm/nanostores@0.10.0/node_modules/nanostores/atom/index.js
3721
+ // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/atom/index.js
3722
3722
  var listenerQueue = [];
3723
3723
  var atom = (initialValue, level) => {
3724
3724
  let listeners = [];
@@ -3807,7 +3807,7 @@ var atom = (initialValue, level) => {
3807
3807
  return $atom;
3808
3808
  };
3809
3809
 
3810
- // ../../node_modules/.pnpm/nanostores@0.10.0/node_modules/nanostores/lifecycle/index.js
3810
+ // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/lifecycle/index.js
3811
3811
  var MOUNT = 5;
3812
3812
  var UNMOUNT = 6;
3813
3813
  var REVERT_MUTATION = 10;
@@ -3880,7 +3880,7 @@ var onMount = ($store, initialize) => {
3880
3880
  });
3881
3881
  };
3882
3882
 
3883
- // ../../node_modules/.pnpm/nanostores@0.10.0/node_modules/nanostores/deep-map/path.js
3883
+ // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/deep-map/path.js
3884
3884
  function getPath(obj, path) {
3885
3885
  let allKeys = getAllKeysFromPath(path);
3886
3886
  let res = obj;
@@ -3926,28 +3926,32 @@ function getKeyAndIndicesFromKey(key) {
3926
3926
  }
3927
3927
  return [key];
3928
3928
  }
3929
+ var IS_NUMBER = /^\d+$/;
3929
3930
  function ensureKey(obj, key, nextKey) {
3930
3931
  if (key in obj) {
3931
3932
  return;
3932
3933
  }
3933
- let nextKeyAsInt = parseInt(
3934
- nextKey !== null && nextKey !== void 0 ? nextKey : ""
3935
- );
3936
- if (Number.isNaN(nextKeyAsInt)) {
3937
- obj[key] = {};
3934
+ let isNum = IS_NUMBER.test(nextKey);
3935
+ if (isNum) {
3936
+ obj[key] = Array(parseInt(nextKey, 10) + 1).fill(void 0);
3938
3937
  } else {
3939
- obj[key] = Array(nextKeyAsInt + 1).fill(void 0);
3938
+ obj[key] = {};
3940
3939
  }
3941
3940
  }
3942
3941
 
3943
- // ../../node_modules/.pnpm/nanostores@0.10.0/node_modules/nanostores/deep-map/index.js
3942
+ // ../../node_modules/.pnpm/nanostores@0.10.3/node_modules/nanostores/deep-map/index.js
3944
3943
  function deepMap(initial = {}) {
3945
3944
  let $deepMap = atom(initial);
3946
3945
  $deepMap.setKey = (key, value) => {
3947
- let oldMap = $deepMap.value;
3946
+ let oldValue;
3947
+ try {
3948
+ oldValue = structuredClone($deepMap.value);
3949
+ } catch {
3950
+ oldValue = { ...$deepMap.value };
3951
+ }
3948
3952
  if (getPath($deepMap.value, key) !== value) {
3949
3953
  $deepMap.value = { ...setPath($deepMap.value, key, value) };
3950
- $deepMap.notify(oldMap, key);
3954
+ $deepMap.notify(oldValue, key);
3951
3955
  }
3952
3956
  };
3953
3957
  return $deepMap;
@@ -3970,10 +3974,74 @@ var memo = (input, cb) => {
3970
3974
  });
3971
3975
  return $memoized;
3972
3976
  };
3977
+ var getClonedOldValue = (atom2) => {
3978
+ let oldValue;
3979
+ try {
3980
+ oldValue = structuredClone(atom2.value);
3981
+ } catch {
3982
+ oldValue = { ...atom2.value };
3983
+ }
3984
+ return oldValue;
3985
+ };
3986
+ var usePath = (atomValue, getPath2) => {
3987
+ const targets = /* @__PURE__ */ new Set();
3988
+ const path = [];
3989
+ let current;
3990
+ const proxyHandler = {
3991
+ get(target, prop, receiver) {
3992
+ if (targets.has(target)) {
3993
+ throw new ReferenceError(`Attempted to access property on the same target multiple times.`);
3994
+ }
3995
+ const value = Reflect.get(target, prop, receiver);
3996
+ targets.add(target);
3997
+ path.push(prop);
3998
+ current = value;
3999
+ if (value === void 0) {
4000
+ return new Proxy({}, proxyHandler);
4001
+ }
4002
+ if (value && typeof value === "object") {
4003
+ return new Proxy(value, proxyHandler);
4004
+ }
4005
+ return value;
4006
+ }
4007
+ };
4008
+ getPath2(new Proxy(atomValue, proxyHandler));
4009
+ if (path.length === 0) {
4010
+ throw new Error("No valid path extracted from the provided getPath function.");
4011
+ }
4012
+ return {
4013
+ path,
4014
+ value: current
4015
+ };
4016
+ };
4017
+ var deepAtom = (init) => {
4018
+ const $atom = deepMap(init);
4019
+ $atom.mutate = (getPath2, setter) => {
4020
+ const { path, value } = usePath($atom.get(), getPath2);
4021
+ const newValue = typeof setter === "function" ? setter(value) : setter;
4022
+ if (newValue === value) {
4023
+ return newValue;
4024
+ }
4025
+ const oldMap = getClonedOldValue($atom);
4026
+ const fakedPath = {
4027
+ split: () => {
4028
+ return {
4029
+ flatMap: () => {
4030
+ return path;
4031
+ }
4032
+ };
4033
+ }
4034
+ };
4035
+ $atom.value = { ...setPath($atom.value, fakedPath, newValue) };
4036
+ $atom.notify(oldMap, path.join("."));
4037
+ return newValue;
4038
+ };
4039
+ return $atom;
4040
+ };
3973
4041
  var getDefaultContextState = () => {
3974
4042
  return {
3975
4043
  background: {
3976
- background: ""
4044
+ background: "#000"
3977
4045
  },
3978
4046
  characters: {},
3979
4047
  choice: {
@@ -4007,7 +4075,7 @@ var getDefaultContextState = () => {
4007
4075
  var createContextStateRoot = (getExtension = () => ({})) => {
4008
4076
  const CACHE = /* @__PURE__ */ new Map();
4009
4077
  const make = () => {
4010
- const contextState = deepMap({
4078
+ const contextState = deepAtom({
4011
4079
  ...getDefaultContextState(),
4012
4080
  ...getExtension()
4013
4081
  });
@@ -4041,7 +4109,7 @@ var createContextStateRoot = (getExtension = () => ({})) => {
4041
4109
  };
4042
4110
  var defaultEmpty = {};
4043
4111
  var createRendererState = (extension = defaultEmpty) => {
4044
- const rendererState = deepMap({
4112
+ const rendererState = deepAtom({
4045
4113
  screen: "mainmenu",
4046
4114
  loadingShown: false,
4047
4115
  exitPromptShown: false,
@@ -4051,11 +4119,6 @@ var createRendererState = (extension = defaultEmpty) => {
4051
4119
  };
4052
4120
  var noop = () => {
4053
4121
  };
4054
- var storeUpdate = (store, path, setter) => {
4055
- const value = getPath(store.get(), path);
4056
- const newer = setter(value);
4057
- store.setKey(path, newer);
4058
- };
4059
4122
  var findLastIndex = (array, fn) => {
4060
4123
  for (let i = array.length - 1; i >= 0; i--) {
4061
4124
  if (fn.call(array, array[i], i, array)) {
@@ -4363,62 +4426,85 @@ var handleBackgroundAction = ($contextState, background) => {
4363
4426
  const { clear } = $contextState.get().background;
4364
4427
  clear && clear();
4365
4428
  if (typeof background === "string") {
4366
- $contextState.setKey("background.background", background);
4429
+ $contextState.mutate((s) => s.background.background, background);
4367
4430
  return;
4368
4431
  }
4369
4432
  const { dispose: dispose2 } = useBackground(background, (value) => {
4370
- $contextState.setKey("background.background", value);
4433
+ $contextState.mutate((s) => s.background.background, value);
4371
4434
  });
4372
- $contextState.setKey("background.clear", dispose2);
4435
+ $contextState.mutate((s) => s.background.clear, () => dispose2);
4373
4436
  };
4374
4437
  var handleDialogAction = ($contextState, content, name, character, emotion, resolve) => {
4375
- $contextState.setKey("dialog", {
4376
- content,
4377
- name,
4378
- miniature: {
4379
- character,
4380
- emotion
4381
- },
4382
- visible: true,
4383
- resolve
4384
- });
4438
+ $contextState.mutate(
4439
+ (s) => s.dialog,
4440
+ {
4441
+ content,
4442
+ name,
4443
+ miniature: {
4444
+ character,
4445
+ emotion
4446
+ },
4447
+ visible: true,
4448
+ resolve
4449
+ }
4450
+ );
4385
4451
  };
4386
4452
  var handleChoiceAction = ($contextState, label, choices, resolve) => {
4387
- $contextState.setKey("choice", { choices, label, resolve, visible: true });
4453
+ $contextState.mutate(
4454
+ (s) => s.choice,
4455
+ { choices, label, resolve, visible: true }
4456
+ );
4388
4457
  };
4389
4458
  var handleClearAction = ($rendererState, $contextState, context, keep, keepCharacters) => {
4390
- $rendererState.setKey("exitPromptShown", false);
4459
+ $rendererState.mutate((s) => s.exitPromptShown, false);
4391
4460
  if (!keep.has("showBackground")) {
4392
- $contextState.setKey("background.background", "#000");
4461
+ $contextState.mutate((s) => s.background.background, "#000");
4393
4462
  }
4394
4463
  if (!keep.has("choice")) {
4395
- $contextState.setKey("choice", {
4396
- choices: [],
4397
- visible: false,
4398
- label: ""
4399
- });
4464
+ $contextState.mutate(
4465
+ (s) => s.choice,
4466
+ {
4467
+ choices: [],
4468
+ visible: false,
4469
+ label: ""
4470
+ }
4471
+ );
4400
4472
  }
4401
4473
  if (!keep.has("input")) {
4402
- $contextState.setKey("input", {
4403
- element: null,
4404
- label: "",
4405
- visible: false,
4406
- error: ""
4407
- });
4474
+ $contextState.mutate(
4475
+ (s) => s.input,
4476
+ {
4477
+ element: null,
4478
+ label: "",
4479
+ visible: false,
4480
+ error: ""
4481
+ }
4482
+ );
4408
4483
  }
4409
4484
  if (!keep.has("dialog")) {
4410
- $contextState.setKey("dialog", { visible: false, content: "", name: "", miniature: {} });
4485
+ $contextState.mutate(
4486
+ (s) => s.dialog,
4487
+ {
4488
+ visible: false,
4489
+ content: "",
4490
+ name: "",
4491
+ miniature: {}
4492
+ }
4493
+ );
4411
4494
  }
4412
4495
  if (!keep.has("text")) {
4413
- $contextState.setKey("text", { content: "" });
4496
+ $contextState.mutate((s) => s.text, { content: "" });
4414
4497
  }
4415
4498
  const { characters, custom } = $contextState.get();
4416
4499
  for (const character of Object.keys(characters)) {
4417
4500
  if (!keepCharacters.has(character)) {
4418
- $contextState.setKey(`characters.${character}`, {
4419
- style: void 0,
4420
- visible: false
4421
- });
4501
+ $contextState.mutate(
4502
+ (s) => s.characters[character],
4503
+ {
4504
+ style: void 0,
4505
+ visible: false
4506
+ }
4507
+ );
4422
4508
  }
4423
4509
  }
4424
4510
  for (const [id, handler] of Object.entries(custom)) {
@@ -4427,7 +4513,7 @@ var handleClearAction = ($rendererState, $contextState, context, keep, keepChara
4427
4513
  if (context.meta.goingBack && handler.fn.skipClearOnGoingBack)
4428
4514
  continue;
4429
4515
  handler.clear();
4430
- $contextState.setKey(`custom.${id}`, void 0);
4516
+ $contextState.mutate((s) => s.custom[id], void 0);
4431
4517
  }
4432
4518
  };
4433
4519
  var handleCustomAction = ($contextState, options, context, fn, resolve) => {
@@ -4441,7 +4527,7 @@ var handleCustomAction = ($contextState, options, context, fn, resolve) => {
4441
4527
  let store = {};
4442
4528
  const clearManager = () => {
4443
4529
  clear();
4444
- $contextState.setKey(`custom.${fn.key}`, void 0);
4530
+ $contextState.mutate((s) => s.custom[fn.key], void 0);
4445
4531
  };
4446
4532
  const createElement = () => {
4447
4533
  const div = document.createElement("div");
@@ -4460,12 +4546,15 @@ var handleCustomAction = ($contextState, options, context, fn, resolve) => {
4460
4546
  clear = cb;
4461
4547
  }
4462
4548
  };
4463
- $contextState.setKey(`custom.${fn.key}`, {
4464
- dom: element,
4465
- fn,
4466
- getReturn,
4467
- clear: clearManager
4468
- });
4549
+ $contextState.mutate(
4550
+ (s) => s.custom[fn.key],
4551
+ {
4552
+ dom: element,
4553
+ fn,
4554
+ getReturn,
4555
+ clear: clearManager
4556
+ }
4557
+ );
4469
4558
  return getReturn;
4470
4559
  };
4471
4560
  const result = fn({
@@ -4484,11 +4573,11 @@ var handleClearCustomAction = ($contextState, fn) => {
4484
4573
  data.clear();
4485
4574
  };
4486
4575
  var handleTextAction = ($contextState, content, resolve) => {
4487
- $contextState.setKey("text", { content, resolve });
4576
+ $contextState.mutate((s) => s.text, { content, resolve });
4488
4577
  };
4489
4578
  var handleInputAction = ($contextState, options, context, label, onInput, setup, resolve) => {
4490
4579
  const error = (value) => {
4491
- $contextState.setKey("input.error", value);
4580
+ $contextState.mutate((s) => s.input.error, value);
4492
4581
  };
4493
4582
  const onInputHandler = (event) => {
4494
4583
  let value;
@@ -4511,14 +4600,17 @@ var handleInputAction = ($contextState, options, context, label, onInput, setup,
4511
4600
  input.setAttribute("required", "true");
4512
4601
  input.setAttribute("autocomplete", "off");
4513
4602
  !context.meta.preview && input.addEventListener("input", onInputHandler);
4514
- setup(input, (callback) => $contextState.setKey("input.cleanup", callback));
4515
- $contextState.setKey("input", {
4516
- element: input,
4517
- label,
4518
- error: "",
4519
- visible: true,
4520
- resolve
4521
- });
4603
+ setup(input, (callback) => $contextState.mutate((s) => s.input.cleanup, () => callback));
4604
+ $contextState.mutate(
4605
+ (s) => s.input,
4606
+ {
4607
+ element: input,
4608
+ label,
4609
+ error: "",
4610
+ visible: true,
4611
+ resolve
4612
+ }
4613
+ );
4522
4614
  !context.meta.preview && input.dispatchEvent(new InputEvent("input", { bubbles: true }));
4523
4615
  };
4524
4616
  var handleVibrateAction = vibrate;
@@ -4994,13 +5086,11 @@ var Save = (props) => {
4994
5086
  const year = date.getFullYear();
4995
5087
  const stringDate = () => capitalize(date.toLocaleDateString(props.language, {
4996
5088
  year: year === CURRENT_YEAR ? void 0 : "numeric",
4997
- weekday: "long",
4998
5089
  month: "long",
4999
5090
  day: "numeric",
5000
5091
  dayPeriod: "narrow",
5001
5092
  hour: "numeric",
5002
- minute: "numeric",
5003
- second: "numeric"
5093
+ minute: "numeric"
5004
5094
  }));
5005
5095
  const stringType = t(type === "auto" ? "Automatic" : "Manual");
5006
5096
  const game = createComponent(Game, {
@@ -5088,7 +5178,7 @@ var Save = (props) => {
5088
5178
  };
5089
5179
  delegateEvents(["click"]);
5090
5180
 
5091
- // ../typewriter/dist/index.js
5181
+ // ../../node_modules/.pnpm/@novely+typewriter@0.5.1/node_modules/@novely/typewriter/dist/index.js
5092
5182
  var defaultSpeed = () => {
5093
5183
  return Math.min(90 * Math.random() + 100, 90);
5094
5184
  };
@@ -5645,17 +5735,18 @@ var Game = (props) => {
5645
5735
  }
5646
5736
  }), null);
5647
5737
  createRenderEffect((_p$) => {
5648
- const _v$7 = background(), _v$8 = `${props.className || ""} root game`, _v$9 = charactersCount(), _v$10 = !!dialogState().visible, _v$11 = !dialogState().visible, _v$12 = !(dialogState().miniature.character && dialogState().miniature.emotion), _v$13 = !dialogState().content, _v$14 = !!props.isPreview, _v$15 = Boolean(textState().content), _v$16 = !textState().content;
5738
+ const _v$7 = background(), _v$8 = `${props.className || ""} root game`, _v$9 = !!props.isPreview, _v$10 = charactersCount(), _v$11 = !!dialogState().visible, _v$12 = !dialogState().visible, _v$13 = !(dialogState().miniature.character && dialogState().miniature.emotion), _v$14 = !dialogState().content, _v$15 = !!props.isPreview, _v$16 = Boolean(textState().content), _v$17 = !textState().content;
5649
5739
  _p$._v$7 = style(_el$, _v$7, _p$._v$7);
5650
5740
  _v$8 !== _p$._v$8 && className(_el$, _p$._v$8 = _v$8);
5651
- _v$9 !== _p$._v$9 && ((_p$._v$9 = _v$9) != null ? _el$2.style.setProperty("--shown-characters-count", _v$9) : _el$2.style.removeProperty("--shown-characters-count"));
5652
- _v$10 !== _p$._v$10 && _el$3.classList.toggle("action-dialog--visible", _p$._v$10 = _v$10);
5653
- _v$11 !== _p$._v$11 && _el$3.classList.toggle("action-dialog--hidden", _p$._v$11 = _v$11);
5654
- _v$12 !== _p$._v$12 && setAttribute(_el$4, "data-no-person", _p$._v$12 = _v$12);
5655
- _v$13 !== _p$._v$13 && setAttribute(_el$4, "aria-disabled", _p$._v$13 = _v$13);
5656
- _v$14 !== _p$._v$14 && _el$6.classList.toggle("action-dialog-content--disable-shadow", _p$._v$14 = _v$14);
5657
- _v$15 !== _p$._v$15 && setAttribute(_el$27, "data-shown", _p$._v$15 = _v$15);
5658
- _v$16 !== _p$._v$16 && setAttribute(_el$27, "aria-disabled", _p$._v$16 = _v$16);
5741
+ _v$9 !== _p$._v$9 && _el$.classList.toggle("preview", _p$._v$9 = _v$9);
5742
+ _v$10 !== _p$._v$10 && ((_p$._v$10 = _v$10) != null ? _el$2.style.setProperty("--shown-characters-count", _v$10) : _el$2.style.removeProperty("--shown-characters-count"));
5743
+ _v$11 !== _p$._v$11 && _el$3.classList.toggle("action-dialog--visible", _p$._v$11 = _v$11);
5744
+ _v$12 !== _p$._v$12 && _el$3.classList.toggle("action-dialog--hidden", _p$._v$12 = _v$12);
5745
+ _v$13 !== _p$._v$13 && setAttribute(_el$4, "data-no-person", _p$._v$13 = _v$13);
5746
+ _v$14 !== _p$._v$14 && setAttribute(_el$4, "aria-disabled", _p$._v$14 = _v$14);
5747
+ _v$15 !== _p$._v$15 && _el$6.classList.toggle("action-dialog-content--disable-shadow", _p$._v$15 = _v$15);
5748
+ _v$16 !== _p$._v$16 && setAttribute(_el$27, "data-shown", _p$._v$16 = _v$16);
5749
+ _v$17 !== _p$._v$17 && setAttribute(_el$27, "aria-disabled", _p$._v$17 = _v$17);
5659
5750
  return _p$;
5660
5751
  }, {
5661
5752
  _v$7: void 0,
@@ -5667,7 +5758,8 @@ var Game = (props) => {
5667
5758
  _v$13: void 0,
5668
5759
  _v$14: void 0,
5669
5760
  _v$15: void 0,
5670
- _v$16: void 0
5761
+ _v$16: void 0,
5762
+ _v$17: void 0
5671
5763
  });
5672
5764
  return _el$;
5673
5765
  })();
@@ -5794,19 +5886,13 @@ var Saves = () => {
5794
5886
  delegateEvents(["click"]);
5795
5887
 
5796
5888
  // src/screens/settings.tsx
5797
- var _tmpl$28 = /* @__PURE__ */ template(`<div class="root settings"><div class="settings__column"><button type="button" class="button settings__button"></button><button type="button" class="button settings__button"></button></div><div class="settings__column-grid"><div><div class="select"><label class="select__label"><span>🌎</span> </label><select class="select__select"></select></div><div class="select"><label class="select__label"><span>⚡</span> </label><select class="select__select"></select></div></div><div><div class="range"><label class="range__label"><span>🎵</span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span>🔊</span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span>🗣️</span> </label><input class="range__range" type="range" min="0" max="1" step="0.01">`);
5889
+ var _tmpl$28 = /* @__PURE__ */ template(`<div class="root settings"><div class="settings__column"><button type="button" class="button settings__button"></button><button type="button" class="button settings__button"></button></div><div class="settings__column-grid"><div><div class="select"><label class="select__label"><span></span> </label><select class="select__select"></select></div><div class="select"><label class="select__label"><span></span> </label><select class="select__select"></select></div></div><div><div class="range"><label class="range__label"><span></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01"></div><div class="range"><label class="range__label"><span></span> </label><input class="range__range" type="range" min="0" max="1" step="0.01">`);
5798
5890
  var _tmpl$29 = /* @__PURE__ */ template(`<option>`);
5799
- var Settings = () => {
5891
+ var Settings = (props) => {
5800
5892
  const data = useData();
5801
5893
  const language = () => data.storageData().meta[0];
5802
5894
  const textSpeed = () => data.storageData().meta[1];
5803
5895
  const volume = (kind) => data.storageData().meta[kind];
5804
- const getLanguageName = (lang) => {
5805
- const intl = new Intl.DisplayNames([language()], {
5806
- type: "language"
5807
- });
5808
- return intl.of(lang) || lang;
5809
- };
5810
5896
  const onLanguageSelect = ({
5811
5897
  currentTarget: {
5812
5898
  value
@@ -5863,7 +5949,7 @@ var Settings = () => {
5863
5949
  children: (lang) => (() => {
5864
5950
  const _el$33 = _tmpl$29();
5865
5951
  _el$33.value = lang;
5866
- insert(_el$33, () => capitalize(getLanguageName(lang)));
5952
+ insert(_el$33, () => data.options.getLanguageDisplayName(lang));
5867
5953
  createRenderEffect(() => _el$33.selected = lang === language());
5868
5954
  return _el$33;
5869
5955
  })()
@@ -5898,6 +5984,21 @@ var Settings = () => {
5898
5984
  insert(_el$29, () => data.t("VoiceVolume"), null);
5899
5985
  addEventListener2(_el$32, "change", volumeChange(4));
5900
5986
  setAttribute(_el$32, "id", voiceVolumeSelectID);
5987
+ createRenderEffect((_p$) => {
5988
+ const _v$ = props.icons.language, _v$2 = props.icons.typewriter_speed, _v$3 = props.icons.music_volume, _v$4 = props.icons.sound_volume, _v$5 = props.icons.voice_volume;
5989
+ _v$ !== _p$._v$ && (_el$9.innerHTML = _p$._v$ = _v$);
5990
+ _v$2 !== _p$._v$2 && (_el$14.innerHTML = _p$._v$2 = _v$2);
5991
+ _v$3 !== _p$._v$3 && (_el$20.innerHTML = _p$._v$3 = _v$3);
5992
+ _v$4 !== _p$._v$4 && (_el$25.innerHTML = _p$._v$4 = _v$4);
5993
+ _v$5 !== _p$._v$5 && (_el$30.innerHTML = _p$._v$5 = _v$5);
5994
+ return _p$;
5995
+ }, {
5996
+ _v$: void 0,
5997
+ _v$2: void 0,
5998
+ _v$3: void 0,
5999
+ _v$4: void 0,
6000
+ _v$5: void 0
6001
+ });
5901
6002
  createRenderEffect(() => _el$22.value = volume(2));
5902
6003
  createRenderEffect(() => _el$27.value = volume(3));
5903
6004
  createRenderEffect(() => _el$32.value = volume(4));
@@ -5919,6 +6020,7 @@ var createRootComponent = ({
5919
6020
  emitter,
5920
6021
  controls,
5921
6022
  skipTypewriterWhenGoingBack,
6023
+ settingsIcons,
5922
6024
  rendererContext
5923
6025
  }) => {
5924
6026
  const Root = () => {
@@ -5999,7 +6101,9 @@ var createRootComponent = ({
5999
6101
  return screen() === "settings";
6000
6102
  },
6001
6103
  get children() {
6002
- return createComponent(Settings, {});
6104
+ return createComponent(Settings, {
6105
+ icons: settingsIcons
6106
+ });
6003
6107
  }
6004
6108
  })];
6005
6109
  }
@@ -6034,7 +6138,14 @@ var createSolidRenderer = ({
6034
6138
  fullscreen = false,
6035
6139
  controls = "outside",
6036
6140
  skipTypewriterWhenGoingBack = true,
6037
- target = document.body
6141
+ target = document.body,
6142
+ settingsIcons = {
6143
+ language: "🌎",
6144
+ typewriter_speed: "⚡",
6145
+ music_volume: "🎵",
6146
+ sound_volume: "🔊",
6147
+ voice_volume: "🗣️"
6148
+ }
6038
6149
  } = {}) => {
6039
6150
  const emitter = createEmitter();
6040
6151
  const $rendererState = createRendererState({
@@ -6095,7 +6206,7 @@ var createSolidRenderer = ({
6095
6206
  },
6096
6207
  append(className2, style2) {
6097
6208
  clearTimeout($contextState.get().characters[character]?.hideTimeoutId);
6098
- $contextState.setKey(`characters.${character}`, {
6209
+ $contextState.mutate((s) => s.characters[character], {
6099
6210
  style: style2,
6100
6211
  visible: true
6101
6212
  });
@@ -6111,19 +6222,19 @@ var createSolidRenderer = ({
6111
6222
  remove(className2, style2, duration, restoring) {
6112
6223
  return new Promise((resolve) => {
6113
6224
  if (restoring) {
6114
- $contextState.setKey(`characters.${character}.visible`, false);
6225
+ $contextState.mutate((s) => s.characters[character].visible, false);
6115
6226
  resolve();
6116
6227
  return;
6117
6228
  }
6118
6229
  const timeoutId = setTimeout(() => {
6119
- $contextState.setKey(`characters.${character}.visible`, false);
6230
+ $contextState.mutate((s) => s.characters[character].visible, false);
6120
6231
  resolve();
6121
6232
  }, duration);
6122
6233
  if (className2) {
6123
6234
  chars[character].canvas.className = className2;
6124
6235
  }
6125
- $contextState.setKey(`characters.${character}.style`, style2);
6126
- $contextState.setKey(`characters.${character}.hideTimeoutId`, timeoutId);
6236
+ $contextState.mutate((s) => s.characters[character].style, style2);
6237
+ $contextState.mutate((s) => s.characters[character].hideTimeoutId, timeoutId);
6127
6238
  });
6128
6239
  },
6129
6240
  animate(timeout, classes) {
@@ -6187,19 +6298,19 @@ var createSolidRenderer = ({
6187
6298
  return $contextState.get().meta.restoring;
6188
6299
  },
6189
6300
  set restoring(value) {
6190
- $contextState.setKey("meta.restoring", value);
6301
+ $contextState.mutate((s) => s.meta.restoring, value);
6191
6302
  },
6192
6303
  get preview() {
6193
6304
  return $contextState.get().meta.preview;
6194
6305
  },
6195
6306
  set preview(value) {
6196
- $contextState.setKey("meta.preview", value);
6307
+ $contextState.mutate((s) => s.meta.preview, value);
6197
6308
  },
6198
6309
  get goingBack() {
6199
6310
  return $contextState.get().meta.goingBack;
6200
6311
  },
6201
6312
  set goingBack(value) {
6202
- $contextState.setKey("meta.goingBack", value);
6313
+ $contextState.mutate((s) => s.meta.goingBack, value);
6203
6314
  }
6204
6315
  }
6205
6316
  };
@@ -6211,19 +6322,19 @@ var createSolidRenderer = ({
6211
6322
  },
6212
6323
  ui: {
6213
6324
  showScreen(name) {
6214
- $rendererState.setKey("screen", name);
6325
+ $rendererState.mutate((s) => s.screen, name);
6215
6326
  },
6216
6327
  getScreen() {
6217
6328
  return $rendererState.get().screen;
6218
6329
  },
6219
6330
  showLoading() {
6220
- $rendererState.setKey("loadingShown", true);
6331
+ $rendererState.mutate((s) => s.loadingShown, true);
6221
6332
  },
6222
6333
  hideLoading() {
6223
- $rendererState.setKey("loadingShown", false);
6334
+ $rendererState.mutate((s) => s.loadingShown, false);
6224
6335
  },
6225
6336
  showExitPrompt() {
6226
- $rendererState.setKey("exitPromptShown", true);
6337
+ $rendererState.mutate((s) => s.exitPromptShown, true);
6227
6338
  },
6228
6339
  start: createStartFunction(() => {
6229
6340
  const Root = createRootComponent({
@@ -6234,6 +6345,7 @@ var createSolidRenderer = ({
6234
6345
  emitter,
6235
6346
  controls,
6236
6347
  skipTypewriterWhenGoingBack,
6348
+ settingsIcons,
6237
6349
  rendererContext: renderer.getContext(options.mainContextKey),
6238
6350
  coreOptions: options,
6239
6351
  $rendererState,
@@ -6267,10 +6379,10 @@ var createSolidRenderer = ({
6267
6379
  return renderer;
6268
6380
  },
6269
6381
  registerScreen(name, screen) {
6270
- $rendererState.setKey(`screens.${name}`, screen);
6382
+ $rendererState.mutate((s) => s.screens[name], () => screen);
6271
6383
  },
6272
6384
  registerMainmenuItem(fn) {
6273
- storeUpdate($rendererState, "mainmenu", (mainmenu) => [...mainmenu, fn]);
6385
+ $rendererState.mutate((s) => s.mainmenu, (mainmenu) => [...mainmenu, fn]);
6274
6386
  }
6275
6387
  };
6276
6388
  };
@@ -1,7 +1,7 @@
1
1
  import type { RendererInit, Context } from '@novely/core';
2
2
  import type { StateScreen, StateScreens, StateMainmenuItem, SolidRendererStore, CreateSolidRendererOptions, EmitterEventsMap } from './types';
3
3
  import { Howl } from '@novely/renderer-toolkit';
4
- declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGoingBack, target, }?: CreateSolidRendererOptions) => {
4
+ declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGoingBack, target, settingsIcons }?: CreateSolidRendererOptions) => {
5
5
  emitter: import("./emitter").Emitter<EmitterEventsMap>;
6
6
  renderer(options: RendererInit): {
7
7
  getContext: (key: string) => Context;
@@ -1,5 +1,7 @@
1
1
  import type { VoidComponent } from 'solid-js';
2
+ import { SettingsIcons } from '../types';
2
3
  interface SettingsProps {
4
+ icons: SettingsIcons;
3
5
  }
4
6
  declare const Settings: VoidComponent<SettingsProps>;
5
7
  export { Settings };
@@ -235,6 +235,16 @@
235
235
  padding: .4rem;
236
236
  font-size: 1.02rem;
237
237
  }
238
+ @media (max-aspect-ratio: .8) {
239
+ .select__select {
240
+ min-width: 50%;
241
+ }
242
+ }
243
+ @media (max-aspect-ratio: .26) {
244
+ .select__select {
245
+ min-width: 100%;
246
+ }
247
+ }
238
248
 
239
249
  /* src/styles/select/label/label.css */
240
250
  .select__label {
@@ -244,6 +254,16 @@
244
254
  padding: .25rem .5rem;
245
255
  font-size: 1.02rem;
246
256
  }
257
+ @media (max-aspect-ratio: .8) {
258
+ .select__label {
259
+ min-width: 50%;
260
+ }
261
+ }
262
+ @media (max-aspect-ratio: .26) {
263
+ .select__label {
264
+ min-width: 100%;
265
+ }
266
+ }
247
267
 
248
268
  /* src/styles/select/index.css */
249
269
 
@@ -263,6 +283,16 @@
263
283
  padding: .25rem .5rem;
264
284
  font-size: 1.02rem;
265
285
  }
286
+ @media (max-aspect-ratio: .8) {
287
+ .range__label {
288
+ min-width: 50%;
289
+ }
290
+ }
291
+ @media (max-aspect-ratio: .26) {
292
+ .range__label {
293
+ min-width: 100%;
294
+ }
295
+ }
266
296
 
267
297
  /* src/styles/range/range/range.css */
268
298
  .range__range {
@@ -315,6 +345,16 @@
315
345
  .range__range:active::-moz-range-thumb {
316
346
  background-color: var(--novely-range-thumb-active-color, #ff66a8);
317
347
  }
348
+ @media (max-aspect-ratio: .8) {
349
+ .range__range {
350
+ min-width: 50%;
351
+ }
352
+ }
353
+ @media (max-aspect-ratio: .26) {
354
+ .range__range {
355
+ min-width: 100%;
356
+ }
357
+ }
318
358
 
319
359
  /* src/styles/range/index.css */
320
360
 
@@ -582,6 +622,9 @@
582
622
  min-width: 30vw;
583
623
  display: grid;
584
624
  }
625
+ .main-menu__button__text {
626
+ align-self: center;
627
+ }
585
628
  @media (max-aspect-ratio: .26) {
586
629
  .main-menu__button {
587
630
  grid-template-columns: 1fr;
@@ -817,6 +860,7 @@
817
860
  display: flex;
818
861
  }
819
862
  .saves__list-item__description {
863
+ font-variant-numeric: tabular-nums;
820
864
  flex-direction: column;
821
865
  width: 100%;
822
866
  display: flex;
package/dist/types.d.ts CHANGED
@@ -12,6 +12,13 @@ type StateMainmenuItems = StateMainmenuItem[];
12
12
  type SolidRendererStore = {
13
13
  characters: Record<string, CharacterHandle>;
14
14
  };
15
+ type SettingsIcons = {
16
+ language: string;
17
+ typewriter_speed: string;
18
+ music_volume: string;
19
+ sound_volume: string;
20
+ voice_volume: string;
21
+ };
15
22
  type CreateSolidRendererOptions = {
16
23
  /**
17
24
  * Enter fullscreen mode when opening a game, exit when opening main-menu
@@ -33,11 +40,7 @@ type CreateSolidRendererOptions = {
33
40
  * @default document.body
34
41
  */
35
42
  target?: MountableElement;
36
- /**
37
- * In the settings screen languages will be shown in it's own language instead of selected language
38
- * @default true
39
- */
40
- useNativeLanguageNames?: boolean;
43
+ settingsIcons?: SettingsIcons;
41
44
  };
42
45
  type EmitterEventsMap = {
43
46
  'screen:change': PossibleScreen;
@@ -46,4 +49,4 @@ type RendererStoreExtension = {
46
49
  screens: Record<string, StateScreen>;
47
50
  mainmenu: StateMainmenuItems;
48
51
  };
49
- export type { EmitterEventsMap, StateScreen, StateScreens, PossibleScreen, StateMainmenuItem, StateMainmenuItems, SolidRendererStore, CreateSolidRendererOptions, RendererStoreExtension };
52
+ export type { SettingsIcons, EmitterEventsMap, StateScreen, StateScreens, PossibleScreen, StateMainmenuItem, StateMainmenuItems, SolidRendererStore, CreateSolidRendererOptions, RendererStoreExtension };
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
1
  {
2
- "name": "@novely/solid-renderer",
3
- "version": "0.25.0",
4
- "type": "module",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "types": "./dist/index.d.ts",
9
- "main": "./dist/index.jsx",
10
- "module": "./dist/index.jsx",
11
- "sideEffects": false,
12
- "scripts": {
13
- "dev": "node ./build.js --watch",
14
- "build": "node ./build.js && tsc"
15
- },
16
- "devDependencies": {
17
- "esbuild": "^0.19.2",
18
- "esbuild-plugin-solid": "^0.5.0",
19
- "typescript": "^5.2.2"
20
- },
21
- "dependencies": {
22
- "@novely/core": "*",
23
- "@novely/renderer-toolkit": "*",
24
- "@novely/typewriter": "*",
25
- "retrieved": "^0.1.0",
26
- "solid-js": "1.8.5"
27
- },
28
- "peerDependencies": {
29
- "@novely/core": "*",
30
- "solid-js": "*"
31
- },
32
- "license": "ISC",
33
- "bugs": {
34
- "url": "https://github.com/yhdgms1/novely/issues"
35
- },
36
- "homepage": "https://github.com/yhdgms1/novely/tree/main/packages/solid-renderer",
37
- "keywords": [
38
- "novely",
39
- "solid-js",
40
- "solid",
41
- "renderer",
42
- "novel"
43
- ],
44
- "author": {
45
- "name": "Artemiy Schukin",
46
- "url": "https://github.com/yhdgms1"
47
- },
48
- "contributors": [],
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/yhdgms1/novely.git"
52
- },
53
- "files": [
54
- "dist/*"
55
- ]
56
- }
2
+ "name": "@novely/solid-renderer",
3
+ "version": "0.26.0",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "types": "./dist/index.d.ts",
9
+ "main": "./dist/index.jsx",
10
+ "module": "./dist/index.jsx",
11
+ "sideEffects": false,
12
+ "devDependencies": {
13
+ "esbuild": "^0.19.2",
14
+ "esbuild-plugin-solid": "^0.5.0",
15
+ "typescript": "^5.2.2"
16
+ },
17
+ "dependencies": {
18
+ "@novely/core": "*",
19
+ "@novely/typewriter": "*",
20
+ "retrieved": "^0.1.0",
21
+ "solid-js": "1.8.5",
22
+ "@novely/renderer-toolkit": "0.1.0"
23
+ },
24
+ "peerDependencies": {
25
+ "@novely/core": "*",
26
+ "solid-js": "*"
27
+ },
28
+ "license": "ISC",
29
+ "bugs": {
30
+ "url": "https://github.com/yhdgms1/novely/issues"
31
+ },
32
+ "homepage": "https://github.com/yhdgms1/novely/tree/main/packages/solid-renderer",
33
+ "keywords": [
34
+ "novely",
35
+ "solid-js",
36
+ "solid",
37
+ "renderer",
38
+ "novel"
39
+ ],
40
+ "author": {
41
+ "name": "Artemiy Schukin",
42
+ "url": "https://github.com/yhdgms1"
43
+ },
44
+ "contributors": [],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/yhdgms1/novely.git"
48
+ },
49
+ "files": [
50
+ "dist/*"
51
+ ],
52
+ "scripts": {
53
+ "dev": "node ./build.js --watch",
54
+ "build": "node ./build.js && tsc"
55
+ }
56
+ }
package/dist/store.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { AtContextState } from './types';
2
- import type { SetStoreFunction } from 'solid-js/store';
3
- declare const createContextState: () => {
4
- state: AtContextState;
5
- setState: SetStoreFunction<AtContextState>;
6
- };
7
- declare const useContextState: (name: string) => {
8
- state: AtContextState;
9
- setState: SetStoreFunction<AtContextState>;
10
- remove: () => void;
11
- };
12
- export { createContextState, useContextState };