@matreshka/bff 0.11.2 → 0.13.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/context/context-ref.d.ts +5 -0
- package/dist/core/context/context-ref.js +10 -0
- 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 +32 -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
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
setValue(value: ValueType): void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Ref `R` совместим с ожидаемым типом значения `ValueType` (проверка на call site).
|
|
25
|
+
*/
|
|
26
|
+
export type CompatibleContextValueRef<ValueType, R extends ContextRef<any, any>> = ValueType extends ContextRefValue<R> ? R : never;
|
|
27
|
+
/**
|
|
28
|
+
* Ссылка на массив элементов в контексте (`ItemType[] | undefined`).
|
|
29
|
+
*
|
|
30
|
+
* Generic задаёт тип **элемента**, как в {@link CompatibleForEachRef} / `forEach`.
|
|
31
|
+
*/
|
|
32
|
+
export type ContextArrayRef<ItemType> = ContextValueRef<ItemType[] | undefined>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { JsonPrimitive } from "@matreshka/shared/types/json";
|
|
2
|
-
import { ContextRef
|
|
2
|
+
import { ContextRef } from "../context/context-ref";
|
|
3
|
+
import { CompatibleContextValueRef } from "./context-value-ref";
|
|
3
4
|
/**
|
|
4
5
|
* Ссылка на поле контекста, тип значения которого совместим с `ValueType`
|
|
5
6
|
* для соответствующего native picker.
|
|
6
7
|
*/
|
|
7
|
-
export type NativePickerContextRef<ValueType extends JsonPrimitive, R extends ContextRef<any, any> = ContextRef<any, any>> = ValueType
|
|
8
|
+
export type NativePickerContextRef<ValueType extends JsonPrimitive, R extends ContextRef<any, any> = ContextRef<any, any>> = CompatibleContextValueRef<ValueType, R>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePartialColorsToIds = resolvePartialColorsToIds;
|
|
4
|
+
const color_token_id_1 = require("./color-token-id");
|
|
5
|
+
function resolvePartialColorsToIds(colors) {
|
|
6
|
+
return Object.entries(colors).reduce((acc, [role, value]) => {
|
|
7
|
+
acc[role] = (0, color_token_id_1.colorTokenId)(value);
|
|
8
|
+
return acc;
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColorRole } from "@matreshka/shared/enums/color-role";
|
|
2
|
+
import { ColorToken } from "@matreshka/shared/types/color-token";
|
|
3
|
+
import type { ClientSettingsColors } from "../types/client-settings";
|
|
4
|
+
export type HandshakeClientSettingsColors = {
|
|
5
|
+
registry: Record<string, ColorToken>;
|
|
6
|
+
default: Partial<Record<ColorRole, string>>;
|
|
7
|
+
};
|
|
8
|
+
export declare function serializeClientSettingsColorsForHandshake(colors: ClientSettingsColors): HandshakeClientSettingsColors;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeClientSettingsColorsForHandshake = serializeClientSettingsColorsForHandshake;
|
|
4
|
+
const color_roles_to_ids_1 = require("./color-roles-to-ids");
|
|
5
|
+
const color_token_id_1 = require("./color-token-id");
|
|
6
|
+
function serializeClientSettingsColorsForHandshake(colors) {
|
|
7
|
+
const registry = colors.registry.reduce((acc, token) => {
|
|
8
|
+
acc[(0, color_token_id_1.colorTokenId)(token)] = token;
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
return {
|
|
12
|
+
registry,
|
|
13
|
+
default: (0, color_roles_to_ids_1.resolvePartialColorsToIds)(colors.default),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlatformEnumeratedDevice } from "@matreshka/shared/messages/client-to-bff/platforms/platform-enumerate-devices-success-message";
|
|
2
2
|
import { Dialog, Popover } from "../components";
|
|
3
3
|
import { Overlay } from "../components/types/container-overlay";
|
|
4
|
-
import { Client, Componentable, ComponentInstance,
|
|
4
|
+
import { Client, Componentable, ComponentInstance, ContextValueRef } from "../core";
|
|
5
5
|
/**
|
|
6
6
|
* Абстрактный класс платформы, управляющий клиентом и его состоянием.
|
|
7
7
|
*/
|
|
@@ -59,10 +59,10 @@ export declare abstract class Platform {
|
|
|
59
59
|
* @param popover Компонент всплывающего окна.
|
|
60
60
|
*/
|
|
61
61
|
showPopover(anchor: ComponentInstance | Componentable, popover: Popover): void;
|
|
62
|
-
showDatePicker(anchor: ComponentInstance | Componentable, ref:
|
|
63
|
-
showColorPicker(anchor: ComponentInstance | Componentable, ref:
|
|
64
|
-
showTimePicker(anchor: ComponentInstance | Componentable, ref:
|
|
65
|
-
showDateTimePicker(anchor: ComponentInstance | Componentable, ref:
|
|
62
|
+
showDatePicker(anchor: ComponentInstance | Componentable, ref: ContextValueRef<string | undefined>): void;
|
|
63
|
+
showColorPicker(anchor: ComponentInstance | Componentable, ref: ContextValueRef<string | undefined>): void;
|
|
64
|
+
showTimePicker(anchor: ComponentInstance | Componentable, ref: ContextValueRef<string | undefined>): void;
|
|
65
|
+
showDateTimePicker(anchor: ComponentInstance | Componentable, ref: ContextValueRef<string | undefined>): void;
|
|
66
66
|
private emitNativePickerCommand;
|
|
67
67
|
/**
|
|
68
68
|
* Задаёт платформенные оверлеи (anchors + component). Вложенные компоненты участвуют в поиске на сервере;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matreshka/bff",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Matreshka BFF: server-driven UI runtime — routing, pages, context, component DSL, and platform APIs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/
|
|
31
|
+
"url": "git+https://github.com/matreshka-dev/matreshka.git",
|
|
32
32
|
"directory": "bff"
|
|
33
33
|
},
|
|
34
34
|
"bugs": {
|
|
35
|
-
"url": "https://github.com/
|
|
35
|
+
"url": "https://github.com/matreshka-dev/matreshka/issues"
|
|
36
36
|
},
|
|
37
|
-
"homepage": "https://github.com/
|
|
37
|
+
"homepage": "https://github.com/matreshka-dev/matreshka/tree/main/bff",
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "^4.1.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@matreshka/shared": "^0.
|
|
65
|
+
"@matreshka/shared": "^0.12.0",
|
|
66
66
|
"@simplewebauthn/server": "^13.1.1",
|
|
67
67
|
"@simplewebauthn/types": "^12.0.0",
|
|
68
68
|
"fast-xml-parser": "^5.3.3",
|