react-native-fxview 1.0.2 → 1.0.3-beta2
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/FXCategoryController.js +24 -20
- package/FXCategoryController.ts +21 -20
- package/FXView.js +9 -5
- package/FXView.tsx +6 -5
- package/FXViewController.js +21 -17
- package/FXViewController.ts +18 -17
- package/FXViewManager.d.ts +10 -0
- package/FXViewManager.js +40 -28
- package/FXViewManager.ts +45 -28
- package/index.d.ts +2 -3
- package/index.js +4 -6
- package/index.ts +2 -3
- package/logger/FXLogger-README.md +248 -0
- package/logger/FXLogger.d.ts +109 -0
- package/logger/FXLogger.js +239 -0
- package/logger/FXLogger.ts +282 -0
- package/package.json +9 -1
- package/queue/PriorityQueue.d.ts +153 -0
- package/queue/PriorityQueue.js +325 -0
- package/queue/PriorityQueue.ts +367 -0
- package/types.ts +1 -1
package/FXCategoryController.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.FXCategoryController = void 0;
|
|
4
7
|
const PriorityQueue_1 = require("./queue/PriorityQueue");
|
|
8
|
+
const FXLogger_1 = __importDefault(require("./logger/FXLogger"));
|
|
5
9
|
class FXCategoryController {
|
|
6
10
|
constructor(fxViewId, categoryId, triggerUpdate) {
|
|
7
11
|
// 存储组件的 Map 和优先队列
|
|
@@ -19,11 +23,11 @@ class FXCategoryController {
|
|
|
19
23
|
* @returns 组件控制器
|
|
20
24
|
*/
|
|
21
25
|
add(component, componentId) {
|
|
22
|
-
|
|
26
|
+
FXLogger_1.default.info(`FXViewCategoryController.add`, `[${this.categoryId}]`, componentId);
|
|
23
27
|
const finalComponentId = componentId || this.autoComponentId();
|
|
24
28
|
// 如果组件已存在,先移除旧的
|
|
25
29
|
if (this.componentMap.has(finalComponentId)) {
|
|
26
|
-
|
|
30
|
+
FXLogger_1.default.warn(`Component ${finalComponentId} already exists, removing old one`);
|
|
27
31
|
this.remove(finalComponentId);
|
|
28
32
|
}
|
|
29
33
|
const componentItem = {
|
|
@@ -43,11 +47,11 @@ class FXCategoryController {
|
|
|
43
47
|
* @returns 组件控制器
|
|
44
48
|
*/
|
|
45
49
|
build(component, componentId) {
|
|
46
|
-
|
|
50
|
+
FXLogger_1.default.info(`FXViewCategoryController.build`, `[${this.categoryId}]`, componentId);
|
|
47
51
|
const finalComponentId = componentId || this.autoComponentId();
|
|
48
52
|
// 如果组件已存在,先移除旧的
|
|
49
53
|
if (this.componentMap.has(finalComponentId)) {
|
|
50
|
-
|
|
54
|
+
FXLogger_1.default.warn(`Component ${finalComponentId} already exists, removing old one`);
|
|
51
55
|
this.remove(finalComponentId);
|
|
52
56
|
}
|
|
53
57
|
const componentItem = {
|
|
@@ -66,15 +70,15 @@ class FXCategoryController {
|
|
|
66
70
|
* @param componentId 组件 ID
|
|
67
71
|
*/
|
|
68
72
|
show(componentId) {
|
|
69
|
-
|
|
73
|
+
FXLogger_1.default.info(`FXViewCategoryController.show`, `[${this.categoryId}]`, componentId);
|
|
70
74
|
const componentItem = this.componentMap.get(componentId);
|
|
71
75
|
if (!componentItem) {
|
|
72
|
-
|
|
76
|
+
FXLogger_1.default.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
73
77
|
return;
|
|
74
78
|
}
|
|
75
79
|
// 如果已经可见,不需要重复操作
|
|
76
80
|
if (componentItem.visible) {
|
|
77
|
-
|
|
81
|
+
FXLogger_1.default.info(`Component ${componentId} is already visible`);
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
84
|
componentItem.visible = true;
|
|
@@ -85,15 +89,15 @@ class FXCategoryController {
|
|
|
85
89
|
* @param componentId 组件 ID
|
|
86
90
|
*/
|
|
87
91
|
hide(componentId) {
|
|
88
|
-
|
|
92
|
+
FXLogger_1.default.info(`FXViewCategoryController.hide`, `[${this.categoryId}]`, componentId);
|
|
89
93
|
const componentItem = this.componentMap.get(componentId);
|
|
90
94
|
if (!componentItem) {
|
|
91
|
-
|
|
95
|
+
FXLogger_1.default.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
92
96
|
return;
|
|
93
97
|
}
|
|
94
98
|
// 如果已经隐藏,不需要重复操作
|
|
95
99
|
if (!componentItem.visible) {
|
|
96
|
-
|
|
100
|
+
FXLogger_1.default.info(`Component ${componentId} is already hidden`);
|
|
97
101
|
return;
|
|
98
102
|
}
|
|
99
103
|
componentItem.visible = false;
|
|
@@ -105,10 +109,10 @@ class FXCategoryController {
|
|
|
105
109
|
* @param component 新的组件内容
|
|
106
110
|
*/
|
|
107
111
|
update(componentId, component) {
|
|
108
|
-
|
|
112
|
+
FXLogger_1.default.info(`FXViewCategoryController.update`, `[${this.categoryId}]`, componentId);
|
|
109
113
|
const componentItem = this.componentMap.get(componentId);
|
|
110
114
|
if (!componentItem) {
|
|
111
|
-
|
|
115
|
+
FXLogger_1.default.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
112
116
|
return;
|
|
113
117
|
}
|
|
114
118
|
// 更新组件内容
|
|
@@ -118,7 +122,7 @@ class FXCategoryController {
|
|
|
118
122
|
this.triggerUpdate();
|
|
119
123
|
}
|
|
120
124
|
else {
|
|
121
|
-
|
|
125
|
+
FXLogger_1.default.info(`Component ${componentId} is hidden, update without re-render`);
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
@@ -126,10 +130,10 @@ class FXCategoryController {
|
|
|
126
130
|
* @param componentId 组件 ID(必需)
|
|
127
131
|
*/
|
|
128
132
|
remove(componentId) {
|
|
129
|
-
|
|
133
|
+
FXLogger_1.default.info(`FXViewCategoryController.remove`, `[${this.categoryId}]`, componentId);
|
|
130
134
|
const componentItem = this.componentMap.get(componentId);
|
|
131
135
|
if (!componentItem) {
|
|
132
|
-
|
|
136
|
+
FXLogger_1.default.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
135
139
|
// 从 Map 中删除
|
|
@@ -142,10 +146,10 @@ class FXCategoryController {
|
|
|
142
146
|
* 移除最后一个组件(可选:用于向后兼容)
|
|
143
147
|
*/
|
|
144
148
|
removeLast() {
|
|
145
|
-
|
|
149
|
+
FXLogger_1.default.info(`FXViewCategoryController.removeLast`, `[${this.categoryId}]`);
|
|
146
150
|
const lastComponent = this.componentQueue.peek();
|
|
147
151
|
if (!lastComponent) {
|
|
148
|
-
|
|
152
|
+
FXLogger_1.default.warn(`No component to remove in category ${this.categoryId}`);
|
|
149
153
|
return;
|
|
150
154
|
}
|
|
151
155
|
this.remove(lastComponent.componentId);
|
|
@@ -154,7 +158,7 @@ class FXCategoryController {
|
|
|
154
158
|
* 清空所有组件
|
|
155
159
|
*/
|
|
156
160
|
clearAll() {
|
|
157
|
-
|
|
161
|
+
FXLogger_1.default.info(`FXViewCategoryController.clearAll`, `[${this.categoryId}]`);
|
|
158
162
|
const hadVisibleComponents = Array.from(this.componentMap.values()).some((item) => item.visible);
|
|
159
163
|
this.componentMap.clear();
|
|
160
164
|
this.componentQueue.clear();
|
|
@@ -215,7 +219,7 @@ class FXCategoryController {
|
|
|
215
219
|
* 触发更新
|
|
216
220
|
*/
|
|
217
221
|
triggerUpdate() {
|
|
218
|
-
|
|
222
|
+
FXLogger_1.default.info(`FXViewCategoryController.triggerUpdate`, `[${this.categoryId}]`);
|
|
219
223
|
if (this.updateCallback) {
|
|
220
224
|
this.updateCallback();
|
|
221
225
|
}
|
|
@@ -226,7 +230,7 @@ class FXCategoryController {
|
|
|
226
230
|
* @returns 组件控制器
|
|
227
231
|
*/
|
|
228
232
|
createController(componentId) {
|
|
229
|
-
|
|
233
|
+
FXLogger_1.default.info(`FXViewCategoryController.createController`, `[${this.categoryId}]`, componentId);
|
|
230
234
|
// ✅ 修复:不在闭包中捕获 componentItem,每次都从 Map 获取最新引用
|
|
231
235
|
return {
|
|
232
236
|
show: () => {
|
package/FXCategoryController.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FXComponentItem, FXComponentController } from "./types";
|
|
3
3
|
import { HeapType, PriorityOrder, PriorityQueue } from "./queue/PriorityQueue";
|
|
4
|
+
import logger from "./logger/FXLogger";
|
|
4
5
|
|
|
5
6
|
export class FXCategoryController {
|
|
6
7
|
public fxViewId: string;
|
|
@@ -33,7 +34,7 @@ export class FXCategoryController {
|
|
|
33
34
|
* @returns 组件控制器
|
|
34
35
|
*/
|
|
35
36
|
add(component: React.ReactNode, componentId?: string): FXComponentController {
|
|
36
|
-
|
|
37
|
+
logger.info(
|
|
37
38
|
`FXViewCategoryController.add`,
|
|
38
39
|
`[${this.categoryId}]`,
|
|
39
40
|
componentId,
|
|
@@ -43,7 +44,7 @@ export class FXCategoryController {
|
|
|
43
44
|
|
|
44
45
|
// 如果组件已存在,先移除旧的
|
|
45
46
|
if (this.componentMap.has(finalComponentId)) {
|
|
46
|
-
|
|
47
|
+
logger.warn(
|
|
47
48
|
`Component ${finalComponentId} already exists, removing old one`,
|
|
48
49
|
);
|
|
49
50
|
this.remove(finalComponentId);
|
|
@@ -72,7 +73,7 @@ export class FXCategoryController {
|
|
|
72
73
|
component: React.ReactNode,
|
|
73
74
|
componentId?: string,
|
|
74
75
|
): FXComponentController {
|
|
75
|
-
|
|
76
|
+
logger.info(
|
|
76
77
|
`FXViewCategoryController.build`,
|
|
77
78
|
`[${this.categoryId}]`,
|
|
78
79
|
componentId,
|
|
@@ -82,7 +83,7 @@ export class FXCategoryController {
|
|
|
82
83
|
|
|
83
84
|
// 如果组件已存在,先移除旧的
|
|
84
85
|
if (this.componentMap.has(finalComponentId)) {
|
|
85
|
-
|
|
86
|
+
logger.warn(
|
|
86
87
|
`Component ${finalComponentId} already exists, removing old one`,
|
|
87
88
|
);
|
|
88
89
|
this.remove(finalComponentId);
|
|
@@ -108,7 +109,7 @@ export class FXCategoryController {
|
|
|
108
109
|
* @param componentId 组件 ID
|
|
109
110
|
*/
|
|
110
111
|
show(componentId: string): void {
|
|
111
|
-
|
|
112
|
+
logger.info(
|
|
112
113
|
`FXViewCategoryController.show`,
|
|
113
114
|
`[${this.categoryId}]`,
|
|
114
115
|
componentId,
|
|
@@ -117,7 +118,7 @@ export class FXCategoryController {
|
|
|
117
118
|
const componentItem = this.componentMap.get(componentId);
|
|
118
119
|
|
|
119
120
|
if (!componentItem) {
|
|
120
|
-
|
|
121
|
+
logger.warn(
|
|
121
122
|
`Component ${componentId} not found in category ${this.categoryId}`,
|
|
122
123
|
);
|
|
123
124
|
return;
|
|
@@ -125,7 +126,7 @@ export class FXCategoryController {
|
|
|
125
126
|
|
|
126
127
|
// 如果已经可见,不需要重复操作
|
|
127
128
|
if (componentItem.visible) {
|
|
128
|
-
|
|
129
|
+
logger.info(`Component ${componentId} is already visible`);
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -138,7 +139,7 @@ export class FXCategoryController {
|
|
|
138
139
|
* @param componentId 组件 ID
|
|
139
140
|
*/
|
|
140
141
|
hide(componentId: string): void {
|
|
141
|
-
|
|
142
|
+
logger.info(
|
|
142
143
|
`FXViewCategoryController.hide`,
|
|
143
144
|
`[${this.categoryId}]`,
|
|
144
145
|
componentId,
|
|
@@ -147,7 +148,7 @@ export class FXCategoryController {
|
|
|
147
148
|
const componentItem = this.componentMap.get(componentId);
|
|
148
149
|
|
|
149
150
|
if (!componentItem) {
|
|
150
|
-
|
|
151
|
+
logger.warn(
|
|
151
152
|
`Component ${componentId} not found in category ${this.categoryId}`,
|
|
152
153
|
);
|
|
153
154
|
return;
|
|
@@ -155,7 +156,7 @@ export class FXCategoryController {
|
|
|
155
156
|
|
|
156
157
|
// 如果已经隐藏,不需要重复操作
|
|
157
158
|
if (!componentItem.visible) {
|
|
158
|
-
|
|
159
|
+
logger.info(`Component ${componentId} is already hidden`);
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -169,7 +170,7 @@ export class FXCategoryController {
|
|
|
169
170
|
* @param component 新的组件内容
|
|
170
171
|
*/
|
|
171
172
|
update(componentId: string, component: React.ReactNode): void {
|
|
172
|
-
|
|
173
|
+
logger.info(
|
|
173
174
|
`FXViewCategoryController.update`,
|
|
174
175
|
`[${this.categoryId}]`,
|
|
175
176
|
componentId,
|
|
@@ -178,7 +179,7 @@ export class FXCategoryController {
|
|
|
178
179
|
const componentItem = this.componentMap.get(componentId);
|
|
179
180
|
|
|
180
181
|
if (!componentItem) {
|
|
181
|
-
|
|
182
|
+
logger.warn(
|
|
182
183
|
`Component ${componentId} not found in category ${this.categoryId}`,
|
|
183
184
|
);
|
|
184
185
|
return;
|
|
@@ -191,7 +192,7 @@ export class FXCategoryController {
|
|
|
191
192
|
if (componentItem.visible) {
|
|
192
193
|
this.triggerUpdate();
|
|
193
194
|
} else {
|
|
194
|
-
|
|
195
|
+
logger.info(
|
|
195
196
|
`Component ${componentId} is hidden, update without re-render`,
|
|
196
197
|
);
|
|
197
198
|
}
|
|
@@ -202,7 +203,7 @@ export class FXCategoryController {
|
|
|
202
203
|
* @param componentId 组件 ID(必需)
|
|
203
204
|
*/
|
|
204
205
|
remove(componentId: string): void {
|
|
205
|
-
|
|
206
|
+
logger.info(
|
|
206
207
|
`FXViewCategoryController.remove`,
|
|
207
208
|
`[${this.categoryId}]`,
|
|
208
209
|
componentId,
|
|
@@ -211,7 +212,7 @@ export class FXCategoryController {
|
|
|
211
212
|
const componentItem = this.componentMap.get(componentId);
|
|
212
213
|
|
|
213
214
|
if (!componentItem) {
|
|
214
|
-
|
|
215
|
+
logger.warn(
|
|
215
216
|
`Component ${componentId} not found in category ${this.categoryId}`,
|
|
216
217
|
);
|
|
217
218
|
return;
|
|
@@ -230,12 +231,12 @@ export class FXCategoryController {
|
|
|
230
231
|
* 移除最后一个组件(可选:用于向后兼容)
|
|
231
232
|
*/
|
|
232
233
|
removeLast(): void {
|
|
233
|
-
|
|
234
|
+
logger.info(`FXViewCategoryController.removeLast`, `[${this.categoryId}]`);
|
|
234
235
|
|
|
235
236
|
const lastComponent = this.componentQueue.peek();
|
|
236
237
|
|
|
237
238
|
if (!lastComponent) {
|
|
238
|
-
|
|
239
|
+
logger.warn(`No component to remove in category ${this.categoryId}`);
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
242
|
|
|
@@ -246,7 +247,7 @@ export class FXCategoryController {
|
|
|
246
247
|
* 清空所有组件
|
|
247
248
|
*/
|
|
248
249
|
clearAll(): void {
|
|
249
|
-
|
|
250
|
+
logger.info(`FXViewCategoryController.clearAll`, `[${this.categoryId}]`);
|
|
250
251
|
|
|
251
252
|
const hadVisibleComponents = Array.from(this.componentMap.values()).some(
|
|
252
253
|
(item) => item.visible,
|
|
@@ -319,7 +320,7 @@ export class FXCategoryController {
|
|
|
319
320
|
* 触发更新
|
|
320
321
|
*/
|
|
321
322
|
private triggerUpdate(): void {
|
|
322
|
-
|
|
323
|
+
logger.info(
|
|
323
324
|
`FXViewCategoryController.triggerUpdate`,
|
|
324
325
|
`[${this.categoryId}]`,
|
|
325
326
|
);
|
|
@@ -335,7 +336,7 @@ export class FXCategoryController {
|
|
|
335
336
|
* @returns 组件控制器
|
|
336
337
|
*/
|
|
337
338
|
private createController(componentId: string): FXComponentController {
|
|
338
|
-
|
|
339
|
+
logger.info(
|
|
339
340
|
`FXViewCategoryController.createController`,
|
|
340
341
|
`[${this.categoryId}]`,
|
|
341
342
|
componentId,
|
package/FXView.js
CHANGED
|
@@ -43,10 +43,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
43
43
|
}
|
|
44
44
|
return t;
|
|
45
45
|
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
46
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
50
|
const react_1 = __importStar(require("react"));
|
|
48
51
|
const react_native_1 = require("react-native");
|
|
49
52
|
const FXViewManager_1 = require("./FXViewManager");
|
|
53
|
+
const FXLogger_1 = __importDefault(require("./logger/FXLogger"));
|
|
50
54
|
class FXView extends react_1.Component {
|
|
51
55
|
constructor(props) {
|
|
52
56
|
super(props);
|
|
@@ -63,18 +67,18 @@ class FXView extends react_1.Component {
|
|
|
63
67
|
`auto_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
64
68
|
}
|
|
65
69
|
componentDidMount() {
|
|
66
|
-
|
|
70
|
+
FXLogger_1.default.log("FXView", `mounted with viewId: ${this.viewId}`);
|
|
67
71
|
// 注册到视图管理器
|
|
68
72
|
FXViewManager_1.FXViewManager.getInstance().registerView(this.viewId, this.updateComponents);
|
|
69
73
|
// 初始更新
|
|
70
74
|
this.updateComponents();
|
|
71
75
|
}
|
|
72
76
|
componentDidUpdate(_prevProps) {
|
|
73
|
-
|
|
77
|
+
FXLogger_1.default.log("FXView", `updated: ${this.viewId}`);
|
|
74
78
|
const newViewId = this.props.fxViewId || this.viewId;
|
|
75
79
|
if (newViewId !== this.viewId) {
|
|
76
80
|
// ID 变化时重新注册
|
|
77
|
-
|
|
81
|
+
FXLogger_1.default.log("FXView", `updated changed: ${this.viewId}`);
|
|
78
82
|
FXViewManager_1.FXViewManager.getInstance().unregisterView(this.viewId);
|
|
79
83
|
this.viewId = newViewId;
|
|
80
84
|
FXViewManager_1.FXViewManager.getInstance().registerView(this.viewId, this.updateComponents);
|
|
@@ -82,7 +86,7 @@ class FXView extends react_1.Component {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
componentWillUnmount() {
|
|
85
|
-
|
|
89
|
+
FXLogger_1.default.log("FXView", `unmounted: ${this.viewId}`);
|
|
86
90
|
// 注销视图(会自动清理所有组件和回调)
|
|
87
91
|
FXViewManager_1.FXViewManager.getInstance().unregisterView(this.viewId);
|
|
88
92
|
}
|
|
@@ -91,7 +95,7 @@ class FXView extends react_1.Component {
|
|
|
91
95
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
92
96
|
const _a = this.props, { fxViewId } = _a, restProps = __rest(_a, ["fxViewId"]);
|
|
93
97
|
const { components } = this.state;
|
|
94
|
-
|
|
98
|
+
FXLogger_1.default.log("FXView", `rendering components: ${components.length}`);
|
|
95
99
|
return (<react_native_1.View {...restProps}>
|
|
96
100
|
{children}
|
|
97
101
|
{components.map((item) => item.visible ? (<react_1.default.Fragment key={item.componentId}>
|
package/FXView.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { Component } from "react";
|
|
|
2
2
|
import { View, ViewProps } from "react-native";
|
|
3
3
|
import { FXComponentItem } from "./types";
|
|
4
4
|
import { FXViewManager } from "./FXViewManager";
|
|
5
|
+
import logger from "./logger/FXLogger";
|
|
5
6
|
|
|
6
7
|
interface FXViewProps extends ViewProps {
|
|
7
8
|
fxViewId?: string; // 动态标识属性,可选
|
|
@@ -27,7 +28,7 @@ export default class FXView extends Component<FXViewProps, FXViewState> {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
componentDidMount() {
|
|
30
|
-
|
|
31
|
+
logger.log("FXView", `mounted with viewId: ${this.viewId}`);
|
|
31
32
|
// 注册到视图管理器
|
|
32
33
|
FXViewManager.getInstance().registerView(
|
|
33
34
|
this.viewId,
|
|
@@ -38,12 +39,12 @@ export default class FXView extends Component<FXViewProps, FXViewState> {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
componentDidUpdate(_prevProps: FXViewProps) {
|
|
41
|
-
|
|
42
|
+
logger.log("FXView", `updated: ${this.viewId}`);
|
|
42
43
|
const newViewId = this.props.fxViewId || this.viewId;
|
|
43
44
|
|
|
44
45
|
if (newViewId !== this.viewId) {
|
|
45
46
|
// ID 变化时重新注册
|
|
46
|
-
|
|
47
|
+
logger.log("FXView", `updated changed: ${this.viewId}`);
|
|
47
48
|
FXViewManager.getInstance().unregisterView(this.viewId);
|
|
48
49
|
this.viewId = newViewId;
|
|
49
50
|
|
|
@@ -56,7 +57,7 @@ export default class FXView extends Component<FXViewProps, FXViewState> {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
componentWillUnmount() {
|
|
59
|
-
|
|
60
|
+
logger.log("FXView", `unmounted: ${this.viewId}`);
|
|
60
61
|
// 注销视图(会自动清理所有组件和回调)
|
|
61
62
|
FXViewManager.getInstance().unregisterView(this.viewId);
|
|
62
63
|
}
|
|
@@ -71,7 +72,7 @@ export default class FXView extends Component<FXViewProps, FXViewState> {
|
|
|
71
72
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
72
73
|
const { fxViewId, ...restProps } = this.props;
|
|
73
74
|
const { components } = this.state;
|
|
74
|
-
|
|
75
|
+
logger.log("FXView", `rendering components: ${components.length}`);
|
|
75
76
|
return (
|
|
76
77
|
<View {...restProps}>
|
|
77
78
|
{children}
|
package/FXViewController.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.FXViewController = void 0;
|
|
4
7
|
const FXCategoryController_1 = require("./FXCategoryController");
|
|
8
|
+
const FXLogger_1 = __importDefault(require("./logger/FXLogger"));
|
|
5
9
|
class FXViewController {
|
|
6
10
|
constructor(fxViewId) {
|
|
7
11
|
// 存储各分类的控制器
|
|
@@ -17,7 +21,7 @@ class FXViewController {
|
|
|
17
21
|
* @returns 组件控制器
|
|
18
22
|
*/
|
|
19
23
|
add(component, categoryId, componentId) {
|
|
20
|
-
|
|
24
|
+
FXLogger_1.default.info("FXViewController.add", `[${this.fxViewId}]`, {
|
|
21
25
|
categoryId,
|
|
22
26
|
componentId,
|
|
23
27
|
});
|
|
@@ -32,7 +36,7 @@ class FXViewController {
|
|
|
32
36
|
* @returns 组件控制器
|
|
33
37
|
*/
|
|
34
38
|
build(component, categoryId, componentId) {
|
|
35
|
-
|
|
39
|
+
FXLogger_1.default.info("FXViewController.build", `[${this.fxViewId}]`, {
|
|
36
40
|
categoryId,
|
|
37
41
|
componentId,
|
|
38
42
|
});
|
|
@@ -45,13 +49,13 @@ class FXViewController {
|
|
|
45
49
|
* @param categoryId 分类 ID(可选,默认 "default")
|
|
46
50
|
*/
|
|
47
51
|
show(componentId, categoryId) {
|
|
48
|
-
|
|
52
|
+
FXLogger_1.default.info("FXViewController.show", `[${this.fxViewId}]`, {
|
|
49
53
|
categoryId,
|
|
50
54
|
componentId,
|
|
51
55
|
});
|
|
52
56
|
const categoryController = this.getCategoryController(categoryId);
|
|
53
57
|
if (!categoryController) {
|
|
54
|
-
|
|
58
|
+
FXLogger_1.default.warn(`CategoryController ${categoryId || "default"} not found in view ${this.fxViewId}`);
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
61
|
categoryController.show(componentId);
|
|
@@ -62,13 +66,13 @@ class FXViewController {
|
|
|
62
66
|
* @param categoryId 分类 ID(可选,默认 "default")
|
|
63
67
|
*/
|
|
64
68
|
hide(componentId, categoryId) {
|
|
65
|
-
|
|
69
|
+
FXLogger_1.default.info("FXViewController.hide", `[${this.fxViewId}]`, {
|
|
66
70
|
categoryId,
|
|
67
71
|
componentId,
|
|
68
72
|
});
|
|
69
73
|
const categoryController = this.getCategoryController(categoryId);
|
|
70
74
|
if (!categoryController) {
|
|
71
|
-
|
|
75
|
+
FXLogger_1.default.warn(`CategoryController ${categoryId || "default"} not found in view ${this.fxViewId}`);
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
78
|
categoryController.hide(componentId);
|
|
@@ -80,13 +84,13 @@ class FXViewController {
|
|
|
80
84
|
* @param categoryId 分类 ID(可选,默认 "default")
|
|
81
85
|
*/
|
|
82
86
|
update(componentId, component, categoryId) {
|
|
83
|
-
|
|
87
|
+
FXLogger_1.default.info("FXViewController.update", `[${this.fxViewId}]`, {
|
|
84
88
|
categoryId,
|
|
85
89
|
componentId,
|
|
86
90
|
});
|
|
87
91
|
const categoryController = this.getCategoryController(categoryId);
|
|
88
92
|
if (!categoryController) {
|
|
89
|
-
|
|
93
|
+
FXLogger_1.default.warn(`CategoryController ${categoryId || "default"} not found in view ${this.fxViewId}`);
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
92
96
|
categoryController.update(componentId, component);
|
|
@@ -97,13 +101,13 @@ class FXViewController {
|
|
|
97
101
|
* @param categoryId 分类 ID(可选,默认 "default")
|
|
98
102
|
*/
|
|
99
103
|
remove(componentId, categoryId) {
|
|
100
|
-
|
|
104
|
+
FXLogger_1.default.info("FXViewController.remove", `[${this.fxViewId}]`, {
|
|
101
105
|
categoryId,
|
|
102
106
|
componentId,
|
|
103
107
|
});
|
|
104
108
|
const categoryController = this.getCategoryController(categoryId);
|
|
105
109
|
if (!categoryController) {
|
|
106
|
-
|
|
110
|
+
FXLogger_1.default.warn(`CategoryController ${categoryId || "default"} not found in view ${this.fxViewId}`);
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
113
|
categoryController.remove(componentId);
|
|
@@ -117,12 +121,12 @@ class FXViewController {
|
|
|
117
121
|
* @param categoryId 分类 ID(可选,默认 "default")
|
|
118
122
|
*/
|
|
119
123
|
removeLast(categoryId) {
|
|
120
|
-
|
|
124
|
+
FXLogger_1.default.info("FXViewController.removeLast", `[${this.fxViewId}]`, {
|
|
121
125
|
categoryId,
|
|
122
126
|
});
|
|
123
127
|
const categoryController = this.getCategoryController(categoryId);
|
|
124
128
|
if (!categoryController) {
|
|
125
|
-
|
|
129
|
+
FXLogger_1.default.warn(`CategoryController ${categoryId || "default"} not found in view ${this.fxViewId}`);
|
|
126
130
|
return;
|
|
127
131
|
}
|
|
128
132
|
categoryController.removeLast();
|
|
@@ -135,12 +139,12 @@ class FXViewController {
|
|
|
135
139
|
* 清空所有分类的所有组件
|
|
136
140
|
*/
|
|
137
141
|
clearAll() {
|
|
138
|
-
|
|
142
|
+
FXLogger_1.default.info("FXViewController.clearAll", `[${this.fxViewId}]`);
|
|
139
143
|
this.categoryControllerMap.forEach((controller) => {
|
|
140
144
|
controller.clearAll();
|
|
141
145
|
});
|
|
142
146
|
this.categoryControllerMap.clear();
|
|
143
|
-
|
|
147
|
+
FXLogger_1.default.info("FXViewController.clearAll done", this.categoryControllerMap.size);
|
|
144
148
|
}
|
|
145
149
|
/**
|
|
146
150
|
* 清空指定分类的所有组件
|
|
@@ -148,12 +152,12 @@ class FXViewController {
|
|
|
148
152
|
*/
|
|
149
153
|
clearCategory(categoryId) {
|
|
150
154
|
const finalCategoryId = categoryId || "default";
|
|
151
|
-
|
|
155
|
+
FXLogger_1.default.info("FXViewController.clearCategory", `[${this.fxViewId}]`, {
|
|
152
156
|
categoryId: finalCategoryId,
|
|
153
157
|
});
|
|
154
158
|
const categoryController = this.getCategoryController(categoryId);
|
|
155
159
|
if (!categoryController) {
|
|
156
|
-
|
|
160
|
+
FXLogger_1.default.warn(`CategoryController ${finalCategoryId} not found in view ${this.fxViewId}`);
|
|
157
161
|
return;
|
|
158
162
|
}
|
|
159
163
|
categoryController.clearAll();
|
|
@@ -280,7 +284,7 @@ class FXViewController {
|
|
|
280
284
|
*/
|
|
281
285
|
removeCategory(categoryId) {
|
|
282
286
|
const finalCategoryId = categoryId || "default";
|
|
283
|
-
|
|
287
|
+
FXLogger_1.default.info("FXViewController.removeCategory", `[${this.fxViewId}]`, {
|
|
284
288
|
categoryId: finalCategoryId,
|
|
285
289
|
});
|
|
286
290
|
this.categoryControllerMap.delete(finalCategoryId);
|