@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.
Files changed (275) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +35 -0
  3. package/dist/components/actions/server-action.d.ts +30 -0
  4. package/dist/components/actions/server-action.js +23 -0
  5. package/dist/components/aliases/button.d.ts +17 -0
  6. package/dist/components/aliases/button.js +54 -0
  7. package/dist/components/aliases/column.d.ts +11 -0
  8. package/dist/components/aliases/column.js +31 -0
  9. package/dist/components/aliases/row.d.ts +11 -0
  10. package/dist/components/aliases/row.js +31 -0
  11. package/dist/components/aliases/surface.d.ts +11 -0
  12. package/dist/components/aliases/surface.js +30 -0
  13. package/dist/components/app.d.ts +5 -0
  14. package/dist/components/app.js +12 -0
  15. package/dist/components/board.d.ts +58 -0
  16. package/dist/components/board.js +152 -0
  17. package/dist/components/boot.d.ts +2 -0
  18. package/dist/components/boot.js +39 -0
  19. package/dist/components/camera.d.ts +77 -0
  20. package/dist/components/camera.js +116 -0
  21. package/dist/components/charts/bar-chart.d.ts +14 -0
  22. package/dist/components/charts/bar-chart.js +27 -0
  23. package/dist/components/charts/chart.d.ts +69 -0
  24. package/dist/components/charts/chart.js +42 -0
  25. package/dist/components/charts/doughnut-chart.d.ts +14 -0
  26. package/dist/components/charts/doughnut-chart.js +27 -0
  27. package/dist/components/charts/line-chart.d.ts +14 -0
  28. package/dist/components/charts/line-chart.js +27 -0
  29. package/dist/components/charts/pie-chart.d.ts +14 -0
  30. package/dist/components/charts/pie-chart.js +27 -0
  31. package/dist/components/charts/polar-area-chart.d.ts +14 -0
  32. package/dist/components/charts/polar-area-chart.js +27 -0
  33. package/dist/components/charts/radar-chart.d.ts +14 -0
  34. package/dist/components/charts/radar-chart.js +27 -0
  35. package/dist/components/component.d.ts +159 -0
  36. package/dist/components/component.js +380 -0
  37. package/dist/components/container.d.ts +48 -0
  38. package/dist/components/container.js +80 -0
  39. package/dist/components/dialog.d.ts +83 -0
  40. package/dist/components/dialog.js +120 -0
  41. package/dist/components/entry-component.d.ts +34 -0
  42. package/dist/components/entry-component.js +74 -0
  43. package/dist/components/enum/password-input-kind.d.ts +1 -0
  44. package/dist/components/enum/password-input-kind.js +5 -0
  45. package/dist/components/enum/popover-position-area.d.ts +1 -0
  46. package/dist/components/enum/popover-position-area.js +5 -0
  47. package/dist/components/enum/text-input-kind.d.ts +1 -0
  48. package/dist/components/enum/text-input-kind.js +5 -0
  49. package/dist/components/enum/textarea-resize.d.ts +1 -0
  50. package/dist/components/enum/textarea-resize.js +5 -0
  51. package/dist/components/file-upload-area.d.ts +79 -0
  52. package/dist/components/file-upload-area.js +138 -0
  53. package/dist/components/for-each.d.ts +188 -0
  54. package/dist/components/for-each.js +362 -0
  55. package/dist/components/form.d.ts +62 -0
  56. package/dist/components/form.js +92 -0
  57. package/dist/components/grid.d.ts +80 -0
  58. package/dist/components/grid.js +79 -0
  59. package/dist/components/index.d.ts +55 -0
  60. package/dist/components/index.js +76 -0
  61. package/dist/components/inputs/input-component.d.ts +37 -0
  62. package/dist/components/inputs/input-component.js +30 -0
  63. package/dist/components/inputs/number-input.d.ts +45 -0
  64. package/dist/components/inputs/number-input.js +43 -0
  65. package/dist/components/inputs/password-input.d.ts +28 -0
  66. package/dist/components/inputs/password-input.js +42 -0
  67. package/dist/components/inputs/text-editor.d.ts +91 -0
  68. package/dist/components/inputs/text-editor.js +282 -0
  69. package/dist/components/inputs/text-input.d.ts +48 -0
  70. package/dist/components/inputs/text-input.js +40 -0
  71. package/dist/components/inputs/textarea.d.ts +36 -0
  72. package/dist/components/inputs/textarea.js +42 -0
  73. package/dist/components/item-list/flatten-nested-items.d.ts +11 -0
  74. package/dist/components/item-list/flatten-nested-items.js +100 -0
  75. package/dist/components/item-list/index.d.ts +5 -0
  76. package/dist/components/item-list/index.js +21 -0
  77. package/dist/components/item-list/item-list-host.d.ts +10 -0
  78. package/dist/components/item-list/item-list-host.js +2 -0
  79. package/dist/components/item-list/item-list.d.ts +68 -0
  80. package/dist/components/item-list/item-list.js +206 -0
  81. package/dist/components/item-list/list-from-ref-context.d.ts +11 -0
  82. package/dist/components/item-list/list-from-ref-context.js +27 -0
  83. package/dist/components/item-list/nested-items-host-support.d.ts +36 -0
  84. package/dist/components/item-list/nested-items-host-support.js +109 -0
  85. package/dist/components/item-list/types.d.ts +40 -0
  86. package/dist/components/item-list/types.js +13 -0
  87. package/dist/components/line.d.ts +43 -0
  88. package/dist/components/line.js +35 -0
  89. package/dist/components/map.d.ts +83 -0
  90. package/dist/components/map.js +146 -0
  91. package/dist/components/outputs/currency.d.ts +63 -0
  92. package/dist/components/outputs/currency.js +42 -0
  93. package/dist/components/outputs/datetime.d.ts +69 -0
  94. package/dist/components/outputs/datetime.js +49 -0
  95. package/dist/components/outputs/icon.d.ts +43 -0
  96. package/dist/components/outputs/icon.js +38 -0
  97. package/dist/components/outputs/iframe.d.ts +48 -0
  98. package/dist/components/outputs/iframe.js +44 -0
  99. package/dist/components/outputs/image.d.ts +73 -0
  100. package/dist/components/outputs/image.js +63 -0
  101. package/dist/components/outputs/number.d.ts +39 -0
  102. package/dist/components/outputs/number.js +47 -0
  103. package/dist/components/outputs/output-component.d.ts +58 -0
  104. package/dist/components/outputs/output-component.js +50 -0
  105. package/dist/components/outputs/progress-bar.d.ts +33 -0
  106. package/dist/components/outputs/progress-bar.js +42 -0
  107. package/dist/components/outputs/progress-spinner.d.ts +37 -0
  108. package/dist/components/outputs/progress-spinner.js +43 -0
  109. package/dist/components/outputs/qr-code.d.ts +28 -0
  110. package/dist/components/outputs/qr-code.js +40 -0
  111. package/dist/components/outputs/text.d.ts +57 -0
  112. package/dist/components/outputs/text.js +78 -0
  113. package/dist/components/outputs/vector.d.ts +47 -0
  114. package/dist/components/outputs/vector.js +53 -0
  115. package/dist/components/page.d.ts +96 -0
  116. package/dist/components/page.js +127 -0
  117. package/dist/components/popover.d.ts +63 -0
  118. package/dist/components/popover.js +96 -0
  119. package/dist/components/stack.d.ts +158 -0
  120. package/dist/components/stack.js +146 -0
  121. package/dist/components/types/component-sequence.d.ts +3 -0
  122. package/dist/components/types/component-sequence.js +2 -0
  123. package/dist/components/types/container-overlay.d.ts +3 -0
  124. package/dist/components/types/container-overlay.js +2 -0
  125. package/dist/components/utils/component-factory-shared.d.ts +4 -0
  126. package/dist/components/utils/component-factory-shared.js +12 -0
  127. package/dist/core/actions/action.d.ts +35 -0
  128. package/dist/core/actions/action.js +45 -0
  129. package/dist/core/actions/animate-component.d.ts +58 -0
  130. package/dist/core/actions/animate-component.js +57 -0
  131. package/dist/core/actions/local-action.d.ts +8 -0
  132. package/dist/core/actions/local-action.js +12 -0
  133. package/dist/core/actions/set-context-value.d.ts +18 -0
  134. package/dist/core/actions/set-context-value.js +32 -0
  135. package/dist/core/actions/set-context-values.d.ts +34 -0
  136. package/dist/core/actions/set-context-values.js +30 -0
  137. package/dist/core/actions/toggle-context-value.d.ts +21 -0
  138. package/dist/core/actions/toggle-context-value.js +30 -0
  139. package/dist/core/actions/write-text-to-clipboard.d.ts +30 -0
  140. package/dist/core/actions/write-text-to-clipboard.js +44 -0
  141. package/dist/core/boot.d.ts +2 -0
  142. package/dist/core/boot.js +8 -0
  143. package/dist/core/client-context.d.ts +7 -0
  144. package/dist/core/client-context.js +20 -0
  145. package/dist/core/client.d.ts +133 -0
  146. package/dist/core/client.js +292 -0
  147. package/dist/core/conditions/condition-group.d.ts +14 -0
  148. package/dist/core/conditions/condition-group.js +30 -0
  149. package/dist/core/conditions/condition-operand.d.ts +27 -0
  150. package/dist/core/conditions/condition-operand.js +15 -0
  151. package/dist/core/conditions/condition.d.ts +27 -0
  152. package/dist/core/conditions/condition.js +35 -0
  153. package/dist/core/conditions/context-array-includes.d.ts +32 -0
  154. package/dist/core/conditions/context-array-includes.js +52 -0
  155. package/dist/core/conditions/context-array-length.d.ts +86 -0
  156. package/dist/core/conditions/context-array-length.js +155 -0
  157. package/dist/core/conditions/context-value-defined.d.ts +12 -0
  158. package/dist/core/conditions/context-value-defined.js +21 -0
  159. package/dist/core/conditions/context-value-equal.d.ts +14 -0
  160. package/dist/core/conditions/context-value-equal.js +26 -0
  161. package/dist/core/conditions/context-value-in.d.ts +17 -0
  162. package/dist/core/conditions/context-value-in.js +26 -0
  163. package/dist/core/conditions/context-value-not-equal.d.ts +14 -0
  164. package/dist/core/conditions/context-value-not-equal.js +26 -0
  165. package/dist/core/conditions/context-value-undefined.d.ts +12 -0
  166. package/dist/core/conditions/context-value-undefined.js +21 -0
  167. package/dist/core/conditions/desktop-device.d.ts +11 -0
  168. package/dist/core/conditions/desktop-device.js +21 -0
  169. package/dist/core/conditions/groups.d.ts +71 -0
  170. package/dist/core/conditions/groups.js +74 -0
  171. package/dist/core/conditions/index.d.ts +17 -0
  172. package/dist/core/conditions/index.js +33 -0
  173. package/dist/core/conditions/mobile-device.d.ts +11 -0
  174. package/dist/core/conditions/mobile-device.js +21 -0
  175. package/dist/core/conditions/not-desktop-device.d.ts +11 -0
  176. package/dist/core/conditions/not-desktop-device.js +21 -0
  177. package/dist/core/conditions/not-mobile-device.d.ts +11 -0
  178. package/dist/core/conditions/not-mobile-device.js +21 -0
  179. package/dist/core/conditions/not-tablet-device.d.ts +11 -0
  180. package/dist/core/conditions/not-tablet-device.js +21 -0
  181. package/dist/core/conditions/tablet-device.d.ts +11 -0
  182. package/dist/core/conditions/tablet-device.js +21 -0
  183. package/dist/core/context/context-ref.d.ts +48 -0
  184. package/dist/core/context/context-ref.js +58 -0
  185. package/dist/core/context/context.d.ts +121 -0
  186. package/dist/core/context/context.js +353 -0
  187. package/dist/core/entry-context.d.ts +14 -0
  188. package/dist/core/entry-context.js +31 -0
  189. package/dist/core/gateway-connection.d.ts +29 -0
  190. package/dist/core/gateway-connection.js +146 -0
  191. package/dist/core/index.d.ts +30 -0
  192. package/dist/core/index.js +46 -0
  193. package/dist/core/matreshka.d.ts +61 -0
  194. package/dist/core/matreshka.js +186 -0
  195. package/dist/core/router.d.ts +38 -0
  196. package/dist/core/router.js +116 -0
  197. package/dist/core/types/client-settings.d.ts +31 -0
  198. package/dist/core/types/client-settings.js +2 -0
  199. package/dist/core/types/component-instance.d.ts +25 -0
  200. package/dist/core/types/component-instance.js +42 -0
  201. package/dist/core/types/component-tree-node.d.ts +11 -0
  202. package/dist/core/types/component-tree-node.js +18 -0
  203. package/dist/core/types/componentable.d.ts +21 -0
  204. package/dist/core/types/componentable.js +2 -0
  205. package/dist/core/types/context-ref-primitive-value.d.ts +5 -0
  206. package/dist/core/types/context-ref-primitive-value.js +2 -0
  207. package/dist/core/types/message.d.ts +15 -0
  208. package/dist/core/types/message.js +2 -0
  209. package/dist/core/types/mixed-with-callbacks-array.d.ts +9 -0
  210. package/dist/core/types/mixed-with-callbacks-array.js +2 -0
  211. package/dist/core/types/native-picker-context-ref.d.ts +7 -0
  212. package/dist/core/types/native-picker-context-ref.js +2 -0
  213. package/dist/core/types/pageable.d.ts +15 -0
  214. package/dist/core/types/pageable.js +2 -0
  215. package/dist/core/types/standalone-component.d.ts +9 -0
  216. package/dist/core/types/standalone-component.js +2 -0
  217. package/dist/core/types/status-code.d.ts +319 -0
  218. package/dist/core/types/status-code.js +322 -0
  219. package/dist/core/utils/calculate-components.d.ts +13 -0
  220. package/dist/core/utils/calculate-components.js +40 -0
  221. package/dist/core/utils/color-token-id.d.ts +11 -0
  222. package/dist/core/utils/color-token-id.js +24 -0
  223. package/dist/core/utils/deep-pick.d.ts +2 -0
  224. package/dist/core/utils/deep-pick.js +54 -0
  225. package/dist/core/utils/hex-to-hsl.d.ts +14 -0
  226. package/dist/core/utils/hex-to-hsl.js +49 -0
  227. package/dist/core/utils/incoming-message-observer.d.ts +9 -0
  228. package/dist/core/utils/incoming-message-observer.js +23 -0
  229. package/dist/core/utils/merge-deep.d.ts +8 -0
  230. package/dist/core/utils/merge-deep.js +39 -0
  231. package/dist/core/utils/objects-diff.d.ts +13 -0
  232. package/dist/core/utils/objects-diff.js +56 -0
  233. package/dist/core/utils/parse-context-path.d.ts +4 -0
  234. package/dist/core/utils/parse-context-path.js +16 -0
  235. package/dist/core/utils/replace-context-keys.d.ts +12 -0
  236. package/dist/core/utils/replace-context-keys.js +90 -0
  237. package/dist/core/utils/serialize-component-tree.d.ts +9 -0
  238. package/dist/core/utils/serialize-component-tree.js +24 -0
  239. package/dist/core/utils/set-object-property.d.ts +2 -0
  240. package/dist/core/utils/set-object-property.js +29 -0
  241. package/dist/core/utils/track-created-instances.d.ts +10 -0
  242. package/dist/core/utils/track-created-instances.js +18 -0
  243. package/dist/core/version.d.ts +1 -0
  244. package/dist/core/version.js +21 -0
  245. package/dist/index.d.ts +3 -0
  246. package/dist/index.js +19 -0
  247. package/dist/platforms/android-platform.d.ts +6 -0
  248. package/dist/platforms/android-platform.js +10 -0
  249. package/dist/platforms/browser-platform.d.ts +79 -0
  250. package/dist/platforms/browser-platform.js +143 -0
  251. package/dist/platforms/client-platform.d.ts +6 -0
  252. package/dist/platforms/client-platform.js +10 -0
  253. package/dist/platforms/index.d.ts +12 -0
  254. package/dist/platforms/index.js +28 -0
  255. package/dist/platforms/ios-platform.d.ts +6 -0
  256. package/dist/platforms/ios-platform.js +10 -0
  257. package/dist/platforms/max-mini-app-platform.d.ts +45 -0
  258. package/dist/platforms/max-mini-app-platform.js +87 -0
  259. package/dist/platforms/mobile-platform.d.ts +117 -0
  260. package/dist/platforms/mobile-platform.js +316 -0
  261. package/dist/platforms/platform.d.ts +109 -0
  262. package/dist/platforms/platform.js +224 -0
  263. package/dist/platforms/pwa-platform.d.ts +6 -0
  264. package/dist/platforms/pwa-platform.js +10 -0
  265. package/dist/platforms/server-platform.d.ts +6 -0
  266. package/dist/platforms/server-platform.js +10 -0
  267. package/dist/platforms/telegram-mini-app-platform.d.ts +87 -0
  268. package/dist/platforms/telegram-mini-app-platform.js +166 -0
  269. package/dist/platforms/utils/client-platform.d.ts +4 -0
  270. package/dist/platforms/utils/client-platform.js +38 -0
  271. package/dist/platforms/utils/mobile-ble-services.d.ts +3 -0
  272. package/dist/platforms/utils/mobile-ble-services.js +31 -0
  273. package/dist/platforms/web-platform.d.ts +9 -0
  274. package/dist/platforms/web-platform.js +13 -0
  275. package/package.json +109 -0
