@microsoft/1ds-core-js 3.2.10 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +1 -1
  2. package/bundle/es5/ms.core-4.0.0.gbl.js +6221 -0
  3. package/bundle/es5/ms.core-4.0.0.gbl.js.map +1 -0
  4. package/bundle/es5/ms.core-4.0.0.gbl.min.js +7 -0
  5. package/bundle/es5/ms.core-4.0.0.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.core-4.0.0.integrity.json +46 -0
  7. package/bundle/es5/ms.core-4.0.0.js +6225 -0
  8. package/bundle/es5/ms.core-4.0.0.js.map +1 -0
  9. package/bundle/es5/ms.core-4.0.0.min.js +7 -0
  10. package/bundle/es5/ms.core-4.0.0.min.js.map +1 -0
  11. package/bundle/es5/ms.core.gbl.js +6221 -0
  12. package/bundle/es5/ms.core.gbl.js.map +1 -0
  13. package/bundle/es5/ms.core.gbl.min.js +7 -0
  14. package/bundle/es5/ms.core.gbl.min.js.map +1 -0
  15. package/bundle/es5/ms.core.integrity.json +46 -0
  16. package/bundle/es5/ms.core.js +6225 -0
  17. package/bundle/es5/ms.core.js.map +1 -0
  18. package/bundle/es5/ms.core.min.js +7 -0
  19. package/bundle/es5/ms.core.min.js.map +1 -0
  20. package/{bundle → dist/es5}/ms.core.js +3798 -2954
  21. package/dist/es5/ms.core.js.map +1 -0
  22. package/dist/es5/ms.core.min.js +7 -0
  23. package/dist/es5/ms.core.min.js.map +1 -0
  24. package/dist-es5/AppInsightsCore.js +91 -0
  25. package/dist-es5/AppInsightsCore.js.map +1 -0
  26. package/{dist-esm/src → dist-es5}/BaseCore.js +18 -11
  27. package/dist-es5/BaseCore.js.map +1 -0
  28. package/{dist-esm/src → dist-es5}/DataModels.js +1 -1
  29. package/{dist-esm/src → dist-es5}/Enums.js +3 -26
  30. package/dist-es5/Enums.js.map +1 -0
  31. package/{dist-esm/src → dist-es5}/Index.js +9 -14
  32. package/dist-es5/Index.js.map +1 -0
  33. package/{dist-esm/src → dist-es5}/InternalConstants.js +1 -3
  34. package/{dist-esm/src → dist-es5}/InternalConstants.js.map +1 -1
  35. package/{dist-esm/src → dist-es5}/Utils.js +19 -144
  36. package/dist-es5/Utils.js.map +1 -0
  37. package/{dist-esm/src → dist-es5}/ValueSanitizer.js +39 -3
  38. package/dist-es5/ValueSanitizer.js.map +1 -0
  39. package/package.json +18 -10
  40. package/tsconfig.json +5 -3
  41. package/types/1ds-core-js.d.ts +1106 -0
  42. package/types/1ds-core-js.namespaced.d.ts +1102 -0
  43. package/bundle/ms.core-3.2.10.gbl.js +0 -5357
  44. package/bundle/ms.core-3.2.10.gbl.js.map +0 -1
  45. package/bundle/ms.core-3.2.10.gbl.min.js +0 -7
  46. package/bundle/ms.core-3.2.10.gbl.min.js.map +0 -1
  47. package/bundle/ms.core-3.2.10.integrity.json +0 -46
  48. package/bundle/ms.core-3.2.10.js +0 -5360
  49. package/bundle/ms.core-3.2.10.js.map +0 -1
  50. package/bundle/ms.core-3.2.10.min.js +0 -7
  51. package/bundle/ms.core-3.2.10.min.js.map +0 -1
  52. package/bundle/ms.core.gbl.js +0 -5357
  53. package/bundle/ms.core.gbl.js.map +0 -1
  54. package/bundle/ms.core.gbl.min.js +0 -7
  55. package/bundle/ms.core.gbl.min.js.map +0 -1
  56. package/bundle/ms.core.integrity.json +0 -46
  57. package/bundle/ms.core.js.map +0 -1
  58. package/bundle/ms.core.min.js +0 -7
  59. package/bundle/ms.core.min.js.map +0 -1
  60. package/dist/ms.core.js +0 -1305
  61. package/dist/ms.core.js.map +0 -1
  62. package/dist/ms.core.min.js +0 -7
  63. package/dist/ms.core.min.js.map +0 -1
  64. package/dist-esm/src/AppInsightsCore.d.ts +0 -15
  65. package/dist-esm/src/AppInsightsCore.js +0 -114
  66. package/dist-esm/src/AppInsightsCore.js.map +0 -1
  67. package/dist-esm/src/BaseCore.d.ts +0 -13
  68. package/dist-esm/src/BaseCore.js.map +0 -1
  69. package/dist-esm/src/DataModels.d.ts +0 -273
  70. package/dist-esm/src/ESPromise.d.ts +0 -110
  71. package/dist-esm/src/ESPromise.js +0 -286
  72. package/dist-esm/src/ESPromise.js.map +0 -1
  73. package/dist-esm/src/ESPromiseScheduler.d.ts +0 -36
  74. package/dist-esm/src/ESPromiseScheduler.js +0 -274
  75. package/dist-esm/src/ESPromiseScheduler.js.map +0 -1
  76. package/dist-esm/src/Enums.d.ts +0 -356
  77. package/dist-esm/src/Enums.js.map +0 -1
  78. package/dist-esm/src/Index.d.ts +0 -19
  79. package/dist-esm/src/Index.js.map +0 -1
  80. package/dist-esm/src/InternalConstants.d.ts +0 -6
  81. package/dist-esm/src/Utils.d.ts +0 -190
  82. package/dist-esm/src/Utils.js.map +0 -1
  83. package/dist-esm/src/ValueSanitizer.d.ts +0 -40
  84. package/dist-esm/src/ValueSanitizer.js.map +0 -1
  85. package/src/AppInsightsCore.ts +0 -135
  86. package/src/BaseCore.ts +0 -72
  87. package/src/DataModels.ts +0 -297
  88. package/src/ESPromise.ts +0 -365
  89. package/src/ESPromiseScheduler.ts +0 -328
  90. package/src/Enums.ts +0 -386
  91. package/src/Index.ts +0 -81
  92. package/src/InternalConstants.ts +0 -16
  93. package/src/Utils.ts +0 -565
  94. package/src/ValueSanitizer.ts +0 -285
  95. /package/{dist-esm/src → dist-es5}/DataModels.js.map +0 -0
