@matreshka/bff 0.9.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/LICENSE +32 -0
- package/README.md +35 -0
- package/dist/components/actions/server-action.d.ts +30 -0
- package/dist/components/actions/server-action.js +23 -0
- package/dist/components/aliases/button.d.ts +17 -0
- package/dist/components/aliases/button.js +54 -0
- package/dist/components/aliases/column.d.ts +11 -0
- package/dist/components/aliases/column.js +31 -0
- package/dist/components/aliases/row.d.ts +11 -0
- package/dist/components/aliases/row.js +31 -0
- package/dist/components/aliases/surface.d.ts +11 -0
- package/dist/components/aliases/surface.js +30 -0
- package/dist/components/app.d.ts +5 -0
- package/dist/components/app.js +12 -0
- package/dist/components/board.d.ts +58 -0
- package/dist/components/board.js +152 -0
- package/dist/components/boot.d.ts +2 -0
- package/dist/components/boot.js +39 -0
- package/dist/components/camera.d.ts +77 -0
- package/dist/components/camera.js +116 -0
- package/dist/components/charts/bar-chart.d.ts +14 -0
- package/dist/components/charts/bar-chart.js +27 -0
- package/dist/components/charts/chart.d.ts +69 -0
- package/dist/components/charts/chart.js +42 -0
- package/dist/components/charts/doughnut-chart.d.ts +14 -0
- package/dist/components/charts/doughnut-chart.js +27 -0
- package/dist/components/charts/line-chart.d.ts +14 -0
- package/dist/components/charts/line-chart.js +27 -0
- package/dist/components/charts/pie-chart.d.ts +14 -0
- package/dist/components/charts/pie-chart.js +27 -0
- package/dist/components/charts/polar-area-chart.d.ts +14 -0
- package/dist/components/charts/polar-area-chart.js +27 -0
- package/dist/components/charts/radar-chart.d.ts +14 -0
- package/dist/components/charts/radar-chart.js +27 -0
- package/dist/components/component.d.ts +159 -0
- package/dist/components/component.js +380 -0
- package/dist/components/container.d.ts +48 -0
- package/dist/components/container.js +80 -0
- package/dist/components/dialog.d.ts +83 -0
- package/dist/components/dialog.js +120 -0
- package/dist/components/entry-component.d.ts +34 -0
- package/dist/components/entry-component.js +74 -0
- package/dist/components/enum/password-input-kind.d.ts +1 -0
- package/dist/components/enum/password-input-kind.js +5 -0
- package/dist/components/enum/popover-position-area.d.ts +1 -0
- package/dist/components/enum/popover-position-area.js +5 -0
- package/dist/components/enum/text-input-kind.d.ts +1 -0
- package/dist/components/enum/text-input-kind.js +5 -0
- package/dist/components/enum/textarea-resize.d.ts +1 -0
- package/dist/components/enum/textarea-resize.js +5 -0
- package/dist/components/file-upload-area.d.ts +79 -0
- package/dist/components/file-upload-area.js +138 -0
- package/dist/components/for-each.d.ts +188 -0
- package/dist/components/for-each.js +362 -0
- package/dist/components/form.d.ts +62 -0
- package/dist/components/form.js +92 -0
- package/dist/components/grid.d.ts +80 -0
- package/dist/components/grid.js +79 -0
- package/dist/components/index.d.ts +55 -0
- package/dist/components/index.js +76 -0
- package/dist/components/inputs/input-component.d.ts +37 -0
- package/dist/components/inputs/input-component.js +30 -0
- package/dist/components/inputs/number-input.d.ts +45 -0
- package/dist/components/inputs/number-input.js +43 -0
- package/dist/components/inputs/password-input.d.ts +28 -0
- package/dist/components/inputs/password-input.js +42 -0
- package/dist/components/inputs/text-editor.d.ts +91 -0
- package/dist/components/inputs/text-editor.js +282 -0
- package/dist/components/inputs/text-input.d.ts +48 -0
- package/dist/components/inputs/text-input.js +40 -0
- package/dist/components/inputs/textarea.d.ts +36 -0
- package/dist/components/inputs/textarea.js +42 -0
- package/dist/components/item-list/flatten-nested-items.d.ts +11 -0
- package/dist/components/item-list/flatten-nested-items.js +100 -0
- package/dist/components/item-list/index.d.ts +5 -0
- package/dist/components/item-list/index.js +21 -0
- package/dist/components/item-list/item-list-host.d.ts +10 -0
- package/dist/components/item-list/item-list-host.js +2 -0
- package/dist/components/item-list/item-list.d.ts +68 -0
- package/dist/components/item-list/item-list.js +206 -0
- package/dist/components/item-list/list-from-ref-context.d.ts +11 -0
- package/dist/components/item-list/list-from-ref-context.js +27 -0
- package/dist/components/item-list/nested-items-host-support.d.ts +36 -0
- package/dist/components/item-list/nested-items-host-support.js +109 -0
- package/dist/components/item-list/types.d.ts +40 -0
- package/dist/components/item-list/types.js +13 -0
- package/dist/components/line.d.ts +43 -0
- package/dist/components/line.js +35 -0
- package/dist/components/map.d.ts +83 -0
- package/dist/components/map.js +146 -0
- package/dist/components/outputs/currency.d.ts +63 -0
- package/dist/components/outputs/currency.js +42 -0
- package/dist/components/outputs/datetime.d.ts +69 -0
- package/dist/components/outputs/datetime.js +49 -0
- package/dist/components/outputs/icon.d.ts +43 -0
- package/dist/components/outputs/icon.js +38 -0
- package/dist/components/outputs/iframe.d.ts +48 -0
- package/dist/components/outputs/iframe.js +44 -0
- package/dist/components/outputs/image.d.ts +73 -0
- package/dist/components/outputs/image.js +63 -0
- package/dist/components/outputs/number.d.ts +39 -0
- package/dist/components/outputs/number.js +47 -0
- package/dist/components/outputs/output-component.d.ts +58 -0
- package/dist/components/outputs/output-component.js +50 -0
- package/dist/components/outputs/progress-bar.d.ts +33 -0
- package/dist/components/outputs/progress-bar.js +42 -0
- package/dist/components/outputs/progress-spinner.d.ts +37 -0
- package/dist/components/outputs/progress-spinner.js +43 -0
- package/dist/components/outputs/qr-code.d.ts +28 -0
- package/dist/components/outputs/qr-code.js +40 -0
- package/dist/components/outputs/text.d.ts +57 -0
- package/dist/components/outputs/text.js +78 -0
- package/dist/components/outputs/vector.d.ts +47 -0
- package/dist/components/outputs/vector.js +53 -0
- package/dist/components/page.d.ts +96 -0
- package/dist/components/page.js +127 -0
- package/dist/components/popover.d.ts +63 -0
- package/dist/components/popover.js +96 -0
- package/dist/components/stack.d.ts +158 -0
- package/dist/components/stack.js +146 -0
- package/dist/components/types/component-sequence.d.ts +3 -0
- package/dist/components/types/component-sequence.js +2 -0
- package/dist/components/types/container-overlay.d.ts +3 -0
- package/dist/components/types/container-overlay.js +2 -0
- package/dist/components/utils/component-factory-shared.d.ts +4 -0
- package/dist/components/utils/component-factory-shared.js +12 -0
- package/dist/core/actions/action.d.ts +35 -0
- package/dist/core/actions/action.js +45 -0
- package/dist/core/actions/animate-component.d.ts +58 -0
- package/dist/core/actions/animate-component.js +57 -0
- package/dist/core/actions/local-action.d.ts +8 -0
- package/dist/core/actions/local-action.js +12 -0
- package/dist/core/actions/set-context-value.d.ts +18 -0
- package/dist/core/actions/set-context-value.js +32 -0
- package/dist/core/actions/set-context-values.d.ts +34 -0
- package/dist/core/actions/set-context-values.js +30 -0
- package/dist/core/actions/toggle-context-value.d.ts +21 -0
- package/dist/core/actions/toggle-context-value.js +30 -0
- package/dist/core/actions/write-text-to-clipboard.d.ts +30 -0
- package/dist/core/actions/write-text-to-clipboard.js +44 -0
- package/dist/core/boot.d.ts +2 -0
- package/dist/core/boot.js +8 -0
- package/dist/core/client-context.d.ts +7 -0
- package/dist/core/client-context.js +20 -0
- package/dist/core/client.d.ts +133 -0
- package/dist/core/client.js +292 -0
- package/dist/core/conditions/condition-group.d.ts +14 -0
- package/dist/core/conditions/condition-group.js +30 -0
- package/dist/core/conditions/condition-operand.d.ts +27 -0
- package/dist/core/conditions/condition-operand.js +15 -0
- package/dist/core/conditions/condition.d.ts +27 -0
- package/dist/core/conditions/condition.js +35 -0
- package/dist/core/conditions/context-array-includes.d.ts +32 -0
- package/dist/core/conditions/context-array-includes.js +52 -0
- package/dist/core/conditions/context-array-length.d.ts +86 -0
- package/dist/core/conditions/context-array-length.js +155 -0
- package/dist/core/conditions/context-value-defined.d.ts +12 -0
- package/dist/core/conditions/context-value-defined.js +21 -0
- package/dist/core/conditions/context-value-equal.d.ts +14 -0
- package/dist/core/conditions/context-value-equal.js +26 -0
- package/dist/core/conditions/context-value-in.d.ts +17 -0
- package/dist/core/conditions/context-value-in.js +26 -0
- package/dist/core/conditions/context-value-not-equal.d.ts +14 -0
- package/dist/core/conditions/context-value-not-equal.js +26 -0
- package/dist/core/conditions/context-value-undefined.d.ts +12 -0
- package/dist/core/conditions/context-value-undefined.js +21 -0
- package/dist/core/conditions/desktop-device.d.ts +11 -0
- package/dist/core/conditions/desktop-device.js +21 -0
- package/dist/core/conditions/groups.d.ts +71 -0
- package/dist/core/conditions/groups.js +74 -0
- package/dist/core/conditions/index.d.ts +17 -0
- package/dist/core/conditions/index.js +33 -0
- package/dist/core/conditions/mobile-device.d.ts +11 -0
- package/dist/core/conditions/mobile-device.js +21 -0
- package/dist/core/conditions/not-desktop-device.d.ts +11 -0
- package/dist/core/conditions/not-desktop-device.js +21 -0
- package/dist/core/conditions/not-mobile-device.d.ts +11 -0
- package/dist/core/conditions/not-mobile-device.js +21 -0
- package/dist/core/conditions/not-tablet-device.d.ts +11 -0
- package/dist/core/conditions/not-tablet-device.js +21 -0
- package/dist/core/conditions/tablet-device.d.ts +11 -0
- package/dist/core/conditions/tablet-device.js +21 -0
- package/dist/core/context/context-ref.d.ts +48 -0
- package/dist/core/context/context-ref.js +58 -0
- package/dist/core/context/context.d.ts +121 -0
- package/dist/core/context/context.js +353 -0
- package/dist/core/entry-context.d.ts +14 -0
- package/dist/core/entry-context.js +31 -0
- package/dist/core/gateway-connection.d.ts +29 -0
- package/dist/core/gateway-connection.js +146 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.js +46 -0
- package/dist/core/matreshka.d.ts +61 -0
- package/dist/core/matreshka.js +186 -0
- package/dist/core/router.d.ts +38 -0
- package/dist/core/router.js +116 -0
- package/dist/core/types/client-settings.d.ts +31 -0
- package/dist/core/types/client-settings.js +2 -0
- package/dist/core/types/component-instance.d.ts +25 -0
- package/dist/core/types/component-instance.js +42 -0
- package/dist/core/types/component-tree-node.d.ts +11 -0
- package/dist/core/types/component-tree-node.js +18 -0
- package/dist/core/types/componentable.d.ts +21 -0
- package/dist/core/types/componentable.js +2 -0
- package/dist/core/types/context-ref-primitive-value.d.ts +5 -0
- package/dist/core/types/context-ref-primitive-value.js +2 -0
- package/dist/core/types/message.d.ts +15 -0
- package/dist/core/types/message.js +2 -0
- package/dist/core/types/mixed-with-callbacks-array.d.ts +9 -0
- package/dist/core/types/mixed-with-callbacks-array.js +2 -0
- package/dist/core/types/native-picker-context-ref.d.ts +7 -0
- package/dist/core/types/native-picker-context-ref.js +2 -0
- package/dist/core/types/pageable.d.ts +15 -0
- package/dist/core/types/pageable.js +2 -0
- package/dist/core/types/standalone-component.d.ts +9 -0
- package/dist/core/types/standalone-component.js +2 -0
- package/dist/core/types/status-code.d.ts +319 -0
- package/dist/core/types/status-code.js +322 -0
- package/dist/core/utils/calculate-components.d.ts +13 -0
- package/dist/core/utils/calculate-components.js +40 -0
- package/dist/core/utils/color-token-id.d.ts +11 -0
- package/dist/core/utils/color-token-id.js +24 -0
- package/dist/core/utils/deep-pick.d.ts +2 -0
- package/dist/core/utils/deep-pick.js +54 -0
- package/dist/core/utils/hex-to-hsl.d.ts +14 -0
- package/dist/core/utils/hex-to-hsl.js +49 -0
- package/dist/core/utils/incoming-message-observer.d.ts +9 -0
- package/dist/core/utils/incoming-message-observer.js +23 -0
- package/dist/core/utils/merge-deep.d.ts +8 -0
- package/dist/core/utils/merge-deep.js +39 -0
- package/dist/core/utils/objects-diff.d.ts +13 -0
- package/dist/core/utils/objects-diff.js +56 -0
- package/dist/core/utils/parse-context-path.d.ts +4 -0
- package/dist/core/utils/parse-context-path.js +16 -0
- package/dist/core/utils/replace-context-keys.d.ts +12 -0
- package/dist/core/utils/replace-context-keys.js +90 -0
- package/dist/core/utils/serialize-component-tree.d.ts +9 -0
- package/dist/core/utils/serialize-component-tree.js +24 -0
- package/dist/core/utils/set-object-property.d.ts +2 -0
- package/dist/core/utils/set-object-property.js +29 -0
- package/dist/core/utils/track-created-instances.d.ts +10 -0
- package/dist/core/utils/track-created-instances.js +18 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/platforms/android-platform.d.ts +6 -0
- package/dist/platforms/android-platform.js +10 -0
- package/dist/platforms/browser-platform.d.ts +79 -0
- package/dist/platforms/browser-platform.js +143 -0
- package/dist/platforms/client-platform.d.ts +6 -0
- package/dist/platforms/client-platform.js +10 -0
- package/dist/platforms/index.d.ts +12 -0
- package/dist/platforms/index.js +28 -0
- package/dist/platforms/ios-platform.d.ts +6 -0
- package/dist/platforms/ios-platform.js +10 -0
- package/dist/platforms/max-mini-app-platform.d.ts +45 -0
- package/dist/platforms/max-mini-app-platform.js +87 -0
- package/dist/platforms/mobile-platform.d.ts +117 -0
- package/dist/platforms/mobile-platform.js +316 -0
- package/dist/platforms/platform.d.ts +109 -0
- package/dist/platforms/platform.js +224 -0
- package/dist/platforms/pwa-platform.d.ts +6 -0
- package/dist/platforms/pwa-platform.js +10 -0
- package/dist/platforms/server-platform.d.ts +6 -0
- package/dist/platforms/server-platform.js +10 -0
- package/dist/platforms/telegram-mini-app-platform.d.ts +87 -0
- package/dist/platforms/telegram-mini-app-platform.js +166 -0
- package/dist/platforms/utils/client-platform.d.ts +4 -0
- package/dist/platforms/utils/client-platform.js +38 -0
- package/dist/platforms/utils/mobile-ble-services.d.ts +3 -0
- package/dist/platforms/utils/mobile-ble-services.js +31 -0
- package/dist/platforms/web-platform.d.ts +9 -0
- package/dist/platforms/web-platform.js +13 -0
- package/package.json +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Matreshka — Creative Commons Attribution-NonCommercial 4.0 International
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dmitriy Tretyakov
|
|
4
|
+
|
|
5
|
+
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0
|
|
6
|
+
International Public License ("CC BY-NC 4.0").
|
|
7
|
+
|
|
8
|
+
You are free to share and adapt the material for non-commercial purposes,
|
|
9
|
+
provided you give appropriate credit, link to the license, and indicate if
|
|
10
|
+
changes were made. You may not use the material for commercial purposes
|
|
11
|
+
under this license.
|
|
12
|
+
|
|
13
|
+
COMMERCIAL USE
|
|
14
|
+
|
|
15
|
+
Any commercial use — including use in products or services that generate
|
|
16
|
+
revenue, or use within a for-profit organization in connection with
|
|
17
|
+
commercial offerings — requires a separate written license from the
|
|
18
|
+
copyright holder. To request commercial licensing, contact:
|
|
19
|
+
|
|
20
|
+
Dmitriy Tretyakov <dmitriy.tretyakov.work@gmail.com>
|
|
21
|
+
|
|
22
|
+
FULL LICENSE TEXT
|
|
23
|
+
|
|
24
|
+
https://creativecommons.org/licenses/by-nc/4.0/legalcode
|
|
25
|
+
|
|
26
|
+
Human-readable summary:
|
|
27
|
+
|
|
28
|
+
https://creativecommons.org/licenses/by-nc/4.0/
|
|
29
|
+
|
|
30
|
+
Creative Commons does not recommend CC licenses for software; this notice
|
|
31
|
+
applies to the Matreshka source code and published npm packages as
|
|
32
|
+
licensed by the copyright holder.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @matreshka/bff
|
|
2
|
+
|
|
3
|
+
Server-driven UI runtime для Matreshka: маршрутизация, страницы, контекст, DSL компонентов и platform API.
|
|
4
|
+
|
|
5
|
+
## Установка
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @matreshka/bff @matreshka/shared
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`@matreshka/shared` подтягивается как зависимость `@matreshka/bff`, но для типов и прямых импортов протокола его часто ставят явно.
|
|
12
|
+
|
|
13
|
+
## Пример
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { stack, text } from "@matreshka/bff/components";
|
|
17
|
+
import { Context } from "@matreshka/bff/core";
|
|
18
|
+
import { when } from "@matreshka/bff/core/conditions";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Точка входа и subpath-экспорты описаны в поле `exports` пакета (`@matreshka/bff/components`, `@matreshka/bff/core`, `@matreshka/bff/platforms` и др.).
|
|
22
|
+
|
|
23
|
+
## Документация
|
|
24
|
+
|
|
25
|
+
- [Документация Matreshka](https://github.com/dmitriytretyakov/matreshka/tree/main/docs/README.md)
|
|
26
|
+
- [Использование BFF](https://github.com/dmitriytretyakov/matreshka/tree/main/docs/usage/README.md)
|
|
27
|
+
- [Быстрый старт](https://github.com/dmitriytretyakov/matreshka/tree/main/docs/usage/quick-start.md)
|
|
28
|
+
|
|
29
|
+
## Лицензия
|
|
30
|
+
|
|
31
|
+
[CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/deed.ru) (указание авторства, некоммерческое использование). Некоммерческое использование, распространение и адаптация — при соблюдении условий лицензии.
|
|
32
|
+
|
|
33
|
+
**Коммерческое использование** (в т.ч. в продуктах и сервисах с выручкой) — только по отдельному соглашению: [dmitriy.tretyakov.work@gmail.com](mailto:dmitriy.tretyakov.work@gmail.com).
|
|
34
|
+
|
|
35
|
+
Полный текст: [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Action, ActionConfig } from "../../core/actions/action";
|
|
2
|
+
import type { ComponentInstance } from "../../core/types/component-instance";
|
|
3
|
+
import type { Componentable } from "../../core/types/componentable";
|
|
4
|
+
/**
|
|
5
|
+
* Свойства действия на сервере.
|
|
6
|
+
* @template ComponentType Тип компонента, над которым совершается действие.
|
|
7
|
+
* @template PayloadType Тип дополнительных данных действия (по умолчанию — undefined).
|
|
8
|
+
* @property instance Инстанс компонента на клиенте, инициировавший взаимодействие.
|
|
9
|
+
* @property payload Дополнительные данные, зависящие от конкретного действия.
|
|
10
|
+
*/
|
|
11
|
+
export type ServerActionProperties<ComponentType extends Componentable, PayloadType = undefined> = {
|
|
12
|
+
instance: ComponentInstance<ComponentType>;
|
|
13
|
+
payload: PayloadType;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Обработчик действия клиента на сервере.
|
|
17
|
+
* Используется для выполнения произвольного кода на сервере, например, при клике по кнопке.
|
|
18
|
+
* @param properties Свойства действия.
|
|
19
|
+
*/
|
|
20
|
+
export type ServerActionHandler<ComponentType extends Componentable, PayloadType = undefined> = (properties: ServerActionProperties<ComponentType, PayloadType>) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Серверное действие, выполняемое BFF при взаимодействии клиента с компонентом.
|
|
23
|
+
*/
|
|
24
|
+
export declare class ServerAction<ComponentType extends Componentable, PayloadType = undefined> extends Action {
|
|
25
|
+
private readonly handler;
|
|
26
|
+
constructor(handler: ServerActionHandler<ComponentType, PayloadType>, config?: ActionConfig);
|
|
27
|
+
class(): string;
|
|
28
|
+
payload(): object;
|
|
29
|
+
execute(properties: ServerActionProperties<ComponentType, PayloadType>): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerAction = void 0;
|
|
4
|
+
const action_1 = require("../../core/actions/action");
|
|
5
|
+
/**
|
|
6
|
+
* Серверное действие, выполняемое BFF при взаимодействии клиента с компонентом.
|
|
7
|
+
*/
|
|
8
|
+
class ServerAction extends action_1.Action {
|
|
9
|
+
constructor(handler, config = {}) {
|
|
10
|
+
super(config.conditions);
|
|
11
|
+
this.handler = handler;
|
|
12
|
+
}
|
|
13
|
+
class() {
|
|
14
|
+
return "server-interaction";
|
|
15
|
+
}
|
|
16
|
+
payload() {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
execute(properties) {
|
|
20
|
+
this.handler(properties);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ServerAction = ServerAction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentTreeNode } from "../../core/types/component-tree-node";
|
|
2
|
+
import type { MixedWithCallbacksArray } from "../../core/types/mixed-with-callbacks-array";
|
|
3
|
+
import { Stack, StackInitConfig } from "../stack";
|
|
4
|
+
/** Один элемент или массив — как раньше у поля `label` у кнопки. */
|
|
5
|
+
export type ButtonContentInput = ComponentTreeNode | MixedWithCallbacksArray<ComponentTreeNode>;
|
|
6
|
+
export type ButtonInitConfig = Omit<StackInitConfig<Button>, "surface" | "direction" | "content"> & {
|
|
7
|
+
content: ButtonContentInput;
|
|
8
|
+
};
|
|
9
|
+
export declare function button(content: ButtonInitConfig["content"]): Button;
|
|
10
|
+
export declare function button(options: Omit<ButtonInitConfig, "content">, content: ButtonInitConfig["content"]): Button;
|
|
11
|
+
export declare function button(config: ButtonInitConfig): Button;
|
|
12
|
+
/**
|
|
13
|
+
* Stack-кнопка: горизонтальный ряд, `surface`, выравнивание по умолчанию по центру по обеим осям (можно переопределить через `align`).
|
|
14
|
+
*/
|
|
15
|
+
export declare class Button extends Stack<StackInitConfig<Button>> {
|
|
16
|
+
constructor(config: ButtonInitConfig);
|
|
17
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Button = void 0;
|
|
4
|
+
exports.button = button;
|
|
5
|
+
const stack_direction_1 = require("@matreshka/shared/enums/stack-direction");
|
|
6
|
+
const component_tree_node_1 = require("../../core/types/component-tree-node");
|
|
7
|
+
const stack_1 = require("../stack");
|
|
8
|
+
const defaultButtonAlign = {
|
|
9
|
+
main: stack_1.StackMainAxisAlign.Center,
|
|
10
|
+
cross: stack_1.StackCrossAxisAlign.Center,
|
|
11
|
+
};
|
|
12
|
+
function button(arg0, arg1) {
|
|
13
|
+
if (arg1 !== undefined) {
|
|
14
|
+
return new Button({
|
|
15
|
+
...arg0,
|
|
16
|
+
content: normalizeButtonContent(arg1),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const single = arg0;
|
|
20
|
+
if (Array.isArray(single)) {
|
|
21
|
+
return new Button({ content: normalizeButtonContent(single) });
|
|
22
|
+
}
|
|
23
|
+
if ((0, component_tree_node_1.isComponentTreeNodeLike)(single)) {
|
|
24
|
+
return new Button({
|
|
25
|
+
content: normalizeButtonContent(single),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return new Button(single);
|
|
29
|
+
}
|
|
30
|
+
function normalizeButtonContent(content) {
|
|
31
|
+
return Array.isArray(content)
|
|
32
|
+
? content
|
|
33
|
+
: [content];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Stack-кнопка: горизонтальный ряд, `surface`, выравнивание по умолчанию по центру по обеим осям (можно переопределить через `align`).
|
|
37
|
+
*/
|
|
38
|
+
class Button extends stack_1.Stack {
|
|
39
|
+
constructor(config) {
|
|
40
|
+
super({
|
|
41
|
+
...config,
|
|
42
|
+
surface: true,
|
|
43
|
+
direction: stack_direction_1.StackDirection.Horizontal,
|
|
44
|
+
overflow: config.overflow ?? stack_1.Overflow.Hidden,
|
|
45
|
+
// flexItem: { grow: 1 },
|
|
46
|
+
align: {
|
|
47
|
+
main: config.align?.main ?? defaultButtonAlign.main,
|
|
48
|
+
cross: config.align?.cross ?? defaultButtonAlign.cross,
|
|
49
|
+
},
|
|
50
|
+
content: normalizeButtonContent(config.content),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Button = Button;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Stack, StackInitConfig } from "../stack";
|
|
2
|
+
export type ColumnInitConfig = Omit<StackInitConfig<Column>, "direction">;
|
|
3
|
+
export declare function column(content: ColumnInitConfig["content"]): Column;
|
|
4
|
+
export declare function column(options: Omit<ColumnInitConfig, "content">, content: ColumnInitConfig["content"]): Column;
|
|
5
|
+
export declare function column(config: ColumnInitConfig): Column;
|
|
6
|
+
/**
|
|
7
|
+
* Вертикальный Stack: направление всегда {@link StackDirection.Vertical}.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Column extends Stack<StackInitConfig<Column>> {
|
|
10
|
+
constructor(config: ColumnInitConfig);
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Column = void 0;
|
|
4
|
+
exports.column = column;
|
|
5
|
+
const stack_direction_1 = require("@matreshka/shared/enums/stack-direction");
|
|
6
|
+
const stack_1 = require("../stack");
|
|
7
|
+
function column(arg0, arg1) {
|
|
8
|
+
if (arg1 !== undefined) {
|
|
9
|
+
return new Column({
|
|
10
|
+
...arg0,
|
|
11
|
+
content: arg1,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const single = arg0;
|
|
15
|
+
if (typeof single === "object" &&
|
|
16
|
+
single !== null &&
|
|
17
|
+
!Array.isArray(single) &&
|
|
18
|
+
"content" in single) {
|
|
19
|
+
return new Column(single);
|
|
20
|
+
}
|
|
21
|
+
return new Column({ content: single });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Вертикальный Stack: направление всегда {@link StackDirection.Vertical}.
|
|
25
|
+
*/
|
|
26
|
+
class Column extends stack_1.Stack {
|
|
27
|
+
constructor(config) {
|
|
28
|
+
super({ ...config, direction: stack_direction_1.StackDirection.Vertical });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Column = Column;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Stack, StackInitConfig } from "../stack";
|
|
2
|
+
export type RowInitConfig = Omit<StackInitConfig<Row>, "direction">;
|
|
3
|
+
export declare function row(content: RowInitConfig["content"]): Row;
|
|
4
|
+
export declare function row(options: Omit<RowInitConfig, "content">, content: RowInitConfig["content"]): Row;
|
|
5
|
+
export declare function row(config: RowInitConfig): Row;
|
|
6
|
+
/**
|
|
7
|
+
* Горизонтальный Stack: направление всегда {@link StackDirection.Horizontal}.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Row extends Stack<StackInitConfig<Row>> {
|
|
10
|
+
constructor(config: RowInitConfig);
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Row = void 0;
|
|
4
|
+
exports.row = row;
|
|
5
|
+
const stack_direction_1 = require("@matreshka/shared/enums/stack-direction");
|
|
6
|
+
const stack_1 = require("../stack");
|
|
7
|
+
function row(arg0, arg1) {
|
|
8
|
+
if (arg1 !== undefined) {
|
|
9
|
+
return new Row({
|
|
10
|
+
...arg0,
|
|
11
|
+
content: arg1,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const single = arg0;
|
|
15
|
+
if (typeof single === "object" &&
|
|
16
|
+
single !== null &&
|
|
17
|
+
!Array.isArray(single) &&
|
|
18
|
+
"content" in single) {
|
|
19
|
+
return new Row(single);
|
|
20
|
+
}
|
|
21
|
+
return new Row({ content: single });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Горизонтальный Stack: направление всегда {@link StackDirection.Horizontal}.
|
|
25
|
+
*/
|
|
26
|
+
class Row extends stack_1.Stack {
|
|
27
|
+
constructor(config) {
|
|
28
|
+
super({ ...config, direction: stack_direction_1.StackDirection.Horizontal });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Row = Row;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Stack, StackInitConfig } from "../stack";
|
|
2
|
+
export type SurfaceInitConfig = Omit<StackInitConfig<Surface>, "surface">;
|
|
3
|
+
export declare function surface(content: SurfaceInitConfig["content"]): Surface;
|
|
4
|
+
export declare function surface(options: Omit<SurfaceInitConfig, "content">, content: SurfaceInitConfig["content"]): Surface;
|
|
5
|
+
export declare function surface(config: SurfaceInitConfig): Surface;
|
|
6
|
+
/**
|
|
7
|
+
* Stack с включённым фоном поверхности (`surface: true`, `--background-color`).
|
|
8
|
+
*/
|
|
9
|
+
export declare class Surface extends Stack<StackInitConfig<Surface>> {
|
|
10
|
+
constructor(config: SurfaceInitConfig);
|
|
11
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Surface = void 0;
|
|
4
|
+
exports.surface = surface;
|
|
5
|
+
const stack_1 = require("../stack");
|
|
6
|
+
function surface(arg0, arg1) {
|
|
7
|
+
if (arg1 !== undefined) {
|
|
8
|
+
return new Surface({
|
|
9
|
+
...arg0,
|
|
10
|
+
content: arg1,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
const single = arg0;
|
|
14
|
+
if (typeof single === "object" &&
|
|
15
|
+
single !== null &&
|
|
16
|
+
!Array.isArray(single) &&
|
|
17
|
+
"content" in single) {
|
|
18
|
+
return new Surface(single);
|
|
19
|
+
}
|
|
20
|
+
return new Surface({ content: single });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Stack с включённым фоном поверхности (`surface: true`, `--background-color`).
|
|
24
|
+
*/
|
|
25
|
+
class Surface extends stack_1.Stack {
|
|
26
|
+
constructor(config) {
|
|
27
|
+
super({ ...config, surface: true });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Surface = Surface;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.App = void 0;
|
|
4
|
+
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
5
|
+
const entry_component_1 = require("./entry-component");
|
|
6
|
+
// Класс-заглушка: entry-корень для глобальных App-оверлеев.
|
|
7
|
+
class App extends entry_component_1.EntryComponent {
|
|
8
|
+
class() {
|
|
9
|
+
return server_component_class_1.ServerComponentClass.App;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.App = App;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
|
+
import type { BoardConfig, BoardPoint } from "@matreshka/shared/types/board-config";
|
|
3
|
+
import { type FlexItemSpec } from "@matreshka/shared/types/flex-item";
|
|
4
|
+
import type { NestedItemBase } from "@matreshka/shared/types/nested-item-base";
|
|
5
|
+
import { Componentable, ComponentInstance, ComponentTreeNode, StandaloneComponent } from "../core";
|
|
6
|
+
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
7
|
+
import type { ItemList } from "./item-list/item-list";
|
|
8
|
+
import type { ItemListHost } from "./item-list/item-list-host";
|
|
9
|
+
import { Overlay } from "./types/container-overlay";
|
|
10
|
+
export declare const board: (config: BoardInitConfig<Board>) => Board;
|
|
11
|
+
export type BoardItem = {
|
|
12
|
+
position: BoardPoint;
|
|
13
|
+
component: ComponentTreeNode;
|
|
14
|
+
};
|
|
15
|
+
export type BoardItemEntry = BoardItem | ItemList<any, BoardItem>;
|
|
16
|
+
export type BoardProperties = {
|
|
17
|
+
center: BoardPoint;
|
|
18
|
+
zoom: number;
|
|
19
|
+
minZoom: number;
|
|
20
|
+
maxZoom: number;
|
|
21
|
+
zoomStep: number;
|
|
22
|
+
overlays?: Overlay[];
|
|
23
|
+
flexItem?: FlexItemSpec;
|
|
24
|
+
} & ComponentProperties;
|
|
25
|
+
export type BoardInitConfig<ComponentType extends Componentable = Board, PropertiesType extends BoardProperties = BoardProperties> = {
|
|
26
|
+
center?: BoardPoint;
|
|
27
|
+
overlays?: Overlay[];
|
|
28
|
+
zoom?: number;
|
|
29
|
+
minZoom?: number;
|
|
30
|
+
maxZoom?: number;
|
|
31
|
+
/** Шаг зума для колёсика, pinch и zoomIn/zoomOut (@panzoom/panzoom `step`). */
|
|
32
|
+
zoomStep?: number;
|
|
33
|
+
flexItem?: FlexItemSpec;
|
|
34
|
+
items?: BoardItemEntry[];
|
|
35
|
+
onCenterChange?: ServerComponentAction<ComponentType, BoardPoint> | ServerComponentAction<ComponentType, BoardPoint>[];
|
|
36
|
+
onZoomChange?: ServerComponentAction<ComponentType, number> | ServerComponentAction<ComponentType, number>[];
|
|
37
|
+
} & ComponentInitConfig<ComponentType, PropertiesType>;
|
|
38
|
+
type DefaultInitConfigType = BoardInitConfig<Board>;
|
|
39
|
+
export declare class Board<InitConfigType extends BoardInitConfig<any> = DefaultInitConfigType, PropertiesType extends BoardProperties = BoardProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent, ItemListHost {
|
|
40
|
+
private readonly itemsSlot;
|
|
41
|
+
private readonly itemListHostAdapter;
|
|
42
|
+
setCenter(center: BoardPoint, instances?: ComponentInstance[]): void;
|
|
43
|
+
setZoom(zoom: number, instances?: ComponentInstance[]): void;
|
|
44
|
+
zoomIn(instances?: ComponentInstance[]): void;
|
|
45
|
+
zoomOut(instances?: ComponentInstance[]): void;
|
|
46
|
+
constructor(config: InitConfigType);
|
|
47
|
+
get hostInstances(): readonly ComponentInstance[];
|
|
48
|
+
syncNestedItems(slot: string, items: NestedItemBase[]): void;
|
|
49
|
+
resyncNestedSlot(slot: string): void;
|
|
50
|
+
protected class(): ServerComponentClass;
|
|
51
|
+
standalone(): true;
|
|
52
|
+
protected initProperties(initValues: InitConfigType): PropertiesType;
|
|
53
|
+
protected serializeRuleOverrides(overrides: Partial<PropertiesType & {
|
|
54
|
+
items?: BoardItemEntry[];
|
|
55
|
+
}>): Record<string, unknown>;
|
|
56
|
+
serialize(instance?: ComponentInstance<this>): BoardConfig;
|
|
57
|
+
}
|
|
58
|
+
export { itemList } from "./item-list";
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemList = exports.Board = exports.board = void 0;
|
|
4
|
+
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
5
|
+
const board_set_center_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-set-center-message");
|
|
6
|
+
const board_set_zoom_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-set-zoom-message");
|
|
7
|
+
const board_zoom_in_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-zoom-in-message");
|
|
8
|
+
const board_zoom_out_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-zoom-out-message");
|
|
9
|
+
const flex_item_1 = require("@matreshka/shared/types/flex-item");
|
|
10
|
+
const core_1 = require("../core");
|
|
11
|
+
const component_1 = require("./component");
|
|
12
|
+
const item_list_1 = require("./item-list");
|
|
13
|
+
const flatten_nested_items_1 = require("./item-list/flatten-nested-items");
|
|
14
|
+
const DEFAULT_ZOOM = 1;
|
|
15
|
+
const DEFAULT_MIN_ZOOM = 0.25;
|
|
16
|
+
const DEFAULT_MAX_ZOOM = 4;
|
|
17
|
+
const DEFAULT_ZOOM_STEP = 0.3;
|
|
18
|
+
const board = (config) => new Board(config);
|
|
19
|
+
exports.board = board;
|
|
20
|
+
class Board extends component_1.Component {
|
|
21
|
+
setCenter(center, instances) {
|
|
22
|
+
if (instances) {
|
|
23
|
+
instances
|
|
24
|
+
.filter((instance) => instance.client)
|
|
25
|
+
.forEach((instance) => {
|
|
26
|
+
instance.client.outcomingMessage$.next(new board_set_center_message_1.BoardSetCenterMessage(instance.id, center));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.broadcast(new board_set_center_message_1.BoardSetCenterMessage(this.id, center));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
setZoom(zoom, instances) {
|
|
34
|
+
if (instances) {
|
|
35
|
+
instances
|
|
36
|
+
.filter((instance) => instance.client)
|
|
37
|
+
.forEach((instance) => {
|
|
38
|
+
instance.client.outcomingMessage$.next(new board_set_zoom_message_1.BoardSetZoomMessage(instance.id, zoom));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.broadcast(new board_set_zoom_message_1.BoardSetZoomMessage(this.id, zoom));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
zoomIn(instances) {
|
|
46
|
+
if (instances) {
|
|
47
|
+
instances
|
|
48
|
+
.filter((instance) => instance.client)
|
|
49
|
+
.forEach((instance) => {
|
|
50
|
+
instance.client.outcomingMessage$.next(new board_zoom_in_message_1.BoardZoomInMessage(instance.id));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.broadcast(new board_zoom_in_message_1.BoardZoomInMessage(this.id));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
zoomOut(instances) {
|
|
58
|
+
if (instances) {
|
|
59
|
+
instances
|
|
60
|
+
.filter((instance) => instance.client)
|
|
61
|
+
.forEach((instance) => {
|
|
62
|
+
instance.client.outcomingMessage$.next(new board_zoom_out_message_1.BoardZoomOutMessage(instance.id));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.broadcast(new board_zoom_out_message_1.BoardZoomOutMessage(this.id));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
constructor(config) {
|
|
70
|
+
const itemsSlot = (0, item_list_1.createNestedItemsSlotState)(config.items);
|
|
71
|
+
(0, item_list_1.wireNestedItemsHostLifecycle)(config, itemsSlot.itemLists);
|
|
72
|
+
super(config);
|
|
73
|
+
this.itemsSlot = {
|
|
74
|
+
slot: "",
|
|
75
|
+
source: [],
|
|
76
|
+
itemLists: [],
|
|
77
|
+
};
|
|
78
|
+
this.itemsSlot.source = itemsSlot.source;
|
|
79
|
+
this.itemsSlot.itemLists = itemsSlot.itemLists;
|
|
80
|
+
(0, item_list_1.attachItemListsToHost)(this, "items", this.itemsSlot);
|
|
81
|
+
this.itemListHostAdapter = (0, item_list_1.createItemListHostAdapter)(() => this.instances, (slot) => (slot === "items" ? this.itemsSlot : undefined));
|
|
82
|
+
if (config.onCenterChange) {
|
|
83
|
+
const actions = config.onCenterChange;
|
|
84
|
+
this.bindActions("center-change", actions);
|
|
85
|
+
}
|
|
86
|
+
if (config.onZoomChange) {
|
|
87
|
+
const actions = config.onZoomChange;
|
|
88
|
+
this.bindActions("zoom-change", actions);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
get hostInstances() {
|
|
92
|
+
return this.instances;
|
|
93
|
+
}
|
|
94
|
+
syncNestedItems(slot, items) {
|
|
95
|
+
this.itemListHostAdapter.syncNestedItems(slot, items);
|
|
96
|
+
}
|
|
97
|
+
resyncNestedSlot(slot) {
|
|
98
|
+
this.itemListHostAdapter.resyncNestedSlot(slot);
|
|
99
|
+
}
|
|
100
|
+
class() {
|
|
101
|
+
return server_component_class_1.ServerComponentClass.Board;
|
|
102
|
+
}
|
|
103
|
+
standalone() {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
initProperties(initValues) {
|
|
107
|
+
return {
|
|
108
|
+
...super.initProperties(initValues),
|
|
109
|
+
center: initValues.center ?? { x: 0, y: 0 },
|
|
110
|
+
zoom: initValues.zoom ?? DEFAULT_ZOOM,
|
|
111
|
+
minZoom: initValues.minZoom ?? DEFAULT_MIN_ZOOM,
|
|
112
|
+
maxZoom: initValues.maxZoom ?? DEFAULT_MAX_ZOOM,
|
|
113
|
+
zoomStep: initValues.zoomStep ?? DEFAULT_ZOOM_STEP,
|
|
114
|
+
overlays: initValues.overlays,
|
|
115
|
+
flexItem: (0, flex_item_1.normalizeFlexItem)(initValues.flexItem),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
serializeRuleOverrides(overrides) {
|
|
119
|
+
const out = { ...overrides };
|
|
120
|
+
if (overrides.overlays !== undefined) {
|
|
121
|
+
out.overlays = (0, core_1.serializeOverlays)(overrides.overlays);
|
|
122
|
+
}
|
|
123
|
+
if (overrides.items !== undefined) {
|
|
124
|
+
const instance = this.createInstance();
|
|
125
|
+
out.items = (0, flatten_nested_items_1.flattenNestedItems)(overrides.items, instance);
|
|
126
|
+
}
|
|
127
|
+
if (overrides.flexItem !== undefined) {
|
|
128
|
+
out.flexItem = (0, flex_item_1.normalizeFlexItem)(overrides.flexItem);
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
serialize(instance) {
|
|
133
|
+
if (!instance) {
|
|
134
|
+
instance = this.createInstance();
|
|
135
|
+
}
|
|
136
|
+
const result = super.serialize(instance);
|
|
137
|
+
const p = this.properties;
|
|
138
|
+
const items = (0, item_list_1.flattenNestedItemsForSerialize)(this.itemsSlot, instance);
|
|
139
|
+
return {
|
|
140
|
+
...result,
|
|
141
|
+
class: server_component_class_1.ServerComponentClass.Board,
|
|
142
|
+
properties: {
|
|
143
|
+
...p,
|
|
144
|
+
overlays: p.overlays ? (0, core_1.serializeOverlays)(p.overlays) : [],
|
|
145
|
+
items: items ?? [],
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.Board = Board;
|
|
151
|
+
var item_list_2 = require("./item-list");
|
|
152
|
+
Object.defineProperty(exports, "itemList", { enumerable: true, get: function () { return item_list_2.itemList; } });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bootServerComponents = void 0;
|
|
4
|
+
const index_1 = require("@matreshka/shared/messages/bff-to-client/app/index");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const core_1 = require("../core");
|
|
7
|
+
const bootServerComponents = (matreshka) => {
|
|
8
|
+
const sendRoutePage = async (client) => {
|
|
9
|
+
try {
|
|
10
|
+
const page = (await matreshka.router.findByRoute(client, client.state$.getValue().route.path));
|
|
11
|
+
if (page) {
|
|
12
|
+
await page.boot();
|
|
13
|
+
(0, core_1.runWithClient)(client, () => {
|
|
14
|
+
const serializedPage = page.serialize();
|
|
15
|
+
const pageInstance = page
|
|
16
|
+
.getInstances({ client })
|
|
17
|
+
.find((instance) => instance.id === serializedPage.id);
|
|
18
|
+
client.switchPage(pageInstance);
|
|
19
|
+
client.outcomingMessage$.next(new index_1.AppPageMessage(serializedPage));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
client.error$.next(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
matreshka.clientConnect$.subscribe((client) => {
|
|
28
|
+
client.state$
|
|
29
|
+
.pipe((0, rxjs_1.pairwise)())
|
|
30
|
+
.subscribe(([prevState, state]) => {
|
|
31
|
+
if (!prevState ||
|
|
32
|
+
state.route.visitedAt !== prevState.route.visitedAt // Проверка времени посещения вместо пути, потому что по одному пути может быть несколько страниц
|
|
33
|
+
) {
|
|
34
|
+
void sendRoutePage(client);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.bootServerComponents = bootServerComponents;
|