@matreshka/bff 0.11.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/components/component.js +2 -8
- package/dist/components/for-each.d.ts +0 -4
- package/dist/components/inputs/input-component.d.ts +8 -3
- package/dist/components/inputs/number-input.d.ts +10 -8
- package/dist/components/inputs/password-input.d.ts +8 -8
- package/dist/components/inputs/text-editor.d.ts +8 -8
- package/dist/components/inputs/text-input.d.ts +8 -8
- package/dist/components/inputs/textarea.d.ts +8 -8
- package/dist/components/outputs/currency.d.ts +8 -8
- package/dist/components/outputs/datetime.d.ts +9 -9
- package/dist/components/outputs/icon.d.ts +8 -8
- package/dist/components/outputs/iframe.d.ts +9 -9
- package/dist/components/outputs/image.d.ts +9 -9
- package/dist/components/outputs/number.d.ts +9 -9
- package/dist/components/outputs/output-component.d.ts +10 -5
- package/dist/components/outputs/progress-bar.d.ts +9 -9
- package/dist/components/outputs/progress-spinner.d.ts +9 -9
- package/dist/components/outputs/qr-code.d.ts +9 -9
- package/dist/components/outputs/text.d.ts +9 -9
- package/dist/components/outputs/vector.d.ts +9 -9
- package/dist/components/types/component-sequence.d.ts +3 -3
- package/dist/core/actions/set-context-value.d.ts +7 -4
- package/dist/core/actions/set-context-value.js +2 -0
- package/dist/core/actions/set-context-values.d.ts +4 -3
- package/dist/core/actions/toggle-context-value.d.ts +5 -7
- package/dist/core/client-storage.d.ts +28 -0
- package/dist/core/client-storage.js +45 -0
- package/dist/core/client.d.ts +5 -0
- package/dist/core/client.js +9 -10
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +4 -0
- package/dist/core/matreshka.js +2 -5
- package/dist/core/types/client-settings.d.ts +9 -2
- package/dist/core/types/context-value-ref.d.ts +31 -0
- package/dist/core/types/context-value-ref.js +2 -0
- package/dist/core/types/native-picker-context-ref.d.ts +3 -2
- package/dist/core/utils/color-roles-to-ids.d.ts +3 -0
- package/dist/core/utils/color-roles-to-ids.js +10 -0
- package/dist/core/utils/serialize-client-settings-colors-for-handshake.d.ts +8 -0
- package/dist/core/utils/serialize-client-settings-colors-for-handshake.js +15 -0
- package/dist/platforms/platform.d.ts +5 -5
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
|
-
import { Componentable,
|
|
3
|
-
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
2
|
+
import { Componentable, StandaloneComponent } from "../../core";
|
|
3
|
+
import { CompatibleOutputRef, NumberOutputContextRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
4
4
|
/**
|
|
5
5
|
* Свойства компонента полоски прогресса.
|
|
6
6
|
*/
|
|
@@ -8,18 +8,18 @@ export type ProgressBarProperties = {} & OutputProperties;
|
|
|
8
8
|
/**
|
|
9
9
|
* Конфигурация инициализации компонента полоски прогресса.
|
|
10
10
|
*/
|
|
11
|
-
export type ProgressBarInitConfig<ComponentType extends Componentable = ProgressBar, RefType extends
|
|
12
|
-
type DefaultInitConfigType<RefType extends
|
|
13
|
-
type ProgressBarValueOrRef<RefType extends
|
|
14
|
-
export declare function progressBar<RefType extends
|
|
15
|
-
export declare function progressBar<RefType extends
|
|
16
|
-
export declare function progressBar<RefType extends
|
|
11
|
+
export type ProgressBarInitConfig<ComponentType extends Componentable = ProgressBar, RefType extends NumberOutputContextRef = NumberOutputContextRef, PropertiesType extends ProgressBarProperties = ProgressBarProperties> = {} & OutputInitConfig<number, ComponentType, RefType, PropertiesType>;
|
|
12
|
+
type DefaultInitConfigType<RefType extends NumberOutputContextRef> = ProgressBarInitConfig<ProgressBar, RefType>;
|
|
13
|
+
type ProgressBarValueOrRef<RefType extends NumberOutputContextRef> = number | CompatibleOutputRef<number, RefType>;
|
|
14
|
+
export declare function progressBar<RefType extends NumberOutputContextRef = NumberOutputContextRef>(options: Omit<DefaultInitConfigType<RefType>, "value" | "ref">, valueOrRef: ProgressBarValueOrRef<RefType>): ProgressBar<RefType>;
|
|
15
|
+
export declare function progressBar<RefType extends NumberOutputContextRef = NumberOutputContextRef>(valueOrRef: ProgressBarValueOrRef<RefType>): ProgressBar<RefType>;
|
|
16
|
+
export declare function progressBar<RefType extends NumberOutputContextRef = NumberOutputContextRef>(config: ProgressBarInitConfig<ProgressBar, RefType>): ProgressBar<RefType>;
|
|
17
17
|
/**
|
|
18
18
|
* Компонент для вывода полоски прогресса.
|
|
19
19
|
* @experimental TODO: Требуется доработка отображения в overlay.
|
|
20
20
|
* Наследуется от {@link OutputComponent}.
|
|
21
21
|
*/
|
|
22
|
-
export declare class ProgressBar<RefType extends
|
|
22
|
+
export declare class ProgressBar<RefType extends NumberOutputContextRef = NumberOutputContextRef, PropertiesType extends ProgressBarProperties = ProgressBarProperties> extends OutputComponent<DefaultInitConfigType<RefType>, PropertiesType> implements StandaloneComponent {
|
|
23
23
|
constructor(config: DefaultInitConfigType<RefType>);
|
|
24
24
|
protected class(): ServerComponentClass;
|
|
25
25
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
|
-
import { Componentable,
|
|
3
|
-
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
2
|
+
import { Componentable, StandaloneComponent } from "../../core";
|
|
3
|
+
import { CompatibleOutputRef, NumberOutputContextRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
4
4
|
/**
|
|
5
5
|
* Свойства компонента вывода прогресса.
|
|
6
6
|
*/
|
|
@@ -10,20 +10,20 @@ export type ProgressSpinnerProperties = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Конфигурация инициализации компонента вывода числа.
|
|
12
12
|
*/
|
|
13
|
-
export type ProgressSpinnerInitConfig<ComponentType extends Componentable = ProgressSpinner, RefType extends
|
|
13
|
+
export type ProgressSpinnerInitConfig<ComponentType extends Componentable = ProgressSpinner, RefType extends NumberOutputContextRef = NumberOutputContextRef, PropertiesType extends ProgressSpinnerProperties = ProgressSpinnerProperties> = {
|
|
14
14
|
background?: boolean;
|
|
15
15
|
} & OutputInitConfig<number, ComponentType, RefType, PropertiesType>;
|
|
16
|
-
type DefaultInitConfigType<RefType extends
|
|
17
|
-
type SpinnerValueOrRef<RefType extends
|
|
18
|
-
export declare function progressSpinner<RefType extends
|
|
19
|
-
export declare function progressSpinner<RefType extends
|
|
20
|
-
export declare function progressSpinner<RefType extends
|
|
16
|
+
type DefaultInitConfigType<RefType extends NumberOutputContextRef> = ProgressSpinnerInitConfig<ProgressSpinner, RefType>;
|
|
17
|
+
type SpinnerValueOrRef<RefType extends NumberOutputContextRef> = number | CompatibleOutputRef<number, RefType>;
|
|
18
|
+
export declare function progressSpinner<RefType extends NumberOutputContextRef = NumberOutputContextRef>(options: Omit<DefaultInitConfigType<RefType>, "value" | "ref">, valueOrRef: SpinnerValueOrRef<RefType>): ProgressSpinner<RefType>;
|
|
19
|
+
export declare function progressSpinner<RefType extends NumberOutputContextRef = NumberOutputContextRef>(valueOrRef: SpinnerValueOrRef<RefType>): ProgressSpinner<RefType>;
|
|
20
|
+
export declare function progressSpinner<RefType extends NumberOutputContextRef = NumberOutputContextRef>(config: ProgressSpinnerInitConfig<ProgressSpinner, RefType>): ProgressSpinner<RefType>;
|
|
21
21
|
/**
|
|
22
22
|
* Компонент для вывода прогресса.
|
|
23
23
|
* @experimental TODO: Требуется доработка отображения в overlay.
|
|
24
24
|
* Наследуется от {@link OutputComponent}.
|
|
25
25
|
*/
|
|
26
|
-
export declare class ProgressSpinner<RefType extends
|
|
26
|
+
export declare class ProgressSpinner<RefType extends NumberOutputContextRef = NumberOutputContextRef, PropertiesType extends ProgressSpinnerProperties = ProgressSpinnerProperties> extends OutputComponent<DefaultInitConfigType<RefType>, PropertiesType> implements StandaloneComponent {
|
|
27
27
|
constructor(config: DefaultInitConfigType<RefType>);
|
|
28
28
|
protected class(): ServerComponentClass;
|
|
29
29
|
/**
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
|
-
import { Componentable
|
|
3
|
-
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
2
|
+
import { Componentable } from "../../core";
|
|
3
|
+
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties, StringOutputContextRef } from "./output-component";
|
|
4
4
|
export type QrCodeProperties = {} & OutputProperties;
|
|
5
5
|
/**
|
|
6
6
|
* Конфигурация инициализации компонента QR-кода.
|
|
7
7
|
*/
|
|
8
|
-
export type QrCodeInitConfig<ComponentType extends Componentable = QrCode, RefType extends
|
|
9
|
-
type DefaultInitConfigType<RefType extends
|
|
10
|
-
type QrValueOrRef<RefType extends
|
|
11
|
-
export declare function qrCode<RefType extends
|
|
12
|
-
export declare function qrCode<RefType extends
|
|
13
|
-
export declare function qrCode<RefType extends
|
|
8
|
+
export type QrCodeInitConfig<ComponentType extends Componentable = QrCode, RefType extends StringOutputContextRef = StringOutputContextRef, PropertiesType extends QrCodeProperties = QrCodeProperties> = {} & OutputInitConfig<string, ComponentType, RefType, PropertiesType>;
|
|
9
|
+
type DefaultInitConfigType<RefType extends StringOutputContextRef> = QrCodeInitConfig<QrCode, RefType>;
|
|
10
|
+
type QrValueOrRef<RefType extends StringOutputContextRef> = string | CompatibleOutputRef<string, RefType>;
|
|
11
|
+
export declare function qrCode<RefType extends StringOutputContextRef = StringOutputContextRef>(options: Omit<DefaultInitConfigType<RefType>, "value" | "ref">, valueOrRef: QrValueOrRef<RefType>): QrCode<RefType>;
|
|
12
|
+
export declare function qrCode<RefType extends StringOutputContextRef = StringOutputContextRef>(valueOrRef: QrValueOrRef<RefType>): QrCode<RefType>;
|
|
13
|
+
export declare function qrCode<RefType extends StringOutputContextRef = StringOutputContextRef>(config: QrCodeInitConfig<QrCode, RefType>): QrCode<RefType>;
|
|
14
14
|
/**
|
|
15
15
|
* Компонент для отображения QR-кода.
|
|
16
16
|
*/
|
|
17
|
-
export declare class QrCode<RefType extends
|
|
17
|
+
export declare class QrCode<RefType extends StringOutputContextRef = StringOutputContextRef, PropertiesType extends QrCodeProperties = QrCodeProperties> extends OutputComponent<DefaultInitConfigType<RefType>, PropertiesType> {
|
|
18
18
|
constructor(config: DefaultInitConfigType<RefType>);
|
|
19
19
|
protected class(): ServerComponentClass;
|
|
20
20
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
2
|
import type { TextOutputProcessorAutolinkConfig, TextOutputProcessorConfig, TextOutputProcessorLineBreaksConfig } from "@matreshka/shared/types/text-output-processor-config";
|
|
3
|
-
import { Componentable,
|
|
4
|
-
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
3
|
+
import { Componentable, StandaloneComponent } from "../../core";
|
|
4
|
+
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties, StringOutputContextRef } from "./output-component";
|
|
5
5
|
export { TextOutputAutolinkScheme } from "@matreshka/shared/enums/text-output-autolink-scheme";
|
|
6
6
|
export { TextOutputAutolinkTarget } from "@matreshka/shared/enums/text-output-autolink-target";
|
|
7
7
|
export { TextOutputProcessor } from "@matreshka/shared/enums/text-output-processor";
|
|
@@ -20,26 +20,26 @@ export type TextProperties = {
|
|
|
20
20
|
* Конфигурация инициализации компонента вывода текста.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export type TextInitConfig<ComponentType extends Componentable = Text, RefType extends
|
|
23
|
+
export type TextInitConfig<ComponentType extends Componentable = Text, RefType extends StringOutputContextRef = StringOutputContextRef, PropertiesType extends TextProperties = TextProperties> = {
|
|
24
24
|
/**
|
|
25
25
|
* Максимальное количество строк, которое может занимать текст.
|
|
26
26
|
*/
|
|
27
27
|
maxLines?: number;
|
|
28
28
|
processors?: TextOutputProcessorConfig[];
|
|
29
29
|
} & OutputInitConfig<string, ComponentType, RefType, PropertiesType>;
|
|
30
|
-
type DefaultInitConfigType<RefType extends
|
|
31
|
-
type TextValueOrRef<RefType extends
|
|
30
|
+
type DefaultInitConfigType<RefType extends StringOutputContextRef> = TextInitConfig<Text, RefType>;
|
|
31
|
+
type TextValueOrRef<RefType extends StringOutputContextRef> = string | CompatibleOutputRef<string, RefType>;
|
|
32
32
|
export declare function lineBreaks(): TextOutputProcessorLineBreaksConfig;
|
|
33
33
|
export declare function autolink(options?: Omit<TextOutputProcessorAutolinkConfig, "processor">): TextOutputProcessorAutolinkConfig;
|
|
34
|
-
export declare function text<RefType extends
|
|
35
|
-
export declare function text<RefType extends
|
|
36
|
-
export declare function text<RefType extends
|
|
34
|
+
export declare function text<RefType extends StringOutputContextRef = StringOutputContextRef>(options: Omit<DefaultInitConfigType<RefType>, "value" | "ref">, valueOrRef: TextValueOrRef<RefType>): Text<RefType>;
|
|
35
|
+
export declare function text<RefType extends StringOutputContextRef = StringOutputContextRef>(valueOrRef: TextValueOrRef<RefType>): Text<RefType>;
|
|
36
|
+
export declare function text<RefType extends StringOutputContextRef = StringOutputContextRef>(config: TextInitConfig<Text, RefType>): Text<RefType>;
|
|
37
37
|
/**
|
|
38
38
|
* Компонент для вывода текста.
|
|
39
39
|
*
|
|
40
40
|
* Наследуется от {@link OutputComponent}.
|
|
41
41
|
*/
|
|
42
|
-
export declare class Text<RefType extends
|
|
42
|
+
export declare class Text<RefType extends StringOutputContextRef = StringOutputContextRef, PropertiesType extends TextProperties = TextProperties> extends OutputComponent<TextInitConfig<Text, RefType>, PropertiesType> implements StandaloneComponent {
|
|
43
43
|
constructor(config: TextInitConfig<Text, RefType>);
|
|
44
44
|
/**
|
|
45
45
|
* Возвращает идентификатор типа вывода.
|
|
@@ -2,8 +2,8 @@ import { RatioMode } from "@matreshka/shared/enums/ratio-mode";
|
|
|
2
2
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
3
3
|
import { VectorMode } from "@matreshka/shared/enums/vector-mode";
|
|
4
4
|
import { type FlexItemSpec } from "@matreshka/shared/types/flex-item";
|
|
5
|
-
import { Componentable,
|
|
6
|
-
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties } from "./output-component";
|
|
5
|
+
import { Componentable, StandaloneComponent } from "../../core";
|
|
6
|
+
import { CompatibleOutputRef, OutputComponent, OutputInitConfig, OutputProperties, StringOutputContextRef } from "./output-component";
|
|
7
7
|
export { RatioMode } from "@matreshka/shared/enums/ratio-mode";
|
|
8
8
|
/** @deprecated Use RatioMode instead */
|
|
9
9
|
export { RatioMode as ImageMode } from "@matreshka/shared/enums/ratio-mode";
|
|
@@ -23,7 +23,7 @@ export type VectorProperties = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Конфигурация инициализации компонента вывода векторной графики.
|
|
25
25
|
*/
|
|
26
|
-
export type VectorInitConfig<ComponentType extends Componentable = Vector, RefType extends
|
|
26
|
+
export type VectorInitConfig<ComponentType extends Componentable = Vector, RefType extends StringOutputContextRef = StringOutputContextRef, PropertiesType extends VectorProperties = VectorProperties> = {
|
|
27
27
|
mode?: VectorMode;
|
|
28
28
|
flexItem?: FlexItemSpec;
|
|
29
29
|
ratio?: {
|
|
@@ -31,15 +31,15 @@ export type VectorInitConfig<ComponentType extends Componentable = Vector, RefTy
|
|
|
31
31
|
mode: RatioMode;
|
|
32
32
|
};
|
|
33
33
|
} & OutputInitConfig<VectorValue, ComponentType, RefType, PropertiesType>;
|
|
34
|
-
type DefaultInitConfigType<RefType extends
|
|
35
|
-
type VectorValueOrRef<RefType extends
|
|
36
|
-
export declare function vector<RefType extends
|
|
37
|
-
export declare function vector<RefType extends
|
|
38
|
-
export declare function vector<RefType extends
|
|
34
|
+
type DefaultInitConfigType<RefType extends StringOutputContextRef> = VectorInitConfig<Vector, RefType>;
|
|
35
|
+
type VectorValueOrRef<RefType extends StringOutputContextRef> = VectorValue | CompatibleOutputRef<VectorValue, RefType>;
|
|
36
|
+
export declare function vector<RefType extends StringOutputContextRef = StringOutputContextRef>(options: Omit<DefaultInitConfigType<RefType>, "value" | "ref">, valueOrRef: VectorValueOrRef<RefType>): Vector<RefType>;
|
|
37
|
+
export declare function vector<RefType extends StringOutputContextRef = StringOutputContextRef>(valueOrRef: VectorValueOrRef<RefType>): Vector<RefType>;
|
|
38
|
+
export declare function vector<RefType extends StringOutputContextRef = StringOutputContextRef>(config: VectorInitConfig<Vector, RefType>): Vector<RefType>;
|
|
39
39
|
/**
|
|
40
40
|
* Компонент для вывода векторной графики (SVG).
|
|
41
41
|
*/
|
|
42
|
-
export declare class Vector<RefType extends
|
|
42
|
+
export declare class Vector<RefType extends StringOutputContextRef = StringOutputContextRef, PropertiesType extends VectorProperties = VectorProperties> extends OutputComponent<DefaultInitConfigType<RefType>, PropertiesType> implements StandaloneComponent {
|
|
43
43
|
constructor(config: DefaultInitConfigType<RefType>);
|
|
44
44
|
protected class(): ServerComponentClass;
|
|
45
45
|
protected initProperties(initValues: DefaultInitConfigType<RefType>): PropertiesType;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ForEach
|
|
2
|
-
import type { ComponentTreeNode } from "@matreshka/bff/core";
|
|
3
|
-
export type ComponentSequence<DataType, T extends ComponentTreeNode = ComponentTreeNode> = (T | ForEach<
|
|
1
|
+
import { ForEach } from "@matreshka/bff/components/for-each";
|
|
2
|
+
import type { ComponentTreeNode, ContextArrayRef } from "@matreshka/bff/core";
|
|
3
|
+
export type ComponentSequence<DataType, T extends ComponentTreeNode = ComponentTreeNode> = (T | ForEach<ContextArrayRef<DataType>, T>)[];
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContextRefValue } from "../context/context-ref";
|
|
2
|
+
import { ContextValueRef } from "../types/context-value-ref";
|
|
2
3
|
import { ActionConfig } from "./action";
|
|
3
4
|
import { LocalAction } from "./local-action";
|
|
4
5
|
/**
|
|
5
6
|
* Запись одного значения в Context на клиенте (с sync на BFF через `context-values`).
|
|
7
|
+
*
|
|
8
|
+
* `R` — конкретный ref; `value` имеет тип значения по этому ref.
|
|
6
9
|
*/
|
|
7
|
-
export declare class SetContextValue extends LocalAction {
|
|
10
|
+
export declare class SetContextValue<R extends ContextValueRef<unknown>> extends LocalAction {
|
|
8
11
|
private readonly ref;
|
|
9
12
|
private readonly value;
|
|
10
|
-
constructor(ref:
|
|
13
|
+
constructor(ref: R, value: ContextRefValue<R>, config?: ActionConfig);
|
|
11
14
|
class(): string;
|
|
12
15
|
payload(): object;
|
|
13
16
|
}
|
|
@@ -15,4 +18,4 @@ export declare class SetContextValue extends LocalAction {
|
|
|
15
18
|
* Функциональная форма {@link SetContextValue}.
|
|
16
19
|
* Тип `value` должен совпадать с типом значения по `ref`.
|
|
17
20
|
*/
|
|
18
|
-
export declare function setContextValue<R extends
|
|
21
|
+
export declare function setContextValue<R extends ContextValueRef<unknown>>(ref: R, value: ContextRefValue<R>, config?: ActionConfig): SetContextValue<R>;
|
|
@@ -5,6 +5,8 @@ exports.setContextValue = setContextValue;
|
|
|
5
5
|
const local_action_1 = require("./local-action");
|
|
6
6
|
/**
|
|
7
7
|
* Запись одного значения в Context на клиенте (с sync на BFF через `context-values`).
|
|
8
|
+
*
|
|
9
|
+
* `R` — конкретный ref; `value` имеет тип значения по этому ref.
|
|
8
10
|
*/
|
|
9
11
|
class SetContextValue extends local_action_1.LocalAction {
|
|
10
12
|
constructor(ref, value, config = {}) {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContextRefValue } from "../context/context-ref";
|
|
2
|
+
import { ContextValueRef } from "../types/context-value-ref";
|
|
2
3
|
import { ActionConfig } from "./action";
|
|
3
4
|
import { LocalAction } from "./local-action";
|
|
4
5
|
/**
|
|
5
6
|
* Пара ref + value для batch-записи в Context.
|
|
6
7
|
* Тип `value` выводится из конкретного `ref`.
|
|
7
8
|
*/
|
|
8
|
-
export type ContextValueAssignment<R extends
|
|
9
|
+
export type ContextValueAssignment<R extends ContextValueRef<unknown> = ContextValueRef<unknown>> = {
|
|
9
10
|
ref: R;
|
|
10
11
|
value: ContextRefValue<R>;
|
|
11
12
|
};
|
|
12
13
|
type AssertContextValueAssignments<T extends readonly unknown[]> = {
|
|
13
14
|
[K in keyof T]: T[K] extends {
|
|
14
|
-
ref: infer R extends
|
|
15
|
+
ref: infer R extends ContextValueRef<unknown>;
|
|
15
16
|
} ? ContextValueAssignment<R> : never;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContextValueRef } from "../types/context-value-ref";
|
|
2
2
|
import { ActionConfig } from "./action";
|
|
3
3
|
import { LocalAction } from "./local-action";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export type BooleanContextRef<R extends ContextRef<any, any>> = Exclude<ContextRefValue<R>, undefined> extends boolean ? R : never;
|
|
4
|
+
/** Ref на boolean-поле контекста. */
|
|
5
|
+
export type BooleanValueRef = ContextValueRef<boolean | undefined>;
|
|
8
6
|
/**
|
|
9
7
|
* Инверсия boolean-значения в Context на клиенте (с sync на BFF через `context-values`).
|
|
10
8
|
*/
|
|
11
9
|
export declare class ToggleContextValue extends LocalAction {
|
|
12
10
|
private readonly ref;
|
|
13
|
-
constructor(ref:
|
|
11
|
+
constructor(ref: BooleanValueRef, config?: ActionConfig);
|
|
14
12
|
class(): string;
|
|
15
13
|
payload(): object;
|
|
16
14
|
}
|
|
@@ -18,4 +16,4 @@ export declare class ToggleContextValue extends LocalAction {
|
|
|
18
16
|
* Функциональная форма {@link ToggleContextValue}.
|
|
19
17
|
* Принимает только `ContextRef` с boolean-значением.
|
|
20
18
|
*/
|
|
21
|
-
export declare function toggleContextValue
|
|
19
|
+
export declare function toggleContextValue(ref: BooleanValueRef, config?: ActionConfig): ToggleContextValue;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Client } from "./client";
|
|
2
|
+
/**
|
|
3
|
+
* Доступ к клиентскому key-value хранилищу из {@link ClientState.storage}.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ClientStorage {
|
|
6
|
+
private readonly client;
|
|
7
|
+
constructor(client: Client);
|
|
8
|
+
/**
|
|
9
|
+
* Возвращает значение из клиентского хранилища по заданному ключу.
|
|
10
|
+
*
|
|
11
|
+
* @param key Ключ значения (поддерживается dot-path).
|
|
12
|
+
* @returns Значение, если оно существует.
|
|
13
|
+
*/
|
|
14
|
+
get(key: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Устанавливает значение в клиентское хранилище и отправляет соответствующее сообщение.
|
|
17
|
+
*
|
|
18
|
+
* @param key Ключ значения.
|
|
19
|
+
* @param value Значение или undefined для удаления.
|
|
20
|
+
*/
|
|
21
|
+
set(key: string, value: string | undefined): void;
|
|
22
|
+
/**
|
|
23
|
+
* Удаляет значение из хранилища по ключу.
|
|
24
|
+
*
|
|
25
|
+
* @param key Ключ для удаления.
|
|
26
|
+
*/
|
|
27
|
+
clear(key: string): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientStorage = void 0;
|
|
4
|
+
const index_1 = require("@matreshka/shared/messages/bff-to-client/app/index");
|
|
5
|
+
const fetch_from_object_1 = require("@matreshka/shared/utils/fetch-from-object");
|
|
6
|
+
const set_object_property_1 = require("./utils/set-object-property");
|
|
7
|
+
/**
|
|
8
|
+
* Доступ к клиентскому key-value хранилищу из {@link ClientState.storage}.
|
|
9
|
+
*/
|
|
10
|
+
class ClientStorage {
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Возвращает значение из клиентского хранилища по заданному ключу.
|
|
16
|
+
*
|
|
17
|
+
* @param key Ключ значения (поддерживается dot-path).
|
|
18
|
+
* @returns Значение, если оно существует.
|
|
19
|
+
*/
|
|
20
|
+
get(key) {
|
|
21
|
+
return (0, fetch_from_object_1.fetchFromObject)(this.client.state$.getValue().storage, key);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Устанавливает значение в клиентское хранилище и отправляет соответствующее сообщение.
|
|
25
|
+
*
|
|
26
|
+
* @param key Ключ значения.
|
|
27
|
+
* @param value Значение или undefined для удаления.
|
|
28
|
+
*/
|
|
29
|
+
set(key, value) {
|
|
30
|
+
const storage = this.client.state$.getValue().storage;
|
|
31
|
+
(0, set_object_property_1.setObjectProperty)(storage, key, value);
|
|
32
|
+
this.client.state$.next({ ...this.client.state$.getValue(), storage });
|
|
33
|
+
const message = new index_1.AppStorageValueMessage({ key, value });
|
|
34
|
+
this.client.outcomingMessage$.next(message);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Удаляет значение из хранилища по ключу.
|
|
38
|
+
*
|
|
39
|
+
* @param key Ключ для удаления.
|
|
40
|
+
*/
|
|
41
|
+
clear(key) {
|
|
42
|
+
this.set(key, undefined);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ClientStorage = ClientStorage;
|
package/dist/core/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { BehaviorSubject, Subject } from "rxjs";
|
|
|
10
10
|
import { z } from "zod/v4";
|
|
11
11
|
import { Page } from "../components";
|
|
12
12
|
import { App } from "../components/app";
|
|
13
|
+
import { ClientStorage } from "./client-storage";
|
|
13
14
|
import { ComponentInstance } from "./types/component-instance";
|
|
14
15
|
import { type ComponentTreeNode } from "./types/component-tree-node";
|
|
15
16
|
/**
|
|
@@ -64,6 +65,7 @@ export declare class Client {
|
|
|
64
65
|
private readonly reliableDelivery;
|
|
65
66
|
readonly state$: BehaviorSubject<ClientState>;
|
|
66
67
|
readonly applicationId$: BehaviorSubject<string | undefined>;
|
|
68
|
+
readonly storage: ClientStorage;
|
|
67
69
|
/**
|
|
68
70
|
* Создает новый экземпляр клиента.
|
|
69
71
|
*
|
|
@@ -112,6 +114,7 @@ export declare class Client {
|
|
|
112
114
|
*
|
|
113
115
|
* @param key Ключ значения.
|
|
114
116
|
* @returns Значение, если оно существует.
|
|
117
|
+
* @deprecated Используйте {@link Client.storage.get}.
|
|
115
118
|
*/
|
|
116
119
|
getStorageValue(key: string): string;
|
|
117
120
|
/**
|
|
@@ -120,6 +123,7 @@ export declare class Client {
|
|
|
120
123
|
* @param key Ключ значения.
|
|
121
124
|
* @param value Значение или undefined для удаления.
|
|
122
125
|
* @returns Ссылку на текущий экземпляр клиента.
|
|
126
|
+
* @deprecated Используйте {@link Client.storage.set}.
|
|
123
127
|
*/
|
|
124
128
|
setStorageValue(key: string, value: string | undefined): this;
|
|
125
129
|
/**
|
|
@@ -127,6 +131,7 @@ export declare class Client {
|
|
|
127
131
|
*
|
|
128
132
|
* @param key Ключ для удаления.
|
|
129
133
|
* @returns Ссылку на текущий экземпляр клиента.
|
|
134
|
+
* @deprecated Используйте {@link Client.storage.clear}.
|
|
130
135
|
*/
|
|
131
136
|
clearStorageValue(key: string): this;
|
|
132
137
|
private forwardToTransport;
|
package/dist/core/client.js
CHANGED
|
@@ -5,22 +5,20 @@ const shared_1 = require("@matreshka/shared");
|
|
|
5
5
|
const browser_engine_1 = require("@matreshka/shared/enums/browser-engine");
|
|
6
6
|
const browser_name_1 = require("@matreshka/shared/enums/browser-name");
|
|
7
7
|
const platform_id_1 = require("@matreshka/shared/enums/platform-id");
|
|
8
|
-
const index_1 = require("@matreshka/shared/messages/bff-to-client/app/index");
|
|
9
8
|
const message_received_message_1 = require("@matreshka/shared/messages/bff-to-client/message-received-message");
|
|
10
9
|
const app_client_state_message_1 = require("@matreshka/shared/messages/client-to-bff/app/app-client-state-message");
|
|
11
10
|
const handshake_message_1 = require("@matreshka/shared/messages/client-to-bff/app/handshake-message");
|
|
12
11
|
const message_received_message_2 = require("@matreshka/shared/messages/client-to-bff/message-received-message");
|
|
13
12
|
const parse_client_to_bff_message_1 = require("@matreshka/shared/messages/client-to-bff/parse-client-to-bff-message");
|
|
14
13
|
const reliable_delivery_1 = require("@matreshka/shared/messages/reliable-delivery");
|
|
15
|
-
const fetch_from_object_1 = require("@matreshka/shared/utils/fetch-from-object");
|
|
16
14
|
const rxjs_1 = require("rxjs");
|
|
17
15
|
const v4_1 = require("zod/v4");
|
|
18
16
|
const app_1 = require("../components/app");
|
|
19
17
|
const component_1 = require("../components/component");
|
|
20
18
|
const client_context_1 = require("./client-context");
|
|
19
|
+
const client_storage_1 = require("./client-storage");
|
|
21
20
|
const component_tree_node_1 = require("./types/component-tree-node");
|
|
22
21
|
const incoming_message_observer_1 = require("./utils/incoming-message-observer");
|
|
23
|
-
const set_object_property_1 = require("./utils/set-object-property");
|
|
24
22
|
const resolveOsNameFromUserAgent = shared_1.getOsNameFromUserAgent;
|
|
25
23
|
const resolveDeviceTypeFromUserAgent = shared_1.getDeviceTypeFromUserAgent;
|
|
26
24
|
/**
|
|
@@ -78,6 +76,7 @@ class Client {
|
|
|
78
76
|
ping$: this.ping$,
|
|
79
77
|
});
|
|
80
78
|
this.applicationId$ = new rxjs_1.BehaviorSubject(undefined);
|
|
79
|
+
this.storage = new client_storage_1.ClientStorage(this);
|
|
81
80
|
this.state$ = new rxjs_1.BehaviorSubject(undefined);
|
|
82
81
|
this.outcomingMessage$.subscribe((message) => {
|
|
83
82
|
this.reliableDelivery.observeOutgoing(message);
|
|
@@ -250,9 +249,10 @@ class Client {
|
|
|
250
249
|
*
|
|
251
250
|
* @param key Ключ значения.
|
|
252
251
|
* @returns Значение, если оно существует.
|
|
252
|
+
* @deprecated Используйте {@link Client.storage.get}.
|
|
253
253
|
*/
|
|
254
254
|
getStorageValue(key) {
|
|
255
|
-
return
|
|
255
|
+
return this.storage.get(key);
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* Устанавливает значение в клиентское хранилище и отправляет соответствующее сообщение.
|
|
@@ -260,13 +260,10 @@ class Client {
|
|
|
260
260
|
* @param key Ключ значения.
|
|
261
261
|
* @param value Значение или undefined для удаления.
|
|
262
262
|
* @returns Ссылку на текущий экземпляр клиента.
|
|
263
|
+
* @deprecated Используйте {@link Client.storage.set}.
|
|
263
264
|
*/
|
|
264
265
|
setStorageValue(key, value) {
|
|
265
|
-
|
|
266
|
-
(0, set_object_property_1.setObjectProperty)(storage, key, value);
|
|
267
|
-
this.state$.next({ ...this.state$.getValue(), storage });
|
|
268
|
-
const message = new index_1.AppStorageValueMessage({ key, value });
|
|
269
|
-
this.outcomingMessage$.next(message);
|
|
266
|
+
this.storage.set(key, value);
|
|
270
267
|
return this;
|
|
271
268
|
}
|
|
272
269
|
/**
|
|
@@ -274,9 +271,11 @@ class Client {
|
|
|
274
271
|
*
|
|
275
272
|
* @param key Ключ для удаления.
|
|
276
273
|
* @returns Ссылку на текущий экземпляр клиента.
|
|
274
|
+
* @deprecated Используйте {@link Client.storage.clear}.
|
|
277
275
|
*/
|
|
278
276
|
clearStorageValue(key) {
|
|
279
|
-
|
|
277
|
+
this.storage.clear(key);
|
|
278
|
+
return this;
|
|
280
279
|
}
|
|
281
280
|
forwardToTransport(message) {
|
|
282
281
|
this.transportSend?.(message);
|
package/dist/core/index.d.ts
CHANGED
|
@@ -8,19 +8,23 @@ export * from "./actions/write-text-to-clipboard";
|
|
|
8
8
|
export * from "./boot";
|
|
9
9
|
export * from "./client";
|
|
10
10
|
export * from "./client-context";
|
|
11
|
+
export * from "./client-storage";
|
|
11
12
|
export * from "./entry-context";
|
|
12
13
|
export * from "./gateway-connection";
|
|
13
14
|
export * from "./matreshka";
|
|
14
15
|
export * from "./conditions";
|
|
15
16
|
export * from "./context/context";
|
|
16
17
|
export * from "./context/context-ref";
|
|
18
|
+
export * from "./types/client-settings";
|
|
17
19
|
export * from "./utils/calculate-components";
|
|
20
|
+
export * from "./utils/color-roles-to-ids";
|
|
18
21
|
export * from "./utils/color-token-id";
|
|
19
22
|
export * from "./utils/serialize-component-tree";
|
|
20
23
|
export * from "@matreshka/shared/types/json";
|
|
21
24
|
export * from "./types/component-instance";
|
|
22
25
|
export * from "./types/component-tree-node";
|
|
23
26
|
export * from "./types/componentable";
|
|
27
|
+
export * from "./types/context-value-ref";
|
|
24
28
|
export * from "./types/message";
|
|
25
29
|
export * from "./types/mixed-with-callbacks-array";
|
|
26
30
|
export * from "./types/native-picker-context-ref";
|
package/dist/core/index.js
CHANGED
|
@@ -24,19 +24,23 @@ __exportStar(require("./actions/write-text-to-clipboard"), exports);
|
|
|
24
24
|
__exportStar(require("./boot"), exports);
|
|
25
25
|
__exportStar(require("./client"), exports);
|
|
26
26
|
__exportStar(require("./client-context"), exports);
|
|
27
|
+
__exportStar(require("./client-storage"), exports);
|
|
27
28
|
__exportStar(require("./entry-context"), exports);
|
|
28
29
|
__exportStar(require("./gateway-connection"), exports);
|
|
29
30
|
__exportStar(require("./matreshka"), exports);
|
|
30
31
|
__exportStar(require("./conditions"), exports);
|
|
31
32
|
__exportStar(require("./context/context"), exports);
|
|
32
33
|
__exportStar(require("./context/context-ref"), exports);
|
|
34
|
+
__exportStar(require("./types/client-settings"), exports);
|
|
33
35
|
__exportStar(require("./utils/calculate-components"), exports);
|
|
36
|
+
__exportStar(require("./utils/color-roles-to-ids"), exports);
|
|
34
37
|
__exportStar(require("./utils/color-token-id"), exports);
|
|
35
38
|
__exportStar(require("./utils/serialize-component-tree"), exports);
|
|
36
39
|
__exportStar(require("@matreshka/shared/types/json"), exports);
|
|
37
40
|
__exportStar(require("./types/component-instance"), exports);
|
|
38
41
|
__exportStar(require("./types/component-tree-node"), exports);
|
|
39
42
|
__exportStar(require("./types/componentable"), exports);
|
|
43
|
+
__exportStar(require("./types/context-value-ref"), exports);
|
|
40
44
|
__exportStar(require("./types/message"), exports);
|
|
41
45
|
__exportStar(require("./types/mixed-with-callbacks-array"), exports);
|
|
42
46
|
__exportStar(require("./types/native-picker-context-ref"), exports);
|
package/dist/core/matreshka.js
CHANGED
|
@@ -41,7 +41,7 @@ const rxjs_1 = require("rxjs");
|
|
|
41
41
|
const client_1 = require("./client");
|
|
42
42
|
const gateway_connection_1 = require("./gateway-connection");
|
|
43
43
|
const router_1 = require("./router");
|
|
44
|
-
const
|
|
44
|
+
const serialize_client_settings_colors_for_handshake_1 = require("./utils/serialize-client-settings-colors-for-handshake");
|
|
45
45
|
const CLIENT_DESTROY_TIMEOUT_MS = 15 * 60 * 1000; // 15 минут
|
|
46
46
|
/**
|
|
47
47
|
* Основной класс приложения, управляющий жизненным циклом клиентов и маршрутизацией.
|
|
@@ -174,10 +174,7 @@ class Matreshka {
|
|
|
174
174
|
clientDestroyTimeoutMs: CLIENT_DESTROY_TIMEOUT_MS,
|
|
175
175
|
settings: {
|
|
176
176
|
...settings,
|
|
177
|
-
colors: settings.colors
|
|
178
|
-
acc[(0, color_token_id_1.colorTokenId)(cur)] = cur;
|
|
179
|
-
return acc;
|
|
180
|
-
}, {}),
|
|
177
|
+
colors: (0, serialize_client_settings_colors_for_handshake_1.serializeClientSettingsColorsForHandshake)(settings.colors),
|
|
181
178
|
},
|
|
182
179
|
});
|
|
183
180
|
client.outcomingMessage$.next(message);
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { ColorRole } from "@matreshka/shared/enums/color-role";
|
|
1
2
|
import { ColorToken } from "@matreshka/shared/types/color-token";
|
|
2
3
|
import { AppFontsConfig } from "@matreshka/shared/types/fonts";
|
|
4
|
+
export type ClientSettingsColors = {
|
|
5
|
+
/** Реестр определений токенов для handshake и резолва id в UI. */
|
|
6
|
+
registry: ColorToken[];
|
|
7
|
+
/** Глобальные роли по умолчанию на клиенте. */
|
|
8
|
+
default: Partial<Record<ColorRole, ColorToken>>;
|
|
9
|
+
};
|
|
3
10
|
/**
|
|
4
11
|
* Настройки интерфейса приложения, передаваемые клиенту.
|
|
5
12
|
*
|
|
@@ -8,7 +15,7 @@ import { AppFontsConfig } from "@matreshka/shared/types/fonts";
|
|
|
8
15
|
* @property faviconUrl Ссылки на иконки favicon.
|
|
9
16
|
* @property pwaIconUrl Ссылки на иконки для установки как PWA.
|
|
10
17
|
* @property fonts Реестр и стек шрифтов интерфейса.
|
|
11
|
-
* @property colors
|
|
18
|
+
* @property colors Реестр токенов и глобальные роли по умолчанию.
|
|
12
19
|
*/
|
|
13
20
|
export type ClientSettings = {
|
|
14
21
|
appName: string;
|
|
@@ -27,5 +34,5 @@ export type ClientSettings = {
|
|
|
27
34
|
svg?: string;
|
|
28
35
|
};
|
|
29
36
|
fonts: AppFontsConfig;
|
|
30
|
-
colors:
|
|
37
|
+
colors: ClientSettingsColors;
|
|
31
38
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ContextRef, ContextRefValue } from "../context/context-ref";
|
|
2
|
+
/**
|
|
3
|
+
* Ссылка на поле контекста с известным типом значения.
|
|
4
|
+
*
|
|
5
|
+
* Контекст и путь не фиксируются — важен только тип значения по ref.
|
|
6
|
+
* Удобно в сигнатурах компонентов и хелперов, которые не обращаются к вложенным
|
|
7
|
+
* полям по типизированному пути.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* function bindAmount(ref: ContextValueRef<number | undefined>) {
|
|
12
|
+
* ref.value(); // number | undefined
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* bindAmount(pageContext.ref("amount"));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type ContextValueRef<ValueType> = ContextRef<any, any> & {
|
|
19
|
+
readonly __valueType?: ValueType;
|
|
20
|
+
value(): ValueType;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Ref `R` совместим с ожидаемым типом значения `ValueType` (проверка на call site).
|
|
24
|
+
*/
|
|
25
|
+
export type CompatibleContextValueRef<ValueType, R extends ContextRef<any, any>> = ValueType extends ContextRefValue<R> ? R : never;
|
|
26
|
+
/**
|
|
27
|
+
* Ссылка на массив элементов в контексте (`ItemType[] | undefined`).
|
|
28
|
+
*
|
|
29
|
+
* Generic задаёт тип **элемента**, как в {@link CompatibleForEachRef} / `forEach`.
|
|
30
|
+
*/
|
|
31
|
+
export type ContextArrayRef<ItemType> = ContextValueRef<ItemType[] | undefined>;
|