@matreshka/bff 0.21.0 → 0.22.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 (44) hide show
  1. package/dist/components/board.d.ts +7 -0
  2. package/dist/components/board.js +7 -0
  3. package/dist/components/camera.d.ts +4 -0
  4. package/dist/components/camera.js +4 -0
  5. package/dist/components/component.d.ts +2 -1
  6. package/dist/components/dialog.d.ts +5 -0
  7. package/dist/components/dialog.js +8 -0
  8. package/dist/components/inputs/text-editor.d.ts +17 -0
  9. package/dist/components/inputs/text-editor.js +17 -0
  10. package/dist/components/map.d.ts +11 -0
  11. package/dist/components/map.js +7 -0
  12. package/dist/components/popover.d.ts +5 -0
  13. package/dist/components/popover.js +8 -0
  14. package/dist/components/stack.d.ts +4 -0
  15. package/dist/components/stack.js +4 -0
  16. package/dist/core/actions/close-entry.d.ts +15 -0
  17. package/dist/core/actions/close-entry.js +28 -0
  18. package/dist/core/actions/component-local-actions.d.ts +113 -0
  19. package/dist/core/actions/component-local-actions.js +274 -0
  20. package/dist/core/actions/dec-context-value.d.ts +21 -0
  21. package/dist/core/actions/dec-context-value.js +35 -0
  22. package/dist/core/actions/inc-context-value.d.ts +22 -0
  23. package/dist/core/actions/inc-context-value.js +35 -0
  24. package/dist/core/actions/local-action.d.ts +4 -0
  25. package/dist/core/actions/local-action.js +43 -0
  26. package/dist/core/actions/set-context.d.ts +20 -0
  27. package/dist/core/actions/set-context.js +33 -0
  28. package/dist/core/conditions/condition-operand.d.ts +5 -3
  29. package/dist/core/context/context-ref.d.ts +21 -0
  30. package/dist/core/context/context-ref.js +16 -0
  31. package/dist/core/context/context.d.ts +10 -0
  32. package/dist/core/context/context.js +11 -0
  33. package/dist/core/index.d.ts +3 -6
  34. package/dist/core/index.js +6 -6
  35. package/dist/core/local/index.d.ts +14 -0
  36. package/dist/core/local/index.js +18 -0
  37. package/dist/core/types/component-instance.d.ts +7 -0
  38. package/dist/core/types/component-instance.js +4 -0
  39. package/dist/core/types/context-value-ref.d.ts +2 -0
  40. package/package.json +2 -2
  41. package/dist/core/actions/set-context-value.d.ts +0 -21
  42. package/dist/core/actions/set-context-value.js +0 -34
  43. package/dist/core/actions/set-context-values.d.ts +0 -35
  44. package/dist/core/actions/set-context-values.js +0 -30
@@ -1,10 +1,4 @@
1
1
  export * from "./actions/action";
2
- export * from "./actions/animate-component";
3
- export * from "./actions/local-action";
4
- export * from "./actions/set-context-value";
5
- export * from "./actions/set-context-values";
6
- export * from "./actions/toggle-context-value";
7
- export * from "./actions/write-text-to-clipboard";
8
2
  export * from "./boot";
9
3
  export * from "./client";
10
4
  export * from "./client-context";
@@ -15,6 +9,9 @@ export * from "./matreshka";
15
9
  export * from "./conditions";
16
10
  export * from "./context/context";
17
11
  export * from "./context/context-ref";
12
+ export type { DimensionalValue } from "@matreshka/shared/types/dimensional-value";
13
+ export { ComponentAnimationEffect, DimensionalUnit, TimingFunction, local, } from "./local";
14
+ export type { ActionConfig, AnimateComponentConfig, ComponentAnimationEffects, DimensionalKeyframeStops, OpacityKeyframeStops, } from "./local";
18
15
  export * from "./types/client-settings";
19
16
  export * from "./utils/calculate-components";
20
17
  export * from "./utils/color-roles-to-ids";
