@microsoft/applicationinsights-core-js 3.0.0-beta.2208-03 → 3.0.0-beta.2208-16

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 (121) hide show
  1. package/README.md +7 -0
  2. package/browser/applicationinsights-core-js.integrity.json +9 -9
  3. package/browser/applicationinsights-core-js.js +2040 -2155
  4. package/browser/applicationinsights-core-js.js.map +1 -1
  5. package/browser/applicationinsights-core-js.min.js +2 -2
  6. package/browser/applicationinsights-core-js.min.js.map +1 -1
  7. package/dist/applicationinsights-core-js.api.json +6998 -10817
  8. package/dist/applicationinsights-core-js.api.md +88 -177
  9. package/dist/applicationinsights-core-js.d.ts +94 -494
  10. package/dist/applicationinsights-core-js.js +2040 -2155
  11. package/dist/applicationinsights-core-js.js.map +1 -1
  12. package/dist/applicationinsights-core-js.min.js +2 -2
  13. package/dist/applicationinsights-core-js.min.js.map +1 -1
  14. package/dist/applicationinsights-core-js.rollup.d.ts +94 -494
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +2 -2
  16. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseCore.js +11 -12
  18. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +3 -2
  20. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/ChannelController.js +2 -2
  22. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +27 -26
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +8 -140
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
  28. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +3 -3
  30. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js.map +1 -1
  31. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +4 -3
  32. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  33. package/dist-esm/JavaScriptSDK/EnvUtils.js +132 -136
  34. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  35. package/dist-esm/JavaScriptSDK/EventHelpers.js +2 -3
  36. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  37. package/dist-esm/JavaScriptSDK/HelperFuncs.js +23 -470
  38. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +5 -5
  40. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/InternalConstants.js +4 -4
  42. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/NotificationManager.js +2 -2
  44. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/PerfManager.js +4 -8
  46. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +3 -3
  48. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +2 -2
  51. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -3
  53. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +2 -3
  55. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  56. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +2 -2
  57. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +5 -31
  59. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -1
  60. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  86. package/dist-esm/__DynamicConstants.js +11 -13
  87. package/dist-esm/__DynamicConstants.js.map +1 -1
  88. package/dist-esm/applicationinsights-core-js.js +6 -5
  89. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  90. package/package.json +4 -3
  91. package/src/JavaScriptSDK/AppInsightsCore.ts +1 -1
  92. package/src/JavaScriptSDK/BaseCore.ts +2 -4
  93. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +2 -1
  94. package/src/JavaScriptSDK/ChannelController.ts +1 -1
  95. package/src/JavaScriptSDK/CookieMgr.ts +6 -5
  96. package/src/JavaScriptSDK/CoreUtils.ts +7 -423
  97. package/src/JavaScriptSDK/DbgExtensionUtils.ts +2 -2
  98. package/src/JavaScriptSDK/DiagnosticLogger.ts +3 -2
  99. package/src/JavaScriptSDK/EnvUtils.ts +145 -148
  100. package/src/JavaScriptSDK/EventHelpers.ts +1 -2
  101. package/src/JavaScriptSDK/HelperFuncs.ts +22 -536
  102. package/src/JavaScriptSDK/InstrumentHooks.ts +4 -4
  103. package/src/JavaScriptSDK/InternalConstants.ts +3 -3
  104. package/src/JavaScriptSDK/NotificationManager.ts +1 -1
  105. package/src/JavaScriptSDK/PerfManager.ts +3 -7
  106. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +4 -4
  107. package/src/JavaScriptSDK/TelemetryHelpers.ts +1 -1
  108. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +2 -2
  109. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +1 -2
  110. package/src/JavaScriptSDK/W3cTraceParent.ts +1 -1
  111. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +5 -36
  112. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +7 -0
  113. package/tsconfig.json +1 -1
  114. package/types/JavaScriptSDK/CoreUtils.d.ts +0 -270
  115. package/types/JavaScriptSDK/EnvUtils.d.ts +0 -65
  116. package/types/JavaScriptSDK/HelperFuncs.d.ts +3 -154
  117. package/types/JavaScriptSDK.Enums/EnumHelperFuncs.d.ts +6 -18
  118. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +6 -0
  119. package/types/__DynamicConstants.d.ts +2 -4
  120. package/types/applicationinsights-core-js.d.ts +5 -4
  121. package/types/tsdoc-metadata.json +1 -1
@@ -1,13 +1,14 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2208-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2208-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
7
  "use strict";
8
- import { getGlobal, strShimObject, strShimPrototype, strShimUndefined } from "@microsoft/applicationinsights-shims";
9
- import { _DYN_CALL, _DYN_INDEX_OF, _DYN_LENGTH, _DYN_NAME, _DYN_SPLIT, _DYN_TO_LOWER_CASE, _DYN_USER_AGENT } from "../__DynamicConstants";
10
- import { isString, isUndefined, strContains } from "./HelperFuncs";
8
+ import { strShimObject, strShimPrototype, strShimUndefined } from "@microsoft/applicationinsights-shims";
9
+ import { getDocument, getInst, getNavigator, hasNavigator, isString, isUndefined } from "@nevware21/ts-utils";
10
+ import { _DYN_LENGTH, _DYN_NAME, _DYN_SPLIT, _DYN_TO_LOWER_CASE, _DYN_USER_AGENT } from "../__DynamicConstants";
11
+ import { strContains } from "./HelperFuncs";
11
12
  import { STR_EMPTY } from "./InternalConstants";
12
13
  /**
13
14
  * This file exists to hold environment utilities that are required to check and
@@ -15,11 +16,7 @@ import { STR_EMPTY } from "./InternalConstants";
15
16
  * only use defined methods (functions) in this class so that users of these
16
17
  * functions/properties only need to include those that are used within their own modules.
17
18
  */
18
- var strWindow = "window";
19
- var strDocument = "document";
20
19
  var strDocumentMode = "documentMode";
21
- var strNavigator = "navigator";
22
- var strHistory = "history";
23
20
  var strLocation = "location";
24
21
  var strConsole = "console";
25
22
  var strPerformance = "performance";
