@matreshka/bff 0.19.0 → 0.21.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 (36) hide show
  1. package/dist/components/board.d.ts +4 -4
  2. package/dist/components/board.js +4 -40
  3. package/dist/components/camera.d.ts +1 -1
  4. package/dist/components/camera.js +2 -15
  5. package/dist/components/component.d.ts +9 -4
  6. package/dist/components/component.js +16 -0
  7. package/dist/components/dialog.d.ts +1 -1
  8. package/dist/components/dialog.js +1 -10
  9. package/dist/components/for-each.d.ts +3 -3
  10. package/dist/components/for-each.js +18 -26
  11. package/dist/components/inputs/text-editor.d.ts +14 -14
  12. package/dist/components/inputs/text-editor.js +14 -154
  13. package/dist/components/item-list/item-list.js +11 -11
  14. package/dist/components/item-list/list-from-ref-context.d.ts +4 -1
  15. package/dist/components/item-list/list-from-ref-context.js +6 -4
  16. package/dist/components/item-list/types.d.ts +5 -5
  17. package/dist/components/item-list/types.js +1 -1
  18. package/dist/components/map.d.ts +4 -4
  19. package/dist/components/map.js +4 -40
  20. package/dist/components/popover.d.ts +1 -1
  21. package/dist/components/popover.js +1 -10
  22. package/dist/components/stack.d.ts +1 -1
  23. package/dist/components/stack.js +2 -17
  24. package/dist/components/utils/targeted-client-component-action.d.ts +5 -0
  25. package/dist/components/utils/targeted-client-component-action.js +25 -0
  26. package/dist/core/context/context-ref.d.ts +5 -4
  27. package/dist/core/context/context-ref.js +9 -8
  28. package/dist/core/context/context.d.ts +42 -10
  29. package/dist/core/context/context.js +76 -13
  30. package/dist/core/types/context-value-ref.d.ts +3 -3
  31. package/dist/core/utils/replace-context-keys.js +1 -2
  32. package/dist/core/utils/targeted-client-action.d.ts +19 -0
  33. package/dist/core/utils/targeted-client-action.js +68 -0
  34. package/dist/platforms/utils/targeted-client-platform-action.js +9 -64
  35. package/dist/platforms/utils/targeted-client-platform-stream.js +2 -2
  36. package/package.json +2 -2
@@ -0,0 +1,19 @@
1
+ import { AnyClientToBffMessage } from "@matreshka/shared/messages/client-to-bff/client-to-bff-message";
2
+ import { Client } from "../client";
3
+ export type TargetedClientActionTerminal<T> = {
4
+ next: (value: T) => void;
5
+ error: (error: Error) => void;
6
+ complete: () => void;
7
+ closed: () => boolean;
8
+ };
9
+ export type TargetedClientActionConfig<T> = {
10
+ scopePrefix: string;
11
+ start: (scope: string, client: Client) => void;
12
+ parseSuccess?: (unsafeMessage: AnyClientToBffMessage) => T | undefined;
13
+ parseFailure?: (unsafeMessage: AnyClientToBffMessage) => Error | undefined;
14
+ };
15
+ export declare function createTargetedActionScope(prefix: string): string;
16
+ export declare function startTargetedClientAction<T>(client: Client, config: TargetedClientActionConfig<T>, terminal: TargetedClientActionTerminal<T>): {
17
+ scope: string;
18
+ teardown: () => void;
19
+ };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTargetedActionScope = createTargetedActionScope;
4
+ exports.startTargetedClientAction = startTargetedClientAction;
5
+ const action_completed_message_1 = require("@matreshka/shared/messages/client-to-bff/action-completed-message");
6
+ const error_message_1 = require("@matreshka/shared/messages/client-to-bff/error-message");
7
+ const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
8
+ const rxjs_1 = require("rxjs");
9
+ const v4_1 = require("zod/v4");
10
+ const incoming_message_observer_1 = require("./incoming-message-observer");
11
+ const errorMessagePayloadSchema = v4_1.z.strictObject({
12
+ message: v4_1.z.string(),
13
+ });
14
+ function createTargetedActionScope(prefix) {
15
+ return prefix + crypto.randomUUID();
16
+ }
17
+ function startTargetedClientAction(client, config, terminal) {
18
+ const scope = createTargetedActionScope(config.scopePrefix);
19
+ let finalized = false;
20
+ const teardown = () => {
21
+ if (finalized) {
22
+ return;
23
+ }
24
+ finalized = true;
25
+ subscription.unsubscribe();
26
+ destroySubscription.unsubscribe();
27
+ };
28
+ const finish = (notify) => {
29
+ notify();
30
+ teardown();
31
+ };
32
+ const subscription = client.incomingMessage$
33
+ .pipe((0, rxjs_1.filter)((unsafeMessage) => (0, targeted_message_1.isTargetedMessage)(unsafeMessage) && unsafeMessage.target === scope), (0, rxjs_1.take)(1))
34
+ .subscribe((0, incoming_message_observer_1.incomingMessageObserver)(client, (unsafeMessage) => {
35
+ if (unsafeMessage instanceof error_message_1.ErrorMessage) {
36
+ const messagePayload = errorMessagePayloadSchema.parse(unsafeMessage.payload);
37
+ finish(() => terminal.error(new Error(messagePayload.message)));
38
+ return;
39
+ }
40
+ if (unsafeMessage instanceof action_completed_message_1.ActionCompletedMessage) {
41
+ finish(() => {
42
+ terminal.next(undefined);
43
+ terminal.complete();
44
+ });
45
+ return;
46
+ }
47
+ const failure = config.parseFailure?.(unsafeMessage);
48
+ if (failure) {
49
+ finish(() => terminal.error(failure));
50
+ return;
51
+ }
52
+ const value = config.parseSuccess?.(unsafeMessage);
53
+ if (value !== undefined) {
54
+ finish(() => {
55
+ terminal.next(value);
56
+ terminal.complete();
57
+ });
58
+ }
59
+ }));
60
+ const destroySubscription = client.destroy$.subscribe(() => {
61
+ if (!terminal.closed()) {
62
+ terminal.complete();
63
+ }
64
+ teardown();
65
+ });
66
+ config.start(scope, client);
67
+ return { scope, teardown };
68
+ }
@@ -1,72 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.targetedClientPlatformAction = targetedClientPlatformAction;
4
- const error_message_1 = require("@matreshka/shared/messages/client-to-bff/error-message");
5
- const platform_action_completed_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/platform-action-completed-message");
6
- const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
7
4
  const rxjs_1 = require("rxjs");