@@ -14,13 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.local = exports.TimingFunction = exports.DimensionalUnit = exports.ComponentAnimationEffect = void 0;
17
18
  __exportStar(require("./actions/action"), exports);
18
- __exportStar(require("./actions/animate-component"), exports);
19
- __exportStar(require("./actions/local-action"), exports);
20
- __exportStar(require("./actions/set-context-value"), exports);
21
- __exportStar(require("./actions/set-context-values"), exports);
22
- __exportStar(require("./actions/toggle-context-value"), exports);
23
- __exportStar(require("./actions/write-text-to-clipboard"), exports);
24
19
  __exportStar(require("./boot"), exports);
25
20
  __exportStar(require("./client"), exports);
26
21
  __exportStar(require("./client-context"), exports);
@@ -31,6 +26,11 @@ __exportStar(require("./matreshka"), exports);
31
26
  __exportStar(require("./conditions"), exports);
32
27
  __exportStar(require("./context/context"), exports);
33
28
  __exportStar(require("./context/context-ref"), exports);
29
+ var local_1 = require("./local");
30
+ Object.defineProperty(exports, "ComponentAnimationEffect", { enumerable: true, get: function () { return local_1.ComponentAnimationEffect; } });
31
+ Object.defineProperty(exports, "DimensionalUnit", { enumerable: true, get: function () { return local_1.DimensionalUnit; } });
32
+ Object.defineProperty(exports, "TimingFunction", { enumerable: true, get: function () { return local_1.TimingFunction; } });
33
+ Object.defineProperty(exports, "local", { enumerable: true, get: function () { return local_1.local; } });
34
34
  __exportStar(require("./types/client-settings"), exports);
35
35
  __exportStar(require("./utils/calculate-components"), exports);
36
36
  __exportStar(require("./utils/color-roles-to-ids"), exports);
@@ -0,0 +1,14 @@
1
+ import { animate } from "../actions/animate-component";
2
+ import { writeTextToClipboard } from "../actions/write-text-to-clipboard";
3
+ export type { ActionConfig } from "../actions/action";
4
+ export { DimensionalUnit } from "@matreshka/shared/enums/dimensional-unit";
5
+ export type { DimensionalValue } from "@matreshka/shared/types/dimensional-value";
6
+ export { animate, ComponentAnimationEffect, TimingFunction, } from "../actions/animate-component";
7
+ export type { AnimateComponentConfig, ComponentAnimationEffects, DimensionalKeyframeStops, OpacityKeyframeStops, } from "../actions/animate-component";
8
+ /**
9
+ * Глобальные локальные (client-only) действия Matreshka BFF.
10
+ */
11
+ export declare const local: {
12
+ readonly animate: typeof animate;
13
+ readonly writeTextToClipboard: typeof writeTextToClipboard;
14
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.local = exports.TimingFunction = exports.ComponentAnimationEffect = exports.animate = exports.DimensionalUnit = void 0;
4
+ const animate_component_1 = require("../actions/animate-component");
5
+ const write_text_to_clipboard_1 = require("../actions/write-text-to-clipboard");
6
+ var dimensional_unit_1 = require("@matreshka/shared/enums/dimensional-unit");
7
+ Object.defineProperty(exports, "DimensionalUnit", { enumerable: true, get: function () { return dimensional_unit_1.DimensionalUnit; } });
8
+ var animate_component_2 = require("../actions/animate-component");
9
+ Object.defineProperty(exports, "animate", { enumerable: true, get: function () { return animate_component_2.animate; } });
10
+ Object.defineProperty(exports, "ComponentAnimationEffect", { enumerable: true, get: function () { return animate_component_2.ComponentAnimationEffect; } });
11
+ Object.defineProperty(exports, "TimingFunction", { enumerable: true, get: function () { return animate_component_2.TimingFunction; } });
12
+ /**
13
+ * Глобальные локальные (client-only) действия Matreshka BFF.
14
+ */
15
+ exports.local = {
16
+ animate: animate_component_1.animate,
17
+ writeTextToClipboard: write_text_to_clipboard_1.writeTextToClipboard,
18
+ };
@@ -1,6 +1,10 @@
1
1
  import { EntryComponent } from "../../components";
2
+ import { InstanceLocalActions } from "../actions/local-action";
2
3
  import type { Client } from "../client";
3
4
  import type { Componentable } from "./componentable";
5
+ type ComponentInstanceLocalActions<ComponentType> = ComponentType extends {
6
+ local: infer LocalActions;
7
+ } ? InstanceLocalActions<LocalActions> : Record<string, never>;
4
8
  /**
5
9
  * Инстанс server-компонента на клиенте.
6
10
  * Один BFF-объект может быть сериализован несколько раз с разными id (`uuid-0`, `uuid-1`, …).
@@ -15,6 +19,8 @@ export declare class ComponentInstance<ComponentType extends Componentable = Com
15
19
  constructor(
16
20
  /** Id инстанса на клиенте (обычно `target` входящего сообщения). */
17
21
  id: string, component: ComponentType);