@@ -69,107 +66,107 @@ function _hasProperty(theClass, property) {
69
66
  export function setEnableEnvMocks(enabled) {
70
67
  _enableMocks = enabled;
71
68
  }
72
- /**
73
- * Return the named global object if available, will return null if the object is not available.
74
- * @param name The globally named object
75
- */
76
- export function getGlobalInst(name) {
77
- var gbl = getGlobal();
78
- if (gbl && gbl[name]) {
79
- return gbl[name];
80
- }
81
- // Test workaround, for environments where <global>.window (when global == window) doesn't return the base window
82
- if (name === strWindow && hasWindow()) {
83
- // tslint:disable-next-line: no-angle-bracket-type-assertion
84
- return window;
85
- }
86
- return null;
87
- }
88
- /**
89
- * Checks if window object is available, this is required as we support the API running without a
90
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a window
91
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: window is not defined"
92
- * exception will be thrown.
93
- * Defined as a function to support lazy / late binding environments.
94
- */
95
- export function hasWindow() {
96
- return Boolean(typeof window === strShimObject && window);
97
- }
98
- /**
99
- * Returns the global window object if it is present otherwise null.
100
- * This helper is used to access the window object without causing an exception
101
- * "Uncaught ReferenceError: window is not defined"
102
- */
103
- export function getWindow() {
104
- if (hasWindow()) {
105
- return window;
106
- }
107
- // Return the global instance or null
108
- return getGlobalInst(strWindow);
109
- }
110
- /**
111
- * Checks if document object is available, this is required as we support the API running without a
112
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a document
113
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: document is not defined"
114
- * exception will be thrown.
115
- * Defined as a function to support lazy / late binding environments.
116
- */
117
- export function hasDocument() {
118
- return Boolean(typeof document === strShimObject && document);
119
- }
120
- /**
121
- * Returns the global document object if it is present otherwise null.
122
- * This helper is used to access the document object without causing an exception
123
- * "Uncaught ReferenceError: document is not defined"
124
- */
125
- export function getDocument() {
126
- if (hasDocument()) {
127
- return document;
128
- }
129
- return getGlobalInst(strDocument);
130
- }
131
- /**
132
- * Checks if navigator object is available, this is required as we support the API running without a
133
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator
134
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: navigator is not defined"
135
- * exception will be thrown.
136
- * Defined as a function to support lazy / late binding environments.
137
- */
138
- export function hasNavigator() {
139
- return Boolean(typeof navigator === strShimObject && navigator);
140
- }
141
- /**
142
- * Returns the global navigator object if it is present otherwise null.
143
- * This helper is used to access the navigator object without causing an exception
144
- * "Uncaught ReferenceError: navigator is not defined"
145
- */
146
- export function getNavigator() {
147
- if (hasNavigator()) {
148
- return navigator;
149
- }
150
- return getGlobalInst(strNavigator);
151
- }
152
- /**
153
- * Checks if history object is available, this is required as we support the API running without a
154
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
155
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: history is not defined"
156
- * exception will be thrown.
157
- * Defined as a function to support lazy / late binding environments.
158
- */
159
- export function hasHistory() {
160
- return Boolean(typeof history === strShimObject && history);
161
- }
162
- /**
163
- * Returns the global history object if it is present otherwise null.
164
- * This helper is used to access the history object without causing an exception
165
- * "Uncaught ReferenceError: history is not defined"
166
- */
167
- export function getHistory() {
168
- if (hasHistory()) {
169
- return history;
170
- }
171
- return getGlobalInst(strHistory);
172
- }
69
+ // /**
70
+ // * Return the named global object if available, will return null if the object is not available.
71
+ // * @param name The globally named object
72
+ // */
73
+ // export function getinst<T>(name:string): T {
74
+ // let gbl = getGlobal();
75
+ // if (gbl && gbl[name]) {
76
+ // return gbl[name] as T;
77
+ // }
78
+ // // Test workaround, for environments where <global>.window (when global == window) doesn't return the base window
79
+ // if (name === strWindow && hasWindow()) {
80
+ // // tslint:disable-next-line: no-angle-bracket-type-assertion
81
+ // return <any>window as T;
82
+ // }
83
+ // return null;
84
+ // }
85
+ // /**
86
+ // * Checks if window object is available, this is required as we support the API running without a
87
+ // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a window
88
+ // * object to a local variable or pass as an argument an "Uncaught ReferenceError: window is not defined"
89
+ // * exception will be thrown.
90
+ // * Defined as a function to support lazy / late binding environments.
91
+ // */
92
+ // export const hasWindow = () => boolean = hasWindow;
93
+ // return Boolean(typeof window === strShimObject && window);
94
+ // }
95
+ // /**
96
+ // * Returns the global window object if it is present otherwise null.
97
+ // * This helper is used to access the window object without causing an exception
98
+ // * "Uncaught ReferenceError: window is not defined"
99
+ // */
100
+ // export function getWindow(): Window | null {
101
+ // if (hasWindow()) {
102
+ // return window;
103
+ // }
104
+ // // Return the global instance or null
105
+ // return getInst(strWindow);
106
+ // }
107
+ // /**
108
+ // * Checks if document object is available, this is required as we support the API running without a
109
+ // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a document
110
+ // * object to a local variable or pass as an argument an "Uncaught ReferenceError: document is not defined"
111
+ // * exception will be thrown.
112
+ // * Defined as a function to support lazy / late binding environments.
113
+ // */
114
+ // export function hasDocument(): boolean {
115
+ // return Boolean(typeof document === strShimObject && document);
116
+ // }
117
+ // /**
118
+ // * Returns the global document object if it is present otherwise null.
119
+ // * This helper is used to access the document object without causing an exception
120
+ // * "Uncaught ReferenceError: document is not defined"
121
+ // */
122
+ // export function getDocument(): Document | null {
123
+ // if (hasDocument()) {
124
+ // return document;
125
+ // }
126
+ // return getInst(strDocument);
127
+ // }
128
+ // /**
129
+ // * Checks if navigator object is available, this is required as we support the API running without a
130
+ // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator
131
+ // * object to a local variable or pass as an argument an "Uncaught ReferenceError: navigator is not defined"
132
+ // * exception will be thrown.
133
+ // * Defined as a function to support lazy / late binding environments.
134
+ // */
135
+ // export function hasNavigator(): boolean {
136
+ // return Boolean(typeof navigator === strShimObject && navigator);
137
+ // }
138
+ // /**
139
+ // * Returns the global navigator object if it is present otherwise null.
140
+ // * This helper is used to access the navigator object without causing an exception
141
+ // * "Uncaught ReferenceError: navigator is not defined"
142
+ // */
143
+ // export function getNavigator(): Navigator | null {
144
+ // if (hasNavigator()) {
145
+ // return navigator;
146
+ // }
147
+ // return getInst(strNavigator);
148
+ // }
149
+ // /**
150
+ // * Checks if history object is available, this is required as we support the API running without a
151
+ // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
152
+ // * object to a local variable or pass as an argument an "Uncaught ReferenceError: history is not defined"
153
+ // * exception will be thrown.
154
+ // * Defined as a function to support lazy / late binding environments.
155
+ // */
156
+ // export function hasHistory(): boolean {
157
+ // return Boolean(typeof history === strShimObject && history);
158
+ // }
159
+ // /**
160
+ // * Returns the global history object if it is present otherwise null.
161
+ // * This helper is used to access the history object without causing an exception
162
+ // * "Uncaught ReferenceError: history is not defined"
163
+ // */
164
+ // export function getHistory(): History | null {
165
+ // if (hasHistory()) {
166
+ // return history;
167
+ // }
168
+ // return getInst(strHistory);
169
+ // }
173
170
  /**
174
171
  * Returns the global location object if it is present otherwise null.
175
172
  * This helper is used to access the location object without causing an exception
@@ -177,7 +174,7 @@ export function getHistory() {
177
174
  */
178
175
  export function getLocation(checkForMock) {
179
176
  if (checkForMock && _enableMocks) {
180
- var mockLocation = getGlobalInst("__mockLocation");
177
+ var mockLocation = getInst("__mockLocation");
181
178
  if (mockLocation) {
182
179
  return mockLocation;
183
180
  }
@@ -185,7 +182,7 @@ export function getLocation(checkForMock) {
185
182
  if (typeof location === strShimObject && location) {
186
183
  return location;
187
184
  }
188
- return getGlobalInst(strLocation);
185
+ return getInst(strLocation);
189
186
  }
190
187
  /**
191
188
  * Returns the global console object
@@ -194,7 +191,7 @@ export function getConsole() {
194
191
  if (typeof console !== strShimUndefined) {
195
192
  return console;
196
193
  }
197
- return getGlobalInst(strConsole);
194
+ return getInst(strConsole);
198
195
  }
199
196
  /**
200
197
  * Returns the performance object if it is present otherwise null.
@@ -202,7 +199,7 @@ export function getConsole() {
202
199
  * global instance which could be window or globalThis for a web worker
203
200
  */
204
201
  export function getPerformance() {
205
- return getGlobalInst(strPerformance);
202
+ return getInst(strPerformance);
206
203
  }
207
204
  /**
208
205
  * Checks if JSON object is available, this is required as we support the API running without a
@@ -212,7 +209,7 @@ export function getPerformance() {
212
209
  * Defined as a function to support lazy / late binding environments.
213
210
  */
214
211
  export function hasJSON() {
215
- return Boolean((typeof JSON === strShimObject && JSON) || getGlobalInst(strJSON) !== null);
212
+ return Boolean((typeof JSON === strShimObject && JSON) || getInst(strJSON) !== null);
216
213
  }
217
214
  /**
218
215
  * Returns the global JSON object if it is present otherwise null.
@@ -221,7 +218,7 @@ export function hasJSON() {
221
218
  */
222
219
  export function getJSON() {
223
220
  if (hasJSON()) {
224
- return JSON || getGlobalInst(strJSON);
221
+ return JSON || getInst(strJSON);
225
222
  }
226
223
  return null;
227
224
  }
@@ -231,7 +228,7 @@ export function getJSON() {
231
228
  * global instance which could be window or globalThis for a web worker
232
229
  */
233
230
  export function getCrypto() {
234
- return getGlobalInst(strCrypto);
231
+ return getInst(strCrypto);
235
232
  }
236
233
  /**
237
234
  * Returns the crypto object if it is present otherwise null.
@@ -239,7 +236,7 @@ export function getCrypto() {
239
236
  * global instance which could be window or globalThis for a web worker
240
237
  */
241
238
  export function getMsCrypto() {
242
- return getGlobalInst(strMsCrypto);
239
+ return getInst(strMsCrypto);
243
240
  }
244
241
  /**
245
242
  * Returns whether the environment is reporting that we are running in a React Native Environment
@@ -288,27 +285,26 @@ export function getIEVersion(userAgentStr) {
288
285
  }
289
286
  return null;
290
287
  }
291
- /**
292
- * Returns string representation of an object suitable for diagnostics logging.
293
- */
294
- export function dumpObj(object) {
295
- var objectTypeDump = Object[strShimPrototype].toString[_DYN_CALL /* @min:%2ecall */](object);
296
- var propertyValueDump = STR_EMPTY;
297
- if (objectTypeDump === "[object Error]") {
298
- propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object[_DYN_NAME /* @min:%2ename */] + "'";
299
- }
300
- else if (hasJSON()) {
301
- propertyValueDump = getJSON().stringify(object);
302
- }
303
- return objectTypeDump + propertyValueDump;
304
- }
288
+ // /**
289
+ // * Returns string representation of an object suitable for diagnostics logging.
290
+ // */
291
+ // export function dumpObj(object: any): string {
292
+ // const objectTypeDump: string = Object[strShimPrototype].toString.call(object);
293
+ // let propertyValueDump: string = STR_EMPTY;
294
+ // if (objectTypeDump === "[object Error]") {
295
+ // propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
296
+ // } else if (hasJSON()) {
297
+ // propertyValueDump = getJSON().stringify(object);
298
+ // }
299
+ // return objectTypeDump + propertyValueDump;
300
+ // }
305
301
  export function isSafari(userAgentStr) {
306
302
  if (!userAgentStr || !isString(userAgentStr)) {
307
303
  var navigator_2 = getNavigator() || {};
308
304
  userAgentStr = navigator_2 ? (navigator_2[_DYN_USER_AGENT /* @min:%2euserAgent */] || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() : STR_EMPTY;
309
305
  }
310
306
  var ua = (userAgentStr || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();
311
- return (ua[_DYN_INDEX_OF /* @min:%2eindexOf */]("safari") >= 0);
307
+ return (ua.indexOf("safari") >= 0);
312
308
  }
313
309
  /**
314
310
  * Checks if HTML5 Beacons are supported in the current environment.
@@ -328,8 +324,8 @@ export function isBeaconsSupported() {
328
324
  export function isFetchSupported(withKeepAlive) {
329
325
  var isSupported = false;
330
326
  try {
331
- isSupported = !!getGlobalInst("fetch");
332
- var request = getGlobalInst("Request");
327
+ isSupported = !!getInst("fetch");
328
+ var request = getInst("Request");
333
329
  if (isSupported && withKeepAlive && request) {
334
330
  isSupported = _hasProperty(request, "keepalive");
335
331
  }
@@ -343,7 +339,7 @@ export function useXDomainRequest() {
343
339
  if (_useXDomainRequest === null) {
344
340
  _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
345
341
  if (_useXDomainRequest && isXhrSupported()) {
346
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
342
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials");
347
343
  }
348
344
  }
349
345
  return _useXDomainRequest;
@@ -355,7 +351,7 @@ export function useXDomainRequest() {
355
351
  export function isXhrSupported() {
356
352
  var isSupported = false;
357
353
  try {
358
- var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
354
+ var xmlHttpRequest = getInst(strXMLHttpRequest);
359
355
  isSupported = !!xmlHttpRequest;
360
356
  }
361
357
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"EnvUtils.js.map","sources":["EnvUtils.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { getGlobal, strShimObject, strShimPrototype, strShimUndefined } from \"@microsoft/applicationinsights-shims\";\r\nimport { _DYN_CALL, _DYN_INDEX_OF, _DYN_LENGTH, _DYN_NAME, _DYN_SPLIT, _DYN_TO_LOWER_CASE, _DYN_USER_AGENT } from \"../__DynamicConstants\";\r\nimport { isString, isUndefined, strContains } from \"./HelperFuncs\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\n/**\r\n * This file exists to hold environment utilities that are required to check and\r\n * validate the current operating environment. Unless otherwise required, please\r\n * only use defined methods (functions) in this class so that users of these\r\n * functions/properties only need to include those that are used within their own modules.\r\n */\r\nvar strWindow = \"window\";\r\nvar strDocument = \"document\";\r\nvar strDocumentMode = \"documentMode\";\r\nvar strNavigator = \"navigator\";\r\nvar strHistory = \"history\";\r\nvar strLocation = \"location\";\r\nvar strConsole = \"console\";\r\nvar strPerformance = \"performance\";\r\nvar strJSON = \"JSON\";\r\nvar strCrypto = \"crypto\";\r\nvar strMsCrypto = \"msCrypto\";\r\nvar strReactNative = \"ReactNative\";\r\nvar strMsie = \"msie\";\r\nvar strTrident = \"trident/\";\r\nvar strXMLHttpRequest = \"XMLHttpRequest\";\r\nvar _isTrident = null;\r\nvar _navUserAgentCheck = null;\r\nvar _enableMocks = false;\r\nvar _useXDomainRequest = null;\r\nvar _beaconsSupported = null;\r\nfunction _hasProperty(theClass, property) {\r\n var supported = false;\r\n if (theClass) {\r\n try {\r\n supported = property in theClass;\r\n if (!supported) {\r\n var proto = theClass[strShimPrototype];\r\n if (proto) {\r\n supported = property in proto;\r\n }\r\n }\r\n }\r\n catch (e) {\r\n // Do Nothing\r\n }\r\n if (!supported) {\r\n try {\r\n var tmp = new theClass();\r\n supported = !isUndefined(tmp[property]);\r\n }\r\n catch (e) {\r\n // Do Nothing\r\n }\r\n }\r\n }\r\n return supported;\r\n}\r\n/**\r\n * Enable the lookup of test mock objects if requested\r\n * @param enabled\r\n */\r\nexport function setEnableEnvMocks(enabled) {\r\n _enableMocks = enabled;\r\n}\r\n/**\r\n * Return the named global object if available, will return null if the object is not available.\r\n * @param name The globally named object\r\n */\r\nexport function getGlobalInst(name) {\r\n var gbl = getGlobal();\r\n if (gbl && gbl[name]) {\r\n return gbl[name];\r\n }\r\n // Test workaround, for environments where <global>.window (when global == window) doesn't return the base window\r\n if (name === strWindow && hasWindow()) {\r\n // tslint:disable-next-line: no-angle-bracket-type-assertion\r\n return window;\r\n }\r\n return null;\r\n}\r\n/**\r\n * Checks if window object is available, this is required as we support the API running without a\r\n * window /document (eg. Node server, electron webworkers) and if we attempt to assign a window\r\n * object to a local variable or pass as an argument an \"Uncaught ReferenceError: window is not defined\"\r\n * exception will be thrown.\r\n * Defined as a function to support lazy / late binding environments.\r\n */\r\nexport function hasWindow() {\r\n return Boolean(typeof window === strShimObject && window);\r\n}\r\n/**\r\n * Returns the global window object if it is present otherwise null.\r\n * This helper is used to access the window object without causing an exception\r\n * \"Uncaught ReferenceError: window is not defined\"\r\n */\r\nexport function getWindow() {\r\n if (hasWindow()) {\r\n return window;\r\n }\r\n // Return the global instance or null\r\n return getGlobalInst(strWindow);\r\n}\r\n/**\r\n * Checks if document object is available, this is required as we support the API running without a\r\n * window /document (eg. Node server, electron webworkers) and if we attempt to assign a document\r\n * object to a local variable or pass as an argument an \"Uncaught ReferenceError: document is not defined\"\r\n * exception will be thrown.\r\n * Defined as a function to support lazy / late binding environments.\r\n */\r\nexport function hasDocument() {\r\n return Boolean(typeof document === strShimObject && document);\r\n}\r\n/**\r\n * Returns the global document object if it is present otherwise null.\r\n * This helper is used to access the document object without causing an exception\r\n * \"Uncaught ReferenceError: document is not defined\"\r\n */\r\nexport function getDocument() {\r\n if (hasDocument()) {\r\n return document;\r\n }\r\n return getGlobalInst(strDocument);\r\n}\r\n/**\r\n * Checks if navigator object is available, this is required as we support the API running without a\r\n * window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator\r\n * object to a local variable or pass as an argument an \"Uncaught ReferenceError: navigator is not defined\"\r\n * exception will be thrown.\r\n * Defined as a function to support lazy / late binding environments.\r\n */\r\nexport function hasNavigator() {\r\n return Boolean(typeof navigator === strShimObject && navigator);\r\n}\r\n/**\r\n * Returns the global navigator object if it is present otherwise null.\r\n * This helper is used to access the navigator object without causing an exception\r\n * \"Uncaught ReferenceError: navigator is not defined\"\r\n */\r\nexport function getNavigator() {\r\n if (hasNavigator()) {\r\n return navigator;\r\n }\r\n return getGlobalInst(strNavigator);\r\n}\r\n/**\r\n * Checks if history object is available, this is required as we support the API running without a\r\n * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history\r\n * object to a local variable or pass as an argument an \"Uncaught ReferenceError: history is not defined\"\r\n * exception will be thrown.\r\n * Defined as a function to support lazy / late binding environments.\r\n */\r\nexport function hasHistory() {\r\n return Boolean(typeof history === strShimObject && history);\r\n}\r\n/**\r\n * Returns the global history object if it is present otherwise null.\r\n * This helper is used to access the history object without causing an exception\r\n * \"Uncaught ReferenceError: history is not defined\"\r\n */\r\nexport function getHistory() {\r\n if (hasHistory()) {\r\n return history;\r\n }\r\n return getGlobalInst(strHistory);\r\n}\r\n/**\r\n * Returns the global location object if it is present otherwise null.\r\n * This helper is used to access the location object without causing an exception\r\n * \"Uncaught ReferenceError: location is not defined\"\r\n */\r\nexport function getLocation(checkForMock) {\r\n if (checkForMock && _enableMocks) {\r\n var mockLocation = getGlobalInst(\"__mockLocation\");\r\n if (mockLocation) {\r\n return mockLocation;\r\n }\r\n }\r\n if (typeof location === strShimObject && location) {\r\n return location;\r\n }\r\n return getGlobalInst(strLocation);\r\n}\r\n/**\r\n * Returns the global console object\r\n */\r\nexport function getConsole() {\r\n if (typeof console !== strShimUndefined) {\r\n return console;\r\n }\r\n return getGlobalInst(strConsole);\r\n}\r\n/**\r\n * Returns the performance object if it is present otherwise null.\r\n * This helper is used to access the performance object from the current\r\n * global instance which could be window or globalThis for a web worker\r\n */\r\nexport function getPerformance() {\r\n return getGlobalInst(strPerformance);\r\n}\r\n/**\r\n * Checks if JSON object is available, this is required as we support the API running without a\r\n * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history\r\n * object to a local variable or pass as an argument an \"Uncaught ReferenceError: JSON is not defined\"\r\n * exception will be thrown.\r\n * Defined as a function to support lazy / late binding environments.\r\n */\r\nexport function hasJSON() {\r\n return Boolean((typeof JSON === strShimObject && JSON) || getGlobalInst(strJSON) !== null);\r\n}\r\n/**\r\n * Returns the global JSON object if it is present otherwise null.\r\n * This helper is used to access the JSON object without causing an exception\r\n * \"Uncaught ReferenceError: JSON is not defined\"\r\n */\r\nexport function getJSON() {\r\n if (hasJSON()) {\r\n return JSON || getGlobalInst(strJSON);\r\n }\r\n return null;\r\n}\r\n/**\r\n * Returns the crypto object if it is present otherwise null.\r\n * This helper is used to access the crypto object from the current\r\n * global instance which could be window or globalThis for a web worker\r\n */\r\nexport function getCrypto() {\r\n return getGlobalInst(strCrypto);\r\n}\r\n/**\r\n * Returns the crypto object if it is present otherwise null.\r\n * This helper is used to access the crypto object from the current\r\n * global instance which could be window or globalThis for a web worker\r\n */\r\nexport function getMsCrypto() {\r\n return getGlobalInst(strMsCrypto);\r\n}\r\n/**\r\n * Returns whether the environment is reporting that we are running in a React Native Environment\r\n */\r\nexport function isReactNative() {\r\n // If running in React Native, navigator.product will be populated\r\n var nav = getNavigator();\r\n if (nav && nav.product) {\r\n return nav.product === strReactNative;\r\n }\r\n return false;\r\n}\r\n/**\r\n * Identifies whether the current environment appears to be IE\r\n */\r\nexport function isIE() {\r\n var nav = getNavigator();\r\n if (nav && (nav[_DYN_USER_AGENT /* @min:%2euserAgent */] !== _navUserAgentCheck || _isTrident === null)) {\r\n // Added to support test mocking of the user agent\r\n _navUserAgentCheck = nav[_DYN_USER_AGENT /* @min:%2euserAgent */];\r\n var userAgent = (_navUserAgentCheck || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();\r\n _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));\r\n }\r\n return _isTrident;\r\n}\r\n/**\r\n * Gets IE version returning the document emulation mode if we are running on IE, or null otherwise\r\n */\r\nexport function getIEVersion(userAgentStr) {\r\n if (userAgentStr === void 0) { userAgentStr = null; }\r\n if (!userAgentStr) {\r\n var navigator_1 = getNavigator() || {};\r\n userAgentStr = navigator_1 ? (navigator_1[_DYN_USER_AGENT /* @min:%2euserAgent */] || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() : STR_EMPTY;\r\n }\r\n var ua = (userAgentStr || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();\r\n // Also check for documentMode in case X-UA-Compatible meta tag was included in HTML.\r\n if (strContains(ua, strMsie)) {\r\n var doc = getDocument() || {};\r\n return Math.max(parseInt(ua[_DYN_SPLIT /* @min:%2esplit */](strMsie)[1]), (doc[strDocumentMode] || 0));\r\n }\r\n else if (strContains(ua, strTrident)) {\r\n var tridentVer = parseInt(ua[_DYN_SPLIT /* @min:%2esplit */](strTrident)[1]);\r\n if (tridentVer) {\r\n return tridentVer + 4;\r\n }\r\n }\r\n return null;\r\n}\r\n/**\r\n * Returns string representation of an object suitable for diagnostics logging.\r\n */\r\nexport function dumpObj(object) {\r\n var objectTypeDump = Object[strShimPrototype].toString[_DYN_CALL /* @min:%2ecall */](object);\r\n var propertyValueDump = STR_EMPTY;\r\n if (objectTypeDump === \"[object Error]\") {\r\n propertyValueDump = \"{ stack: '\" + object.stack + \"', message: '\" + object.message + \"', name: '\" + object[_DYN_NAME /* @min:%2ename */] + \"'\";\r\n }\r\n else if (hasJSON()) {\r\n propertyValueDump = getJSON().stringify(object);\r\n }\r\n return objectTypeDump + propertyValueDump;\r\n}\r\nexport function isSafari(userAgentStr) {\r\n if (!userAgentStr || !isString(userAgentStr)) {\r\n var navigator_2 = getNavigator() || {};\r\n userAgentStr = navigator_2 ? (navigator_2[_DYN_USER_AGENT /* @min:%2euserAgent */] || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() : STR_EMPTY;\r\n }\r\n var ua = (userAgentStr || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();\r\n return (ua[_DYN_INDEX_OF /* @min:%2eindexOf */](\"safari\") >= 0);\r\n}\r\n/**\r\n * Checks if HTML5 Beacons are supported in the current environment.\r\n * @returns True if supported, false otherwise.\r\n */\r\nexport function isBeaconsSupported() {\r\n if (_beaconsSupported === null) {\r\n _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);\r\n }\r\n return _beaconsSupported;\r\n}\r\n/**\r\n * Checks if the Fetch API is supported in the current environment.\r\n * @param withKeepAlive - [Optional] If True, check if fetch is available and it supports the keepalive feature, otherwise only check if fetch is supported\r\n * @returns True if supported, otherwise false\r\n */\r\nexport function isFetchSupported(withKeepAlive) {\r\n var isSupported = false;\r\n try {\r\n isSupported = !!getGlobalInst(\"fetch\");\r\n var request = getGlobalInst(\"Request\");\r\n if (isSupported && withKeepAlive && request) {\r\n isSupported = _hasProperty(request, \"keepalive\");\r\n }\r\n }\r\n catch (e) {\r\n // Just Swallow any failure during availability checks\r\n }\r\n return isSupported;\r\n}\r\nexport function useXDomainRequest() {\r\n if (_useXDomainRequest === null) {\r\n _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);\r\n if (_useXDomainRequest && isXhrSupported()) {\r\n _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), \"withCredentials\");\r\n }\r\n }\r\n return _useXDomainRequest;\r\n}\r\n/**\r\n * Checks if XMLHttpRequest is supported\r\n * @returns True if supported, otherwise false\r\n */\r\nexport function isXhrSupported() {\r\n var isSupported = false;\r\n try {\r\n var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);\r\n isSupported = !!xmlHttpRequest;\r\n }\r\n catch (e) {\r\n // Just Swallow any failure during availability checks\r\n }\r\n return isSupported;\r\n}\r\nfunction _getNamedValue(values, name) {\r\n if (values) {\r\n for (var i = 0; i < values[_DYN_LENGTH /* @min:%2elength */]; i++) {\r\n var value = values[i];\r\n if (value[_DYN_NAME /* @min:%2ename */]) {\r\n if (value[_DYN_NAME /* @min:%2ename */] === name) {\r\n return value;\r\n }\r\n }\r\n }\r\n }\r\n return {};\r\n}\r\n/**\r\n * Helper function to fetch the named meta-tag from the page.\r\n * @param name\r\n */\r\nexport function findMetaTag(name) {\r\n var doc = getDocument();\r\n if (doc && name) {\r\n // Look for a meta-tag\r\n return _getNamedValue(doc.querySelectorAll(\"meta\"), name).content;\r\n }\r\n return null;\r\n}\r\n/**\r\n * Helper function to fetch the named server timing value from the page response (first navigation event).\r\n * @param name\r\n */\r\nexport function findNamedServerTiming(name) {\r\n var value;\r\n var perf = getPerformance();\r\n if (perf) {\r\n // Try looking for a server-timing header\r\n var navPerf = perf.getEntriesByType(\"navigation\") || [];\r\n value = _getNamedValue((navPerf[_DYN_LENGTH /* @min:%2elength */] > 0 ? navPerf[0] : {}).serverTiming, name).description;\r\n }\r\n return value;\r\n}\r\n//# sourceMappingURL=EnvUtils.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"EnvUtils.js.map","sources":["EnvUtils.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { strShimObject, strShimPrototype, strShimUndefined } from \"@microsoft/applicationinsights-shims\";\r\nimport { getDocument, getInst, getNavigator, hasNavigator, isString, isUndefined } from \"@nevware21/ts-utils\";\r\nimport { _DYN_LENGTH, _DYN_NAME, _DYN_SPLIT, _DYN_TO_LOWER_CASE, _DYN_USER_AGENT } from \"../__DynamicConstants\";\r\nimport { strContains } from \"./HelperFuncs\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\n/**\r\n * This file exists to hold environment utilities that are required to check and\r\n * validate the current operating environment. Unless otherwise required, please\r\n * only use defined methods (functions) in this class so that users of these\r\n * functions/properties only need to include those that are used within their own modules.\r\n */\r\nvar strDocumentMode = \"documentMode\";\r\nvar strLocation = \"location\";\r\nvar strConsole = \"console\";\r\nvar strPerformance = \"performance\";\r\nvar strJSON = \"JSON\";\r\nvar strCrypto = \"crypto\";\r\nvar strMsCrypto = \"msCrypto\";\r\nvar strReactNative = \"ReactNative\";\r\nvar strMsie = \"msie\";\r\nvar strTrident = \"trident/\";\r\nvar strXMLHttpRequest = \"XMLHttpRequest\";\r\nvar _isTrident = null;\r\nvar _navUserAgentCheck = null;\r\nvar _enableMocks = false;\r\nvar _useXDomainRequest = null;\r\nvar _beaconsSupported = null;\r\nfunction _hasProperty(theClass, property) {\r\n var supported = false;\r\n if (theClass) {\r\n try {\r\n supported = property in theClass;\r\n if (!supported) {\r\n var proto = theClass[strShimPrototype];\r\n if (proto) {\r\n supported = property in proto;\r\n }\r\n }\r\n }\r\n catch (e) {\r\n // Do Nothing\r\n }\r\n if (!supported) {\r\n try {\r\n var tmp = new theClass();\r\n supported = !isUndefined(tmp[property]);\r\n }\r\n catch (e) {\r\n // Do Nothing\r\n }\r\n }\r\n }\r\n return supported;\r\n}\r\n/**\r\n * Enable the lookup of test mock objects if requested\r\n * @param enabled\r\n */\r\nexport function setEnableEnvMocks(enabled) {\r\n _enableMocks = enabled;\r\n}\r\n// /**\r\n// * Return the named global object if available, will return null if the object is not available.\r\n// * @param name The globally named object\r\n// */\r\n// export function getinst<T>(name:string): T {\r\n// let gbl = getGlobal();\r\n// if (gbl && gbl[name]) {\r\n// return gbl[name] as T;\r\n// }\r\n// // Test workaround, for environments where <global>.window (when global == window) doesn't return the base window\r\n// if (name === strWindow && hasWindow()) {\r\n// // tslint:disable-next-line: no-angle-bracket-type-assertion\r\n// return <any>window as T;\r\n// }\r\n// return null;\r\n// }\r\n// /**\r\n// * Checks if window object is available, this is required as we support the API running without a\r\n// * window /document (eg. Node server, electron webworkers) and if we attempt to assign a window\r\n// * object to a local variable or pass as an argument an \"Uncaught ReferenceError: window is not defined\"\r\n// * exception will be thrown.\r\n// * Defined as a function to support lazy / late binding environments.\r\n// */\r\n// export const hasWindow = () => boolean = hasWindow;\r\n// return Boolean(typeof window === strShimObject && window);\r\n// }\r\n// /**\r\n// * Returns the global window object if it is present otherwise null.\r\n// * This helper is used to access the window object without causing an exception\r\n// * \"Uncaught ReferenceError: window is not defined\"\r\n// */\r\n// export function getWindow(): Window | null {\r\n// if (hasWindow()) {\r\n// return window;\r\n// }\r\n// // Return the global instance or null\r\n// return getInst(strWindow);\r\n// }\r\n// /**\r\n// * Checks if document object is available, this is required as we support the API running without a\r\n// * window /document (eg. Node server, electron webworkers) and if we attempt to assign a document\r\n// * object to a local variable or pass as an argument an \"Uncaught ReferenceError: document is not defined\"\r\n// * exception will be thrown.\r\n// * Defined as a function to support lazy / late binding environments.\r\n// */\r\n// export function hasDocument(): boolean {\r\n// return Boolean(typeof document === strShimObject && document);\r\n// }\r\n// /**\r\n// * Returns the global document object if it is present otherwise null.\r\n// * This helper is used to access the document object without causing an exception\r\n// * \"Uncaught ReferenceError: document is not defined\"\r\n// */\r\n// export function getDocument(): Document | null {\r\n// if (hasDocument()) {\r\n// return document;\r\n// }\r\n// return getInst(strDocument);\r\n// }\r\n// /**\r\n// * Checks if navigator object is available, this is required as we support the API running without a\r\n// * window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator\r\n// * object to a local variable or pass as an argument an \"Uncaught ReferenceError: navigator is not defined\"\r\n// * exception will be thrown.\r\n// * Defined as a function to support lazy / late binding environments.\r\n// */\r\n// export function hasNavigator(): boolean {\r\n// return Boolean(typeof navigator === strShimObject && navigator);\r\n// }\r\n// /**\r\n// * Returns the global navigator object if it is present otherwise null.\r\n// * This helper is used to access the navigator object without causing an exception\r\n// * \"Uncaught ReferenceError: navigator is not defined\"\r\n// */\r\n// export function getNavigator(): Navigator | null {\r\n// if (hasNavigator()) {\r\n// return navigator;\r\n// }\r\n// return getInst(strNavigator);\r\n// }\r\n// /**\r\n// * Checks if history object is available, this is required as we support the API running without a\r\n// * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history\r\n// * object to a local variable or pass as an argument an \"Uncaught ReferenceError: history is not defined\"\r\n// * exception will be thrown.\r\n// * Defined as a function to support lazy / late binding environments.\r\n// */\r\n// export function hasHistory(): boolean {\r\n// return Boolean(typeof history === strShimObject && history);\r\n// }\r\n// /**\r\n// * Returns the global history object if it is present otherwise null.\r\n// * This helper is used to access the history object without causing an exception\r\n// * \"Uncaught ReferenceError: history is not defined\"\r\n// */\r\n// export function getHistory(): History | null {\r\n// if (hasHistory()) {\r\n// return history;\r\n// }\r\n// return getInst(strHistory);\r\n// }\r\n/**\r\n * Returns the global location object if it is present otherwise null.\r\n * This helper is used to access the location object without causing an exception\r\n * \"Uncaught ReferenceError: location is not defined\"\r\n */\r\nexport function getLocation(checkForMock) {\r\n if (checkForMock && _enableMocks) {\r\n var mockLocation = getInst(\"__mockLocation\");\r\n if (mockLocation) {\r\n return mockLocation;\r\n }\r\n }\r\n if (typeof location === strShimObject && location) {\r\n return location;\r\n }\r\n return getInst(strLocation);\r\n}\r\n/**\r\n * Returns the global console object\r\n */\r\nexport function getConsole() {\r\n if (typeof console !== strShimUndefined) {\r\n return console;\r\n }\r\n return getInst(strConsole);\r\n}\r\n/**\r\n * Returns the performance object if it is present otherwise null.\r\n * This helper is used to access the performance object from the current\r\n * global instance which could be window or globalThis for a web worker\r\n */\r\nexport function getPerformance() {\r\n return getInst(strPerformance);\r\n}\r\n/**\r\n * Checks if JSON object is available, this is required as we support the API running without a\r\n * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history\r\n * object to a local variable or pass as an argument an \"Uncaught ReferenceError: JSON is not defined\"\r\n * exception will be thrown.\r\n * Defined as a function to support lazy / late binding environments.\r\n */\r\nexport function hasJSON() {\r\n return Boolean((typeof JSON === strShimObject && JSON) || getInst(strJSON) !== null);\r\n}\r\n/**\r\n * Returns the global JSON object if it is present otherwise null.\r\n * This helper is used to access the JSON object without causing an exception\r\n * \"Uncaught ReferenceError: JSON is not defined\"\r\n */\r\nexport function getJSON() {\r\n if (hasJSON()) {\r\n return JSON || getInst(strJSON);\r\n }\r\n return null;\r\n}\r\n/**\r\n * Returns the crypto object if it is present otherwise null.\r\n * This helper is used to access the crypto object from the current\r\n * global instance which could be window or globalThis for a web worker\r\n */\r\nexport function getCrypto() {\r\n return getInst(strCrypto);\r\n}\r\n/**\r\n * Returns the crypto object if it is present otherwise null.\r\n * This helper is used to access the crypto object from the current\r\n * global instance which could be window or globalThis for a web worker\r\n */\r\nexport function getMsCrypto() {\r\n return getInst(strMsCrypto);\r\n}\r\n/**\r\n * Returns whether the environment is reporting that we are running in a React Native Environment\r\n */\r\nexport function isReactNative() {\r\n // If running in React Native, navigator.product will be populated\r\n var nav = getNavigator();\r\n if (nav && nav.product) {\r\n return nav.product === strReactNative;\r\n }\r\n return false;\r\n}\r\n/**\r\n * Identifies whether the current environment appears to be IE\r\n */\r\nexport function isIE() {\r\n var nav = getNavigator();\r\n if (nav && (nav[_DYN_USER_AGENT /* @min:%2euserAgent */] !== _navUserAgentCheck || _isTrident === null)) {\r\n // Added to support test mocking of the user agent\r\n _navUserAgentCheck = nav[_DYN_USER_AGENT /* @min:%2euserAgent */];\r\n var userAgent = (_navUserAgentCheck || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();\r\n _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));\r\n }\r\n return _isTrident;\r\n}\r\n/**\r\n * Gets IE version returning the document emulation mode if we are running on IE, or null otherwise\r\n */\r\nexport function getIEVersion(userAgentStr) {\r\n if (userAgentStr === void 0) { userAgentStr = null; }\r\n if (!userAgentStr) {\r\n var navigator_1 = getNavigator() || {};\r\n userAgentStr = navigator_1 ? (navigator_1[_DYN_USER_AGENT /* @min:%2euserAgent */] || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() : STR_EMPTY;\r\n }\r\n var ua = (userAgentStr || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();\r\n // Also check for documentMode in case X-UA-Compatible meta tag was included in HTML.\r\n if (strContains(ua, strMsie)) {\r\n var doc = getDocument() || {};\r\n return Math.max(parseInt(ua[_DYN_SPLIT /* @min:%2esplit */](strMsie)[1]), (doc[strDocumentMode] || 0));\r\n }\r\n else if (strContains(ua, strTrident)) {\r\n var tridentVer = parseInt(ua[_DYN_SPLIT /* @min:%2esplit */](strTrident)[1]);\r\n if (tridentVer) {\r\n return tridentVer + 4;\r\n }\r\n }\r\n return null;\r\n}\r\n// /**\r\n// * Returns string representation of an object suitable for diagnostics logging.\r\n// */\r\n// export function dumpObj(object: any): string {\r\n// const objectTypeDump: string = Object[strShimPrototype].toString.call(object);\r\n// let propertyValueDump: string = STR_EMPTY;\r\n// if (objectTypeDump === \"[object Error]\") {\r\n// propertyValueDump = \"{ stack: '\" + object.stack + \"', message: '\" + object.message + \"', name: '\" + object.name + \"'\";\r\n// } else if (hasJSON()) {\r\n// propertyValueDump = getJSON().stringify(object);\r\n// }\r\n// return objectTypeDump + propertyValueDump;\r\n// }\r\nexport function isSafari(userAgentStr) {\r\n if (!userAgentStr || !isString(userAgentStr)) {\r\n var navigator_2 = getNavigator() || {};\r\n userAgentStr = navigator_2 ? (navigator_2[_DYN_USER_AGENT /* @min:%2euserAgent */] || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() : STR_EMPTY;\r\n }\r\n var ua = (userAgentStr || STR_EMPTY)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]();\r\n return (ua.indexOf(\"safari\") >= 0);\r\n}\r\n/**\r\n * Checks if HTML5 Beacons are supported in the current environment.\r\n * @returns True if supported, false otherwise.\r\n */\r\nexport function isBeaconsSupported() {\r\n if (_beaconsSupported === null) {\r\n _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);\r\n }\r\n return _beaconsSupported;\r\n}\r\n/**\r\n * Checks if the Fetch API is supported in the current environment.\r\n * @param withKeepAlive - [Optional] If True, check if fetch is available and it supports the keepalive feature, otherwise only check if fetch is supported\r\n * @returns True if supported, otherwise false\r\n */\r\nexport function isFetchSupported(withKeepAlive) {\r\n var isSupported = false;\r\n try {\r\n isSupported = !!getInst(\"fetch\");\r\n var request = getInst(\"Request\");\r\n if (isSupported && withKeepAlive && request) {\r\n isSupported = _hasProperty(request, \"keepalive\");\r\n }\r\n }\r\n catch (e) {\r\n // Just Swallow any failure during availability checks\r\n }\r\n return isSupported;\r\n}\r\nexport function useXDomainRequest() {\r\n if (_useXDomainRequest === null) {\r\n _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);\r\n if (_useXDomainRequest && isXhrSupported()) {\r\n _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), \"withCredentials\");\r\n }\r\n }\r\n return _useXDomainRequest;\r\n}\r\n/**\r\n * Checks if XMLHttpRequest is supported\r\n * @returns True if supported, otherwise false\r\n */\r\nexport function isXhrSupported() {\r\n var isSupported = false;\r\n try {\r\n var xmlHttpRequest = getInst(strXMLHttpRequest);\r\n isSupported = !!xmlHttpRequest;\r\n }\r\n catch (e) {\r\n // Just Swallow any failure during availability checks\r\n }\r\n return isSupported;\r\n}\r\nfunction _getNamedValue(values, name) {\r\n if (values) {\r\n for (var i = 0; i < values[_DYN_LENGTH /* @min:%2elength */]; i++) {\r\n var value = values[i];\r\n if (value[_DYN_NAME /* @min:%2ename */]) {\r\n if (value[_DYN_NAME /* @min:%2ename */] === name) {\r\n return value;\r\n }\r\n }\r\n }\r\n }\r\n return {};\r\n}\r\n/**\r\n * Helper function to fetch the named meta-tag from the page.\r\n * @param name\r\n */\r\nexport function findMetaTag(name) {\r\n var doc = getDocument();\r\n if (doc && name) {\r\n // Look for a meta-tag\r\n return _getNamedValue(doc.querySelectorAll(\"meta\"), name).content;\r\n }\r\n return null;\r\n}\r\n/**\r\n * Helper function to fetch the named server timing value from the page response (first navigation event).\r\n * @param name\r\n */\r\nexport function findNamedServerTiming(name) {\r\n var value;\r\n var perf = getPerformance();\r\n if (perf) {\r\n // Try looking for a server-timing header\r\n var navPerf = perf.getEntriesByType(\"navigation\") || [];\r\n value = _getNamedValue((navPerf[_DYN_LENGTH /* @min:%2elength */] > 0 ? navPerf[0] : {}).serverTiming, name).description;\r\n }\r\n return value;\r\n}\r\n//# sourceMappingURL=EnvUtils.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,13 +1,12 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2208-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2208-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
+ import { arrForEach, arrIndexOf, getDocument, getWindow, isArray, objForEachKey, objKeys } from "@nevware21/ts-utils";
7
8
  import { _DYN_HANDLER, _DYN_LENGTH, _DYN_NAME, _DYN_PUSH, _DYN_REPLACE, _DYN_SPLICE, _DYN_SPLIT, _DYN_TYPE } from "../__DynamicConstants";
8
9
  import { createElmNodeData, createUniqueNamespace } from "./DataCacheHelper";
9
- import { getDocument, getWindow } from "./EnvUtils";
10
- import { arrForEach, arrIndexOf, isArray, objForEachKey, objKeys } from "./HelperFuncs";
11
10
  import { STR_EMPTY } from "./InternalConstants";
12
11
  // Added to help with minfication
13
12
  var strOnPrefix = "on";