@microsoft/applicationinsights-react-native 3.0.3 → 4.0.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 (40) hide show
  1. package/browser/applicationinsights-react-native.js +1995 -1061
  2. package/browser/applicationinsights-react-native.js.map +1 -1
  3. package/browser/applicationinsights-react-native.min.js +2 -2
  4. package/browser/applicationinsights-react-native.min.js.map +1 -1
  5. package/dist/applicationinsights-react-native.api.json +147 -17
  6. package/dist/applicationinsights-react-native.api.md +9 -1
  7. package/dist/applicationinsights-react-native.d.ts +8 -4
  8. package/dist/applicationinsights-react-native.js +1995 -1061
  9. package/dist/applicationinsights-react-native.js.map +1 -1
  10. package/dist/applicationinsights-react-native.min.js +2 -2
  11. package/dist/applicationinsights-react-native.min.js.map +1 -1
  12. package/dist/applicationinsights-react-native.rollup.d.ts +8 -4
  13. package/dist-esm/DeviceInfo/DeviceModule.js +1 -1
  14. package/dist-esm/DeviceInfo/ReactNativeDeviceInfo.js +1 -1
  15. package/dist-esm/Interfaces/IDeviceInfoModule.js +1 -1
  16. package/dist-esm/Interfaces/INativeDevice.js +1 -1
  17. package/dist-esm/Interfaces/IReactNativePluginConfig.js +1 -1
  18. package/dist-esm/Interfaces/index.js +1 -1
  19. package/dist-esm/ReactNativeManualDevicePlugin.js +236 -0
  20. package/dist-esm/ReactNativeManualDevicePlugin.js.map +1 -0
  21. package/dist-esm/ReactNativePlugin.js +8 -209
  22. package/dist-esm/ReactNativePlugin.js.map +1 -1
  23. package/dist-esm/index.js +3 -2
  24. package/dist-esm/index.js.map +1 -1
  25. package/dist-esm/manualIndex.js +9 -0
  26. package/dist-esm/manualIndex.js.map +1 -0
  27. package/package.json +14 -6
  28. package/types/ReactNativeManualDevicePlugin.d.ts +43 -0
  29. package/types/ReactNativePlugin.d.ts +3 -41
  30. package/types/index.d.ts +2 -1
  31. package/types/manualIndex.d.ts +4 -0
  32. package/types/tsdoc-metadata.json +1 -1
  33. package/src/DeviceInfo/DeviceModule.ts +0 -44
  34. package/src/DeviceInfo/ReactNativeDeviceInfo.ts +0 -13
  35. package/src/Interfaces/IDeviceInfoModule.ts +0 -31
  36. package/src/Interfaces/INativeDevice.ts +0 -19
  37. package/src/Interfaces/IReactNativePluginConfig.ts +0 -19
  38. package/src/Interfaces/index.ts +0 -7
  39. package/src/ReactNativePlugin.ts +0 -303
  40. package/src/index.ts +0 -10
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Native Plugin, 3.0.3
2
+ * Application Insights JavaScript SDK - React Native Plugin, 4.0.0
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -16,108 +16,182 @@
16
16
  var strShimObject = "object";
17
17
  var strShimUndefined = "undefined";
18
18
  var strShimPrototype = "prototype";
19
- var strShimHasOwnProperty = "hasOwnProperty";
20
19
  var ObjClass$1 = Object;
21
- var ObjProto$1 = ObjClass$1[strShimPrototype];
22
- var ObjCreate = ObjClass$1["create"];
23
- var ObjDefineProperty = ObjClass$1["defineProperty"];
24
- var ObjHasOwnProperty = ObjProto$1[strShimHasOwnProperty];
25
20
 