8
- const v4_1 = require("zod/v4");
9
- const incoming_message_observer_1 = require("../../core/utils/incoming-message-observer");
10
- const errorMessagePayloadSchema = v4_1.z.strictObject({
11
- message: v4_1.z.string(),
12
- });
13
- function startTargetedClientPlatformAction(client, config, terminal) {
14
- const scope = "platform-action-" + crypto.randomUUID();
15
- let finalized = false;
16
- const teardown = () => {
17
- if (finalized) {
18
- return;
19
- }
20
- finalized = true;
21
- subscription.unsubscribe();
22
- destroySubscription.unsubscribe();
23
- };
24
- const finish = (notify) => {
25
- notify();
26
- teardown();
27
- };
28
- const subscription = client.incomingMessage$
29
- .pipe((0, rxjs_1.filter)((unsafeMessage) => (0, targeted_message_1.isTargetedMessage)(unsafeMessage) && unsafeMessage.target === scope), (0, rxjs_1.take)(1))
30
- .subscribe((0, incoming_message_observer_1.incomingMessageObserver)(client, (unsafeMessage) => {
31
- if (unsafeMessage instanceof error_message_1.ErrorMessage) {
32
- const messagePayload = errorMessagePayloadSchema.parse(unsafeMessage.payload);
33
- finish(() => terminal.error(new Error(messagePayload.message)));
34
- return;
35
- }
36
- if (unsafeMessage instanceof platform_action_completed_message_1.PlatformActionCompletedMessage) {
37
- finish(() => {
38
- terminal.next(undefined);
39
- terminal.complete();
40
- });
41
- return;
42
- }
43
- const failure = config.parseFailure?.(unsafeMessage);
44
- if (failure) {
45
- finish(() => terminal.error(failure));
46
- return;
47
- }
48
- const value = config.parseSuccess?.(unsafeMessage);
49
- if (value !== undefined) {
50
- finish(() => {
51
- terminal.next(value);
52
- terminal.complete();
53
- });
54
- }
55
- }));
56
- const destroySubscription = client.destroy$.subscribe(() => {
57
- if (!terminal.closed()) {
58
- terminal.complete();
59
- }
60
- teardown();
61
- });
62
- const start = () => {
63
- client.outcomingMessage$.next(config.outgoingMessage(scope));
64
- };
65
- return { start, teardown };
66
- }
5
+ const targeted_client_action_1 = require("../../core/utils/targeted-client-action");
67
6
  function targetedClientPlatformAction(client, config) {
68
7
  const result$ = new rxjs_1.ReplaySubject(1);
69
- const { start } = startTargetedClientPlatformAction(client, config, {
8
+ (0, targeted_client_action_1.startTargetedClientAction)(client, {
9
+ scopePrefix: "platform-action-",
10
+ start: (scope) => {
11
+ client.outcomingMessage$.next(config.outgoingMessage(scope));
12
+ },
13
+ parseSuccess: config.parseSuccess,
14
+ parseFailure: config.parseFailure,
15
+ }, {
70
16
  next: (value) => {
71
17
  result$.next(value);
72
18
  result$.complete();
@@ -75,6 +21,5 @@ function targetedClientPlatformAction(client, config) {
75
21
  complete: () => result$.complete(),
76
22
  closed: () => result$.closed,
77
23
  });
78
- start();
79
24
  return result$.asObservable();
80
25
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.targetedClientPlatformStream = targetedClientPlatformStream;
4
+ const action_completed_message_1 = require("@matreshka/shared/messages/client-to-bff/action-completed-message");
4
5
  const error_message_1 = require("@matreshka/shared/messages/client-to-bff/error-message");
5
- const platform_action_completed_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/platform-action-completed-message");
6
6
  const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
7
7
  const rxjs_1 = require("rxjs");
8
8
  const v4_1 = require("zod/v4");
@@ -59,7 +59,7 @@ function targetedClientPlatformStream(client, config) {
59
59
  finishWithError(failure);
60
60
  return;
61
61
  }
62
- if (unsafeMessage instanceof platform_action_completed_message_1.PlatformActionCompletedMessage) {
62
+ if (unsafeMessage instanceof action_completed_message_1.ActionCompletedMessage) {
63
63
  finishComplete();
64
64
  return;
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matreshka/bff",
3
- "version": "0.19.0",
3
+ "version": "0.21.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.19.0",
65
+ "@matreshka/shared": "^0.20.0",
66
66
  "@simplewebauthn/server": "^13.1.1",
67
67
  "@simplewebauthn/types": "^12.0.0",
68
68
  "fast-xml-parser": "^5.3.3",