@microsoft/applicationinsights-core-js 2.8.5-nightly.2206-03 → 2.8.5-nightly.2207-01

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 (133) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +807 -711
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +400 -336
  7. package/dist/applicationinsights-core-js.d.ts +1 -1
  8. package/dist/applicationinsights-core-js.js +807 -711
  9. package/dist/applicationinsights-core-js.js.map +1 -1
  10. package/dist/applicationinsights-core-js.min.js +2 -2
  11. package/dist/applicationinsights-core-js.min.js.map +1 -1
  12. package/dist/applicationinsights-core-js.rollup.d.ts +1 -1
  13. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +14 -10
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  15. package/dist-esm/JavaScriptSDK/BaseCore.js +158 -139
  16. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +39 -36
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/ChannelController.js +60 -61
  20. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/CookieMgr.js +46 -43
  22. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  23. package/dist-esm/JavaScriptSDK/CoreUtils.js +16 -15
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +7 -5
  26. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +4 -3
  28. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +56 -56
  30. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  31. package/dist-esm/JavaScriptSDK/EnvUtils.js +21 -20
  32. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  33. package/dist-esm/JavaScriptSDK/EventHelpers.js +45 -39
  34. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  35. package/dist-esm/JavaScriptSDK/HelperFuncs.js +49 -40
  36. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  37. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +18 -16
  38. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/InternalConstants.js +19 -21
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/NotificationManager.js +26 -23
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/PerfManager.js +41 -35
  44. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +54 -53
  46. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/RandomHelper.js +5 -4
  48. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +34 -34
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  51. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +11 -10
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  53. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +4 -3
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  55. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +26 -23
  56. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +103 -86
  60. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  85. package/dist-esm/__DynamicConstants.js +70 -0
  86. package/dist-esm/__DynamicConstants.js.map +1 -0
  87. package/dist-esm/applicationinsights-core-js.js +1 -1
  88. package/package.json +5 -2
  89. package/src/JavaScriptSDK/AppInsightsCore.ts +17 -17
  90. package/src/JavaScriptSDK/BaseCore.ts +112 -97
  91. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +36 -32
  92. package/src/JavaScriptSDK/ChannelController.ts +39 -37
  93. package/src/JavaScriptSDK/CookieMgr.ts +27 -27
  94. package/src/JavaScriptSDK/CoreUtils.ts +19 -20
  95. package/src/JavaScriptSDK/DataCacheHelper.ts +12 -11
  96. package/src/JavaScriptSDK/DbgExtensionUtils.ts +9 -9
  97. package/src/JavaScriptSDK/DiagnosticLogger.ts +49 -50
  98. package/src/JavaScriptSDK/EnvUtils.ts +15 -17
  99. package/src/JavaScriptSDK/EventHelpers.ts +15 -14
  100. package/src/JavaScriptSDK/HelperFuncs.ts +20 -11
  101. package/src/JavaScriptSDK/InstrumentHooks.ts +11 -13
  102. package/src/JavaScriptSDK/InternalConstants.ts +20 -20
  103. package/src/JavaScriptSDK/NotificationManager.ts +27 -27
  104. package/src/JavaScriptSDK/PerfManager.ts +21 -19
  105. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +38 -34
  106. package/src/JavaScriptSDK/RandomHelper.ts +8 -9
  107. package/src/JavaScriptSDK/TelemetryHelpers.ts +33 -34
  108. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +17 -16
  109. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +11 -11
  110. package/src/JavaScriptSDK/W3cTraceParent.ts +6 -6
  111. package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +1 -1
  112. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +72 -56
  113. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +1 -1
  114. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +2 -2
  115. package/types/JavaScriptSDK/AppInsightsCore.d.ts +4 -4
  116. package/types/JavaScriptSDK/BaseCore.d.ts +11 -11
  117. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +4 -4
  118. package/types/JavaScriptSDK/ChannelController.d.ts +1 -2
  119. package/types/JavaScriptSDK/CookieMgr.d.ts +3 -3
  120. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +2 -2
  121. package/types/JavaScriptSDK/HelperFuncs.d.ts +6 -0
  122. package/types/JavaScriptSDK/InstrumentHooks.d.ts +1 -1
  123. package/types/JavaScriptSDK/InternalConstants.d.ts +16 -20
  124. package/types/JavaScriptSDK/NotificationManager.d.ts +1 -1
  125. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +2 -2
  126. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +4 -4
  127. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +2 -2
  128. package/types/__DynamicConstants.d.ts +56 -0
  129. package/types/tsdoc-metadata.json +1 -1
  130. package/dist-esm/JavaScriptSDK/Constants.js +0 -9
  131. package/dist-esm/JavaScriptSDK/Constants.js.map +0 -1
  132. package/src/JavaScriptSDK/Constants.ts +0 -5
  133. package/types/JavaScriptSDK/Constants.d.ts +0 -2
@@ -1,15 +1,16 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2206-03
2
+ * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2207-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
7
  "use strict";
8
- import { safeGetLogger, _throwInternal } from "./DiagnosticLogger";
8
+ import { _DYN_CALL, _DYN_CONFIG, _DYN_CREATE_NEW, _DYN_DIAG_LOG, _DYN_GET_NEXT, _DYN_GET_PLUGIN, _DYN_IDENTIFIER, _DYN_IS_ASYNC, _DYN_IS_INITIALIZED, _DYN_LENGTH, _DYN_LOGGER, _DYN_PROCESS_NEXT, _DYN_PUSH, _DYN_SET_NEXT_PLUGIN, _DYN_TEARDOWN, _DYN_UPDATE } from "../__DynamicConstants";
9
+ import { _throwInternal, safeGetLogger } from "./DiagnosticLogger";
10
+ import { dumpObj } from "./EnvUtils";
9
11
  import { arrForEach, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objExtend, objForEachKey, objFreeze, objKeys, proxyFunctions } from "./HelperFuncs";
12
+ import { STR_CORE, STR_DISABLED, STR_EMPTY, STR_EXTENSION_CONFIG, STR_PRIORITY, STR_PROCESS_TELEMETRY } from "./InternalConstants";
10
13
  import { doPerf } from "./PerfManager";
11
- import { dumpObj } from "./EnvUtils";
12
- import { strCore, strDisabled, strEmpty, strIsInitialized, strTeardown, strUpdate } from "./InternalConstants";
13
14
  import { _getPluginState } from "./TelemetryHelpers";
14
15
  var strTelemetryPluginChain = "TelemetryPluginChain";
15
16
  var strHasRunFlags = "_hasRun";
@@ -17,13 +18,13 @@ var strGetTelCtx = "_getTelCtx";
17
18
  var _chainId = 0;