22
+ /** Локальные действия компонента, адресованные этому instance. */
23
+ readonly local: ComponentInstanceLocalActions<ComponentType>;
18
24
  get client(): Client | undefined;
19
25
  /** Entry-инстанс дерева, внутри которого сериализован этот компонент (`entry.component` — BFF entry). */
20
26
  get entry(): ComponentInstance<EntryComponent> | undefined;
@@ -23,3 +29,4 @@ export declare class ComponentInstance<ComponentType extends Componentable = Com
23
29
  /** Закрепляет instance за client/entry после успешной сериализации конфига. */
24
30
  commitSerialization(): void;
25
31
  }
32
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentInstance = void 0;
4
+ const local_action_1 = require("../actions/local-action");
4
5
  const client_context_1 = require("../client-context");
5
6
  const entry_context_1 = require("../entry-context");
6
7
  /**
@@ -14,6 +15,9 @@ class ComponentInstance {
14
15
  this.id = id;
15
16
  this.component = component;
16
17
  this._serialized = false;
18
+ this.local = (0, local_action_1.createInstanceLocalActions)("local" in component
19
+ ? component.local
20
+ : undefined, id);
17
21
  }
18
22
  get client() {
19
23
  return this._client;
@@ -24,6 +24,8 @@ export type ContextValueRef<ValueType> = ContextRef<any, any> & {
24
24
  * Ref `R` совместим с ожидаемым типом значения `ValueType` (проверка на call site).
25
25
  */
26
26
  export type CompatibleContextValueRef<ValueType, R extends ContextRef> = ValueType extends ContextRefValue<R> ? R : never;
