@matreshka/bff 0.17.0 → 0.20.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/dist/components/board.d.ts +4 -7
- package/dist/components/board.js +7 -51
- package/dist/components/camera.d.ts +1 -4
- package/dist/components/camera.js +6 -26
- package/dist/components/component.d.ts +26 -5
- package/dist/components/component.js +35 -2
- package/dist/components/container.js +8 -11
- package/dist/components/dialog.d.ts +1 -4
- package/dist/components/dialog.js +5 -21
- package/dist/components/file-upload-area.js +8 -11
- package/dist/components/form.js +8 -11
- package/dist/components/grid.js +7 -11
- package/dist/components/inputs/text-editor.d.ts +14 -14
- package/dist/components/inputs/text-editor.js +14 -154
- package/dist/components/map.d.ts +4 -7
- package/dist/components/map.js +6 -52
- package/dist/components/page.d.ts +0 -1
- package/dist/components/page.js +4 -10
- package/dist/components/popover.d.ts +1 -4
- package/dist/components/popover.js +5 -21
- package/dist/components/stack.d.ts +2 -5
- package/dist/components/stack.js +6 -28
- package/dist/components/utils/targeted-client-component-action.d.ts +5 -0
- package/dist/components/utils/targeted-client-component-action.js +25 -0
- package/dist/core/utils/serialize-component-tree.d.ts +3 -0
- package/dist/core/utils/serialize-component-tree.js +21 -0
- package/dist/core/utils/targeted-client-action.d.ts +19 -0
- package/dist/core/utils/targeted-client-action.js +68 -0
- package/dist/platforms/browser-platform.d.ts +21 -37
- package/dist/platforms/browser-platform.js +61 -104
- package/dist/platforms/max-mini-app-platform.d.ts +2 -8
- package/dist/platforms/max-mini-app-platform.js +10 -21
- package/dist/platforms/mobile-platform.d.ts +32 -58
- package/dist/platforms/mobile-platform.js +139 -211
- package/dist/platforms/platform.d.ts +32 -49
- package/dist/platforms/platform.js +77 -87
- package/dist/platforms/telegram-mini-app-platform.d.ts +16 -34
- package/dist/platforms/telegram-mini-app-platform.js +41 -92
- package/dist/platforms/utils/client-back-platform-action.d.ts +9 -0
- package/dist/platforms/utils/client-back-platform-action.js +48 -0
- package/dist/platforms/utils/client-navigate-platform-action.d.ts +19 -0
- package/dist/platforms/utils/client-navigate-platform-action.js +60 -0
- package/dist/platforms/utils/client-reload-platform-action.d.ts +8 -0
- package/dist/platforms/utils/client-reload-platform-action.js +41 -0
- package/dist/platforms/utils/client-route-page-wait.d.ts +11 -0
- package/dist/platforms/utils/client-route-page-wait.js +33 -0
- package/dist/platforms/utils/match-navigate-path.d.ts +11 -0
- package/dist/platforms/utils/match-navigate-path.js +95 -0
- package/dist/platforms/utils/targeted-client-platform-action.d.ts +11 -0
- package/dist/platforms/utils/targeted-client-platform-action.js +25 -0
- package/dist/platforms/utils/targeted-client-platform-stream.d.ts +17 -0
- package/dist/platforms/utils/targeted-client-platform-stream.js +90 -0
- package/package.json +2 -2
|
@@ -6,7 +6,6 @@ import { Componentable, ComponentInstance, ComponentTreeNode, StandaloneComponen
|
|
|
6
6
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
7
7
|
import type { ItemList } from "./item-list/item-list";
|
|
8
8
|
import type { ItemListHost } from "./item-list/item-list-host";
|
|
9
|
-
import { Overlay } from "./types/container-overlay";
|
|
10
9
|
export declare const board: (config: BoardInitConfig<Board>) => Board;
|
|
11
10
|
export type BoardItem = {
|
|
12
11
|
position: BoardPoint;
|
|
@@ -19,12 +18,10 @@ export type BoardProperties = {
|
|
|
19
18
|
minZoom: number;
|
|
20
19
|
maxZoom: number;
|
|
21
20
|
zoomStep: number;
|
|
22
|
-
overlays?: Overlay[];
|
|
23
21
|
flexItem?: FlexItemSpec;
|
|
24
22
|
} & ComponentProperties;
|
|
25
23
|
export type BoardInitConfig<ComponentType extends Componentable = Board, PropertiesType extends BoardProperties = BoardProperties> = {
|
|
26
24
|
center?: BoardPoint;
|
|
27
|
-
overlays?: Overlay[];
|
|
28
25
|
zoom?: number;
|
|
29
26
|
minZoom?: number;
|
|
30
27
|
maxZoom?: number;
|
|
@@ -39,10 +36,10 @@ type DefaultInitConfigType = BoardInitConfig<Board>;
|
|
|
39
36
|
export declare class Board<InitConfigType extends BoardInitConfig<any> = DefaultInitConfigType, PropertiesType extends BoardProperties = BoardProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent, ItemListHost {
|
|
40
37
|
private readonly itemsSlot;
|
|
41
38
|
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
|
|
39
|
+
setCenter(center: BoardPoint, instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
40
|
+
setZoom(zoom: number, instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
41
|
+
zoomIn(instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
42
|
+
zoomOut(instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
46
43
|
constructor(config: InitConfigType);
|
|
47
44
|
get hostInstances(): readonly ComponentInstance[];
|
|
48
45
|
syncNestedItems(slot: string, items: NestedItemBase[]): void;
|
package/dist/components/board.js
CHANGED
|
@@ -7,7 +7,6 @@ const board_set_zoom_message_1 = require("@matreshka/shared/messages/bff-to-clie
|
|
|
7
7
|
const board_zoom_in_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-zoom-in-message");
|
|
8
8
|
const board_zoom_out_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-zoom-out-message");
|
|
9
9
|
const flex_item_1 = require("@matreshka/shared/types/flex-item");
|
|
10
|
-
const core_1 = require("../core");
|
|
11
10
|
const component_1 = require("./component");
|
|
12
11
|
const item_list_1 = require("./item-list");
|
|
13
12
|
const flatten_nested_items_1 = require("./item-list/flatten-nested-items");
|
|
@@ -19,52 +18,16 @@ const board = (config) => new Board(config);
|
|
|
19
18
|
exports.board = board;
|
|
20
19
|
class Board extends component_1.Component {
|
|
21
20
|
setCenter(center, instances) {
|
|
22
|
-
|
|
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
|
-
}
|
|
21
|
+
return this.dispatchComponentCommand(instances, (target, actionScope) => new board_set_center_message_1.BoardSetCenterMessage(target, { ...center, actionScope }));
|
|
32
22
|
}
|
|
33
23
|
setZoom(zoom, instances) {
|
|
34
|
-
|
|
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
|
-
}
|
|
24
|
+
return this.dispatchComponentCommand(instances, (target, actionScope) => new board_set_zoom_message_1.BoardSetZoomMessage(target, { zoom, actionScope }));
|
|
44
25
|
}
|
|
45
26
|
zoomIn(instances) {
|
|
46
|
-
|
|
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
|
-
}
|
|
27
|
+
return this.dispatchComponentCommand(instances, (target, actionScope) => new board_zoom_in_message_1.BoardZoomInMessage(target, actionScope));
|
|
56
28
|
}
|
|
57
29
|
zoomOut(instances) {
|
|
58
|
-
|
|
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
|
-
}
|
|
30
|
+
return this.dispatchComponentCommand(instances, (target, actionScope) => new board_zoom_out_message_1.BoardZoomOutMessage(target, actionScope));
|
|
68
31
|
}
|
|
69
32
|
constructor(config) {
|
|
70
33
|
const itemsSlot = (0, item_list_1.createNestedItemsSlotState)(config.items);
|
|
@@ -111,15 +74,11 @@ class Board extends component_1.Component {
|
|
|
111
74
|
minZoom: initValues.minZoom ?? DEFAULT_MIN_ZOOM,
|
|
112
75
|
maxZoom: initValues.maxZoom ?? DEFAULT_MAX_ZOOM,
|
|
113
76
|
zoomStep: initValues.zoomStep ?? DEFAULT_ZOOM_STEP,
|
|
114
|
-
overlays: initValues.overlays,
|
|
115
77
|
flexItem: (0, flex_item_1.normalizeFlexItem)(initValues.flexItem),
|
|
116
78
|
};
|
|
117
79
|
}
|
|
118
80
|
serializeRuleOverrides(overrides) {
|
|
119
|
-
const out =
|
|
120
|
-
if (overrides.overlays !== undefined) {
|
|
121
|
-
out.overlays = (0, core_1.serializeOverlays)(overrides.overlays);
|
|
122
|
-
}
|
|
81
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
123
82
|
if (overrides.items !== undefined) {
|
|
124
83
|
const instance = this.createInstance();
|
|
125
84
|
out.items = (0, flatten_nested_items_1.flattenNestedItems)(overrides.items, instance);
|
|
@@ -134,16 +93,13 @@ class Board extends component_1.Component {
|
|
|
134
93
|
instance = this.createInstance();
|
|
135
94
|
}
|
|
136
95
|
const result = super.serialize(instance);
|
|
137
|
-
const p = this.properties;
|
|
138
96
|
const items = (0, item_list_1.flattenNestedItemsForSerialize)(this.itemsSlot, instance);
|
|
139
97
|
return {
|
|
140
98
|
...result,
|
|
141
99
|
class: server_component_class_1.ServerComponentClass.Board,
|
|
142
|
-
properties: {
|
|
143
|
-
...p,
|
|
144
|
-
overlays: p.overlays ? (0, core_1.serializeOverlays)(p.overlays) : [],
|
|
100
|
+
properties: this.buildPropertiesForClient({
|
|
145
101
|
items: items ?? [],
|
|
146
|
-
},
|
|
102
|
+
}),
|
|
147
103
|
};
|
|
148
104
|
}
|
|
149
105
|
}
|
|
@@ -5,11 +5,9 @@ import type { CameraConfig } from "@matreshka/shared/types/camera-config";
|
|
|
5
5
|
import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray, StandaloneComponent } from "../core";
|
|
6
6
|
import { VideoInputDevice } from "../platforms/platform";
|
|
7
7
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
8
|
-
import { Overlay } from "./types/container-overlay";
|
|
9
8
|
export { VideoFacingMode } from "@matreshka/shared/enums/video-facing-mode";
|
|
10
9
|
export type CameraProperties = {
|
|
11
10
|
content: ComponentTreeNode[];
|
|
12
|
-
overlays?: Overlay[];
|
|
13
11
|
facingMode?: VideoFacingMode;
|
|
14
12
|
} & ComponentProperties;
|
|
15
13
|
/**
|
|
@@ -26,7 +24,6 @@ export type CameraInitConfig<ContentType extends ComponentTreeNode = ComponentTr
|
|
|
26
24
|
* Полезно для кейсов вроде сканирования QR (обычно нужна задняя камера: `"environment"`).
|
|
27
25
|
*/
|
|
28
26
|
facingMode?: VideoFacingMode;
|
|
29
|
-
overlays?: Overlay[];
|
|
30
27
|
content: MixedWithCallbacksArray<ContentType>;
|
|
31
28
|
/**
|
|
32
29
|
* Обработчики события распознавания QR-кода на клиенте.
|
|
@@ -71,7 +68,7 @@ export declare class Camera<ContentType extends ComponentTreeNode = ComponentTre
|
|
|
71
68
|
/**
|
|
72
69
|
* Отправляет на клиент команду переключения активной камеры устройства на указанную.
|
|
73
70
|
*/
|
|
74
|
-
switchCamera(device: VideoInputDevice, instances?: ComponentInstance[]):
|
|
71
|
+
switchCamera(device: VideoInputDevice, instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
75
72
|
protected serializeRuleOverrides(overrides: Partial<PropertiesType>): Record<string, unknown>;
|
|
76
73
|
serialize(): CameraConfig;
|
|
77
74
|
}
|
|
@@ -65,7 +65,6 @@ class Camera extends component_1.Component {
|
|
|
65
65
|
return {
|
|
66
66
|
...super.initProperties(initValues),
|
|
67
67
|
content: (0, core_1.calculateComponents)(initValues.content),
|
|
68
|
-
overlays: initValues.overlays,
|
|
69
68
|
facingMode: initValues.facingMode,
|
|
70
69
|
};
|
|
71
70
|
}
|
|
@@ -73,43 +72,24 @@ class Camera extends component_1.Component {
|
|
|
73
72
|
* Отправляет на клиент команду переключения активной камеры устройства на указанную.
|
|
74
73
|
*/
|
|
75
74
|
switchCamera(device, instances) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.filter((instance) => instance.client)
|
|
79
|
-
.forEach((instance) => {
|
|
80
|
-
instance.client.outcomingMessage$.next(new camera_switch_message_1.CameraSwitchMessage(instance.id, {
|
|
81
|
-
deviceId: device.deviceId,
|
|
82
|
-
}));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
this.broadcast(new camera_switch_message_1.CameraSwitchMessage(this.id, {
|
|
87
|
-
deviceId: device.deviceId,
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
return this;
|
|
75
|
+
const payload = { deviceId: device.deviceId };
|
|
76
|
+
return this.dispatchComponentCommand(instances, (target, actionScope) => new camera_switch_message_1.CameraSwitchMessage(target, { ...payload, actionScope }));
|
|
91
77
|
}
|
|
92
78
|
serializeRuleOverrides(overrides) {
|
|
93
|
-
const out =
|
|
79
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
94
80
|
if (overrides.content !== undefined) {
|
|
95
81
|
out.content = (0, core_1.serializeComponentList)(overrides.content);
|
|
96
82
|
}
|
|
97
|
-
if (overrides.overlays !== undefined) {
|
|
98
|
-
out.overlays = (0, core_1.serializeOverlays)(overrides.overlays);
|
|
99
|
-
}
|
|
100
83
|
return out;
|
|
101
84
|
}
|
|
102
85
|
serialize() {
|
|
103
86
|
const result = super.serialize();
|
|
104
|
-
const p = this.properties;
|
|
105
87
|
return {
|
|
106
88
|
...result,
|
|
107
89
|
class: server_component_class_1.ServerComponentClass.Camera,
|
|
108
|
-
properties: {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
overlays: p.overlays ? (0, core_1.serializeOverlays)(p.overlays) : undefined,
|
|
112
|
-
},
|
|
90
|
+
properties: this.buildPropertiesForClient({
|
|
91
|
+
content: (0, core_1.serializeComponentList)(this.properties.content),
|
|
92
|
+
}),
|
|
113
93
|
};
|
|
114
94
|
}
|
|
115
95
|
}
|
|
@@ -4,14 +4,16 @@ import { TextAlign } from "@matreshka/shared/enums/text-align";
|
|
|
4
4
|
import { TextDecoration } from "@matreshka/shared/enums/text-decoration";
|
|
5
5
|
import { ComponentCommandMessage } from "@matreshka/shared/messages/bff-to-client/component-command-message";
|
|
6
6
|
import { ColorToken } from "@matreshka/shared/types/color-token";
|
|
7
|
+
import type { Overlay as ClientOverlayShape } from "@matreshka/shared/types/container-overlay";
|
|
7
8
|
import type { FontStackToken } from "@matreshka/shared/types/fonts";
|
|
8
9
|
import type { GridItem } from "@matreshka/shared/types/grid-item";
|
|
9
10
|
import type { ServerComponentConfig } from "@matreshka/shared/types/server-component-config";
|
|
10
|
-
import { Subscription } from "rxjs";
|
|
11
|
+
import { Observable, Subscription } from "rxjs";
|
|
11
12
|
import { Client, Componentable, ComponentInstance, LocalAction } from "../core";
|
|
12
13
|
import { Condition } from "../core/conditions";
|
|
13
14
|
import { ServerAction, ServerActionHandler } from "./actions/server-action";
|
|
14
15
|
import type { EntryComponent } from "./entry-component";
|
|
16
|
+
import type { Overlay } from "./types/container-overlay";
|
|
15
17
|
/**
|
|
16
18
|
* @prop colors - Цветовые схемы для раскраски
|
|
17
19
|
* @prop font - Stack token для сборки CSS-свойств шрифта
|
|
@@ -33,6 +35,14 @@ export type ComponentProperties = {
|
|
|
33
35
|
link?: {
|
|
34
36
|
value: string;
|
|
35
37
|
};
|
|
38
|
+
/** Наложения поверх компонента (якоря + вложенный component). */
|
|
39
|
+
overlays?: Overlay[];
|
|
40
|
+
};
|
|
41
|
+
/** Оверлей в wire-конфиге (вложенный component уже сериализован). */
|
|
42
|
+
export type ClientSerializedOverlay = ClientOverlayShape<ServerComponentConfig>;
|
|
43
|
+
/** BFF-свойства компонента, подготовленные для клиента (overlays сериализованы). */
|
|
44
|
+
export type ClientSerializedProperties<P extends ComponentProperties> = Omit<P, "overlays"> & {
|
|
45
|
+
overlays?: ClientSerializedOverlay[];
|
|
36
46
|
};
|
|
37
47
|
/**
|
|
38
48
|
* Переопределения в {@link ComponentInitConfig.rules}: те же поля, что у свойств
|
|
@@ -72,6 +82,8 @@ export type ComponentInitConfig<ComponentType extends Componentable, PropertiesT
|
|
|
72
82
|
textDecoration?: TextDecoration;
|
|
73
83
|
/** Настройки размещения элемента, когда он находится внутри grid. */
|
|
74
84
|
gridItem?: GridItem;
|
|
85
|
+
/** Наложения поверх компонента. */
|
|
86
|
+
overlays?: Overlay[];
|
|
75
87
|
conditions?: Condition[] | (() => Condition[]);
|
|
76
88
|
rules?: {
|
|
77
89
|
conditions: [Condition, ...Condition[]];
|
|
@@ -107,13 +119,13 @@ export declare abstract class Component<InitConfigType extends ComponentInitConf
|
|
|
107
119
|
private destroyHandlers;
|
|
108
120
|
private _destroyInstance$;
|
|
109
121
|
/** Сигнал о том, что инстанс компонента прекращено */
|
|
110
|
-
readonly destroyInstance$:
|
|
122
|
+
readonly destroyInstance$: Observable<ComponentInstance<Componentable>>;
|
|
111
123
|
private _startUsing$;
|
|
112
124
|
/** Сигнал о том, что инстанс компонента началось (появилось первое инстанс) */
|
|
113
|
-
readonly startUsing$:
|
|
125
|
+
readonly startUsing$: Observable<void>;
|
|
114
126
|
private _stopUsing$;
|
|
115
127
|
/** Сигнал о том, что инстанс компонента прекращено (завершилось последнее инстанс) */
|
|
116
|
-
readonly stopUsing$:
|
|
128
|
+
readonly stopUsing$: Observable<void>;
|
|
117
129
|
constructor(config: InitConfigType);
|
|
118
130
|
/** Инициализация свойств, происходит при первом обращении к свойствам */
|
|
119
131
|
protected initProperties(initValues: InitConfigType): PropertiesType;
|
|
@@ -124,6 +136,11 @@ export declare abstract class Component<InitConfigType extends ComponentInitConf
|
|
|
124
136
|
protected bindActions(event: string, actions: ServerComponentAction<Componentable> | ServerComponentAction<Componentable>[]): void;
|
|
125
137
|
/** Массовая установка внутренних server-only cleanup-обработчиков release stage. */
|
|
126
138
|
protected bindDestroyActions(actions: ServerDestroyAction<Componentable> | ServerDestroyAction<Componentable>[]): void;
|
|
139
|
+
/**
|
|
140
|
+
* Hot Observable: команда pingable component command с ack клиента.
|
|
141
|
+
* По одному сообщению на каждый instance с подключённым клиентом.
|
|
142
|
+
*/
|
|
143
|
+
protected dispatchComponentCommand(instances: ComponentInstance[] | undefined, createMessage: (instanceTarget: string, actionScope: string) => ComponentCommandMessage): Observable<void>;
|
|
127
144
|
/** Рассылка сообщения всем подписанным клиентам данного компонента */
|
|
128
145
|
protected broadcast(message: ComponentCommandMessage): void;
|
|
129
146
|
/** Обработка взаимодействия */
|
|
@@ -134,7 +151,11 @@ export declare abstract class Component<InitConfigType extends ComponentInitConf
|
|
|
134
151
|
protected onInteraction<PayloadType>(type: string, callback: ServerComponentAction<Componentable, PayloadType>): this;
|
|
135
152
|
protected usingByClient(client: Client): boolean;
|
|
136
153
|
protected usingByEntry(entry: EntryComponent): boolean;
|
|
137
|
-
protected serializeRuleOverrides(overrides:
|
|
154
|
+
protected serializeRuleOverrides(overrides: Partial<PropertiesType>): Record<string, unknown>;
|
|
155
|
+
/** Свойства для клиента: сериализует overlays и убирает сырые деревья component. */
|
|
156
|
+
protected serializePropertiesForClient(properties: PropertiesType): ClientSerializedProperties<PropertiesType>;
|
|
157
|
+
/** {@link serializePropertiesForClient} + поля, которые сериализуются только в override (content, markers, …). */
|
|
158
|
+
protected buildPropertiesForClient<T extends Record<string, unknown>>(extra?: T): ClientSerializedProperties<PropertiesType> & T;
|
|
138
159
|
protected resolveRuleOverridesForClient(overrides: ComponentRuleOverrides<PropertiesType>): Partial<PropertiesType>;
|
|
139
160
|
/** Проверяет, содержит ли компонент хотя бы один серверный обработчик. В этом случае нужно подписываться на входящие сообщения от клиента */
|
|
140
161
|
private hasServerAction;
|
|
@@ -40,8 +40,10 @@ const crypto = __importStar(require("node:crypto"));
|
|
|
40
40
|
const rxjs_1 = require("rxjs");
|
|
41
41
|
const core_1 = require("../core");
|
|
42
42
|
const incoming_message_observer_1 = require("../core/utils/incoming-message-observer");
|
|
43
|
+
const serialize_component_tree_1 = require("../core/utils/serialize-component-tree");
|
|
43
44
|
const track_created_instances_1 = require("../core/utils/track-created-instances");
|
|
44
45
|
const server_action_1 = require("./actions/server-action");
|
|
46
|
+
const targeted_client_component_action_1 = require("./utils/targeted-client-component-action");
|
|
45
47
|
/**
|
|
46
48
|
* @typeParam InitConfigType - Тип конфигурации, используемой в конструкторе компонента
|
|
47
49
|
* @typeParam PropertiesType - Тип свойств компонента
|
|
@@ -98,6 +100,7 @@ class Component {
|
|
|
98
100
|
textDecoration: initValues.textDecoration,
|
|
99
101
|
gridItem: initValues.gridItem,
|
|
100
102
|
link: initValues.link,
|
|
103
|
+
overlays: initValues.overlays,
|
|
101
104
|
colors,
|
|
102
105
|
};
|
|
103
106
|
}
|
|
@@ -123,6 +126,21 @@ class Component {
|
|
|
123
126
|
this.destroyHandlers.push(this.parseDestroyAction(action));
|
|
124
127
|
});
|
|
125
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Hot Observable: команда pingable component command с ack клиента.
|
|
131
|
+
* По одному сообщению на каждый instance с подключённым клиентом.
|
|
132
|
+
*/
|
|
133
|
+
dispatchComponentCommand(instances, createMessage) {
|
|
134
|
+
const targets = (instances ?? this.instances).filter((instance) => instance.client);
|
|
135
|
+
if (targets.length === 0) {
|
|
136
|
+
return (0, rxjs_1.of)(undefined);
|
|
137
|
+
}
|
|
138
|
+
const actions = targets.map((instance) => (0, targeted_client_component_action_1.targetedClientComponentAction)(instance.client, (actionScope) => createMessage(instance.id, actionScope)));
|
|
139
|
+
if (actions.length === 1) {
|
|
140
|
+
return actions[0];
|
|
141
|
+
}
|
|
142
|
+
return (0, rxjs_1.forkJoin)(actions).pipe((0, rxjs_1.map)(() => undefined));
|
|
143
|
+
}
|
|
126
144
|
/** Рассылка сообщения всем подписанным клиентам данного компонента */
|
|
127
145
|
broadcast(message) {
|
|
128
146
|
new Set(this.instances
|
|
@@ -181,7 +199,22 @@ class Component {
|
|
|
181
199
|
this.instances.some((x) => x.entry?.component === entry));
|
|
182
200
|
}
|
|
183
201
|
serializeRuleOverrides(overrides) {
|
|
184
|
-
|
|
202
|
+
const out = { ...overrides };
|
|
203
|
+
(0, serialize_component_tree_1.assignSerializedOverlays)(out, overrides.overlays);
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
/** Свойства для клиента: сериализует overlays и убирает сырые деревья component. */
|
|
207
|
+
serializePropertiesForClient(properties) {
|
|
208
|
+
const out = { ...properties };
|
|
209
|
+
(0, serialize_component_tree_1.assignSerializedOverlays)(out, properties.overlays);
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
/** {@link serializePropertiesForClient} + поля, которые сериализуются только в override (content, markers, …). */
|
|
213
|
+
buildPropertiesForClient(extra = {}) {
|
|
214
|
+
return {
|
|
215
|
+
...this.serializePropertiesForClient(this.properties),
|
|
216
|
+
...extra,
|
|
217
|
+
};
|
|
185
218
|
}
|
|
186
219
|
resolveRuleOverridesForClient(overrides) {
|
|
187
220
|
if (overrides.colors === undefined) {
|
|
@@ -300,7 +333,7 @@ class Component {
|
|
|
300
333
|
result.interactions = interactions;
|
|
301
334
|
}
|
|
302
335
|
if (hasProperties) {
|
|
303
|
-
result.properties = properties;
|
|
336
|
+
result.properties = this.serializePropertiesForClient(properties);
|
|
304
337
|
}
|
|
305
338
|
if (hasRules) {
|
|
306
339
|
result.rules = rules.map((rule) => ({
|
|
@@ -57,23 +57,20 @@ class Container extends component_1.Component {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
serializeRuleOverrides(overrides) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
content
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
60
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
61
|
+
if (overrides.content !== undefined) {
|
|
62
|
+
out.content = (0, core_1.serializeComponentList)(overrides.content);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
66
65
|
}
|
|
67
66
|
serialize() {
|
|
68
67
|
const result = super.serialize();
|
|
69
|
-
const p = this.properties;
|
|
70
68
|
return {
|
|
71
69
|
...result,
|
|
72
70
|
class: server_component_class_1.ServerComponentClass.Container,
|
|
73
|
-
properties: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
71
|
+
properties: this.buildPropertiesForClient({
|
|
72
|
+
content: (0, core_1.serializeComponentList)(this.properties.content),
|
|
73
|
+
}),
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
76
|
}
|
|
@@ -5,7 +5,6 @@ import type { DialogConfig } from "@matreshka/shared/types/dialog-config";
|
|
|
5
5
|
import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray } from "../core";
|
|
6
6
|
import type { AnimateComponent } from "../core/actions/animate-component";
|
|
7
7
|
import { EntryComponent, EntryComponentInitConfig, EntryComponentProperties } from "./entry-component";
|
|
8
|
-
import { Overlay } from "./types/container-overlay";
|
|
9
8
|
/** Анимации подложки модального диалога при инициализации. */
|
|
10
9
|
export type DialogBackdropInitConfig = {
|
|
11
10
|
onEnter?: AnimateComponent | AnimateComponent[];
|
|
@@ -24,7 +23,6 @@ export type DialogProperties = {
|
|
|
24
23
|
* См. {@link DialogInitConfig.modal}.
|
|
25
24
|
*/
|
|
26
25
|
modal?: boolean;
|
|
27
|
-
overlays?: Overlay[];
|
|
28
26
|
/** Анимации нативной подложки (`::backdrop`) модального диалога. */
|
|
29
27
|
backdrop?: DialogBackdropConfig;
|
|
30
28
|
} & EntryComponentProperties;
|
|
@@ -44,7 +42,6 @@ export type DialogInitConfig<ComponentType extends Componentable = Dialog, Prope
|
|
|
44
42
|
* `false` — немодальное (`show()`): остальная страница остаётся доступной
|
|
45
43
|
*/
|
|
46
44
|
modal?: boolean;
|
|
47
|
-
overlays?: Overlay[];
|
|
48
45
|
/** Анимации нативной подложки (`::backdrop`) модального диалога. */
|
|
49
46
|
backdrop?: DialogBackdropInitConfig;
|
|
50
47
|
} & EntryComponentInitConfig<ComponentType, PropertiesType>;
|
|
@@ -75,7 +72,7 @@ export declare class Dialog<InitConfigType extends DialogInitConfig<any> = Defau
|
|
|
75
72
|
/**
|
|
76
73
|
* Закрывает диалог, инициируя событие взаимодействия "close".
|
|
77
74
|
*/
|
|
78
|
-
close(instances?: ComponentInstance[]): void
|
|
75
|
+
close(instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
79
76
|
protected serializeRuleOverrides(overrides: Partial<PropertiesType>): Record<string, unknown>;
|
|
80
77
|
protected serializeEntry(instance: ComponentInstance<this>): DialogConfig;
|
|
81
78
|
serialize(instance?: ComponentInstance<this>): DialogConfig;
|
|
@@ -71,7 +71,6 @@ class Dialog extends entry_component_1.EntryComponent {
|
|
|
71
71
|
content: (0, core_1.calculateComponents)(initValues.content),
|
|
72
72
|
anchors: initValues.anchors,
|
|
73
73
|
modal: initValues.modal,
|
|
74
|
-
overlays: initValues.overlays,
|
|
75
74
|
backdrop: serializeDialogBackdrop(initValues.backdrop),
|
|
76
75
|
};
|
|
77
76
|
}
|
|
@@ -79,38 +78,23 @@ class Dialog extends entry_component_1.EntryComponent {
|
|
|
79
78
|
* Закрывает диалог, инициируя событие взаимодействия "close".
|
|
80
79
|
*/
|
|
81
80
|
close(instances) {
|
|
82
|
-
|
|
83
|
-
instances
|
|
84
|
-
.filter((instance) => instance.client)
|
|
85
|
-
.forEach((instance) => {
|
|
86
|
-
instance.client.outcomingMessage$.next(new dialog_close_message_1.DialogCloseMessage(instance.id));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
this.broadcast(new dialog_close_message_1.DialogCloseMessage(this.id));
|
|
91
|
-
}
|
|
81
|
+
return this.dispatchComponentCommand(instances, (target, actionScope) => new dialog_close_message_1.DialogCloseMessage(target, actionScope));
|
|
92
82
|
}
|
|
93
83
|
serializeRuleOverrides(overrides) {
|
|
94
|
-
const out =
|
|
84
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
95
85
|
if (overrides.content !== undefined) {
|
|
96
86
|
out.content = (0, core_1.serializeComponentList)(overrides.content);
|
|
97
87
|
}
|
|
98
|
-
if (overrides.overlays !== undefined) {
|
|
99
|
-
out.overlays = (0, core_1.serializeOverlays)(overrides.overlays);
|
|
100
|
-
}
|
|
101
88
|
return out;
|
|
102
89
|
}
|
|
103
90
|
serializeEntry(instance) {
|
|
104
91
|
const result = super.serializeEntry(instance);
|
|
105
|
-
const p = this.properties;
|
|
106
92
|
return {
|
|
107
93
|
...result,
|
|
108
94
|
class: server_component_class_1.ServerComponentClass.Dialog,
|
|
109
|
-
properties: {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
overlays: p.overlays ? (0, core_1.serializeOverlays)(p.overlays) : [],
|
|
113
|
-
},
|
|
95
|
+
properties: this.buildPropertiesForClient({
|
|
96
|
+
content: (0, core_1.serializeComponentList)(this.properties.content),
|
|
97
|
+
}),
|
|
114
98
|
};
|
|
115
99
|
}
|
|
116
100
|
serialize(instance) {
|
|
@@ -115,23 +115,20 @@ class FileUploadArea extends component_1.Component {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
serializeRuleOverrides(overrides) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
content
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
118
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
119
|
+
if (overrides.content !== undefined) {
|
|
120
|
+
out.content = (0, core_1.serializeComponentList)(overrides.content);
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
124
123
|
}
|
|
125
124
|
serialize() {
|
|
126
125
|
const result = super.serialize();
|
|
127
|
-
const p = this.properties;
|
|
128
126
|
return {
|
|
129
127
|
...result,
|
|
130
128
|
class: server_component_class_1.ServerComponentClass.FileUploadArea,
|
|
131
|
-
properties: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
129
|
+
properties: this.buildPropertiesForClient({
|
|
130
|
+
content: (0, core_1.serializeComponentList)(this.properties.content),
|
|
131
|
+
}),
|
|
135
132
|
};
|
|
136
133
|
}
|
|
137
134
|
}
|
package/dist/components/form.js
CHANGED
|
@@ -69,23 +69,20 @@ class Form extends component_1.Component {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
serializeRuleOverrides(overrides) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
content
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
72
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
73
|
+
if (overrides.content !== undefined) {
|
|
74
|
+
out.content = (0, core_1.serializeComponentList)(overrides.content);
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
78
77
|
}
|
|
79
78
|
serialize() {
|
|
80
79
|
const result = super.serialize();
|
|
81
|
-
const p = this.properties;
|
|
82
80
|
return {
|
|
83
81
|
...result,
|
|
84
82
|
class: server_component_class_1.ServerComponentClass.Form,
|
|
85
|
-
properties: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
83
|
+
properties: this.buildPropertiesForClient({
|
|
84
|
+
content: (0, core_1.serializeComponentList)(this.properties.content),
|
|
85
|
+
}),
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
88
|
}
|
package/dist/components/grid.js
CHANGED
|
@@ -52,12 +52,10 @@ class Grid extends component_1.Component {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
serializeRuleOverrides(overrides) {
|
|
55
|
-
const out =
|
|
56
|
-
|
|
57
|
-
content
|
|
58
|
-
|
|
59
|
-
: undefined,
|
|
60
|
-
};
|
|
55
|
+
const out = super.serializeRuleOverrides(overrides);
|
|
56
|
+
if (overrides.content !== undefined) {
|
|
57
|
+
out.content = (0, core_1.serializeComponentList)(overrides.content);
|
|
58
|
+
}
|
|
61
59
|
if (overrides.flexItem !== undefined) {
|
|
62
60
|
out.flexItem = (0, flex_item_1.normalizeFlexItem)(overrides.flexItem);
|
|
63
61
|
}
|
|
@@ -65,14 +63,12 @@ class Grid extends component_1.Component {
|
|
|
65
63
|
}
|
|
66
64
|
serialize() {
|
|
67
65
|
const result = super.serialize();
|
|
68
|
-
const p = this.properties;
|
|
69
66
|
return {
|
|
70
67
|
...result,
|
|
71
68
|
class: server_component_class_1.ServerComponentClass.Grid,
|
|
72
|
-
properties: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
69
|
+
properties: this.buildPropertiesForClient({
|
|
70
|
+
content: (0, core_1.serializeComponentList)(this.properties.content),
|
|
71
|
+
}),
|
|
76
72
|
};
|
|
77
73
|
}
|
|
78
74
|
}
|