@microsoft/1ds-core-js 3.2.1 → 3.2.4

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 (68) hide show
  1. package/README.md +1 -1
  2. package/bundle/{ms.core-3.2.1.gbl.js → ms.core-3.2.4.gbl.js} +1745 -1435
  3. package/bundle/ms.core-3.2.4.gbl.js.map +1 -0
  4. package/bundle/ms.core-3.2.4.gbl.min.js +7 -0
  5. package/bundle/ms.core-3.2.4.gbl.min.js.map +1 -0
  6. package/bundle/ms.core-3.2.4.integrity.json +46 -0
  7. package/bundle/{ms.core-3.2.1.js → ms.core-3.2.4.js} +1745 -1435
  8. package/bundle/ms.core-3.2.4.js.map +1 -0
  9. package/bundle/ms.core-3.2.4.min.js +7 -0
  10. package/bundle/ms.core-3.2.4.min.js.map +1 -0
  11. package/bundle/ms.core.gbl.js +1744 -1434
  12. package/bundle/ms.core.gbl.js.map +1 -1
  13. package/bundle/ms.core.gbl.min.js +2 -2
  14. package/bundle/ms.core.gbl.min.js.map +1 -1
  15. package/bundle/ms.core.integrity.json +17 -17
  16. package/bundle/ms.core.js +1744 -1434
  17. package/bundle/ms.core.js.map +1 -1
  18. package/bundle/ms.core.min.js +2 -2
  19. package/bundle/ms.core.min.js.map +1 -1
  20. package/dist/ms.core.js +42 -33
  21. package/dist/ms.core.js.map +1 -1
  22. package/dist/ms.core.min.js +2 -2
  23. package/dist/ms.core.min.js.map +1 -1
  24. package/dist-esm/src/AppInsightsCore.d.ts +2 -7
  25. package/dist-esm/src/AppInsightsCore.js +26 -28
  26. package/dist-esm/src/AppInsightsCore.js.map +1 -1
  27. package/dist-esm/src/BaseCore.d.ts +2 -2
  28. package/dist-esm/src/BaseCore.js +17 -11
  29. package/dist-esm/src/BaseCore.js.map +1 -1
  30. package/dist-esm/src/DataModels.js +1 -1
  31. package/dist-esm/src/ESPromise.d.ts +5 -5
  32. package/dist-esm/src/ESPromise.js +15 -15
  33. package/dist-esm/src/ESPromise.js.map +1 -1
  34. package/dist-esm/src/ESPromiseScheduler.d.ts +4 -4
  35. package/dist-esm/src/ESPromiseScheduler.js +8 -8
  36. package/dist-esm/src/ESPromiseScheduler.js.map +1 -1
  37. package/dist-esm/src/Enums.d.ts +6 -5
  38. package/dist-esm/src/Enums.js +61 -61
  39. package/dist-esm/src/Enums.js.map +1 -1
  40. package/dist-esm/src/Index.d.ts +1 -2
  41. package/dist-esm/src/Index.js +3 -3
  42. package/dist-esm/src/Index.js.map +1 -1
  43. package/dist-esm/src/InternalConstants.d.ts +6 -0
  44. package/dist-esm/src/InternalConstants.js +19 -0
  45. package/dist-esm/src/InternalConstants.js.map +1 -0
  46. package/dist-esm/src/Utils.d.ts +9 -3
  47. package/dist-esm/src/Utils.js +40 -39
  48. package/dist-esm/src/Utils.js.map +1 -1
  49. package/dist-esm/src/ValueSanitizer.d.ts +1 -1
  50. package/dist-esm/src/ValueSanitizer.js +19 -18
  51. package/dist-esm/src/ValueSanitizer.js.map +1 -1
  52. package/package.json +5 -4
  53. package/src/AppInsightsCore.ts +28 -30
  54. package/src/BaseCore.ts +13 -10
  55. package/src/ESPromise.ts +6 -6
  56. package/src/ESPromiseScheduler.ts +8 -8
  57. package/src/Enums.ts +5 -5
  58. package/src/Index.ts +3 -3
  59. package/src/InternalConstants.ts +16 -0
  60. package/src/Utils.ts +24 -24
  61. package/src/ValueSanitizer.ts +5 -4
  62. package/bundle/ms.core-3.2.1.gbl.js.map +0 -1
  63. package/bundle/ms.core-3.2.1.gbl.min.js +0 -7
  64. package/bundle/ms.core-3.2.1.gbl.min.js.map +0 -1
  65. package/bundle/ms.core-3.2.1.integrity.json +0 -46
  66. package/bundle/ms.core-3.2.1.js.map +0 -1
  67. package/bundle/ms.core-3.2.1.min.js +0 -7
  68. package/bundle/ms.core-3.2.1.min.js.map +0 -1
@@ -1,42 +1,41 @@
1
1
  /*
2
- * 1DS JS SDK Core, 3.2.1
2
+ * 1DS JS SDK Core, 3.2.4
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
7
7
  /**
8
- * AppInsightsCore.ts
9
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
10
- * @copyright Microsoft 2018
11
- */
12
- import { AppInsightsCore as InternalCore, doPerf, arrForEach, dumpObj, DiagnosticLogger } from "@microsoft/applicationinsights-core-js";
13
- import { isLatency, FullVersionString, getTime } from "./Utils";
8
+ * AppInsightsCore.ts
9
+ * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
10
+ * @copyright Microsoft 2018
11
+ */
14
12
  import dynamicProto from "@microsoft/dynamicproto-js";
15
- var PropVersion = "version";
16
- var properties = "properties";
13
+ import { AppInsightsCore as InternalCore, DiagnosticLogger, _throwInternal, arrForEach, doPerf, dumpObj, throwError } from "@microsoft/applicationinsights-core-js";
14
+ import { STR_DEFAULT_ENDPOINT_URL, STR_EMPTY, STR_PROPERTIES, STR_VERSION } from "./InternalConstants";
15
+ import { FullVersionString, getTime, isLatency } from "./Utils";
17
16
  var AppInsightsCore = /** @class */ (function (_super) {
18
17
  __extends(AppInsightsCore, _super);
19
18
  function AppInsightsCore() {
20
19
  var _this = _super.call(this) || this;
21
20
  _this.pluginVersionStringArr = [];
22
- _this.pluginVersionString = "";
23
21
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
24
22
  if (!_self.logger || !_self.logger.queue) {
25
23
  // The AI Base can inject a No-Op logger so if not defined or the No-Op, change to use a default logger so initialization errors
26
24
  // are not dropped on the floor if one is not already defined
27
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 /* CRITICAL */ });
25
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 /* eLoggingSeverity.CRITICAL */ });
28
26
  }