package/src/ESPromise.ts DELETED
@@ -1,365 +0,0 @@
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
- */
7
-
8
- import dynamicProto from "@microsoft/dynamicproto-js";
9
- import { isFunction } from "@microsoft/applicationinsights-core-js";
10
-
11
- /**
12
- * @ignore -- Don't include in the generated documentation
13
- */
14
- const enum PromiseState {
15
- Pending = 0,
16
- Resolved = 1,
17
- Rejected = 2
18
- }
19
-
20
- /**
21
- * @ignore -- Don't include in the generated documentation
22
- * Using a local variable to assist with minfication
23
- */
24
- var _isFunction = isFunction;
25
-
26
- /**
27
- * @ignore -- Don't include in the generated documentation
28
- * This function will be used as onFulfilled handler for any Promise found in the iterable passed to Promise.all.
29
- * The goal here is to capture in a closure the index of the current item from the iterable. If we did not create
30
- * this closure, the captured index variable would be the same one that the for loop updates and thus would always
31
- * be pointing to the last index in the iterable by the time that the onFulfilled handler is called.
32
- * However, note that for the resolvedCallback callback we want the opposite. For this one we do want to capture
33
- * the same variable that the for loop updates so that we have the full count of pending promises by the time
34
- * the onFulfilled handlers start getting called.
35
- * @param values The resolving promise values
36
- * @param index The index of this callback function
37
- * @param resolvedCallback THe callback function used to check if the "all" promise is complete
38
- */
39
- function _createPromiseAllOnResolvedFunction(values: any[], index: number, resolvedCallback: VoidFunction) {
40
- return (value: any) => {
41
- values[index] = value;
42
- resolvedCallback();
43
- };
44
- }
45
-
46
- /**
47
- * This defines the handler function for when a promise is resolved.
48
- * @param value This is the value passed as part of resolving the Promise
49
- * @return This may return a value, another Promise or void. See [[then]] for how the value is handled.
50
- */
51
- export type ESPromiseOnResolvedFunc<T> = (value: T) => T|ESPromise<T|any>|void;
52
-
53
- /**
54
- * This defines the handler function for when a promise is rejected.
55
- * @param value This is the value passed as part of resolving the Promise
56
- * @return This may return a value, another Promise or void. @see then for how the value is handled.
57
- */
58
- export type ESPromiseOnRejectedFunc<T> = (reason: any) => T|ESPromise<T|any>|void;
59
-
60
- /**
61
- * Defines the signature of the resolve function passed to the resolverFunc (in the Promise constructor)
62
- * @param value The value to resolve the Promise with
63
- * @returns Nothing
64
- */
65
- export type ResolverResolveFunc<T> = (value?: T|void) => void;
66
-
67
- /**
68
- * Defines the signature of the reject function passed to the resolverFunc (in the Promise constructor)
69
- * @param value The value to reject the Promise with
70
- * @returns Nothing
71
- */
72
- export type ResolverRejectFunc<T> = (reason?: T|Error|void) => void;
73
-
74
- /**
75
- * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
76
- */
77
- export default class ESPromise<T> {
78
-
79
- /**
80
- * 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;
81
- * if the value is a thenable (i.e. has a "then" method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise
82
- * the returned promise will be fulfilled with the value. This function flattens nested layers of promise-like objects (e.g. a promise that resolves
83
- * to a promise that resolves to something) into a single layer.
84
- * @param value Argument to be resolved by this Promise. Can also be a Promise or a thenable to resolve.
85
- */
86
- public static resolve<T>(value?: any) {
87
- if (value instanceof ESPromise) {
88
- // Value is a Promise so just return it
89
- return value;
90
- } else if (value && _isFunction(value.then)) {
91
- // Value looks like a promise or thenable (has a then function)
92
- return new ESPromise((resolve, reject) => {
93
- try {
94
- value.then(resolve, reject);
95
- } catch (error) {
96
- reject(error);
97
- }
98
- });
99
- }
100
-
101
- return new ESPromise<T>((resolve) => {
102
- resolve(value);
103
- });
104
- }
105
-
106
- /**
107
- * The Promise.reject() method returns a Promise object that is rejected with a given reason.
108
- * @param reason The reason why this Promise rejected.
109
- */
110
- public static reject<T>(reason?: T | Error | void) {
111
- return new ESPromise<T>((resolve, reject) => {
112
- reject(reason);
113
- });
114
- }
115
-
116
- /**
117
- * The Promise.all() method returns a single Promise that resolves when all of the promises passed as an iterable
118
- * have resolved or when the iterable contains no promises. It rejects with the reason of the first promise that
119
- * rejects. There is no implied ordering in the execution of the array of Promises given. On some computers, they
120
- * may be executed in parallel, or in some sense concurrently, while on others they may be executed serially. For
121
- * this reason, there must be no dependency in any Promise on the order of execution of the Promises.
122
- * This method can be useful for aggregating the results of multiple promises.
123
- * FulfillmentSection - The returned promise is fulfilled with an array containing all the values of the iterable
124
- * passed as argument (also non-promise values).
125
- * If an empty iterable is passed, then this method returns (synchronously) an already resolved promise.
126
- * If all of the passed-in promises fulfill, or are not promises, the promise returned by Promise.all is fulfilled
127
- * asynchronously.
128
- * RejectionSection - If any of the passed-in promises reject, Promise.all asynchronously rejects with the value of
129
- * the promise that rejected, whether or not the other promises have resolved.
130
- * @param iterable
131
- */
132
- public static all<T>(iterable: any[]) {
133
- if (!iterable || !iterable.length) {
134
- return;
135
- }
136
-
137
- return new ESPromise<T>((resolve, reject) => {
138
- try {
139
- let values = [] as any;
140
- let pending = 0;
141
-
142
- for (let lp = 0; lp < iterable.length; lp++) {
143
- let item: any = iterable[lp];
144
-
145
- // Quick and direct check for a Promise (will also catch a thenable)
146
- if (item && _isFunction(item.then)) {
147
- pending++;
148
- item.then(
149
- _createPromiseAllOnResolvedFunction(
150
- values,
151
- lp,
152
- () => {
153
- if (--pending === 0) {
154
- resolve(values);
155
- }
156
- }),
157
- reject);
158
- } else {
159
- values[lp] = item;
160
- }
161
- }
162
-
163
- if (pending === 0) {
164
- // All promises were either resolved or where not a promise
165
- setTimeout(() => {
166
- resolve(values);
167
- }, 0);
168
- }
169
- } catch (error) {
170
- reject(error);
171
- }
172
- });
173
- }
174
-
175
- /**
176
- * The race function returns a Promise that is settled the same way (and takes the same value) as the first promise
177
- * that settles amongst the promises of the iterable passed as an argument.
178
- * If the iterable passed is empty, the promise returned will be forever pending.
179
- * If the iterable contains one or more non-promise value and/or an already settled promise, then Promise.race will
180
- * resolve to the first of these values found in the iterable.
181
- * @param iterable
182
- */
183
- public static race<T>(iterable: any[]) {
184
- return new ESPromise<T>((resolve, reject) => {
185
- if (!iterable || !iterable.length) {
186
- return;
187
- }
188
-
189
- try {
190
- for (let lp = 0; lp < iterable.length; lp++) {
191
- let item: any = iterable[lp];
192
-
193
- // Quick and direct check for a Promise (will also catch a thenable)
194
- if (item && _isFunction(item.then)) {
195
- item.then(resolve, reject);
196
- } else {
197
- setTimeout(() => {
198
- resolve(item);
199
- }, 0);
200
- }
201
- }
202
- } catch (error) {
203
- reject(error);
204
- }
205
- });
206
- }
207
-
208
- /**
209
- * The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.
210
- * @param resolverFunc A function that is passed with the arguments resolve and reject. The executor function is executed
211
- * immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise
212
- * constructor even returns the created object). The resolve and reject functions, when called, resolve or reject the promise,
213
- * respectively. The executor normally initiates some asynchronous work, and then, once that completes, either calls the resolve
214
- * function to resolve the promise or else rejects it if an error occurred. If an error is thrown in the executor function, the
215
- * promise is rejected. The return value of the executor is ignored.
216
- */
217
- constructor(resolverFunc: (resolve: ResolverResolveFunc<T>, reject: ResolverRejectFunc<T>) => void) {
218
- let _state = PromiseState.Pending;
219
- let _settledValue: T = null;
220
- let _queue = [];
221
-
222
- dynamicProto(ESPromise, this, (_this) => {
223
- _this.then = (onResolved: ESPromiseOnResolvedFunc<T>, onRejected?: ESPromiseOnRejectedFunc<T>) => {
224
- return new ESPromise((resolve: ResolverResolveFunc<T>, reject: ResolverRejectFunc<T>) => {
225
- // Queue the new promise returned to be resolved or rejected
226
- // when this promise settles.
227
- _enqueue(onResolved, onRejected, resolve, reject);
228
- });
229
- };
230
-
231
- _this["catch"] = (onRejected: ESPromiseOnRejectedFunc<T>) => {
232
- return _this.then(null, onRejected);
233
- };
234
- });
235
-
236
- function _enqueue(onResolved: ESPromiseOnResolvedFunc<T>, onRejected: ESPromiseOnRejectedFunc<T>, resolve: ResolverResolveFunc<T>, reject: ResolverRejectFunc<T>) {
237
- _queue.push(() => {
238
- let value: T|ESPromise<T>|void;
239
-
240
- try {
241
- // First call the onFulfilled or onRejected handler, on the settled value
242
- // of this promise. If the corresponding handler does not exist, simply
243
- // pass through the settled value.
244
- if (_state === PromiseState.Resolved) {
245
- value = _isFunction(onResolved) ? onResolved(_settledValue) : _settledValue;
246
- } else {
247
- value = _isFunction(onRejected) ? onRejected(_settledValue) : _settledValue;
248
- }
249
-
250
- if (value instanceof ESPromise) {
251
- // The called handlers returned a new promise, so the chained promise
252
- // will follow the state of this promise.
253
- value.then(resolve, reject);
254
- } else if (_state === PromiseState.Rejected && !_isFunction(onRejected)) {
255
- // If there wasn't an onRejected handler and this promise is rejected, then
256
- // the chained promise also rejects with the same reason.
257
- reject(value);
258
- } else {
259
- // If this promise is fulfilled, then the chained promise is also fulfilled
260
- // with either the settled value of this promise (if no onFulfilled handler
261
- // was available) or the return value of the handler. If this promise is
262
- // rejected and there was an onRejected handler, then the chained promise is
263
- // fulfilled with the return value of the handler.
264
- resolve(value);
265
- }
266
- } catch (error) {
267
- // The chained promise will reject if there is any exception thrown while
268
- // calling the onFulfilled or onRejected handlers.
269
- reject(error);
270
- return;
271
- }
272
- });
273
-
274
- // If this promise is already settled, then immediately process the callback we
275
- // just added to the queue.
276
- if (_state !== PromiseState.Pending) {
277
- _processQueue();
278
- }
279
- }
280
-
281
- function _processQueue() {
282
- if (_queue.length > 0) {
283
- // The onFulfilled and onRejected handlers must be called asynchronously. Thus,
284
- // we make a copy of the queue and work on it once the current call stack unwinds.
285
- let pending = _queue.slice();
286
- _queue = [];
287
-
288
- setTimeout(() => {
289
- for (var i = 0, len = pending.length; i < len; ++i) {
290
- try {
291
- pending[i]();
292
- } catch (e) {
293
- // Don't let 1 failing handler break all others
294
- // TODO (newylie): Add some form of error reporting (i.e. Call any registered JS error handler so the error is reported)
295
- }
296
- }
297
- }, 0);
298
- }
299
- }
300
-
301
- function _resolve(value: T): void {
302
- if (_state === PromiseState.Pending) {
303
- _settledValue = value;
304
- _state = PromiseState.Resolved;
305
- _processQueue();
306
- }
307
- }
308
-
309
- function _reject(reason: any): void {
310
- if (_state === PromiseState.Pending) {
311
- _settledValue = reason;
312
- _state = PromiseState.Rejected;
313
- _processQueue();
314
- }
315
- }
316
-
317
- (function _initialize() {
318
- if (!_isFunction(resolverFunc)) {
319
- throw new TypeError("ESPromise: resolvedFunc argument is not a Function");
320
- }
321
-
322
- try {
323
- resolverFunc(_resolve, _reject);
324
- } catch (error) {
325
- // This promise will immediately reject if any exception is thrown
326
- // from within the executor function.
327
- _reject(error);
328
- }
329
- })();
330
- }
331
-
332
- /**
333
- * The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.
334
- * @param onResolved A Function called if the Promise is fulfilled. This function has one argument, the fulfillment value. If it is not a
335
- * function, it is internally replaced with an "Identity" function (it returns the received argument).
336
- * @param onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason. If it is not a
337
- * function, it is internally replaced with a "Thrower" function (it throws an error it received as argument).
338
- * @returns Once a Promise is fulfilled or rejected, the respective handler function (onFulfilled or onRejected) will be called asynchronously
339
- * (scheduled in the current thread loop). The behavior of the handler function follows a specific set of rules. If a handler function:
340
- * - returns a value, the promise returned by then gets resolved with the returned value as its value;
341
- * - doesn't return anything, the promise returned by then gets resolved with an undefined value;
342
- * - throws an error, the promise returned by then gets rejected with the thrown error as its value;
343
- * - returns an already fulfilled promise, the promise returned by then gets fulfilled with that promise's value as its value;
344
- * - returns an already rejected promise, the promise returned by then gets rejected with that promise's value as its value;
345
- * - returns another pending promise object, the resolution/rejection of the promise returned by then will be subsequent to the
346
- * 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.
347
- */
348
- public then(onResolved: ESPromiseOnResolvedFunc<T>, onRejected?: ESPromiseOnRejectedFunc<T>): ESPromise<T> {
349
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
350
- return;
351
- }
352
-
353
- /**
354
- * The catch() method returns a Promise and deals with rejected cases only. It behaves the same as calling Promise.prototype.then(undefined, onRejected)
355
- * (in fact, calling obj.catch(onRejected) internally calls obj.then(undefined, onRejected)). This means that you have to provide an onRejected function
356
- * even if you want to fall back to an undefined result value - for example obj.catch(() => {}).
357
- * @param onRejected A Function called when the Promise is rejected. This function has one argument: reason The rejection reason.
358
- * @returns Internally calls Promise.prototype.then on the object upon which it was called, passing the parameters undefined and the received
359
- * onRejected handler. Returns the value of that call, which is a Promise.
360
- */
361
- public catch(onRejected: ESPromiseOnRejectedFunc<T>): ESPromise<T> {
362
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
363
- return;
364
- }
365
- }