@matreshka/bff 0.23.1 → 0.24.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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Client } from "../core/client";
|
|
2
1
|
import type { ComponentInstance } from "../core/types/component-instance";
|
|
3
2
|
import type { Componentable } from "../core/types/componentable";
|
|
4
3
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
@@ -29,6 +28,6 @@ export declare abstract class EntryComponent<InitConfigType extends EntryCompone
|
|
|
29
28
|
/** Контекст сериализации дочерних компонентов без полной serialize entry. @internal */
|
|
30
29
|
beginSerializationContext(): ComponentInstance<this>;
|
|
31
30
|
protected createSelfEntry(): ComponentInstance<this>;
|
|
32
|
-
|
|
31
|
+
protected emitInteraction(type: string, payload: unknown, instance: ComponentInstance<this>, handlers: number[]): void;
|
|
33
32
|
}
|
|
34
33
|
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntryComponent = void 0;
|
|
4
|
-
const app_destroy_entry_instance_message_1 = require("@matreshka/shared/messages/client-to-bff/app/app-destroy-entry-instance-message");
|
|
5
|
-
const rxjs_1 = require("rxjs");
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
4
|
const client_context_1 = require("../core/client-context");
|
|
8
5
|
const entry_context_1 = require("../core/entry-context");
|
|
9
|
-
const incoming_message_observer_1 = require("../core/utils/incoming-message-observer");
|
|
10
6
|
const component_1 = require("./component");
|
|
11
7
|
/**
|
|
12
8
|
* Абстрактный компонент-входная точка, наследует поведение базового Component
|
|
@@ -46,29 +42,17 @@ class EntryComponent extends component_1.Component {
|
|
|
46
42
|
createSelfEntry() {
|
|
47
43
|
const instance = super.createSelfEntry();
|
|
48
44
|
const client = (0, client_context_1.currentClient)();
|
|
49
|
-
//
|
|
45
|
+
// Подписка на leave и прочие interaction до commitSerialization instance.entry.
|
|
50
46
|
if (!this.usingByClient(client)) {
|
|
51
47
|
this.subscribeClientEvents(client);
|
|
52
48
|
}
|
|
53
49
|
return instance;
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
super.
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
const messagePayload = zod_1.z
|
|
61
|
-
.object({ id: zod_1.z.string() })
|
|
62
|
-
.parse(unsafeMessage.payload);
|
|
63
|
-
const instanceIndex = this.instances.findIndex((instance) => instance.id === messagePayload.id);
|
|
64
|
-
if (instanceIndex === -1) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (this.instances[instanceIndex].client !== client) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this.releaseInstances([this.instances[instanceIndex]]);
|
|
71
|
-
})));
|
|
51
|
+
emitInteraction(type, payload, instance, handlers) {
|
|
52
|
+
super.emitInteraction(type, payload, instance, handlers);
|
|
53
|
+
if (type === "leave") {
|
|
54
|
+
this.releaseInstances([instance]);
|
|
55
|
+
}
|
|
72
56
|
}
|
|
73
57
|
}
|
|
74
58
|
exports.EntryComponent = EntryComponent;
|
package/dist/core/client.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare class Client {
|
|
|
57
57
|
app: App;
|
|
58
58
|
/**
|
|
59
59
|
* Id страницы, для которой при навигации нужно снять обработчики предыдущей страницы.
|
|
60
|
-
* Диалоги/popover/оверлеи сюда не входят — их снимают по
|
|
60
|
+
* Диалоги/popover/оверлеи сюда не входят — их снимают по leave interaction или removeGlobalComponent.
|
|
61
61
|
*/
|
|
62
62
|
private currentPageInstance?;
|
|
63
63
|
private appOverlayEntry?;
|
package/dist/core/client.js
CHANGED
|
@@ -198,6 +198,7 @@ class Client {
|
|
|
198
198
|
* Переход на другую страницу: снимает обработчики с предыдущей страницы и запоминает id новой.
|
|
199
199
|
*/
|
|
200
200
|
switchPage(newPageInstance) {
|
|
201
|
+
// Вообще эта логика не обязательна, т.к. releaseInstances вызывается при получении leave interaction, это скорее защита от недобросовестных клиентов чтобы не копились лишние обработчики в памяти
|
|
201
202
|
this.currentPageInstance?.component.releaseInstances([
|
|
202
203
|
this.currentPageInstance,
|
|
203
204
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matreshka/bff",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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.22.
|
|
65
|
+
"@matreshka/shared": "^0.22.2",
|
|
66
66
|
"@simplewebauthn/server": "^13.1.1",
|
|
67
67
|
"@simplewebauthn/types": "^12.0.0",
|
|
68
68
|
"fast-xml-parser": "^5.3.3",
|