poe-svelte-ui-lib 2.10.1 → 2.11.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 +15 -2
- package/dist/GUIRenderer/GUIRenderer.svelte +19 -11
- package/dist/GUIRenderer/GUIRenderer.svelte.d.ts +2 -0
- package/dist/GUIRenderer/extras.d.ts +11 -0
- package/dist/GUIRenderer/extras.js +6 -0
- package/dist/WidgetDeviceInfo/README.md +2 -3
- package/dist/WidgetDeviceInfo/WidgetDeviceInfoProps.svelte +29 -18
- package/dist/componentMeta.d.ts +11 -0
- package/dist/componentMeta.js +38 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/locales/translations.d.ts +10 -0
- package/dist/locales/translations.js +5 -3
- package/dist/registry.d.ts +2 -8
- package/dist/registry.js +28 -36
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -122,9 +122,19 @@
|
|
|
122
122
|
Интерфейс, собранный в конструкторе, рисует компонент `GUIRenderer`. Он сам раскладывает блоки по сетке, берёт значения переменных, отправляет команды и ведёт смарт-виджеты и файлы. Приложению остаётся транспорт, выбор модуля, загрузка GUI и хранилище значений.
|
|
123
123
|
|
|
124
124
|
```svelte
|
|
125
|
-
<UI.GUIRenderer
|
|
125
|
+
<UI.GUIRenderer
|
|
126
|
+
components={module.UIBlocks}
|
|
127
|
+
{link}
|
|
128
|
+
persistKey={module.ModSN}
|
|
129
|
+
viewer={!canManage}
|
|
130
|
+
render={{ VideoViewer: video }}
|
|
131
|
+
extras={UI.GUI_EXTRAS}
|
|
132
|
+
onError={addMessage}
|
|
133
|
+
/>
|
|
126
134
|
```
|
|
127
135
|
|
|
136
|
+
**📦 Что попадает в сборку.** Тяжёлые компоненты - `WidgetMap`, `WidgetPFD`, `VideoViewer` и `Joystick` - `GUIRenderer` берёт из пропса `extras`. Передайте `UI.GUI_EXTRAS` целиком или только нужные из них. Чего нет в `extras`, то не попадает в сборку приложения и рисуется заглушкой «Компонент не входит в эту сборку». Так веб-интерфейс прошивки без карты и пилотажного прибора меньше примерно на 48 КБ сжатого JS. Облако и терминал передают полный набор.
|
|
137
|
+
|
|
128
138
|
**📐 Правила для автора GUI.** Рендерер понимает интерфейс по группам, поэтому при сборке в конструкторе соблюдайте правила:
|
|
129
139
|
|
|
130
140
|
1. 🧱 Группа - параметры одного объекта (мотор, канал, контур регулятора). Внутри группы блоки стоят вплотную, без пустых клеток.
|
|
@@ -159,6 +169,7 @@
|
|
|
159
169
|
| `viewer` | наблюдатель: видны только `access` `full` и `viewOnly`, управление отключено; `WidgetWiFi` и `WidgetDeviceInfo` без `onSave` - только для чтения, пароли маской |
|
|
160
170
|
| `persistKey` | ключ хранения в браузере (обычно `ModSN`): свёрнутость виджетов, планы `WidgetMap` |
|
|
161
171
|
| `render` | своя отрисовка типа: `{ VideoViewer: snippet }`, сниппет получает компонент |
|
|
172
|
+
| `extras` | тяжёлые компоненты: `GUI_EXTRAS` или их часть; тип без компонента рисуется заглушкой |
|
|
162
173
|
| `onError` | готовый текст ошибки на языке библиотеки: команда не собрана, ошибка передачи файла, сбой поиска сетей WiFi (ER! или нет ответа) |
|
|
163
174
|
|
|
164
175
|
```ts
|
|
@@ -230,7 +241,9 @@ socket.send(valueToCbor(encodeWsEnvelope("SET", "JoinDev", { DevSN, Watch: true
|
|
|
230
241
|
|
|
231
242
|
**Реестр.**
|
|
232
243
|
|
|
233
|
-
- `
|
|
244
|
+
- `COMPONENT_META[type]` - `{ io, fields? }`: обмен с устройством (`none`, `read`, `write`, `readWrite`, `widget`) и поля смарт-виджета, без самих компонентов (`componentMeta.ts`). Его берёт `GUIRenderer`.
|
|
245
|
+
- `COMPONENTS[type]` - `{ view, io, fields? }`: то же плюс компонент отрисовки, для конструктора. Тянет в сборку все виджеты, поэтому в рендерере не используется.
|
|
246
|
+
- `package.json` объявляет `"sideEffects": ["**/*.css"]`: без этого сборщик приложения не может выбросить неиспользуемые модули библиотеки.
|
|
234
247
|
- `componentVariables(component)` - переменные устройства компонента (список переменных конструктора).
|
|
235
248
|
- `UIComponent` - объединение по `type`: после `component.type === "Button"` у `properties` тип `IButtonProps`, `UIComponent<"Button">` - компонент одного типа.
|
|
236
249
|
- В `poe-svelte-ui-lib/constructor`: `PANELS[type]` - панель свойств, `COMPONENT_DEFAULTS`, `COMPONENT_SIZES`, `minComponentWidth`, `createComponent(type, { col, row }, parentId, { tab, areaWidth })`, `applyPropertyChange(component, change)`.
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
type DeviceLink,
|
|
28
28
|
type DevicePacket,
|
|
29
29
|
} from "../gui"
|
|
30
|
-
import {
|
|
30
|
+
import { COMPONENT_META } from "../componentMeta"
|
|
31
31
|
import Accordion from "../Accordion/Accordion.svelte"
|
|
32
32
|
import Tabs from "../Tabs/Tabs.svelte"
|
|
33
33
|
import Button from "../Button/Button.svelte"
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
import Select from "../Select/Select.svelte"
|
|
36
36
|
import Switch from "../Switch/Switch.svelte"
|
|
37
37
|
import Slider from "../Slider/Slider.svelte"
|
|
38
|
-
import Joystick from "../Joystick/Joystick.svelte"
|
|
39
38
|
import Widget from "../Widget/Widget.svelte"
|
|
40
39
|
import TextField from "../TextField/TextField.svelte"
|
|
41
40
|
import Divider from "../Divider/Divider.svelte"
|
|
@@ -43,15 +42,13 @@
|
|
|
43
42
|
import Graph from "../Graph/Graph.svelte"
|
|
44
43
|
import PeriodChart from "../PeriodChart/PeriodChart.svelte"
|
|
45
44
|
import FileAttach from "../FileAttach/FileAttach.svelte"
|
|
46
|
-
import VideoViewer from "../VideoViewer/VideoViewer.svelte"
|
|
47
45
|
import WidgetWiFi from "../WidgetWiFi/WidgetWiFi.svelte"
|
|
48
46
|
import WidgetDeviceInfo from "../WidgetDeviceInfo/WidgetDeviceInfo.svelte"
|
|
49
47
|
import WidgetFileSystem from "../WidgetFileSystem/WidgetFileSystem.svelte"
|
|
50
48
|
import WidgetStackInfo from "../WidgetStackInfo/WidgetStackInfo.svelte"
|
|
51
49
|
import WidgetRGBStrip from "../WidgetRGBStrip/WidgetRGBStrip.svelte"
|
|
52
|
-
import WidgetPFD from "../WidgetPFD/WidgetPFD.svelte"
|
|
53
|
-
import WidgetMap from "../WidgetMap/WidgetMap.svelte"
|
|
54
50
|
import DeviceTable from "./DeviceTable.svelte"
|
|
51
|
+
import type { GuiExtras } from "./extras"
|
|
55
52
|
|
|
56
53
|
interface Props {
|
|
57
54
|
components: UIComponent[]
|
|
@@ -64,11 +61,16 @@
|
|
|
64
61
|
persistKey?: string
|
|
65
62
|
/* Своя отрисовка типа (например VideoViewer с потоком приложения) */
|
|
66
63
|
render?: Partial<Record<UIType, Snippet<[UIComponent]>>>
|
|
64
|
+
/* Тяжёлые компоненты (GUI_EXTRAS или их часть): без них тип рисуется заглушкой и не попадает в сборку приложения */
|
|
65
|
+
extras?: GuiExtras
|
|
67
66
|
/* Ошибка команды или передачи файла, для уведомления */
|
|
68
67
|
onError?: (message: string) => void
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
let { components, link, language, viewer = false, persistKey, render, onError }: Props = $props()
|
|
70
|
+
let { components, link, language, viewer = false, persistKey, render, extras, onError }: Props = $props()
|
|
71
|
+
|
|
72
|
+
/* Типы из GUI_EXTRAS - списком, а не из модуля: импорт GUI_EXTRAS сюда затянул бы их в любую сборку */
|
|
73
|
+
const EXTRA_TYPES: readonly UIType[] = ["Joystick", "VideoViewer", "WidgetPFD", "WidgetMap"]
|
|
72
74
|
|
|
73
75
|
/* Кэш по ссылке и языку: localizeDeep создаёт новые объекты, без кэша обновление значений сбрасывало бы раскрытые аккордеоны и вкладки */
|
|
74
76
|
let localized: { src?: UIComponent[]; lang?: string; out: UIComponent[] } = { out: [] }
|
|
@@ -234,7 +236,7 @@
|
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
const persist = (component: UIComponent) => (persistKey ? `${persistKey}|${component.id}` : undefined)
|
|
237
|
-
const writable = (component: UIComponent) => !viewer &&
|
|
239
|
+
const writable = (component: UIComponent) => !viewer && COMPONENT_META[component.type].io !== "none"
|
|
238
240
|
</script>
|
|
239
241
|
|
|
240
242
|
<div bind:clientWidth={width}>
|
|
@@ -345,7 +347,10 @@
|
|
|
345
347
|
value={link.get(id) as number | [number, number]}
|
|
346
348
|
onUpdate={(value) => change(component, value)}
|
|
347
349
|
/>
|
|
348
|
-
{:else if component.type
|
|
350
|
+
{:else if EXTRA_TYPES.includes(component.type) && !extras?.[component.type as keyof GuiExtras]}
|
|
351
|
+
<p class="flex h-full items-center justify-center p-2 text-center text-[12px] text-(--muted-color)">{$T("gui.extra_missing")}: {component.type}</p>
|
|
352
|
+
{:else if component.type === "Joystick" && extras?.Joystick}
|
|
353
|
+
{@const Joystick = extras.Joystick}
|
|
349
354
|
<Joystick
|
|
350
355
|
{...component.properties}
|
|
351
356
|
readonly={locked || component.properties.readonly}
|
|
@@ -390,7 +395,8 @@
|
|
|
390
395
|
disabled={locked || component.properties.disabled}
|
|
391
396
|
onUpdate={(file) => file && fs().upload(file.name, file).catch(report)}
|
|
392
397
|
/>
|
|
393
|
-
{:else if component.type === "VideoViewer"}
|
|
398
|
+
{:else if component.type === "VideoViewer" && extras?.VideoViewer}
|
|
399
|
+
{@const VideoViewer = extras.VideoViewer}
|
|
394
400
|
<VideoViewer {...component.properties} />
|
|
395
401
|
{:else if component.type === "WidgetWiFi"}
|
|
396
402
|
{@const props = component.properties}
|
|
@@ -457,13 +463,15 @@
|
|
|
457
463
|
onUpdate={locked ? undefined : (value, field) => saveFields(prefix, [field], { [field]: value }, props.keys)}
|
|
458
464
|
onSave={locked ? undefined : (hardware) => saveFields(prefix, WIDGET_SAVE_FIELDS.WidgetRGBStrip, hardware, props.keys)}
|
|
459
465
|
/>
|
|
460
|
-
{:else if component.type === "WidgetPFD"}
|
|
466
|
+
{:else if component.type === "WidgetPFD" && extras?.WidgetPFD}
|
|
467
|
+
{@const WidgetPFD = extras.WidgetPFD}
|
|
461
468
|
<WidgetPFD
|
|
462
469
|
{...component.properties}
|
|
463
470
|
value={fields(component, widgetPrefixes(component.type, component.properties)[0], WIDGET_FIELDS.WidgetPFD)}
|
|
464
471
|
persistKey={persist(component)}
|
|
465
472
|
/>
|
|
466
|
-
{:else if component.type === "WidgetMap"}
|
|
473
|
+
{:else if component.type === "WidgetMap" && extras?.WidgetMap}
|
|
474
|
+
{@const WidgetMap = extras.WidgetMap}
|
|
467
475
|
<WidgetMap
|
|
468
476
|
{...component.properties}
|
|
469
477
|
value={stable(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
2
|
import type { UIComponent, UIType } from "../types";
|
|
3
3
|
import { type DeviceLink } from "../gui";
|
|
4
|
+
import type { GuiExtras } from "./extras";
|
|
4
5
|
interface Props {
|
|
5
6
|
components: UIComponent[];
|
|
6
7
|
link: DeviceLink;
|
|
@@ -8,6 +9,7 @@ interface Props {
|
|
|
8
9
|
viewer?: boolean;
|
|
9
10
|
persistKey?: string;
|
|
10
11
|
render?: Partial<Record<UIType, Snippet<[UIComponent]>>>;
|
|
12
|
+
extras?: GuiExtras;
|
|
11
13
|
onError?: (message: string) => void;
|
|
12
14
|
}
|
|
13
15
|
declare const GUIRenderer: import("svelte").Component<Props, {}, "">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const GUI_EXTRAS: {
|
|
2
|
+
Joystick: import("svelte").Component<import("..").IJoystickProps, {}, "value">;
|
|
3
|
+
VideoViewer: import("svelte").Component<import("..").IVideoViewerProps, {
|
|
4
|
+
getDevices: () => Promise<MediaDeviceInfo[]>;
|
|
5
|
+
startStream: (devId?: string) => Promise<void>;
|
|
6
|
+
stopStream: () => void;
|
|
7
|
+
}, "">;
|
|
8
|
+
WidgetPFD: import("svelte").Component<import("..").IWidgetPFDProps, {}, "collapsed">;
|
|
9
|
+
WidgetMap: import("svelte").Component<import("..").IWidgetMapProps, {}, "collapsed" | "plan" | "route" | "trackEnabled" | "trackLength" | "markerTimeout">;
|
|
10
|
+
};
|
|
11
|
+
export type GuiExtras = Partial<typeof GUI_EXTRAS>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* src/lib/GUIRenderer/extras.ts - тяжёлые компоненты GUI (карта, пилотажный прибор, видео, джойстик): GUIRenderer получает их через extras, без них они не попадают в сборку приложения */
|
|
2
|
+
import Joystick from "../Joystick/Joystick.svelte";
|
|
3
|
+
import VideoViewer from "../VideoViewer/VideoViewer.svelte";
|
|
4
|
+
import WidgetPFD from "../WidgetPFD/WidgetPFD.svelte";
|
|
5
|
+
import WidgetMap from "../WidgetMap/WidgetMap.svelte";
|
|
6
|
+
export const GUI_EXTRAS = { Joystick, VideoViewer, WidgetPFD, WidgetMap };
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
1. Перетащите виджет на макет. Привязывать поля не нужно: виджет сам знает, где лежат данные устройства.
|
|
21
21
|
2. Если нужно, задайте заголовок. Без него карточка называется «Об устройстве» на языке пользователя.
|
|
22
22
|
3. Выберите мастер-цвет: в него окрасятся значок и кнопка «Сохранить».
|
|
23
|
-
4. В группе «Поля»
|
|
23
|
+
4. В группе «Поля» отметьте галочками, что показывать. У отмеченного поля рядом его ключ в прошивке, его меняют, только если в прошивке другое имя. По умолчанию набор шлюза ESP. Для модуля STM: `DevSN`, `DevBusID`, `DevFW`, `RunCnt`, `DevName`, `SCLL`.
|
|
24
24
|
5. Команды перезагрузки и сброса уже настроены под прошивку, менять их не нужно.
|
|
25
25
|
|
|
26
26
|
## 💡 Полезно знать
|
|
@@ -132,8 +132,7 @@
|
|
|
132
132
|
Панель для конструктора DevCloud. Значения по умолчанию совпадают с прошивкой.
|
|
133
133
|
|
|
134
134
|
- **Общие:** заголовок и переводы, префикс группы, мастер-цвет.
|
|
135
|
-
- **Поля:**
|
|
136
|
-
- **Ключи устройства:** другое имя для каждого из 12 полей.
|
|
135
|
+
- **Поля:** 12 строк. Галочка - поле показывается и сохраняется (`show`), рядом у отмеченного - ключ в прошивке (`keys`). У неотмеченных ключа нет, панель не загромождается.
|
|
137
136
|
- **Команда перезагрузки:** заголовок пакета и аргумент.
|
|
138
137
|
- **Команда сброса настроек:** заголовок пакета и аргумент.
|
|
139
138
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- $lib/WidgetDeviceInfo/WidgetDeviceInfoProps.svelte - панель пропсов конструктора для WidgetDeviceInfo: заголовок/мастер-цвет/префикс группы,
|
|
1
|
+
<!-- $lib/WidgetDeviceInfo/WidgetDeviceInfoProps.svelte - панель пропсов конструктора для WidgetDeviceInfo: заголовок/мастер-цвет/префикс группы, поля списком: галочка - показывать (show), рядом у включённых - ключ поля в прошивке (keys) и команды перезагрузки и сброса - все с дефолтами, равными текущей прошивочной конвенции (COMPONENT_DEFAULTS). -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { DEVICE_INFO_DEFAULT_FIELDS, WIDGET_FIELDS } from "../gui"
|
|
4
4
|
import TextsEditor from "../TextsEditor.svelte"
|
|
@@ -21,11 +21,35 @@
|
|
|
21
21
|
} = $props()
|
|
22
22
|
|
|
23
23
|
const edit = $derived(createPropsEditor(component, onPropertyChange))
|
|
24
|
+
const shown = $derived(new Set<string>(component.properties.show ?? DEVICE_INFO_DEFAULT_FIELDS))
|
|
25
|
+
|
|
26
|
+
/* Порядок show - как в списке полей, а не как щёлкали */
|
|
27
|
+
const toggleField = (key: keyof IWidgetDeviceInfoConfig, on: boolean) =>
|
|
28
|
+
edit.set(
|
|
29
|
+
"show",
|
|
30
|
+
DEVICE_INFO_KEYS.filter((field) => (field === key ? on : shown.has(field))),
|
|
31
|
+
)
|
|
24
32
|
</script>
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
<!-- Поле - строка: галочка с именем, у включённого рядом ключ в прошивке; выключенные - одной строкой без ключа -->
|
|
35
|
+
{#snippet WidgetFields()}
|
|
27
36
|
{#each DEVICE_INFO_KEYS as key (key)}
|
|
28
|
-
<
|
|
37
|
+
<div class="flex h-8 items-center gap-2">
|
|
38
|
+
<UI.Switch
|
|
39
|
+
type="checkbox"
|
|
40
|
+
wrapperClass="w-28 shrink-0 justify-start"
|
|
41
|
+
label={{ name: key }}
|
|
42
|
+
value={shown.has(key) ? 1 : 0}
|
|
43
|
+
onUpdate={(value) => toggleField(key, value === 1)}
|
|
44
|
+
/>
|
|
45
|
+
{#if shown.has(key)}
|
|
46
|
+
<UI.Input
|
|
47
|
+
wrapperClass="min-w-0 flex-1"
|
|
48
|
+
value={component.properties.keys?.[key] ?? key}
|
|
49
|
+
onUpdate={(value) => edit.patch("keys", { [key]: String(value) })}
|
|
50
|
+
/>
|
|
51
|
+
{/if}
|
|
52
|
+
</div>
|
|
29
53
|
{/each}
|
|
30
54
|
{/snippet}
|
|
31
55
|
|
|
@@ -53,21 +77,8 @@
|
|
|
53
77
|
<CommonSnippets snippet="Accent" {component} {onPropertyChange} />
|
|
54
78
|
</PropsGroup>
|
|
55
79
|
<PropsGroup label={$T("widget.info.fields")}>
|
|
56
|
-
<UI.
|
|
57
|
-
|
|
58
|
-
multiSelect
|
|
59
|
-
help={{ info: $T("widget.info.fields.info") }}
|
|
60
|
-
options={DEVICE_INFO_KEYS.map((key) => ({ value: key, name: key }))}
|
|
61
|
-
value={component.properties.show ?? DEVICE_INFO_DEFAULT_FIELDS}
|
|
62
|
-
onUpdate={(fields) =>
|
|
63
|
-
edit.set(
|
|
64
|
-
"show",
|
|
65
|
-
DEVICE_INFO_KEYS.filter((key) => (fields as string[]).includes(key)),
|
|
66
|
-
)}
|
|
67
|
-
/>
|
|
68
|
-
</PropsGroup>
|
|
69
|
-
<PropsGroup label={$T("widget.common.device_keys")}>
|
|
70
|
-
{@render WidgetKeys()}
|
|
80
|
+
<UI.FieldLabel label={{ name: $T("widget.info.fields.list") }} info={$T("widget.info.fields.info")} />
|
|
81
|
+
{@render WidgetFields()}
|
|
71
82
|
</PropsGroup>
|
|
72
83
|
<PropsGroup label={$T("widget.info.restart_command")}>
|
|
73
84
|
{@render WidgetCommand("restartCommand", "Restart")}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UIType } from "./types";
|
|
2
|
+
export type ComponentIO = "none" | "read" | "write" | "readWrite" | "widget";
|
|
3
|
+
export interface ComponentMeta {
|
|
4
|
+
io: ComponentIO;
|
|
5
|
+
fields?: object;
|
|
6
|
+
}
|
|
7
|
+
export declare const COMPONENT_META: Record<UIType, ComponentMeta>;
|
|
8
|
+
export declare const componentVariables: (component: {
|
|
9
|
+
type: UIType;
|
|
10
|
+
properties: object;
|
|
11
|
+
}) => string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* $lib/componentMeta.ts - метаданные типов GUI без самих компонентов: обмен с устройством и поля смарт-виджетов. GUIRenderer берёт их отсюда, а не из registry.ts, иначе в сборку приложения попали бы все виджеты */
|
|
2
|
+
import { WIDGET_FIELDS, widgetKey, widgetPrefixes } from "./gui";
|
|
3
|
+
export const COMPONENT_META = {
|
|
4
|
+
Accordion: { io: "none" },
|
|
5
|
+
Tabs: { io: "none" },
|
|
6
|
+
TextField: { io: "none" },
|
|
7
|
+
Divider: { io: "none" },
|
|
8
|
+
Button: { io: "write" },
|
|
9
|
+
FileAttach: { io: "write" },
|
|
10
|
+
Input: { io: "readWrite" },
|
|
11
|
+
Select: { io: "readWrite" },
|
|
12
|
+
Switch: { io: "readWrite" },
|
|
13
|
+
Slider: { io: "readWrite" },
|
|
14
|
+
Joystick: { io: "readWrite" },
|
|
15
|
+
Widget: { io: "readWrite" },
|
|
16
|
+
ProgressBar: { io: "read" },
|
|
17
|
+
Graph: { io: "read" },
|
|
18
|
+
PeriodChart: { io: "read" },
|
|
19
|
+
Table: { io: "read" },
|
|
20
|
+
VideoViewer: { io: "none" },
|
|
21
|
+
WidgetWiFi: { io: "widget", fields: WIDGET_FIELDS.WidgetWiFi },
|
|
22
|
+
WidgetDeviceInfo: { io: "widget", fields: WIDGET_FIELDS.WidgetDeviceInfo },
|
|
23
|
+
WidgetFileSystem: { io: "widget", fields: WIDGET_FIELDS.WidgetFileSystem },
|
|
24
|
+
WidgetStackInfo: { io: "widget", fields: WIDGET_FIELDS.WidgetStackInfo },
|
|
25
|
+
WidgetRGBStrip: { io: "widget", fields: WIDGET_FIELDS.WidgetRGBStrip },
|
|
26
|
+
WidgetPFD: { io: "widget", fields: WIDGET_FIELDS.WidgetPFD },
|
|
27
|
+
WidgetMap: { io: "widget", fields: WIDGET_FIELDS.WidgetMap },
|
|
28
|
+
};
|
|
29
|
+
/* Переменные устройства компонента (без префикса модуля): поля смарт-виджета, properties.id компонента с данными, переменные уровней PeriodChart */
|
|
30
|
+
export const componentVariables = (component) => {
|
|
31
|
+
const entry = COMPONENT_META[component.type];
|
|
32
|
+
const props = component.properties;
|
|
33
|
+
if (entry.io === "widget")
|
|
34
|
+
return widgetPrefixes(component.type, props).flatMap((prefix) => Object.keys(entry.fields ?? {}).map((field) => widgetKey(prefix, field, props.keys)));
|
|
35
|
+
if (entry.io === "none" || entry.io === "write" || !props.id)
|
|
36
|
+
return [];
|
|
37
|
+
return [props.id, ...(props.levels ?? []).flatMap((level) => (level.variable ? [level.variable] : []))];
|
|
38
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,9 @@ export * from "./locales/languages";
|
|
|
43
43
|
export { localizeDeep, type LocalizedText } from "./locales/localize";
|
|
44
44
|
export { accentStyle, ACCENT_COLORS, type AccentColor } from "./accent";
|
|
45
45
|
export { default as GUIRenderer } from "./GUIRenderer/GUIRenderer.svelte";
|
|
46
|
-
export {
|
|
46
|
+
export { GUI_EXTRAS, type GuiExtras } from "./GUIRenderer/extras";
|
|
47
|
+
export { COMPONENTS, type ComponentEntry } from "./registry";
|
|
48
|
+
export { COMPONENT_META, componentVariables, type ComponentMeta, type ComponentIO } from "./componentMeta";
|
|
47
49
|
export { GUI_GRID, isWidgetType, spanRows, WIDGET_FIELDS, WIDGET_SAVE_FIELDS, widgetKey, widgetPrefixes, readWidgetFields, widgetPacket, bitRange, readBits, writeBits, commandPacket, tablePacket, mergeDevicePayload, type WidgetFieldsType, type DeviceLink, type DevicePacket, } from "./gui";
|
|
48
50
|
export { createFsTransfer, sendCommand, argumentCode, FsTransferError, FsNameError, type FsErrorCode, type DeviceReply, type DeviceTransport, type FsTransfer, type FsTransferOptions, type FsProgress, } from "./fsTransfer";
|
|
49
51
|
export { copyText } from "./clipboard";
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,9 @@ export * from "./locales/languages";
|
|
|
44
44
|
export { localizeDeep } from "./locales/localize";
|
|
45
45
|
export { accentStyle, ACCENT_COLORS } from "./accent";
|
|
46
46
|
export { default as GUIRenderer } from "./GUIRenderer/GUIRenderer.svelte";
|
|
47
|
-
export {
|
|
47
|
+
export { GUI_EXTRAS } from "./GUIRenderer/extras";
|
|
48
|
+
export { COMPONENTS } from "./registry";
|
|
49
|
+
export { COMPONENT_META, componentVariables } from "./componentMeta";
|
|
48
50
|
export { GUI_GRID, isWidgetType, spanRows, WIDGET_FIELDS, WIDGET_SAVE_FIELDS, widgetKey, widgetPrefixes, readWidgetFields, widgetPacket, bitRange, readBits, writeBits, commandPacket, tablePacket, mergeDevicePayload, } from "./gui";
|
|
49
51
|
export { createFsTransfer, sendCommand, argumentCode, FsTransferError, FsNameError, } from "./fsTransfer";
|
|
50
52
|
export { copyText } from "./clipboard";
|
|
@@ -14,6 +14,11 @@ declare const translations: {
|
|
|
14
14
|
en: string;
|
|
15
15
|
zh: string;
|
|
16
16
|
};
|
|
17
|
+
"gui.extra_missing": {
|
|
18
|
+
ru: string;
|
|
19
|
+
en: string;
|
|
20
|
+
zh: string;
|
|
21
|
+
};
|
|
17
22
|
"gui.error.event_handler": {
|
|
18
23
|
ru: string;
|
|
19
24
|
en: string;
|
|
@@ -314,6 +319,11 @@ declare const translations: {
|
|
|
314
319
|
en: string;
|
|
315
320
|
zh: string;
|
|
316
321
|
};
|
|
322
|
+
"widget.info.fields.list": {
|
|
323
|
+
ru: string;
|
|
324
|
+
en: string;
|
|
325
|
+
zh: string;
|
|
326
|
+
};
|
|
317
327
|
"widget.info.name_required": {
|
|
318
328
|
ru: string;
|
|
319
329
|
en: string;
|
|
@@ -2,6 +2,7 @@ const translations = {
|
|
|
2
2
|
"common.select_tag": { ru: "Сделайте выбор", en: "Make a choice", zh: "请选择" },
|
|
3
3
|
"common.table.clear": { ru: "Очистить таблицу", en: "Clear table", zh: "清空表格" },
|
|
4
4
|
"library.retry": { ru: "Повторить", en: "Retry", zh: "重试" },
|
|
5
|
+
"gui.extra_missing": { ru: "Компонент не входит в эту сборку", en: "Component is not included in this build", zh: "此版本不包含该组件" },
|
|
5
6
|
"gui.error.event_handler": {
|
|
6
7
|
ru: "Команда компонента не собрана: проверьте eventHandler",
|
|
7
8
|
en: "Component command not built: check eventHandler",
|
|
@@ -79,10 +80,11 @@ const translations = {
|
|
|
79
80
|
"widget.info.log_level": { ru: "Уровень логов", en: "Log level", zh: "日志级别" },
|
|
80
81
|
"widget.info.fields": { ru: "Поля", en: "Fields", zh: "字段" },
|
|
81
82
|
"widget.info.fields.info": {
|
|
82
|
-
ru: "
|
|
83
|
-
en: "
|
|
84
|
-
zh: "
|
|
83
|
+
ru: "Галочка - поле показывается и сохраняется, рядом - его ключ в прошивке. Скрытые поля не уходят в устройство. STM: DevSN, DevBusID, DevFW, RunCnt, DevName, SCLL",
|
|
84
|
+
en: "Checked - the field is shown and saved, next to it - its key in the firmware. Hidden fields are not sent to the device. STM: DevSN, DevBusID, DevFW, RunCnt, DevName, SCLL",
|
|
85
|
+
zh: "勾选 - 显示并保存该字段,旁边是固件中的键。隐藏字段不会发送到设备。STM:DevSN、DevBusID、DevFW、RunCnt、DevName、SCLL",
|
|
85
86
|
},
|
|
87
|
+
"widget.info.fields.list": { ru: "Поле и ключ в прошивке", en: "Field and firmware key", zh: "字段和固件键" },
|
|
86
88
|
"widget.info.name_required": { ru: "Укажите имя устройства", en: "Enter the device name", zh: "请输入设备名称" },
|
|
87
89
|
"widget.stack.title": { ru: "Стек и задачи", en: "Stack and Tasks", zh: "堆栈与任务" },
|
|
88
90
|
"widget.stack.off": { ru: "Выкл", en: "Off", zh: "关" },
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { Component } from "svelte";
|
|
2
|
+
import { type ComponentMeta } from "./componentMeta";
|
|
2
3
|
import type { UIType } from "./types";
|
|
3
|
-
export
|
|
4
|
-
export interface ComponentEntry {
|
|
4
|
+
export interface ComponentEntry extends ComponentMeta {
|
|
5
5
|
view: Component<any, any, any>;
|
|
6
|
-
io: ComponentIO;
|
|
7
|
-
fields?: object;
|
|
8
6
|
}
|
|
9
7
|
export declare const COMPONENTS: Record<UIType, ComponentEntry>;
|
|
10
|
-
export declare const componentVariables: (component: {
|
|
11
|
-
type: UIType;
|
|
12
|
-
properties: object;
|
|
13
|
-
}) => string[];
|
package/dist/registry.js
CHANGED
|
@@ -22,40 +22,32 @@ import WidgetStackInfo from "./WidgetStackInfo/WidgetStackInfo.svelte";
|
|
|
22
22
|
import WidgetRGBStrip from "./WidgetRGBStrip/WidgetRGBStrip.svelte";
|
|
23
23
|
import WidgetPFD from "./WidgetPFD/WidgetPFD.svelte";
|
|
24
24
|
import WidgetMap from "./WidgetMap/WidgetMap.svelte";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Divider
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Input
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
VideoViewer
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/* Переменные устройства компонента (без префикса модуля): поля смарт-виджета, properties.id компонента с данными, переменные уровней PeriodChart */
|
|
53
|
-
export const componentVariables = (component) => {
|
|
54
|
-
const entry = COMPONENTS[component.type];
|
|
55
|
-
const props = component.properties;
|
|
56
|
-
if (entry.io === "widget")
|
|
57
|
-
return widgetPrefixes(component.type, props).flatMap((prefix) => Object.keys(entry.fields ?? {}).map((field) => widgetKey(prefix, field, props.keys)));
|
|
58
|
-
if (entry.io === "none" || entry.io === "write" || !props.id)
|
|
59
|
-
return [];
|
|
60
|
-
return [props.id, ...(props.levels ?? []).flatMap((level) => (level.variable ? [level.variable] : []))];
|
|
25
|
+
import { COMPONENT_META } from "./componentMeta";
|
|
26
|
+
/* Компонент каждого типа - для конструктора: тянет в сборку все виджеты, поэтому GUIRenderer его не импортирует (метаданные - componentMeta.ts) */
|
|
27
|
+
const VIEWS = {
|
|
28
|
+
Accordion,
|
|
29
|
+
Button,
|
|
30
|
+
Divider,
|
|
31
|
+
FileAttach,
|
|
32
|
+
Graph,
|
|
33
|
+
Input,
|
|
34
|
+
Joystick,
|
|
35
|
+
PeriodChart,
|
|
36
|
+
ProgressBar,
|
|
37
|
+
Select,
|
|
38
|
+
Slider,
|
|
39
|
+
Switch,
|
|
40
|
+
Table,
|
|
41
|
+
Tabs,
|
|
42
|
+
TextField,
|
|
43
|
+
VideoViewer,
|
|
44
|
+
Widget,
|
|
45
|
+
WidgetWiFi,
|
|
46
|
+
WidgetDeviceInfo,
|
|
47
|
+
WidgetFileSystem,
|
|
48
|
+
WidgetStackInfo,
|
|
49
|
+
WidgetRGBStrip,
|
|
50
|
+
WidgetPFD,
|
|
51
|
+
WidgetMap,
|
|
61
52
|
};
|
|
53
|
+
export const COMPONENTS = Object.fromEntries(Object.keys(COMPONENT_META).map((type) => [type, { ...COMPONENT_META[type], view: VIEWS[type] }]));
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poe-svelte-ui-lib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"
|
|
7
7
|
},
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"**/*.css"
|
|
12
|
+
],
|
|
10
13
|
"imports": {
|
|
11
14
|
"#lib": "./src/lib/index.ts",
|
|
12
15
|
"#lib/*": "./src/lib/*"
|