poe-svelte-ui-lib 2.11.0 → 2.12.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 +4 -3
- package/dist/GUIRenderer/DeviceTable.svelte +9 -3
- package/dist/GUIRenderer/DeviceTable.svelte.d.ts +2 -0
- package/dist/GUIRenderer/GUIRenderer.svelte +54 -56
- package/dist/GUIRenderer/GUIRenderer.svelte.d.ts +2 -2
- package/dist/gui.d.ts +4 -1
- package/dist/gui.js +2 -0
- package/dist/guiViews.d.ts +52 -0
- package/dist/guiViews.js +54 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/translations.d.ts +1 -1
- package/dist/locales/translations.js +1 -1
- package/package.json +1 -1
- package/dist/GUIRenderer/extras.d.ts +0 -11
- package/dist/GUIRenderer/extras.js +0 -6
package/README.md
CHANGED
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
persistKey={module.ModSN}
|
|
129
129
|
viewer={!canManage}
|
|
130
130
|
render={{ VideoViewer: video }}
|
|
131
|
-
|
|
131
|
+
views={UI.GUI_VIEWS}
|
|
132
132
|
onError={addMessage}
|
|
133
133
|
/>
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
**📦 Что попадает в сборку.**
|
|
136
|
+
**📦 Что попадает в сборку.** `GUIRenderer` сам не импортирует ни одного компонента: каждый тип он берёт из пропса `views`. Облако и терминал передают `UI.GUI_VIEWS` - все типы. Приложению с ограниченной памятью (веб-интерфейс прошивки) достаточно перечислить только нужные: `{ Button: UI.Button, Input: UI.Input, ... }`. Чего нет в `views`, то не попадает в сборку и рисуется заглушкой «Компонент не входит в эту сборку». Какие типы есть в GUI, возвращает `guiTypes(components)`.
|
|
137
137
|
|
|
138
138
|
**📐 Правила для автора GUI.** Рендерер понимает интерфейс по группам, поэтому при сборке в конструкторе соблюдайте правила:
|
|
139
139
|
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
| `viewer` | наблюдатель: видны только `access` `full` и `viewOnly`, управление отключено; `WidgetWiFi` и `WidgetDeviceInfo` без `onSave` - только для чтения, пароли маской |
|
|
170
170
|
| `persistKey` | ключ хранения в браузере (обычно `ModSN`): свёрнутость виджетов, планы `WidgetMap` |
|
|
171
171
|
| `render` | своя отрисовка типа: `{ VideoViewer: snippet }`, сниппет получает компонент |
|
|
172
|
-
| `
|
|
172
|
+
| `views` | компоненты отрисовки по типу: `GUI_VIEWS` или только нужные; тип без компонента рисуется заглушкой |
|
|
173
173
|
| `onError` | готовый текст ошибки на языке библиотеки: команда не собрана, ошибка передачи файла, сбой поиска сетей WiFi (ER! или нет ответа) |
|
|
174
174
|
|
|
175
175
|
```ts
|
|
@@ -238,6 +238,7 @@ socket.send(valueToCbor(encodeWsEnvelope("SET", "JoinDev", { DevSN, Watch: true
|
|
|
238
238
|
| `widgetPacket(prefix, fields, values, keys)` | Payload `SET ModCfg` виджета |
|
|
239
239
|
| `WIDGET_FIELDS`, `WIDGET_SAVE_FIELDS`, `widgetPrefixes` | поля смарт-виджетов (из них выведены `IWidgetWiFiConfig` и остальные), сохраняемые поля, группы |
|
|
240
240
|
| `GUI_GRID`, `spanRows`, `isWidgetType` | сетка |
|
|
241
|
+
| `guiTypes` | типы компонентов в GUI - из них приложение собирает `views` рендерера |
|
|
241
242
|
|
|
242
243
|
**Реестр.**
|
|
243
244
|
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
<!-- $lib/GUIRenderer/DeviceTable.svelte - таблица рендерера: обычная - строки из value, журнал (dataBuffer.stashData) - каждое новое value добавляется push() -->
|
|
2
2
|
<script lang="ts">
|
|
3
|
-
import Table from "../Table/Table.svelte"
|
|
3
|
+
import type Table from "../Table/Table.svelte"
|
|
4
4
|
import type { ITableButton, ITableProps } from "../types"
|
|
5
5
|
|
|
6
6
|
type Row = Record<string, unknown>
|
|
7
|
-
|
|
7
|
+
/* view - компонент Table из views рендерера: таблица попадает в сборку, только если приложение её передало */
|
|
8
|
+
let {
|
|
9
|
+
view: TableView,
|
|
10
|
+
properties,
|
|
11
|
+
value,
|
|
12
|
+
onClick,
|
|
13
|
+
}: { view: typeof Table; properties: ITableProps<Row>; value: unknown; onClick?: (row: Row, button: ITableButton<Row>) => void } = $props()
|
|
8
14
|
|
|
9
15
|
let table: Table<Row> | undefined = $state()
|
|
10
16
|
const rows = $derived((Array.isArray(value) ? value : value && typeof value === "object" ? [value] : []) as Row[])
|
|
@@ -14,4 +20,4 @@
|
|
|
14
20
|
})
|
|
15
21
|
</script>
|
|
16
22
|
|
|
17
|
-
<
|
|
23
|
+
<TableView bind:this={table} {...properties} body={properties.dataBuffer?.stashData ? undefined : rows} {onClick} />
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type Table from "../Table/Table.svelte";
|
|
1
2
|
import type { ITableButton, ITableProps } from "../types";
|
|
2
3
|
type Row = Record<string, unknown>;
|
|
3
4
|
type $$ComponentProps = {
|
|
5
|
+
view: typeof Table;
|
|
4
6
|
properties: ITableProps<Row>;
|
|
5
7
|
value: unknown;
|
|
6
8
|
onClick?: (row: Row, button: ITableButton<Row>) => void;
|
|
@@ -28,27 +28,8 @@
|
|
|
28
28
|
type DevicePacket,
|
|
29
29
|
} from "../gui"
|
|
30
30
|
import { COMPONENT_META } from "../componentMeta"
|
|
31
|
-
import Accordion from "../Accordion/Accordion.svelte"
|
|
32
|
-
import Tabs from "../Tabs/Tabs.svelte"
|
|
33
|
-
import Button from "../Button/Button.svelte"
|
|
34
|
-
import Input from "../Input/Input.svelte"
|
|
35
|
-
import Select from "../Select/Select.svelte"
|
|
36
|
-
import Switch from "../Switch/Switch.svelte"
|
|
37
|
-
import Slider from "../Slider/Slider.svelte"
|
|
38
|
-
import Widget from "../Widget/Widget.svelte"
|
|
39
|
-
import TextField from "../TextField/TextField.svelte"
|
|
40
|
-
import Divider from "../Divider/Divider.svelte"
|
|
41
|
-
import ProgressBar from "../ProgressBar/ProgressBar.svelte"
|
|
42
|
-
import Graph from "../Graph/Graph.svelte"
|
|
43
|
-
import PeriodChart from "../PeriodChart/PeriodChart.svelte"
|
|
44
|
-
import FileAttach from "../FileAttach/FileAttach.svelte"
|
|
45
|
-
import WidgetWiFi from "../WidgetWiFi/WidgetWiFi.svelte"
|
|
46
|
-
import WidgetDeviceInfo from "../WidgetDeviceInfo/WidgetDeviceInfo.svelte"
|
|
47
|
-
import WidgetFileSystem from "../WidgetFileSystem/WidgetFileSystem.svelte"
|
|
48
|
-
import WidgetStackInfo from "../WidgetStackInfo/WidgetStackInfo.svelte"
|
|
49
|
-
import WidgetRGBStrip from "../WidgetRGBStrip/WidgetRGBStrip.svelte"
|
|
50
31
|
import DeviceTable from "./DeviceTable.svelte"
|
|
51
|
-
import type {
|
|
32
|
+
import type { GuiViews } from "../guiViews"
|
|
52
33
|
|
|
53
34
|
interface Props {
|
|
54
35
|
components: UIComponent[]
|
|
@@ -61,16 +42,13 @@
|
|
|
61
42
|
persistKey?: string
|
|
62
43
|
/* Своя отрисовка типа (например VideoViewer с потоком приложения) */
|
|
63
44
|
render?: Partial<Record<UIType, Snippet<[UIComponent]>>>
|
|
64
|
-
/*
|
|
65
|
-
|
|
45
|
+
/* Компоненты отрисовки по типу (GUI_VIEWS или только нужные): тип без компонента рисуется заглушкой и не попадает в сборку приложения */
|
|
46
|
+
views: GuiViews
|
|
66
47
|
/* Ошибка команды или передачи файла, для уведомления */
|
|
67
48
|
onError?: (message: string) => void
|
|
68
49
|
}
|
|
69
50
|
|
|
70
|
-
let { components, link, language, viewer = false, persistKey, render,
|
|
71
|
-
|
|
72
|
-
/* Типы из GUI_EXTRAS - списком, а не из модуля: импорт GUI_EXTRAS сюда затянул бы их в любую сборку */
|
|
73
|
-
const EXTRA_TYPES: readonly UIType[] = ["Joystick", "VideoViewer", "WidgetPFD", "WidgetMap"]
|
|
51
|
+
let { components, link, language, viewer = false, persistKey, render, views, onError }: Props = $props()
|
|
74
52
|
|
|
75
53
|
/* Кэш по ссылке и языку: localizeDeep создаёт новые объекты, без кэша обновление значений сбрасывало бы раскрытые аккордеоны и вкладки */
|
|
76
54
|
let localized: { src?: UIComponent[]; lang?: string; out: UIComponent[] } = { out: [] }
|
|
@@ -298,34 +276,39 @@
|
|
|
298
276
|
<div class={component.type === "Accordion" ? "" : "flex flex-col justify-start"} style={cellStyle(component, fixedHeight)}>
|
|
299
277
|
{#if render?.[component.type]}
|
|
300
278
|
{@render render[component.type]?.(component)}
|
|
301
|
-
{:else if component.type === "Accordion"}
|
|
279
|
+
{:else if component.type === "Accordion" && views.Accordion}
|
|
280
|
+
{@const Accordion = views.Accordion}
|
|
302
281
|
<Accordion {...component.properties}>
|
|
303
282
|
<!-- Своя сетка содержимого во всю ширину аккордеона: колонок не меньше, чем у самого дальнего блока -->
|
|
304
283
|
<div class="min-w-0" style="grid-column: 1 / -1; grid-row: 1 / -1">
|
|
305
284
|
{@render Layout(childrenOf(component).filter(visible), component.properties.size?.width ?? 1, !!component.properties.image)}
|
|
306
285
|
</div>
|
|
307
286
|
</Accordion>
|
|
308
|
-
{:else if component.type === "Tabs"}
|
|
287
|
+
{:else if component.type === "Tabs" && views.Tabs}
|
|
288
|
+
{@const Tabs = views.Tabs}
|
|
309
289
|
<!-- Содержимое вкладки - через Layout, как у Accordion: на телефоне раскладка по группам, а не одна колонка сетки size.width -->
|
|
310
290
|
<Tabs {...component.properties} apiArray={childrenOf(component)}>
|
|
311
291
|
{#snippet Content(list: UIComponent[])}
|
|
312
292
|
{@render Layout(list.filter(visible), component.properties.size?.width ?? 1, false)}
|
|
313
293
|
{/snippet}
|
|
314
294
|
</Tabs>
|
|
315
|
-
{:else if component.type === "Button"}
|
|
295
|
+
{:else if component.type === "Button" && views.Button}
|
|
296
|
+
{@const Button = views.Button}
|
|
316
297
|
<Button
|
|
317
298
|
{...component.properties}
|
|
318
299
|
disabled={locked || component.properties.disabled}
|
|
319
300
|
onClick={() => dispatch(commandPacket(component.eventHandler, get))}
|
|
320
301
|
/>
|
|
321
|
-
{:else if component.type === "Input"}
|
|
302
|
+
{:else if component.type === "Input" && views.Input}
|
|
303
|
+
{@const Input = views.Input}
|
|
322
304
|
<Input
|
|
323
305
|
{...component.properties}
|
|
324
306
|
readonly={locked || component.properties.readonly}
|
|
325
307
|
value={(readBits(component, link.get(id)) as string | number | undefined) ?? component.properties.value}
|
|
326
308
|
onUpdate={(value) => change(component, value)}
|
|
327
309
|
/>
|
|
328
|
-
{:else if component.type === "Select"}
|
|
310
|
+
{:else if component.type === "Select" && views.Select}
|
|
311
|
+
{@const Select = views.Select}
|
|
329
312
|
<Select
|
|
330
313
|
{...component.properties}
|
|
331
314
|
disabled={locked || component.properties.disabled}
|
|
@@ -333,49 +316,57 @@
|
|
|
333
316
|
options={selectOptions(component)}
|
|
334
317
|
onUpdate={(value) => change(component, value)}
|
|
335
318
|
/>
|
|
336
|
-
{:else if component.type === "Switch"}
|
|
319
|
+
{:else if component.type === "Switch" && views.Switch}
|
|
320
|
+
{@const Switch = views.Switch}
|
|
337
321
|
<Switch
|
|
338
322
|
{...component.properties}
|
|
339
323
|
disabled={locked || component.properties.disabled}
|
|
340
324
|
value={link.get(id) as number}
|
|
341
325
|
onUpdate={(value) => change(component, value)}
|
|
342
326
|
/>
|
|
343
|
-
{:else if component.type === "Slider"}
|
|
327
|
+
{:else if component.type === "Slider" && views.Slider}
|
|
328
|
+
{@const Slider = views.Slider}
|
|
344
329
|
<Slider
|
|
345
330
|
{...component.properties}
|
|
346
331
|
disabled={locked || component.properties.disabled}
|
|
347
332
|
value={link.get(id) as number | [number, number]}
|
|
348
333
|
onUpdate={(value) => change(component, value)}
|
|
349
334
|
/>
|
|
350
|
-
{:else if
|
|
351
|
-
<p class="flex h-full items-center justify-center p-2 text-center text-[12px] text-(--muted-color)">{$T("gui.
|
|
352
|
-
{:else if component.type === "Joystick" &&
|
|
353
|
-
{@const Joystick =
|
|
335
|
+
{:else if !views[component.type]}
|
|
336
|
+
<p class="flex h-full items-center justify-center p-2 text-center text-[12px] text-(--muted-color)">{$T("gui.view_missing")}: {component.type}</p>
|
|
337
|
+
{:else if component.type === "Joystick" && views.Joystick}
|
|
338
|
+
{@const Joystick = views.Joystick}
|
|
354
339
|
<Joystick
|
|
355
340
|
{...component.properties}
|
|
356
341
|
readonly={locked || component.properties.readonly}
|
|
357
342
|
value={link.get(id) as number[]}
|
|
358
343
|
onUpdate={(value) => change(component, value)}
|
|
359
344
|
/>
|
|
360
|
-
{:else if component.type === "Widget"}
|
|
345
|
+
{:else if component.type === "Widget" && views.Widget}
|
|
346
|
+
{@const Widget = views.Widget}
|
|
361
347
|
<Widget
|
|
362
348
|
{...component.properties}
|
|
363
349
|
readonly={locked || component.properties.readonly}
|
|
364
350
|
value={link.get(id) as number}
|
|
365
351
|
onUpdate={(value) => change(component, value)}
|
|
366
352
|
/>
|
|
367
|
-
{:else if component.type === "TextField"}
|
|
353
|
+
{:else if component.type === "TextField" && views.TextField}
|
|
354
|
+
{@const TextField = views.TextField}
|
|
368
355
|
<TextField {...component.properties} />
|
|
369
|
-
{:else if component.type === "Divider"}
|
|
356
|
+
{:else if component.type === "Divider" && views.Divider}
|
|
357
|
+
{@const Divider = views.Divider}
|
|
370
358
|
<Divider {...component.properties} />
|
|
371
|
-
{:else if component.type === "ProgressBar"}
|
|
359
|
+
{:else if component.type === "ProgressBar" && views.ProgressBar}
|
|
360
|
+
{@const ProgressBar = views.ProgressBar}
|
|
372
361
|
<ProgressBar {...component.properties} value={link.get(id) as never} />
|
|
373
|
-
{:else if component.type === "Graph"}
|
|
362
|
+
{:else if component.type === "Graph" && views.Graph}
|
|
363
|
+
{@const Graph = views.Graph}
|
|
374
364
|
<Graph
|
|
375
365
|
{...component.properties}
|
|
376
366
|
streamingData={{ data: component.properties.isTest ? (component.properties.streamingData?.data ?? null) : (link.get(id) as never) }}
|
|
377
367
|
/>
|
|
378
|
-
{:else if component.type === "PeriodChart"}
|
|
368
|
+
{:else if component.type === "PeriodChart" && views.PeriodChart}
|
|
369
|
+
{@const PeriodChart = views.PeriodChart}
|
|
379
370
|
<PeriodChart
|
|
380
371
|
{...component.properties}
|
|
381
372
|
levels={(component.properties.levels ?? []).map((level) => ({
|
|
@@ -383,22 +374,25 @@
|
|
|
383
374
|
data: ((level.variable && link.get(level.variable)) as number[] | undefined) ?? level.data ?? [],
|
|
384
375
|
}))}
|
|
385
376
|
/>
|
|
386
|
-
{:else if component.type === "Table"}
|
|
377
|
+
{:else if component.type === "Table" && views.Table}
|
|
387
378
|
<DeviceTable
|
|
379
|
+
view={views.Table}
|
|
388
380
|
properties={component.properties}
|
|
389
381
|
value={tableRows(component)}
|
|
390
382
|
onClick={locked ? undefined : (row: Row, button: ITableButton<Row>) => dispatch(tablePacket(button.eventHandler, row))}
|
|
391
383
|
/>
|
|
392
|
-
{:else if component.type === "FileAttach"}
|
|
384
|
+
{:else if component.type === "FileAttach" && views.FileAttach}
|
|
385
|
+
{@const FileAttach = views.FileAttach}
|
|
393
386
|
<FileAttach
|
|
394
387
|
{...component.properties}
|
|
395
388
|
disabled={locked || component.properties.disabled}
|
|
396
389
|
onUpdate={(file) => file && fs().upload(file.name, file).catch(report)}
|
|
397
390
|
/>
|
|
398
|
-
{:else if component.type === "VideoViewer" &&
|
|
399
|
-
{@const VideoViewer =
|
|
391
|
+
{:else if component.type === "VideoViewer" && views.VideoViewer}
|
|
392
|
+
{@const VideoViewer = views.VideoViewer}
|
|
400
393
|
<VideoViewer {...component.properties} />
|
|
401
|
-
{:else if component.type === "WidgetWiFi"}
|
|
394
|
+
{:else if component.type === "WidgetWiFi" && views.WidgetWiFi}
|
|
395
|
+
{@const WidgetWiFi = views.WidgetWiFi}
|
|
402
396
|
{@const props = component.properties}
|
|
403
397
|
{@const prefix = widgetPrefixes(component.type, props)[0]}
|
|
404
398
|
<WidgetWiFi
|
|
@@ -408,7 +402,8 @@
|
|
|
408
402
|
onScan={locked ? undefined : () => scanWiFi(prefix, props.keys, props.scanCommand)}
|
|
409
403
|
onSave={locked ? undefined : (config) => saveFields(prefix, WIDGET_SAVE_FIELDS.WidgetWiFi, config, props.keys)}
|
|
410
404
|
/>
|
|
411
|
-
{:else if component.type === "WidgetDeviceInfo"}
|
|
405
|
+
{:else if component.type === "WidgetDeviceInfo" && views.WidgetDeviceInfo}
|
|
406
|
+
{@const WidgetDeviceInfo = views.WidgetDeviceInfo}
|
|
412
407
|
{@const props = component.properties}
|
|
413
408
|
{@const prefix = widgetPrefixes(component.type, props)[0]}
|
|
414
409
|
<WidgetDeviceInfo
|
|
@@ -427,7 +422,8 @@
|
|
|
427
422
|
onRestart={locked ? undefined : () => send(props.restartCommand?.header || "SET", props.restartCommand?.argument || "Restart", {})}
|
|
428
423
|
onFactoryReset={locked ? undefined : () => send(props.resetCommand?.header || "SET", props.resetCommand?.argument || "RstNVS", {})}
|
|
429
424
|
/>
|
|
430
|
-
{:else if component.type === "WidgetFileSystem"}
|
|
425
|
+
{:else if component.type === "WidgetFileSystem" && views.WidgetFileSystem}
|
|
426
|
+
{@const WidgetFileSystem = views.WidgetFileSystem}
|
|
431
427
|
{@const props = component.properties}
|
|
432
428
|
{@const argument = props.argument || "FS"}
|
|
433
429
|
{@const transfer = () => fs(argument, props.maxNameLength)}
|
|
@@ -445,7 +441,8 @@
|
|
|
445
441
|
.download(name)
|
|
446
442
|
.then((bytes) => saveFile(name, bytes), fail)}
|
|
447
443
|
/>
|
|
448
|
-
{:else if component.type === "WidgetStackInfo"}
|
|
444
|
+
{:else if component.type === "WidgetStackInfo" && views.WidgetStackInfo}
|
|
445
|
+
{@const WidgetStackInfo = views.WidgetStackInfo}
|
|
449
446
|
{@const props = component.properties}
|
|
450
447
|
<WidgetStackInfo
|
|
451
448
|
{...props}
|
|
@@ -453,7 +450,8 @@
|
|
|
453
450
|
persistKey={persist(component)}
|
|
454
451
|
onRefresh={() => send("GET", props.argument || "StackInfo", {})}
|
|
455
452
|
/>
|
|
456
|
-
{:else if component.type === "WidgetRGBStrip"}
|
|
453
|
+
{:else if component.type === "WidgetRGBStrip" && views.WidgetRGBStrip}
|
|
454
|
+
{@const WidgetRGBStrip = views.WidgetRGBStrip}
|
|
457
455
|
{@const props = component.properties}
|
|
458
456
|
{@const prefix = widgetPrefixes(component.type, props)[0]}
|
|
459
457
|
<WidgetRGBStrip
|
|
@@ -463,15 +461,15 @@
|
|
|
463
461
|
onUpdate={locked ? undefined : (value, field) => saveFields(prefix, [field], { [field]: value }, props.keys)}
|
|
464
462
|
onSave={locked ? undefined : (hardware) => saveFields(prefix, WIDGET_SAVE_FIELDS.WidgetRGBStrip, hardware, props.keys)}
|
|
465
463
|
/>
|
|
466
|
-
{:else if component.type === "WidgetPFD" &&
|
|
467
|
-
{@const WidgetPFD =
|
|
464
|
+
{:else if component.type === "WidgetPFD" && views.WidgetPFD}
|
|
465
|
+
{@const WidgetPFD = views.WidgetPFD}
|
|
468
466
|
<WidgetPFD
|
|
469
467
|
{...component.properties}
|
|
470
468
|
value={fields(component, widgetPrefixes(component.type, component.properties)[0], WIDGET_FIELDS.WidgetPFD)}
|
|
471
469
|
persistKey={persist(component)}
|
|
472
470
|
/>
|
|
473
|
-
{:else if component.type === "WidgetMap" &&
|
|
474
|
-
{@const WidgetMap =
|
|
471
|
+
{:else if component.type === "WidgetMap" && views.WidgetMap}
|
|
472
|
+
{@const WidgetMap = views.WidgetMap}
|
|
475
473
|
<WidgetMap
|
|
476
474
|
{...component.properties}
|
|
477
475
|
value={stable(
|
|
@@ -1,7 +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 {
|
|
4
|
+
import type { GuiViews } from "../guiViews";
|
|
5
5
|
interface Props {
|
|
6
6
|
components: UIComponent[];
|
|
7
7
|
link: DeviceLink;
|
|
@@ -9,7 +9,7 @@ interface Props {
|
|
|
9
9
|
viewer?: boolean;
|
|
10
10
|
persistKey?: string;
|
|
11
11
|
render?: Partial<Record<UIType, Snippet<[UIComponent]>>>;
|
|
12
|
-
|
|
12
|
+
views: GuiViews;
|
|
13
13
|
onError?: (message: string) => void;
|
|
14
14
|
}
|
|
15
15
|
declare const GUIRenderer: import("svelte").Component<Props, {}, "">;
|
package/dist/gui.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeviceTransport } from "./fsTransfer";
|
|
2
|
-
import type { IUIComponentHandler, IWidgetFileSystemInfo, IWidgetStackInfo, UIComponent } from "./types";
|
|
2
|
+
import type { IUIComponentHandler, IWidgetFileSystemInfo, IWidgetStackInfo, UIComponent, UIType } from "./types";
|
|
3
3
|
export declare const GUI_GRID: {
|
|
4
4
|
readonly columns: 23;
|
|
5
5
|
readonly cellHeight: 6;
|
|
@@ -164,3 +164,6 @@ export type FlowNode = {
|
|
|
164
164
|
export declare const layoutFlow: (list: UIComponent[]) => FlowNode;
|
|
165
165
|
export declare const flowMinWidth: (node: FlowNode) => number;
|
|
166
166
|
export declare const layoutColumns: (list: UIComponent[], total: number) => string;
|
|
167
|
+
export declare const guiTypes: (components: readonly {
|
|
168
|
+
type: UIType;
|
|
169
|
+
}[]) => UIType[];
|
package/dist/gui.js
CHANGED
|
@@ -335,3 +335,5 @@ export const layoutColumns = (list, total) => {
|
|
|
335
335
|
const last = Math.max(...used);
|
|
336
336
|
return Array.from({ length: count }, (_, i) => (i + 1 > first && i + 1 < last && !used.has(i + 1) ? GUTTER : "minmax(0, 1fr)")).join(" ");
|
|
337
337
|
};
|
|
338
|
+
/* Типы компонентов, которые встречаются в GUI (по порядку первого появления): по ним приложение собирает views для GUIRenderer, чтобы в сборку попали только они */
|
|
339
|
+
export const guiTypes = (components) => [...new Set(components.map((component) => component.type))];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Accordion from "./Accordion/Accordion.svelte";
|
|
2
|
+
import Button from "./Button/Button.svelte";
|
|
3
|
+
import Divider from "./Divider/Divider.svelte";
|
|
4
|
+
import FileAttach from "./FileAttach/FileAttach.svelte";
|
|
5
|
+
import Graph from "./Graph/Graph.svelte";
|
|
6
|
+
import Input from "./Input/Input.svelte";
|
|
7
|
+
import Joystick from "./Joystick/Joystick.svelte";
|
|
8
|
+
import PeriodChart from "./PeriodChart/PeriodChart.svelte";
|
|
9
|
+
import ProgressBar from "./ProgressBar/ProgressBar.svelte";
|
|
10
|
+
import Select from "./Select/Select.svelte";
|
|
11
|
+
import Slider from "./Slider/Slider.svelte";
|
|
12
|
+
import Switch from "./Switch/Switch.svelte";
|
|
13
|
+
import Table from "./Table/Table.svelte";
|
|
14
|
+
import Tabs from "./Tabs/Tabs.svelte";
|
|
15
|
+
import TextField from "./TextField/TextField.svelte";
|
|
16
|
+
import VideoViewer from "./VideoViewer/VideoViewer.svelte";
|
|
17
|
+
import Widget from "./Widget/Widget.svelte";
|
|
18
|
+
import WidgetWiFi from "./WidgetWiFi/WidgetWiFi.svelte";
|
|
19
|
+
import WidgetDeviceInfo from "./WidgetDeviceInfo/WidgetDeviceInfo.svelte";
|
|
20
|
+
import WidgetFileSystem from "./WidgetFileSystem/WidgetFileSystem.svelte";
|
|
21
|
+
import WidgetStackInfo from "./WidgetStackInfo/WidgetStackInfo.svelte";
|
|
22
|
+
import WidgetRGBStrip from "./WidgetRGBStrip/WidgetRGBStrip.svelte";
|
|
23
|
+
import WidgetPFD from "./WidgetPFD/WidgetPFD.svelte";
|
|
24
|
+
import WidgetMap from "./WidgetMap/WidgetMap.svelte";
|
|
25
|
+
export interface GuiViewsAll {
|
|
26
|
+
Accordion: typeof Accordion;
|
|
27
|
+
Button: typeof Button;
|
|
28
|
+
Divider: typeof Divider;
|
|
29
|
+
FileAttach: typeof FileAttach;
|
|
30
|
+
Graph: typeof Graph;
|
|
31
|
+
Input: typeof Input;
|
|
32
|
+
Joystick: typeof Joystick;
|
|
33
|
+
PeriodChart: typeof PeriodChart;
|
|
34
|
+
ProgressBar: typeof ProgressBar;
|
|
35
|
+
Select: typeof Select;
|
|
36
|
+
Slider: typeof Slider;
|
|
37
|
+
Switch: typeof Switch;
|
|
38
|
+
Table: typeof Table;
|
|
39
|
+
Tabs: typeof Tabs;
|
|
40
|
+
TextField: typeof TextField;
|
|
41
|
+
VideoViewer: typeof VideoViewer;
|
|
42
|
+
Widget: typeof Widget;
|
|
43
|
+
WidgetWiFi: typeof WidgetWiFi;
|
|
44
|
+
WidgetDeviceInfo: typeof WidgetDeviceInfo;
|
|
45
|
+
WidgetFileSystem: typeof WidgetFileSystem;
|
|
46
|
+
WidgetStackInfo: typeof WidgetStackInfo;
|
|
47
|
+
WidgetRGBStrip: typeof WidgetRGBStrip;
|
|
48
|
+
WidgetPFD: typeof WidgetPFD;
|
|
49
|
+
WidgetMap: typeof WidgetMap;
|
|
50
|
+
}
|
|
51
|
+
export declare const GUI_VIEWS: GuiViewsAll;
|
|
52
|
+
export type GuiViews = Partial<GuiViewsAll>;
|
package/dist/guiViews.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Accordion from "./Accordion/Accordion.svelte";
|
|
2
|
+
import Button from "./Button/Button.svelte";
|
|
3
|
+
import Divider from "./Divider/Divider.svelte";
|
|
4
|
+
import FileAttach from "./FileAttach/FileAttach.svelte";
|
|
5
|
+
import Graph from "./Graph/Graph.svelte";
|
|
6
|
+
import Input from "./Input/Input.svelte";
|
|
7
|
+
import Joystick from "./Joystick/Joystick.svelte";
|
|
8
|
+
import PeriodChart from "./PeriodChart/PeriodChart.svelte";
|
|
9
|
+
import ProgressBar from "./ProgressBar/ProgressBar.svelte";
|
|
10
|
+
import Select from "./Select/Select.svelte";
|
|
11
|
+
import Slider from "./Slider/Slider.svelte";
|
|
12
|
+
import Switch from "./Switch/Switch.svelte";
|
|
13
|
+
import Table from "./Table/Table.svelte";
|
|
14
|
+
import Tabs from "./Tabs/Tabs.svelte";
|
|
15
|
+
import TextField from "./TextField/TextField.svelte";
|
|
16
|
+
import VideoViewer from "./VideoViewer/VideoViewer.svelte";
|
|
17
|
+
import Widget from "./Widget/Widget.svelte";
|
|
18
|
+
import WidgetWiFi from "./WidgetWiFi/WidgetWiFi.svelte";
|
|
19
|
+
import WidgetDeviceInfo from "./WidgetDeviceInfo/WidgetDeviceInfo.svelte";
|
|
20
|
+
import WidgetFileSystem from "./WidgetFileSystem/WidgetFileSystem.svelte";
|
|
21
|
+
import WidgetStackInfo from "./WidgetStackInfo/WidgetStackInfo.svelte";
|
|
22
|
+
import WidgetRGBStrip from "./WidgetRGBStrip/WidgetRGBStrip.svelte";
|
|
23
|
+
import WidgetPFD from "./WidgetPFD/WidgetPFD.svelte";
|
|
24
|
+
import WidgetMap from "./WidgetMap/WidgetMap.svelte";
|
|
25
|
+
/* Все типы - для облака, терминала и конструктора; приложению с ограниченной памятью - свой набор из отдельных компонентов */
|
|
26
|
+
export const GUI_VIEWS = {
|
|
27
|
+
Accordion,
|
|
28
|
+
Button,
|
|
29
|
+
Divider,
|
|
30
|
+
FileAttach,
|
|
31
|
+
Graph,
|
|
32
|
+
Input,
|
|
33
|
+
Joystick,
|
|
34
|
+
PeriodChart,
|
|
35
|
+
ProgressBar,
|
|
36
|
+
Select,
|
|
37
|
+
Slider,
|
|
38
|
+
Switch,
|
|
39
|
+
Table,
|
|
40
|
+
Tabs,
|
|
41
|
+
TextField,
|
|
42
|
+
VideoViewer,
|
|
43
|
+
Widget,
|
|
44
|
+
WidgetWiFi,
|
|
45
|
+
WidgetDeviceInfo,
|
|
46
|
+
WidgetFileSystem,
|
|
47
|
+
WidgetStackInfo,
|
|
48
|
+
WidgetRGBStrip,
|
|
49
|
+
WidgetPFD,
|
|
50
|
+
WidgetMap,
|
|
51
|
+
};
|
|
52
|
+
/* Каждый тип GUI есть в GuiViewsAll: новый тип без компонента - ошибка компиляции */
|
|
53
|
+
const _everyType = GUI_VIEWS;
|
|
54
|
+
void _everyType;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ 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_VIEWS, type GuiViews } from "./guiViews";
|
|
47
47
|
export { COMPONENTS, type ComponentEntry } from "./registry";
|
|
48
48
|
export { COMPONENT_META, componentVariables, type ComponentMeta, type ComponentIO } from "./componentMeta";
|
|
49
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";
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ 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_VIEWS } from "./guiViews";
|
|
48
48
|
export { COMPONENTS } from "./registry";
|
|
49
49
|
export { COMPONENT_META, componentVariables } from "./componentMeta";
|
|
50
50
|
export { GUI_GRID, isWidgetType, spanRows, WIDGET_FIELDS, WIDGET_SAVE_FIELDS, widgetKey, widgetPrefixes, readWidgetFields, widgetPacket, bitRange, readBits, writeBits, commandPacket, tablePacket, mergeDevicePayload, } from "./gui";
|
|
@@ -2,7 +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.
|
|
5
|
+
"gui.view_missing": { ru: "Компонент не входит в эту сборку", en: "Component is not included in this build", zh: "此版本不包含该组件" },
|
|
6
6
|
"gui.error.event_handler": {
|
|
7
7
|
ru: "Команда компонента не собрана: проверьте eventHandler",
|
|
8
8
|
en: "Component command not built: check eventHandler",
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
|
@@ -1,6 +0,0 @@
|
|
|
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 };
|