27
+ /** Статическое значение или ссылка на совместимое значение в контексте. */
28
+ export type ContextValueOrRef<ValueType> = ValueType | ContextValueRef<Exclude<ValueType, undefined>>;
27
29
  /**
28
30
  * Ссылка на массив элементов в контексте (`ItemType[] | undefined`).
29
31
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matreshka/bff",
3
- "version": "0.21.0",
3
+ "version": "0.22.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",
@@ -62,7 +62,7 @@
62
62
  "vitest": "^4.1.0"
63
63
  },
64
64
  "dependencies": {
65
- "@matreshka/shared": "^0.20.0",
65
+ "@matreshka/shared": "^0.21.0",
66
66
  "@simplewebauthn/server": "^13.1.1",
67
67
  "@simplewebauthn/types": "^12.0.0",
68
68
  "fast-xml-parser": "^5.3.3",
@@ -1,21 +0,0 @@
1
- import { ContextRefValue } from "../context/context-ref";
2
- import { ContextValueRef } from "../types/context-value-ref";
3
- import { ActionConfig } from "./action";
4
- import { LocalAction } from "./local-action";
5
- /**
6
- * Запись одного значения в Context на клиенте (с sync на BFF через `context-values`).
7
- *
8
- * `R` — конкретный ref; `value` имеет тип значения по этому ref.
9
- */
10
- export declare class SetContextValue<R extends ContextValueRef<unknown>> extends LocalAction {
11
- private readonly ref;
12
- private readonly value;
13
- constructor(ref: R, value: ContextRefValue<R>, config?: ActionConfig);
14
- class(): string;
15
- payload(): object;
16
- }
17
- /**
18
- * Функциональная форма {@link SetContextValue}.
19
- * Тип `value` должен совпадать с типом значения по `ref`.
20
- */
21
- export declare function setContextValue<R extends ContextValueRef<unknown>>(ref: R, value: ContextRefValue<R>, config?: ActionConfig): SetContextValue<R>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetContextValue = void 0;
4
- exports.setContextValue = setContextValue;
5
- const local_action_1 = require("./local-action");
6
- /**
7
- * Запись одного значения в Context на клиенте (с sync на BFF через `context-values`).
8
- *
9
- * `R` — конкретный ref; `value` имеет тип значения по этому ref.
10
- */
11
- class SetContextValue extends local_action_1.LocalAction {
12
- constructor(ref, value, config = {}) {
13
- super(config.conditions);
14
- this.ref = ref;
15
- this.value = value;
16
- }
17
- class() {
18
- return "set-context-value";
19
- }
20
- payload() {
21
- return {
22
- ref: this.ref,
23
- value: this.value,
24
- };
25
- }
26
- }
27
- exports.SetContextValue = SetContextValue;
28
- /**
29
- * Функциональная форма {@link SetContextValue}.
30
- * Тип `value` должен совпадать с типом значения по `ref`.
31
- */
32
- function setContextValue(ref, value, config = {}) {
33
- return new SetContextValue(ref, value, config);
34
- }
@@ -1,35 +0,0 @@
1
- import { ContextRefValue } from "../context/context-ref";
2
- import { ContextValueRef } from "../types/context-value-ref";
3
- import { ActionConfig } from "./action";
4
- import { LocalAction } from "./local-action";
5
- /**
6
- * Пара ref + value для batch-записи в Context.
7
- * Тип `value` выводится из конкретного `ref`.
8
- */
9
- export type ContextValueAssignment<R extends ContextValueRef<unknown> = ContextValueRef<unknown>> = {
10
- ref: R;
11
- value: ContextRefValue<R>;
12
- };
13
- type AssertContextValueAssignments<T extends readonly unknown[]> = {
14
- [K in keyof T]: T[K] extends {
15
- ref: infer R extends ContextValueRef<unknown>;
16
- } ? ContextValueAssignment<R> : never;
17
- };
18
- /**
19
- * Batch-запись значений в Context на клиенте (с sync на BFF через `context-values`).
20
- */
21
- export declare class SetContextValues extends LocalAction {
22
- private readonly values;
23
- constructor(values: readonly ContextValueAssignment[], config?: ActionConfig);
24
- class(): string;
25
- payload(): object;
26
- }
27
- /**
28
- * Функциональная форма {@link SetContextValues}.
29
- * У каждого элемента массива тип `value` должен совпадать с типом значения по `ref`.
30
- */
31
- export declare function setContextValues<const T extends readonly [
32
- ContextValueAssignment,
33
- ...ContextValueAssignment[]
34
- ]>(values: AssertContextValueAssignments<T> & T, config?: ActionConfig): SetContextValues;
35
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetContextValues = void 0;
4
- exports.setContextValues = setContextValues;
5
- const local_action_1 = require("./local-action");
6
- /**
7
- * Batch-запись значений в Context на клиенте (с sync на BFF через `context-values`).
8
- */
9
- class SetContextValues extends local_action_1.LocalAction {
10
- constructor(values, config = {}) {
11
- super(config.conditions);
12
- this.values = values;
13
- }
14
- class() {
15
- return "set-context-values";
16
- }
17
- payload() {
18
- return {
19
- values: this.values.map(({ ref, value }) => ({ ref, value })),
20
- };
21
- }
22
- }
23
- exports.SetContextValues = SetContextValues;
24
- /**
25
- * Функциональная форма {@link SetContextValues}.
26
- * У каждого элемента массива тип `value` должен совпадать с типом значения по `ref`.
27
- */
28
- function setContextValues(values, config = {}) {
29
- return new SetContextValues(values, config);
30
- }