@@ -0,0 +1,159 @@
1
+ import { ColorRole } from "@matreshka/shared/enums/color-role";
2
+ import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
3
+ import { TextAlign } from "@matreshka/shared/enums/text-align";
4
+ import { TextDecoration } from "@matreshka/shared/enums/text-decoration";
5
+ import { ComponentCommandMessage } from "@matreshka/shared/messages/bff-to-client/component-command-message";
6
+ import { ColorToken } from "@matreshka/shared/types/color-token";
7
+ import type { FontStackToken } from "@matreshka/shared/types/fonts";
8
+ import type { GridItem } from "@matreshka/shared/types/grid-item";
9
+ import type { ServerComponentConfig } from "@matreshka/shared/types/server-component-config";
10
+ import { Subscription } from "rxjs";
11
+ import { Client, Componentable, ComponentInstance, LocalAction } from "../core";
12
+ import { Condition } from "../core/conditions";
13
+ import { ServerAction, ServerActionHandler } from "./actions/server-action";
14
+ import type { EntryComponent } from "./entry-component";
15
+ /**
16
+ * @prop colors - Цветовые схемы для раскраски
17
+ * @prop font - Stack token для сборки CSS-свойств шрифта
18
+ * @prop scale - масштаб компонента
19
+ * @prop textAlign - горизонтальное выравнивание текста компонента и его потомков
20
+ * @prop textDecoration - оформление текста (подчёркивание, зачёркивание)
21
+ * @prop gridItem - настройки размещения элемента, когда он находится внутри grid
22
+ * @prop link - адрес перехода при клике на компонент
23
+ */
24
+ export type ComponentProperties = {
25
+ colors?: Partial<Record<ColorRole, string>>;
26
+ font?: FontStackToken;
27
+ scale?: number;
28
+ textAlign?: TextAlign;
29
+ textDecoration?: TextDecoration;
30
+ /** Настройки размещения элемента, когда он находится внутри grid. */
31
+ gridItem?: GridItem;
32
+ /** Адрес перехода при клике на компонент. */
33
+ link?: {
34
+ value: string;
35
+ };
36
+ };
37
+ /**
38
+ * Переопределения в {@link ComponentInitConfig.rules}: те же поля, что у свойств
39
+ * компонента, но в `colors` указываются {@link ColorToken} (строковые id клиент получает
40
+ * после сериализации, см. {@link Component#resolveRuleOverridesForClient}).
41
+ */
42
+ export type ComponentRuleOverrides<PropertiesType extends ComponentProperties> = Partial<Omit<PropertiesType, "colors">> & {
43
+ colors?: Partial<Record<ColorRole, ColorToken>>;
44
+ };
45
+ /**
46
+ * @prop onShow - обработчики, которые должны выполниться при инициализации компонента на стороне клиента
47
+ * @prop onHide - обработчики, которые должны выполниться при скрытии компонента на стороне клиента
48
+ * @prop onMouseEnter - обработчики, которые должны выполниться при наведении курсора на компонент
49
+ * @prop onMouseLeave - обработчики, которые должны выполниться при уходе курсора с компонента
50
+ * @prop colors - Цветовые схемы для раскраски
51
+ * @prop font - Stack token для сборки CSS-свойств шрифта
52
+ * @prop scale - масштаб компонента
53
+ * @prop textAlign - горизонтальное выравнивание текста компонента и его потомков
54
+ * @prop textDecoration - оформление текста (подчёркивание, зачёркивание)
55
+ * @prop gridItem - настройки размещения элемента, когда он находится внутри grid
56
+ * @prop link - адрес перехода при клике на компонент
57
+ * @prop conditions - условия, при выполнении которых компонент отобразится на клиенте
58
+ * @prop rules - правила, при выполнении conditions значения из overrides переопределяют свойства компонента
59
+ */
60
+ export type ComponentInitConfig<ComponentType extends Componentable, PropertiesType extends ComponentProperties = ComponentProperties> = {
61
+ link?: {
62
+ value: string;
63
+ };
64
+ onShow?: ServerComponentAction<ComponentType> | ServerComponentAction<ComponentType>[];
65
+ onHide?: ServerComponentAction<ComponentType> | ServerComponentAction<ComponentType>[];
66
+ onMouseEnter?: ServerComponentAction<ComponentType> | ServerComponentAction<ComponentType>[];
67
+ onMouseLeave?: ServerComponentAction<ComponentType> | ServerComponentAction<ComponentType>[];
68
+ colors?: Partial<Record<ColorRole, ColorToken>>;
69
+ font?: FontStackToken;
70
+ scale?: number;
71
+ textAlign?: TextAlign;
72
+ textDecoration?: TextDecoration;
73
+ /** Настройки размещения элемента, когда он находится внутри grid. */
74
+ gridItem?: GridItem;
75
+ conditions?: Condition[] | (() => Condition[]);
76
+ rules?: {
77
+ conditions: [Condition, ...Condition[]];
78
+ overrides: ComponentRuleOverrides<PropertiesType>;
79
+ }[];
80
+ };
81
+ type DefaultInitConfigType = ComponentInitConfig<Component, ComponentProperties>;
82
+ /** Список доступных видов обработчиков, нужен чтобы не копировать в каждый компонент */
83
+ export type ServerComponentAction<ComponentType extends Componentable, PayloadType = unknown> = ServerAction<ComponentType, PayloadType> | ServerActionHandler<ComponentType, PayloadType> | LocalAction;
84
+ export type ServerDestroyAction<ComponentType extends Componentable> = ServerAction<ComponentType, undefined> | ServerActionHandler<ComponentType, undefined>;
85
+ /**
86
+ * @typeParam InitConfigType - Тип конфигурации, используемой в конструкторе компонента
87
+ * @typeParam PropertiesType - Тип свойств компонента
88
+ */
89
+ export declare abstract class Component<InitConfigType extends ComponentInitConfig<any, any> = DefaultInitConfigType, PropertiesType extends ComponentProperties = ComponentProperties> implements Componentable {
90
+ protected config: InitConfigType;
91
+ private instancePrefix;
92
+ /** Информаиця об использовании компонента, при каждой сериализации сохраняется для какого клиента и entry она было выполнена */
93
+ protected instances: ComponentInstance<this>[];
94
+ /** Подписки на disconnect/reconnect/destroy по клиентам (снимаются в {@link notifyReleasedFromClient} и при destroy). */
95
+ protected clientSubscriptions: Map<Client, Subscription>;
96
+ /** Entry, для которых уже подписан destroyInstance$ (до commitSerialization instance.entry ещё пуст). */
97
+ private subscribedEntries;
98
+ /** Идентификатор класса компонента, должен быть уникальным, нужен для поиска компонента в клиентском приложении */
99
+ protected abstract class(): ServerComponentClass;
100
+ /** Уникальный идентификатор компонента */
101
+ readonly id: string;
102
+ /** Свойства компонента, нельзя менять после создания */
103
+ private _properties?;
104
+ /** Виды взаимодействий (событий) и обработчики. Компонент сам определяет список доступных взаимодействий */
105
+ private interactions;
106
+ /** Серверные cleanup-обработчики для окончательного release instance. Не сериализуются на клиент. */
107
+ private destroyHandlers;
108
+ private _destroyInstance$;
109
+ /** Сигнал о том, что инстанс компонента прекращено */
110
+ readonly destroyInstance$: import("rxjs").Observable<ComponentInstance<Componentable>>;
111
+ private _startUsing$;
112
+ /** Сигнал о том, что инстанс компонента началось (появилось первое инстанс) */
113
+ readonly startUsing$: import("rxjs").Observable<void>;
114
+ private _stopUsing$;
115
+ /** Сигнал о том, что инстанс компонента прекращено (завершилось последнее инстанс) */
116
+ readonly stopUsing$: import("rxjs").Observable<void>;
117
+ constructor(config: InitConfigType);
118
+ /** Инициализация свойств, происходит при первом обращении к свойствам */
119
+ protected initProperties(initValues: InitConfigType): PropertiesType;
120
+ /** Свойства компонента, изменение запрещено */
121
+ get properties(): Readonly<PropertiesType>;
122
+ protected colors(): Partial<Record<ColorRole, ColorToken>>;
123
+ /** Массовая установка обработчиков на взаимодействие */
124
+ protected bindActions(event: string, actions: ServerComponentAction<Componentable> | ServerComponentAction<Componentable>[]): void;
125
+ /** Массовая установка внутренних server-only cleanup-обработчиков release stage. */
126
+ protected bindDestroyActions(actions: ServerDestroyAction<Componentable> | ServerDestroyAction<Componentable>[]): void;
127
+ /** Рассылка сообщения всем подписанным клиентам данного компонента */
128
+ protected broadcast(message: ComponentCommandMessage): void;
129
+ /** Обработка взаимодействия */
130
+ protected emitInteraction(type: string, payload: unknown, instance: ComponentInstance<this>): void;
131
+ /** Выполняет server-only cleanup перед окончательным release instance. */
132
+ protected emitOnDestroy(instance: ComponentInstance<this>): void;
133
+ /** Добавление обработчика на взаимодействие */
134
+ protected onInteraction<PayloadType>(type: string, callback: ServerComponentAction<Componentable, PayloadType>): this;
135
+ protected usingByClient(client: Client): boolean;
136
+ protected usingByEntry(entry: EntryComponent): boolean;
137
+ protected serializeRuleOverrides(overrides: Record<string, unknown>): Record<string, unknown>;
138
+ protected resolveRuleOverridesForClient(overrides: ComponentRuleOverrides<PropertiesType>): Partial<PropertiesType>;
139
+ /** Проверяет, содержит ли компонент хотя бы один серверный обработчик. В этом случае нужно подписываться на входящие сообщения от клиента */
140
+ private hasServerAction;
141
+ getInstances(filter?: {
142
+ client?: Client;
143
+ entry?: Componentable;
144
+ }): ComponentInstance<this>[];
145
+ createInstance(): ComponentInstance<this>;
146
+ /** Instance entry без подписки на события entry — для корневой serialize EntryComponent. */
147
+ protected createSelfEntry(): ComponentInstance<this>;
148
+ protected currentIdForSerialization(): string;
149
+ /** Сериализация компонента перед отправкой клиенту. Использование передается в случае когда не нужно создавать новое инстанс компонента */
150
+ serialize(instance?: ComponentInstance<this>): ServerComponentConfig;
151
+ /** Новый клиент, за которым нужно наблюдать */
152
+ protected subscribeClientEvents(client: Client): void;
153
+ private subscribeEntryEvents;
154
+ private parseAction;
155
+ private parseDestroyAction;
156
+ releaseInstances(instances: ComponentInstance[]): void;
157
+ private teardownClient;
158
+ }
159
+ export {};
@@ -0,0 +1,380 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Component = void 0;
37
+ const shared_1 = require("@matreshka/shared");
38
+ const component_interaction_message_1 = require("@matreshka/shared/messages/client-to-bff/components/component-interaction-message");
39
+ const crypto = __importStar(require("node:crypto"));
40
+ const rxjs_1 = require("rxjs");
41
+ const core_1 = require("../core");
42
+ const incoming_message_observer_1 = require("../core/utils/incoming-message-observer");
43
+ const track_created_instances_1 = require("../core/utils/track-created-instances");
44
+ const server_action_1 = require("./actions/server-action");
45
+ function resolvePartialColorsToIds(colors) {
46
+ return Object.entries(colors).reduce((acc, [role, value]) => {
47
+ acc[role] = (0, core_1.colorTokenId)(value);
48
+ return acc;
49
+ }, {});
50
+ }
51
+ /**
52
+ * @typeParam InitConfigType - Тип конфигурации, используемой в конструкторе компонента
53
+ * @typeParam PropertiesType - Тип свойств компонента
54
+ */
55
+ class Component {
56
+ constructor(config) {
57
+ this.config = config;
58
+ // Счетчик использований, используется для формирования id использования
59
+ this.instancePrefix = 0;
60
+ /** Информаиця об использовании компонента, при каждой сериализации сохраняется для какого клиента и entry она было выполнена */
61
+ this.instances = [];
62
+ /** Подписки на disconnect/reconnect/destroy по клиентам (снимаются в {@link notifyReleasedFromClient} и при destroy). */
63
+ this.clientSubscriptions = new Map();
64
+ /** Entry, для которых уже подписан destroyInstance$ (до commitSerialization instance.entry ещё пуст). */
65
+ this.subscribedEntries = new WeakSet();
66
+ /** Виды взаимодействий (событий) и обработчики. Компонент сам определяет список доступных взаимодействий */
67
+ this.interactions = new Map();
68
+ /** Серверные cleanup-обработчики для окончательного release instance. Не сериализуются на клиент. */
69
+ this.destroyHandlers = [];
70
+ this._destroyInstance$ = new rxjs_1.Subject();
71
+ /** Сигнал о том, что инстанс компонента прекращено */
72
+ this.destroyInstance$ = this._destroyInstance$.asObservable();
73
+ this._startUsing$ = new rxjs_1.Subject();
74
+ /** Сигнал о том, что инстанс компонента началось (появилось первое инстанс) */
75
+ this.startUsing$ = this._startUsing$.asObservable();
76
+ this._stopUsing$ = new rxjs_1.Subject();
77
+ /** Сигнал о том, что инстанс компонента прекращено (завершилось последнее инстанс) */
78
+ this.stopUsing$ = this._stopUsing$.asObservable();
79
+ this.id = crypto.randomUUID();
80
+ if (config.onShow) {
81
+ this.bindActions("show", config.onShow);
82
+ }
83
+ if (config.onHide) {
84
+ this.bindActions("hide", config.onHide);
85
+ }
86
+ if (config.onMouseEnter) {
87
+ this.bindActions("mouseenter", config.onMouseEnter);
88
+ }
89
+ if (config.onMouseLeave) {
90
+ this.bindActions("mouseleave", config.onMouseLeave);
91
+ }
92
+ }
93
+ /** Инициализация свойств, происходит при первом обращении к свойствам */
94
+ initProperties(initValues) {
95
+ const colorSources = { ...this.colors(), ...initValues.colors };
96
+ const colors = Object.keys(colorSources).length > 0
97
+ ? resolvePartialColorsToIds(colorSources)
98
+ : undefined;
99
+ // @ts-expect-error properties are validated elsewhere; unsafe cast is intentional
100
+ return {
101
+ font: initValues.font,
102
+ scale: initValues.scale,
103
+ textAlign: initValues.textAlign,
104
+ textDecoration: initValues.textDecoration,
105
+ gridItem: initValues.gridItem,
106
+ link: initValues.link,
107
+ colors,
108
+ };
109
+ }
110
+ /** Свойства компонента, изменение запрещено */
111
+ get properties() {
112
+ if (!this._properties) {
113
+ this._properties = this.initProperties(this.config);
114
+ }
115
+ return this._properties;
116
+ }
117
+ colors() {
118
+ return {};
119
+ }
120
+ /** Массовая установка обработчиков на взаимодействие */
121
+ bindActions(event, actions) {
122
+ (Array.isArray(actions) ? actions : [actions]).map((action) => {
123
+ this.onInteraction(event, action);
124
+ });
125
+ }
126
+ /** Массовая установка внутренних server-only cleanup-обработчиков release stage. */
127
+ bindDestroyActions(actions) {
128
+ (Array.isArray(actions) ? actions : [actions]).forEach((action) => {
129
+ this.destroyHandlers.push(this.parseDestroyAction(action));
130
+ });
131
+ }
132
+ /** Рассылка сообщения всем подписанным клиентам данного компонента */
133
+ broadcast(message) {
134
+ new Set(this.instances
135
+ .map((x) => x.client)
136
+ .filter((client) => !!client)).forEach((client) => {
137
+ client.outcomingMessage$.next(message);
138
+ });
139
+ }
140
+ /** Обработка взаимодействия */
141
+ emitInteraction(type, payload, instance) {
142
+ const client = (0, core_1.currentClient)();
143
+ this.interactions.get(type)?.forEach((handler) => {
144
+ if (handler instanceof server_action_1.ServerAction && handler.canExecute(client)) {
145
+ handler.execute({
146
+ instance,
147
+ payload,
148
+ });
149
+ }
150
+ });
151
+ }
152
+ /** Выполняет server-only cleanup перед окончательным release instance. */
153
+ emitOnDestroy(instance) {
154
+ if (this.destroyHandlers.length === 0) {
155
+ return;
156
+ }
157
+ const client = instance.client;
158
+ if (!client) {
159
+ return;
160
+ }
161
+ (0, core_1.runWithClient)(client, () => {
162
+ this.destroyHandlers.forEach((handler) => {
163
+ if (handler.canExecute(client)) {
164
+ handler.execute({
165
+ instance,
166
+ payload: undefined,
167
+ });
168
+ }
169
+ });
170
+ });
171
+ }
172
+ /** Добавление обработчика на взаимодействие */
173
+ onInteraction(type, callback) {
174
+ const value = this.interactions.get(type) || [];
175
+ value.push(this.parseAction(callback));
176
+ this.interactions.set(type, value);
177
+ return this;
178
+ }
179
+ usingByClient(client) {
180
+ return this.clientSubscriptions.has(client);
181
+ }
182
+ usingByEntry(entry) {
183
+ return (this.subscribedEntries.has(entry) ||
184
+ this.instances.some((x) => x.entry?.component === entry));
185
+ }
186
+ serializeRuleOverrides(overrides) {
187
+ return overrides;
188
+ }
189
+ resolveRuleOverridesForClient(overrides) {
190
+ if (overrides.colors === undefined) {
191
+ return overrides;
192
+ }
193
+ const colors = resolvePartialColorsToIds(overrides.colors);
194
+ return {
195
+ ...overrides,
196
+ colors: Object.keys(colors).length > 0 ? colors : undefined,
197
+ };
198
+ }
199
+ /** Проверяет, содержит ли компонент хотя бы один серверный обработчик. В этом случае нужно подписываться на входящие сообщения от клиента */
200
+ hasServerAction() {
201
+ for (const eventInteractions of this.interactions.entries()) {
202
+ if (eventInteractions[1].some((x) => x instanceof server_action_1.ServerAction)) {
203
+ return true;
204
+ }
205
+ }
206
+ return false;
207
+ }
208
+ getInstances(filter) {
209
+ let res = this.instances;
210
+ if (filter) {
211
+ if (filter.client) {
212
+ res = res.filter((x) => x.client === filter.client);
213
+ }
214
+ if (filter.entry) {
215
+ res = res.filter((x) => x.entry?.component === filter.entry);
216
+ }
217
+ }
218
+ return res;
219
+ }
220
+ createInstance() {
221
+ const id = this.currentIdForSerialization();
222
+ this.instancePrefix++;
223
+ const client = (0, core_1.currentClient)();
224
+ const entry = (0, core_1.tryCurrentEntry)();
225
+ const entryComponent = entry?.component;
226
+ // Снятие instances при уничтожении entry нужно всем компонентам, не только с server-action.
227
+ const isEntrySerializingItself = entryComponent !== undefined &&
228
+ entryComponent === this;
229
+ if (entryComponent &&
230
+ !this.usingByEntry(entryComponent) &&
231
+ !isEntrySerializingItself) {
232
+ this.subscribeEntryEvents(entryComponent);
233
+ }
234
+ if (this.hasServerAction() && !this.usingByClient(client)) {
235
+ this.subscribeClientEvents(client);
236
+ }
237
+ const instance = new core_1.ComponentInstance(id, this);
238
+ this.instances.push(instance);
239
+ (0, track_created_instances_1.trackCreatedInstance)(instance);
240
+ return instance;
241
+ }
242
+ /** Instance entry без подписки на события entry — для корневой serialize EntryComponent. */
243
+ createSelfEntry() {
244
+ const id = this.currentIdForSerialization();
245
+ this.instancePrefix++;
246
+ const client = (0, core_1.currentClient)();
247
+ if (this.hasServerAction() && !this.usingByClient(client)) {
248
+ this.subscribeClientEvents(client);
249
+ }
250
+ const instance = new core_1.ComponentInstance(id, this);
251
+ this.instances.push(instance);
252
+ (0, track_created_instances_1.trackCreatedInstance)(instance);
253
+ return instance;
254
+ }
255
+ currentIdForSerialization() {
256
+ return `${this.id}-${this.instancePrefix}`;
257
+ }
258
+ /** Сериализация компонента перед отправкой клиенту. Использование передается в случае когда не нужно создавать новое инстанс компонента */
259
+ serialize(instance) {
260
+ if (instance?.serialized) {
261
+ throw new Error("Instance already serialized. Create new instance instead.");
262
+ }
263
+ if (!instance) {
264
+ instance = this.createInstance();
265
+ }
266
+ if (this.instances.length === 1) {
267
+ this._startUsing$.next();
268
+ }
269
+ const interactions = {};
270
+ this.interactions.forEach((eventInteractions, key) => {
271
+ interactions[key] = [];
272
+ eventInteractions.forEach((eventInteraction) => {
273
+ interactions[key].push(eventInteraction.toJSON());
274
+ });
275
+ });
276
+ /** Условия, при выполнении которых компонент отобразится на клиенте */
277
+ let conditions;
278
+ if (this.config.conditions) {
279
+ conditions = Array.isArray(this.config.conditions)
280
+ ? this.config.conditions
281
+ : this.config.conditions();
282
+ }
283
+ else {
284
+ conditions = [];
285
+ }
286
+ const properties = this.properties;
287
+ const rules = this.config.rules?.map(({ conditions, overrides }) => ({
288
+ conditions: conditions.map((condition) => condition.toJSON()),
289
+ overrides: this.resolveRuleOverridesForClient(overrides),
290
+ })) ?? [];
291
+ const hasProperties = properties && Object.keys(properties).length > 0;
292
+ const hasInteractions = Object.keys(interactions).length > 0;
293
+ const hasConditions = conditions.length > 0;
294
+ const hasRules = rules.length > 0;
295
+ const result = {
296
+ id: instance.id,
297
+ class: this.class(),
298
+ };
299
+ if (hasConditions) {
300
+ result.conditions = conditions.map((condition) => condition.toJSON());
301
+ }
302
+ if (hasInteractions) {
303
+ result.interactions = interactions;
304
+ }
305
+ if (hasProperties) {
306
+ result.properties = properties;
307
+ }
308
+ if (hasRules) {
309
+ result.rules = rules.map((rule) => ({
310
+ ...rule,
311
+ overrides: this.serializeRuleOverrides(rule.overrides),
312
+ }));
313
+ }
314
+ instance.commitSerialization();
315
+ return result;
316
+ }
317
+ /** Новый клиент, за которым нужно наблюдать */
318
+ subscribeClientEvents(client) {
319
+ const sub = new rxjs_1.Subscription();
320
+ sub.add(client.destroy$.subscribe(() => {
321
+ this.teardownClient(client);
322
+ }));
323
+ sub.add(client.incomingMessage$
324
+ .pipe((0, rxjs_1.filter)((message) => message instanceof component_interaction_message_1.ComponentInteractionMessage), (0, rxjs_1.filter)((message) => (0, shared_1.componentBaseId)(message.scope) === this.id))
325
+ .subscribe((0, incoming_message_observer_1.incomingMessageObserver)(client, (message) => {
326
+ const instance = this.instances.find((x) => x.id === message.scope);
327
+ if (!instance) {
328
+ client.error$.next("Component interaction call, component instance not found");
329
+ return;
330
+ }
331
+ if (instance.client !== client) {
332
+ client.error$.next("Component interaction call, component are not using for this client");
333
+ return;
334
+ }
335
+ this.emitInteraction(message.eventType, message.payload, instance);
336
+ })));
337
+ this.clientSubscriptions.set(client, sub);
338
+ }
339
+ subscribeEntryEvents(entry) {
340
+ this.subscribedEntries.add(entry);
341
+ entry.destroyInstance$.subscribe((releasedEntry) => {
342
+ this.releaseInstances(this.instances.filter((x) => x.entry === releasedEntry));
343
+ });
344
+ }
345
+ parseAction(action) {
346
+ if (action instanceof core_1.Action) {
347
+ return action;
348
+ }
349
+ return new server_action_1.ServerAction(action);
350
+ }
351
+ parseDestroyAction(action) {
352
+ if (action instanceof server_action_1.ServerAction) {
353
+ return action;
354
+ }
355
+ if (action instanceof core_1.Action) {
356
+ throw new Error("onDestroy supports only server actions and does not allow LocalAction");
357
+ }
358
+ return new server_action_1.ServerAction(action);
359
+ }
360
+ /* @internal */
361
+ releaseInstances(instances) {
362
+ const activeInstances = instances.filter((instance) => this.instances.includes(instance));
363
+ if (activeInstances.length === 0) {
364
+ return;
365
+ }
366
+ const hadInstances = this.instances.length > 0;
367
+ activeInstances.forEach((instance) => this.emitOnDestroy(instance));
368
+ this.instances = this.instances.filter((x) => !activeInstances.includes(x));
369
+ activeInstances.forEach((u) => this._destroyInstance$.next(u)); // Сообщение другим, что инстанс компонента прекращено
370
+ if (hadInstances && this.instances.length === 0) {
371
+ this._stopUsing$.next();
372
+ }
373
+ }
374
+ teardownClient(client) {
375
+ this.clientSubscriptions.get(client)?.unsubscribe();
376
+ this.clientSubscriptions.delete(client);
377
+ this.releaseInstances(this.instances.filter((x) => x.client === client));
378
+ }
379
+ }
380
+ exports.Component = Component;
@@ -0,0 +1,48 @@
1
+ import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
2
+ import type { ContainerConfig } from "@matreshka/shared/types/container-config";
3
+ import { Componentable, ComponentTreeNode, MixedWithCallbacksArray, StandaloneComponent } from "../core";
4
+ import { Component, ComponentInitConfig, ComponentProperties } from "./component";
5
+ export type ContainerProperties = {
6
+ content: ComponentTreeNode[];
7
+ } & ComponentProperties;
8
+ /**
9
+ * Конфигурация инициализации для компонента Container.
10
+ *
11
+ * @template T Тип вложенных компонентов.
12
+ * @property content Массив вложенных компонентов.
13
+ */
14
+ export type ContainerInitConfig<ContentType extends ComponentTreeNode = ComponentTreeNode, ComponentType extends Componentable = Container, PropertiesType extends ContainerProperties = ContainerProperties> = {
15
+ content: MixedWithCallbacksArray<ContentType>;
16
+ } & ComponentInitConfig<ComponentType, PropertiesType>;
17
+ type DefaultInitConfigType<ContentType extends ComponentTreeNode = ComponentTreeNode> = ContainerInitConfig<ContentType, Container>;
18
+ export declare function container<ContentType extends ComponentTreeNode = ComponentTreeNode>(content: DefaultInitConfigType<ContentType>["content"]): Container<ContentType>;
19
+ export declare function container<ContentType extends ComponentTreeNode = ComponentTreeNode>(options: Omit<DefaultInitConfigType<ContentType>, "content">, content: DefaultInitConfigType<ContentType>["content"]): Container<ContentType>;
20
+ export declare function container<ContentType extends ComponentTreeNode = ComponentTreeNode>(config: DefaultInitConfigType<ContentType>): Container<ContentType>;
21
+ /**
22
+ * Компонент-контейнер, содержащий массив вложенных компонентов.
23
+ * Используется для обобщения логики отображения компонент (условий, палитры), чтобы не писать одинаковый код для каждого компонента.
24
+ *
25
+ * @template T Тип вложенных узлов дерева ({@link ComponentTreeNode}).
26
+ */
27
+ export declare class Container<ContentType extends ComponentTreeNode = ComponentTreeNode, InitConfigType extends ContainerInitConfig<ContentType, any> = DefaultInitConfigType<ContentType>, PropertiesType extends ContainerProperties = ContainerProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent {
28
+ /**
29
+ * Возвращает уникальный идентификатор класса компонента.
30
+ * @returns Строка `"container"`.
31
+ */
32
+ protected class(): ServerComponentClass;
33
+ /**
34
+ * Возвращает флаг, указывающий, что компонент является самостоятельным.
35
+ * @returns Всегда true.
36
+ */
37
+ standalone(): true;
38
+ /**
39
+ * Инициализирует свойства компонента на основе переданных значений.
40
+ *
41
+ * @param initValues Конфигурация инициализации.
42
+ * @returns Объект с инициализированными свойствами.
43
+ */
44
+ protected initProperties(initValues: InitConfigType): PropertiesType;
45
+ protected serializeRuleOverrides(overrides: Partial<PropertiesType>): Record<string, unknown>;
46
+ serialize(): ContainerConfig;
47
+ }
48
+ export {};
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Container = void 0;
4
+ exports.container = container;
5
+ const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
6
+ const core_1 = require("../core");
7
+ const component_1 = require("./component");
8
+ function container(arg0, arg1) {
9
+ if (arg1 !== undefined) {
10
+ return new Container({
11
+ ...arg0,
12
+ content: arg1,
13
+ });
14
+ }
15
+ const single = arg0;
16
+ if (typeof single === "object" &&
17
+ single !== null &&
18
+ !Array.isArray(single) &&
19
+ "content" in single) {
20
+ return new Container(single);
21
+ }
22
+ return new Container({
23
+ content: single,
24
+ });
25
+ }
26
+ /**
27
+ * Компонент-контейнер, содержащий массив вложенных компонентов.
28
+ * Используется для обобщения логики отображения компонент (условий, палитры), чтобы не писать одинаковый код для каждого компонента.
29
+ *
30
+ * @template T Тип вложенных узлов дерева ({@link ComponentTreeNode}).
31
+ */
32
+ class Container extends component_1.Component {
33
+ /**
34
+ * Возвращает уникальный идентификатор класса компонента.
35
+ * @returns Строка `"container"`.
36
+ */
37
+ class() {
38
+ return server_component_class_1.ServerComponentClass.Container;
39
+ }
40
+ /**
41
+ * Возвращает флаг, указывающий, что компонент является самостоятельным.
42
+ * @returns Всегда true.
43
+ */
44
+ standalone() {
45
+ return true;
46
+ }
47
+ /**
48
+ * Инициализирует свойства компонента на основе переданных значений.
49
+ *
50
+ * @param initValues Конфигурация инициализации.
51
+ * @returns Объект с инициализированными свойствами.
52
+ */
53
+ initProperties(initValues) {
54
+ return {
55
+ ...super.initProperties(initValues),
56
+ content: (0, core_1.calculateComponents)(initValues.content),
57
+ };
58
+ }
59
+ serializeRuleOverrides(overrides) {
60
+ return {
61
+ ...overrides,
62
+ content: overrides.content
63
+ ? (0, core_1.serializeComponentList)(overrides.content)
64
+ : undefined,
65
+ };
66
+ }
67
+ serialize() {
68
+ const result = super.serialize();
69
+ const p = this.properties;
70
+ return {
71
+ ...result,
72
+ class: server_component_class_1.ServerComponentClass.Container,
73
+ properties: {
74
+ ...p,
75
+ content: (0, core_1.serializeComponentList)(p.content),
76
+ },
77
+ };
78
+ }
79
+ }
80
+ exports.Container = Container;