@matreshka/bff 0.12.0 → 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.
@@ -43,6 +43,11 @@ export declare class ContextRef<ContextType extends JsonObject = any, PathType e
43
43
  */
44
44
  strictRef<OtherContextType extends JsonObject, OtherPathType extends Paths<OtherContextType>>(other: ContextRef<OtherContextType, OtherPathType>): ContextRef<ContextType, `${PathType}.${PathValue<OtherContextType, OtherPathType> & string}`>;
45
45
  value(): PathValue<ContextType, PathType>;
46
+ /**
47
+ * Запись значения по текущему пути через {@link Context.setValue}.
48
+ * Если контекст уже уничтожен, вызов игнорируется (без исключения).
49
+ */
50
+ setValue(value: PathValue<ContextType, PathType>): void;
46
51
  toString(): string;
47
52
  toJSON(): string;
48
53
  }
@@ -47,6 +47,16 @@ class ContextRef {
47
47
  // Явно выбираем перегрузку Context.value(string): unknown и приводим к ожидаемому типу
48
48
  return this.context.value(this.path);
49
49
  }
50
+ /**
51
+ * Запись значения по текущему пути через {@link Context.setValue}.
52
+ * Если контекст уже уничтожен, вызов игнорируется (без исключения).
53
+ */
54
+ setValue(value) {
55
+ if (this.context.isDestroyed()) {
56
+ return;
57
+ }
58
+ this.context.setValue(this.path, value);
59
+ }
50
60
  toString() {
51
61
  return `@{${this.context.id}.${this.path}}`;
52
62
  }
@@ -18,6 +18,7 @@ import { ContextRef, ContextRefValue } from "../context/context-ref";
18
18
  export type ContextValueRef<ValueType> = ContextRef<any, any> & {
19
19
  readonly __valueType?: ValueType;
20
20
  value(): ValueType;
21
+ setValue(value: ValueType): void;
21
22
  };
22
23
  /**
23
24
  * Ref `R` совместим с ожидаемым типом значения `ValueType` (проверка на call site).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matreshka/bff",
3
- "version": "0.12.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",