26
- var _cachedGlobal = null;
27
- function getGlobal(useCached) {
28
- if (useCached === void 0) { useCached = true; }
29
- var result = useCached === false ? null : _cachedGlobal;
30
- if (!result) {
31
- if (typeof globalThis !== strShimUndefined) {
32
- result = globalThis;
33
- }
34
- if (!result && typeof self !== strShimUndefined) {
35
- result = self;
36
- }
37
- if (!result && typeof window !== strShimUndefined) {
38
- result = window;
39
- }
40
- if (!result && typeof global !== strShimUndefined) {
41
- result = global;
42
- }
43
- _cachedGlobal = result;
21
+ var UNDEF_VALUE = undefined;
22
+ var NULL_VALUE = null;
23
+ var EMPTY = "";
24
+ var FUNCTION = "function";
25
+ var NUMBER = "number";
26
+ var OBJECT = "object";
27
+ var PROTOTYPE = "prototype";
28
+ var __PROTO__ = "__proto__";
29
+ var STRING = "string";
30
+ var UNDEFINED = "undefined";
31
+ var CONSTRUCTOR = "constructor";
32
+ var SYMBOL = "Symbol";
33
+ var POLYFILL_TAG = "_polyfill";
34
+ var INDEX_OF = "indexOf";
35
+ var LAST_INDEX_OF = "lastIndexOf";
36
+ var LENGTH = "length";
37
+ var DONE = "done";
38
+ var VALUE = "value";
39
+ var NAME = "name";
40
+ var SLICE = "slice";
41
+ var ObjClass = Object;
42
+ var ObjProto = ObjClass[PROTOTYPE];
43
+ var StrCls = String;
44
+ var StrProto = StrCls[PROTOTYPE];
45
+ var ArrCls = Array;
46
+ var ArrProto = ArrCls[PROTOTYPE];
47
+
48
+ function safeGet(cb, defValue) {
49
+ var result = defValue;
50
+ try {
51
+ result = cb();
52
+ }
53
+ catch (e) {
44
54
  }
45
55
  return result;
46
56
  }
47
- function throwTypeError$1(message) {
48
- throw new TypeError(message);
57
+
58
+ function _createIs(theType) {
59
+ return function (value) {
60
+ return typeof value === theType;
61
+ };
49
62
  }
50
- function objCreateFn(obj) {
51
- var func = ObjCreate;
52
- if (func) {
53
- return func(obj);
54
- }
55
- if (obj == null) {
56
- return {};
57
- }
58
- var type = typeof obj;
59
- if (type !== strShimObject && type !== strShimFunction) {
60
- throwTypeError$1("Object prototype may only be an Object:" + obj);
63
+ function _createObjIs(theName) {
64
+ var theType = "[object " + theName + "]";
65
+ return function (value) {
66
+ return !!(value && objToString(value) === theType);
67
+ };
68
+ }
69
+ function objToString(value) {
70
+ return ObjProto.toString.call(value);
71
+ }
72
+ function isUndefined(value) {
73
+ return typeof value === UNDEFINED || value === UNDEFINED;
74
+ }
75
+ function isNullOrUndefined(value) {
76
+ return value === NULL_VALUE || isUndefined(value);
77
+ }
78
+ function isStrictNullOrUndefined(value) {
79
+ return value === NULL_VALUE || !isDefined(value);
80
+ }
81
+ function isDefined(arg) {
82
+ return !!arg || arg !== UNDEF_VALUE;
83
+ }
84
+ var isString = _createIs(STRING);
85
+ var isFunction = _createIs(FUNCTION);
86
+ function isObject(value) {
87
+ if (!value && isNullOrUndefined(value)) {
88
+ return false;
61
89
  }
62
- function tmpFunc() { }
63
- tmpFunc[strShimPrototype] = obj;
64
- return new tmpFunc();
90
+ return !!value && typeof value === OBJECT;
91
+ }
92
+ var isArray = ArrCls.isArray;
93
+ var isNumber = _createIs(NUMBER);
94
+ var isError = _createObjIs("Error");
95
+ function isPromiseLike(value) {
96
+ return !!value && isFunction(value.then);
65
97
  }
66
98
 
67
- (getGlobal() || {})["Symbol"];
68
- (getGlobal() || {})["Reflect"];
69
- var extendStaticsFn = function (d, b) {
70
- extendStaticsFn = ObjClass$1["setPrototypeOf"] ||
71
- ({ __proto__: [] } instanceof Array && function (d, b) {
72
- d.__proto__ = b;
73
- }) ||
74
- function (d, b) {
75
- for (var p in b) {
76
- if (b[strShimHasOwnProperty](p)) {
77
- d[p] = b[p];
99
+ var objGetOwnPropertyDescriptor = ObjClass.getOwnPropertyDescriptor;
100
+
101
+ function objHasOwnProperty(obj, prop) {
102
+ return obj && ObjProto.hasOwnProperty.call(obj, prop);
103
+ }
104
+
105
+ var objHasOwn = ObjClass["hasOwn"] || polyObjHasOwn;
106
+ function polyObjHasOwn(obj, prop) {
107
+ return objHasOwnProperty(obj, prop) || !!objGetOwnPropertyDescriptor(obj, prop);
108
+ }
109
+
110
+ function objForEachKey(theObject, callbackfn, thisArg) {
111
+ if (theObject && isObject(theObject)) {
112
+ for (var prop in theObject) {
113
+ if (objHasOwn(theObject, prop)) {
114
+ if (callbackfn.call(thisArg || theObject, prop, theObject[prop]) === -1) {
115
+ break;
78
116
  }
79
117
  }
80
- };
81
- return extendStaticsFn(d, b);
82
- };
83
- function __extendsFn(d, b) {
84
- if (typeof b !== strShimFunction && b !== null) {
85
- throwTypeError$1("Class extends value " + String(b) + " is not a constructor or null");
118
+ }
86
119
  }
87
- extendStaticsFn(d, b);
88
- function __() {
89
- this.constructor = d;
120
+ }
121
+
122
+ function _createKeyValueMap(values, keyType, valueType, completeFn) {
123
+ var theMap = {};
124
+ objForEachKey(values, function (key, value) {
125
+ theMap[key] = keyType ? value : key;
126
+ theMap[value] = valueType ? value : key;
127
+ });
128
+ return completeFn(theMap);
129
+ }
130
+
131
+ function throwTypeError(message) {
132
+ throw new TypeError(message);
133
+ }
134
+
135
+ function polyObjEntries(value) {
136
+ var result = [];
137
+ objForEachKey(value, function (key, value) {
138
+ result.push([key, value]);
139
+ });
140
+ return result;
141
+ }
142
+ function polyObjValues(value) {
143
+ var result = [];
144
+ objForEachKey(value, function (key, value) {
145
+ result.push(value);
146
+ });
147
+ return result;
148
+ }
149
+
150
+ var _objFreeze = ObjClass["freeze"];
151
+ var _doNothing = function (value) { return value; };
152
+ var _getProto = function (value) { return value[__PROTO__] || NULL_VALUE; };
153
+ ObjClass["assign"];
154
+ function objDeepFreeze(value) {
155
+ if (_objFreeze) {
156
+ objForEachKey(value, function (key, value) {
157
+ if (isArray(value) || isObject(value)) {
158
+ _objFreeze(value);
159
+ }
160
+ });
90
161
  }
91
- d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
162
+ return objFreeze(value);
92
163
  }
164
+ var objFreeze = _objFreeze || _doNothing;
165
+ ObjClass["seal"] || _doNothing;
166
+ var objGetPrototypeOf = ObjClass["getPrototypeOf"] || _getProto;
167
+ ObjClass.entries || polyObjEntries;
168
+ ObjClass.values || polyObjValues;
93
169
 
94
- /*!
95
- * Microsoft Dynamic Proto Utility, 1.1.9
96
- * Copyright (c) Microsoft and contributors. All rights reserved.
97
- */
98
- var _a;
99
- var UNDEFINED = "undefined";
100
- var Constructor = 'constructor';
101
- var Prototype = 'prototype';
102
- var strFunction = 'function';
103
- var DynInstFuncTable = '_dynInstFuncs';
104
- var DynProxyTag = '_isDynProxy';
105
- var DynClassName = '_dynClass';
106
- var DynClassNamePrefix = '_dynCls$';
107
- var DynInstChkTag = '_dynInstChk';
108
- var DynAllowInstChkTag = DynInstChkTag;
109
- var DynProtoDefaultOptions = '_dfOpts';
110
- var UnknownValue = '_unknown_';
111
- var str__Proto$1 = "__proto__";
112
- var DynProtoBaseProto = "_dyn" + str__Proto$1;
113
- var DynProtoGlobalSettings = "__dynProto$Gbl";
114
- var DynProtoCurrent = "_dynInstProto";
115
- var strUseBaseInst = 'useBaseInst';
116
- var strSetInstFuncs = 'setInstFuncs';
117
- var Obj = Object;
118
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
119
- var _objGetOwnProps = Obj["getOwnPropertyNames"];
120
- function _getGlobal() {
170
+ function createEnumKeyMap(values) {
171
+ return _createKeyValueMap(values, 0 , 0 , objDeepFreeze);
172
+ }
173
+
174
+ var _wellKnownSymbolMap = createEnumKeyMap({
175
+ asyncIterator: 0 ,
176
+ hasInstance: 1 ,
177
+ isConcatSpreadable: 2 ,
178
+ iterator: 3 ,
179
+ match: 4 ,
180
+ matchAll: 5 ,
181
+ replace: 6 ,
182
+ search: 7 ,
183
+ species: 8 ,
184
+ split: 9 ,
185
+ toPrimitive: 10 ,
186
+ toStringTag: 11 ,
187
+ unscopables: 12
188
+ });
189
+
190
+ var asString = StrCls;
191
+
192
+ var GLOBAL_CONFIG_KEY = "__tsUtils$gblCfg";
193
+ var _globalCfg;
194
+ function _getGlobalValue() {
121
195
  var result;
122
196
  if (typeof globalThis !== UNDEFINED) {
123
197
  result = globalThis;
@@ -131,587 +205,1693 @@
131
205
  if (!result && typeof global !== UNDEFINED) {
132
206
  result = global;
133
207
  }
134
- return result || {};
135
- }
136
- var _gbl = _getGlobal();
137
- var _gblInst = _gbl[DynProtoGlobalSettings] || (_gbl[DynProtoGlobalSettings] = {
138
- o: (_a = {},
139
- _a[strSetInstFuncs] = true,
140
- _a[strUseBaseInst] = true,
141
- _a),
142
- n: 1000
143
- });
144
- function _hasOwnProperty(obj, prop) {
145
- return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
146
- }
147
- function _isObjectOrArrayPrototype(target) {
148
- return target && (target === Obj[Prototype] || target === Array[Prototype]);
149
- }
150
- function _isObjectArrayOrFunctionPrototype(target) {
151
- return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
208
+ return result;
152
209
  }
153
- function _getObjProto$1(target) {
154
- var newProto;
155
- if (target) {
156
- if (_objGetPrototypeOf$1) {
157
- return _objGetPrototypeOf$1(target);
158
- }
159
- var curProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
160
- newProto = target[DynProtoBaseProto] || curProto;
161
- if (!_hasOwnProperty(target, DynProtoBaseProto)) {
162
- delete target[DynProtoCurrent];
163
- newProto = target[DynProtoBaseProto] = target[DynProtoCurrent] || target[DynProtoBaseProto];
164
- target[DynProtoCurrent] = curProto;
165
- }
210
+ function _getGlobalConfig() {
211
+ if (!_globalCfg) {
212
+ var gbl = _getGlobalValue() || {};
213
+ _globalCfg = gbl[GLOBAL_CONFIG_KEY] = gbl[GLOBAL_CONFIG_KEY] || {};
166
214
  }
167
- return newProto;
215
+ return _globalCfg;
168
216
  }
169
- function _forEachProp(target, func) {
170
- var props = [];
171
- if (_objGetOwnProps) {
172
- props = _objGetOwnProps(target);
217
+
218
+ function dumpObj(object, format) {
219
+ var propertyValueDump = EMPTY;
220
+ if (isError(object)) {
221
+ propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
173
222
  }
174
223
  else {
175
- for (var name_1 in target) {
176
- if (typeof name_1 === "string" && _hasOwnProperty(target, name_1)) {
177
- props.push(name_1);
178
- }
224
+ try {
225
+ propertyValueDump = JSON.stringify(object, NULL_VALUE, format ? (isNumber(format) ? format : 4) : UNDEF_VALUE);
179
226
  }
180
- }
181
- if (props && props.length > 0) {
182
- for (var lp = 0; lp < props.length; lp++) {
183
- func(props[lp]);
227
+ catch (e) {
228
+ propertyValueDump = " - " + dumpObj(e, format);
184
229
  }
185
230
  }
231
+ return objToString(object) + ": " + propertyValueDump;
186
232
  }
187
- function _isDynamicCandidate(target, funcName, skipOwn) {
188
- return (funcName !== Constructor && typeof target[funcName] === strFunction && (skipOwn || _hasOwnProperty(target, funcName)));
189
- }
190
- function _throwTypeError(message) {
191
- throw new TypeError("DynamicProto: " + message);
192
- }
193
- function _getInstanceFuncs(thisTarget) {
194
- var instFuncs = {};
195
- _forEachProp(thisTarget, function (name) {
196
- if (!instFuncs[name] && _isDynamicCandidate(thisTarget, name, false)) {
197
- instFuncs[name] = thisTarget[name];
233
+
234
+ var _arrSlice = ArrProto[SLICE];
235
+ var _throwMissingFunction = function (funcName, thisArg) {
236
+ throwTypeError("'" + asString(funcName) + "' not defined for " + dumpObj(thisArg));
237
+ };
238
+ var _unwrapInstFunction = function (funcName) {
239
+ return function (thisArg) {
240
+ return thisArg[funcName].apply(thisArg, _arrSlice.call(arguments, 1));
241
+ };
242
+ };
243
+ var _unwrapFunction = function (funcName, clsProto) {
244
+ var clsFn = clsProto && clsProto[funcName];
245
+ return function (thisArg) {
246
+ var theFunc = (thisArg && thisArg[funcName]) || clsFn;
247
+ if (theFunc) {
248
+ return theFunc.apply(thisArg, _arrSlice.call(arguments, 1));
198
249
  }
199
- });
200
- return instFuncs;
250
+ _throwMissingFunction(funcName, thisArg);
251
+ };
252
+ };
253
+
254
+ var _polySymbols;
255
+ function _globalSymbolRegistry() {
256
+ if (!_polySymbols) {
257
+ var gblCfg = _getGlobalConfig();
258
+ _polySymbols = gblCfg.gblSym = gblCfg.gblSym || { k: {}, s: {} };
259
+ }
260
+ return _polySymbols;
261
+ }
262
+ var _wellKnownSymbolCache = {};
263
+ function polyNewSymbol(description) {
264
+ var theSymbol = {
265
+ description: asString(description),
266
+ toString: function () { return SYMBOL + "(" + description + ")"; }
267
+ };
268
+ theSymbol[POLYFILL_TAG] = true;
269
+ return theSymbol;
201
270
  }
202
- function _hasVisited(values, value) {
203
- for (var lp = values.length - 1; lp >= 0; lp--) {
204
- if (values[lp] === value) {
205
- return true;
206
- }
271
+ function polySymbolFor(key) {
272
+ var registry = _globalSymbolRegistry();
273
+ if (!objHasOwn(registry, key)) {
274
+ var newSymbol = polyNewSymbol(key);
275
+ registry.k[key] = newSymbol;
276
+ registry.s[newSymbol] = asString(key);
207
277
  }
208
- return false;
278
+ return registry.k[key];
209
279
  }
210
- function _getBaseFuncs(classProto, thisTarget, instFuncs, useBaseInst) {
211
- function _instFuncProxy(target, funcHost, funcName) {
212
- var theFunc = funcHost[funcName];
213
- if (theFunc[DynProxyTag] && useBaseInst) {
214
- var instFuncTable = target[DynInstFuncTable] || {};
215
- if (instFuncTable[DynAllowInstChkTag] !== false) {
216
- theFunc = (instFuncTable[funcHost[DynClassName]] || {})[funcName] || theFunc;
217
- }
280
+ function polyGetKnownSymbol(name) {
281
+ var result;
282
+ var knownName = _wellKnownSymbolMap[name];
283
+ if (knownName) {
284
+ result = _wellKnownSymbolCache[knownName] = _wellKnownSymbolCache[knownName] || polyNewSymbol(SYMBOL + "." + knownName);
285
+ }
286
+ return result;
287
+ }
288
+
289
+ var propMap = {
290
+ e: "enumerable",
291
+ c: "configurable",
292
+ v: VALUE,
293
+ w: "writable",
294
+ g: "get",
295
+ s: "set"
296
+ };
297
+ function _createProp(value) {
298
+ var prop = {};
299
+ prop[propMap["c"]] = true;
300
+ prop[propMap["e"]] = true;
301
+ if (value.l) {
302
+ prop.get = function () { return value.l.v; };
303
+ var desc = objGetOwnPropertyDescriptor(value.l, "v");
304
+ if (desc && desc.set) {
305
+ prop.set = function (newValue) {
306
+ value.l.v = newValue;
307
+ };
218
308
  }
219
- return function () {
220
- return theFunc.apply(target, arguments);
221
- };
222
309
  }
223
- var baseFuncs = {};
224
- _forEachProp(instFuncs, function (name) {
225
- baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
310
+ objForEachKey(value, function (key, value) {
311
+ prop[propMap[key]] = isUndefined(value) ? prop[propMap[key]] : value;
226
312
  });
227
- var baseProto = _getObjProto$1(classProto);
228
- var visited = [];
229
- while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
230
- _forEachProp(baseProto, function (name) {
231
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
232
- baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
233
- }
234
- });
235
- visited.push(baseProto);
236
- baseProto = _getObjProto$1(baseProto);
237
- }
238
- return baseFuncs;
313
+ return prop;
239
314
  }
240
- function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
241
- var instFunc = null;
242
- if (target && _hasOwnProperty(proto, DynClassName)) {
243
- var instFuncTable = target[DynInstFuncTable] || {};
244
- instFunc = (instFuncTable[proto[DynClassName]] || {})[funcName];
245
- if (!instFunc) {
246
- _throwTypeError("Missing [" + funcName + "] " + strFunction);
247
- }
248
- if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
249
- var canAddInst = !_hasOwnProperty(target, funcName);
250
- var objProto = _getObjProto$1(target);
251
- var visited = [];
252
- while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
253
- var protoFunc = objProto[funcName];
254
- if (protoFunc) {
255
- canAddInst = (protoFunc === currentDynProtoProxy);
256
- break;
257
- }
258
- visited.push(objProto);
259
- objProto = _getObjProto$1(objProto);
260
- }
261
- try {
262
- if (canAddInst) {
263
- target[funcName] = instFunc;
315
+ var objDefineProp = ObjClass["defineProperty"];
316
+ function objDefine(target, key, propDesc) {
317
+ return objDefineProp(target, key, _createProp(propDesc));
318
+ }
319
+
320
+ var _globalLazyTestHooks;
321
+ var _fetchLazyTestHooks = function () {
322
+ _globalLazyTestHooks = _getGlobalConfig();
323
+ _fetchLazyTestHooks = NULL_VALUE;
324
+ };
325
+ function getLazy(cb) {
326
+ var lazyValue = {};
327
+ _fetchLazyTestHooks && _fetchLazyTestHooks();
328
+ lazyValue.b = _globalLazyTestHooks.lzy;
329
+ objDefineProp(lazyValue, "v", {
330
+ configurable: true,
331
+ get: function () {
332
+ var result = cb();
333
+ if (!_globalLazyTestHooks.lzy) {
334
+ objDefineProp(lazyValue, "v", {
335
+ value: result
336
+ });
337
+ if (lazyValue.b) {
338
+ delete lazyValue.b;
264
339
  }
265
- instFunc[DynInstChkTag] = 1;
266
340
  }
267
- catch (e) {
268
- instFuncTable[DynAllowInstChkTag] = false;
341
+ if (_globalLazyTestHooks.lzy && lazyValue.b !== _globalLazyTestHooks.lzy) {
342
+ lazyValue.b = _globalLazyTestHooks.lzy;
269
343
  }
344
+ return result;
270
345
  }
271
- }
272
- return instFunc;
346
+ });
347
+ return lazyValue;
273
348
  }
274
- function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
275
- var protoFunc = proto[funcName];
276
- if (protoFunc === currentDynProtoProxy) {
277
- protoFunc = _getObjProto$1(proto)[funcName];
349
+
350
+ function safeGetLazy(cb, defValue) {
351
+ return getLazy(function () { return safeGet(cb, defValue); });
352
+ }
353
+
354
+ var WINDOW = "window";
355
+ var _cachedGlobal;
356
+ var _cachedWindow;
357
+ var _cachedNavigator;
358
+ var lazySafeGetInst = function (name) { return safeGetLazy(function () { return getInst(name) || UNDEF_VALUE; }, UNDEF_VALUE); };
359
+ var getGlobal = function (useCached) {
360
+ (!_cachedGlobal || useCached === false || (_globalLazyTestHooks && _globalLazyTestHooks.lzy && !_cachedGlobal.b)) && (_cachedGlobal = safeGetLazy(_getGlobalValue, NULL_VALUE));
361
+ return _cachedGlobal.v;
362
+ };
363
+ var getInst = function (name, useCached) {
364
+ var gbl = (!_cachedGlobal || useCached === false) ? getGlobal(useCached) : _cachedGlobal.v;
365
+ if (gbl && gbl[name]) {
366
+ return gbl[name];
278
367
  }
279
- if (typeof protoFunc !== strFunction) {
280
- _throwTypeError("[" + funcName + "] is not a " + strFunction);
368
+ if (name === WINDOW && _cachedWindow) {
369
+ return _cachedWindow.v;
281
370
  }
282
- return protoFunc;
371
+ return NULL_VALUE;
372
+ };
373
+ var hasWindow = function () { return !!getWindow(); };
374
+ var getWindow = function () {
375
+ (!_cachedWindow || (_globalLazyTestHooks && _globalLazyTestHooks.lzy && !_cachedWindow.b)) && (_cachedWindow = lazySafeGetInst(WINDOW));
376
+ return _cachedWindow.v;
377
+ };
378
+ var getNavigator = function () {
379
+ (!_cachedNavigator || (_globalLazyTestHooks && _globalLazyTestHooks.lzy && !_cachedNavigator.b)) && (_cachedNavigator = lazySafeGetInst("navigator"));
380
+ return _cachedNavigator.v;
381
+ };
382
+
383
+ var _symbol;
384
+ var _symbolFor;
385
+ var _symbolKeyFor;
386
+ function _getSymbolValue(name) {
387
+ return safeGetLazy(function () {
388
+ return (_symbol.v ? _symbol[name] : UNDEF_VALUE);
389
+ }, UNDEF_VALUE);
390
+ }
391
+ function getSymbol() {
392
+ var resetCache = !_symbol || (_globalLazyTestHooks && _globalLazyTestHooks.lzy && !_symbol.b);
393
+ resetCache && (_symbol = lazySafeGetInst(SYMBOL));
394
+ (!_symbolFor || resetCache) && (_symbolFor = _getSymbolValue("for"));
395
+ (!_symbolKeyFor || resetCache) && (_symbolKeyFor = _getSymbolValue("keyFor"));
396
+ return _symbol.v;
397
+ }
398
+ function getKnownSymbol(name, noPoly) {
399
+ var knownName = _wellKnownSymbolMap[name];
400
+ (!_symbol || (_globalLazyTestHooks.lzy && !_symbol.b)) && getSymbol();
401
+ return _symbol.v ? _symbol.v[knownName || name] : (!noPoly ? polyGetKnownSymbol(name) : UNDEF_VALUE);
402
+ }
403
+ function newSymbol(description, noPoly) {
404
+ (!_symbol || (_globalLazyTestHooks.lzy && !_symbol.b)) && getSymbol();
405
+ return _symbol.v ? _symbol.v(description) : (!noPoly ? polyNewSymbol(description) : NULL_VALUE);
406
+ }
407
+ function symbolFor(key) {
408
+ (!_symbolFor || (_globalLazyTestHooks.lzy && !_symbol.b)) && getSymbol();
409
+ return (_symbolFor.v || polySymbolFor)(key);
283
410
  }
284
- function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
285
- function _createDynamicPrototype(proto, funcName) {
286
- var dynProtoProxy = function () {
287
- var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
288
- return instFunc.apply(this, arguments);
411
+
412
+ function isIterator(value) {
413
+ return !!value && isFunction(value.next);
414
+ }
415
+ function isIterable(value) {
416
+ return !isStrictNullOrUndefined(value) && isFunction(value[getKnownSymbol(3 )]);
417
+ }
418
+
419
+ var _iterSymbol;
420
+ function iterForOf(iter, callbackfn, thisArg) {
421
+ if (iter) {
422
+ if (!isIterator(iter)) {
423
+ !_iterSymbol && (_iterSymbol = getLazy(function () { return getKnownSymbol(3 ); }));
424
+ iter = iter[_iterSymbol.v] ? iter[_iterSymbol.v]() : null;
425
+ }
426
+ if (isIterator(iter)) {
427
+ var err = void 0;
428
+ var iterResult = void 0;
429
+ try {
430
+ var count = 0;
431
+ while (!(iterResult = iter.next())[DONE]) {
432
+ if (callbackfn.call(thisArg || iter, iterResult[VALUE], count, iter) === -1) {
433
+ break;
434
+ }
435
+ count++;
436
+ }
437
+ }
438
+ catch (failed) {
439
+ err = { e: failed };
440
+ if (iter.throw) {
441
+ iterResult = null;
442
+ iter.throw(err);
443
+ }
444
+ }
445
+ finally {
446
+ try {
447
+ if (iterResult && !iterResult[DONE]) {
448
+ iter.return && iter.return(iterResult);
449
+ }
450
+ }
451
+ finally {
452
+ if (err) {
453
+ throw err.e;
454
+ }
455
+ }
456
+ }
457
+ }
458
+ }
459
+ }
460
+
461
+ var fnApply = _unwrapInstFunction("apply");
462
+
463
+ function arrAppend(target, elms) {
464
+ if (!isUndefined(elms) && target) {
465
+ if (isArray(elms)) {
466
+ fnApply(target.push, target, elms);
467
+ }
468
+ else if (isIterator(elms) || isIterable(elms)) {
469
+ iterForOf(elms, function (elm) {
470
+ target.push(elm);
471
+ });
472
+ }
473
+ else {
474
+ target.push(elms);
475
+ }
476
+ }
477
+ return target;
478
+ }
479
+
480
+ function arrForEach(theArray, callbackfn, thisArg) {
481
+ if (theArray) {
482
+ var len = theArray[LENGTH] >>> 0;
483
+ for (var idx = 0; idx < len; idx++) {
484
+ if (idx in theArray) {
485
+ if (callbackfn.call(thisArg || theArray, theArray[idx], idx, theArray) === -1) {
486
+ break;
487
+ }
488
+ }
489
+ }
490
+ }
491
+ }
492
+
493
+ var arrIndexOf = _unwrapFunction(INDEX_OF, ArrProto);
494
+ _unwrapFunction(LAST_INDEX_OF, ArrProto);
495
+
496
+ var arrSlice = _unwrapFunction(SLICE, ArrProto);
497
+
498
+ var fnCall = _unwrapInstFunction("call");
499
+
500
+ var _objCreate = ObjClass["create"];
501
+ var objCreate = _objCreate || polyObjCreate;
502
+ function polyObjCreate(obj) {
503
+ if (!obj) {
504
+ return {};
505
+ }
506
+ var type = typeof obj;
507
+ if (type !== OBJECT && type !== FUNCTION) {
508
+ throw new TypeError("Prototype must be an Object or function: " + dumpObj(obj));
509
+ }
510
+ function tempFunc() { }
511
+ tempFunc[PROTOTYPE] = obj;
512
+ return new tempFunc();
513
+ }
514
+
515
+ var _isProtoArray;
516
+ function objSetPrototypeOf(obj, proto) {
517
+ var fn = ObjClass["setPrototypeOf"] ||
518
+ function (d, b) {
519
+ !_isProtoArray && (_isProtoArray = getLazy(function () {
520
+ var _a;
521
+ return ((_a = {}, _a[__PROTO__] = [], _a) instanceof Array);
522
+ }));
523
+ _isProtoArray.v ? d[__PROTO__] = b : objForEachKey(b, function (key, value) { return d[key] = value; });
289
524
  };
290
- dynProtoProxy[DynProxyTag] = 1;
291
- return dynProtoProxy;
525
+ return fn(obj, proto);
526
+ }
527
+
528
+ var _createCustomError = function (name, d, b) {
529
+ _safeDefineName(d, name);
530
+ d = objSetPrototypeOf(d, b);
531
+ function __() {
532
+ this.constructor = d;
533
+ _safeDefineName(this, name);
292
534
  }
293
- if (!_isObjectOrArrayPrototype(proto)) {
294
- var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
295
- var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
296
- if (instFuncTable[DynAllowInstChkTag] !== false) {
297
- instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
535
+ d[PROTOTYPE] = b === NULL_VALUE ? objCreate(b) : (__[PROTOTYPE] = b[PROTOTYPE], new __());
536
+ return d;
537
+ };
538
+ var _safeSetName = function (baseClass, name) {
539
+ try {
540
+ name && (baseClass[NAME] = name);
541
+ }
542
+ catch (e) {
543
+ }
544
+ };
545
+ var _safeDefineName = function (target, name) {
546
+ try {
547
+ objDefine(target, NAME, { v: name, c: true, e: false });
548
+ }
549
+ catch (e) {
550
+ }
551
+ };
552
+ function createCustomError(name, constructCb, errorBase) {
553
+ var theBaseClass = errorBase || Error;
554
+ var orgName = theBaseClass[PROTOTYPE][NAME];
555
+ var captureFn = Error.captureStackTrace;
556
+ return _createCustomError(name, function () {
557
+ var _this = this;
558
+ try {
559
+ _safeSetName(theBaseClass, name);
560
+ var _self = fnApply(theBaseClass, _this, arrSlice(arguments)) || _this;
561
+ if (_self !== _this) {
562
+ var orgProto = objGetPrototypeOf(_this);
563
+ if (orgProto !== objGetPrototypeOf(_self)) {
564
+ objSetPrototypeOf(_self, orgProto);
565
+ }
566
+ }
567
+ captureFn && captureFn(_self, _this[CONSTRUCTOR]);
568
+ constructCb && constructCb(_self, arguments);
569
+ return _self;
570
+ }
571
+ finally {
572
+ _safeSetName(theBaseClass, orgName);
573
+ }
574
+ }, theBaseClass);
575
+ }
576
+
577
+ function utcNow() {
578
+ return (Date.now || polyUtcNow)();
579
+ }
580
+ function polyUtcNow() {
581
+ return new Date().getTime();
582
+ }
583
+
584
+ var _fnToString;
585
+ var _objCtrFnString;
586
+ var _gblWindow;
587
+ function isPlainObject(value) {
588
+ if (!value || typeof value !== OBJECT) {
589
+ return false;
590
+ }
591
+ if (!_gblWindow) {
592
+ _gblWindow = hasWindow() ? getWindow() : true;
593
+ }
594
+ var result = false;
595
+ if (value !== _gblWindow) {
596
+ if (!_objCtrFnString) {
597
+ _fnToString = Function[PROTOTYPE].toString;
598
+ _objCtrFnString = fnCall(_fnToString, ObjClass);
599
+ }
600
+ try {
601
+ var proto = objGetPrototypeOf(value);
602
+ result = !proto;
603
+ if (!result) {
604
+ if (objHasOwnProperty(proto, CONSTRUCTOR)) {
605
+ proto = proto[CONSTRUCTOR];
606
+ }
607
+ result = proto && typeof proto === FUNCTION && _fnToString.call(proto) === _objCtrFnString;
608
+ }
609
+ }
610
+ catch (ex) {
611
+ }
612
+ }
613
+ return result;
614
+ }
615
+
616
+ var strIndexOf = _unwrapFunction(INDEX_OF, StrProto);
617
+ _unwrapFunction(LAST_INDEX_OF, StrProto);
618
+
619
+ var REF = "ref";
620
+ var UNREF = "un" + REF;
621
+ var HAS_REF = "hasRef";
622
+ var ENABLED = "enabled";
623
+ function _createTimerHandler(startTimer, refreshFn, cancelFn) {
624
+ var _a;
625
+ var ref = true;
626
+ var timerId = startTimer ? refreshFn(NULL_VALUE) : NULL_VALUE;
627
+ var theTimerHandler;
628
+ var _unref = function () {
629
+ ref = false;
630
+ timerId && timerId[UNREF] && timerId[UNREF]();
631
+ return theTimerHandler;
632
+ };
633
+ var _ref = function () {
634
+ ref = true;
635
+ timerId && timerId[REF] && timerId[REF]();
636
+ return theTimerHandler;
637
+ };
638
+ var _hasRef = function () {
639
+ if (timerId && timerId[HAS_REF]) {
640
+ return timerId[HAS_REF]();
641
+ }
642
+ return ref;
643
+ };
644
+ var _refresh = function () {
645
+ timerId = refreshFn(timerId);
646
+ if (!ref) {
647
+ _unref();
648
+ }
649
+ return theTimerHandler;
650
+ };
651
+ var _cancel = function () {
652
+ timerId && cancelFn(timerId);
653
+ timerId = NULL_VALUE;
654
+ };
655
+ var _setEnabled = function (value) {
656
+ !value && timerId && _cancel();
657
+ value && !timerId && _refresh();
658
+ };
659
+ theTimerHandler = (_a = {
660
+ cancel: _cancel,
661
+ refresh: _refresh
662
+ },
663
+ _a[HAS_REF] = _hasRef,
664
+ _a[REF] = _ref,
665
+ _a[UNREF] = _unref,
666
+ _a[ENABLED] = false,
667
+ _a);
668
+ objDefineProp(theTimerHandler, ENABLED, {
669
+ get: function () { return !!timerId; },
670
+ set: _setEnabled
671
+ });
672
+ return {
673
+ h: theTimerHandler,
674
+ dn: function () {
675
+ timerId = NULL_VALUE;
676
+ }
677
+ };
678
+ }
679
+
680
+ function _createTimeoutWith(self, startTimer, overrideFn, theArgs) {
681
+ var isArr = isArray(overrideFn);
682
+ var len = isArr ? overrideFn.length : 0;
683
+ var setFn = (len > 0 ? overrideFn[0] : (!isArr ? overrideFn : UNDEF_VALUE)) || setTimeout;
684
+ var clearFn = (len > 1 ? overrideFn[1] : UNDEF_VALUE) || clearTimeout;
685
+ var timerFn = theArgs[0];
686
+ theArgs[0] = function () {
687
+ handler.dn();
688
+ fnApply(timerFn, self, arrSlice(arguments));
689
+ };
690
+ var handler = _createTimerHandler(startTimer, function (timerId) {
691
+ if (timerId) {
692
+ if (timerId.refresh) {
693
+ timerId.refresh();
694
+ return timerId;
695
+ }
696
+ fnApply(clearFn, self, [timerId]);
697
+ }
698
+ return fnApply(setFn, self, theArgs);
699
+ }, function (timerId) {
700
+ fnApply(clearFn, self, [timerId]);
701
+ });
702
+ return handler.h;
703
+ }
704
+ function scheduleTimeout(callback, timeout) {
705
+ return _createTimeoutWith(this, true, UNDEF_VALUE, arrSlice(arguments));
706
+ }
707
+
708
+ (getGlobal() || {})["Symbol"];
709
+ (getGlobal() || {})["Reflect"];
710
+ var strHasOwnProperty = "hasOwnProperty";
711
+ var extendStaticsFn = function (d, b) {
712
+ extendStaticsFn = ObjClass$1["setPrototypeOf"] ||
713
+ ({ __proto__: [] } instanceof Array && function (d, b) {
714
+ d.__proto__ = b;
715
+ }) ||
716
+ function (d, b) {
717
+ for (var p in b) {
718
+ if (b[strHasOwnProperty](p)) {
719
+ d[p] = b[p];
720
+ }
721
+ }
722
+ };
723
+ return extendStaticsFn(d, b);
724
+ };
725
+ function __extendsFn(d, b) {
726
+ if (typeof b !== strShimFunction && b !== null) {
727
+ throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
728
+ }
729
+ extendStaticsFn(d, b);
730
+ function __() {
731
+ this.constructor = d;
732
+ }
733
+ d[strShimPrototype] = b === null ? objCreate(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
734
+ }
735
+
736
+ function getReactNativeDeviceInfo() {
737
+ return DeviceInfo__default["default"];
738
+ }
739
+
740
+ var _a$2;
741
+ var Constructor = 'constructor';
742
+ var Prototype = 'prototype';
743
+ var strFunction = 'function';
744
+ var DynInstFuncTable = '_dynInstFuncs';
745
+ var DynProxyTag = '_isDynProxy';
746
+ var DynClassName = '_dynClass';
747
+ var DynClassNamePrefix = '_dynCls$';
748
+ var DynInstChkTag = '_dynInstChk';
749
+ var DynAllowInstChkTag = DynInstChkTag;
750
+ var DynProtoDefaultOptions = '_dfOpts';
751
+ var UnknownValue = '_unknown_';
752
+ var str__Proto = "__proto__";
753
+ var DynProtoBaseProto = "_dyn" + str__Proto;
754
+ var DynProtoGlobalSettings = "__dynProto$Gbl";
755
+ var DynProtoCurrent = "_dynInstProto";
756
+ var strUseBaseInst = 'useBaseInst';
757
+ var strSetInstFuncs = 'setInstFuncs';
758
+ var Obj = Object;
759
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
760
+ var _objGetOwnProps = Obj["getOwnPropertyNames"];
761
+ var _gbl = getGlobal();
762
+ var _gblInst = _gbl[DynProtoGlobalSettings] || (_gbl[DynProtoGlobalSettings] = {
763
+ o: (_a$2 = {},
764
+ _a$2[strSetInstFuncs] = true,
765
+ _a$2[strUseBaseInst] = true,
766
+ _a$2),
767
+ n: 1000
768
+ });
769
+ function _isObjectOrArrayPrototype(target) {
770
+ return target && (target === Obj[Prototype] || target === Array[Prototype]);
771
+ }
772
+ function _isObjectArrayOrFunctionPrototype(target) {
773
+ return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
774
+ }
775
+ function _getObjProto(target) {
776
+ var newProto;
777
+ if (target) {
778
+ if (_objGetPrototypeOf) {
779
+ return _objGetPrototypeOf(target);
780
+ }
781
+ var curProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
782
+ newProto = target[DynProtoBaseProto] || curProto;
783
+ if (!objHasOwnProperty(target, DynProtoBaseProto)) {
784
+ delete target[DynProtoCurrent];
785
+ newProto = target[DynProtoBaseProto] = target[DynProtoCurrent] || target[DynProtoBaseProto];
786
+ target[DynProtoCurrent] = curProto;
787
+ }
788
+ }
789
+ return newProto;
790
+ }
791
+ function _forEachProp(target, func) {
792
+ var props = [];
793
+ if (_objGetOwnProps) {
794
+ props = _objGetOwnProps(target);
795
+ }
796
+ else {
797
+ for (var name_1 in target) {
798
+ if (typeof name_1 === "string" && objHasOwnProperty(target, name_1)) {
799
+ props.push(name_1);
800
+ }
801
+ }
802
+ }
803
+ if (props && props.length > 0) {
804
+ for (var lp = 0; lp < props.length; lp++) {
805
+ func(props[lp]);
806
+ }
807
+ }
808
+ }
809
+ function _isDynamicCandidate(target, funcName, skipOwn) {
810
+ return (funcName !== Constructor && typeof target[funcName] === strFunction && (skipOwn || objHasOwnProperty(target, funcName)));
811
+ }
812
+ function _throwTypeError(message) {
813
+ throwTypeError("DynamicProto: " + message);
814
+ }
815
+ function _getInstanceFuncs(thisTarget) {
816
+ var instFuncs = {};
817
+ _forEachProp(thisTarget, function (name) {
818
+ if (!instFuncs[name] && _isDynamicCandidate(thisTarget, name, false)) {
819
+ instFuncs[name] = thisTarget[name];
820
+ }
821
+ });
822
+ return instFuncs;
823
+ }
824
+ function _hasVisited(values, value) {
825
+ for (var lp = values.length - 1; lp >= 0; lp--) {
826
+ if (values[lp] === value) {
827
+ return true;
828
+ }
829
+ }
830
+ return false;
831
+ }
832
+ function _getBaseFuncs(classProto, thisTarget, instFuncs, useBaseInst) {
833
+ function _instFuncProxy(target, funcHost, funcName) {
834
+ var theFunc = funcHost[funcName];
835
+ if (theFunc[DynProxyTag] && useBaseInst) {
836
+ var instFuncTable = target[DynInstFuncTable] || {};
837
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
838
+ theFunc = (instFuncTable[funcHost[DynClassName]] || {})[funcName] || theFunc;
839
+ }
840
+ }
841
+ return function () {
842
+ return theFunc.apply(target, arguments);
843
+ };
844
+ }
845
+ var baseFuncs = {};
846
+ _forEachProp(instFuncs, function (name) {
847
+ baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
848
+ });
849
+ var baseProto = _getObjProto(classProto);
850
+ var visited = [];
851
+ while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
852
+ _forEachProp(baseProto, function (name) {
853
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
854
+ baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
855
+ }
856
+ });
857
+ visited.push(baseProto);
858
+ baseProto = _getObjProto(baseProto);
859
+ }
860
+ return baseFuncs;
861
+ }
862
+ function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
863
+ var instFunc = null;
864
+ if (target && objHasOwnProperty(proto, DynClassName)) {
865
+ var instFuncTable = target[DynInstFuncTable] || {};
866
+ instFunc = (instFuncTable[proto[DynClassName]] || {})[funcName];
867
+ if (!instFunc) {
868
+ _throwTypeError("Missing [" + funcName + "] " + strFunction);
869
+ }
870
+ if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
871
+ var canAddInst = !objHasOwnProperty(target, funcName);
872
+ var objProto = _getObjProto(target);
873
+ var visited = [];
874
+ while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
875
+ var protoFunc = objProto[funcName];
876
+ if (protoFunc) {
877
+ canAddInst = (protoFunc === currentDynProtoProxy);
878
+ break;
879
+ }
880
+ visited.push(objProto);
881
+ objProto = _getObjProto(objProto);
882
+ }
883
+ try {
884
+ if (canAddInst) {
885
+ target[funcName] = instFunc;
886
+ }
887
+ instFunc[DynInstChkTag] = 1;
888
+ }
889
+ catch (e) {
890
+ instFuncTable[DynAllowInstChkTag] = false;
891
+ }
892
+ }
893
+ }
894
+ return instFunc;
895
+ }
896
+ function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
897
+ var protoFunc = proto[funcName];
898
+ if (protoFunc === currentDynProtoProxy) {
899
+ protoFunc = _getObjProto(proto)[funcName];
900
+ }
901
+ if (typeof protoFunc !== strFunction) {
902
+ _throwTypeError("[" + funcName + "] is not a " + strFunction);
903
+ }
904
+ return protoFunc;
905
+ }
906
+ function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
907
+ function _createDynamicPrototype(proto, funcName) {
908
+ var dynProtoProxy = function () {
909
+ var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
910
+ return instFunc.apply(this, arguments);
911
+ };
912
+ dynProtoProxy[DynProxyTag] = 1;
913
+ return dynProtoProxy;
914
+ }
915
+ if (!_isObjectOrArrayPrototype(proto)) {
916
+ var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
917
+ var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
918
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
919
+ instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
920
+ }
921
+ _forEachProp(target, function (name) {
922
+ if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
923
+ instFuncs_1[name] = target[name];
924
+ delete target[name];
925
+ if (!objHasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
926
+ proto[name] = _createDynamicPrototype(proto, name);
927
+ }
928
+ }
929
+ });
930
+ }
931
+ }
932
+ function _checkPrototype(classProto, thisTarget) {
933
+ if (_objGetPrototypeOf) {
934
+ var visited = [];
935
+ var thisProto = _getObjProto(thisTarget);
936
+ while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
937
+ if (thisProto === classProto) {
938
+ return true;
939
+ }
940
+ visited.push(thisProto);
941
+ thisProto = _getObjProto(thisProto);
942
+ }
943
+ return false;
944
+ }
945
+ return true;
946
+ }
947
+ function _getObjName(target, unknownValue) {
948
+ if (objHasOwnProperty(target, Prototype)) {
949
+ return target.name || unknownValue || UnknownValue;
950
+ }
951
+ return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
952
+ }
953
+ function dynamicProto(theClass, target, delegateFunc, options) {
954
+ if (!objHasOwnProperty(theClass, Prototype)) {
955
+ _throwTypeError("theClass is an invalid class definition.");
956
+ }
957
+ var classProto = theClass[Prototype];
958
+ if (!_checkPrototype(classProto, target)) {
959
+ _throwTypeError("[" + _getObjName(theClass) + "] not in hierarchy of [" + _getObjName(target) + "]");
960
+ }
961
+ var className = null;
962
+ if (objHasOwnProperty(classProto, DynClassName)) {
963
+ className = classProto[DynClassName];
964
+ }
965
+ else {
966
+ className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _gblInst.n;
967
+ _gblInst.n++;
968
+ classProto[DynClassName] = className;
969
+ }
970
+ var perfOptions = dynamicProto[DynProtoDefaultOptions];
971
+ var useBaseInst = !!perfOptions[strUseBaseInst];
972
+ if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
973
+ useBaseInst = !!options[strUseBaseInst];
974
+ }
975
+ var instFuncs = _getInstanceFuncs(target);
976
+ var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
977
+ delegateFunc(target, baseFuncs);
978
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
979
+ if (setInstanceFunc && options) {
980
+ setInstanceFunc = !!options[strSetInstFuncs];
981
+ }
982
+ _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
983
+ }
984
+ dynamicProto[DynProtoDefaultOptions] = _gblInst.o;
985
+
986
+ var _DYN_TO_LOWER_CASE = "toLowerCase";
987
+ var _DYN_BLK_VAL = "blkVal";
988
+ var _DYN_LENGTH = "length";
989
+ var _DYN_RD_ONLY = "rdOnly";
990
+ var _DYN_NOTIFY = "notify";
991
+ var _DYN_WARN_TO_CONSOLE = "warnToConsole";
992
+ var _DYN_THROW_INTERNAL = "throwInternal";
993
+ var _DYN_SET_DF = "setDf";
994
+ var _DYN_WATCH = "watch";
995
+ var _DYN_LOGGER = "logger";
996
+ var _DYN_APPLY = "apply";
997
+ var _DYN_PUSH = "push";
998
+ var _DYN_SPLICE = "splice";
999
+ var _DYN_HDLR = "hdlr";
1000
+ var _DYN_CANCEL = "cancel";
1001
+ var _DYN_INITIALIZE = "initialize";
1002
+ var _DYN_IDENTIFIER = "identifier";
1003
+ var _DYN_IS_INITIALIZED = "isInitialized";
1004
+ var _DYN_GET_PLUGIN = "getPlugin";
1005
+ var _DYN_NAME = "name";
1006
+ var _DYN_TIME = "time";
1007
+ var _DYN_PROCESS_NEXT = "processNext";
1008
+ var _DYN_GET_PROCESS_TEL_CONT0 = "getProcessTelContext";
1009
+ var _DYN_UNLOAD = "unload";
1010
+ var _DYN_LOGGING_LEVEL_CONSOL4 = "loggingLevelConsole";
1011
+ var _DYN_CREATE_NEW = "createNew";
1012
+ var _DYN_TEARDOWN = "teardown";
1013
+ var _DYN_MESSAGE_ID = "messageId";
1014
+ var _DYN_MESSAGE = "message";
1015
+ var _DYN_IS_ASYNC = "isAsync";
1016
+ var _DYN_DIAG_LOG = "diagLog";
1017
+ var _DYN__DO_TEARDOWN = "_doTeardown";
1018
+ var _DYN_UPDATE = "update";
1019
+ var _DYN_GET_NEXT = "getNext";
1020
+ var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
1021
+ var _DYN_USER_AGENT = "userAgent";
1022
+ var _DYN_NODE_TYPE = "nodeType";
1023
+ var _DYN_REPLACE = "replace";
1024
+ var _DYN_LOG_INTERNAL_MESSAGE = "logInternalMessage";
1025
+ var _DYN_IS_CHILD_EVT = "isChildEvt";
1026
+ var _DYN_GET_CTX = "getCtx";
1027
+ var _DYN_SET_CTX = "setCtx";
1028
+ var _DYN_COMPLETE = "complete";
1029
+
1030
+ var aggregationErrorType;
1031
+ function throwAggregationError(message, sourceErrors) {
1032
+ if (!aggregationErrorType) {
1033
+ aggregationErrorType = createCustomError("AggregationError", function (self, args) {
1034
+ if (args[_DYN_LENGTH ] > 1) {
1035
+ self.errors = args[1];
1036
+ }
1037
+ });
1038
+ }
1039
+ var theMessage = message || "One or more errors occurred.";
1040
+ arrForEach(sourceErrors, function (srcError, idx) {
1041
+ theMessage += "\n".concat(idx, " > ").concat(dumpObj(srcError));
1042
+ });
1043
+ throw new aggregationErrorType(theMessage, sourceErrors || []);
1044
+ }
1045
+
1046
+ var UNDEFINED_VALUE = undefined;
1047
+ var STR_EMPTY = "";
1048
+ var STR_CORE = "core";
1049
+ var STR_DISABLED = "disabled";
1050
+ var STR_EXTENSION_CONFIG = "extensionConfig";
1051
+ var STR_PROCESS_TELEMETRY = "processTelemetry";
1052
+ var STR_PRIORITY = "priority";
1053
+ var STR_GET_PERF_MGR = "getPerfMgr";
1054
+ var STR_NOT_DYNAMIC_ERROR = "Not dynamic - ";
1055
+
1056
+ var rCamelCase = /-([a-z])/g;
1057
+ var rNormalizeInvalid = /([^\w\d_$])/g;
1058
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
1059
+ function isNotNullOrUndefined(value) {
1060
+ return !isNullOrUndefined(value);
1061
+ }
1062
+ function normalizeJsName(name) {
1063
+ var value = name;
1064
+ if (value && isString(value)) {
1065
+ value = value[_DYN_REPLACE ](rCamelCase, function (_all, letter) {
1066
+ return letter.toUpperCase();
1067
+ });
1068
+ value = value[_DYN_REPLACE ](rNormalizeInvalid, "_");
1069
+ value = value[_DYN_REPLACE ](rLeadingNumeric, function (_all, match) {
1070
+ return "_" + match;
1071
+ });
1072
+ }
1073
+ return value;
1074
+ }
1075
+ function strContains(value, search) {
1076
+ if (value && search) {
1077
+ return strIndexOf(value, search) !== -1;
1078
+ }
1079
+ return false;
1080
+ }
1081
+ function getExceptionName(object) {
1082
+ if (isError(object)) {
1083
+ return object[_DYN_NAME ];
1084
+ }
1085
+ return STR_EMPTY;
1086
+ }
1087
+ function _createProxyFunction(source, funcName) {
1088
+ var srcFunc = null;
1089
+ var src = null;
1090
+ if (isFunction(source)) {
1091
+ srcFunc = source;
1092
+ }
1093
+ else {
1094
+ src = source;
1095
+ }
1096
+ return function () {
1097
+ var originalArguments = arguments;
1098
+ if (srcFunc) {
1099
+ src = srcFunc();
1100
+ }
1101
+ if (src) {
1102
+ return src[funcName][_DYN_APPLY ](src, originalArguments);
1103
+ }
1104
+ };
1105
+ }
1106
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
1107
+ if (target && name && source) {
1108
+ if (overwriteTarget !== false || isUndefined(target[name])) {
1109
+ target[name] = _createProxyFunction(source, theFunc);
1110
+ }
1111
+ }
1112
+ }
1113
+
1114
+ var strConsole = "console";
1115
+ var strJSON = "JSON";
1116
+ var strCrypto = "crypto";
1117
+ var strMsCrypto = "msCrypto";
1118
+ var strMsie = "msie";
1119
+ var strTrident = "trident/";
1120
+ var _isTrident = null;
1121
+ var _navUserAgentCheck = null;
1122
+ function getConsole() {
1123
+ if (typeof console !== strShimUndefined) {
1124
+ return console;
1125
+ }
1126
+ return getInst(strConsole);
1127
+ }
1128
+ function hasJSON() {
1129
+ return Boolean((typeof JSON === strShimObject && JSON) || getInst(strJSON) !== null);
1130
+ }
1131
+ function getJSON() {
1132
+ if (hasJSON()) {
1133
+ return JSON || getInst(strJSON);
1134
+ }
1135
+ return null;
1136
+ }
1137
+ function getCrypto() {
1138
+ return getInst(strCrypto);
1139
+ }
1140
+ function getMsCrypto() {
1141
+ return getInst(strMsCrypto);
1142
+ }
1143
+ function isIE() {
1144
+ var nav = getNavigator();
1145
+ if (nav && (nav[_DYN_USER_AGENT ] !== _navUserAgentCheck || _isTrident === null)) {
1146
+ _navUserAgentCheck = nav[_DYN_USER_AGENT ];
1147
+ var userAgent = (_navUserAgentCheck || STR_EMPTY)[_DYN_TO_LOWER_CASE ]();
1148
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1149
+ }
1150
+ return _isTrident;
1151
+ }
1152
+
1153
+ var UInt32Mask = 0x100000000;
1154
+ var MaxUInt32 = 0xffffffff;
1155
+ var SEED1 = 123456789;
1156
+ var SEED2 = 987654321;
1157
+ var _mwcSeeded = false;
1158
+ var _mwcW = SEED1;
1159
+ var _mwcZ = SEED2;
1160
+ function _mwcSeed(seedValue) {
1161
+ if (seedValue < 0) {
1162
+ seedValue >>>= 0;
1163
+ }
1164
+ _mwcW = (SEED1 + seedValue) & MaxUInt32;
1165
+ _mwcZ = (SEED2 - seedValue) & MaxUInt32;
1166
+ _mwcSeeded = true;
1167
+ }
1168
+ function _autoSeedMwc() {
1169
+ try {
1170
+ var now = utcNow() & 0x7fffffff;
1171
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1172
+ }
1173
+ catch (e) {
1174
+ }
1175
+ }
1176
+ function random32(signed) {
1177
+ var value = 0;
1178
+ var c = getCrypto() || getMsCrypto();
1179
+ if (c && c.getRandomValues) {
1180
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1181
+ }
1182
+ if (value === 0 && isIE()) {
1183
+ if (!_mwcSeeded) {
1184
+ _autoSeedMwc();
1185
+ }
1186
+ value = mwcRandom32() & MaxUInt32;
1187
+ }
1188
+ if (value === 0) {
1189
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1190
+ }
1191
+ if (!signed) {
1192
+ value >>>= 0;
1193
+ }
1194
+ return value;
1195
+ }
1196
+ function mwcRandom32(signed) {
1197
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1198
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1199
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1200
+ if (!signed) {
1201
+ value >>>= 0;
1202
+ }
1203
+ return value;
1204
+ }
1205
+ function newId(maxLength) {
1206
+ if (maxLength === void 0) { maxLength = 22; }
1207
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1208
+ var number = random32() >>> 0;
1209
+ var chars = 0;
1210
+ var result = STR_EMPTY;
1211
+ while (result[_DYN_LENGTH ] < maxLength) {
1212
+ chars++;
1213
+ result += base64chars.charAt(number & 0x3F);
1214
+ number >>>= 6;
1215
+ if (chars === 5) {
1216
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1217
+ chars = 0;
1218
+ }
1219
+ }
1220
+ return result;
1221
+ }
1222
+
1223
+ var version = '3.0.2';
1224
+ var instanceName = "." + newId(6);
1225
+ var _dataUid = 0;
1226
+ function _canAcceptData(target) {
1227
+ return target[_DYN_NODE_TYPE ] === 1 || target[_DYN_NODE_TYPE ] === 9 || !(+target[_DYN_NODE_TYPE ]);
1228
+ }
1229
+ function _getCache(data, target) {
1230
+ var theCache = target[data.id];
1231
+ if (!theCache) {
1232
+ theCache = {};
1233
+ try {
1234
+ if (_canAcceptData(target)) {
1235
+ objDefine(target, data.id, {
1236
+ e: false,
1237
+ v: theCache
1238
+ });
1239
+ }
298
1240
  }
299
- _forEachProp(target, function (name) {
300
- if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
301
- instFuncs_1[name] = target[name];
302
- delete target[name];
303
- if (!_hasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
304
- proto[name] = _createDynamicPrototype(proto, name);
1241
+ catch (e) {
1242
+ }
1243
+ }
1244
+ return theCache;
1245
+ }
1246
+ function createUniqueNamespace(name, includeVersion) {
1247
+ if (includeVersion === void 0) { includeVersion = false; }
1248
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY) + instanceName);
1249
+ }
1250
+ function createElmNodeData(name) {
1251
+ var data = {
1252
+ id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY) + "." + version),
1253
+ accept: function (target) {
1254
+ return _canAcceptData(target);
1255
+ },
1256
+ get: function (target, name, defValue, addDefault) {
1257
+ var theCache = target[data.id];
1258
+ if (!theCache) {
1259
+ if (addDefault) {
1260
+ theCache = _getCache(data, target);
1261
+ theCache[normalizeJsName(name)] = defValue;
305
1262
  }
1263
+ return defValue;
306
1264
  }
307
- });
308
- }
1265
+ return theCache[normalizeJsName(name)];
1266
+ },
1267
+ kill: function (target, name) {
1268
+ if (target && target[name]) {
1269
+ try {
1270
+ delete target[name];
1271
+ }
1272
+ catch (e) {
1273
+ }
1274
+ }
1275
+ }
1276
+ };
1277
+ return data;
309
1278
  }
310
- function _checkPrototype(classProto, thisTarget) {
311
- if (_objGetPrototypeOf$1) {
312
- var visited = [];
313
- var thisProto = _getObjProto$1(thisTarget);
314
- while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
315
- if (thisProto === classProto) {
316
- return true;
1279
+
1280
+ function _isConfigDefaults(value) {
1281
+ return (value && isObject(value) && (value.isVal || value.fb || objHasOwn(value, "v") || objHasOwn(value, "mrg") || objHasOwn(value, "ref") || value.set));
1282
+ }
1283
+ function _getDefault(dynamicHandler, theConfig, cfgDefaults) {
1284
+ var defValue;
1285
+ var isDefaultValid = cfgDefaults.dfVal || isDefined;
1286
+ if (theConfig && cfgDefaults.fb) {
1287
+ var fallbacks = cfgDefaults.fb;
1288
+ if (!isArray(fallbacks)) {
1289
+ fallbacks = [fallbacks];
1290
+ }
1291
+ for (var lp = 0; lp < fallbacks[_DYN_LENGTH ]; lp++) {
1292
+ var fallback = fallbacks[lp];
1293
+ var fbValue = theConfig[fallback];
1294
+ if (isDefaultValid(fbValue)) {
1295
+ defValue = fbValue;
1296
+ }
1297
+ else if (dynamicHandler) {
1298
+ fbValue = dynamicHandler.cfg[fallback];
1299
+ if (isDefaultValid(fbValue)) {
1300
+ defValue = fbValue;
1301
+ }
1302
+ dynamicHandler.set(dynamicHandler.cfg, asString(fallback), fbValue);
1303
+ }
1304
+ if (isDefaultValid(defValue)) {
1305
+ break;
317
1306
  }
318
- visited.push(thisProto);
319
- thisProto = _getObjProto$1(thisProto);
320
1307
  }
321
- return false;
322
1308
  }
323
- return true;
1309
+ if (!isDefaultValid(defValue) && isDefaultValid(cfgDefaults.v)) {
1310
+ defValue = cfgDefaults.v;
1311
+ }
1312
+ return defValue;
324
1313
  }
325
- function _getObjName(target, unknownValue) {
326
- if (_hasOwnProperty(target, Prototype)) {
327
- return target.name || unknownValue || UnknownValue;
1314
+ function _resolveDefaultValue(dynamicHandler, theConfig, cfgDefaults) {
1315
+ var theValue = cfgDefaults;
1316
+ if (cfgDefaults && _isConfigDefaults(cfgDefaults)) {
1317
+ theValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);
328
1318
  }
329
- return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
1319
+ if (theValue) {
1320
+ if (_isConfigDefaults(theValue)) {
1321
+ theValue = _resolveDefaultValue(dynamicHandler, theConfig, theValue);
1322
+ }
1323
+ var newValue_1;
1324
+ if (isArray(theValue)) {
1325
+ newValue_1 = [];
1326
+ newValue_1[_DYN_LENGTH ] = theValue[_DYN_LENGTH ];
1327
+ }
1328
+ else if (isPlainObject(theValue)) {
1329
+ newValue_1 = {};
1330
+ }
1331
+ if (newValue_1) {
1332
+ objForEachKey(theValue, function (key, value) {
1333
+ if (value && _isConfigDefaults(value)) {
1334
+ value = _resolveDefaultValue(dynamicHandler, theConfig, value);
1335
+ }
1336
+ newValue_1[key] = value;
1337
+ });
1338
+ theValue = newValue_1;
1339
+ }
1340
+ }
1341
+ return theValue;
330
1342
  }
331
- function dynamicProto(theClass, target, delegateFunc, options) {
332
- if (!_hasOwnProperty(theClass, Prototype)) {
333
- _throwTypeError("theClass is an invalid class definition.");
1343
+ function _applyDefaultValue(dynamicHandler, theConfig, name, defaultValue) {
1344
+ var isValid;
1345
+ var setFn;
1346
+ var defValue;
1347
+ var cfgDefaults = defaultValue;
1348
+ var mergeDf;
1349
+ var reference;
1350
+ var readOnly;
1351
+ var blkDynamicValue;
1352
+ if (_isConfigDefaults(cfgDefaults)) {
1353
+ isValid = cfgDefaults.isVal;
1354
+ setFn = cfgDefaults.set;
1355
+ readOnly = cfgDefaults[_DYN_RD_ONLY ];
1356
+ blkDynamicValue = cfgDefaults[_DYN_BLK_VAL ];
1357
+ mergeDf = cfgDefaults.mrg;
1358
+ reference = cfgDefaults.ref;
1359
+ if (!reference && isUndefined(reference)) {
1360
+ reference = !!mergeDf;
1361
+ }
1362
+ defValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);
334
1363
  }
335
- var classProto = theClass[Prototype];
336
- if (!_checkPrototype(classProto, target)) {
337
- _throwTypeError("[" + _getObjName(theClass) + "] not in hierarchy of [" + _getObjName(target) + "]");
1364
+ else {
1365
+ defValue = defaultValue;
1366
+ }
1367
+ if (blkDynamicValue) {
1368
+ dynamicHandler[_DYN_BLK_VAL ](theConfig, name);
1369
+ }
1370
+ var theValue;
1371
+ var usingDefault = true;
1372
+ var cfgValue = theConfig[name];
1373
+ if (cfgValue || !isNullOrUndefined(cfgValue)) {
1374
+ theValue = cfgValue;
1375
+ usingDefault = false;
1376
+ if (isValid && theValue !== defValue && !isValid(theValue)) {
1377
+ theValue = defValue;
1378
+ usingDefault = true;
1379
+ }
1380
+ if (setFn) {
1381
+ theValue = setFn(theValue, defValue, theConfig);
1382
+ usingDefault = theValue === defValue;
1383
+ }
1384
+ }
1385
+ if (!usingDefault) {
1386
+ if (isPlainObject(theValue) || isArray(defValue)) {
1387
+ if (mergeDf && defValue && (isPlainObject(defValue) || isArray(defValue))) {
1388
+ objForEachKey(defValue, function (dfName, dfValue) {
1389
+ _applyDefaultValue(dynamicHandler, theValue, dfName, dfValue);
1390
+ });
1391
+ }
1392
+ }
338
1393
  }
339
- var className = null;
340
- if (_hasOwnProperty(classProto, DynClassName)) {
341
- className = classProto[DynClassName];
1394
+ else if (defValue) {
1395
+ theValue = _resolveDefaultValue(dynamicHandler, theConfig, defValue);
342
1396
  }
343
1397
  else {
344
- className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _gblInst.n;
345
- _gblInst.n++;
346
- classProto[DynClassName] = className;
1398
+ theValue = defValue;
347
1399
  }
348
- var perfOptions = dynamicProto[DynProtoDefaultOptions];
349
- var useBaseInst = !!perfOptions[strUseBaseInst];
350
- if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
351
- useBaseInst = !!options[strUseBaseInst];
1400
+ dynamicHandler.set(theConfig, name, theValue);
1401
+ if (reference) {
1402
+ dynamicHandler.ref(theConfig, name);
352
1403
  }
353
- var instFuncs = _getInstanceFuncs(target);
354
- var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
355
- delegateFunc(target, baseFuncs);
356
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
357
- if (setInstanceFunc && options) {
358
- setInstanceFunc = !!options[strSetInstFuncs];
1404
+ if (readOnly) {
1405
+ dynamicHandler[_DYN_RD_ONLY ](theConfig, name);
359
1406
  }
360
- _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
361
1407
  }
362
- dynamicProto[DynProtoDefaultOptions] = _gblInst.o;
363
-
364
- var _DYN_INITIALIZE = "initialize";
365
- var _DYN_NAME = "name";
366
- var _DYN_IDENTIFIER = "identifier";
367
- var _DYN_PUSH = "push";
368
- var _DYN_IS_INITIALIZED = "isInitialized";
369
- var _DYN_CONFIG = "config";
370
- var _DYN_LOGGER = "logger";
371
- var _DYN_LENGTH = "length";
372
- var _DYN_TIME = "time";
373
- var _DYN_PROCESS_NEXT = "processNext";
374
- var _DYN_GET_PROCESS_TEL_CONT0 = "getProcessTelContext";
375
- var _DYN_GET_PLUGIN = "getPlugin";
376
- var _DYN_TEARDOWN = "teardown";
377
- var _DYN_MESSAGE_ID = "messageId";
378
- var _DYN_MESSAGE = "message";
379
- var _DYN_IS_ASYNC = "isAsync";
380
- var _DYN__DO_TEARDOWN = "_doTeardown";
381
- var _DYN_UPDATE = "update";
382
- var _DYN_GET_NEXT = "getNext";
383
- var _DYN_DIAG_LOG = "diagLog";
384
- var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
385
- var _DYN_CREATE_NEW = "createNew";
386
- var _DYN_INDEX_OF = "indexOf";
387
- var _DYN_USER_AGENT = "userAgent";
388
- var _DYN_NODE_TYPE = "nodeType";
389
- var _DYN_APPLY = "apply";
390
- var _DYN_REPLACE = "replace";
391
- var _DYN_ENABLE_DEBUG_EXCEPTI4 = "enableDebugExceptions";
392
- var _DYN_LOG_INTERNAL_MESSAGE = "logInternalMessage";
393
- var _DYN_TO_LOWER_CASE = "toLowerCase";
394
- var _DYN_CALL = "call";
395
- var _DYN_IS_CHILD_EVT = "isChildEvt";
396
- var _DYN_GET_CTX = "getCtx";
397
- var _DYN_SET_CTX = "setCtx";
398
- var _DYN_COMPLETE = "complete";
399
-
400
- var STR_EMPTY = "";
401
- var STR_CORE = "core";
402
- var STR_DISABLED = "disabled";
403
- var STR_EXTENSION_CONFIG = "extensionConfig";
404
- var STR_PROCESS_TELEMETRY = "processTelemetry";
405
- var STR_PRIORITY = "priority";
406
- var STR_ERROR_TO_CONSOLE = "errorToConsole";
407
- var STR_WARN_TO_CONSOLE = "warnToConsole";
408
- var STR_GET_PERF_MGR = "getPerfMgr";
409
1408
 
410
- var strToString = "toString";
411
- var str__Proto = "__proto__";
412
- var strConstructor = "constructor";
413
- var _objDefineProperty$1 = ObjDefineProperty;
414
- var _objFreeze = ObjClass$1.freeze;
415
- var _isArray = Array.isArray;
416
- var _objToString = ObjProto$1[strToString];
417
- var _fnToString = ObjHasOwnProperty[strToString];
418
- var _objFunctionString = _fnToString[_DYN_CALL ](ObjClass$1);
419
- var rCamelCase = /-([a-z])/g;
420
- var rNormalizeInvalid = /([^\w\d_$])/g;
421
- var rLeadingNumeric = /^(\d+[\w\d_$])/;
422
- var _objGetPrototypeOf = Object["getPrototypeOf"];
423
- function _getObjProto(target) {
424
- if (target) {
425
- if (_objGetPrototypeOf) {
426
- return _objGetPrototypeOf(target);
1409
+ var CFG_HANDLER_LINK = symbolFor("[[ai_dynCfg_1]]");
1410
+ var BLOCK_DYNAMIC = symbolFor("[[ai_blkDynCfg_1]]");
1411
+ var FORCE_DYNAMIC = symbolFor("[[ai_frcDynCfg_1]]");
1412
+ function _cfgDeepCopy(source) {
1413
+ if (source) {
1414
+ var target_1;
1415
+ if (isArray(source)) {
1416
+ target_1 = [];
1417
+ target_1[_DYN_LENGTH ] = source[_DYN_LENGTH ];
1418
+ }
1419
+ else if (isPlainObject(source)) {
1420
+ target_1 = {};
1421
+ }
1422
+ if (target_1) {
1423
+ objForEachKey(source, function (key, value) {
1424
+ target_1[key] = _cfgDeepCopy(value);
1425
+ });
1426
+ return target_1;
427
1427
  }
428
- var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
429
- if (newProto) {
430
- return newProto;
1428
+ }
1429
+ return source;
1430
+ }
1431
+ function getDynamicConfigHandler(value) {
1432
+ if (value) {
1433
+ var handler = value[CFG_HANDLER_LINK] || value;
1434
+ if (handler.cfg && (handler.cfg === value || handler.cfg[CFG_HANDLER_LINK] === handler)) {
1435
+ return handler;
431
1436
  }
432
1437
  }
433
1438
  return null;
434
1439
  }
435
- function isUndefined(value) {
436
- return value === undefined || typeof value === strShimUndefined;
437
- }
438
- function isNullOrUndefined(value) {
439
- return (value === null || isUndefined(value));
1440
+ function blockDynamicConversion(value) {
1441
+ if (value && (isPlainObject(value) || isArray(value))) {
1442
+ try {
1443
+ value[BLOCK_DYNAMIC] = true;
1444
+ }
1445
+ catch (e) {
1446
+ }
1447
+ }
1448
+ return value;
440
1449
  }
441
- function isObject(value) {
442
- return !!(value && typeof value === strShimObject);
1450
+ function _canMakeDynamic(getFunc, state, value) {
1451
+ var result = false;
1452
+ if (value && !getFunc[state.blkVal]) {
1453
+ result = value[FORCE_DYNAMIC];
1454
+ if (!result && !value[BLOCK_DYNAMIC]) {
1455
+ result = isPlainObject(value) || isArray(value);
1456
+ }
1457
+ }
1458
+ return result;
443
1459
  }
444
- function isFunction$1(value) {
445
- return !!(value && typeof value === strShimFunction);
1460
+ function throwInvalidAccess(message) {
1461
+ throwTypeError("InvalidAccess:" + message);
446
1462
  }
447
- function normalizeJsName(name) {
448
- var value = name;
449
- if (value && isString$1(value)) {
450
- value = value[_DYN_REPLACE ](rCamelCase, function (_all, letter) {
451
- return letter.toUpperCase();
452
- });
453
- value = value[_DYN_REPLACE ](rNormalizeInvalid, "_");
454
- value = value[_DYN_REPLACE ](rLeadingNumeric, function (_all, match) {
455
- return "_" + match;
1463
+
1464
+ var arrayMethodsToPatch = [
1465
+ "push",
1466
+ "pop",
1467
+ "shift",
1468
+ "unshift",
1469
+ "splice"
1470
+ ];
1471
+ var _throwDynamicError = function (logger, name, desc, e) {
1472
+ logger && logger[_DYN_THROW_INTERNAL ](3 , 108 , "".concat(desc, " [").concat(name, "] failed - ") + dumpObj(e));
1473
+ };
1474
+ function _patchArray(state, target, name) {
1475
+ if (isArray(target)) {
1476
+ arrForEach(arrayMethodsToPatch, function (method) {
1477
+ var orgMethod = target[method];
1478
+ target[method] = function () {
1479
+ var args = [];
1480
+ for (var _i = 0; _i < arguments.length; _i++) {
1481
+ args[_i] = arguments[_i];
1482
+ }
1483
+ var result = orgMethod[_DYN_APPLY ](this, args);
1484
+ _makeDynamicObject(state, target, name, "Patching");
1485
+ return result;
1486
+ };
456
1487
  });
457
1488
  }
458
- return value;
459
1489
  }
460
- function objForEachKey(target, callbackfn) {
461
- if (target) {
462
- for (var prop in target) {
463
- if (ObjHasOwnProperty[_DYN_CALL ](target, prop)) {
464
- callbackfn[_DYN_CALL ](target, prop, target[prop]);
1490
+ function _getOwnPropGetter(target, name) {
1491
+ var propDesc = objGetOwnPropertyDescriptor(target, name);
1492
+ return propDesc && propDesc.get;
1493
+ }
1494
+ function _createDynamicProperty(state, theConfig, name, value) {
1495
+ var detail = {
1496
+ n: name,
1497
+ h: [],
1498
+ trk: function (handler) {
1499
+ if (handler && handler.fn) {
1500
+ if (arrIndexOf(detail.h, handler) === -1) {
1501
+ detail.h[_DYN_PUSH ](handler);
1502
+ }
1503
+ state.trk(handler, detail);
465
1504
  }
1505
+ },
1506
+ clr: function (handler) {
1507
+ var idx = arrIndexOf(detail.h, handler);
1508
+ if (idx !== -1) {
1509
+ detail.h[_DYN_SPLICE ](idx, 1);
1510
+ }
1511
+ }
1512
+ };
1513
+ var checkDynamic = true;
1514
+ var isObjectOrArray = false;
1515
+ function _getProperty() {
1516
+ if (checkDynamic) {
1517
+ isObjectOrArray = isObjectOrArray || _canMakeDynamic(_getProperty, state, value);
1518
+ if (value && !value[CFG_HANDLER_LINK] && isObjectOrArray) {
1519
+ value = _makeDynamicObject(state, value, name, "Converting");
1520
+ }
1521
+ checkDynamic = false;
1522
+ }
1523
+ var activeHandler = state.act;
1524
+ if (activeHandler) {
1525
+ detail.trk(activeHandler);
466
1526
  }
1527
+ return value;
467
1528
  }
468
- }
469
- function strContains(value, search) {
470
- if (value && search) {
471
- return value[_DYN_INDEX_OF ](search) !== -1;
1529
+ _getProperty[state.prop] = {
1530
+ chng: function () {
1531
+ state.add(detail);
1532
+ }
1533
+ };
1534
+ function _setProperty(newValue) {
1535
+ if (value !== newValue) {
1536
+ if (!!_getProperty[state.ro] && !state.upd) {
1537
+ throwInvalidAccess("[" + name + "] is read-only:" + dumpObj(theConfig));
1538
+ }
1539
+ if (checkDynamic) {
1540
+ isObjectOrArray = isObjectOrArray || _canMakeDynamic(_getProperty, state, value);
1541
+ checkDynamic = false;
1542
+ }
1543
+ var isReferenced = isObjectOrArray && _getProperty[state.rf];
1544
+ if (isObjectOrArray) {
1545
+ if (isReferenced) {
1546
+ objForEachKey(value, function (key) {
1547
+ value[key] = newValue ? newValue[key] : UNDEFINED_VALUE;
1548
+ });
1549
+ try {
1550
+ objForEachKey(newValue, function (key, theValue) {
1551
+ _setDynamicProperty(state, value, key, theValue);
1552
+ });
1553
+ newValue = value;
1554
+ }
1555
+ catch (e) {
1556
+ _throwDynamicError((state.hdlr || {})[_DYN_LOGGER ], name, "Assigning", e);
1557
+ isObjectOrArray = false;
1558
+ }
1559
+ }
1560
+ else if (value && value[CFG_HANDLER_LINK]) {
1561
+ objForEachKey(value, function (key) {
1562
+ var getter = _getOwnPropGetter(value, key);
1563
+ if (getter) {
1564
+ var valueState = getter[state.prop];
1565
+ valueState && valueState.chng();
1566
+ }
1567
+ });
1568
+ }
1569
+ }
1570
+ if (newValue !== value) {
1571
+ var newIsObjectOrArray = newValue && _canMakeDynamic(_getProperty, state, newValue);
1572
+ if (!isReferenced && newIsObjectOrArray) {
1573
+ newValue = _makeDynamicObject(state, newValue, name, "Converting");
1574
+ }
1575
+ value = newValue;
1576
+ isObjectOrArray = newIsObjectOrArray;
1577
+ }
1578
+ state.add(detail);
1579
+ }
472
1580
  }
473
- return false;
1581
+ objDefine(theConfig, detail.n, { g: _getProperty, s: _setProperty });
474
1582
  }
475
- var isArray$1 = _isArray || _isArrayPoly;
476
- function _isArrayPoly(obj) {
477
- return !!(obj && _objToString[_DYN_CALL ](obj) === "[object Array]");
478
- }
479
- function isError$1(obj) {
480
- return !!(obj && _objToString[_DYN_CALL ](obj) === "[object Error]");
1583
+ function _setDynamicProperty(state, target, name, value) {
1584
+ if (target) {
1585
+ var getter = _getOwnPropGetter(target, name);
1586
+ var isDynamic = getter && !!getter[state.prop];
1587
+ if (!isDynamic) {
1588
+ _createDynamicProperty(state, target, name, value);
1589
+ }
1590
+ else {
1591
+ target[name] = value;
1592
+ }
1593
+ }
1594
+ return target;
481
1595
  }
482
- function isString$1(value) {
483
- return typeof value === "string";
1596
+ function _setDynamicPropertyState(state, target, name, flags) {
1597
+ if (target) {
1598
+ var getter = _getOwnPropGetter(target, name);
1599
+ var isDynamic = getter && !!getter[state.prop];
1600
+ var inPlace = flags && flags[0 ];
1601
+ var rdOnly = flags && flags[1 ];
1602
+ var blkProp = flags && flags[2 ];
1603
+ if (!isDynamic) {
1604
+ if (blkProp) {
1605
+ try {
1606
+ blockDynamicConversion(target);
1607
+ }
1608
+ catch (e) {
1609
+ _throwDynamicError((state.hdlr || {})[_DYN_LOGGER ], name, "Blocking", e);
1610
+ }
1611
+ }
1612
+ try {
1613
+ _setDynamicProperty(state, target, name, target[name]);
1614
+ getter = _getOwnPropGetter(target, name);
1615
+ }
1616
+ catch (e) {
1617
+ _throwDynamicError((state.hdlr || {})[_DYN_LOGGER ], name, "State", e);
1618
+ }
1619
+ }
1620
+ if (inPlace) {
1621
+ getter[state.rf] = inPlace;
1622
+ }
1623
+ if (rdOnly) {
1624
+ getter[state.ro] = rdOnly;
1625
+ }
1626
+ if (blkProp) {
1627
+ getter[state.blkVal] = true;
1628
+ }
1629
+ }
1630
+ return target;
484
1631
  }
485
- function isBoolean(value) {
486
- return typeof value === "boolean";
1632
+ function _makeDynamicObject(state, target, name, desc) {
1633
+ try {
1634
+ objForEachKey(target, function (key, value) {
1635
+ _setDynamicProperty(state, target, key, value);
1636
+ });
1637
+ if (!target[CFG_HANDLER_LINK]) {
1638
+ objDefineProp(target, CFG_HANDLER_LINK, {
1639
+ get: function () {
1640
+ return state[_DYN_HDLR ];
1641
+ }
1642
+ });
1643
+ _patchArray(state, target, name);
1644
+ }
1645
+ }
1646
+ catch (e) {
1647
+ _throwDynamicError((state.hdlr || {})[_DYN_LOGGER ], name, desc, e);
1648
+ }
1649
+ return target;
487
1650
  }
488
- function isPlainObject(value) {
489
- var result = false;
490
- if (value && typeof value === "object") {
491
- var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
492
- if (!proto) {
493
- result = true;
1651
+
1652
+ var symPrefix = "[[ai_";
1653
+ var symPostfix = "]]";
1654
+ function _createState(cfgHandler) {
1655
+ var _a;
1656
+ var dynamicPropertySymbol = newSymbol(symPrefix + "get" + cfgHandler.uid + symPostfix);
1657
+ var dynamicPropertyReadOnly = newSymbol(symPrefix + "ro" + cfgHandler.uid + symPostfix);
1658
+ var dynamicPropertyReferenced = newSymbol(symPrefix + "rf" + cfgHandler.uid + symPostfix);
1659
+ var dynamicPropertyBlockValue = newSymbol(symPrefix + "blkVal" + cfgHandler.uid + symPostfix);
1660
+ var dynamicPropertyDetail = newSymbol(symPrefix + "dtl" + cfgHandler.uid + symPostfix);
1661
+ var _waitingHandlers = null;
1662
+ var _watcherTimer = null;
1663
+ var theState;
1664
+ function _useHandler(activeHandler, callback) {
1665
+ var prevWatcher = theState.act;
1666
+ try {
1667
+ theState.act = activeHandler;
1668
+ if (activeHandler && activeHandler[dynamicPropertyDetail]) {
1669
+ arrForEach(activeHandler[dynamicPropertyDetail], function (detail) {
1670
+ detail.clr(activeHandler);
1671
+ });
1672
+ activeHandler[dynamicPropertyDetail] = [];
1673
+ }
1674
+ callback({
1675
+ cfg: cfgHandler.cfg,
1676
+ set: cfgHandler.set.bind(cfgHandler),
1677
+ setDf: cfgHandler[_DYN_SET_DF ].bind(cfgHandler),
1678
+ ref: cfgHandler.ref.bind(cfgHandler),
1679
+ rdOnly: cfgHandler[_DYN_RD_ONLY ].bind(cfgHandler)
1680
+ });
494
1681
  }
495
- else {
496
- if (proto[strConstructor] && ObjHasOwnProperty[_DYN_CALL ](proto, strConstructor)) {
497
- proto = proto[strConstructor];
1682
+ catch (e) {
1683
+ var logger = cfgHandler[_DYN_LOGGER ];
1684
+ if (logger) {
1685
+ logger[_DYN_THROW_INTERNAL ](1 , 107 , dumpObj(e));
1686
+ }
1687
+ throw e;
1688
+ }
1689
+ finally {
1690
+ theState.act = prevWatcher || null;
1691
+ }
1692
+ }
1693
+ function _notifyWatchers() {
1694
+ if (_waitingHandlers) {
1695
+ var notifyHandlers = _waitingHandlers;
1696
+ _waitingHandlers = null;
1697
+ _watcherTimer && _watcherTimer[_DYN_CANCEL ]();
1698
+ _watcherTimer = null;
1699
+ var watcherFailures_1 = [];
1700
+ arrForEach(notifyHandlers, function (handler) {
1701
+ if (handler) {
1702
+ if (handler[dynamicPropertyDetail]) {
1703
+ arrForEach(handler[dynamicPropertyDetail], function (detail) {
1704
+ detail.clr(handler);
1705
+ });
1706
+ handler[dynamicPropertyDetail] = null;
1707
+ }
1708
+ if (handler.fn) {
1709
+ try {
1710
+ _useHandler(handler, handler.fn);
1711
+ }
1712
+ catch (e) {
1713
+ watcherFailures_1[_DYN_PUSH ](e);
1714
+ }
1715
+ }
1716
+ }
1717
+ });
1718
+ if (_waitingHandlers) {
1719
+ try {
1720
+ _notifyWatchers();
1721
+ }
1722
+ catch (e) {
1723
+ watcherFailures_1[_DYN_PUSH ](e);
1724
+ }
1725
+ }
1726
+ if (watcherFailures_1[_DYN_LENGTH ] > 0) {
1727
+ throwAggregationError("Watcher error(s): ", watcherFailures_1);
498
1728
  }
499
- result = typeof proto === strShimFunction && _fnToString[_DYN_CALL ](proto) === _objFunctionString;
500
1729
  }
501
1730
  }
502
- return result;
503
- }
504
- function arrForEach(arr, callbackfn, thisArg) {
505
- var len = arr[_DYN_LENGTH ];
506
- try {
507
- for (var idx = 0; idx < len; idx++) {
508
- if (idx in arr) {
509
- if (callbackfn[_DYN_CALL ](thisArg || arr, arr[idx], idx, arr) === -1) {
510
- break;
1731
+ function _addWatcher(detail) {
1732
+ if (detail && detail.h[_DYN_LENGTH ] > 0) {
1733
+ if (!_waitingHandlers) {
1734
+ _waitingHandlers = [];
1735
+ }
1736
+ if (!_watcherTimer) {
1737
+ _watcherTimer = scheduleTimeout(function () {
1738
+ _watcherTimer = null;
1739
+ _notifyWatchers();
1740
+ }, 0);
1741
+ }
1742
+ for (var idx = 0; idx < detail.h[_DYN_LENGTH ]; idx++) {
1743
+ var handler = detail.h[idx];
1744
+ if (handler && arrIndexOf(_waitingHandlers, handler) === -1) {
1745
+ _waitingHandlers[_DYN_PUSH ](handler);
511
1746
  }
512
1747
  }
513
1748
  }
514
1749
  }
515
- catch (e) {
516
- }
517
- }
518
- function objDefineAccessors(target, prop, getProp, setProp) {
519
- if (_objDefineProperty$1) {
520
- try {
521
- var descriptor = {
522
- enumerable: true,
523
- configurable: true
524
- };
525
- if (getProp) {
526
- descriptor.get = getProp;
527
- }
528
- if (setProp) {
529
- descriptor.set = setProp;
1750
+ function _trackHandler(handler, detail) {
1751
+ if (handler) {
1752
+ var details = handler[dynamicPropertyDetail] = handler[dynamicPropertyDetail] || [];
1753
+ if (arrIndexOf(details, detail) === -1) {
1754
+ details[_DYN_PUSH ](detail);
530
1755
  }
531
- _objDefineProperty$1(target, prop, descriptor);
532
- return true;
533
- }
534
- catch (e) {
535
1756
  }
536
1757
  }
537
- return false;
538
- }
539
- function _doNothing(value) {
540
- return value;
541
- }
542
- var objFreeze = _objFreeze || _doNothing;
543
- function dateNow() {
544
- var dt = Date;
545
- return dt.now ? dt.now() : new dt().getTime();
546
- }
547
- function getExceptionName(object) {
548
- if (isError$1(object)) {
549
- return object[_DYN_NAME ];
550
- }
551
- return STR_EMPTY;
1758
+ theState = (_a = {
1759
+ prop: dynamicPropertySymbol,
1760
+ ro: dynamicPropertyReadOnly,
1761
+ rf: dynamicPropertyReferenced
1762
+ },
1763
+ _a[_DYN_BLK_VAL ] = dynamicPropertyBlockValue,
1764
+ _a[_DYN_HDLR ] = cfgHandler,
1765
+ _a.add = _addWatcher,
1766
+ _a[_DYN_NOTIFY ] = _notifyWatchers,
1767
+ _a.use = _useHandler,
1768
+ _a.trk = _trackHandler,
1769
+ _a);
1770
+ return theState;
552
1771
  }
553
- function setValue(target, field, value, valChk, srcChk) {
554
- var theValue = value;
555
- if (target) {
556
- theValue = target[field];
557
- if (theValue !== value && (!srcChk || srcChk(theValue)) && (!valChk || valChk(value))) {
558
- theValue = value;
559
- target[field] = theValue;
1772
+
1773
+ function _createAndUseHandler(state, configHandler) {
1774
+ var handler = {
1775
+ fn: configHandler,
1776
+ rm: function () {
1777
+ handler.fn = null;
1778
+ state = null;
1779
+ configHandler = null;
560
1780
  }
561
- }
562
- return theValue;
563
- }
564
- function getCfgValue(theValue, defaultValue) {
565
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1781
+ };
1782
+ state.use(handler, configHandler);
1783
+ return handler;
566
1784
  }
567
- function _createProxyFunction(source, funcName) {
568
- var srcFunc = null;
569
- var src = null;
570
- if (isFunction$1(source)) {
571
- srcFunc = source;
1785
+ function _createDynamicHandler(logger, target, inPlace) {
1786
+ var _a;
1787
+ var dynamicHandler = getDynamicConfigHandler(target);
1788
+ if (dynamicHandler) {
1789
+ return dynamicHandler;
572
1790
  }
573
- else {
574
- src = source;
1791
+ var uid = createUniqueNamespace("dyncfg", true);
1792
+ var newTarget = (target && inPlace !== false) ? target : _cfgDeepCopy(target);
1793
+ var theState;
1794
+ function _notifyWatchers() {
1795
+ theState[_DYN_NOTIFY ]();
575
1796
  }
576
- return function () {
577
- var originalArguments = arguments;
578
- if (srcFunc) {
579
- src = srcFunc();
580
- }
581
- if (src) {
582
- return src[funcName][_DYN_APPLY ](src, originalArguments);
1797
+ function _setValue(target, name, value) {
1798
+ try {
1799
+ target = _setDynamicProperty(theState, target, name, value);
583
1800
  }
584
- };
585
- }
586
- function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
587
- if (target && name && source) {
588
- if (overwriteTarget !== false || isUndefined(target[name])) {
589
- target[name] = _createProxyFunction(source, theFunc);
1801
+ catch (e) {
1802
+ _throwDynamicError(logger, name, "Setting value", e);
590
1803
  }
1804
+ return target[name];
591
1805
  }
592
- }
593
- function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
594
- var theArgs = arguments;
595
- var extended = theArgs[0] || {};
596
- var argLen = theArgs[_DYN_LENGTH ];
597
- var deep = false;
598
- var idx = 1;
599
- if (argLen > 0 && isBoolean(extended)) {
600
- deep = extended;
601
- extended = theArgs[idx] || {};
602
- idx++;
603
- }
604
- if (!isObject(extended)) {
605
- extended = {};
606
- }
607
- for (; idx < argLen; idx++) {
608
- var arg = theArgs[idx];
609
- var isArgArray = isArray$1(arg);
610
- var isArgObj = isObject(arg);
611
- for (var prop in arg) {
612
- var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty[_DYN_CALL ](arg, prop)));
613
- if (!propOk) {
614
- continue;
615
- }
616
- var newValue = arg[prop];
617
- var isNewArray = void 0;
618
- if (deep && newValue && ((isNewArray = isArray$1(newValue)) || isPlainObject(newValue))) {
619
- var clone = extended[prop];
620
- if (isNewArray) {
621
- if (!isArray$1(clone)) {
622
- clone = [];
623
- }
624
- }
625
- else if (!isPlainObject(clone)) {
626
- clone = {};
1806
+ function _watch(configHandler) {
1807
+ return _createAndUseHandler(theState, configHandler);
1808
+ }
1809
+ function _block(configHandler, allowUpdate) {
1810
+ theState.use(null, function (details) {
1811
+ var prevUpd = theState.upd;
1812
+ try {
1813
+ if (!isUndefined(allowUpdate)) {
1814
+ theState.upd = allowUpdate;
627
1815
  }
628
- newValue = objExtend(deep, clone, newValue);
1816
+ configHandler(details);
629
1817
  }
630
- if (newValue !== undefined) {
631
- extended[prop] = newValue;
1818
+ finally {
1819
+ theState.upd = prevUpd;
632
1820
  }
633
- }
1821
+ });
634
1822
  }
635
- return extended;
636
- }
637
-
638
- var strWindow = "window";
639
- var strNavigator = "navigator";
640
- var strConsole = "console";
641
- var strJSON = "JSON";
642
- var strCrypto = "crypto";
643
- var strMsCrypto = "msCrypto";
644
- var strMsie = "msie";
645
- var strTrident = "trident/";
646
- var _isTrident = null;
647
- var _navUserAgentCheck = null;
648
- function getGlobalInst(name) {
649
- var gbl = getGlobal();
650
- if (gbl && gbl[name]) {
651
- return gbl[name];
1823
+ function _ref(target, name) {
1824
+ var _a;
1825
+ return _setDynamicPropertyState(theState, target, name, (_a = {}, _a[0 ] = true, _a))[name];
652
1826
  }
653
- if (name === strWindow && hasWindow()) {
654
- return window;
1827
+ function _rdOnly(target, name) {
1828
+ var _a;
1829
+ return _setDynamicPropertyState(theState, target, name, (_a = {}, _a[1 ] = true, _a))[name];
655
1830
  }
656
- return null;
657
- }
658
- function hasWindow() {
659
- return Boolean(typeof window === strShimObject && window);
660
- }
661
- function hasNavigator() {
662
- return Boolean(typeof navigator === strShimObject && navigator);
663
- }
664
- function getNavigator() {
665
- if (hasNavigator()) {
666
- return navigator;
1831
+ function _blkPropValue(target, name) {
1832
+ var _a;
1833
+ return _setDynamicPropertyState(theState, target, name, (_a = {}, _a[2 ] = true, _a))[name];
667
1834
  }
668
- return getGlobalInst(strNavigator);
669
- }
670
- function getConsole() {
671
- if (typeof console !== strShimUndefined) {
672
- return console;
1835
+ function _applyDefaults(theConfig, defaultValues) {
1836
+ if (defaultValues) {
1837
+ objForEachKey(defaultValues, function (name, value) {
1838
+ _applyDefaultValue(cfgHandler, theConfig, name, value);
1839
+ });
1840
+ }
1841
+ return theConfig;
673
1842
  }
674
- return getGlobalInst(strConsole);
675
- }
676
- function hasJSON() {
677
- return Boolean((typeof JSON === strShimObject && JSON) || getGlobalInst(strJSON) !== null);
1843
+ var cfgHandler = (_a = {
1844
+ uid: null,
1845
+ cfg: newTarget
1846
+ },
1847
+ _a[_DYN_LOGGER ] = logger,
1848
+ _a[_DYN_NOTIFY ] = _notifyWatchers,
1849
+ _a.set = _setValue,
1850
+ _a[_DYN_SET_DF ] = _applyDefaults,
1851
+ _a[_DYN_WATCH ] = _watch,
1852
+ _a.ref = _ref,
1853
+ _a[_DYN_RD_ONLY ] = _rdOnly,
1854
+ _a[_DYN_BLK_VAL ] = _blkPropValue,
1855
+ _a._block = _block,
1856
+ _a);
1857
+ objDefine(cfgHandler, "uid", {
1858
+ c: false,
1859
+ e: false,
1860
+ w: false,
1861
+ v: uid
1862
+ });
1863
+ theState = _createState(cfgHandler);
1864
+ _makeDynamicObject(theState, newTarget, "config", "Creating");
1865
+ return cfgHandler;
678
1866
  }
679
- function getJSON() {
680
- if (hasJSON()) {
681
- return JSON || getGlobalInst(strJSON);
1867
+ function _logInvalidAccess(logger, message) {
1868
+ if (logger) {
1869
+ logger[_DYN_WARN_TO_CONSOLE ](message);
1870
+ logger[_DYN_THROW_INTERNAL ](2 , 108 , message);
682
1871
  }
683
- return null;
684
- }
685
- function getCrypto() {
686
- return getGlobalInst(strCrypto);
687
- }
688
- function getMsCrypto() {
689
- return getGlobalInst(strMsCrypto);
690
- }
691
- function isIE() {
692
- var nav = getNavigator();
693
- if (nav && (nav[_DYN_USER_AGENT ] !== _navUserAgentCheck || _isTrident === null)) {
694
- _navUserAgentCheck = nav[_DYN_USER_AGENT ];
695
- var userAgent = (_navUserAgentCheck || STR_EMPTY)[_DYN_TO_LOWER_CASE ]();
696
- _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1872
+ else {
1873
+ throwInvalidAccess(message);
697
1874
  }
698
- return _isTrident;
699
1875
  }
700
- function dumpObj$1(object) {
701
- var objectTypeDump = Object[strShimPrototype].toString[_DYN_CALL ](object);
702
- var propertyValueDump = STR_EMPTY;
703
- if (objectTypeDump === "[object Error]") {
704
- propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object[_DYN_NAME ] + "'";
1876
+ function createDynamicConfig(config, defaultConfig, logger, inPlace) {
1877
+ var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);
1878
+ if (defaultConfig) {
1879
+ dynamicHandler[_DYN_SET_DF ](dynamicHandler.cfg, defaultConfig);
705
1880
  }
706
- else if (hasJSON()) {
707
- propertyValueDump = getJSON().stringify(object);
1881
+ return dynamicHandler;
1882
+ }
1883
+ function onConfigChange(config, configHandler, logger) {
1884
+ var handler = config[CFG_HANDLER_LINK] || config;
1885
+ if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {
1886
+ return handler[_DYN_WATCH ](configHandler);
708
1887
  }
709
- return objectTypeDump + propertyValueDump;
1888
+ _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));
1889
+ return createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
710
1890
  }
711
1891
 
712
1892
  var _aiNamespace = null;
713
1893
  function _getExtensionNamespace() {
714
- var target = getGlobalInst("Microsoft");
1894
+ var target = getInst("Microsoft");
715
1895
  if (target) {
716
1896
  _aiNamespace = target["ApplicationInsights"];
717
1897
  }
@@ -725,9 +1905,23 @@
725
1905
  return ns ? ns["ChromeDbgExt"] : null;
726
1906
  }
727
1907
 
1908
+ var _a$1;
1909
+ var STR_WARN_TO_CONSOLE = "warnToConsole";
728
1910
  var AiNonUserActionablePrefix = "AI (Internal): ";
729
1911
  var AiUserActionablePrefix = "AI: ";
730
1912
  var AIInternalMessagePrefix = "AITR_";
1913
+ var defaultValues$1 = {
1914
+ loggingLevelConsole: 0,
1915
+ loggingLevelTelemetry: 1,
1916
+ maxMessageLimit: 25,
1917
+ enableDebug: false
1918
+ };
1919
+ var _logFuncs = (_a$1 = {},
1920
+ _a$1[0 ] = null,
1921
+ _a$1[1 ] = "errorToConsole",
1922
+ _a$1[2 ] = STR_WARN_TO_CONSOLE,
1923
+ _a$1[3 ] = "debugToConsole",
1924
+ _a$1);
731
1925
  function _sanitizeDiagnosticText(text) {
732
1926
  if (text) {
733
1927
  return "\"" + text[_DYN_REPLACE ](/\"/g, STR_EMPTY) + "\"";
@@ -741,7 +1935,7 @@
741
1935
  if (theConsole[func]) {
742
1936
  logFunc = func;
743
1937
  }
744
- if (isFunction$1(theConsole[logFunc])) {
1938
+ if (isFunction(theConsole[logFunc])) {
745
1939
  theConsole[logFunc](message);
746
1940
  }
747
1941
  }
@@ -778,20 +1972,18 @@
778
1972
  var _loggingLevelTelemetry;
779
1973
  var _maxInternalMessageLimit;
780
1974
  var _enableDebug;
1975
+ var _unloadHandler;
781
1976
  dynamicProto(DiagnosticLogger, this, function (_self) {
782
- _setDefaultsFromConfig(config || {});
1977
+ _unloadHandler = _setDefaultsFromConfig(config || {});
783
1978
  _self.consoleLoggingLevel = function () { return _loggingLevelConsole; };
784
- _self.telemetryLoggingLevel = function () { return _loggingLevelTelemetry; };
785
- _self.maxInternalMessageLimit = function () { return _maxInternalMessageLimit; };
786
- _self[_DYN_ENABLE_DEBUG_EXCEPTI4 ] = function () { return _enableDebug; };
787
- _self.throwInternal = function (severity, msgId, msg, properties, isUserAct) {
1979
+ _self[_DYN_THROW_INTERNAL ] = function (severity, msgId, msg, properties, isUserAct) {
788
1980
  if (isUserAct === void 0) { isUserAct = false; }
789
1981
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
790
1982
  if (_enableDebug) {
791
- throw dumpObj$1(message);
1983
+ throw dumpObj(message);
792
1984
  }
793
1985
  else {
794
- var logFunc = severity === 1 ? STR_ERROR_TO_CONSOLE : STR_WARN_TO_CONSOLE;
1986
+ var logFunc = _logFuncs[severity] || STR_WARN_TO_CONSOLE;
795
1987
  if (!isUndefined(message[_DYN_MESSAGE ])) {
796
1988
  if (isUserAct) {
797
1989
  var messageKey = +message[_DYN_MESSAGE_ID ];
@@ -812,11 +2004,15 @@
812
2004
  }
813
2005
  }
814
2006
  };
815
- _self[STR_WARN_TO_CONSOLE ] = function (message) {
2007
+ _self.debugToConsole = function (message) {
2008
+ _logToConsole("debug", message);
2009
+ _debugExtMsg("warning", message);
2010
+ };
2011
+ _self[_DYN_WARN_TO_CONSOLE ] = function (message) {
816
2012
  _logToConsole("warn", message);
817
2013
  _debugExtMsg("warning", message);
818
2014
  };
819
- _self[STR_ERROR_TO_CONSOLE ] = function (message) {
2015
+ _self.errorToConsole = function (message) {
820
2016
  _logToConsole("error", message);
821
2017
  _debugExtMsg("error", message);
822
2018
  };
@@ -825,6 +2021,10 @@
825
2021
  _messageLogged = {};
826
2022
  };
827
2023
  _self[_DYN_LOG_INTERNAL_MESSAGE ] = _logInternalMessage;
2024
+ _self[_DYN_UNLOAD ] = function (isAsync) {
2025
+ _unloadHandler && _unloadHandler.rm();
2026
+ _unloadHandler = null;
2027
+ };
828
2028
  function _logInternalMessage(severity, message) {
829
2029
  if (_areInternalMessagesThrottled()) {
830
2030
  return;
@@ -848,19 +2048,22 @@
848
2048
  var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
849
2049
  _self.queue[_DYN_PUSH ](throttleMessage);
850
2050
  if (severity === 1 ) {
851
- _self[STR_ERROR_TO_CONSOLE ](throttleLimitMessage);
2051
+ _self.errorToConsole(throttleLimitMessage);
852
2052
  }
853
2053
  else {
854
- _self[STR_WARN_TO_CONSOLE ](throttleLimitMessage);
2054
+ _self[_DYN_WARN_TO_CONSOLE ](throttleLimitMessage);
855
2055
  }
856
2056
  }
857
2057
  }
858
2058
  }
859
2059
  function _setDefaultsFromConfig(config) {
860
- _loggingLevelConsole = getCfgValue(config.loggingLevelConsole, 0);
861
- _loggingLevelTelemetry = getCfgValue(config.loggingLevelTelemetry, 1);
862
- _maxInternalMessageLimit = getCfgValue(config.maxMessageLimit, 25);
863
- _enableDebug = getCfgValue(config.enableDebug, getCfgValue(config[_DYN_ENABLE_DEBUG_EXCEPTI4 ], false));
2060
+ return onConfigChange(createDynamicConfig(config, defaultValues$1, _self).cfg, function (details) {
2061
+ var config = details.cfg;
2062
+ _loggingLevelConsole = config[_DYN_LOGGING_LEVEL_CONSOL4 ];
2063
+ _loggingLevelTelemetry = config.loggingLevelTelemetry;
2064
+ _maxInternalMessageLimit = config.maxMessageLimit;
2065
+ _enableDebug = config.enableDebug;
2066
+ });
864
2067
  }
865
2068
  function _areInternalMessagesThrottled() {
866
2069
  return _messageCount >= _maxInternalMessageLimit;
@@ -881,10 +2084,10 @@
881
2084
  }
882
2085
  function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
883
2086
  if (isUserAct === void 0) { isUserAct = false; }
884
- _getLogger(logger).throwInternal(severity, msgId, msg, properties, isUserAct);
2087
+ _getLogger(logger)[_DYN_THROW_INTERNAL ](severity, msgId, msg, properties, isUserAct);
885
2088
  }
886
2089
  function _warnToConsole(logger, message) {
887
- _getLogger(logger)[STR_WARN_TO_CONSOLE ](message);
2090
+ _getLogger(logger)[_DYN_WARN_TO_CONSOLE ](message);
888
2091
  }
889
2092
 
890
2093
  var strExecutionContextKey = "ctx";
@@ -893,19 +2096,20 @@
893
2096
  var PerfEvent = /** @class */ (function () {
894
2097
  function PerfEvent(name, payloadDetails, isAsync) {
895
2098
  var _self = this;
896
- var accessorDefined = false;
897
- _self.start = dateNow();
2099
+ _self.start = utcNow();
898
2100
  _self[_DYN_NAME ] = name;
899
2101
  _self[_DYN_IS_ASYNC ] = isAsync;
900
2102
  _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
901
- if (isFunction$1(payloadDetails)) {
2103
+ if (isFunction(payloadDetails)) {
902
2104
  var theDetails_1;
903
- accessorDefined = objDefineAccessors(_self, "payload", function () {
904
- if (!theDetails_1 && isFunction$1(payloadDetails)) {
905
- theDetails_1 = payloadDetails();
906
- payloadDetails = null;
2105
+ objDefine(_self, "payload", {
2106
+ g: function () {
2107
+ if (!theDetails_1 && isFunction(payloadDetails)) {
2108
+ theDetails_1 = payloadDetails();
2109
+ payloadDetails = null;
2110
+ }
2111
+ return theDetails_1;
907
2112
  }
908
- return theDetails_1;
909
2113
  });
910
2114
  }
911
2115
  _self[_DYN_GET_CTX ] = function (key) {
@@ -937,7 +2141,7 @@
937
2141
  _self[_DYN_COMPLETE ] = function () {
938
2142
  var childTime = 0;
939
2143
  var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
940
- if (isArray$1(childEvts)) {
2144
+ if (isArray(childEvts)) {
941
2145
  for (var lp = 0; lp < childEvts[_DYN_LENGTH ]; lp++) {
942
2146
  var childEvt = childEvts[lp];
943
2147
  if (childEvt) {
@@ -945,12 +2149,9 @@
945
2149
  }
946
2150
  }
947
2151
  }
948
- _self[_DYN_TIME ] = dateNow() - _self.start;
2152
+ _self[_DYN_TIME ] = utcNow() - _self.start;
949
2153
  _self.exTime = _self[_DYN_TIME ] - childTime;
950
2154
  _self[_DYN_COMPLETE ] = function () { };
951
- if (!accessorDefined && isFunction$1(payloadDetails)) {
952
- _self.payload = payloadDetails();
953
- }
954
2155
  };
955
2156
  }
956
2157
  PerfEvent.ParentContextKey = "parent";
@@ -972,173 +2173,33 @@
972
2173
  if (perfEvt) {
973
2174
  if (currentActive && perfEvt[_DYN_SET_CTX ]) {
974
2175
  perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
975
- if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
976
- var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
977
- if (!children) {
978
- children = [];
979
- currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
980
- }
981
- children[_DYN_PUSH ](perfEvt);
982
- }
983
- }
984
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
985
- return func(perfEvt);
986
- }
987
- }
988
- catch (ex) {
989
- if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
990
- perfEvt[_DYN_SET_CTX ]("exception", ex);
991
- }
992
- }
993
- finally {
994
- if (perfEvt) {
995
- perfMgr.fire(perfEvt);
996
- }
997
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
998
- }
999
- }
1000
- }
1001
- return func();
1002
- }
1003
-
1004
- var UInt32Mask = 0x100000000;
1005
- var MaxUInt32 = 0xffffffff;
1006
- var _mwcSeeded = false;
1007
- var _mwcW = 123456789;
1008
- var _mwcZ = 987654321;
1009
- function _mwcSeed(seedValue) {
1010
- if (seedValue < 0) {
1011
- seedValue >>>= 0;
1012
- }
1013
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1014
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1015
- _mwcSeeded = true;
1016
- }
1017
- function _autoSeedMwc() {
1018
- try {
1019
- var now = dateNow() & 0x7fffffff;
1020
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1021
- }
1022
- catch (e) {
1023
- }
1024
- }
1025
- function random32(signed) {
1026
- var value = 0;
1027
- var c = getCrypto() || getMsCrypto();
1028
- if (c && c.getRandomValues) {
1029
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1030
- }
1031
- if (value === 0 && isIE()) {
1032
- if (!_mwcSeeded) {
1033
- _autoSeedMwc();
1034
- }
1035
- value = mwcRandom32() & MaxUInt32;
1036
- }
1037
- if (value === 0) {
1038
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1039
- }
1040
- if (!signed) {
1041
- value >>>= 0;
1042
- }
1043
- return value;
1044
- }
1045
- function mwcRandom32(signed) {
1046
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1047
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1048
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1049
- if (!signed) {
1050
- value >>>= 0;
1051
- }
1052
- return value;
1053
- }
1054
- function newId(maxLength) {
1055
- if (maxLength === void 0) { maxLength = 22; }
1056
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1057
- var number = random32() >>> 0;
1058
- var chars = 0;
1059
- var result = STR_EMPTY;
1060
- while (result[_DYN_LENGTH ] < maxLength) {
1061
- chars++;
1062
- result += base64chars.charAt(number & 0x3F);
1063
- number >>>= 6;
1064
- if (chars === 5) {
1065
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1066
- chars = 0;
1067
- }
1068
- }
1069
- return result;
1070
- }
1071
-
1072
- var _objDefineProperty = ObjDefineProperty;
1073
- var version = '2.8.14';
1074
- var instanceName = "." + newId(6);
1075
- var _dataUid = 0;
1076
- function _createAccessor(target, prop, value) {
1077
- if (_objDefineProperty) {
1078
- try {
1079
- _objDefineProperty(target, prop, {
1080
- value: value,
1081
- enumerable: false,
1082
- configurable: true
1083
- });
1084
- return true;
1085
- }
1086
- catch (e) {
1087
- }
1088
- }
1089
- return false;
1090
- }
1091
- function _canAcceptData(target) {
1092
- return target[_DYN_NODE_TYPE ] === 1 || target[_DYN_NODE_TYPE ] === 9 || !(+target[_DYN_NODE_TYPE ]);
1093
- }
1094
- function _getCache(data, target) {
1095
- var theCache = target[data.id];
1096
- if (!theCache) {
1097
- theCache = {};
1098
- try {
1099
- if (_canAcceptData(target)) {
1100
- if (!_createAccessor(target, data.id, theCache)) {
1101
- target[data.id] = theCache;
1102
- }
1103
- }
1104
- }
1105
- catch (e) {
1106
- }
1107
- }
1108
- return theCache;
1109
- }
1110
- function createUniqueNamespace(name, includeVersion) {
1111
- if (includeVersion === void 0) { includeVersion = false; }
1112
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY) + instanceName);
1113
- }
1114
- function createElmNodeData(name) {
1115
- var data = {
1116
- id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY) + "." + version),
1117
- accept: function (target) {
1118
- return _canAcceptData(target);
1119
- },
1120
- get: function (target, name, defValue, addDefault) {
1121
- var theCache = target[data.id];
1122
- if (!theCache) {
1123
- if (addDefault) {
1124
- theCache = _getCache(data, target);
1125
- theCache[normalizeJsName(name)] = defValue;
2176
+ if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
2177
+ var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2178
+ if (!children) {
2179
+ children = [];
2180
+ currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
2181
+ }
2182
+ children[_DYN_PUSH ](perfEvt);
2183
+ }
2184
+ }
2185
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
2186
+ return func(perfEvt);
1126
2187
  }
1127
- return defValue;
1128
2188
  }
1129
- return theCache[normalizeJsName(name)];
1130
- },
1131
- kill: function (target, name) {
1132
- if (target && target[name]) {
1133
- try {
1134
- delete target[name];
2189
+ catch (ex) {
2190
+ if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
2191
+ perfEvt[_DYN_SET_CTX ]("exception", ex);
1135
2192
  }
1136
- catch (e) {
2193
+ }
2194
+ finally {
2195
+ if (perfEvt) {
2196
+ perfMgr.fire(perfEvt);
1137
2197
  }
2198
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
1138
2199
  }
1139
2200
  }
1140
- };
1141
- return data;
2201
+ }
2202
+ return func();
1142
2203
  }
1143
2204
 
1144
2205
  var pluginStateData = createElmNodeData("plugin");
@@ -1157,11 +2218,14 @@
1157
2218
  }
1158
2219
  proxy = proxy[_DYN_GET_NEXT ]();
1159
2220
  }
1160
- return createTelemetryProxyChain([startAt], core[_DYN_CONFIG ] || {}, core);
2221
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
1161
2222
  }
1162
- function _createInternalContext(telemetryChain, config, core, startAt) {
2223
+ function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
1163
2224
  var _nextProxy = null;
1164
2225
  var _onComplete = [];
2226
+ if (!dynamicHandler) {
2227
+ dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2228
+ }
1165
2229
  if (startAt !== null) {
1166
2230
  _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1167
2231
  }
@@ -1172,12 +2236,12 @@
1172
2236
  return core;
1173
2237
  },
1174
2238
  diagLog: function () {
1175
- return safeGetLogger(core, config);
2239
+ return safeGetLogger(core, dynamicHandler.cfg);
1176
2240
  },
1177
2241
  getCfg: function () {
1178
- return config;
2242
+ return dynamicHandler.cfg;
1179
2243
  },
1180
- getExtCfg: _getExtCfg,
2244
+ getExtCfg: _resolveExtCfg,
1181
2245
  getConfig: _getConfig,
1182
2246
  hasNext: function () {
1183
2247
  return !!_nextProxy;
@@ -1213,10 +2277,10 @@
1213
2277
  if (onComplete && onComplete[_DYN_LENGTH ] > 0) {
1214
2278
  arrForEach(onComplete, function (completeDetails) {
1215
2279
  try {
1216
- completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2280
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1217
2281
  }
1218
2282
  catch (e) {
1219
- _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj$1(e));
2283
+ _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1220
2284
  }
1221
2285
  });
1222
2286
  _onComplete = [];
@@ -1224,48 +2288,54 @@
1224
2288
  }
1225
2289
  return nextProxy;
1226
2290
  }
1227
- function _getExtCfg(identifier, defaultValue, mergeDefault) {
1228
- if (defaultValue === void 0) { defaultValue = {}; }
1229
- if (mergeDefault === void 0) { mergeDefault = 0 ; }
1230
- var theConfig;
1231
- if (config) {
1232
- var extConfig = config[STR_EXTENSION_CONFIG ];
1233
- if (extConfig && identifier) {
1234
- theConfig = extConfig[identifier];
1235
- }
1236
- }
1237
- if (!theConfig) {
1238
- theConfig = defaultValue;
1239
- }
1240
- else if (isObject(defaultValue)) {
1241
- if (mergeDefault !== 0 ) {
1242
- var newConfig_1 = objExtend(true, defaultValue, theConfig);
1243
- if (config && mergeDefault === 2 ) {
1244
- objForEachKey(defaultValue, function (field) {
1245
- if (isNullOrUndefined(newConfig_1[field])) {
1246
- var cfgValue = config[field];
1247
- if (!isNullOrUndefined(cfgValue)) {
1248
- newConfig_1[field] = cfgValue;
1249
- }
1250
- }
1251
- });
2291
+ function _getExtCfg(identifier, createIfMissing) {
2292
+ var idCfg = null;
2293
+ var cfg = dynamicHandler.cfg;
2294
+ if (cfg && identifier) {
2295
+ var extCfg = cfg[STR_EXTENSION_CONFIG ];
2296
+ if (!extCfg && createIfMissing) {
2297
+ extCfg = {};
2298
+ }
2299
+ cfg[STR_EXTENSION_CONFIG] = extCfg;
2300
+ extCfg = dynamicHandler.ref(cfg, STR_EXTENSION_CONFIG);
2301
+ if (extCfg) {
2302
+ idCfg = extCfg[identifier];
2303
+ if (!idCfg && createIfMissing) {
2304
+ idCfg = {};
1252
2305
  }
1253
- theConfig = newConfig_1;
2306
+ extCfg[identifier] = idCfg;
2307
+ idCfg = dynamicHandler.ref(extCfg, identifier);
1254
2308
  }
1255
2309
  }
1256
- return theConfig;
2310
+ return idCfg;
2311
+ }
2312
+ function _resolveExtCfg(identifier, defaultValues) {
2313
+ var newConfig = _getExtCfg(identifier, true);
2314
+ if (defaultValues) {
2315
+ objForEachKey(defaultValues, function (field, defaultValue) {
2316
+ if (isNullOrUndefined(newConfig[field])) {
2317
+ var cfgValue = dynamicHandler.cfg[field];
2318
+ if (cfgValue || !isNullOrUndefined(cfgValue)) {
2319
+ newConfig[field] = cfgValue;
2320
+ }
2321
+ }
2322
+ _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2323
+ });
2324
+ }
2325
+ return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
1257
2326
  }
1258
2327
  function _getConfig(identifier, field, defaultValue) {
1259
2328
  if (defaultValue === void 0) { defaultValue = false; }
1260
2329
  var theValue;
1261
- var extConfig = _getExtCfg(identifier, null);
1262
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
2330
+ var extConfig = _getExtCfg(identifier, false);
2331
+ var rootConfig = dynamicHandler.cfg;
2332
+ if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
1263
2333
  theValue = extConfig[field];
1264
2334
  }
1265
- else if (config && !isNullOrUndefined(config[field])) {
1266
- theValue = config[field];
2335
+ else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2336
+ theValue = rootConfig[field];
1267
2337
  }
1268
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
2338
+ return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
1269
2339
  }
1270
2340
  function _iterateChain(cb) {
1271
2341
  var nextPlugin;
@@ -1278,38 +2348,41 @@
1278
2348
  }
1279
2349
  return context;
1280
2350
  }
1281
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
2351
+ function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2352
+ var config = createDynamicConfig(cfg);
1282
2353
  var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1283
2354
  var context = internalContext.ctx;
1284
2355
  function _processNext(env) {
1285
2356
  var nextPlugin = internalContext._next();
1286
- nextPlugin && nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2357
+ if (nextPlugin) {
2358
+ nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2359
+ }
1287
2360
  return !nextPlugin;
1288
2361
  }
1289
2362
  function _createNew(plugins, startAt) {
1290
2363
  if (plugins === void 0) { plugins = null; }
1291
- if (isArray$1(plugins)) {
1292
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
2364
+ if (isArray(plugins)) {
2365
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
1293
2366
  }
1294
- return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config, core, startAt);
2367
+ return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
1295
2368
  }
1296
2369
  context[_DYN_PROCESS_NEXT ] = _processNext;
1297
2370
  context[_DYN_CREATE_NEW ] = _createNew;
1298
2371
  return context;
1299
2372
  }
1300
2373
  function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
1301
- var config = core[_DYN_CONFIG ] || {};
2374
+ var config = createDynamicConfig(core.config);
1302
2375
  var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1303
2376
  var context = internalContext.ctx;
1304
2377
  function _processNext(unloadState) {
1305
2378
  var nextPlugin = internalContext._next();
1306
- nextPlugin && nextPlugin.unload(context, unloadState);
2379
+ nextPlugin && nextPlugin[_DYN_UNLOAD ](context, unloadState);
1307
2380
  return !nextPlugin;
1308
2381
  }
1309
2382
  function _createNew(plugins, startAt) {
1310
2383
  if (plugins === void 0) { plugins = null; }
1311
- if (isArray$1(plugins)) {
1312
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
2384
+ if (isArray(plugins)) {
2385
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
1313
2386
  }
1314
2387
  return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
1315
2388
  }
@@ -1318,20 +2391,20 @@
1318
2391
  return context;
1319
2392
  }
1320
2393
  function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
1321
- var config = core[_DYN_CONFIG ] || {};
2394
+ var config = createDynamicConfig(core.config);
1322
2395
  var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1323
2396
  var context = internalContext.ctx;
1324
2397
  function _processNext(updateState) {
1325
2398
  return context.iterate(function (plugin) {
1326
- if (isFunction$1(plugin[_DYN_UPDATE ])) {
2399
+ if (isFunction(plugin[_DYN_UPDATE ])) {
1327
2400
  plugin[_DYN_UPDATE ](context, updateState);
1328
2401
  }
1329
2402
  });
1330
2403
  }
1331
2404
  function _createNew(plugins, startAt) {
1332
2405
  if (plugins === void 0) { plugins = null; }
1333
- if (isArray$1(plugins)) {
1334
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
2406
+ if (isArray(plugins)) {
2407
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
1335
2408
  }
1336
2409
  return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
1337
2410
  }
@@ -1342,13 +2415,13 @@
1342
2415
  function createTelemetryProxyChain(plugins, config, core, startAt) {
1343
2416
  var firstProxy = null;
1344
2417
  var add = startAt ? false : true;
1345
- if (isArray$1(plugins) && plugins[_DYN_LENGTH ] > 0) {
2418
+ if (isArray(plugins) && plugins[_DYN_LENGTH ] > 0) {
1346
2419
  var lastProxy_1 = null;
1347
2420
  arrForEach(plugins, function (thePlugin) {
1348
2421
  if (!add && startAt === thePlugin) {
1349
2422
  add = true;
1350
2423
  }
1351
- if (add && thePlugin && isFunction$1(thePlugin[STR_PROCESS_TELEMETRY ])) {
2424
+ if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
1352
2425
  var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1353
2426
  if (!firstProxy) {
1354
2427
  firstProxy = newProxy;
@@ -1367,8 +2440,8 @@
1367
2440
  }
1368
2441
  function createTelemetryPluginProxy(plugin, config, core) {
1369
2442
  var nextProxy = null;
1370
- var hasProcessTelemetry = isFunction$1(plugin[STR_PROCESS_TELEMETRY ]);
1371
- var hasSetNext = isFunction$1(plugin[_DYN_SET_NEXT_PLUGIN ]);
2443
+ var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
2444
+ var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
1372
2445
  var chainId;
1373
2446
  if (plugin) {
1374
2447
  chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
@@ -1393,7 +2466,7 @@
1393
2466
  };
1394
2467
  function _getTelCtx() {
1395
2468
  var itemCtx;
1396
- if (plugin && isFunction$1(plugin[strGetTelCtx])) {
2469
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1397
2470
  itemCtx = plugin[strGetTelCtx]();
1398
2471
  }
1399
2472
  if (!itemCtx) {
@@ -1425,7 +2498,7 @@
1425
2498
  hasRun = true;
1426
2499
  }
1427
2500
  if (!nextProxy || !hasNextRun) {
1428
- _throwInternal(itemCtx[_DYN_DIAG_LOG ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj$1(error) + ", run flags: " + dumpObj$1(hasRunContext));
2501
+ _throwInternal(itemCtx[_DYN_DIAG_LOG ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1429
2502
  }
1430
2503
  }
1431
2504
  }, details, isAsync);
@@ -1507,7 +2580,7 @@
1507
2580
  handler(unloadCtx, unloadState);
1508
2581
  }
1509
2582
  catch (e) {
1510
- _throwInternal(unloadCtx[_DYN_DIAG_LOG ](), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj$1(e));
2583
+ _throwInternal(unloadCtx[_DYN_DIAG_LOG ](), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1511
2584
  }
1512
2585
  });
1513
2586
  handlers = [];
@@ -1518,7 +2591,36 @@
1518
2591
  };
1519
2592
  }
1520
2593
 
2594
+ function createUnloadHookContainer() {
2595
+ var _hooks = [];
2596
+ function _doUnload(logger) {
2597
+ var oldHooks = _hooks;
2598
+ _hooks = [];
2599
+ arrForEach(oldHooks, function (fn) {
2600
+ try {
2601
+ (fn.rm || fn.remove).call(fn);
2602
+ }
2603
+ catch (e) {
2604
+ _throwInternal(logger, 2 , 73 , "Unloading:" + dumpObj(e));
2605
+ }
2606
+ });
2607
+ }
2608
+ function _addHook(hooks) {
2609
+ if (hooks) {
2610
+ arrAppend(_hooks, hooks);
2611
+ }
2612
+ }
2613
+ return {
2614
+ run: _doUnload,
2615
+ add: _addHook
2616
+ };
2617
+ }
2618
+
2619
+ var _a;
1521
2620
  var strGetPlugin = "getPlugin";
2621
+ var defaultValues = (_a = {},
2622
+ _a[STR_EXTENSION_CONFIG] = { isVal: isNotNullOrUndefined, v: {} },
2623
+ _a);
1522
2624
  var BaseTelemetryPlugin = /** @class */ (function () {
1523
2625
  function BaseTelemetryPlugin() {
1524
2626
  var _self = this;
@@ -1526,7 +2628,7 @@
1526
2628
  var _rootCtx;
1527
2629
  var _nextPlugin;
1528
2630
  var _unloadHandlerContainer;
1529
- var _hooks;
2631
+ var _hookContainer;
1530
2632
  _initDefaults();
1531
2633
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1532
2634
  _self[_DYN_INITIALIZE ] = function (config, core, extensions, pluginChain) {
@@ -1551,11 +2653,7 @@
1551
2653
  if (!unloadDone) {
1552
2654
  unloadDone = true;
1553
2655
  _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1554
- var oldHooks = _hooks;
1555
- _hooks = [];
1556
- arrForEach(oldHooks, function (fn) {
1557
- fn.rm();
1558
- });
2656
+ _hookContainer.run(theUnloadCtx[_DYN_DIAG_LOG ]());
1559
2657
  if (result === true) {
1560
2658
  theUnloadCtx[_DYN_PROCESS_NEXT ](theUnloadState);
1561
2659
  }
@@ -1595,17 +2693,9 @@
1595
2693
  }
1596
2694
  return result;
1597
2695
  };
1598
- _self._addHook = function (hooks) {
1599
- if (hooks) {
1600
- if (isArray$1(hooks)) {
1601
- _hooks = _hooks.concat(hooks);
1602
- }
1603
- else {
1604
- _hooks[_DYN_PUSH ](hooks);
1605
- }
1606
- }
1607
- };
1608
2696
  proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2697
+ proxyFunctionAs(_self, "_addHook", function () { return _hookContainer; }, "add");
2698
+ objDefine(_self, "_unloadHooks", { g: function () { return _hookContainer; } });
1609
2699
  });
1610
2700
  _self[_DYN_DIAG_LOG ] = function (itemCtx) {
1611
2701
  return _getTelCtx(itemCtx)[_DYN_DIAG_LOG ]();
@@ -1623,7 +2713,7 @@
1623
2713
  if (itemCtx) {
1624
2714
  itemCtx[_DYN_PROCESS_NEXT ](env);
1625
2715
  }
1626
- else if (_nextPlugin && isFunction$1(_nextPlugin[STR_PROCESS_TELEMETRY ])) {
2716
+ else if (_nextPlugin && isFunction(_nextPlugin[STR_PROCESS_TELEMETRY ])) {
1627
2717
  _nextPlugin[STR_PROCESS_TELEMETRY ](env, null);
1628
2718
  }
1629
2719
  };
@@ -1643,9 +2733,7 @@
1643
2733
  return itemCtx;
1644
2734
  }
1645
2735
  function _setDefaults(config, core, pluginChain) {
1646
- if (config) {
1647
- setValue(config, STR_EXTENSION_CONFIG, [], null, isNullOrUndefined);
1648
- }
2736
+ createDynamicConfig(config, defaultValues, safeGetLogger(core));
1649
2737
  if (!pluginChain && core) {
1650
2738
  pluginChain = core[_DYN_GET_PROCESS_TEL_CONT0 ]()[_DYN_GET_NEXT ]();
1651
2739
  }
@@ -1661,7 +2749,7 @@
1661
2749
  _self[STR_CORE ] = null;
1662
2750
  _rootCtx = null;
1663
2751
  _nextPlugin = null;
1664
- _hooks = [];
2752
+ _hookContainer = createUnloadHookContainer();
1665
2753
  _unloadHandlerContainer = createUnloadHandlerContainer();
1666
2754
  }
1667
2755
  }
@@ -1669,197 +2757,16 @@
1669
2757
  return BaseTelemetryPlugin;
1670
2758
  }());
1671
2759
 
1672
- var _DYN_EXTENSION_CONFIG = "extensionConfig";
1673
-
1674
- var ConfigurationManager = /** @class */ (function () {
1675
- function ConfigurationManager() {
1676
- }
1677
- ConfigurationManager.getConfig = function (config, field, identifier, defaultValue) {
1678
- if (defaultValue === void 0) { defaultValue = false; }
1679
- var configValue;
1680
- if (identifier && config[_DYN_EXTENSION_CONFIG ] && config[_DYN_EXTENSION_CONFIG ][identifier] && !isNullOrUndefined(config[_DYN_EXTENSION_CONFIG ][identifier][field])) {
1681
- configValue = config[_DYN_EXTENSION_CONFIG ][identifier][field];
1682
- }
1683
- else {
1684
- configValue = config[field];
1685
- }
1686
- return !isNullOrUndefined(configValue) ? configValue : defaultValue;
1687
- };
1688
- return ConfigurationManager;
1689
- }());
1690
-
1691
2760
  var AnalyticsPluginIdentifier = "ApplicationInsightsAnalytics";
1692
2761
 
1693
- var UNDEF_VALUE = undefined;
1694
- var NULL_VALUE = null;
1695
- var EMPTY = "";
1696
- var FUNCTION = "function";
1697
- var NUMBER = "number";
1698
- var PROTOTYPE = "prototype";
1699
- var STRING = "string";
1700
- var SLICE = "slice";
1701
- var ObjClass = Object;
1702
- var ObjProto = ObjClass[PROTOTYPE];
1703
- var StrCls = String;
1704
- var ArrCls = Array;
1705
- var ArrProto = ArrCls[PROTOTYPE];
1706
-
1707
- function _createIs(theType) {
1708
- return function (value) {
1709
- return typeof value === theType;
1710
- };
1711
- }
1712
- function _createObjIs(theName) {
1713
- var theType = "[object " + theName + "]";
1714
- return function (value) {
1715
- return !!(value && objToString(value) === theType);
1716
- };
1717
- }
1718
- function objToString(value) {
1719
- return ObjProto.toString.call(value);
1720
- }
1721
- var isString = _createIs(STRING);
1722
- var isFunction = _createIs(FUNCTION);
1723
- var isArray = ArrCls.isArray;
1724
- var isNumber = _createIs(NUMBER);
1725
- var isError = _createObjIs("Error");
1726
- function isPromiseLike(value) {
1727
- return !!value && isFunction(value.then);
1728
- }
1729
-
1730
- function throwTypeError(message) {
1731
- throw new TypeError(message);
1732
- }
1733
-
1734
- var asString = StrCls;
1735
-
1736
- function dumpObj(object, format) {
1737
- var propertyValueDump = EMPTY;
1738
- if (isError(object)) {
1739
- propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
1740
- }
1741
- else {
1742
- try {
1743
- propertyValueDump = JSON.stringify(object, NULL_VALUE, format ? (isNumber(format) ? format : 4) : UNDEF_VALUE);
1744
- }
1745
- catch (e) {
1746
- propertyValueDump = " - " + dumpObj(e, format);
1747
- }
1748
- }
1749
- return objToString(object) + ": " + propertyValueDump;
1750
- }
1751
-
1752
- function _unwrapFunction(funcName, target, polyFunc) {
1753
- return function (thisArg) {
1754
- var theFunc = (thisArg && thisArg[funcName]) || (target && target[funcName]);
1755
- if (theFunc || polyFunc) {
1756
- var theArgs = arguments;
1757
- return (theFunc || polyFunc).apply(thisArg, theFunc ? ArrProto[SLICE].call(theArgs, 1) : theArgs);
1758
- }
1759
- throwTypeError("'" + asString(funcName) + "' not defined for " + dumpObj(thisArg));
1760
- };
1761
- }
1762
-
1763
- var objDefineProp = ObjClass["defineProperty"];
1764
-
1765
- var arrSlice = _unwrapFunction(SLICE, ArrProto);
1766
-
1767
- var REF = "ref";
1768
- var UNREF = "un" + REF;
1769
- var HAS_REF = "hasRef";
1770
- var ENABLED = "enabled";
1771
- function _createTimerHandler(startTimer, refreshFn, cancelFn) {
1772
- var _a;
1773
- var ref = true;
1774
- var timerId = startTimer ? refreshFn(NULL_VALUE) : NULL_VALUE;
1775
- var theTimerHandler;
1776
- var _unref = function () {
1777
- ref = false;
1778
- timerId && timerId[UNREF] && timerId[UNREF]();
1779
- return theTimerHandler;
1780
- };
1781
- var _ref = function () {
1782
- ref = true;
1783
- timerId && timerId[REF] && timerId[REF]();
1784
- return theTimerHandler;
1785
- };
1786
- var _hasRef = function () {
1787
- if (timerId && timerId[HAS_REF]) {
1788
- return timerId[HAS_REF]();
1789
- }
1790
- return ref;
1791
- };
1792
- var _refresh = function () {
1793
- timerId = refreshFn(timerId);
1794
- if (!ref) {
1795
- _unref();
1796
- }
1797
- return theTimerHandler;
1798
- };
1799
- var _cancel = function () {
1800
- timerId && cancelFn(timerId);
1801
- timerId = NULL_VALUE;
1802
- };
1803
- var _setEnabled = function (value) {
1804
- !value && timerId && _cancel();
1805
- value && !timerId && _refresh();
1806
- };
1807
- theTimerHandler = (_a = {
1808
- cancel: _cancel,
1809
- refresh: _refresh
1810
- },
1811
- _a[HAS_REF] = _hasRef,
1812
- _a[REF] = _ref,
1813
- _a[UNREF] = _unref,
1814
- _a[ENABLED] = false,
1815
- _a);
1816
- objDefineProp(theTimerHandler, ENABLED, {
1817
- get: function () { return !!timerId; },
1818
- set: _setEnabled
1819
- });
1820
- return {
1821
- h: theTimerHandler,
1822
- dn: function () {
1823
- timerId = NULL_VALUE;
1824
- }
1825
- };
1826
- }
1827
-
1828
- function _createTimeoutWith(self, startTimer, overrideFn, theArgs) {
1829
- var isArr = isArray(overrideFn);
1830
- var len = isArr ? overrideFn.length : 0;
1831
- var setFn = (len > 0 ? overrideFn[0] : (!isArr ? overrideFn : UNDEF_VALUE)) || setTimeout;
1832
- var clearFn = (len > 1 ? overrideFn[1] : UNDEF_VALUE) || clearTimeout;
1833
- var timerFn = theArgs[0];
1834
- theArgs[0] = function () {
1835
- handler.dn();
1836
- timerFn.apply(self, arguments);
1837
- };
1838
- var handler = _createTimerHandler(startTimer, function (timerId) {
1839
- if (timerId) {
1840
- if (timerId.refresh) {
1841
- timerId.refresh();
1842
- return timerId;
1843
- }
1844
- clearFn.call(self, timerId);
1845
- }
1846
- return setFn.apply(self, theArgs);
1847
- }, function (timerId) {
1848
- clearFn.call(self, timerId);
1849
- });
1850
- return handler.h;
1851
- }
1852
- function scheduleTimeout(callback, timeout) {
1853
- return _createTimeoutWith(this, true, UNDEF_VALUE, arrSlice(arguments));
1854
- }
1855
-
1856
- function getReactNativeDeviceInfo() {
1857
- return DeviceInfo__default["default"];
1858
- }
1859
-
1860
- var ReactNativePlugin = /** @class */ (function (_super) {
1861
- __extendsFn(ReactNativePlugin, _super);
1862
- function ReactNativePlugin(config) {
2762
+ var defaultReactNativePluginConfig = objDeepFreeze({
2763
+ disableDeviceCollection: false,
2764
+ disableExceptionCollection: false,
2765
+ uniqueIdPromiseTimeout: 5000
2766
+ });
2767
+ var ReactNativeManualDevicePlugin = /** @class */ (function (_super) {
2768
+ __extendsFn(ReactNativeManualDevicePlugin, _super);
2769
+ function ReactNativeManualDevicePlugin(config) {
1863
2770
  var _this = _super.call(this) || this;
1864
2771
  _this.identifier = "AppInsightsReactNativePlugin";
1865
2772
  _this.priority = 140;
@@ -1871,27 +2778,36 @@
1871
2778
  var _waitingTimer;
1872
2779
  var _waitingItems = null;
1873
2780
  var _deviceInfoModule;
1874
- dynamicProto(ReactNativePlugin, _this, function (_self, _base) {
2781
+ var _deviceInfoNeedsUpdate;
2782
+ var exceptionHandlerSet;
2783
+ dynamicProto(ReactNativeManualDevicePlugin, _this, function (_self, _base) {
1875
2784
  _initDefaults();
1876
2785
  _self.initialize = function (config,
1877
2786
  core, extensions) {
1878
- var _a;
2787
+ var identifier = _this.identifier;
1879
2788
  if (!_self.isInitialized()) {
1880
2789
  _base.initialize(config, core, extensions);
1881
- var inConfig_1 = config || {};
1882
- var defaultConfig = _getDefaultConfig();
1883
- objForEachKey(defaultConfig, function (option, value) {
1884
- _config[option] = ConfigurationManager.getConfig(inConfig_1, option, _self.identifier, !isUndefined(_config[option]) ? _config[option] : value);
1885
- });
1886
- if (!_config.disableDeviceCollection) {
1887
- _self._collectDeviceInfo();
1888
- }
1889
- if (core && core.getPlugin) {
1890
- _analyticsPlugin = (_a = core.getPlugin(AnalyticsPluginIdentifier)) === null || _a === void 0 ? void 0 : _a.plugin;
1891
- }
1892
- if (!_config.disableExceptionCollection) {
1893
- _self._setExceptionHandler();
1894
- }
2790
+ _self._addHook(onConfigChange(config, function (details) {
2791
+ var _a;
2792
+ var ctx = _self._getTelCtx();
2793
+ _config = ctx.getExtCfg(identifier, defaultReactNativePluginConfig);
2794
+ if (!_config.disableDeviceCollection && _deviceInfoNeedsUpdate) {
2795
+ _deviceInfoNeedsUpdate = !_self._collectDeviceInfo();
2796
+ }
2797
+ if (core && core.getPlugin) {
2798
+ _analyticsPlugin = (_a = core.getPlugin(AnalyticsPluginIdentifier)) === null || _a === void 0 ? void 0 : _a.plugin;
2799
+ }
2800
+ else {
2801
+ _analyticsPlugin = null;
2802
+ }
2803
+ if (exceptionHandlerSet) {
2804
+ _resetGlobalErrorHandler();
2805
+ }
2806
+ if (!_config.disableExceptionCollection) {
2807
+ _self._setExceptionHandler();
2808
+ exceptionHandlerSet = true;
2809
+ }
2810
+ }));
1895
2811
  }
1896
2812
  };
1897
2813
  _self.processTelemetry = function (item, itemCtx) {
@@ -1909,6 +2825,7 @@
1909
2825
  };
1910
2826
  _self.setDeviceInfoModule = function (deviceInfoModule) {
1911
2827
  _deviceInfoModule = deviceInfoModule;
2828
+ _deviceInfoNeedsUpdate = true;
1912
2829
  };
1913
2830
  _self.setDeviceId = _setDeviceId;
1914
2831
  _self.setDeviceModel = function (newModel) {
@@ -1919,10 +2836,13 @@
1919
2836
  };
1920
2837
  _self._collectDeviceInfo = function () {
1921
2838
  try {
1922
- var deviceInfoModule = _deviceInfoModule || getReactNativeDeviceInfo();
1923
- _device.deviceClass = deviceInfoModule.getDeviceType();
1924
- _device.model = deviceInfoModule.getModel();
1925
- var uniqueId = deviceInfoModule.getUniqueId();
2839
+ _deviceInfoModule = _this.getDeviceInfoModule(_deviceInfoModule);
2840
+ if (!_deviceInfoModule) {
2841
+ return false;
2842
+ }
2843
+ _device.deviceClass = _deviceInfoModule.getDeviceType();
2844
+ _device.model = _deviceInfoModule.getModel();
2845
+ var uniqueId = _deviceInfoModule.getUniqueId();
1926
2846
  if (isPromiseLike(uniqueId)) {
1927
2847
  _waitingForId = true;
1928
2848
  if (_waitingTimer) {
@@ -1936,16 +2856,17 @@
1936
2856
  uniqueId.then(function (value) {
1937
2857
  _setDeviceId(value);
1938
2858
  }, function (reason) {
1939
- _warnToConsole(_self.diagLog(), "Failed to get device id: " + dumpObj$1(reason));
2859
+ _warnToConsole(_self.diagLog(), "Failed to get device id: " + dumpObj(reason));
1940
2860
  _setDeviceId(_device.id);
1941
2861
  });
1942
2862
  }
1943
2863
  else if (isString(uniqueId)) {
1944
2864
  _device.id = uniqueId;
1945
2865
  }
2866
+ return true;
1946
2867
  }
1947
2868
  catch (e) {
1948
- _warnToConsole(_self.diagLog(), "Failed to get DeviceInfo: " + getExceptionName(e) + " - " + dumpObj$1(e));
2869
+ _warnToConsole(_self.diagLog(), "Failed to get DeviceInfo: " + getExceptionName(e) + " - " + dumpObj(e));
1949
2870
  }
1950
2871
  };
1951
2872
  _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
@@ -1954,11 +2875,13 @@
1954
2875
  };
1955
2876
  function _initDefaults() {
1956
2877
  _device = {};
1957
- _config = config || _getDefaultConfig();
2878
+ _config = {};
1958
2879
  _analyticsPlugin = null;
1959
2880
  _defaultHandler = null;
1960
2881
  _waitingForId = false;
1961
2882
  _deviceInfoModule = null;
2883
+ _deviceInfoNeedsUpdate = true;
2884
+ exceptionHandlerSet = false;
1962
2885
  }
1963
2886
  function _setDeviceId(newId) {
1964
2887
  _device.id = newId;
@@ -2026,22 +2949,33 @@
2026
2949
  }
2027
2950
  _self._config = _config;
2028
2951
  _self._getDbgPlgTargets = function () {
2029
- return [_device, _deviceInfoModule];
2952
+ return [_device, _deviceInfoModule, _config];
2030
2953
  };
2031
2954
  });
2032
- function _getDefaultConfig() {
2033
- return {
2034
- disableDeviceCollection: false,
2035
- disableExceptionCollection: false,
2036
- uniqueIdPromiseTimeout: 5000
2037
- };
2038
- }
2039
2955
  return _this;
2040
2956
  }
2041
- ReactNativePlugin.__ieDyn=1;
2042
- return ReactNativePlugin;
2957
+ ReactNativeManualDevicePlugin.prototype.getDeviceInfoModule = function (_deviceInfoModule) {
2958
+ if (!_deviceInfoModule) {
2959
+ _warnToConsole(this.diagLog(), "Failed to get DeviceInfo. Provide DeviceInfo while init or turn it off by setting disableDeviceCollection flag to true");
2960
+ return null;
2961
+ }
2962
+ return _deviceInfoModule;
2963
+ };
2964
+ return ReactNativeManualDevicePlugin;
2043
2965
  }(BaseTelemetryPlugin));
2044
2966
 
2967
+ var ReactNativePlugin = /** @class */ (function (_super) {
2968
+ __extendsFn(ReactNativePlugin, _super);
2969
+ function ReactNativePlugin() {
2970
+ return _super !== null && _super.apply(this, arguments) || this;
2971
+ }
2972
+ ReactNativePlugin.prototype.getDeviceInfoModule = function (_deviceInfoModule) {
2973
+ return _deviceInfoModule || getReactNativeDeviceInfo();
2974
+ };
2975
+ return ReactNativePlugin;
2976
+ }(ReactNativeManualDevicePlugin));
2977
+
2978
+ exports.ReactNativeManualDevicePlugin = ReactNativeManualDevicePlugin;
2045
2979
  exports.ReactNativePlugin = ReactNativePlugin;
2046
2980
  exports.getReactNativeDeviceInfo = getReactNativeDeviceInfo;
2047
2981