@arms/rum-core 0.1.1 → 0.1.3

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,10 +1,12 @@
1
1
  import { IConfiguration, IContext, IRumSession } from "../types/client";
2
2
  import { RumEvent, IViewData } from "../types/rum-event";
3
3
  import { IConfigManager } from "../types/config";
4
+ import { EventEmitter } from "../utils/events";
4
5
  declare class Context implements IContext {
5
6
  private config;
6
7
  private rumEvent;
7
8
  private views;
9
+ emitter: EventEmitter;
8
10
  session: IRumSession;
9
11
  configManager: IConfigManager;
10
12
  constructor(config: IConfiguration, rumSession?: IRumSession, configManager?: IConfigManager);
@@ -2,11 +2,13 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports["default"] = void 0;
5
+ var _events = require("../utils/events");
5
6
  var Context = /*#__PURE__*/function () {
6
7
  function Context(config, rumSession, configManager) {
7
8
  this.config = config;
8
9
  this.rumEvent = void 0;
9
10
  this.views = [];
11
+ this.emitter = new _events.EventEmitter();
10
12
  this.session = void 0;
11
13
  this.configManager = void 0;
12
14
  if (rumSession) {
@@ -198,8 +198,8 @@ var Reporter = exports["default"] = /*#__PURE__*/function () {
198
198
  _reportConfig$maxRetr,
199
199
  _reportConfig$retryDe,
200
200
  _this2 = this;
201
- var reportConfig, maxRetryCount, retryDelay;
202
- return _regenerator["default"].wrap(function _callee$(_context) {
201
+ var reportConfig, maxRetryCount, retryDelay, _t;
202
+ return _regenerator["default"].wrap(function (_context) {
203
203
  while (1) switch (_context.prev = _context.next) {
204
204
  case 0:
205
205
  if (retry === void 0) {
@@ -208,26 +208,26 @@ var Reporter = exports["default"] = /*#__PURE__*/function () {
208
208
  reportConfig = (_this$ctx$getConfig = this.ctx.getConfig()) === null || _this$ctx$getConfig === void 0 ? void 0 : _this$ctx$getConfig.reportConfig;
209
209
  maxRetryCount = (_reportConfig$maxRetr = reportConfig === null || reportConfig === void 0 ? void 0 : reportConfig.maxRetryCount) !== null && _reportConfig$maxRetr !== void 0 ? _reportConfig$maxRetr : 0;
210
210
  retryDelay = (_reportConfig$retryDe = reportConfig === null || reportConfig === void 0 ? void 0 : reportConfig.retryDelay) !== null && _reportConfig$retryDe !== void 0 ? _reportConfig$retryDe : 3000;
211
- _context.prev = 4;
211
+ _context.prev = 1;
212
212
  bundle._retry = retry;
213
- _context.next = 8;
213
+ _context.next = 2;
214
214
  return this.request(this.ctx, bundle);
215
- case 8:
216
- _context.next = 13;
215
+ case 2:
216
+ _context.next = 4;
217
217
  break;
218
- case 10:
219
- _context.prev = 10;
220
- _context.t0 = _context["catch"](4);
218
+ case 3:
219
+ _context.prev = 3;
220
+ _t = _context["catch"](1);
221
221
  if (retry < maxRetryCount - 1) {
222
222
  setTimeout(function () {
223
223
  return _this2.tryRequest(bundle, retry + 1);
224
224
  }, retryDelay);
225
225
  }
226
- case 13:
226
+ case 4:
227
227
  case "end":
228
228
  return _context.stop();
229
229
  }
230
- }, _callee, this, [[4, 10]]);
230
+ }, _callee, this, [[1, 3]]);
231
231
  }));
232
232
  function tryRequest(_x, _x2) {
233
233
  return _tryRequest.apply(this, arguments);
@@ -7,57 +7,33 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
7
7
  var _rumEvent = require("../types/rum-event");
8
8
  var _client = _interopRequireDefault(require("../model/client"));
9
9
  var _is = require("../utils/is");
10
- // import combineConfig, { isRemoteConfigEnable, getRemoteConfigUrl } from "../utils/combineConfig";
11
10
  var Shell = exports["default"] = /*#__PURE__*/function () {
12
11
  function Shell(config) {
12
+ // private callbacks: Function[] = [];
13
+ // private initialized = false;
13
14
  this.client = void 0;
14
15
  this.client = new _client["default"]();
15
16
  if (config && this.init) {
16
17
  this.init(config);
18
+ // const p = this.init(config) as Promise<Shell>;
19
+ // if(isFunction(p?.then)){
20
+ // p.then(this.shellReady);
21
+ // } else {
22
+ // this.shellReady()
23
+ // }
17
24
  }
18
25
  }
19
26
 
20
- // getCombinedConfig(config?: IConfiguration) {
21
- // let combinedConf;
22
- // if(isRemoteConfigEnable(config) && isFunction(this.getLocalConfig)) {
23
- // const localConfig = this.getLocalConfig(0, config.pid);
24
- // combinedConf = combineConfig(config, localConfig);
25
- // }
26
- // return combinedConf || config;
27
+ // private shellReady = () => {
28
+ // this.initialized = true;
29
+ // this.callbacks.forEach(cb => cb());
27
30
  // }
28
31
  //
29
- // updateFromRemoteConfig(config: any, reSetup: boolean = true) {
30
- // // 请求动态配置
31
- // if( config.pid && isRemoteConfigEnable(config) && isFunction(this.getRemoteConfig) ){
32
- // const that = this;
33
- // const proms = this.getRemoteConfig(getRemoteConfigUrl(config), config);
34
- // proms?.then(remoteConfig => {
35
- // if(!remoteConfig || remoteConfig.errorStatus !== undefined) return;
36
- // const combinedConf = combineConfig(config, remoteConfig);
37
- //
38
- // // 无有效的新配置,无需更新
39
- // if(!combinedConf) return;
40
- //
41
- // // 存储到本地
42
- // if(isFunction(that.storeRemoteConfig)) {
43
- // that.storeRemoteConfig(remoteConfig, config.pid);
44
- // }
45
- //
46
- // if(reSetup === false || config.remoteConfig.reSetup === false) return;
47
- //
48
- // const context = that.client.getContext();
49
- // // 更新配置
50
- // context.setConfig(combinedConf);
51
- // // 逐个更新collector
52
- // const collectors = that.client.getCollectors();
53
- // collectors.forEach(collector => {
54
- // if(isFunction(collector.destroy)) {
55
- // collector.destroy();
56
- // collector.setup(context, that.client.sendEvent);
57
- // }
58
- // });
59
- // });
32
+ // onReady(callback: Function) {
33
+ // if (this.initialized) {
34
+ // callback();
60
35
  // }
36
+ // this.callbacks.push(callback);
61
37
  // }
62
38
 
63
39
  /**
@@ -79,21 +55,6 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
79
55
  }
80
56
  }
81
57
 
82
- // /**
83
- // * 获取远程配置
84
- // */
85
- // abstract getRemoteConfig(url: string, config: any): object;
86
- //
87
- // /**
88
- // * 存储远程配置到本地
89
- // */
90
- // abstract storeRemoteConfig(config: any, pid: string): boolean;
91
- //
92
- // /**
93
- // * 提取本地存储的配置
94
- // */
95
- // abstract getLocalConfig(duration: number, pid: string): any;
96
-
97
58
  /**
98
59
  * set config
99
60
  */;
@@ -2,8 +2,9 @@ import { ICollector } from './collector';
2
2
  import { IProcessor } from './processor';
3
3
  import { IReporter } from './reporter';
4
4
  import { RumEvent, RumEventBundle, IViewData } from './rum-event';
5
- import { MatchOption } from "../utils/match";
6
- import { IConfigManager } from "./config";
5
+ import { MatchOption } from '../utils/match';
6
+ import { IConfigManager } from './config';
7
+ import { EventEmitter } from '../utils/events';
7
8
  export declare enum EventType {
8
9
  /**
9
10
  * 收集数据
@@ -12,6 +13,7 @@ export declare enum EventType {
12
13
  }
13
14
  export interface IContext {
14
15
  session: IRumSession;
16
+ emitter: EventEmitter;
15
17
  /**
16
18
  * user config
17
19
  */
@@ -90,7 +92,7 @@ export interface IRemoteConfig {
90
92
  [key: string]: unknown;
91
93
  }
92
94
  export interface ICollectorConfig {
93
- name: string;
95
+ name?: string;
94
96
  enable?: boolean;
95
97
  sampling?: number;
96
98
  filters?: MatchOption[];
@@ -218,5 +220,12 @@ export interface IConfiguration {
218
220
  * 检测正则匹配内容
219
221
  */
220
222
  regexp?: string;
223
+ /**
224
+ * 检测元素是否包含特定属性或者属性值的元素,支持正则匹配
225
+ */
226
+ attributeRules?: Array<{
227
+ attributeName: string;
228
+ attributeValue?: Array<string | RegExp> | null;
229
+ }>;
221
230
  [key: string]: unknown;
222
231
  }
@@ -10,9 +10,11 @@ export declare enum RumEventType {
10
10
  export interface BaseObject {
11
11
  [key: string]: BaseObjectValue;
12
12
  }
13
- export interface IViewData {
13
+ export type loading_type = 'initial_load' | 'route_change';
14
+ export interface IViewData extends BaseObject {
14
15
  id: string;
15
16
  name: string;
17
+ loading_type?: loading_type;
16
18
  }
17
19
  export type BaseObjectPrimitiveValue = string | number | boolean | null | undefined;
18
20
  export type BaseObjectValue = BaseObjectPrimitiveValue | BaseObject | BaseObjectPrimitiveValue[] | IViewData;
@@ -26,27 +28,64 @@ export interface RumBaseEvent extends BaseObject {
26
28
  snapshots?: string;
27
29
  properties?: BaseObject;
28
30
  }
31
+ /** 事件类型:页面浏览、性能指标、Web Vitals、自定义指标、会话回放 */
32
+ export type view_type = 'pv' | 'perf' | 'webvitals' | 'custom' | 'replay' | 'view-stats';
29
33
  export interface RumViewEvent extends RumBaseEvent {
30
- loading_type?: 'initial_load' | 'route_change';
31
- type: 'pv' | 'perf' | 'webvitals' | 'custom';
34
+ /** 页面加载类型:初始加载或路由切换 */
35
+ loading_type?: loading_type;
36
+ type: view_type;
37
+ /** 最大内容绘制时间 (LCP) - 页面加载过程中最大文本块或图像元素的渲染时间 */
32
38
  largest_contentful_paint?: number;
39
+ /** 首次输入延迟 (FID) - 用户首次与页面交互到浏览器响应该交互的时间 */
33
40
  first_input_delay?: number;
41
+ /** 累积布局偏移 (CLS) - 页面可见元素意外移动的累积分数 */
34
42
  cumulative_layout_shift?: number;
43
+ /** 首次输入时间 (FIT) - 用户首次与页面交互的时间戳 */
35
44
  first_input_time?: number;
45
+ /** 页面加载时间 - 从开始加载到页面完全加载的时间 */
36
46
  loading_time?: number;
47
+ /** 首次绘制时间 (FP) - 浏览器首次渲染任何内容的时间 */
37
48
  first_paint?: number;
49
+ /** 首次内容绘制时间 (FCP) - 浏览器首次渲染DOM内容的时间 */
38
50
  first_contentful_paint?: number;
51
+ /** DOM 交互时间 - DOM 构建完成且脚本开始执行的时间 */
39
52
  dom_interactive?: number;
53
+ /** DOM 内容加载完成时间 - DOM 和所有子资源加载完成的时间 */
40
54
  dom_content_loaded?: number;
55
+ /** DOM 完成时间 - 页面及其所有资源加载完成的时间 */
41
56
  dom_complete?: number;
57
+ /** 加载事件时间 - load 事件触发的时间 */
42
58
  load_event?: number;
59
+ /** 自定义性能指标 T1 */
43
60
  t1?: number;
61
+ /** 自定义性能指标 T2 */
44
62
  t2?: number;
63
+ /** 自定义性能指标 T3 */
45
64
  t3?: number;
65
+ /** 来源页面 URL */
46
66
  referrer?: string;
67
+ /** 当前页面 URL */
47
68
  url?: string;
69
+ /** 性能时序数据 (JSON 字符串格式) */
48
70
  timing_data?: string;
49
71
  }
72
+ export interface RumReplayEvent extends RumBaseEvent {
73
+ type: 'replay';
74
+ /** 当前Records记录的结束时间 */
75
+ records_end?: number;
76
+ /** 会话回放片段索引 */
77
+ records_index?: number;
78
+ /** 当前会话包含的record数量 */
79
+ records_count?: number;
80
+ /** 创建record原因 */
81
+ records_reason?: string;
82
+ /** 包含的replay数据大小 */
83
+ records_size?: number;
84
+ /** 是否包含完整的Snapshot */
85
+ has_full_snapshot?: number;
86
+ /** 上报的录屏数据 */
87
+ records_data?: string;
88
+ }
50
89
  /**
51
90
  * 枚举值,表示资源是否加载成功
52
91
  */
@@ -96,10 +135,43 @@ export interface RumLongTaskEvent extends RumBaseEvent {
96
135
  snapshots: string;
97
136
  }
98
137
  export interface RumActionEvent extends RumBaseEvent {
138
+ event_type: RumEventType.ACTION;
139
+ /** 行为类型 */
99
140
  type?: string;
141
+ /** 行为名称 */
100
142
  name?: string;
143
+ /** 目标元素名称XPath */
101
144
  target_name?: string;
145
+ /** 操作持续时间(毫秒) */
102
146
  duration?: number;
147
+ /**
148
+ * Heatmap Analysis - 热力图分析
149
+ * 当 trackUserInteractions 开启时才会采集以下数据
150
+ * */
151
+ /** 点击位置信息 */
152
+ position?: {
153
+ /** 点击 X 坐标(相对于文档) */
154
+ x?: number;
155
+ /** 点击 Y 坐标(相对于文档) */
156
+ y?: number;
157
+ /** 元素内相对 X 坐标 */
158
+ ex?: number;
159
+ /** 元素内相对 Y 坐标 */
160
+ ey?: number;
161
+ };
162
+ /** 目标元素信息 */
163
+ target?: {
164
+ /** 元素的 selector:#root > div > button:nth-child(15) */
165
+ selector?: string;
166
+ /** 元素的宽度(像素) */
167
+ width?: number;
168
+ /** 元素的高度(像素) */
169
+ height?: number;
170
+ /** 是否为可交互元素(0=不可交互, 1=可交互),用于无效点击分析 */
171
+ reaction?: number;
172
+ /** 是否可信的交互(0=不可信, 1=可信),用于错误点击分析 */
173
+ trust?: number;
174
+ };
103
175
  }
104
176
  export interface RumCustomEvent extends RumBaseEvent {
105
177
  type: string;
@@ -12,6 +12,7 @@ var RumEventType = exports.RumEventType = /*#__PURE__*/function (RumEventType) {
12
12
  RumEventType["APPLICATION"] = "application";
13
13
  return RumEventType;
14
14
  }({});
15
+ /** 事件类型:页面浏览、性能指标、Web Vitals、自定义指标、会话回放 */
15
16
  /**
16
17
  * 枚举值,表示资源是否加载成功
17
18
  */
@@ -41,17 +41,6 @@ export declare function debounce(func: Function, wait: number): () => void;
41
41
  * @param wait 延迟执行毫秒数
42
42
  */
43
43
  export declare function delay(func: Function, wait: number, ...args: any[]): number;
44
- /**
45
- * @desc 需要严格区分object和array
46
- * @param obj 任意对象
47
- */
48
- export declare function getType(obj: any): any;
49
- /**
50
- * @desc 将字符串转换成正则表达式
51
- * @param str 任意字符串
52
- * 注意,这里只支持 /xxx/ 这种格式,不支持修饰符,例如 /xxx/ig
53
- */
54
- export declare function transStrToReg(str: string): string | RegExp;
55
44
  /**
56
45
  * 解析正则表达式字符串,支持 /pattern/flags 格式
57
46
  * @param str 正则表达式字符串,如 "/a/ig" 或 "a"
package/lib/utils/base.js CHANGED
@@ -7,15 +7,10 @@ exports.generateEventId = generateEventId;
7
7
  exports.generateGUID = generateGUID;
8
8
  exports.generateSpanId = generateSpanId;
9
9
  exports.generateTraceId = generateTraceId;
10
- exports.getType = getType;
11
10
  exports.interceptFunction = interceptFunction;
12
11
  exports.parseRegExpString = parseRegExpString;
13
12
  exports.restoreFunction = restoreFunction;
14
- exports.transStrToReg = transStrToReg;
15
13
  var _is = require("./is");
16
- // 类型匹配正则
17
- var TYPE_REG = /^\[object ([a-z]*)\]$/;
18
-
19
14
  /**
20
15
  * 劫持函数或原型
21
16
  */
@@ -163,30 +158,32 @@ function delay(func, wait) {
163
158
  return setTimeout.apply(void 0, [func, +wait || 0].concat(args));
164
159
  }
165
160
 
166
- /**
167
- * @desc 需要严格区分object和array
168
- * @param obj 任意对象
169
- */
170
- function getType(obj) {
171
- var type = Object.prototype.toString.call(obj);
172
- type = type.toLowerCase() || '';
173
- var arr = type.match(TYPE_REG);
174
- return arr === null || arr === void 0 ? void 0 : arr[1];
175
- }
176
-
177
- /**
178
- * @desc 将字符串转换成正则表达式
179
- * @param str 任意字符串
180
- * 注意,这里只支持 /xxx/ 这种格式,不支持修饰符,例如 /xxx/ig
181
- */
182
- function transStrToReg(str) {
183
- if (getType(str) !== 'string') return str;
184
- if (str.length > 2 && str[0] === '/' && str[str.length - 1] === '/') {
185
- return new RegExp(str.substr(1, str.length - 2));
186
- }
187
- return str;
188
- }
189
-
161
+ // // 类型匹配正则
162
+ // const TYPE_REG = /^\[object ([a-z]*)\]$/;
163
+ // /**
164
+ // * @desc 需要严格区分object和array
165
+ // * @param obj 任意对象
166
+ // */
167
+ // export function getType(obj: any) {
168
+ // let type = Object.prototype.toString.call(obj);
169
+ // type = type.toLowerCase() || '';
170
+ // const arr = type.match(TYPE_REG);
171
+ // return arr?.[1];
172
+ // }
173
+ //
174
+ // /**
175
+ // * @desc 将字符串转换成正则表达式
176
+ // * @param str 任意字符串
177
+ // * 注意,这里只支持 /xxx/ 这种格式,不支持修饰符,例如 /xxx/ig
178
+ // */
179
+ // export function transStrToReg(str: string) {
180
+ // if (getType(str) !== 'string') return str;
181
+ // if (str.length > 2 && str[0] === '/' && str[str.length - 1] === '/') {
182
+ // return new RegExp(str.substr(1, str.length - 2));
183
+ // }
184
+ // return str;
185
+ // }
186
+ //
190
187
  // /**
191
188
  // *
192
189
  // * @param config 配置
@@ -1,4 +1,4 @@
1
- type EventHandler = (...args: any[]) => void;
1
+ export type EventHandler = (...args: any[]) => void;
2
2
  export declare class EventEmitter {
3
3
  private events;
4
4
  /**
@@ -26,4 +26,3 @@ export declare class EventEmitter {
26
26
  */
27
27
  once(eventName: string, handler: EventHandler): void;
28
28
  }
29
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arms/rum-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "arms rum javascript sdk core",
5
5
  "author": "guangli.fj <guangli.fj@alibaba-inc.com>",
6
6
  "license": "ISC",
@@ -1,89 +0,0 @@
1
- // import{ getType, toRegFormat} from './base';
2
- //
3
- //
4
- // // 需要检查是否需要字符串格式化为正则的配置路径
5
- // const REG_FORMAT_PATHS = [
6
- // 'filters.exception',
7
- // 'filters.resource',
8
- // 'tracing.allowedUrls.[].match'
9
- // ];
10
- //
11
- // export function isRemoteConfigEnable(config: any) {
12
- // return config.remoteConfig === true ||
13
- // (config.remoteConfig && config.remoteConfig.enable !== false);
14
- // }
15
- //
16
- // /**
17
- // *
18
- // * @param config
19
- // * @returns
20
- // */
21
- // export function getRemoteConfigUrl(config: any){
22
- // if(config.remoteConfig && config.remoteConfig.url) {
23
- // return config.remoteConfig.url;
24
- // }
25
- // const sereis = config.pid.split('@');
26
- // if(!sereis || sereis.length<2) return;
27
- // const timestamp = Date.now();
28
- // return `//${sereis[0]}-sdk.rum.aliyuncs.com/config/${config.remoteConfig.region || 'cn-hangzhou'}/${sereis[1]}?t=${timestamp}`;
29
- // }
30
- //
31
- // /**
32
- // *
33
- // * @param oldConfig
34
- // * @param remoteConfig
35
- // */
36
- // function doCover(oldConfig: any ={}, remoteConfig: any ={}){
37
- // for(const key in oldConfig) {
38
- // if(key === 'pid' || key === 'endpoint') continue;
39
- // if(remoteConfig?.[key] === undefined) continue;
40
- // const oldV = oldConfig[key];
41
- // const newV = remoteConfig?.[key];
42
- // if(getType(oldV) === 'object' && getType(newV) === 'object') {
43
- // doCover(oldV, newV);
44
- // } else {
45
- // oldConfig[key] = newV;
46
- // }
47
- // }
48
- // }
49
- //
50
- // /**
51
- // *
52
- // * @param oldConfig
53
- // * @param remoteConfig
54
- // */
55
- // function doSupplement(oldConfig: any ={}, remoteConfig: any ={}) {
56
- // for(const key in remoteConfig) {
57
- // if(oldConfig?.[key] === undefined) {
58
- // oldConfig[key] = remoteConfig[key];
59
- // } else {
60
- // const oldV = oldConfig[key];
61
- // const newV = remoteConfig[key];
62
- // if(getType(oldV) === 'object' && getType(newV) === 'object') {
63
- // doSupplement(oldV, newV);
64
- // }
65
- // }
66
- // }
67
- // }
68
- //
69
- // /**
70
- // *
71
- // * @param oldConfig
72
- // * @param remoteConfig
73
- // * @returns config
74
- // */
75
- // function combineConfig(oldConfig={}, remoteConfig=null) {
76
- // if(!remoteConfig) return null;
77
- // if(getType(oldConfig) !== 'object' || getType(remoteConfig) !== 'object') return null;
78
- // const config = {...oldConfig};
79
- // // 先检查远程配置的,是否有需要将字符串格式化为正则的
80
- // toRegFormat(remoteConfig, REG_FORMAT_PATHS);
81
- // // 执行覆盖
82
- // doCover(config, remoteConfig);
83
- // // 执行补充
84
- // doSupplement(config, remoteConfig);
85
- // return config;
86
- // }
87
- //
88
- //
89
- // export default combineConfig;
@@ -1,90 +0,0 @@
1
- // import{ getType, toRegFormat} from './base';
2
- //
3
- //
4
- // // 需要检查是否需要字符串格式化为正则的配置路径
5
- // const REG_FORMAT_PATHS = [
6
- // 'filters.exception',
7
- // 'filters.resource',
8
- // 'tracing.allowedUrls.[].match'
9
- // ];
10
- //
11
- // export function isRemoteConfigEnable(config: any) {
12
- // return config.remoteConfig === true ||
13
- // (config.remoteConfig && config.remoteConfig.enable !== false);
14
- // }
15
- //
16
- // /**
17
- // *
18
- // * @param config
19
- // * @returns
20
- // */
21
- // export function getRemoteConfigUrl(config: any){
22
- // if(config.remoteConfig && config.remoteConfig.url) {
23
- // return config.remoteConfig.url;
24
- // }
25
- // const sereis = config.pid.split('@');
26
- // if(!sereis || sereis.length<2) return;
27
- // const timestamp = Date.now();
28
- // return `//${sereis[0]}-sdk.rum.aliyuncs.com/config/${config.remoteConfig.region || 'cn-hangzhou'}/${sereis[1]}?t=${timestamp}`;
29
- // }
30
- //
31
- // /**
32
- // *
33
- // * @param oldConfig
34
- // * @param remoteConfig
35
- // */
36
- // function doCover(oldConfig: any ={}, remoteConfig: any ={}){
37
- // for(const key in oldConfig) {
38
- // if(key === 'pid' || key === 'endpoint') continue;
39
- // if(remoteConfig?.[key] === undefined) continue;
40
- // const oldV = oldConfig[key];
41
- // const newV = remoteConfig?.[key];
42
- // if(getType(oldV) === 'object' && getType(newV) === 'object') {
43
- // doCover(oldV, newV);
44
- // } else {
45
- // oldConfig[key] = newV;
46
- // }
47
- // }
48
- // }
49
- //
50
- // /**
51
- // *
52
- // * @param oldConfig
53
- // * @param remoteConfig
54
- // */
55
- // function doSupplement(oldConfig: any ={}, remoteConfig: any ={}) {
56
- // for(const key in remoteConfig) {
57
- // if(oldConfig?.[key] === undefined) {
58
- // oldConfig[key] = remoteConfig[key];
59
- // } else {
60
- // const oldV = oldConfig[key];
61
- // const newV = remoteConfig[key];
62
- // if(getType(oldV) === 'object' && getType(newV) === 'object') {
63
- // doSupplement(oldV, newV);
64
- // }
65
- // }
66
- // }
67
- // }
68
- //
69
- // /**
70
- // *
71
- // * @param oldConfig
72
- // * @param remoteConfig
73
- // * @returns config
74
- // */
75
- // function combineConfig(oldConfig={}, remoteConfig=null) {
76
- // if(!remoteConfig) return null;
77
- // if(getType(oldConfig) !== 'object' || getType(remoteConfig) !== 'object') return null;
78
- // const config = {...oldConfig};
79
- // // 先检查远程配置的,是否有需要将字符串格式化为正则的
80
- // toRegFormat(remoteConfig, REG_FORMAT_PATHS);
81
- // // 执行覆盖
82
- // doCover(config, remoteConfig);
83
- // // 执行补充
84
- // doSupplement(config, remoteConfig);
85
- // return config;
86
- // }
87
- //
88
- //
89
- // export default combineConfig;
90
- "use strict";