29
27
  _self.initialize = function (config, extensions, logger, notificationManager) {
30
28
  doPerf(_self, function () { return "AppInsightsCore.initialize"; }, function () {
29
+ var _pluginVersionStringArr = _self.pluginVersionStringArr;
31
30
  // Add default collector url
32
31
  if (config) {
33
32
  if (!config.endpointUrl) {
34
- config.endpointUrl = "https://browser.events.data.microsoft.com/OneCollector/1.0/";
33
+ config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;
35
34
  }
36
35
  var propertyStorageOverride = config.propertyStorageOverride;
37
36
  // Validate property storage override
38
37
  if (propertyStorageOverride && (!propertyStorageOverride.getProperty || !propertyStorageOverride.setProperty)) {
39
- throw new Error("Invalid property storage override passed.");
38
+ throwError("Invalid property storage override passed.");
40
39
  }
41
40
  if (config.channels) {
42
41
  arrForEach(config.channels, function (channels) {
@@ -44,7 +43,7 @@ var AppInsightsCore = /** @class */ (function (_super) {
44
43
  arrForEach(channels, function (channel) {
45
44
  if (channel.identifier && channel.version) {
46
45
  var ver = channel.identifier + "=" + channel.version;
47
- _self.pluginVersionStringArr.push(ver);
46
+ _pluginVersionStringArr.push(ver);
48
47
  }
49
48
  });
50
49
  }
@@ -58,11 +57,12 @@ var AppInsightsCore = /** @class */ (function (_super) {
58
57
  arrForEach(extensions, function (ext) {
59
58
  if (ext && ext.identifier && ext.version) {
60
59
  var ver = ext.identifier + "=" + ext.version;
61
- _self.pluginVersionStringArr.push(ver);
60
+ _pluginVersionStringArr.push(ver);
62
61
  }
63
62
  });
64
63
  }
65
- _self.pluginVersionString = _self.pluginVersionStringArr.join(";");
64
+ _self.pluginVersionString = _pluginVersionStringArr.join(";");
65
+ _self.pluginVersionStringArr = _pluginVersionStringArr;
66
66
  try {
67
67
  _base.initialize(config, extensions, logger, notificationManager);
68
68
  _self.pollInternalLogs("InternalLog");
@@ -74,7 +74,7 @@ var AppInsightsCore = /** @class */ (function (_super) {
74
74
  // Add some additional context to the underlying reported error
75
75
  message += "\n - Channels must be provided through config.channels only!";
76
76
  }
77
- logger_1.throwInternal(1 /* CRITICAL */, 514 /* FailedToInitializeSDK */, "SDK Initialization Failed - no telemetry will be sent: " + message);
77
+ _throwInternal(logger_1, 1 /* eLoggingSeverity.CRITICAL */, 514 /* _eExtendedInternalMessageId.FailedToInitializeSDK */, "SDK Initialization Failed - no telemetry will be sent: " + message);
78
78
  }
79
79
  }, function () { return ({ config: config, extensions: extensions, logger: logger, notificationManager: notificationManager }); });
80
80
  };
@@ -85,22 +85,15 @@ var AppInsightsCore = /** @class */ (function (_super) {
85
85
  telemetryItem.timings = telemetryItem.timings || {};
86
86
  telemetryItem.timings.trackStart = getTime();
87
87
  if (!isLatency(telemetryItem.latency)) {
88
- telemetryItem.latency = 1 /* Normal */;
88
+ telemetryItem.latency = 1 /* EventLatencyValue.Normal */;
89
89
  }
90
90
  var itemExt = telemetryItem.ext = telemetryItem.ext || {};
91
91
  itemExt.sdk = itemExt.sdk || {};
92
92
  itemExt.sdk.ver = FullVersionString;
93
93
  var baseData = telemetryItem.baseData = telemetryItem.baseData || {};
94
- if (!baseData[properties]) {
95
- baseData[properties] = {};
96
- }
97
- var itemProperties = baseData[properties];
98
- if (!itemProperties[PropVersion]) {
99
- itemProperties[PropVersion] = "";
100
- }
101
- if (_self.pluginVersionString !== "") {
102
- itemProperties[PropVersion] = _self.pluginVersionString;
103
- }
94
+ baseData[STR_PROPERTIES] = baseData[STR_PROPERTIES] || {};
95
+ var itemProperties = baseData[STR_PROPERTIES];
96
+ itemProperties[STR_VERSION] = _self.pluginVersionString || itemProperties[STR_VERSION] || STR_EMPTY;
104
97
  }
105
98
  _base.track(telemetryItem);
106
99
  }, function () { return ({ item: item }); }, !(item.sync));
@@ -110,6 +103,11 @@ var AppInsightsCore = /** @class */ (function (_super) {
110
103
  }
111
104
  // Removed Stub for AppInsightsCore.prototype.initialize.
112
105
  // Removed Stub for AppInsightsCore.prototype.track.
106
+ // This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
107
+ // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
108
+ // this will be removed when ES3 support is dropped.
109
+ AppInsightsCore.__ieDyn=1;
110
+
113
111
  return AppInsightsCore;
114
112
  }(InternalCore));
115
113
  export default AppInsightsCore;
@@ -1 +1 @@
1
- {"version":3,"file":"AppInsightsCore.js.map","sources":["AppInsightsCore.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\n/**\r\n * AppInsightsCore.ts\r\n * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n * @copyright Microsoft 2018\r\n */\r\nimport { AppInsightsCore as InternalCore, doPerf, arrForEach, dumpObj, DiagnosticLogger } from \"@microsoft/applicationinsights-core-js\";\r\nimport { isLatency, FullVersionString, getTime } from \"./Utils\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nvar PropVersion = \"version\";\r\nvar properties = \"properties\";\r\nvar AppInsightsCore = /** @class */ (function (_super) {\r\n __extends(AppInsightsCore, _super);\r\n function AppInsightsCore() {\r\n var _this = _super.call(this) || this;\r\n _this.pluginVersionStringArr = [];\r\n _this.pluginVersionString = \"\";\r\n dynamicProto(AppInsightsCore, _this, function (_self, _base) {\r\n if (!_self.logger || !_self.logger.queue) {\r\n // The AI Base can inject a No-Op logger so if not defined or the No-Op, change to use a default logger so initialization errors\r\n // are not dropped on the floor if one is not already defined\r\n _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 /* CRITICAL */ });\r\n }\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n doPerf(_self, function () { return \"AppInsightsCore.initialize\"; }, function () {\r\n // Add default collector url\r\n if (config) {\r\n if (!config.endpointUrl) {\r\n config.endpointUrl = \"https://browser.events.data.microsoft.com/OneCollector/1.0/\";\r\n }\r\n var propertyStorageOverride = config.propertyStorageOverride;\r\n // Validate property storage override\r\n if (propertyStorageOverride && (!propertyStorageOverride.getProperty || !propertyStorageOverride.setProperty)) {\r\n throw new Error(\"Invalid property storage override passed.\");\r\n }\r\n if (config.channels) {\r\n arrForEach(config.channels, function (channels) {\r\n if (channels) {\r\n arrForEach(channels, function (channel) {\r\n if (channel.identifier && channel.version) {\r\n var ver = channel.identifier + \"=\" + channel.version;\r\n _self.pluginVersionStringArr.push(ver);\r\n }\r\n });\r\n }\r\n });\r\n }\r\n }\r\n _self.getWParam = function () {\r\n return typeof document !== \"undefined\" ? 0 : -1;\r\n };\r\n if (extensions) {\r\n arrForEach(extensions, function (ext) {\r\n if (ext && ext.identifier && ext.version) {\r\n var ver = ext.identifier + \"=\" + ext.version;\r\n _self.pluginVersionStringArr.push(ver);\r\n }\r\n });\r\n }\r\n _self.pluginVersionString = _self.pluginVersionStringArr.join(\";\");\r\n try {\r\n _base.initialize(config, extensions, logger, notificationManager);\r\n _self.pollInternalLogs(\"InternalLog\");\r\n }\r\n catch (e) {\r\n var logger_1 = _self.logger;\r\n var message = dumpObj(e);\r\n if (message.indexOf(\"channels\") !== -1) {\r\n // Add some additional context to the underlying reported error\r\n message += \"\\n - Channels must be provided through config.channels only!\";\r\n }\r\n logger_1.throwInternal(1 /* CRITICAL */, 514 /* FailedToInitializeSDK */, \"SDK Initialization Failed - no telemetry will be sent: \" + message);\r\n }\r\n }, function () { return ({ config: config, extensions: extensions, logger: logger, notificationManager: notificationManager }); });\r\n };\r\n _self.track = function (item) {\r\n doPerf(_self, function () { return \"AppInsightsCore.track\"; }, function () {\r\n var telemetryItem = item;\r\n if (telemetryItem) {\r\n telemetryItem.timings = telemetryItem.timings || {};\r\n telemetryItem.timings.trackStart = getTime();\r\n if (!isLatency(telemetryItem.latency)) {\r\n telemetryItem.latency = 1 /* Normal */;\r\n }\r\n var itemExt = telemetryItem.ext = telemetryItem.ext || {};\r\n itemExt.sdk = itemExt.sdk || {};\r\n itemExt.sdk.ver = FullVersionString;\r\n var baseData = telemetryItem.baseData = telemetryItem.baseData || {};\r\n if (!baseData[properties]) {\r\n baseData[properties] = {};\r\n }\r\n var itemProperties = baseData[properties];\r\n if (!itemProperties[PropVersion]) {\r\n itemProperties[PropVersion] = \"\";\r\n }\r\n if (_self.pluginVersionString !== \"\") {\r\n itemProperties[PropVersion] = _self.pluginVersionString;\r\n }\r\n }\r\n _base.track(telemetryItem);\r\n }, function () { return ({ item: item }); }, !(item.sync));\r\n };\r\n });\r\n return _this;\r\n }\r\n /**\r\n * Initialize the sdk.\r\n * @param config - The configuration to initialize the SDK.\r\n * @param extensions - An array of extensions that are to be used by the core.\r\n */\r\n AppInsightsCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n AppInsightsCore.prototype.track = function (item) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return AppInsightsCore;\r\n}(InternalCore));\r\nexport default AppInsightsCore;\r\n//# sourceMappingURL=AppInsightsCore.js.map"],"names":[],"mappings":";;;;;AAAA,gFAAkC;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;oDAUM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"AppInsightsCore.js.map","sources":["AppInsightsCore.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\n/**\r\n* AppInsightsCore.ts\r\n* @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { AppInsightsCore as InternalCore, DiagnosticLogger, _throwInternal, arrForEach, doPerf, dumpObj, throwError } from \"@microsoft/applicationinsights-core-js\";\r\nimport { STR_DEFAULT_ENDPOINT_URL, STR_EMPTY, STR_PROPERTIES, STR_VERSION } from \"./InternalConstants\";\r\nimport { FullVersionString, getTime, isLatency } from \"./Utils\";\r\nvar AppInsightsCore = /** @class */ (function (_super) {\r\n __extends(AppInsightsCore, _super);\r\n function AppInsightsCore() {\r\n var _this = _super.call(this) || this;\r\n _this.pluginVersionStringArr = [];\r\n dynamicProto(AppInsightsCore, _this, function (_self, _base) {\r\n if (!_self.logger || !_self.logger.queue) {\r\n // The AI Base can inject a No-Op logger so if not defined or the No-Op, change to use a default logger so initialization errors\r\n // are not dropped on the floor if one is not already defined\r\n _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 /* eLoggingSeverity.CRITICAL */ });\r\n }\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n doPerf(_self, function () { return \"AppInsightsCore.initialize\"; }, function () {\r\n var _pluginVersionStringArr = _self.pluginVersionStringArr;\r\n // Add default collector url\r\n if (config) {\r\n if (!config.endpointUrl) {\r\n config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;\r\n }\r\n var propertyStorageOverride = config.propertyStorageOverride;\r\n // Validate property storage override\r\n if (propertyStorageOverride && (!propertyStorageOverride.getProperty || !propertyStorageOverride.setProperty)) {\r\n throwError(\"Invalid property storage override passed.\");\r\n }\r\n if (config.channels) {\r\n arrForEach(config.channels, function (channels) {\r\n if (channels) {\r\n arrForEach(channels, function (channel) {\r\n if (channel.identifier && channel.version) {\r\n var ver = channel.identifier + \"=\" + channel.version;\r\n _pluginVersionStringArr.push(ver);\r\n }\r\n });\r\n }\r\n });\r\n }\r\n }\r\n _self.getWParam = function () {\r\n return typeof document !== \"undefined\" ? 0 : -1;\r\n };\r\n if (extensions) {\r\n arrForEach(extensions, function (ext) {\r\n if (ext && ext.identifier && ext.version) {\r\n var ver = ext.identifier + \"=\" + ext.version;\r\n _pluginVersionStringArr.push(ver);\r\n }\r\n });\r\n }\r\n _self.pluginVersionString = _pluginVersionStringArr.join(\";\");\r\n _self.pluginVersionStringArr = _pluginVersionStringArr;\r\n try {\r\n _base.initialize(config, extensions, logger, notificationManager);\r\n _self.pollInternalLogs(\"InternalLog\");\r\n }\r\n catch (e) {\r\n var logger_1 = _self.logger;\r\n var message = dumpObj(e);\r\n if (message.indexOf(\"channels\") !== -1) {\r\n // Add some additional context to the underlying reported error\r\n message += \"\\n - Channels must be provided through config.channels only!\";\r\n }\r\n _throwInternal(logger_1, 1 /* eLoggingSeverity.CRITICAL */, 514 /* _eExtendedInternalMessageId.FailedToInitializeSDK */, \"SDK Initialization Failed - no telemetry will be sent: \" + message);\r\n }\r\n }, function () { return ({ config: config, extensions: extensions, logger: logger, notificationManager: notificationManager }); });\r\n };\r\n _self.track = function (item) {\r\n doPerf(_self, function () { return \"AppInsightsCore.track\"; }, function () {\r\n var telemetryItem = item;\r\n if (telemetryItem) {\r\n telemetryItem.timings = telemetryItem.timings || {};\r\n telemetryItem.timings.trackStart = getTime();\r\n if (!isLatency(telemetryItem.latency)) {\r\n telemetryItem.latency = 1 /* EventLatencyValue.Normal */;\r\n }\r\n var itemExt = telemetryItem.ext = telemetryItem.ext || {};\r\n itemExt.sdk = itemExt.sdk || {};\r\n itemExt.sdk.ver = FullVersionString;\r\n var baseData = telemetryItem.baseData = telemetryItem.baseData || {};\r\n baseData[STR_PROPERTIES] = baseData[STR_PROPERTIES] || {};\r\n var itemProperties = baseData[STR_PROPERTIES];\r\n itemProperties[STR_VERSION] = _self.pluginVersionString || itemProperties[STR_VERSION] || STR_EMPTY;\r\n }\r\n _base.track(telemetryItem);\r\n }, function () { return ({ item: item }); }, !(item.sync));\r\n };\r\n });\r\n return _this;\r\n }\r\n /**\r\n * Initialize the sdk.\r\n * @param config - The configuration to initialize the SDK.\r\n * @param extensions - An array of extensions that are to be used by the core.\r\n */\r\n AppInsightsCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n AppInsightsCore.prototype.track = function (item) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return AppInsightsCore;\r\n}(InternalCore));\r\nexport default AppInsightsCore;\r\n//# sourceMappingURL=AppInsightsCore.js.map"],"names":[],"mappings":";;;;;AAAA,gFAAkC;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;oDAUM,CAAC;;;;;;2BACoB;AAC3B;AACA;AACA"}
@@ -1,5 +1,5 @@
1
- import { BaseCore as InternalCore, IPlugin, ITelemetryItem, IDiagnosticLogger, INotificationManager } from "@microsoft/applicationinsights-core-js";
2
- import { IExtendedConfiguration, IExtendedTelemetryItem, IExtendedAppInsightsCore } from "./DataModels";
1
+ import { BaseCore as InternalCore, IDiagnosticLogger, INotificationManager, IPlugin, ITelemetryItem } from "@microsoft/applicationinsights-core-js";
2
+ import { IExtendedAppInsightsCore, IExtendedConfiguration, IExtendedTelemetryItem } from "./DataModels";
3
3
  export default class BaseCore extends InternalCore implements IExtendedAppInsightsCore {
4
4
  getWParam: () => number;
5
5
  constructor();
@@ -1,19 +1,20 @@
1
1
  /*
2
- * 1DS JS SDK Core, 3.2.1
2
+ * 1DS JS SDK Core, 3.2.4
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
7
7
  /**
8
- * BaseCore.ts
9
- * Base Core is a subset of 1DS Web SDK Core. The purpose of Base Core is to generate a smaller bundle size while providing essential features of Core. Features that are not included in Base Core are:
10
- * 1. Internal logging
11
- * 2. Sending notifications on telemetry sent/discarded
12
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
13
- * @copyright Microsoft 2018
14
- */
8
+ * BaseCore.ts
9
+ * Base Core is a subset of 1DS Web SDK Core. The purpose of Base Core is to generate a smaller bundle size while providing essential features of Core. Features that are not included in Base Core are:
10
+ * 1. Internal logging
11
+ * 2. Sending notifications on telemetry sent/discarded
12
+ * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
13
+ * @copyright Microsoft 2018
14
+ */
15
15
  import dynamicProto from "@microsoft/dynamicproto-js";
16
- import { BaseCore as InternalCore, dumpObj, _throwInternal } from "@microsoft/applicationinsights-core-js";
16
+ import { BaseCore as InternalCore, _throwInternal, dumpObj } from "@microsoft/applicationinsights-core-js";
17
+ import { STR_DEFAULT_ENDPOINT_URL } from "./InternalConstants";
17
18
  import { FullVersionString, isDocumentObjectAvailable } from "./Utils";
18
19
  var BaseCore = /** @class */ (function (_super) {
19
20
  __extends(BaseCore, _super);
@@ -22,7 +23,7 @@ var BaseCore = /** @class */ (function (_super) {
22
23
  dynamicProto(BaseCore, _this, function (_self, _base) {
23
24
  _self.initialize = function (config, extensions, logger, notificationManager) {
24
25
  if (config && !config.endpointUrl) {
25
- config.endpointUrl = "https://browser.events.data.microsoft.com/OneCollector/1.0/";
26
+ config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;
26
27
  }
27
28
  _self.getWParam = function () {
28
29
  return isDocumentObjectAvailable ? 0 : -1;
@@ -31,7 +32,7 @@ var BaseCore = /** @class */ (function (_super) {
31
32
  _base.initialize(config, extensions, logger, notificationManager);
32
33
  }
33
34
  catch (e) {
34
- _throwInternal(_self.logger, 1 /* CRITICAL */, 514 /* FailedToInitializeSDK */, "Initialization Failed: " + dumpObj(e) + "\n - Note: Channels must be provided through config.channels only");
35
+ _throwInternal(_self.logger, 1 /* eLoggingSeverity.CRITICAL */, 514 /* _eExtendedInternalMessageId.FailedToInitializeSDK */, "Initialization Failed: " + dumpObj(e) + "\n - Note: Channels must be provided through config.channels only");
35
36
  }
36
37
  };
37
38
  _self.track = function (item) {
@@ -48,6 +49,11 @@ var BaseCore = /** @class */ (function (_super) {
48
49
  }
49
50
  // Removed Stub for BaseCore.prototype.initialize.
50
51
  // Removed Stub for BaseCore.prototype.track.
52
+ // This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
53
+ // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
54
+ // this will be removed when ES3 support is dropped.
55
+ BaseCore.__ieDyn=1;
56
+
51
57
  return BaseCore;
52
58
  }(InternalCore));
53
59
  export default BaseCore;
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCore.js.map","sources":["BaseCore.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\n/**\r\n * BaseCore.ts\r\n * Base Core is a subset of 1DS Web SDK Core. The purpose of Base Core is to generate a smaller bundle size while providing essential features of Core. Features that are not included in Base Core are:\r\n * 1. Internal logging\r\n * 2. Sending notifications on telemetry sent/discarded\r\n * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n * @copyright Microsoft 2018\r\n */\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseCore as InternalCore, dumpObj, _throwInternal } from \"@microsoft/applicationinsights-core-js\";\r\nimport { FullVersionString, isDocumentObjectAvailable } from \"./Utils\";\r\nvar BaseCore = /** @class */ (function (_super) {\r\n __extends(BaseCore, _super);\r\n function BaseCore() {\r\n var _this = _super.call(this) || this;\r\n dynamicProto(BaseCore, _this, function (_self, _base) {\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n if (config && !config.endpointUrl) {\r\n config.endpointUrl = \"https://browser.events.data.microsoft.com/OneCollector/1.0/\";\r\n }\r\n _self.getWParam = function () {\r\n return isDocumentObjectAvailable ? 0 : -1;\r\n };\r\n try {\r\n _base.initialize(config, extensions, logger, notificationManager);\r\n }\r\n catch (e) {\r\n _throwInternal(_self.logger, 1 /* CRITICAL */, 514 /* FailedToInitializeSDK */, \"Initialization Failed: \" + dumpObj(e) + \"\\n - Note: Channels must be provided through config.channels only\");\r\n }\r\n };\r\n _self.track = function (item) {\r\n var telemetryItem = item;\r\n if (telemetryItem) {\r\n var ext = telemetryItem.ext = telemetryItem.ext || {};\r\n ext.sdk = ext.sdk || {};\r\n ext.sdk.ver = FullVersionString;\r\n }\r\n _base.track(telemetryItem);\r\n };\r\n });\r\n return _this;\r\n }\r\n /**\r\n * Initialize the sdk.\r\n * @param config - The configuration to initialize the SDK.\r\n * @param extensions - An array of extensions that are to be used by the core.\r\n */\r\n BaseCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.track = function (item) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return BaseCore;\r\n}(InternalCore));\r\nexport default BaseCore;\r\n//# sourceMappingURL=BaseCore.js.map"],"names":[],"mappings":";;;;;AAAA,gFAAkC;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;6CAUM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"BaseCore.js.map","sources":["BaseCore.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\n/**\r\n* BaseCore.ts\r\n* Base Core is a subset of 1DS Web SDK Core. The purpose of Base Core is to generate a smaller bundle size while providing essential features of Core. Features that are not included in Base Core are:\r\n* 1. Internal logging\r\n* 2. Sending notifications on telemetry sent/discarded\r\n* @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseCore as InternalCore, _throwInternal, dumpObj } from \"@microsoft/applicationinsights-core-js\";\r\nimport { STR_DEFAULT_ENDPOINT_URL } from \"./InternalConstants\";\r\nimport { FullVersionString, isDocumentObjectAvailable } from \"./Utils\";\r\nvar BaseCore = /** @class */ (function (_super) {\r\n __extends(BaseCore, _super);\r\n function BaseCore() {\r\n var _this = _super.call(this) || this;\r\n dynamicProto(BaseCore, _this, function (_self, _base) {\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n if (config && !config.endpointUrl) {\r\n config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;\r\n }\r\n _self.getWParam = function () {\r\n return isDocumentObjectAvailable ? 0 : -1;\r\n };\r\n try {\r\n _base.initialize(config, extensions, logger, notificationManager);\r\n }\r\n catch (e) {\r\n _throwInternal(_self.logger, 1 /* eLoggingSeverity.CRITICAL */, 514 /* _eExtendedInternalMessageId.FailedToInitializeSDK */, \"Initialization Failed: \" + dumpObj(e) + \"\\n - Note: Channels must be provided through config.channels only\");\r\n }\r\n };\r\n _self.track = function (item) {\r\n var telemetryItem = item;\r\n if (telemetryItem) {\r\n var ext = telemetryItem.ext = telemetryItem.ext || {};\r\n ext.sdk = ext.sdk || {};\r\n ext.sdk.ver = FullVersionString;\r\n }\r\n _base.track(telemetryItem);\r\n };\r\n });\r\n return _this;\r\n }\r\n /**\r\n * Initialize the sdk.\r\n * @param config - The configuration to initialize the SDK.\r\n * @param extensions - An array of extensions that are to be used by the core.\r\n */\r\n BaseCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.track = function (item) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return BaseCore;\r\n}(InternalCore));\r\nexport default BaseCore;\r\n//# sourceMappingURL=BaseCore.js.map"],"names":[],"mappings":";;;;;AAAA,gFAAkC;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;6CAUM,CAAC;;;;;;oBACa;AACpB;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK Core, 3.2.1
2
+ * 1DS JS SDK Core, 3.2.4
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -1,9 +1,9 @@
1
1
  /**
2
- * ESPromise.ts
3
- * @author Nev Wylie (newylie))
4
- * @copyright Microsoft 2019
5
- * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
6
- */
2
+ * ESPromise.ts
3
+ * @author Nev Wylie (newylie))
4
+ * @copyright Microsoft 2019
5
+ * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
6
+ */
7
7
  /**
8
8
  * This defines the handler function for when a promise is resolved.
9
9
  * @param value This is the value passed as part of resolving the Promise
@@ -1,16 +1,16 @@
1
1
  /*
2
- * 1DS JS SDK Core, 3.2.1
2
+ * 1DS JS SDK Core, 3.2.4
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  /**
7
- * ESPromise.ts
8
- * @author Nev Wylie (newylie))
9
- * @copyright Microsoft 2019
10
- * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
11
- */
12
- import { isFunction } from "@microsoft/applicationinsights-core-js";
7
+ * ESPromise.ts
8
+ * @author Nev Wylie (newylie))
9
+ * @copyright Microsoft 2019
10
+ * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
11
+ */
13
12
  import dynamicProto from "@microsoft/dynamicproto-js";
13
+ import { isFunction } from "@microsoft/applicationinsights-core-js";
14
14
  /**
15
15
  * @ignore -- Don't include in the generated documentation
16
16
  * Using a local variable to assist with minfication
@@ -49,7 +49,7 @@ var ESPromise = /** @class */ (function () {
49
49
  * promise is rejected. The return value of the executor is ignored.
50
50
  */
51
51
  function ESPromise(resolverFunc) {
52
- var _state = 0 /* Pending */;
52
+ var _state = 0 /* PromiseState.Pending */;
53
53
  var _settledValue = null;
54
54
  var _queue = [];
55
55
  dynamicProto(ESPromise, this, function (_this) {
@@ -71,7 +71,7 @@ var ESPromise = /** @class */ (function () {
71
71
  // First call the onFulfilled or onRejected handler, on the settled value
72
72
  // of this promise. If the corresponding handler does not exist, simply
73
73
  // pass through the settled value.
74
- if (_state === 1 /* Resolved */) {
74
+ if (_state === 1 /* PromiseState.Resolved */) {
75
75
  value = _isFunction(onResolved) ? onResolved(_settledValue) : _settledValue;
76
76
  }
77
77
  else {
@@ -82,7 +82,7 @@ var ESPromise = /** @class */ (function () {
82
82
  // will follow the state of this promise.
83
83
  value.then(resolve, reject);
84
84
  }
85
- else if (_state === 2 /* Rejected */ && !_isFunction(onRejected)) {
85
+ else if (_state === 2 /* PromiseState.Rejected */ && !_isFunction(onRejected)) {
86
86
  // If there wasn't an onRejected handler and this promise is rejected, then
87
87
  // the chained promise also rejects with the same reason.
88
88
  reject(value);
@@ -105,7 +105,7 @@ var ESPromise = /** @class */ (function () {
105
105
  });
106
106
  // If this promise is already settled, then immediately process the callback we
107
107
  // just added to the queue.
108
- if (_state !== 0 /* Pending */) {
108
+ if (_state !== 0 /* PromiseState.Pending */) {
109
109
  _processQueue();
110
110
  }
111
111
  }
@@ -129,16 +129,16 @@ var ESPromise = /** @class */ (function () {
129
129
  }
130
130
  }
131
131
  function _resolve(value) {
132
- if (_state === 0 /* Pending */) {
132
+ if (_state === 0 /* PromiseState.Pending */) {
133
133
  _settledValue = value;
134
- _state = 1 /* Resolved */;
134
+ _state = 1 /* PromiseState.Resolved */;
135
135
  _processQueue();
136
136
  }
137
137
  }
138
138
  function _reject(reason) {
139
- if (_state === 0 /* Pending */) {
139
+ if (_state === 0 /* PromiseState.Pending */) {
140
140
  _settledValue = reason;
141
- _state = 2 /* Rejected */;
141
+ _state = 2 /* PromiseState.Rejected */;
142
142
  _processQueue();
143
143
  }
144
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ESPromise.js.map","sources":["ESPromise.js"],"sourcesContent":["/**\r\n * ESPromise.ts\r\n * @author Nev Wylie (newylie))\r\n * @copyright Microsoft 2019\r\n * Simplified wrapper to provide ES6 style Promise callback handling for older browsers\r\n */\r\nimport { isFunction } from \"@microsoft/applicationinsights-core-js\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\n/**\r\n * @ignore -- Don't include in the generated documentation\r\n * Using a local variable to assist with minfication\r\n */\r\nvar _isFunction = isFunction;\r\n/**\r\n * @ignore -- Don't include in the generated documentation\r\n * This function will be used as onFulfilled handler for any Promise found in the iterable passed to Promise.all.\r\n * The goal here is to capture in a closure the index of the current item from the iterable. If we did not create\r\n * this closure, the captured index variable would be the same one that the for loop updates and thus would always\r\n * be pointing to the last index in the iterable by the time that the onFulfilled handler is called.\r\n * However, note that for the resolvedCallback callback we want the opposite. For this one we do want to capture\r\n * the same variable that the for loop updates so that we have the full count of pending promises by the time\r\n * the onFulfilled handlers start getting called.\r\n * @param values The resolving promise values\r\n * @param index The index of this callback function\r\n * @param resolvedCallback THe callback function used to check if the \"all\" promise is complete\r\n */\r\nfunction _createPromiseAllOnResolvedFunction(values, index, resolvedCallback) {\r\n return function (value) {\r\n values[index] = value;\r\n resolvedCallback();\r\n };\r\n}\r\n/**\r\n * Simplified wrapper to provide ES6 style Promise callback handling for older browsers\r\n */\r\nvar ESPromise = /** @class */ (function () {\r\n /**\r\n * The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.\r\n * @param resolverFunc A function that is passed with the arguments resolve and reject. The executor function is executed\r\n * immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise\r\n * constructor even returns the created object). The resolve and reject functions, when called, resolve or reject the promise,\r\n * respectively. The executor normally initiates some asynchronous work, and then, once that completes, either calls the resolve\r\n * function to resolve the promise or else rejects it if an error occurred. If an error is thrown in the executor function, the\r\n * promise is rejected. The return value of the executor is ignored.\r\n */\r\n function ESPromise(resolverFunc) {\r\n var _state = 0 /* Pending */;\r\n var _settledValue = null;\r\n var _queue = [];\r\n dynamicProto(ESPromise, this, function (_this) {\r\n _this.then = function (onResolved, onRejected) {\r\n return new ESPromise(function (resolve, reject) {\r\n // Queue the new promise returned to be resolved or rejected\r\n // when this promise settles.\r\n _enqueue(onResolved, onRejected, resolve, reject);\r\n });\r\n };\r\n _this[\"catch\"] = function (onRejected) {\r\n return _this.then(null, onRejected);\r\n };\r\n });\r\n function _enqueue(onResolved, onRejected, resolve, reject) {\r\n _queue.push(function () {\r\n var value;\r\n try {\r\n // First call the onFulfilled or onRejected handler, on the settled value\r\n // of this promise. If the corresponding handler does not exist, simply\r\n // pass through the settled value.\r\n if (_state === 1 /* Resolved */) {\r\n value = _isFunction(onResolved) ? onResolved(_settledValue) : _settledValue;\r\n }\r\n else {\r\n value = _isFunction(onRejected) ? onRejected(_settledValue) : _settledValue;\r\n }\r\n if (value instanceof ESPromise) {\r\n // The called handlers returned a new promise, so the chained promise\r\n // will follow the state of this promise.\r\n value.then(resolve, reject);\r\n }\r\n else if (_state === 2 /* Rejected */ && !_isFunction(onRejected)) {\r\n // If there wasn't an onRejected handler and this promise is rejected, then\r\n // the chained promise also rejects with the same reason.\r\n reject(value);\r\n }\r\n else {\r\n // If this promise is fulfilled, then the chained promise is also fulfilled\r\n // with either the settled value of this promise (if no onFulfilled handler\r\n // was available) or the return value of the handler. If this promise is\r\n // rejected and there was an onRejected handler, then the chained promise is\r\n // fulfilled with the return value of the handler.\r\n resolve(value);\r\n }\r\n }\r\n catch (error) {\r\n // The chained promise will reject if there is any exception thrown while\r\n // calling the onFulfilled or onRejected handlers.\r\n reject(error);\r\n return;\r\n }\r\n });\r\n // If this promise is already settled, then immediately process the callback we\r\n // just added to the queue.\r\n if (_state !== 0 /* Pending */) {\r\n _processQueue();\r\n }\r\n }\r\n function _processQueue() {\r\n if (_queue.length > 0) {\r\n // The onFulfilled and onRejected handlers must be called asynchronously. Thus,\r\n // we make a copy of the queue and work on it once the current call stack unwinds.\r\n var pending_1 = _queue.slice();\r\n _queue = [];\r\n setTimeout(function () {\r\n for (var i = 0, len = pending_1.length; i < len; ++i) {\r\n try {\r\n pending_1[i]();\r\n }\r\n catch (e) {\r\n // Don't let 1 failing handler break all others\r\n // TODO (newylie): Add some form of error reporting (i.e. Call any registered JS error handler so the error is reported)\r\n }\r\n }\r\n }, 0);\r\n }\r\n }\r\n function _resolve(value) {\r\n if (_state === 0 /* Pending */) {\r\n _settledValue = value;\r\n _state = 1 /* Resolved */;\r\n _processQueue();\r\n }\r\n }\r\n function _reject(reason) {\r\n if (_state === 0 /* Pending */) {\r\n _settledValue = reason;\r\n _state = 2 /* Rejected */;\r\n _processQueue();\r\n }\r\n }\r\n (function _initialize() {\r\n if (!_isFunction(resolverFunc)) {\r\n throw new TypeError(\"ESPromise: resolvedFunc argument is not a Function\");\r\n }\r\n try {\r\n resolverFunc(_resolve, _reject);\r\n }\r\n catch (error) {\r\n // This promise will immediately reject if any exception is thrown\r\n // from within the executor function.\r\n _reject(error);\r\n }\r\n })();\r\n }\r\n /**\r\n * The Promise.resolve() method returns a Promise object that is resolved with a given value. If the value is a promise, that promise is returned;\r\n * if the value is a thenable (i.e. has a \"then\" method), the returned promise will \"follow\" that thenable, adopting its eventual state; otherwise\r\n * the returned promise will be fulfilled with the value. This function flattens nested layers of promise-like objects (e.g. a promise that resolves\r\n * to a promise that resolves to something) into a single layer.\r\n * @param value Argument to be resolved by this Promise. Can also be a Promise or a thenable to resolve.\r\n */\r\n ESPromise.resolve = function (value) {\r\n if (value instanceof ESPromise) {\r\n // Value is a Promise so just return it\r\n return value;\r\n }\r\n else if (value && _isFunction(value.then)) {\r\n // Value looks like a promise or thenable (has a then function)\r\n return new ESPromise(function (resolve, reject) {\r\n try {\r\n value.then(resolve, reject);\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n }\r\n return new ESPromise(function (resolve) {\r\n resolve(value);\r\n });\r\n };\r\n /**\r\n * The Promise.reject() method returns a Promise object that is rejected with a given reason.\r\n * @param reason The reason why this Promise rejected.\r\n */\r\n ESPromise.reject = function (reason) {\r\n return new ESPromise(function (resolve, reject) {\r\n reject(reason);\r\n });\r\n };\r\n /**\r\n * The Promise.all() method returns a single Promise that resolves when all of the promises passed as an iterable\r\n * have resolved or when the iterable contains no promises. It rejects with the reason of the first promise that\r\n * rejects. There is no implied ordering in the execution of the array of Promises given. On some computers, they\r\n * may be executed in parallel, or in some sense concurrently, while on others they may be executed serially. For\r\n * this reason, there must be no dependency in any Promise on the order of execution of the Promises.\r\n * This method can be useful for aggregating the results of multiple promises.\r\n * FulfillmentSection - The returned promise is fulfilled with an array containing all the values of the iterable\r\n * passed as argument (also non-promise values).\r\n * If an empty iterable is passed, then this method returns (synchronously) an already resolved promise.\r\n * If all of the passed-in promises fulfill, or are not promises, the promise returned by Promise.all is fulfilled\r\n * asynchronously.\r\n * RejectionSection - If any of the passed-in promises reject, Promise.all asynchronously rejects with the value of\r\n * the promise that rejected, whether or not the other promises have resolved.\r\n * @param iterable\r\n */\r\n ESPromise.all = function (iterable) {\r\n if (!iterable || !iterable.length) {\r\n return;\r\n }\r\n return new ESPromise(function (resolve, reject) {\r\n try {\r\n var values_1 = [];\r\n var pending_2 = 0;\r\n for (var lp = 0; lp < iterable.length; lp++) {\r\n var item = iterable[lp];\r\n // Quick and direct check for a Promise (will also catch a thenable)\r\n if (item && _isFunction(item.then)) {\r\n pending_2++;\r\n item.then(_createPromiseAllOnResolvedFunction(values_1, lp, function () {\r\n if (--pending_2 === 0) {\r\n resolve(values_1);\r\n }\r\n }), reject);\r\n }\r\n else {\r\n values_1[lp] = item;\r\n }\r\n }\r\n if (pending_2 === 0) {\r\n // All promises were either resolved or where not a promise\r\n setTimeout(function () {\r\n resolve(values_1);\r\n }, 0);\r\n }\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n };\r\n /**\r\n * The race function returns a Promise that is settled the same way (and takes the same value) as the first promise\r\n * that settles amongst the promises of the iterable passed as an argument.\r\n * If the iterable passed is empty, the promise returned will be forever pending.\r\n * If the iterable contains one or more non-promise value and/or an already settled promise, then Promise.race will\r\n * resolve to the first of these values found in the iterable.\r\n * @param iterable\r\n */\r\n ESPromise.race = function (iterable) {\r\n return new ESPromise(function (resolve, reject) {\r\n if (!iterable || !iterable.length) {\r\n return;\r\n }\r\n try {\r\n var _loop_1 = function (lp) {\r\n var item = iterable[lp];\r\n // Quick and direct check for a Promise (will also catch a thenable)\r\n if (item && _isFunction(item.then)) {\r\n item.then(resolve, reject);\r\n }\r\n else {\r\n setTimeout(function () {\r\n resolve(item);\r\n }, 0);\r\n }\r\n };\r\n for (var lp = 0; lp < iterable.length; lp++) {\r\n _loop_1(lp);\r\n }\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n };\r\n /**\r\n * The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.\r\n * @param onResolved A Function called if the Promise is fulfilled. This function has one argument, the fulfillment value. If it is not a\r\n * function, it is internally replaced with an \"Identity\" function (it returns the received argument).\r\n * @param onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason. If it is not a\r\n * function, it is internally replaced with a \"Thrower\" function (it throws an error it received as argument).\r\n * @returns Once a Promise is fulfilled or rejected, the respective handler function (onFulfilled or onRejected) will be called asynchronously\r\n * (scheduled in the current thread loop). The behavior of the handler function follows a specific set of rules. If a handler function:\r\n * - returns a value, the promise returned by then gets resolved with the returned value as its value;\r\n * - doesn't return anything, the promise returned by then gets resolved with an undefined value;\r\n * - throws an error, the promise returned by then gets rejected with the thrown error as its value;\r\n * - returns an already fulfilled promise, the promise returned by then gets fulfilled with that promise's value as its value;\r\n * - returns an already rejected promise, the promise returned by then gets rejected with that promise's value as its value;\r\n * - returns another pending promise object, the resolution/rejection of the promise returned by then will be subsequent to the\r\n * resolution/rejection of the promise returned by the handler. Also, the value of the promise returned by then will be the same as the value of the promise returned by the handler.\r\n */\r\n ESPromise.prototype.then = function (onResolved, onRejected) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * The catch() method returns a Promise and deals with rejected cases only. It behaves the same as calling Promise.prototype.then(undefined, onRejected)\r\n * (in fact, calling obj.catch(onRejected) internally calls obj.then(undefined, onRejected)). This means that you have to provide an onRejected function\r\n * even if you want to fall back to an undefined result value - for example obj.catch(() => {}).\r\n * @param onRejected A Function called when the Promise is rejected. This function has one argument: reason The rejection reason.\r\n * @returns Internally calls Promise.prototype.then on the object upon which it was called, passing the parameters undefined and the received\r\n * onRejected handler. Returns the value of that call, which is a Promise.\r\n */\r\n ESPromise.prototype[\"catch\"] = function (onRejected) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n return ESPromise;\r\n}());\r\nexport default ESPromise;\r\n//# sourceMappingURL=ESPromise.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;iDA+BM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"ESPromise.js.map","sources":["ESPromise.js"],"sourcesContent":["/**\r\n* ESPromise.ts\r\n* @author Nev Wylie (newylie))\r\n* @copyright Microsoft 2019\r\n* Simplified wrapper to provide ES6 style Promise callback handling for older browsers\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { isFunction } from \"@microsoft/applicationinsights-core-js\";\r\n/**\r\n * @ignore -- Don't include in the generated documentation\r\n * Using a local variable to assist with minfication\r\n */\r\nvar _isFunction = isFunction;\r\n/**\r\n * @ignore -- Don't include in the generated documentation\r\n * This function will be used as onFulfilled handler for any Promise found in the iterable passed to Promise.all.\r\n * The goal here is to capture in a closure the index of the current item from the iterable. If we did not create\r\n * this closure, the captured index variable would be the same one that the for loop updates and thus would always\r\n * be pointing to the last index in the iterable by the time that the onFulfilled handler is called.\r\n * However, note that for the resolvedCallback callback we want the opposite. For this one we do want to capture\r\n * the same variable that the for loop updates so that we have the full count of pending promises by the time\r\n * the onFulfilled handlers start getting called.\r\n * @param values The resolving promise values\r\n * @param index The index of this callback function\r\n * @param resolvedCallback THe callback function used to check if the \"all\" promise is complete\r\n */\r\nfunction _createPromiseAllOnResolvedFunction(values, index, resolvedCallback) {\r\n return function (value) {\r\n values[index] = value;\r\n resolvedCallback();\r\n };\r\n}\r\n/**\r\n * Simplified wrapper to provide ES6 style Promise callback handling for older browsers\r\n */\r\nvar ESPromise = /** @class */ (function () {\r\n /**\r\n * The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.\r\n * @param resolverFunc A function that is passed with the arguments resolve and reject. The executor function is executed\r\n * immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise\r\n * constructor even returns the created object). The resolve and reject functions, when called, resolve or reject the promise,\r\n * respectively. The executor normally initiates some asynchronous work, and then, once that completes, either calls the resolve\r\n * function to resolve the promise or else rejects it if an error occurred. If an error is thrown in the executor function, the\r\n * promise is rejected. The return value of the executor is ignored.\r\n */\r\n function ESPromise(resolverFunc) {\r\n var _state = 0 /* PromiseState.Pending */;\r\n var _settledValue = null;\r\n var _queue = [];\r\n dynamicProto(ESPromise, this, function (_this) {\r\n _this.then = function (onResolved, onRejected) {\r\n return new ESPromise(function (resolve, reject) {\r\n // Queue the new promise returned to be resolved or rejected\r\n // when this promise settles.\r\n _enqueue(onResolved, onRejected, resolve, reject);\r\n });\r\n };\r\n _this[\"catch\"] = function (onRejected) {\r\n return _this.then(null, onRejected);\r\n };\r\n });\r\n function _enqueue(onResolved, onRejected, resolve, reject) {\r\n _queue.push(function () {\r\n var value;\r\n try {\r\n // First call the onFulfilled or onRejected handler, on the settled value\r\n // of this promise. If the corresponding handler does not exist, simply\r\n // pass through the settled value.\r\n if (_state === 1 /* PromiseState.Resolved */) {\r\n value = _isFunction(onResolved) ? onResolved(_settledValue) : _settledValue;\r\n }\r\n else {\r\n value = _isFunction(onRejected) ? onRejected(_settledValue) : _settledValue;\r\n }\r\n if (value instanceof ESPromise) {\r\n // The called handlers returned a new promise, so the chained promise\r\n // will follow the state of this promise.\r\n value.then(resolve, reject);\r\n }\r\n else if (_state === 2 /* PromiseState.Rejected */ && !_isFunction(onRejected)) {\r\n // If there wasn't an onRejected handler and this promise is rejected, then\r\n // the chained promise also rejects with the same reason.\r\n reject(value);\r\n }\r\n else {\r\n // If this promise is fulfilled, then the chained promise is also fulfilled\r\n // with either the settled value of this promise (if no onFulfilled handler\r\n // was available) or the return value of the handler. If this promise is\r\n // rejected and there was an onRejected handler, then the chained promise is\r\n // fulfilled with the return value of the handler.\r\n resolve(value);\r\n }\r\n }\r\n catch (error) {\r\n // The chained promise will reject if there is any exception thrown while\r\n // calling the onFulfilled or onRejected handlers.\r\n reject(error);\r\n return;\r\n }\r\n });\r\n // If this promise is already settled, then immediately process the callback we\r\n // just added to the queue.\r\n if (_state !== 0 /* PromiseState.Pending */) {\r\n _processQueue();\r\n }\r\n }\r\n function _processQueue() {\r\n if (_queue.length > 0) {\r\n // The onFulfilled and onRejected handlers must be called asynchronously. Thus,\r\n // we make a copy of the queue and work on it once the current call stack unwinds.\r\n var pending_1 = _queue.slice();\r\n _queue = [];\r\n setTimeout(function () {\r\n for (var i = 0, len = pending_1.length; i < len; ++i) {\r\n try {\r\n pending_1[i]();\r\n }\r\n catch (e) {\r\n // Don't let 1 failing handler break all others\r\n // TODO (newylie): Add some form of error reporting (i.e. Call any registered JS error handler so the error is reported)\r\n }\r\n }\r\n }, 0);\r\n }\r\n }\r\n function _resolve(value) {\r\n if (_state === 0 /* PromiseState.Pending */) {\r\n _settledValue = value;\r\n _state = 1 /* PromiseState.Resolved */;\r\n _processQueue();\r\n }\r\n }\r\n function _reject(reason) {\r\n if (_state === 0 /* PromiseState.Pending */) {\r\n _settledValue = reason;\r\n _state = 2 /* PromiseState.Rejected */;\r\n _processQueue();\r\n }\r\n }\r\n (function _initialize() {\r\n if (!_isFunction(resolverFunc)) {\r\n throw new TypeError(\"ESPromise: resolvedFunc argument is not a Function\");\r\n }\r\n try {\r\n resolverFunc(_resolve, _reject);\r\n }\r\n catch (error) {\r\n // This promise will immediately reject if any exception is thrown\r\n // from within the executor function.\r\n _reject(error);\r\n }\r\n })();\r\n }\r\n /**\r\n * The Promise.resolve() method returns a Promise object that is resolved with a given value. If the value is a promise, that promise is returned;\r\n * if the value is a thenable (i.e. has a \"then\" method), the returned promise will \"follow\" that thenable, adopting its eventual state; otherwise\r\n * the returned promise will be fulfilled with the value. This function flattens nested layers of promise-like objects (e.g. a promise that resolves\r\n * to a promise that resolves to something) into a single layer.\r\n * @param value Argument to be resolved by this Promise. Can also be a Promise or a thenable to resolve.\r\n */\r\n ESPromise.resolve = function (value) {\r\n if (value instanceof ESPromise) {\r\n // Value is a Promise so just return it\r\n return value;\r\n }\r\n else if (value && _isFunction(value.then)) {\r\n // Value looks like a promise or thenable (has a then function)\r\n return new ESPromise(function (resolve, reject) {\r\n try {\r\n value.then(resolve, reject);\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n }\r\n return new ESPromise(function (resolve) {\r\n resolve(value);\r\n });\r\n };\r\n /**\r\n * The Promise.reject() method returns a Promise object that is rejected with a given reason.\r\n * @param reason The reason why this Promise rejected.\r\n */\r\n ESPromise.reject = function (reason) {\r\n return new ESPromise(function (resolve, reject) {\r\n reject(reason);\r\n });\r\n };\r\n /**\r\n * The Promise.all() method returns a single Promise that resolves when all of the promises passed as an iterable\r\n * have resolved or when the iterable contains no promises. It rejects with the reason of the first promise that\r\n * rejects. There is no implied ordering in the execution of the array of Promises given. On some computers, they\r\n * may be executed in parallel, or in some sense concurrently, while on others they may be executed serially. For\r\n * this reason, there must be no dependency in any Promise on the order of execution of the Promises.\r\n * This method can be useful for aggregating the results of multiple promises.\r\n * FulfillmentSection - The returned promise is fulfilled with an array containing all the values of the iterable\r\n * passed as argument (also non-promise values).\r\n * If an empty iterable is passed, then this method returns (synchronously) an already resolved promise.\r\n * If all of the passed-in promises fulfill, or are not promises, the promise returned by Promise.all is fulfilled\r\n * asynchronously.\r\n * RejectionSection - If any of the passed-in promises reject, Promise.all asynchronously rejects with the value of\r\n * the promise that rejected, whether or not the other promises have resolved.\r\n * @param iterable\r\n */\r\n ESPromise.all = function (iterable) {\r\n if (!iterable || !iterable.length) {\r\n return;\r\n }\r\n return new ESPromise(function (resolve, reject) {\r\n try {\r\n var values_1 = [];\r\n var pending_2 = 0;\r\n for (var lp = 0; lp < iterable.length; lp++) {\r\n var item = iterable[lp];\r\n // Quick and direct check for a Promise (will also catch a thenable)\r\n if (item && _isFunction(item.then)) {\r\n pending_2++;\r\n item.then(_createPromiseAllOnResolvedFunction(values_1, lp, function () {\r\n if (--pending_2 === 0) {\r\n resolve(values_1);\r\n }\r\n }), reject);\r\n }\r\n else {\r\n values_1[lp] = item;\r\n }\r\n }\r\n if (pending_2 === 0) {\r\n // All promises were either resolved or where not a promise\r\n setTimeout(function () {\r\n resolve(values_1);\r\n }, 0);\r\n }\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n };\r\n /**\r\n * The race function returns a Promise that is settled the same way (and takes the same value) as the first promise\r\n * that settles amongst the promises of the iterable passed as an argument.\r\n * If the iterable passed is empty, the promise returned will be forever pending.\r\n * If the iterable contains one or more non-promise value and/or an already settled promise, then Promise.race will\r\n * resolve to the first of these values found in the iterable.\r\n * @param iterable\r\n */\r\n ESPromise.race = function (iterable) {\r\n return new ESPromise(function (resolve, reject) {\r\n if (!iterable || !iterable.length) {\r\n return;\r\n }\r\n try {\r\n var _loop_1 = function (lp) {\r\n var item = iterable[lp];\r\n // Quick and direct check for a Promise (will also catch a thenable)\r\n if (item && _isFunction(item.then)) {\r\n item.then(resolve, reject);\r\n }\r\n else {\r\n setTimeout(function () {\r\n resolve(item);\r\n }, 0);\r\n }\r\n };\r\n for (var lp = 0; lp < iterable.length; lp++) {\r\n _loop_1(lp);\r\n }\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n };\r\n /**\r\n * The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.\r\n * @param onResolved A Function called if the Promise is fulfilled. This function has one argument, the fulfillment value. If it is not a\r\n * function, it is internally replaced with an \"Identity\" function (it returns the received argument).\r\n * @param onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason. If it is not a\r\n * function, it is internally replaced with a \"Thrower\" function (it throws an error it received as argument).\r\n * @returns Once a Promise is fulfilled or rejected, the respective handler function (onFulfilled or onRejected) will be called asynchronously\r\n * (scheduled in the current thread loop). The behavior of the handler function follows a specific set of rules. If a handler function:\r\n * - returns a value, the promise returned by then gets resolved with the returned value as its value;\r\n * - doesn't return anything, the promise returned by then gets resolved with an undefined value;\r\n * - throws an error, the promise returned by then gets rejected with the thrown error as its value;\r\n * - returns an already fulfilled promise, the promise returned by then gets fulfilled with that promise's value as its value;\r\n * - returns an already rejected promise, the promise returned by then gets rejected with that promise's value as its value;\r\n * - returns another pending promise object, the resolution/rejection of the promise returned by then will be subsequent to the\r\n * resolution/rejection of the promise returned by the handler. Also, the value of the promise returned by then will be the same as the value of the promise returned by the handler.\r\n */\r\n ESPromise.prototype.then = function (onResolved, onRejected) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * The catch() method returns a Promise and deals with rejected cases only. It behaves the same as calling Promise.prototype.then(undefined, onRejected)\r\n * (in fact, calling obj.catch(onRejected) internally calls obj.then(undefined, onRejected)). This means that you have to provide an onRejected function\r\n * even if you want to fall back to an undefined result value - for example obj.catch(() => {}).\r\n * @param onRejected A Function called when the Promise is rejected. This function has one argument: reason The rejection reason.\r\n * @returns Internally calls Promise.prototype.then on the object upon which it was called, passing the parameters undefined and the received\r\n * onRejected handler. Returns the value of that call, which is a Promise.\r\n */\r\n ESPromise.prototype[\"catch\"] = function (onRejected) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n return ESPromise;\r\n}());\r\nexport default ESPromise;\r\n//# sourceMappingURL=ESPromise.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;iDA+BM;AACN;AACA;AACA;AACA"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * ESPromiseScheduler.ts
3
- * @author Nev Wylie (newylie)
4
- * @copyright Microsoft 2019
5
- */
2
+ * ESPromiseScheduler.ts
3
+ * @author Nev Wylie (newylie)
4
+ * @copyright Microsoft 2019
5
+ */
6
6
  import ESPromise from "./ESPromise";
7
7
  import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js";
8
8
  export declare type ESPromiseSchedulerEvent<T> = (eventId?: string) => ESPromise<T>;
@@ -1,16 +1,16 @@
1
1
  /*
2
- * 1DS JS SDK Core, 3.2.1
2
+ * 1DS JS SDK Core, 3.2.4
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  /**
7
- * ESPromiseScheduler.ts
8
- * @author Nev Wylie (newylie)
9
- * @copyright Microsoft 2019
10
- */
11
- import ESPromise from "./ESPromise";
12
- import { getGlobal } from "@microsoft/applicationinsights-core-js";
7
+ * ESPromiseScheduler.ts
8
+ * @author Nev Wylie (newylie)
9
+ * @copyright Microsoft 2019
10
+ */
13
11
  import dynamicProto from "@microsoft/dynamicproto-js";
12
+ import ESPromise from "./ESPromise";
13
+ import { _warnToConsole, getGlobal } from "@microsoft/applicationinsights-core-js";
14
14
  /** This is a default timeout that will cause outstanding running promises to be removed/rejected to avoid filling up memory with blocked events */
15
15
  var LazyRejectPeriod = 600000; // 10 Minutes
16
16
  // These are global variables that are shared across ALL instances of the scheduler
@@ -258,7 +258,7 @@ var ESPromiseScheduler = /** @class */ (function () {
258
258
  }
259
259
  }
260
260
  function _warnLog(message) {
261
- diagLog && diagLog.warnToConsole("ESPromiseScheduler[" + _scheduledName + "] " + message);
261
+ _warnToConsole(diagLog, "ESPromiseScheduler[" + _scheduledName + "] " + message);
262
262
  }
263
263
  }
264
264
  ESPromiseScheduler.incomplete = function () {
@@ -1 +1 @@
1
- {"version":3,"file":"ESPromiseScheduler.js.map","sources":["ESPromiseScheduler.js"],"sourcesContent":["/**\r\n * ESPromiseScheduler.ts\r\n * @author Nev Wylie (newylie)\r\n * @copyright Microsoft 2019\r\n */\r\nimport ESPromise from \"./ESPromise\";\r\nimport { getGlobal } from \"@microsoft/applicationinsights-core-js\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\n/** This is a default timeout that will cause outstanding running promises to be removed/rejected to avoid filling up memory with blocked events */\r\nvar LazyRejectPeriod = 600000; // 10 Minutes\r\n// These are global variables that are shared across ALL instances of the scheduler\r\n/**\r\n * @ignore\r\n */\r\nvar _schedulerId = 0;\r\n/**\r\n * @ignore\r\n */\r\nvar _running = [];\r\n/**\r\n * @ignore\r\n */\r\nvar _waiting = [];\r\n/**\r\n * @ignore\r\n */\r\nvar _timedOut = [];\r\n/**\r\n * @ignore\r\n */\r\nfunction _getTime() {\r\n return new Date().getTime();\r\n}\r\n/**\r\n * Provides a simple mechanism queueing mechanism for scheduling events based on the ESPromise callbacks, this is used to ensure\r\n * order of async operations that are required to be executed in a specific order.\r\n */\r\nvar ESPromiseScheduler = /** @class */ (function () {\r\n function ESPromiseScheduler(name, diagLog) {\r\n var _promiseId = 0;\r\n var _scheduledName = (name || \"<unnamed>\") + \".\" + _schedulerId;\r\n _schedulerId++;\r\n dynamicProto(ESPromiseScheduler, this, function (_this) {\r\n var _lastEvent = null;\r\n var _eventCount = 0;\r\n _this.scheduleEvent = function (startEventAction, eventName, timeout) {\r\n var uniqueId = _scheduledName + \".\" + _eventCount;\r\n _eventCount++;\r\n if (eventName) {\r\n uniqueId += \"-(\" + eventName + \")\";\r\n }\r\n var uniqueEventId = uniqueId + \"{\" + _promiseId + \"}\";\r\n _promiseId++;\r\n // Create the next scheduled event details\r\n var newScheduledEvent = {\r\n evt: null,\r\n tm: _getTime(),\r\n id: uniqueEventId,\r\n isRunning: false,\r\n isAborted: false\r\n };\r\n if (!_lastEvent) {\r\n // We don't have any currently running event, so just start the next event\r\n newScheduledEvent.evt = _startWaitingEvent(newScheduledEvent);\r\n }\r\n else {\r\n // Start a new promise which will wait until all current active events are complete before starting\r\n // the new event, it does not resolve this scheduled event until after the new event is resolve to\r\n // ensure that all scheduled events are completed in the correct order\r\n newScheduledEvent.evt = _waitForPreviousEvent(newScheduledEvent, _lastEvent);\r\n }\r\n // Set this new event as the last one, so that any future events will wait for this one\r\n _lastEvent = newScheduledEvent;\r\n _lastEvent.evt._schId = uniqueEventId;\r\n return newScheduledEvent.evt;\r\n function _abortAndRemoveOldEvents(eventQueue) {\r\n var now = _getTime();\r\n var expired = now - LazyRejectPeriod;\r\n var len = eventQueue.length;\r\n var lp = 0;\r\n while (lp < len) {\r\n var evt = eventQueue[lp];\r\n if (evt && evt.tm < expired) {\r\n var message = null;\r\n if (evt.abort) {\r\n message = \"Aborting [\" + evt.id + \"] due to Excessive runtime (\" + (now - evt.tm) + \" ms)\";\r\n evt.abort(message);\r\n }\r\n else {\r\n message = \"Removing [\" + evt.id + \"] due to Excessive runtime (\" + (now - evt.tm) + \" ms)\";\r\n }\r\n _warnLog(message);\r\n eventQueue.splice(lp, 1);\r\n len--;\r\n }\r\n else {\r\n lp++;\r\n }\r\n }\r\n }\r\n function _cleanup(eventId, completed) {\r\n var toQueue = false;\r\n var removed = _removeQueuedEvent(_running, eventId);\r\n if (!removed) {\r\n removed = _removeQueuedEvent(_timedOut, eventId);\r\n toQueue = true;\r\n }\r\n if (removed) {\r\n if (removed.to) {\r\n // If there was a timeout stop it\r\n clearTimeout(removed.to);\r\n removed.to = null;\r\n }\r\n // TODO (newylie): Convert this into reportable metrics\r\n var tm = _getTime() - removed.tm;\r\n if (completed) {\r\n if (!toQueue) {\r\n _debugLog(\"Promise [\" + eventId + \"] Complete -- \" + tm + \" ms\");\r\n }\r\n else {\r\n _warnLog(\"Timed out event [\" + eventId + \"] finally complete -- \" + tm + \" ms\");\r\n }\r\n }\r\n else {\r\n _timedOut.push(removed);\r\n _warnLog(\"Event [\" + eventId + \"] Timed out and removed -- \" + tm + \" ms\");\r\n }\r\n }\r\n else {\r\n _debugLog(\"Failed to remove [\" + eventId + \"] from running queue\");\r\n }\r\n // Also if the last scheduled event was this event then clear it as we are now finished\r\n if (_lastEvent && _lastEvent.id === eventId) {\r\n _lastEvent = null;\r\n }\r\n _abortAndRemoveOldEvents(_running);\r\n _abortAndRemoveOldEvents(_waiting);\r\n _abortAndRemoveOldEvents(_timedOut);\r\n }\r\n // Return a callback function that will be called when the waiting promise is resolved or rejected to ensure\r\n // that any outer promise is also resolved or rejected\r\n function _removeScheduledEvent(eventId, callback) {\r\n return function (value) {\r\n _cleanup(eventId, true);\r\n callback && callback(value);\r\n return value;\r\n };\r\n }\r\n function _waitForFinalResult(eventId, startResult, schEventResolve, schEventReject) {\r\n startResult.then(function (value) {\r\n if (value instanceof ESPromise) {\r\n // If the result is a promise then this appears to be a chained result, so wait for this promise to complete\r\n _debugLog(\"Event [\" + eventId + \"] returned a promise -- waiting\");\r\n _waitForFinalResult(eventId, value, schEventResolve, schEventReject);\r\n return value;\r\n }\r\n else {\r\n return _removeScheduledEvent(eventId, schEventResolve)(value);\r\n }\r\n }, _removeScheduledEvent(eventId, schEventReject));\r\n }\r\n // Add the passed event to the active event list with resolve and reject callbacks that will remove\r\n // it from the active event list\r\n function _createScheduledEvent(eventDetails, startEvent) {\r\n var eventId = eventDetails.id;\r\n return new ESPromise(function (schEventResolve, schEventReject) {\r\n _debugLog(\"Event [\" + eventId + \"] Starting -- waited for \" + (eventDetails.wTm || \"--\") + \" ms\");\r\n eventDetails.isRunning = true;\r\n eventDetails.abort = function (message) {\r\n eventDetails.abort = null;\r\n eventDetails.isAborted = true;\r\n _cleanup(eventId, false);\r\n schEventReject(new Error(message));\r\n };\r\n var startResult = startEvent(eventId);\r\n if (startResult instanceof ESPromise) {\r\n if (timeout) {\r\n // Note: Only starting a timer if a timeout was specified\r\n eventDetails.to = setTimeout(function () {\r\n _cleanup(eventId, false);\r\n // Cause the listeners to reject (Note: We can't actually reject the waiting event)\r\n schEventReject(new Error(\"Timed out after [\" + timeout + \"] ms\"));\r\n }, timeout);\r\n }\r\n _waitForFinalResult(eventId, startResult, function (theResult) {\r\n _debugLog(\"Event [\" + eventId + \"] Resolving after \" + (_getTime() - eventDetails.tm) + \" ms\");\r\n schEventResolve(theResult);\r\n }, schEventReject);\r\n }\r\n else {\r\n // The startEvent didn't return a promise so just return a resolved promise\r\n _debugLog(\"Promise [\" + eventId + \"] Auto completed as the start action did not return a promise\");\r\n schEventResolve();\r\n }\r\n });\r\n }\r\n function _startWaitingEvent(eventDetails) {\r\n var now = _getTime();\r\n eventDetails.wTm = now - eventDetails.tm;\r\n eventDetails.tm = now;\r\n if (eventDetails.isAborted) {\r\n return ESPromise.reject(new Error(\"[\" + uniqueId + \"] was aborted\"));\r\n }\r\n _running.push(eventDetails);\r\n return _createScheduledEvent(eventDetails, startEventAction);\r\n }\r\n // Start a new promise which will wait until all current active events are complete before starting\r\n // the new event, it does not resolve this scheduled event until after the new event is resolve to\r\n // ensure that all scheduled events are completed in the correct order\r\n function _waitForPreviousEvent(eventDetails, waitForEvent) {\r\n var waitEvent = new ESPromise(function (waitResolve, waitReject) {\r\n var runTime = _getTime() - waitForEvent.tm;\r\n var prevId = waitForEvent.id;\r\n _debugLog(\"[\" + uniqueId + \"] is waiting for [\" + prevId + \":\" + runTime + \" ms] to complete before starting -- [\" + _waiting.length + \"] waiting and [\" + _running.length + \"] running\");\r\n eventDetails.abort = function (message) {\r\n eventDetails.abort = null;\r\n _removeQueuedEvent(_waiting, uniqueId);\r\n eventDetails.isAborted = true;\r\n waitReject(new Error(message));\r\n };\r\n // Wait for the previous event to complete\r\n waitForEvent.evt.then(function (value) {\r\n _removeQueuedEvent(_waiting, uniqueId);\r\n // Wait for the last event to complete before starting the new one, this ensures the execution\r\n // order so that we don't try and remove events that havn't been committed yet\r\n _startWaitingEvent(eventDetails).then(waitResolve, waitReject);\r\n }, function (reason) {\r\n _removeQueuedEvent(_waiting, uniqueId);\r\n // Wait for the last event to complete before starting the new one, this ensures the execution\r\n // order so that we don't try and remove events that havn't been committed yet\r\n _startWaitingEvent(eventDetails).then(waitResolve, waitReject);\r\n });\r\n });\r\n _waiting.push(eventDetails);\r\n return waitEvent;\r\n }\r\n };\r\n function _removeQueuedEvent(queue, eventId) {\r\n for (var lp = 0; lp < queue.length; lp++) {\r\n if (queue[lp].id === eventId) {\r\n return queue.splice(lp, 1)[0];\r\n }\r\n }\r\n return null;\r\n }\r\n });\r\n function _debugLog(message) {\r\n // Only log if running within test harness\r\n var global = getGlobal();\r\n if (global && global[\"QUnit\"]) {\r\n // tslint:disable-next-line:no-console\r\n console && console.log(\"ESPromiseScheduler[\" + _scheduledName + \"] \" + message);\r\n }\r\n }\r\n function _warnLog(message) {\r\n diagLog && diagLog.warnToConsole(\"ESPromiseScheduler[\" + _scheduledName + \"] \" + message);\r\n }\r\n }\r\n ESPromiseScheduler.incomplete = function () {\r\n return _running;\r\n };\r\n ESPromiseScheduler.waitingToStart = function () {\r\n return _waiting;\r\n };\r\n /**\r\n * Schedule an event that will execute the startEvent after all outstanding events are resolved or rejected. This is used to ensure\r\n * order of async operations that are required to be executed in a specific order.\r\n * The returned promise will be resolve or rejected based on the values returned from the doAction.\r\n * @param startEventAction The function to execute to start the event after all outstanding events have completed, will be called asynchronously.\r\n * @param eventName An [Optional] event name to assist with debbuging to understand what events are either waiting to start or still running (incomplete).\r\n * @param timeout An [Optional] timeout\r\n */\r\n ESPromiseScheduler.prototype.scheduleEvent = function (startEventAction, eventName, timeout) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n return ESPromiseScheduler;\r\n}());\r\nexport default ESPromiseScheduler;\r\n//# sourceMappingURL=ESPromiseScheduler.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+DAWM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"ESPromiseScheduler.js.map","sources":["ESPromiseScheduler.js"],"sourcesContent":["/**\r\n* ESPromiseScheduler.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2019\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport ESPromise from \"./ESPromise\";\r\nimport { _warnToConsole, getGlobal } from \"@microsoft/applicationinsights-core-js\";\r\n/** This is a default timeout that will cause outstanding running promises to be removed/rejected to avoid filling up memory with blocked events */\r\nvar LazyRejectPeriod = 600000; // 10 Minutes\r\n// These are global variables that are shared across ALL instances of the scheduler\r\n/**\r\n * @ignore\r\n */\r\nvar _schedulerId = 0;\r\n/**\r\n * @ignore\r\n */\r\nvar _running = [];\r\n/**\r\n * @ignore\r\n */\r\nvar _waiting = [];\r\n/**\r\n * @ignore\r\n */\r\nvar _timedOut = [];\r\n/**\r\n * @ignore\r\n */\r\nfunction _getTime() {\r\n return new Date().getTime();\r\n}\r\n/**\r\n * Provides a simple mechanism queueing mechanism for scheduling events based on the ESPromise callbacks, this is used to ensure\r\n * order of async operations that are required to be executed in a specific order.\r\n */\r\nvar ESPromiseScheduler = /** @class */ (function () {\r\n function ESPromiseScheduler(name, diagLog) {\r\n var _promiseId = 0;\r\n var _scheduledName = (name || \"<unnamed>\") + \".\" + _schedulerId;\r\n _schedulerId++;\r\n dynamicProto(ESPromiseScheduler, this, function (_this) {\r\n var _lastEvent = null;\r\n var _eventCount = 0;\r\n _this.scheduleEvent = function (startEventAction, eventName, timeout) {\r\n var uniqueId = _scheduledName + \".\" + _eventCount;\r\n _eventCount++;\r\n if (eventName) {\r\n uniqueId += \"-(\" + eventName + \")\";\r\n }\r\n var uniqueEventId = uniqueId + \"{\" + _promiseId + \"}\";\r\n _promiseId++;\r\n // Create the next scheduled event details\r\n var newScheduledEvent = {\r\n evt: null,\r\n tm: _getTime(),\r\n id: uniqueEventId,\r\n isRunning: false,\r\n isAborted: false\r\n };\r\n if (!_lastEvent) {\r\n // We don't have any currently running event, so just start the next event\r\n newScheduledEvent.evt = _startWaitingEvent(newScheduledEvent);\r\n }\r\n else {\r\n // Start a new promise which will wait until all current active events are complete before starting\r\n // the new event, it does not resolve this scheduled event until after the new event is resolve to\r\n // ensure that all scheduled events are completed in the correct order\r\n newScheduledEvent.evt = _waitForPreviousEvent(newScheduledEvent, _lastEvent);\r\n }\r\n // Set this new event as the last one, so that any future events will wait for this one\r\n _lastEvent = newScheduledEvent;\r\n _lastEvent.evt._schId = uniqueEventId;\r\n return newScheduledEvent.evt;\r\n function _abortAndRemoveOldEvents(eventQueue) {\r\n var now = _getTime();\r\n var expired = now - LazyRejectPeriod;\r\n var len = eventQueue.length;\r\n var lp = 0;\r\n while (lp < len) {\r\n var evt = eventQueue[lp];\r\n if (evt && evt.tm < expired) {\r\n var message = null;\r\n if (evt.abort) {\r\n message = \"Aborting [\" + evt.id + \"] due to Excessive runtime (\" + (now - evt.tm) + \" ms)\";\r\n evt.abort(message);\r\n }\r\n else {\r\n message = \"Removing [\" + evt.id + \"] due to Excessive runtime (\" + (now - evt.tm) + \" ms)\";\r\n }\r\n _warnLog(message);\r\n eventQueue.splice(lp, 1);\r\n len--;\r\n }\r\n else {\r\n lp++;\r\n }\r\n }\r\n }\r\n function _cleanup(eventId, completed) {\r\n var toQueue = false;\r\n var removed = _removeQueuedEvent(_running, eventId);\r\n if (!removed) {\r\n removed = _removeQueuedEvent(_timedOut, eventId);\r\n toQueue = true;\r\n }\r\n if (removed) {\r\n if (removed.to) {\r\n // If there was a timeout stop it\r\n clearTimeout(removed.to);\r\n removed.to = null;\r\n }\r\n // TODO (newylie): Convert this into reportable metrics\r\n var tm = _getTime() - removed.tm;\r\n if (completed) {\r\n if (!toQueue) {\r\n _debugLog(\"Promise [\" + eventId + \"] Complete -- \" + tm + \" ms\");\r\n }\r\n else {\r\n _warnLog(\"Timed out event [\" + eventId + \"] finally complete -- \" + tm + \" ms\");\r\n }\r\n }\r\n else {\r\n _timedOut.push(removed);\r\n _warnLog(\"Event [\" + eventId + \"] Timed out and removed -- \" + tm + \" ms\");\r\n }\r\n }\r\n else {\r\n _debugLog(\"Failed to remove [\" + eventId + \"] from running queue\");\r\n }\r\n // Also if the last scheduled event was this event then clear it as we are now finished\r\n if (_lastEvent && _lastEvent.id === eventId) {\r\n _lastEvent = null;\r\n }\r\n _abortAndRemoveOldEvents(_running);\r\n _abortAndRemoveOldEvents(_waiting);\r\n _abortAndRemoveOldEvents(_timedOut);\r\n }\r\n // Return a callback function that will be called when the waiting promise is resolved or rejected to ensure\r\n // that any outer promise is also resolved or rejected\r\n function _removeScheduledEvent(eventId, callback) {\r\n return function (value) {\r\n _cleanup(eventId, true);\r\n callback && callback(value);\r\n return value;\r\n };\r\n }\r\n function _waitForFinalResult(eventId, startResult, schEventResolve, schEventReject) {\r\n startResult.then(function (value) {\r\n if (value instanceof ESPromise) {\r\n // If the result is a promise then this appears to be a chained result, so wait for this promise to complete\r\n _debugLog(\"Event [\" + eventId + \"] returned a promise -- waiting\");\r\n _waitForFinalResult(eventId, value, schEventResolve, schEventReject);\r\n return value;\r\n }\r\n else {\r\n return _removeScheduledEvent(eventId, schEventResolve)(value);\r\n }\r\n }, _removeScheduledEvent(eventId, schEventReject));\r\n }\r\n // Add the passed event to the active event list with resolve and reject callbacks that will remove\r\n // it from the active event list\r\n function _createScheduledEvent(eventDetails, startEvent) {\r\n var eventId = eventDetails.id;\r\n return new ESPromise(function (schEventResolve, schEventReject) {\r\n _debugLog(\"Event [\" + eventId + \"] Starting -- waited for \" + (eventDetails.wTm || \"--\") + \" ms\");\r\n eventDetails.isRunning = true;\r\n eventDetails.abort = function (message) {\r\n eventDetails.abort = null;\r\n eventDetails.isAborted = true;\r\n _cleanup(eventId, false);\r\n schEventReject(new Error(message));\r\n };\r\n var startResult = startEvent(eventId);\r\n if (startResult instanceof ESPromise) {\r\n if (timeout) {\r\n // Note: Only starting a timer if a timeout was specified\r\n eventDetails.to = setTimeout(function () {\r\n _cleanup(eventId, false);\r\n // Cause the listeners to reject (Note: We can't actually reject the waiting event)\r\n schEventReject(new Error(\"Timed out after [\" + timeout + \"] ms\"));\r\n }, timeout);\r\n }\r\n _waitForFinalResult(eventId, startResult, function (theResult) {\r\n _debugLog(\"Event [\" + eventId + \"] Resolving after \" + (_getTime() - eventDetails.tm) + \" ms\");\r\n schEventResolve(theResult);\r\n }, schEventReject);\r\n }\r\n else {\r\n // The startEvent didn't return a promise so just return a resolved promise\r\n _debugLog(\"Promise [\" + eventId + \"] Auto completed as the start action did not return a promise\");\r\n schEventResolve();\r\n }\r\n });\r\n }\r\n function _startWaitingEvent(eventDetails) {\r\n var now = _getTime();\r\n eventDetails.wTm = now - eventDetails.tm;\r\n eventDetails.tm = now;\r\n if (eventDetails.isAborted) {\r\n return ESPromise.reject(new Error(\"[\" + uniqueId + \"] was aborted\"));\r\n }\r\n _running.push(eventDetails);\r\n return _createScheduledEvent(eventDetails, startEventAction);\r\n }\r\n // Start a new promise which will wait until all current active events are complete before starting\r\n // the new event, it does not resolve this scheduled event until after the new event is resolve to\r\n // ensure that all scheduled events are completed in the correct order\r\n function _waitForPreviousEvent(eventDetails, waitForEvent) {\r\n var waitEvent = new ESPromise(function (waitResolve, waitReject) {\r\n var runTime = _getTime() - waitForEvent.tm;\r\n var prevId = waitForEvent.id;\r\n _debugLog(\"[\" + uniqueId + \"] is waiting for [\" + prevId + \":\" + runTime + \" ms] to complete before starting -- [\" + _waiting.length + \"] waiting and [\" + _running.length + \"] running\");\r\n eventDetails.abort = function (message) {\r\n eventDetails.abort = null;\r\n _removeQueuedEvent(_waiting, uniqueId);\r\n eventDetails.isAborted = true;\r\n waitReject(new Error(message));\r\n };\r\n // Wait for the previous event to complete\r\n waitForEvent.evt.then(function (value) {\r\n _removeQueuedEvent(_waiting, uniqueId);\r\n // Wait for the last event to complete before starting the new one, this ensures the execution\r\n // order so that we don't try and remove events that havn't been committed yet\r\n _startWaitingEvent(eventDetails).then(waitResolve, waitReject);\r\n }, function (reason) {\r\n _removeQueuedEvent(_waiting, uniqueId);\r\n // Wait for the last event to complete before starting the new one, this ensures the execution\r\n // order so that we don't try and remove events that havn't been committed yet\r\n _startWaitingEvent(eventDetails).then(waitResolve, waitReject);\r\n });\r\n });\r\n _waiting.push(eventDetails);\r\n return waitEvent;\r\n }\r\n };\r\n function _removeQueuedEvent(queue, eventId) {\r\n for (var lp = 0; lp < queue.length; lp++) {\r\n if (queue[lp].id === eventId) {\r\n return queue.splice(lp, 1)[0];\r\n }\r\n }\r\n return null;\r\n }\r\n });\r\n function _debugLog(message) {\r\n // Only log if running within test harness\r\n var global = getGlobal();\r\n if (global && global[\"QUnit\"]) {\r\n // tslint:disable-next-line:no-console\r\n console && console.log(\"ESPromiseScheduler[\" + _scheduledName + \"] \" + message);\r\n }\r\n }\r\n function _warnLog(message) {\r\n _warnToConsole(diagLog, \"ESPromiseScheduler[\" + _scheduledName + \"] \" + message);\r\n }\r\n }\r\n ESPromiseScheduler.incomplete = function () {\r\n return _running;\r\n };\r\n ESPromiseScheduler.waitingToStart = function () {\r\n return _waiting;\r\n };\r\n /**\r\n * Schedule an event that will execute the startEvent after all outstanding events are resolved or rejected. This is used to ensure\r\n * order of async operations that are required to be executed in a specific order.\r\n * The returned promise will be resolve or rejected based on the values returned from the doAction.\r\n * @param startEventAction The function to execute to start the event after all outstanding events have completed, will be called asynchronously.\r\n * @param eventName An [Optional] event name to assist with debbuging to understand what events are either waiting to start or still running (incomplete).\r\n * @param timeout An [Optional] timeout\r\n */\r\n ESPromiseScheduler.prototype.scheduleEvent = function (startEventAction, eventName, timeout) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n return ESPromiseScheduler;\r\n}());\r\nexport default ESPromiseScheduler;\r\n//# sourceMappingURL=ESPromiseScheduler.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+DAWM;AACN;AACA;AACA;AACA"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Enums.ts
3
- * @author Abhilash Panwar (abpanwar)
4
- * @copyright Microsoft 2018
5
- * File containing the enums as constants.
6
- */
2
+ * Enums.ts
3
+ * @author Abhilash Panwar (abpanwar)
4
+ * @copyright Microsoft 2018
5
+ * File containing the enums as constants.
6
+ */
7
7
  import { _eInternalMessageId } from "@microsoft/applicationinsights-core-js";
8
8
  /**
9
9
  * The eValueKind contains a set of values that specify value kind of the property.
@@ -313,6 +313,7 @@ export declare const _ExtendedInternalMessageId: {
313
313
  TrackPageActionEventFailed: _eInternalMessageId.TrackPageActionEventFailed;
314
314
  FailedAddingCustomDefinedRequestContext: _eInternalMessageId.FailedAddingCustomDefinedRequestContext;
315
315
  InMemoryStorageBufferFull: _eInternalMessageId.InMemoryStorageBufferFull;
316
+ InstrumentationKeyDeprecation: _eInternalMessageId.InstrumentationKeyDeprecation;
316
317
  };
317
318
  export declare type _ExtendedInternalMessageId = number | _eExtendedInternalMessageId | _eInternalMessageId;
318
319
  export declare const enum GuidStyle {