18
19
  function _getNextProxyStart(proxy, core, startAt) {
19
20
  while (proxy) {
20
- if (proxy.getPlugin() === startAt) {
21
+ if (proxy[_DYN_GET_PLUGIN /* @min:%2egetPlugin */]() === startAt) {
21
22
  return proxy;
22
23
  }
23
- proxy = proxy.getNext();
24
+ proxy = proxy[_DYN_GET_NEXT /* @min:%2egetNext */]();
24
25
  }
25
26
  // This wasn't found in the existing chain so create an isolated one with just this plugin
26
- return createTelemetryProxyChain([startAt], core.config || {}, core);
27
+ return createTelemetryProxyChain([startAt], core[_DYN_CONFIG /* @min:%2econfig */] || {}, core);
27
28
  }
28
29
  /**
29
30
  * @ignore
@@ -75,7 +76,7 @@ function _createInternalContext(telemetryChain, config, core, startAt) {
75
76
  args[_i - 2] = arguments[_i];
76
77
  }
77
78
  if (onComplete) {
78
- _onComplete.push({
79
+ _onComplete[_DYN_PUSH /* @min:%2epush */]({
79
80
  func: onComplete,
80
81
  self: !isUndefined(that) ? that : context.ctx,
81
82
  args: args
@@ -85,16 +86,16 @@ function _createInternalContext(telemetryChain, config, core, startAt) {
85
86
  function _moveNext() {
86
87
  var nextProxy = _nextProxy;
87
88
  // Automatically move to the next plugin
88
- _nextProxy = nextProxy ? nextProxy.getNext() : null;
89
+ _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT /* @min:%2egetNext */]() : null;
89
90
  if (!nextProxy) {
90
91
  var onComplete = _onComplete;
91
- if (onComplete && onComplete.length > 0) {
92
+ if (onComplete && onComplete[_DYN_LENGTH /* @min:%2elength */] > 0) {
92
93
  arrForEach(onComplete, function (completeDetails) {
93
94
  try {
94
- completeDetails.func.call(completeDetails.self, completeDetails.args);
95
+ completeDetails.func[_DYN_CALL /* @min:%2ecall */](completeDetails.self, completeDetails.args);
95
96
  }
96
97
  catch (e) {
97
- _throwInternal(core.logger, 2 /* eLoggingSeverity.WARNING */, 73 /* _eInternalMessageId.PluginException */, "Unexpected Exception during onComplete - " + dumpObj(e));
98
+ _throwInternal(core[_DYN_LOGGER /* @min:%2elogger */], 2 /* eLoggingSeverity.WARNING */, 73 /* _eInternalMessageId.PluginException */, "Unexpected Exception during onComplete - " + dumpObj(e));
98
99
  }
99
100
  });
100
101
  _onComplete = [];
@@ -107,7 +108,7 @@ function _createInternalContext(telemetryChain, config, core, startAt) {
107
108
  if (mergeDefault === void 0) { mergeDefault = 0 /* GetExtCfgMergeType.None */; }
108
109
  var theConfig;
109
110
  if (config) {
110
- var extConfig = config.extensionConfig;
111
+ var extConfig = config[STR_EXTENSION_CONFIG /* @min:%2eextensionConfig */];
111
112
  if (extConfig && identifier) {
112
113
  theConfig = extConfig[identifier];
113
114
  }
@@ -154,7 +155,7 @@ function _createInternalContext(telemetryChain, config, core, startAt) {
154
155
  // Keep processing until we reach the end of the chain
155
156
  var nextPlugin;
156
157
  while (!!(nextPlugin = context._next())) {
157
- var plugin = nextPlugin.getPlugin();
158
+ var plugin = nextPlugin[_DYN_GET_PLUGIN /* @min:%2egetPlugin */]();
158
159
  if (plugin) {
159
160
  // callback with the current on
160
161
  cb(plugin);
@@ -176,7 +177,7 @@ export function createProcessTelemetryContext(telemetryChain, config, core, star
176
177
  function _processNext(env) {
177
178
  var nextPlugin = internalContext._next();
178
179
  // Run the next plugin which will call "processNext()"
179
- nextPlugin && nextPlugin.processTelemetry(env, context);
180
+ nextPlugin && nextPlugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */](env, context);
180
181
  return !nextPlugin;
181
182
  }
182
183
  function _createNew(plugins, startAt) {
@@ -184,10 +185,10 @@ export function createProcessTelemetryContext(telemetryChain, config, core, star
184
185
  if (isArray(plugins)) {
185
186
  plugins = createTelemetryProxyChain(plugins, config, core, startAt);
186
187
  }
187
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
188
+ return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT /* @min:%2egetNext */](), config, core, startAt);
188
189
  }
189
- context.processNext = _processNext;
190
- context.createNew = _createNew;
190
+ context[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */] = _processNext;
191
+ context[_DYN_CREATE_NEW /* @min:%2ecreateNew */] = _createNew;
191
192
  return context;
192
193
  }
193
194
  /**
@@ -198,7 +199,7 @@ export function createProcessTelemetryContext(telemetryChain, config, core, star
198
199
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
199
200
  */
200
201
  export function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
201
- var config = core.config || {};
202
+ var config = core[_DYN_CONFIG /* @min:%2econfig */] || {};
202
203
  var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
203
204
  var context = internalContext.ctx;
204
205
  function _processNext(unloadState) {
@@ -211,10 +212,10 @@ export function createProcessTelemetryUnloadContext(telemetryChain, core, startA
211
212
  if (isArray(plugins)) {
212
213
  plugins = createTelemetryProxyChain(plugins, config, core, startAt);
213
214
  }
214
- return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
215
+ return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT /* @min:%2egetNext */](), core, startAt);
215
216
  }
216
- context.processNext = _processNext;
217
- context.createNew = _createNew;
217
+ context[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */] = _processNext;
218
+ context[_DYN_CREATE_NEW /* @min:%2ecreateNew */] = _createNew;
218
219
  return context;
219
220
  }
220
221
  /**
@@ -225,13 +226,13 @@ export function createProcessTelemetryUnloadContext(telemetryChain, core, startA
225
226
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
226
227
  */
227
228
  export function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
228
- var config = core.config || {};
229
+ var config = core[_DYN_CONFIG /* @min:%2econfig */] || {};
229
230
  var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
230
231
  var context = internalContext.ctx;
231
232
  function _processNext(updateState) {
232
233
  return context.iterate(function (plugin) {
233
- if (isFunction(plugin.update)) {
234
- plugin.update(context, updateState);
234
+ if (isFunction(plugin[_DYN_UPDATE /* @min:%2eupdate */])) {
235
+ plugin[_DYN_UPDATE /* @min:%2eupdate */](context, updateState);
235
236
  }
236
237
  });
237
238
  }
@@ -240,10 +241,10 @@ export function createProcessTelemetryUpdateContext(telemetryChain, core, startA
240
241
  if (isArray(plugins)) {
241
242
  plugins = createTelemetryProxyChain(plugins, config, core, startAt);
242
243
  }
243
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
244
+ return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT /* @min:%2egetNext */](), core, startAt);
244
245
  }
245
- context.processNext = _processNext;
246
- context.createNew = _createNew;
246
+ context[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */] = _processNext;
247
+ context[_DYN_CREATE_NEW /* @min:%2ecreateNew */] = _createNew;
247
248
  return context;
248
249
  }
249
250
  /**
@@ -256,14 +257,14 @@ export function createProcessTelemetryUpdateContext(telemetryChain, core, startA
256
257
  export function createTelemetryProxyChain(plugins, config, core, startAt) {
257
258
  var firstProxy = null;
258
259
  var add = startAt ? false : true;
259
- if (isArray(plugins) && plugins.length > 0) {
260
+ if (isArray(plugins) && plugins[_DYN_LENGTH /* @min:%2elength */] > 0) {
260
261
  // Create the proxies and wire up the next plugin chain
261
262
  var lastProxy_1 = null;
262
263
  arrForEach(plugins, function (thePlugin) {
263
264
  if (!add && startAt === thePlugin) {
264
265
  add = true;
265
266
  }
266
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
267
+ if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */])) {
267
268
  // Only add plugins that are processors
268
269
  var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
269
270
  if (!firstProxy) {
@@ -296,11 +297,11 @@ export function createTelemetryProxyChain(plugins, config, core, startAt) {
296
297
  */
297
298
  export function createTelemetryPluginProxy(plugin, config, core) {
298
299
  var nextProxy = null;
299
- var hasProcessTelemetry = isFunction(plugin.processTelemetry);
300
- var hasSetNext = isFunction(plugin.setNextPlugin);
300
+ var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */]);
301
+ var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN /* @min:%2esetNextPlugin */]);
301
302
  var chainId;
302
303
  if (plugin) {
303
- chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
304
+ chainId = plugin[_DYN_IDENTIFIER /* @min:%2eidentifier */] + "-" + plugin[STR_PRIORITY /* @min:%2epriority */] + "-" + _chainId++;
304
305
  }
305
306
  else {
306
307
  chainId = "Unknown-0-" + _chainId++;
@@ -335,7 +336,7 @@ export function createTelemetryPluginProxy(plugin, config, core) {
335
336
  }
336
337
  function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
337
338
  var hasRun = false;
338
- var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
339
+ var identifier = plugin ? plugin[_DYN_IDENTIFIER /* @min:%2eidentifier */] : strTelemetryPluginChain;
339
340
  var hasRunContext = itemCtx[strHasRunFlags];
340
341
  if (!hasRunContext) {
341
342
  // Assign and populate
@@ -344,12 +345,12 @@ export function createTelemetryPluginProxy(plugin, config, core) {
344
345
  // Ensure that we keep the context in sync
345
346
  itemCtx.setNext(nextProxy);
346
347
  if (plugin) {
347
- doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
348
+ doPerf(itemCtx[STR_CORE /* @min:%2ecore */](), function () { return identifier + ":" + name; }, function () {
348
349
  // Mark this component as having run
349
350
  hasRunContext[chainId] = true;
350
351
  try {
351
352
  // Set a flag on the next plugin so we know if it was attempted to be executed
352
- var nextId = nextProxy ? nextProxy._id : strEmpty;
353
+ var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
353
354
  if (nextId) {
354
355
  hasRunContext[nextId] = false;
355
356
  }
@@ -364,7 +365,7 @@ export function createTelemetryPluginProxy(plugin, config, core) {
364
365
  if (!nextProxy || !hasNextRun) {
365
366
  // Either we have no next plugin or the current one did not attempt to call the next plugin
366
367
  // Which means the current one is the root of the failure so log/report this failure
367
- _throwInternal(itemCtx.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 73 /* _eInternalMessageId.PluginException */, "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
368
+ _throwInternal(itemCtx[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 73 /* _eInternalMessageId.PluginException */, "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
368
369
  }
369
370
  }
370
371
  }, details, isAsync);
@@ -378,7 +379,7 @@ export function createTelemetryPluginProxy(plugin, config, core) {
378
379
  return false;
379
380
  }
380
381
  var pluginState = _getPluginState(plugin);
381
- if (pluginState.teardown || pluginState[strDisabled]) {
382
+ if (pluginState[_DYN_TEARDOWN /* @min:%2eteardown */] || pluginState[STR_DISABLED]) {
382
383
  return false;
383
384
  }
384
385
  // Ensure that we keep the context in sync (for processNext()), just in case a plugin
@@ -386,16 +387,16 @@ export function createTelemetryPluginProxy(plugin, config, core) {
386
387
  // other form of error occurred
387
388
  if (hasSetNext) {
388
389
  // Backward compatibility setting the next plugin on the instance
389
- plugin.setNextPlugin(nextProxy);
390
+ plugin[_DYN_SET_NEXT_PLUGIN /* @min:%2esetNextPlugin */](nextProxy);
390
391
  }
391
- plugin.processTelemetry(env, itemCtx);
392
+ plugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */](env, itemCtx);
392
393
  // Process Telemetry is expected to call itemCtx.processNext() or nextPlugin.processTelemetry()
393
394
  return true;
394
395
  }
395
396
  if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
396
397
  // The underlying plugin is either not defined, not enabled or does not have a processTelemetry implementation
397
398
  // so we still want the next plugin to be executed.
398
- itemCtx.processNext(env);
399
+ itemCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](env);
399
400
  }
400
401
  }
401
402
  function _unloadPlugin(unloadCtx, unloadState) {
@@ -404,14 +405,14 @@ export function createTelemetryPluginProxy(plugin, config, core) {
404
405
  var hasRun = false;
405
406
  if (plugin) {
406
407
  var pluginState = _getPluginState(plugin);
407
- var pluginCore = plugin[strCore] || pluginState.core;
408
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE /* @min:%2ecore */];
408
409
  // Only teardown the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
409
- if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
410
+ if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN /* @min:%2eteardown */]) {
410
411
  // Handle plugins that don't extend from the BaseTelemetryPlugin
411
- pluginState[strCore] = null;
412
- pluginState[strTeardown] = true;
413
- pluginState[strIsInitialized] = false;
414
- if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
412
+ pluginState[STR_CORE /* @min:%2ecore */] = null;
413
+ pluginState[_DYN_TEARDOWN /* @min:%2eteardown */] = true;
414
+ pluginState[_DYN_IS_INITIALIZED /* @min:%2eisInitialized */] = false;
415
+ if (plugin[_DYN_TEARDOWN /* @min:%2eteardown */] && plugin[_DYN_TEARDOWN /* @min:%2eteardown */](unloadCtx, unloadState) === true) {
415
416
  // plugin told us that it was going to (or has) call unloadCtx.processNext()
416
417
  hasRun = true;
417
418
  }
@@ -419,9 +420,9 @@ export function createTelemetryPluginProxy(plugin, config, core) {
419
420
  }
420
421
  return hasRun;
421
422
  }
422
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
423
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC /* @min:%2eisAsync */])) {
423
424
  // Only called if we hasRun was not true
424
- unloadCtx.processNext(unloadState);
425
+ unloadCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](unloadState);
425
426
  }
426
427
  }
427
428
  function _updatePlugin(updateCtx, updateState) {
@@ -430,10 +431,10 @@ export function createTelemetryPluginProxy(plugin, config, core) {
430
431
  var hasRun = false;
431
432
  if (plugin) {
432
433
  var pluginState = _getPluginState(plugin);
433
- var pluginCore = plugin[strCore] || pluginState.core;
434
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE /* @min:%2ecore */];
434
435
  // Only update the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
435
- if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
436
- if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
436
+ if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN /* @min:%2eteardown */]) {
437
+ if (plugin[_DYN_UPDATE /* @min:%2eupdate */] && plugin[_DYN_UPDATE /* @min:%2eupdate */](updateCtx, updateState) === true) {
437
438
  // plugin told us that it was going to (or has) call unloadCtx.processNext()
438
439
  hasRun = true;
439
440
  }
@@ -443,7 +444,7 @@ export function createTelemetryPluginProxy(plugin, config, core) {
443
444
  }
444
445
  if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
445
446
  // Only called if we hasRun was not true
446
- updateCtx.processNext(updateState);
447
+ updateCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](updateState);
447
448
  }
448
449
  }
449
450
  return objFreeze(proxyChain);
@@ -1 +1 @@
1
- {"version":3,"file":"ProcessTelemetryContext.js.map","sources":["ProcessTelemetryContext.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { safeGetLogger, _throwInternal } from \"./DiagnosticLogger\";\r\nimport { arrForEach, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objExtend, objForEachKey, objFreeze, objKeys, proxyFunctions } from \"./HelperFuncs\";\r\nimport { doPerf } from \"./PerfManager\";\r\nimport { dumpObj } from \"./EnvUtils\";\r\nimport { strCore, strDisabled, strEmpty, strIsInitialized, strTeardown, strUpdate } from \"./InternalConstants\";\r\nimport { _getPluginState } from \"./TelemetryHelpers\";\r\nvar strTelemetryPluginChain = \"TelemetryPluginChain\";\r\nvar strHasRunFlags = \"_hasRun\";\r\nvar strGetTelCtx = \"_getTelCtx\";\r\nvar _chainId = 0;\r\nfunction _getNextProxyStart(proxy, core, startAt) {\r\n while (proxy) {\r\n if (proxy.getPlugin() === startAt) {\r\n return proxy;\r\n }\r\n proxy = proxy.getNext();\r\n }\r\n // This wasn't found in the existing chain so create an isolated one with just this plugin\r\n return createTelemetryProxyChain([startAt], core.config || {}, core);\r\n}\r\n/**\r\n * @ignore\r\n * @param telemetryChain\r\n * @param config\r\n * @param core\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n * @returns\r\n */\r\nfunction _createInternalContext(telemetryChain, config, core, startAt) {\r\n // We have a special case where we want to start execution from this specific plugin\r\n // or we simply reuse the existing telemetry plugin chain (normal execution case)\r\n var _nextProxy = null; // By Default set as no next plugin\r\n var _onComplete = [];\r\n if (startAt !== null) {\r\n // There is no next element (null) vs not defined (undefined) so use the full chain\r\n _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;\r\n }\r\n var context = {\r\n _next: _moveNext,\r\n ctx: {\r\n core: function () {\r\n return core;\r\n },\r\n diagLog: function () {\r\n return safeGetLogger(core, config);\r\n },\r\n getCfg: function () {\r\n return config;\r\n },\r\n getExtCfg: _getExtCfg,\r\n getConfig: _getConfig,\r\n hasNext: function () {\r\n return !!_nextProxy;\r\n },\r\n getNext: function () {\r\n return _nextProxy;\r\n },\r\n setNext: function (nextPlugin) {\r\n _nextProxy = nextPlugin;\r\n },\r\n iterate: _iterateChain,\r\n onComplete: _addOnComplete\r\n }\r\n };\r\n function _addOnComplete(onComplete, that) {\r\n var args = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n args[_i - 2] = arguments[_i];\r\n }\r\n if (onComplete) {\r\n _onComplete.push({\r\n func: onComplete,\r\n self: !isUndefined(that) ? that : context.ctx,\r\n args: args\r\n });\r\n }\r\n }\r\n function _moveNext() {\r\n var nextProxy = _nextProxy;\r\n // Automatically move to the next plugin\r\n _nextProxy = nextProxy ? nextProxy.getNext() : null;\r\n if (!nextProxy) {\r\n var onComplete = _onComplete;\r\n if (onComplete && onComplete.length > 0) {\r\n arrForEach(onComplete, function (completeDetails) {\r\n try {\r\n completeDetails.func.call(completeDetails.self, completeDetails.args);\r\n }\r\n catch (e) {\r\n _throwInternal(core.logger, 2 /* eLoggingSeverity.WARNING */, 73 /* _eInternalMessageId.PluginException */, \"Unexpected Exception during onComplete - \" + dumpObj(e));\r\n }\r\n });\r\n _onComplete = [];\r\n }\r\n }\r\n return nextProxy;\r\n }\r\n function _getExtCfg(identifier, defaultValue, mergeDefault) {\r\n if (defaultValue === void 0) { defaultValue = {}; }\r\n if (mergeDefault === void 0) { mergeDefault = 0 /* GetExtCfgMergeType.None */; }\r\n var theConfig;\r\n if (config) {\r\n var extConfig = config.extensionConfig;\r\n if (extConfig && identifier) {\r\n theConfig = extConfig[identifier];\r\n }\r\n }\r\n if (!theConfig) {\r\n // Just use the defaults\r\n theConfig = defaultValue;\r\n }\r\n else if (isObject(defaultValue)) {\r\n if (mergeDefault !== 0 /* GetExtCfgMergeType.None */) {\r\n // Merge the defaults and configured values\r\n var newConfig_1 = objExtend(true, defaultValue, theConfig);\r\n if (config && mergeDefault === 2 /* GetExtCfgMergeType.MergeDefaultFromRootOrDefault */) {\r\n // Enumerate over the defaultValues and if not already populated attempt to\r\n // find a value from the root config\r\n objForEachKey(defaultValue, function (field) {\r\n // for each unspecified field, set the default value\r\n if (isNullOrUndefined(newConfig_1[field])) {\r\n var cfgValue = config[field];\r\n if (!isNullOrUndefined(cfgValue)) {\r\n newConfig_1[field] = cfgValue;\r\n }\r\n }\r\n });\r\n }\r\n theConfig = newConfig_1;\r\n }\r\n }\r\n return theConfig;\r\n }\r\n function _getConfig(identifier, field, defaultValue) {\r\n if (defaultValue === void 0) { defaultValue = false; }\r\n var theValue;\r\n var extConfig = _getExtCfg(identifier, null);\r\n if (extConfig && !isNullOrUndefined(extConfig[field])) {\r\n theValue = extConfig[field];\r\n }\r\n else if (config && !isNullOrUndefined(config[field])) {\r\n theValue = config[field];\r\n }\r\n return !isNullOrUndefined(theValue) ? theValue : defaultValue;\r\n }\r\n function _iterateChain(cb) {\r\n // Keep processing until we reach the end of the chain\r\n var nextPlugin;\r\n while (!!(nextPlugin = context._next())) {\r\n var plugin = nextPlugin.getPlugin();\r\n if (plugin) {\r\n // callback with the current on\r\n cb(plugin);\r\n }\r\n }\r\n }\r\n return context;\r\n}\r\n/**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n */\r\nexport function createProcessTelemetryContext(telemetryChain, config, core, startAt) {\r\n var internalContext = _createInternalContext(telemetryChain, config, core, startAt);\r\n var context = internalContext.ctx;\r\n function _processNext(env) {\r\n var nextPlugin = internalContext._next();\r\n // Run the next plugin which will call \"processNext()\"\r\n nextPlugin && nextPlugin.processTelemetry(env, context);\r\n return !nextPlugin;\r\n }\r\n function _createNew(plugins, startAt) {\r\n if (plugins === void 0) { plugins = null; }\r\n if (isArray(plugins)) {\r\n plugins = createTelemetryProxyChain(plugins, config, core, startAt);\r\n }\r\n return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);\r\n }\r\n context.processNext = _processNext;\r\n context.createNew = _createNew;\r\n return context;\r\n}\r\n/**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain for handling the unloading of the chain\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n */\r\nexport function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {\r\n var config = core.config || {};\r\n var internalContext = _createInternalContext(telemetryChain, config, core, startAt);\r\n var context = internalContext.ctx;\r\n function _processNext(unloadState) {\r\n var nextPlugin = internalContext._next();\r\n nextPlugin && nextPlugin.unload(context, unloadState);\r\n return !nextPlugin;\r\n }\r\n function _createNew(plugins, startAt) {\r\n if (plugins === void 0) { plugins = null; }\r\n if (isArray(plugins)) {\r\n plugins = createTelemetryProxyChain(plugins, config, core, startAt);\r\n }\r\n return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);\r\n }\r\n context.processNext = _processNext;\r\n context.createNew = _createNew;\r\n return context;\r\n}\r\n/**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain for updating the configuration\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n */\r\nexport function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {\r\n var config = core.config || {};\r\n var internalContext = _createInternalContext(telemetryChain, config, core, startAt);\r\n var context = internalContext.ctx;\r\n function _processNext(updateState) {\r\n return context.iterate(function (plugin) {\r\n if (isFunction(plugin.update)) {\r\n plugin.update(context, updateState);\r\n }\r\n });\r\n }\r\n function _createNew(plugins, startAt) {\r\n if (plugins === void 0) { plugins = null; }\r\n if (isArray(plugins)) {\r\n plugins = createTelemetryProxyChain(plugins, config, core, startAt);\r\n }\r\n return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);\r\n }\r\n context.processNext = _processNext;\r\n context.createNew = _createNew;\r\n return context;\r\n}\r\n/**\r\n * Creates an execution chain from the array of plugins\r\n * @param plugins - The array of plugins that will be executed in this order\r\n * @param defItemCtx - The default execution context to use when no telemetry context is passed to processTelemetry(), this\r\n * should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error\r\n * reporting (hasRun) when errors occur.\r\n */\r\nexport function createTelemetryProxyChain(plugins, config, core, startAt) {\r\n var firstProxy = null;\r\n var add = startAt ? false : true;\r\n if (isArray(plugins) && plugins.length > 0) {\r\n // Create the proxies and wire up the next plugin chain\r\n var lastProxy_1 = null;\r\n arrForEach(plugins, function (thePlugin) {\r\n if (!add && startAt === thePlugin) {\r\n add = true;\r\n }\r\n if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {\r\n // Only add plugins that are processors\r\n var newProxy = createTelemetryPluginProxy(thePlugin, config, core);\r\n if (!firstProxy) {\r\n firstProxy = newProxy;\r\n }\r\n if (lastProxy_1) {\r\n // Set this new proxy as the next for the previous one\r\n lastProxy_1._setNext(newProxy);\r\n }\r\n lastProxy_1 = newProxy;\r\n }\r\n });\r\n }\r\n if (startAt && !firstProxy) {\r\n // Special case where the \"startAt\" was not in the original list of plugins\r\n return createTelemetryProxyChain([startAt], config, core);\r\n }\r\n return firstProxy;\r\n}\r\n/**\r\n * Create the processing telemetry proxy instance, the proxy is used to abstract the current plugin to allow monitoring and\r\n * execution plugins while passing around the dynamic execution state (IProcessTelemetryContext), the proxy instance no longer\r\n * contains any execution state and can be reused between requests (this was not the case for 2.7.2 and earlier with the\r\n * TelemetryPluginChain class).\r\n * @param plugin - The plugin instance to proxy\r\n * @param config - The default execution context to use when no telemetry context is passed to processTelemetry(), this\r\n * should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error\r\n * reporting (hasRun) when errors occur.\r\n * @returns\r\n */\r\nexport function createTelemetryPluginProxy(plugin, config, core) {\r\n var nextProxy = null;\r\n var hasProcessTelemetry = isFunction(plugin.processTelemetry);\r\n var hasSetNext = isFunction(plugin.setNextPlugin);\r\n var chainId;\r\n if (plugin) {\r\n chainId = plugin.identifier + \"-\" + plugin.priority + \"-\" + _chainId++;\r\n }\r\n else {\r\n chainId = \"Unknown-0-\" + _chainId++;\r\n }\r\n var proxyChain = {\r\n getPlugin: function () {\r\n return plugin;\r\n },\r\n getNext: function () {\r\n return nextProxy;\r\n },\r\n processTelemetry: _processTelemetry,\r\n unload: _unloadPlugin,\r\n update: _updatePlugin,\r\n _id: chainId,\r\n _setNext: function (nextPlugin) {\r\n nextProxy = nextPlugin;\r\n }\r\n };\r\n function _getTelCtx() {\r\n var itemCtx;\r\n // Looks like a plugin didn't pass the (optional) context, so create a new one\r\n if (plugin && isFunction(plugin[strGetTelCtx])) {\r\n // This plugin extends from the BaseTelemetryPlugin so lets use it\r\n itemCtx = plugin[strGetTelCtx]();\r\n }\r\n if (!itemCtx) {\r\n // Create a temporary one\r\n itemCtx = createProcessTelemetryContext(proxyChain, config, core);\r\n }\r\n return itemCtx;\r\n }\r\n function _processChain(itemCtx, processPluginFn, name, details, isAsync) {\r\n var hasRun = false;\r\n var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;\r\n var hasRunContext = itemCtx[strHasRunFlags];\r\n if (!hasRunContext) {\r\n // Assign and populate\r\n hasRunContext = itemCtx[strHasRunFlags] = {};\r\n }\r\n // Ensure that we keep the context in sync\r\n itemCtx.setNext(nextProxy);\r\n if (plugin) {\r\n doPerf(itemCtx[strCore](), function () { return identifier + \":\" + name; }, function () {\r\n // Mark this component as having run\r\n hasRunContext[chainId] = true;\r\n try {\r\n // Set a flag on the next plugin so we know if it was attempted to be executed\r\n var nextId = nextProxy ? nextProxy._id : strEmpty;\r\n if (nextId) {\r\n hasRunContext[nextId] = false;\r\n }\r\n hasRun = processPluginFn(itemCtx);\r\n }\r\n catch (error) {\r\n var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;\r\n if (hasNextRun) {\r\n // The next plugin after us has already run so set this one as complete\r\n hasRun = true;\r\n }\r\n if (!nextProxy || !hasNextRun) {\r\n // Either we have no next plugin or the current one did not attempt to call the next plugin\r\n // Which means the current one is the root of the failure so log/report this failure\r\n _throwInternal(itemCtx.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 73 /* _eInternalMessageId.PluginException */, \"Plugin [\" + identifier + \"] failed during \" + name + \" - \" + dumpObj(error) + \", run flags: \" + dumpObj(hasRunContext));\r\n }\r\n }\r\n }, details, isAsync);\r\n }\r\n return hasRun;\r\n }\r\n function _processTelemetry(env, itemCtx) {\r\n itemCtx = itemCtx || _getTelCtx();\r\n function _callProcessTelemetry(itemCtx) {\r\n if (!plugin || !hasProcessTelemetry) {\r\n return false;\r\n }\r\n var pluginState = _getPluginState(plugin);\r\n if (pluginState.teardown || pluginState[strDisabled]) {\r\n return false;\r\n }\r\n // Ensure that we keep the context in sync (for processNext()), just in case a plugin\r\n // doesn't calls processTelemetry() instead of itemContext.processNext() or some\r\n // other form of error occurred\r\n if (hasSetNext) {\r\n // Backward compatibility setting the next plugin on the instance\r\n plugin.setNextPlugin(nextProxy);\r\n }\r\n plugin.processTelemetry(env, itemCtx);\r\n // Process Telemetry is expected to call itemCtx.processNext() or nextPlugin.processTelemetry()\r\n return true;\r\n }\r\n if (!_processChain(itemCtx, _callProcessTelemetry, \"processTelemetry\", function () { return ({ item: env }); }, !(env.sync))) {\r\n // The underlying plugin is either not defined, not enabled or does not have a processTelemetry implementation\r\n // so we still want the next plugin to be executed.\r\n itemCtx.processNext(env);\r\n }\r\n }\r\n function _unloadPlugin(unloadCtx, unloadState) {\r\n function _callTeardown() {\r\n // Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().\r\n var hasRun = false;\r\n if (plugin) {\r\n var pluginState = _getPluginState(plugin);\r\n var pluginCore = plugin[strCore] || pluginState.core;\r\n // Only teardown the plugin if it was initialized by the current core (i.e. It's not a shared plugin)\r\n if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {\r\n // Handle plugins that don't extend from the BaseTelemetryPlugin\r\n pluginState[strCore] = null;\r\n pluginState[strTeardown] = true;\r\n pluginState[strIsInitialized] = false;\r\n if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {\r\n // plugin told us that it was going to (or has) call unloadCtx.processNext()\r\n hasRun = true;\r\n }\r\n }\r\n }\r\n return hasRun;\r\n }\r\n if (!_processChain(unloadCtx, _callTeardown, \"unload\", function () { }, unloadState.isAsync)) {\r\n // Only called if we hasRun was not true\r\n unloadCtx.processNext(unloadState);\r\n }\r\n }\r\n function _updatePlugin(updateCtx, updateState) {\r\n function _callUpdate() {\r\n // Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().\r\n var hasRun = false;\r\n if (plugin) {\r\n var pluginState = _getPluginState(plugin);\r\n var pluginCore = plugin[strCore] || pluginState.core;\r\n // Only update the plugin if it was initialized by the current core (i.e. It's not a shared plugin)\r\n if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {\r\n if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {\r\n // plugin told us that it was going to (or has) call unloadCtx.processNext()\r\n hasRun = true;\r\n }\r\n }\r\n }\r\n return hasRun;\r\n }\r\n if (!_processChain(updateCtx, _callUpdate, \"update\", function () { }, false)) {\r\n // Only called if we hasRun was not true\r\n updateCtx.processNext(updateState);\r\n }\r\n }\r\n return objFreeze(proxyChain);\r\n}\r\n/**\r\n * This class will be removed!\r\n * @deprecated use createProcessTelemetryContext() instead\r\n */\r\nvar ProcessTelemetryContext = /** @class */ (function () {\r\n /**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n */\r\n function ProcessTelemetryContext(pluginChain, config, core, startAt) {\r\n var _self = this;\r\n var context = createProcessTelemetryContext(pluginChain, config, core, startAt);\r\n // Proxy all functions of the context to this object\r\n proxyFunctions(_self, context, objKeys(context));\r\n }\r\n return ProcessTelemetryContext;\r\n}());\r\nexport { ProcessTelemetryContext };\r\n//# sourceMappingURL=ProcessTelemetryContext.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"ProcessTelemetryContext.js.map","sources":["ProcessTelemetryContext.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { _DYN_CALL, _DYN_CONFIG, _DYN_CREATE_NEW, _DYN_DIAG_LOG, _DYN_GET_NEXT, _DYN_GET_PLUGIN, _DYN_IDENTIFIER, _DYN_IS_ASYNC, _DYN_IS_INITIALIZED, _DYN_LENGTH, _DYN_LOGGER, _DYN_PROCESS_NEXT, _DYN_PUSH, _DYN_SET_NEXT_PLUGIN, _DYN_TEARDOWN, _DYN_UPDATE } from \"../__DynamicConstants\";\r\nimport { _throwInternal, safeGetLogger } from \"./DiagnosticLogger\";\r\nimport { dumpObj } from \"./EnvUtils\";\r\nimport { arrForEach, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objExtend, objForEachKey, objFreeze, objKeys, proxyFunctions } from \"./HelperFuncs\";\r\nimport { STR_CORE, STR_DISABLED, STR_EMPTY, STR_EXTENSION_CONFIG, STR_PRIORITY, STR_PROCESS_TELEMETRY } from \"./InternalConstants\";\r\nimport { doPerf } from \"./PerfManager\";\r\nimport { _getPluginState } from \"./TelemetryHelpers\";\r\nvar strTelemetryPluginChain = \"TelemetryPluginChain\";\r\nvar strHasRunFlags = \"_hasRun\";\r\nvar strGetTelCtx = \"_getTelCtx\";\r\nvar _chainId = 0;\r\nfunction _getNextProxyStart(proxy, core, startAt) {\r\n while (proxy) {\r\n if (proxy[_DYN_GET_PLUGIN /* @min:%2egetPlugin */]() === startAt) {\r\n return proxy;\r\n }\r\n proxy = proxy[_DYN_GET_NEXT /* @min:%2egetNext */]();\r\n }\r\n // This wasn't found in the existing chain so create an isolated one with just this plugin\r\n return createTelemetryProxyChain([startAt], core[_DYN_CONFIG /* @min:%2econfig */] || {}, core);\r\n}\r\n/**\r\n * @ignore\r\n * @param telemetryChain\r\n * @param config\r\n * @param core\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n * @returns\r\n */\r\nfunction _createInternalContext(telemetryChain, config, core, startAt) {\r\n // We have a special case where we want to start execution from this specific plugin\r\n // or we simply reuse the existing telemetry plugin chain (normal execution case)\r\n var _nextProxy = null; // By Default set as no next plugin\r\n var _onComplete = [];\r\n if (startAt !== null) {\r\n // There is no next element (null) vs not defined (undefined) so use the full chain\r\n _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;\r\n }\r\n var context = {\r\n _next: _moveNext,\r\n ctx: {\r\n core: function () {\r\n return core;\r\n },\r\n diagLog: function () {\r\n return safeGetLogger(core, config);\r\n },\r\n getCfg: function () {\r\n return config;\r\n },\r\n getExtCfg: _getExtCfg,\r\n getConfig: _getConfig,\r\n hasNext: function () {\r\n return !!_nextProxy;\r\n },\r\n getNext: function () {\r\n return _nextProxy;\r\n },\r\n setNext: function (nextPlugin) {\r\n _nextProxy = nextPlugin;\r\n },\r\n iterate: _iterateChain,\r\n onComplete: _addOnComplete\r\n }\r\n };\r\n function _addOnComplete(onComplete, that) {\r\n var args = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n args[_i - 2] = arguments[_i];\r\n }\r\n if (onComplete) {\r\n _onComplete[_DYN_PUSH /* @min:%2epush */]({\r\n func: onComplete,\r\n self: !isUndefined(that) ? that : context.ctx,\r\n args: args\r\n });\r\n }\r\n }\r\n function _moveNext() {\r\n var nextProxy = _nextProxy;\r\n // Automatically move to the next plugin\r\n _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT /* @min:%2egetNext */]() : null;\r\n if (!nextProxy) {\r\n var onComplete = _onComplete;\r\n if (onComplete && onComplete[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(onComplete, function (completeDetails) {\r\n try {\r\n completeDetails.func[_DYN_CALL /* @min:%2ecall */](completeDetails.self, completeDetails.args);\r\n }\r\n catch (e) {\r\n _throwInternal(core[_DYN_LOGGER /* @min:%2elogger */], 2 /* eLoggingSeverity.WARNING */, 73 /* _eInternalMessageId.PluginException */, \"Unexpected Exception during onComplete - \" + dumpObj(e));\r\n }\r\n });\r\n _onComplete = [];\r\n }\r\n }\r\n return nextProxy;\r\n }\r\n function _getExtCfg(identifier, defaultValue, mergeDefault) {\r\n if (defaultValue === void 0) { defaultValue = {}; }\r\n if (mergeDefault === void 0) { mergeDefault = 0 /* GetExtCfgMergeType.None */; }\r\n var theConfig;\r\n if (config) {\r\n var extConfig = config[STR_EXTENSION_CONFIG /* @min:%2eextensionConfig */];\r\n if (extConfig && identifier) {\r\n theConfig = extConfig[identifier];\r\n }\r\n }\r\n if (!theConfig) {\r\n // Just use the defaults\r\n theConfig = defaultValue;\r\n }\r\n else if (isObject(defaultValue)) {\r\n if (mergeDefault !== 0 /* GetExtCfgMergeType.None */) {\r\n // Merge the defaults and configured values\r\n var newConfig_1 = objExtend(true, defaultValue, theConfig);\r\n if (config && mergeDefault === 2 /* GetExtCfgMergeType.MergeDefaultFromRootOrDefault */) {\r\n // Enumerate over the defaultValues and if not already populated attempt to\r\n // find a value from the root config\r\n objForEachKey(defaultValue, function (field) {\r\n // for each unspecified field, set the default value\r\n if (isNullOrUndefined(newConfig_1[field])) {\r\n var cfgValue = config[field];\r\n if (!isNullOrUndefined(cfgValue)) {\r\n newConfig_1[field] = cfgValue;\r\n }\r\n }\r\n });\r\n }\r\n theConfig = newConfig_1;\r\n }\r\n }\r\n return theConfig;\r\n }\r\n function _getConfig(identifier, field, defaultValue) {\r\n if (defaultValue === void 0) { defaultValue = false; }\r\n var theValue;\r\n var extConfig = _getExtCfg(identifier, null);\r\n if (extConfig && !isNullOrUndefined(extConfig[field])) {\r\n theValue = extConfig[field];\r\n }\r\n else if (config && !isNullOrUndefined(config[field])) {\r\n theValue = config[field];\r\n }\r\n return !isNullOrUndefined(theValue) ? theValue : defaultValue;\r\n }\r\n function _iterateChain(cb) {\r\n // Keep processing until we reach the end of the chain\r\n var nextPlugin;\r\n while (!!(nextPlugin = context._next())) {\r\n var plugin = nextPlugin[_DYN_GET_PLUGIN /* @min:%2egetPlugin */]();\r\n if (plugin) {\r\n // callback with the current on\r\n cb(plugin);\r\n }\r\n }\r\n }\r\n return context;\r\n}\r\n/**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n */\r\nexport function createProcessTelemetryContext(telemetryChain, config, core, startAt) {\r\n var internalContext = _createInternalContext(telemetryChain, config, core, startAt);\r\n var context = internalContext.ctx;\r\n function _processNext(env) {\r\n var nextPlugin = internalContext._next();\r\n // Run the next plugin which will call \"processNext()\"\r\n nextPlugin && nextPlugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */](env, context);\r\n return !nextPlugin;\r\n }\r\n function _createNew(plugins, startAt) {\r\n if (plugins === void 0) { plugins = null; }\r\n if (isArray(plugins)) {\r\n plugins = createTelemetryProxyChain(plugins, config, core, startAt);\r\n }\r\n return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT /* @min:%2egetNext */](), config, core, startAt);\r\n }\r\n context[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */] = _processNext;\r\n context[_DYN_CREATE_NEW /* @min:%2ecreateNew */] = _createNew;\r\n return context;\r\n}\r\n/**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain for handling the unloading of the chain\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n */\r\nexport function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {\r\n var config = core[_DYN_CONFIG /* @min:%2econfig */] || {};\r\n var internalContext = _createInternalContext(telemetryChain, config, core, startAt);\r\n var context = internalContext.ctx;\r\n function _processNext(unloadState) {\r\n var nextPlugin = internalContext._next();\r\n nextPlugin && nextPlugin.unload(context, unloadState);\r\n return !nextPlugin;\r\n }\r\n function _createNew(plugins, startAt) {\r\n if (plugins === void 0) { plugins = null; }\r\n if (isArray(plugins)) {\r\n plugins = createTelemetryProxyChain(plugins, config, core, startAt);\r\n }\r\n return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT /* @min:%2egetNext */](), core, startAt);\r\n }\r\n context[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */] = _processNext;\r\n context[_DYN_CREATE_NEW /* @min:%2ecreateNew */] = _createNew;\r\n return context;\r\n}\r\n/**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain for updating the configuration\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n * @param startAt - Identifies the next plugin to execute, if null there is no \"next\" plugin and if undefined it should assume the start of the chain\r\n */\r\nexport function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {\r\n var config = core[_DYN_CONFIG /* @min:%2econfig */] || {};\r\n var internalContext = _createInternalContext(telemetryChain, config, core, startAt);\r\n var context = internalContext.ctx;\r\n function _processNext(updateState) {\r\n return context.iterate(function (plugin) {\r\n if (isFunction(plugin[_DYN_UPDATE /* @min:%2eupdate */])) {\r\n plugin[_DYN_UPDATE /* @min:%2eupdate */](context, updateState);\r\n }\r\n });\r\n }\r\n function _createNew(plugins, startAt) {\r\n if (plugins === void 0) { plugins = null; }\r\n if (isArray(plugins)) {\r\n plugins = createTelemetryProxyChain(plugins, config, core, startAt);\r\n }\r\n return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT /* @min:%2egetNext */](), core, startAt);\r\n }\r\n context[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */] = _processNext;\r\n context[_DYN_CREATE_NEW /* @min:%2ecreateNew */] = _createNew;\r\n return context;\r\n}\r\n/**\r\n * Creates an execution chain from the array of plugins\r\n * @param plugins - The array of plugins that will be executed in this order\r\n * @param defItemCtx - The default execution context to use when no telemetry context is passed to processTelemetry(), this\r\n * should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error\r\n * reporting (hasRun) when errors occur.\r\n */\r\nexport function createTelemetryProxyChain(plugins, config, core, startAt) {\r\n var firstProxy = null;\r\n var add = startAt ? false : true;\r\n if (isArray(plugins) && plugins[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n // Create the proxies and wire up the next plugin chain\r\n var lastProxy_1 = null;\r\n arrForEach(plugins, function (thePlugin) {\r\n if (!add && startAt === thePlugin) {\r\n add = true;\r\n }\r\n if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */])) {\r\n // Only add plugins that are processors\r\n var newProxy = createTelemetryPluginProxy(thePlugin, config, core);\r\n if (!firstProxy) {\r\n firstProxy = newProxy;\r\n }\r\n if (lastProxy_1) {\r\n // Set this new proxy as the next for the previous one\r\n lastProxy_1._setNext(newProxy);\r\n }\r\n lastProxy_1 = newProxy;\r\n }\r\n });\r\n }\r\n if (startAt && !firstProxy) {\r\n // Special case where the \"startAt\" was not in the original list of plugins\r\n return createTelemetryProxyChain([startAt], config, core);\r\n }\r\n return firstProxy;\r\n}\r\n/**\r\n * Create the processing telemetry proxy instance, the proxy is used to abstract the current plugin to allow monitoring and\r\n * execution plugins while passing around the dynamic execution state (IProcessTelemetryContext), the proxy instance no longer\r\n * contains any execution state and can be reused between requests (this was not the case for 2.7.2 and earlier with the\r\n * TelemetryPluginChain class).\r\n * @param plugin - The plugin instance to proxy\r\n * @param config - The default execution context to use when no telemetry context is passed to processTelemetry(), this\r\n * should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error\r\n * reporting (hasRun) when errors occur.\r\n * @returns\r\n */\r\nexport function createTelemetryPluginProxy(plugin, config, core) {\r\n var nextProxy = null;\r\n var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */]);\r\n var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN /* @min:%2esetNextPlugin */]);\r\n var chainId;\r\n if (plugin) {\r\n chainId = plugin[_DYN_IDENTIFIER /* @min:%2eidentifier */] + \"-\" + plugin[STR_PRIORITY /* @min:%2epriority */] + \"-\" + _chainId++;\r\n }\r\n else {\r\n chainId = \"Unknown-0-\" + _chainId++;\r\n }\r\n var proxyChain = {\r\n getPlugin: function () {\r\n return plugin;\r\n },\r\n getNext: function () {\r\n return nextProxy;\r\n },\r\n processTelemetry: _processTelemetry,\r\n unload: _unloadPlugin,\r\n update: _updatePlugin,\r\n _id: chainId,\r\n _setNext: function (nextPlugin) {\r\n nextProxy = nextPlugin;\r\n }\r\n };\r\n function _getTelCtx() {\r\n var itemCtx;\r\n // Looks like a plugin didn't pass the (optional) context, so create a new one\r\n if (plugin && isFunction(plugin[strGetTelCtx])) {\r\n // This plugin extends from the BaseTelemetryPlugin so lets use it\r\n itemCtx = plugin[strGetTelCtx]();\r\n }\r\n if (!itemCtx) {\r\n // Create a temporary one\r\n itemCtx = createProcessTelemetryContext(proxyChain, config, core);\r\n }\r\n return itemCtx;\r\n }\r\n function _processChain(itemCtx, processPluginFn, name, details, isAsync) {\r\n var hasRun = false;\r\n var identifier = plugin ? plugin[_DYN_IDENTIFIER /* @min:%2eidentifier */] : strTelemetryPluginChain;\r\n var hasRunContext = itemCtx[strHasRunFlags];\r\n if (!hasRunContext) {\r\n // Assign and populate\r\n hasRunContext = itemCtx[strHasRunFlags] = {};\r\n }\r\n // Ensure that we keep the context in sync\r\n itemCtx.setNext(nextProxy);\r\n if (plugin) {\r\n doPerf(itemCtx[STR_CORE /* @min:%2ecore */](), function () { return identifier + \":\" + name; }, function () {\r\n // Mark this component as having run\r\n hasRunContext[chainId] = true;\r\n try {\r\n // Set a flag on the next plugin so we know if it was attempted to be executed\r\n var nextId = nextProxy ? nextProxy._id : STR_EMPTY;\r\n if (nextId) {\r\n hasRunContext[nextId] = false;\r\n }\r\n hasRun = processPluginFn(itemCtx);\r\n }\r\n catch (error) {\r\n var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;\r\n if (hasNextRun) {\r\n // The next plugin after us has already run so set this one as complete\r\n hasRun = true;\r\n }\r\n if (!nextProxy || !hasNextRun) {\r\n // Either we have no next plugin or the current one did not attempt to call the next plugin\r\n // Which means the current one is the root of the failure so log/report this failure\r\n _throwInternal(itemCtx[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 73 /* _eInternalMessageId.PluginException */, \"Plugin [\" + identifier + \"] failed during \" + name + \" - \" + dumpObj(error) + \", run flags: \" + dumpObj(hasRunContext));\r\n }\r\n }\r\n }, details, isAsync);\r\n }\r\n return hasRun;\r\n }\r\n function _processTelemetry(env, itemCtx) {\r\n itemCtx = itemCtx || _getTelCtx();\r\n function _callProcessTelemetry(itemCtx) {\r\n if (!plugin || !hasProcessTelemetry) {\r\n return false;\r\n }\r\n var pluginState = _getPluginState(plugin);\r\n if (pluginState[_DYN_TEARDOWN /* @min:%2eteardown */] || pluginState[STR_DISABLED]) {\r\n return false;\r\n }\r\n // Ensure that we keep the context in sync (for processNext()), just in case a plugin\r\n // doesn't calls processTelemetry() instead of itemContext.processNext() or some\r\n // other form of error occurred\r\n if (hasSetNext) {\r\n // Backward compatibility setting the next plugin on the instance\r\n plugin[_DYN_SET_NEXT_PLUGIN /* @min:%2esetNextPlugin */](nextProxy);\r\n }\r\n plugin[STR_PROCESS_TELEMETRY /* @min:%2eprocessTelemetry */](env, itemCtx);\r\n // Process Telemetry is expected to call itemCtx.processNext() or nextPlugin.processTelemetry()\r\n return true;\r\n }\r\n if (!_processChain(itemCtx, _callProcessTelemetry, \"processTelemetry\", function () { return ({ item: env }); }, !(env.sync))) {\r\n // The underlying plugin is either not defined, not enabled or does not have a processTelemetry implementation\r\n // so we still want the next plugin to be executed.\r\n itemCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](env);\r\n }\r\n }\r\n function _unloadPlugin(unloadCtx, unloadState) {\r\n function _callTeardown() {\r\n // Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().\r\n var hasRun = false;\r\n if (plugin) {\r\n var pluginState = _getPluginState(plugin);\r\n var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE /* @min:%2ecore */];\r\n // Only teardown the plugin if it was initialized by the current core (i.e. It's not a shared plugin)\r\n if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN /* @min:%2eteardown */]) {\r\n // Handle plugins that don't extend from the BaseTelemetryPlugin\r\n pluginState[STR_CORE /* @min:%2ecore */] = null;\r\n pluginState[_DYN_TEARDOWN /* @min:%2eteardown */] = true;\r\n pluginState[_DYN_IS_INITIALIZED /* @min:%2eisInitialized */] = false;\r\n if (plugin[_DYN_TEARDOWN /* @min:%2eteardown */] && plugin[_DYN_TEARDOWN /* @min:%2eteardown */](unloadCtx, unloadState) === true) {\r\n // plugin told us that it was going to (or has) call unloadCtx.processNext()\r\n hasRun = true;\r\n }\r\n }\r\n }\r\n return hasRun;\r\n }\r\n if (!_processChain(unloadCtx, _callTeardown, \"unload\", function () { }, unloadState[_DYN_IS_ASYNC /* @min:%2eisAsync */])) {\r\n // Only called if we hasRun was not true\r\n unloadCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](unloadState);\r\n }\r\n }\r\n function _updatePlugin(updateCtx, updateState) {\r\n function _callUpdate() {\r\n // Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().\r\n var hasRun = false;\r\n if (plugin) {\r\n var pluginState = _getPluginState(plugin);\r\n var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE /* @min:%2ecore */];\r\n // Only update the plugin if it was initialized by the current core (i.e. It's not a shared plugin)\r\n if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN /* @min:%2eteardown */]) {\r\n if (plugin[_DYN_UPDATE /* @min:%2eupdate */] && plugin[_DYN_UPDATE /* @min:%2eupdate */](updateCtx, updateState) === true) {\r\n // plugin told us that it was going to (or has) call unloadCtx.processNext()\r\n hasRun = true;\r\n }\r\n }\r\n }\r\n return hasRun;\r\n }\r\n if (!_processChain(updateCtx, _callUpdate, \"update\", function () { }, false)) {\r\n // Only called if we hasRun was not true\r\n updateCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](updateState);\r\n }\r\n }\r\n return objFreeze(proxyChain);\r\n}\r\n/**\r\n * This class will be removed!\r\n * @deprecated use createProcessTelemetryContext() instead\r\n */\r\nvar ProcessTelemetryContext = /** @class */ (function () {\r\n /**\r\n * Creates a new Telemetry Item context with the current config, core and plugin execution chain\r\n * @param plugins - The plugin instances that will be executed\r\n * @param config - The current config\r\n * @param core - The current core instance\r\n */\r\n function ProcessTelemetryContext(pluginChain, config, core, startAt) {\r\n var _self = this;\r\n var context = createProcessTelemetryContext(pluginChain, config, core, startAt);\r\n // Proxy all functions of the context to this object\r\n proxyFunctions(_self, context, objKeys(context));\r\n }\r\n return ProcessTelemetryContext;\r\n}());\r\nexport { ProcessTelemetryContext };\r\n//# sourceMappingURL=ProcessTelemetryContext.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,12 +1,13 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2206-03
2
+ * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2207-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
+ import { _DYN_LENGTH } from "../__DynamicConstants";
7
8
  import { getCrypto, getMsCrypto, isIE } from "./EnvUtils";
8
9
  import { dateNow } from "./HelperFuncs";
9
- import { strEmpty } from "./InternalConstants";
10
+ import { STR_EMPTY } from "./InternalConstants";
10
11
  var UInt32Mask = 0x100000000;
11
12
  var MaxUInt32 = 0xffffffff;
12
13
  // MWC based Random generator (for IE)
@@ -115,8 +116,8 @@ export function newId(maxLength) {
115
116
  // Start with an initial random number, consuming the value in reverse byte order
116
117
  var number = random32() >>> 0; // Make sure it's a +ve number
117
118
  var chars = 0;
118
- var result = strEmpty;
119
- while (result.length < maxLength) {
119
+ var result = STR_EMPTY;
120
+ while (result[_DYN_LENGTH /* @min:%2elength */] < maxLength) {
120
121
  chars++;
121
122
  result += base64chars.charAt(number & 0x3F);
122
123
  number >>>= 6; // Zero fill with right shift
@@ -1 +1 @@
1
- {"version":3,"file":"RandomHelper.js.map","sources":["RandomHelper.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { getCrypto, getMsCrypto, isIE } from \"./EnvUtils\";\r\nimport { dateNow } from \"./HelperFuncs\";\r\nimport { strEmpty } from \"./InternalConstants\";\r\nvar UInt32Mask = 0x100000000;\r\nvar MaxUInt32 = 0xffffffff;\r\n// MWC based Random generator (for IE)\r\nvar _mwcSeeded = false;\r\nvar _mwcW = 123456789;\r\nvar _mwcZ = 987654321;\r\n// Takes any integer\r\nfunction _mwcSeed(seedValue) {\r\n if (seedValue < 0) {\r\n // Make sure we end up with a positive number and not -ve one.\r\n seedValue >>>= 0;\r\n }\r\n _mwcW = (123456789 + seedValue) & MaxUInt32;\r\n _mwcZ = (987654321 - seedValue) & MaxUInt32;\r\n _mwcSeeded = true;\r\n}\r\nfunction _autoSeedMwc() {\r\n // Simple initialization using default Math.random() - So we inherit any entropy from the browser\r\n // and bitwise XOR with the current milliseconds\r\n try {\r\n var now = dateNow() & 0x7fffffff;\r\n _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);\r\n }\r\n catch (e) {\r\n // Don't crash if something goes wrong\r\n }\r\n}\r\n/**\r\n * Generate a random value between 0 and maxValue, max value should be limited to a 32-bit maximum.\r\n * So maxValue(16) will produce a number from 0..16 (range of 17)\r\n * @param maxValue\r\n */\r\nexport function randomValue(maxValue) {\r\n if (maxValue > 0) {\r\n return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;\r\n }\r\n return 0;\r\n}\r\n/**\r\n * generate a random 32-bit number (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), defaults un-unsigned.\r\n * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)\r\n */\r\nexport function random32(signed) {\r\n var value = 0;\r\n var c = getCrypto() || getMsCrypto();\r\n if (c && c.getRandomValues) {\r\n // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF)\r\n value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;\r\n }\r\n if (value === 0 && isIE()) {\r\n // For IE 6, 7, 8 (especially on XP) Math.random is not very random\r\n if (!_mwcSeeded) {\r\n // Set the seed for the Mwc algorithm\r\n _autoSeedMwc();\r\n }\r\n // Don't use Math.random for IE\r\n // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF)\r\n value = mwcRandom32() & MaxUInt32;\r\n }\r\n if (value === 0) {\r\n // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF)\r\n value = Math.floor((UInt32Mask * Math.random()) | 0);\r\n }\r\n if (!signed) {\r\n // Make sure we end up with a positive number and not -ve one.\r\n value >>>= 0;\r\n }\r\n return value;\r\n}\r\n/**\r\n * Seed the MWC random number generator with the specified seed or a random value\r\n * @param value - optional the number to used as the seed, if undefined, null or zero a random value will be chosen\r\n */\r\nexport function mwcRandomSeed(value) {\r\n if (!value) {\r\n _autoSeedMwc();\r\n }\r\n else {\r\n _mwcSeed(value);\r\n }\r\n}\r\n/**\r\n * Generate a random 32-bit number between (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), using MWC (Multiply with carry)\r\n * instead of Math.random() defaults to un-signed.\r\n * Used as a replacement random generator for IE to avoid issues with older IE instances.\r\n * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)\r\n */\r\nexport function mwcRandom32(signed) {\r\n _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;\r\n _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;\r\n var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;\r\n if (!signed) {\r\n // Make sure we end up with a positive number and not -ve one.\r\n value >>>= 0;\r\n }\r\n return value;\r\n}\r\n/**\r\n * Generate random base64 id string.\r\n * The default length is 22 which is 132-bits so almost the same as a GUID but as base64 (the previous default was 5)\r\n * @param maxLength - Optional value to specify the length of the id to be generated, defaults to 22\r\n */\r\nexport function newId(maxLength) {\r\n if (maxLength === void 0) { maxLength = 22; }\r\n var base64chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\r\n // Start with an initial random number, consuming the value in reverse byte order\r\n var number = random32() >>> 0; // Make sure it's a +ve number\r\n var chars = 0;\r\n var result = strEmpty;\r\n while (result.length < maxLength) {\r\n chars++;\r\n result += base64chars.charAt(number & 0x3F);\r\n number >>>= 6; // Zero fill with right shift\r\n if (chars === 5) {\r\n // 5 base64 characters === 30 bits so we don't have enough bits for another base64 char\r\n // So add on another 30 bits and make sure it's +ve\r\n number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;\r\n chars = 0; // We need to reset the number every 5 chars (30 bits)\r\n }\r\n }\r\n return result;\r\n}\r\n//# sourceMappingURL=RandomHelper.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"RandomHelper.js.map","sources":["RandomHelper.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { _DYN_LENGTH } from \"../__DynamicConstants\";\r\nimport { getCrypto, getMsCrypto, isIE } from \"./EnvUtils\";\r\nimport { dateNow } from \"./HelperFuncs\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nvar UInt32Mask = 0x100000000;\r\nvar MaxUInt32 = 0xffffffff;\r\n// MWC based Random generator (for IE)\r\nvar _mwcSeeded = false;\r\nvar _mwcW = 123456789;\r\nvar _mwcZ = 987654321;\r\n// Takes any integer\r\nfunction _mwcSeed(seedValue) {\r\n if (seedValue < 0) {\r\n // Make sure we end up with a positive number and not -ve one.\r\n seedValue >>>= 0;\r\n }\r\n _mwcW = (123456789 + seedValue) & MaxUInt32;\r\n _mwcZ = (987654321 - seedValue) & MaxUInt32;\r\n _mwcSeeded = true;\r\n}\r\nfunction _autoSeedMwc() {\r\n // Simple initialization using default Math.random() - So we inherit any entropy from the browser\r\n // and bitwise XOR with the current milliseconds\r\n try {\r\n var now = dateNow() & 0x7fffffff;\r\n _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);\r\n }\r\n catch (e) {\r\n // Don't crash if something goes wrong\r\n }\r\n}\r\n/**\r\n * Generate a random value between 0 and maxValue, max value should be limited to a 32-bit maximum.\r\n * So maxValue(16) will produce a number from 0..16 (range of 17)\r\n * @param maxValue\r\n */\r\nexport function randomValue(maxValue) {\r\n if (maxValue > 0) {\r\n return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;\r\n }\r\n return 0;\r\n}\r\n/**\r\n * generate a random 32-bit number (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), defaults un-unsigned.\r\n * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)\r\n */\r\nexport function random32(signed) {\r\n var value = 0;\r\n var c = getCrypto() || getMsCrypto();\r\n if (c && c.getRandomValues) {\r\n // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF)\r\n value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;\r\n }\r\n if (value === 0 && isIE()) {\r\n // For IE 6, 7, 8 (especially on XP) Math.random is not very random\r\n if (!_mwcSeeded) {\r\n // Set the seed for the Mwc algorithm\r\n _autoSeedMwc();\r\n }\r\n // Don't use Math.random for IE\r\n // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF)\r\n value = mwcRandom32() & MaxUInt32;\r\n }\r\n if (value === 0) {\r\n // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF)\r\n value = Math.floor((UInt32Mask * Math.random()) | 0);\r\n }\r\n if (!signed) {\r\n // Make sure we end up with a positive number and not -ve one.\r\n value >>>= 0;\r\n }\r\n return value;\r\n}\r\n/**\r\n * Seed the MWC random number generator with the specified seed or a random value\r\n * @param value - optional the number to used as the seed, if undefined, null or zero a random value will be chosen\r\n */\r\nexport function mwcRandomSeed(value) {\r\n if (!value) {\r\n _autoSeedMwc();\r\n }\r\n else {\r\n _mwcSeed(value);\r\n }\r\n}\r\n/**\r\n * Generate a random 32-bit number between (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), using MWC (Multiply with carry)\r\n * instead of Math.random() defaults to un-signed.\r\n * Used as a replacement random generator for IE to avoid issues with older IE instances.\r\n * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)\r\n */\r\nexport function mwcRandom32(signed) {\r\n _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;\r\n _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;\r\n var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;\r\n if (!signed) {\r\n // Make sure we end up with a positive number and not -ve one.\r\n value >>>= 0;\r\n }\r\n return value;\r\n}\r\n/**\r\n * Generate random base64 id string.\r\n * The default length is 22 which is 132-bits so almost the same as a GUID but as base64 (the previous default was 5)\r\n * @param maxLength - Optional value to specify the length of the id to be generated, defaults to 22\r\n */\r\nexport function newId(maxLength) {\r\n if (maxLength === void 0) { maxLength = 22; }\r\n var base64chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\r\n // Start with an initial random number, consuming the value in reverse byte order\r\n var number = random32() >>> 0; // Make sure it's a +ve number\r\n var chars = 0;\r\n var result = STR_EMPTY;\r\n while (result[_DYN_LENGTH /* @min:%2elength */] < maxLength) {\r\n chars++;\r\n result += base64chars.charAt(number & 0x3F);\r\n number >>>= 6; // Zero fill with right shift\r\n if (chars === 5) {\r\n // 5 base64 characters === 30 bits so we don't have enough bits for another base64 char\r\n // So add on another 30 bits and make sure it's +ve\r\n number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;\r\n chars = 0; // We need to reset the number every 5 chars (30 bits)\r\n }\r\n }\r\n return result;\r\n}\r\n//# sourceMappingURL=RandomHelper.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}