@novely/solid-renderer 0.20.0 → 0.21.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/README.md CHANGED
@@ -1,79 +1,3 @@
1
1
  # @novely/solid-renderer
2
2
 
3
3
  Renderer for @novely/core powered by SolidJS
4
-
5
- ## Использование
6
-
7
- Make sure you have [SolidJS](https://www.solidjs.com/) installed and your bundler setup dones.
8
-
9
- ```tsx
10
- // @see https://www.solidjs.com/docs/latest/api#render
11
- import { render } from 'solid-js/web';
12
-
13
- import { novely, localStorageStorage } from '@novely/core';
14
- import { createT9N } from '@novely/t9n';
15
- import { createSolidRenderer } from '@novely/solid-renderer';
16
-
17
- // Важно - импортируйте css!
18
- import '@novely/solid-renderer/dist/index.css';
19
-
20
- // Специфичная для `@novely/solid-renderer` настройка
21
- const { renderer, Novely } = createSolidRenderer();
22
-
23
- // Задайте начальные настройки
24
- const engine = novely({
25
- renderer,
26
- languages: ['ru'],
27
- storage: localStorageStorage({ key: 'my-story' }),
28
- characters: {
29
- Spike: {
30
- name: {
31
- ru: 'Спайк',
32
- },
33
- color: '#99d41e',
34
- emotions: {
35
- ok: './brawl-start-spike.png',
36
- },
37
- },
38
- },
39
- t9n: createT9N({
40
- ru: {
41
- pluralization: {},
42
- strings: {
43
- Hello: 'Привет, я - Спайк. А как зовут тебя?',
44
- },
45
- },
46
- }),
47
- });
48
-
49
- // Опишите историю
50
- engine.withStory({
51
- start: [],
52
- });
53
-
54
- // Запустите рендер
55
- render(
56
- () => (
57
- <Novely
58
- style={{
59
- '--novely-settings-background-image': `url("./settings-background-image.png")`,
60
- '--novely-main-menu-background-image': `url("./main-menu-background-image.png")`,
61
- '--novely-saves-background-image': `url("./saves-background-image.png")`,
62
- }}
63
- />
64
- ),
65
- document.body,
66
- );
67
- ```
68
-
69
- ## CSS Variables API
70
-
71
- Not documented yet.
72
-
73
- ## CSS Breakpoints
74
-
75
- | Name | Description |
76
- | -------------------------- | -------------------- |
77
- | `(max-aspect-ratio: 0.8)` | Portrait |
78
- | `(max-aspect-ratio: 0.26)` | Hyper-Wide Portrait |
79
- | `(max-aspect-ratio: 0.10)` | Thermometer Portrait |
package/dist/index.jsx CHANGED
@@ -5039,7 +5039,7 @@ var Game = (props) => {
5039
5039
  return props.state.choices.choices;
5040
5040
  },
5041
5041
  children: ([text, _actions, active], i) => {
5042
- const disabled = active ? !active() : false;
5042
+ const disabled = !active;
5043
5043
  const index = i();
5044
5044
  return (() => {
5045
5045
  const _el$33 = _tmpl$92();
@@ -5344,6 +5344,7 @@ var Saves = () => {
5344
5344
  }
5345
5345
  })
5346
5346
  }));
5347
+ createRenderEffect(() => _el$5.classList.toggle("saves__list-few", !!(saves().length < 3)));
5347
5348
  return _el$5;
5348
5349
  }
5349
5350
  }));
@@ -5544,6 +5545,8 @@ var createSolidRenderer = ({
5544
5545
  }
5545
5546
  }
5546
5547
  });
5548
+ const rendererContextMain = renderer.getContext(options.mainContextKey);
5549
+ const stateContextMain = useContextState(options.mainContextKey);
5547
5550
  return (() => {
5548
5551
  const _el$ = _tmpl$30();
5549
5552
  const _ref$ = root;
@@ -5577,11 +5580,11 @@ var createSolidRenderer = ({
5577
5580
  get children() {
5578
5581
  return createComponent(Game, {
5579
5582
  get state() {
5580
- return useContextState(options.mainContextKey).state;
5583
+ return stateContextMain.state;
5581
5584
  },
5582
- setState: useContextState(options.mainContextKey).setState,
5583
- store: renderer.getContext(options.mainContextKey).store,
5584
- context: renderer.getContext(options.mainContextKey),
5585
+ setState: stateContextMain.setState,
5586
+ store: rendererContextMain.store,
5587
+ context: rendererContextMain,
5585
5588
  controls,
5586
5589
  skipTypewriterWhenGoingBack
5587
5590
  });
@@ -5838,6 +5841,7 @@ var createSolidRenderer = ({
5838
5841
  input,
5839
5842
  event,
5840
5843
  error,
5844
+ state: init.getStateFunction(name),
5841
5845
  get value() {
5842
5846
  if (value)
5843
5847
  return value;
@@ -5903,7 +5907,8 @@ var createSolidRenderer = ({
5903
5907
  get,
5904
5908
  goingBack: ctx.meta.goingBack,
5905
5909
  preview: ctx.meta.preview,
5906
- lang: options.$.get().meta[0]
5910
+ lang: options.$.get().meta[0],
5911
+ state: init.getStateFunction(name)
5907
5912
  });
5908
5913
  result ? result.then(resolve) : resolve();
5909
5914
  return result;
@@ -778,6 +778,9 @@
778
778
  overflow-y: scroll;
779
779
  touch-action: auto !important;
780
780
  }
781
+ .saves__list-few {
782
+ justify-content: flex-start;
783
+ }
781
784
  .saves__list::-webkit-scrollbar {
782
785
  width: var(--novely-saves-list-border-width, .875rem);
783
786
  }
package/dist/types.d.ts CHANGED
@@ -55,7 +55,7 @@ interface StateChoices {
55
55
  /**
56
56
  * Выборы
57
57
  */
58
- choices: ([string, ValidAction[]] | [string, ValidAction[], () => boolean])[];
58
+ choices: [string, ValidAction[], boolean?][];
59
59
  /**
60
60
  * Должен ли отображаться диалог
61
61
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"