@microsoft/applicationinsights-core-js 3.0.0-beta.2302-04 → 3.0.0-beta.2302-06

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 (101) hide show
  1. package/README.md +2 -1
  2. package/browser/applicationinsights-core-js.integrity.json +9 -9
  3. package/browser/applicationinsights-core-js.js +236 -141
  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 +813 -41
  8. package/dist/applicationinsights-core-js.api.md +27 -6
  9. package/dist/applicationinsights-core-js.d.ts +82 -7
  10. package/dist/applicationinsights-core-js.js +236 -141
  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 +82 -7
  15. package/dist-esm/Config/ConfigDefaultHelpers.js +103 -0
  16. package/dist-esm/Config/ConfigDefaultHelpers.js.map +1 -0
  17. package/dist-esm/Config/ConfigDefaults.js +81 -11
  18. package/dist-esm/Config/ConfigDefaults.js.map +1 -1
  19. package/dist-esm/Config/DynamicConfig.js +3 -3
  20. package/dist-esm/Config/DynamicConfig.js.map +1 -1
  21. package/dist-esm/Config/DynamicProperty.js +1 -1
  22. package/dist-esm/Config/DynamicState.js +3 -3
  23. package/dist-esm/Config/DynamicState.js.map +1 -1
  24. package/dist-esm/Config/DynamicSupport.js +1 -1
  25. package/dist-esm/Config/IConfigDefaults.js +1 -1
  26. package/dist-esm/Config/IDynamicConfigHandler.js +1 -1
  27. package/dist-esm/Config/IDynamicPropertyHandler.js +1 -1
  28. package/dist-esm/Config/IDynamicWatcher.js +1 -1
  29. package/dist-esm/Config/_IDynamicConfigHandlerState.js +1 -1
  30. package/dist-esm/JavaScriptSDK/AggregationError.js +1 -1
  31. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +2 -2
  32. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  33. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  34. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  35. package/dist-esm/JavaScriptSDK/CookieMgr.js +17 -15
  36. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  37. package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
  38. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
  39. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  40. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  41. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
  42. package/dist-esm/JavaScriptSDK/EnvUtils.js +3 -3
  43. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  44. package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
  45. package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -10
  46. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +12 -9
  48. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
  50. package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
  51. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  52. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
  53. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  54. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
  55. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
  56. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  57. package/dist-esm/JavaScriptSDK/UnloadHookContainer.js +1 -1
  58. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +6 -5
  59. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  60. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  86. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
  87. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  88. package/dist-esm/__DynamicConstants.js +6 -5
  89. package/dist-esm/__DynamicConstants.js.map +1 -1
  90. package/dist-esm/applicationinsights-core-js.js +2 -1
  91. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  92. package/package.json +1 -1
  93. package/src/JavaScriptSDK/CookieMgr.ts +14 -13
  94. package/src/JavaScriptSDK/HelperFuncs.ts +0 -11
  95. package/src/JavaScriptSDK/InstrumentHooks.ts +11 -8
  96. package/types/Config/ConfigDefaultHelpers.d.ts +47 -0
  97. package/types/Config/ConfigDefaults.d.ts +1 -2
  98. package/types/Config/IConfigDefaults.d.ts +24 -3
  99. package/types/JavaScriptSDK/InstrumentHooks.d.ts +6 -3
  100. package/types/__DynamicConstants.d.ts +2 -1
  101. package/types/applicationinsights-core-js.d.ts +1 -0
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2302-04
2
+ * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -396,6 +396,57 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
396
396
  protected _addHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
397
397
  }
398
398
 
399
+ /**
400
+ * Helper which returns an IConfigDefaultCheck instance that will validate and convert the user
401
+ * provided value to a boolean from a string or boolean value
402
+ * @param validator - The IConfigCheckFn function to validate the user provided value
403
+ * @param defaultValue - The default value to apply it not provided or it's not valid
404
+ * @param fallBackName - The fallback configuration name if the current value is not available
405
+ * @returns a new IConfigDefaultCheck structure
406
+ */
407
+ export declare function cfgDfBoolean<T, C = IConfiguration>(defaultValue?: boolean, fallBackName?: keyof T | keyof C | Array<keyof T | keyof C>): IConfigDefaultCheck<T, boolean, C>;
408
+
409
+ /**
410
+ * Helper which returns an IConfigDefaultCheck instance that will validate that the user
411
+ * provided value is a function.
412
+ * @param defaultValue - The default value to apply it not provided or it's not valid
413
+ * @returns a new IConfigDefaultCheck structure
414
+ */
415
+ export declare function cfgDfFunc<V, T, C = IConfiguration>(defaultValue?: V): IConfigDefaultCheck<T, V, C>;
416
+
417
+ /**
418
+ * Helper which returns an IConfigDefaultCheck instance with the provided field validator
419
+ * @param validator - The IConfigCheckFn function to validate the user provided value
420
+ * @param defaultValue - The default value to apply it not provided or it's not valid
421
+ * @returns a new IConfigDefaultCheck structure
422
+ */
423
+ export declare function cfgDfMerge<V, T = IConfiguration, C = IConfiguration>(defaultValue: V | IConfigDefaults<V, T>): IConfigDefaultCheck<T, V, C>;
424
+
425
+ /**
426
+ * Helper which returns an IConfigDefaultCheck instance with the provided field set function
427
+ * @param setter - The IConfigCheckFn function to validate the user provided value
428
+ * @param defaultValue - The default value to apply it not provided or it's not valid
429
+ * @returns a new IConfigDefaultCheck structure
430
+ */
431
+ export declare function cfgDfSet<V, T, C = IConfiguration>(setter: IConfigSetFn<T, V>, defaultValue: V): IConfigDefaultCheck<T, V, C>;
432
+
433
+ /**
434
+ * Helper which returns an IConfigDefaultCheck instance that will validate that the user
435
+ * provided value is a function.
436
+ * @param defaultValue - The default string value to apply it not provided or it's not valid, defaults to an empty string
437
+ * @returns a new IConfigDefaultCheck structure
438
+ */
439
+ export declare function cfgDfString<T, C = IConfiguration>(defaultValue?: string): IConfigDefaultCheck<T, string, C>;
440
+
441
+ /**
442
+ * Helper which returns an IConfigDefaultCheck instance with the provided field validator
443
+ * @param validator - The IConfigCheckFn function to validate the user provided value
444
+ * @param defaultValue - The default value to apply it not provided or it's not valid
445
+ * @param fallBackName - The fallback configuration name if the current value is not available
446
+ * @returns a new IConfigDefaultCheck structure
447
+ */
448
+ export declare function cfgDfValidate<V, T, C = IConfiguration>(validator: IConfigCheckFn<V>, defaultValue: V, fallBackName?: keyof T | keyof C | Array<keyof T | keyof C>): IConfigDefaultCheck<T, V, C>;
449
+
399
450
  /**
400
451
  * Simpler helper to create a dynamic class that implements the interface and populates the values with the defaults.
401
452
  * Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance
@@ -1089,7 +1140,7 @@ export declare type IConfigCheckFn<V> = (value: V) => boolean;
1089
1140
  /**
1090
1141
  * The default values with a check function
1091
1142
  */
1092
- export declare interface IConfigDefaultCheck<T, V, C extends IConfiguration = IConfiguration> {
1143
+ export declare interface IConfigDefaultCheck<T, V, C = IConfiguration> {
1093
1144
  /**
1094
1145
  * Callback function to check if the user-supplied value is valid, if not the default will be applied
1095
1146
  */
@@ -1101,7 +1152,7 @@ export declare interface IConfigDefaultCheck<T, V, C extends IConfiguration = IC
1101
1152
  /**
1102
1153
  * The default value to apply if the user-supplied value is not valid
1103
1154
  */
1104
- v?: V;
1155
+ v?: V | IConfigDefaults<V, T>;
1105
1156
  /**
1106
1157
  * The default fallback key if the main key is not present, this is the key value from the config
1107
1158
  */
@@ -1111,13 +1162,34 @@ export declare interface IConfigDefaultCheck<T, V, C extends IConfiguration = IC
1111
1162
  * therefore `null`; `""` are considered to be valid values.
1112
1163
  */
1113
1164
  dfVal?: (value: any) => boolean;
1165
+ /**
1166
+ * Specify that any provided value should have the default value(s) merged into the value rather than
1167
+ * just using either the default of user provided values. Mergeed objects will automatically be marked
1168
+ * as referenced.
1169
+ */
1170
+ mrg?: boolean;
1171
+ /**
1172
+ * Set this field of the target as referenced, which will cause any object or array instance
1173
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
1174
+ * This is required for nested default objects to avoid multiple repetitive updates to listeners
1175
+ * @returns The referenced properties current value
1176
+ */
1177
+ ref?: boolean;
1178
+ /**
1179
+ * Set this field of the target as read-only, which will block this single named property from
1180
+ * ever being changed for the target instance.
1181
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
1182
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
1183
+ * @returns The referenced properties current value
1184
+ */
1185
+ rdOnly?: boolean;
1114
1186
  }
1115
1187
 
1116
1188
  /**
1117
1189
  * The Type definition to define default values to be applied to the config
1118
1190
  * The value may be either the direct value or a ConfigDefaultCheck definition
1119
1191
  */
1120
- export declare type IConfigDefaults<T, C extends IConfiguration = IConfiguration> = {
1192
+ export declare type IConfigDefaults<T, C = IConfiguration> = {
1121
1193
  [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
1122
1194
  };
1123
1195
 
@@ -1746,8 +1818,9 @@ export declare interface INotificationManager {
1746
1818
  * @param evtName - The name of the event
1747
1819
  * @param callbacks - The callbacks to configure and call whenever the function is called
1748
1820
  * @param checkPrototype - If the function doesn't exist on the target should it attempt to hook the prototype function
1821
+ * @param checkParentProto - If the function doesn't exist on the target or it's prototype should it attempt to hook the parent's prototype
1749
1822
  */
1750
- export declare function InstrumentEvent(target: any, evtName: string, callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean): IInstrumentHook;
1823
+ export declare function InstrumentEvent(target: any, evtName: string, callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean, checkParentProto?: boolean): IInstrumentHook;
1751
1824
 
1752
1825
  /**
1753
1826
  * Intercept the named prototype functions for the target class / object
@@ -1755,8 +1828,9 @@ export declare function InstrumentEvent(target: any, evtName: string, callbacks:
1755
1828
  * @param funcName - The function name
1756
1829
  * @param callbacks - The callbacks to configure and call whenever the function is called
1757
1830
  * @param checkPrototype - If the function doesn't exist on the target should it attempt to hook the prototype function
1831
+ * @param checkParentProto - If the function doesn't exist on the target or it's prototype should it attempt to hook the parent's prototype
1758
1832
  */
1759
- export declare function InstrumentFunc(target: any, funcName: string, callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean): IInstrumentHook;
1833
+ export declare function InstrumentFunc(target: any, funcName: string, callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean, checkParentProto?: boolean): IInstrumentHook;
1760
1834
 
1761
1835
  /**
1762
1836
  * Intercept the named functions for the target class / object
@@ -1764,8 +1838,9 @@ export declare function InstrumentFunc(target: any, funcName: string, callbacks:
1764
1838
  * @param funcNames - The function names to intercept and call
1765
1839
  * @param callbacks - The callbacks to configure and call whenever the function is called
1766
1840
  * @param checkPrototype - If the function doesn't exist on the target should it attempt to hook the prototype function
1841
+ * @param checkParentProto - If the function doesn't exist on the target or it's prototype should it attempt to hook the parent's prototype
1767
1842
  */
1768
- export declare function InstrumentFuncs(target: any, funcNames: string[], callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean): IInstrumentHook[];
1843
+ export declare function InstrumentFuncs(target: any, funcNames: string[], callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean, checkParentProto?: boolean): IInstrumentHook[];
1769
1844
 
1770
1845
  /**
1771
1846
  * A callback function that will be called for the wrapped instrumentation function
@@ -0,0 +1,103 @@
1
+ /*
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ */
5
+
6
+
7
+ import { asString, isBoolean, isFunction, isNullOrUndefined, isString } from "@nevware21/ts-utils";
8
+ import { STR_EMPTY } from "../JavaScriptSDK/InternalConstants";
9
+ import { _DYN_TO_LOWER_CASE } from "../__DynamicConstants";
10
+ /**
11
+ * @internal
12
+ * @ignore
13
+ * @param str
14
+ * @param defaultValue
15
+ * @returns
16
+ */
17
+ function _stringToBoolOrDefault(theValue, defaultValue, theConfig) {
18
+ if (!theValue && isNullOrUndefined(theValue)) {
19
+ return defaultValue;
20
+ }
21
+ if (isBoolean(theValue)) {
22
+ return theValue;
23
+ }
24
+ return asString(theValue)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() === "true";
25
+ }
26
+ /**
27
+ * Helper which returns an IConfigDefaultCheck instance with the provided field validator
28
+ * @param validator - The IConfigCheckFn function to validate the user provided value
29
+ * @param defaultValue - The default value to apply it not provided or it's not valid
30
+ * @returns a new IConfigDefaultCheck structure
31
+ */
32
+ export function cfgDfMerge(defaultValue) {
33
+ return {
34
+ mrg: true,
35
+ v: defaultValue
36
+ };
37
+ }
38
+ /**
39
+ * Helper which returns an IConfigDefaultCheck instance with the provided field set function
40
+ * @param setter - The IConfigCheckFn function to validate the user provided value
41
+ * @param defaultValue - The default value to apply it not provided or it's not valid
42
+ * @returns a new IConfigDefaultCheck structure
43
+ */
44
+ export function cfgDfSet(setter, defaultValue) {
45
+ return {
46
+ set: setter,
47
+ v: defaultValue
48
+ };
49
+ }
50
+ /**
51
+ * Helper which returns an IConfigDefaultCheck instance with the provided field validator
52
+ * @param validator - The IConfigCheckFn function to validate the user provided value
53
+ * @param defaultValue - The default value to apply it not provided or it's not valid
54
+ * @param fallBackName - The fallback configuration name if the current value is not available
55
+ * @returns a new IConfigDefaultCheck structure
56
+ */
57
+ export function cfgDfValidate(validator, defaultValue, fallBackName) {
58
+ return {
59
+ fb: fallBackName,
60
+ isVal: validator,
61
+ v: defaultValue
62
+ };
63
+ }
64
+ /**
65
+ * Helper which returns an IConfigDefaultCheck instance that will validate and convert the user
66
+ * provided value to a boolean from a string or boolean value
67
+ * @param validator - The IConfigCheckFn function to validate the user provided value
68
+ * @param defaultValue - The default value to apply it not provided or it's not valid
69
+ * @param fallBackName - The fallback configuration name if the current value is not available
70
+ * @returns a new IConfigDefaultCheck structure
71
+ */
72
+ export function cfgDfBoolean(defaultValue, fallBackName) {
73
+ return {
74
+ fb: fallBackName,
75
+ set: _stringToBoolOrDefault,
76
+ v: !!defaultValue
77
+ };
78
+ }
79
+ /**
80
+ * Helper which returns an IConfigDefaultCheck instance that will validate that the user
81
+ * provided value is a function.
82
+ * @param defaultValue - The default value to apply it not provided or it's not valid
83
+ * @returns a new IConfigDefaultCheck structure
84
+ */
85
+ export function cfgDfFunc(defaultValue) {
86
+ return {
87
+ isVal: isFunction,
88
+ v: defaultValue || null
89
+ };
90
+ }
91
+ /**
92
+ * Helper which returns an IConfigDefaultCheck instance that will validate that the user
93
+ * provided value is a function.
94
+ * @param defaultValue - The default string value to apply it not provided or it's not valid, defaults to an empty string
95
+ * @returns a new IConfigDefaultCheck structure
96
+ */
97
+ export function cfgDfString(defaultValue) {
98
+ return {
99
+ isVal: isString,
100
+ v: asString(defaultValue || STR_EMPTY)
101
+ };
102
+ }
103
+ //# sourceMappingURL=ConfigDefaultHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigDefaultHelpers.js.map","sources":["ConfigDefaultHelpers.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { asString, isBoolean, isFunction, isNullOrUndefined, isString } from \"@nevware21/ts-utils\";\r\nimport { STR_EMPTY } from \"../JavaScriptSDK/InternalConstants\";\r\nimport { _DYN_TO_LOWER_CASE } from \"../__DynamicConstants\";\r\n/**\r\n * @internal\r\n * @ignore\r\n * @param str\r\n * @param defaultValue\r\n * @returns\r\n */\r\nfunction _stringToBoolOrDefault(theValue, defaultValue, theConfig) {\r\n if (!theValue && isNullOrUndefined(theValue)) {\r\n return defaultValue;\r\n }\r\n if (isBoolean(theValue)) {\r\n return theValue;\r\n }\r\n return asString(theValue)[_DYN_TO_LOWER_CASE /* @min:%2etoLowerCase */]() === \"true\";\r\n}\r\n/**\r\n * Helper which returns an IConfigDefaultCheck instance with the provided field validator\r\n * @param validator - The IConfigCheckFn function to validate the user provided value\r\n * @param defaultValue - The default value to apply it not provided or it's not valid\r\n * @returns a new IConfigDefaultCheck structure\r\n */\r\nexport function cfgDfMerge(defaultValue) {\r\n return {\r\n mrg: true,\r\n v: defaultValue\r\n };\r\n}\r\n/**\r\n * Helper which returns an IConfigDefaultCheck instance with the provided field set function\r\n * @param setter - The IConfigCheckFn function to validate the user provided value\r\n * @param defaultValue - The default value to apply it not provided or it's not valid\r\n * @returns a new IConfigDefaultCheck structure\r\n */\r\nexport function cfgDfSet(setter, defaultValue) {\r\n return {\r\n set: setter,\r\n v: defaultValue\r\n };\r\n}\r\n/**\r\n * Helper which returns an IConfigDefaultCheck instance with the provided field validator\r\n * @param validator - The IConfigCheckFn function to validate the user provided value\r\n * @param defaultValue - The default value to apply it not provided or it's not valid\r\n * @param fallBackName - The fallback configuration name if the current value is not available\r\n * @returns a new IConfigDefaultCheck structure\r\n */\r\nexport function cfgDfValidate(validator, defaultValue, fallBackName) {\r\n return {\r\n fb: fallBackName,\r\n isVal: validator,\r\n v: defaultValue\r\n };\r\n}\r\n/**\r\n * Helper which returns an IConfigDefaultCheck instance that will validate and convert the user\r\n * provided value to a boolean from a string or boolean value\r\n * @param validator - The IConfigCheckFn function to validate the user provided value\r\n * @param defaultValue - The default value to apply it not provided or it's not valid\r\n * @param fallBackName - The fallback configuration name if the current value is not available\r\n * @returns a new IConfigDefaultCheck structure\r\n */\r\nexport function cfgDfBoolean(defaultValue, fallBackName) {\r\n return {\r\n fb: fallBackName,\r\n set: _stringToBoolOrDefault,\r\n v: !!defaultValue\r\n };\r\n}\r\n/**\r\n * Helper which returns an IConfigDefaultCheck instance that will validate that the user\r\n * provided value is a function.\r\n * @param defaultValue - The default value to apply it not provided or it's not valid\r\n * @returns a new IConfigDefaultCheck structure\r\n */\r\nexport function cfgDfFunc(defaultValue) {\r\n return {\r\n isVal: isFunction,\r\n v: defaultValue || null\r\n };\r\n}\r\n/**\r\n * Helper which returns an IConfigDefaultCheck instance that will validate that the user\r\n * provided value is a function.\r\n * @param defaultValue - The default string value to apply it not provided or it's not valid, defaults to an empty string\r\n * @returns a new IConfigDefaultCheck structure\r\n */\r\nexport function cfgDfString(defaultValue) {\r\n return {\r\n isVal: isString,\r\n v: asString(defaultValue || STR_EMPTY)\r\n };\r\n}\r\n//# sourceMappingURL=ConfigDefaultHelpers.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"}
@@ -1,12 +1,14 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
- import { asString, isArray, isDefined, isNullOrUndefined, isObject, isPlainObject, objHasOwn } from "@nevware21/ts-utils";
8
- import { _DYN_LENGTH } from "../__DynamicConstants";
9
- import { _cfgDeepCopy } from "./DynamicSupport";
7
+ import { asString, isArray, isDefined, isNullOrUndefined, isObject, isPlainObject, isUndefined, objForEachKey, objHasOwn } from "@nevware21/ts-utils";
8
+ import { _DYN_LENGTH, _DYN_RD_ONLY } from "../__DynamicConstants";
9
+ function _isConfigDefaults(value) {
10
+ return (value && isObject(value) && (value.isVal || value.fb || objHasOwn(value, "v") || objHasOwn(value, "mrg") || objHasOwn(value, "ref") || value.set));
11
+ }
10
12
  function _getDefault(dynamicHandler, theConfig, cfgDefaults) {
11
13
  var defValue;
12
14
  var isDefaultValid = cfgDefaults.dfVal || isDefined;
@@ -22,7 +24,7 @@ function _getDefault(dynamicHandler, theConfig, cfgDefaults) {
22
24
  if (isDefaultValid(fbValue)) {
23
25
  defValue = fbValue;
24
26
  }
25
- else {
27
+ else if (dynamicHandler) {
26
28
  // Needed to ensure that the fallback value (and potentially) new field is also dynamic even if null/undefined
27
29
  fbValue = dynamicHandler.cfg[fallback];
28
30
  if (isDefaultValid(fbValue)) {
@@ -43,6 +45,42 @@ function _getDefault(dynamicHandler, theConfig, cfgDefaults) {
43
45
  }
44
46
  return defValue;
45
47
  }
48
+ /**
49
+ * Recursively resolve the default value
50
+ * @param dynamicHandler
51
+ * @param theConfig
52
+ * @param cfgDefaults
53
+ * @returns
54
+ */
55
+ function _resolveDefaultValue(dynamicHandler, theConfig, cfgDefaults) {
56
+ var theValue = cfgDefaults;
57
+ if (cfgDefaults && _isConfigDefaults(cfgDefaults)) {
58
+ theValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);
59
+ }
60
+ if (theValue) {
61
+ if (_isConfigDefaults(theValue)) {
62
+ theValue = _resolveDefaultValue(dynamicHandler, theConfig, theValue);
63
+ }
64
+ var newValue_1;
65
+ if (isArray(theValue)) {
66
+ newValue_1 = [];
67
+ newValue_1[_DYN_LENGTH /* @min:%2elength */] = theValue[_DYN_LENGTH /* @min:%2elength */];
68
+ }
69
+ else if (isPlainObject(theValue)) {
70
+ newValue_1 = {};
71
+ }
72
+ if (newValue_1) {
73
+ objForEachKey(theValue, function (key, value) {
74
+ if (value && _isConfigDefaults(value)) {
75
+ value = _resolveDefaultValue(dynamicHandler, theConfig, value);
76
+ }
77
+ newValue_1[key] = value;
78
+ });
79
+ theValue = newValue_1;
80
+ }
81
+ }
82
+ return theValue;
83
+ }
46
84
  /**
47
85
  * Applies the default value on the config property and makes sure that it's dynamic
48
86
  * @param theConfig
@@ -55,17 +93,26 @@ export function _applyDefaultValue(dynamicHandler, theConfig, name, defaultValue
55
93
  var setFn;
56
94
  var defValue;
57
95
  var cfgDefaults = defaultValue;
58
- if (cfgDefaults && isObject(cfgDefaults) && (cfgDefaults.isVal || cfgDefaults.set || cfgDefaults.fb || objHasOwn(cfgDefaults, "v"))) {
96
+ var mergeDf;
97
+ var reference;
98
+ var readOnly;
99
+ if (_isConfigDefaults(cfgDefaults)) {
59
100
  // looks like a IConfigDefault
60
101
  isValid = cfgDefaults.isVal;
61
102
  setFn = cfgDefaults.set;
103
+ readOnly = cfgDefaults[_DYN_RD_ONLY /* @min:%2erdOnly */];
104
+ mergeDf = cfgDefaults.mrg;
105
+ reference = cfgDefaults.ref;
106
+ if (!reference && isUndefined(reference)) {
107
+ reference = !!mergeDf;
108
+ }
62
109
  defValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);
63
110
  }
64
111
  else {
65
112
  defValue = defaultValue;
66
113
  }
67
114
  // Set the value to the default value;
68
- var theValue = defValue;
115
+ var theValue;
69
116
  var usingDefault = true;
70
117
  var cfgValue = theConfig[name];
71
118
  // try and get and user provided values
@@ -73,8 +120,6 @@ export function _applyDefaultValue(dynamicHandler, theConfig, name, defaultValue
73
120
  // Use the defined theConfig[name] value
74
121
  theValue = cfgValue;
75
122
  usingDefault = false;
76
- }
77
- if (!usingDefault) {
78
123
  // The values are different and we have a special default value check, which is used to
79
124
  // override config values like empty strings to continue using the default
80
125
  if (isValid && theValue !== defValue && !isValid(theValue)) {
@@ -86,10 +131,35 @@ export function _applyDefaultValue(dynamicHandler, theConfig, name, defaultValue
86
131
  usingDefault = theValue === defValue;
87
132
  }
88
133
  }
89
- if (theValue && usingDefault && (isPlainObject(theValue) || isArray(theValue))) {
90
- theValue = _cfgDeepCopy(theValue);
134
+ if (!usingDefault) {
135
+ if (isPlainObject(theValue) || isArray(defValue)) {
136
+ // we are using the user supplied value and it's an object
137
+ if (mergeDf && defValue && (isPlainObject(defValue) || isArray(defValue))) {
138
+ // Resolve/apply the defaults
139
+ objForEachKey(defValue, function (dfName, dfValue) {
140
+ // Sets the value and makes it dynamic (if it doesn't already exist)
141
+ _applyDefaultValue(dynamicHandler, theValue, dfName, dfValue);
142
+ });
143
+ }
144
+ }
91
145
  }
146
+ else if (defValue) {
147
+ // Just resolve the default
148
+ theValue = _resolveDefaultValue(dynamicHandler, theConfig, defValue);
149
+ }
150
+ else {
151
+ theValue = defValue;
152
+ }
153
+ // if (theValue && usingDefault && (isPlainObject(theValue) || isArray(theValue))) {
154
+ // theValue = _cfgDeepCopy(theValue);
155
+ // }
92
156
  // Needed to ensure that the (potentially) new field is dynamic even if null/undefined
93
157
  dynamicHandler.set(theConfig, name, theValue);
158
+ if (reference) {
159
+ dynamicHandler.ref(theConfig, name);
160
+ }
161
+ if (readOnly) {
162
+ dynamicHandler[_DYN_RD_ONLY /* @min:%2erdOnly */](theConfig, name);
163
+ }
94
164
  }
95
165
  //# sourceMappingURL=ConfigDefaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigDefaults.js.map","sources":["ConfigDefaults.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { asString, isArray, isDefined, isNullOrUndefined, isObject, isPlainObject, objHasOwn } from \"@nevware21/ts-utils\";\r\nimport { _DYN_LENGTH } from \"../__DynamicConstants\";\r\nimport { _cfgDeepCopy } from \"./DynamicSupport\";\r\nfunction _getDefault(dynamicHandler, theConfig, cfgDefaults) {\r\n var defValue;\r\n var isDefaultValid = cfgDefaults.dfVal || isDefined;\r\n // There is a fallback config key so try and grab that first\r\n if (theConfig && cfgDefaults.fb) {\r\n var fallbacks = cfgDefaults.fb;\r\n if (!isArray(fallbacks)) {\r\n fallbacks = [fallbacks];\r\n }\r\n for (var lp = 0; lp < fallbacks[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n var fallback = fallbacks[lp];\r\n var fbValue = theConfig[fallback];\r\n if (isDefaultValid(fbValue)) {\r\n defValue = fbValue;\r\n }\r\n else {\r\n // Needed to ensure that the fallback value (and potentially) new field is also dynamic even if null/undefined\r\n fbValue = dynamicHandler.cfg[fallback];\r\n if (isDefaultValid(fbValue)) {\r\n defValue = fbValue;\r\n }\r\n // Needed to ensure that the fallback value (and potentially) new field is also dynamic even if null/undefined\r\n dynamicHandler.set(dynamicHandler.cfg, asString(fallback), fbValue);\r\n }\r\n if (isDefaultValid(defValue)) {\r\n // We have a valid default so break out of the look\r\n break;\r\n }\r\n }\r\n }\r\n // If the value is still not defined and we have a default value then use that\r\n if (!isDefaultValid(defValue) && isDefaultValid(cfgDefaults.v)) {\r\n defValue = cfgDefaults.v;\r\n }\r\n return defValue;\r\n}\r\n/**\r\n * Applies the default value on the config property and makes sure that it's dynamic\r\n * @param theConfig\r\n * @param name\r\n * @param defaultValue\r\n */\r\nexport function _applyDefaultValue(dynamicHandler, theConfig, name, defaultValue) {\r\n // Resolve the initial config value from the provided value or use the defined default\r\n var isValid;\r\n var setFn;\r\n var defValue;\r\n var cfgDefaults = defaultValue;\r\n if (cfgDefaults && isObject(cfgDefaults) && (cfgDefaults.isVal || cfgDefaults.set || cfgDefaults.fb || objHasOwn(cfgDefaults, \"v\"))) {\r\n // looks like a IConfigDefault\r\n isValid = cfgDefaults.isVal;\r\n setFn = cfgDefaults.set;\r\n defValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);\r\n }\r\n else {\r\n defValue = defaultValue;\r\n }\r\n // Set the value to the default value;\r\n var theValue = defValue;\r\n var usingDefault = true;\r\n var cfgValue = theConfig[name];\r\n // try and get and user provided values\r\n if (cfgValue || !isNullOrUndefined(cfgValue)) {\r\n // Use the defined theConfig[name] value\r\n theValue = cfgValue;\r\n usingDefault = false;\r\n }\r\n if (!usingDefault) {\r\n // The values are different and we have a special default value check, which is used to\r\n // override config values like empty strings to continue using the default\r\n if (isValid && theValue !== defValue && !isValid(theValue)) {\r\n theValue = defValue;\r\n usingDefault = true;\r\n }\r\n if (setFn) {\r\n theValue = setFn(theValue, defValue, theConfig);\r\n usingDefault = theValue === defValue;\r\n }\r\n }\r\n if (theValue && usingDefault && (isPlainObject(theValue) || isArray(theValue))) {\r\n theValue = _cfgDeepCopy(theValue);\r\n }\r\n // Needed to ensure that the (potentially) new field is dynamic even if null/undefined\r\n dynamicHandler.set(theConfig, name, theValue);\r\n}\r\n//# sourceMappingURL=ConfigDefaults.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"}
1
+ {"version":3,"file":"ConfigDefaults.js.map","sources":["ConfigDefaults.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { asString, isArray, isDefined, isNullOrUndefined, isObject, isPlainObject, isUndefined, objForEachKey, objHasOwn } from \"@nevware21/ts-utils\";\r\nimport { _DYN_LENGTH, _DYN_RD_ONLY } from \"../__DynamicConstants\";\r\nfunction _isConfigDefaults(value) {\r\n return (value && isObject(value) && (value.isVal || value.fb || objHasOwn(value, \"v\") || objHasOwn(value, \"mrg\") || objHasOwn(value, \"ref\") || value.set));\r\n}\r\nfunction _getDefault(dynamicHandler, theConfig, cfgDefaults) {\r\n var defValue;\r\n var isDefaultValid = cfgDefaults.dfVal || isDefined;\r\n // There is a fallback config key so try and grab that first\r\n if (theConfig && cfgDefaults.fb) {\r\n var fallbacks = cfgDefaults.fb;\r\n if (!isArray(fallbacks)) {\r\n fallbacks = [fallbacks];\r\n }\r\n for (var lp = 0; lp < fallbacks[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n var fallback = fallbacks[lp];\r\n var fbValue = theConfig[fallback];\r\n if (isDefaultValid(fbValue)) {\r\n defValue = fbValue;\r\n }\r\n else if (dynamicHandler) {\r\n // Needed to ensure that the fallback value (and potentially) new field is also dynamic even if null/undefined\r\n fbValue = dynamicHandler.cfg[fallback];\r\n if (isDefaultValid(fbValue)) {\r\n defValue = fbValue;\r\n }\r\n // Needed to ensure that the fallback value (and potentially) new field is also dynamic even if null/undefined\r\n dynamicHandler.set(dynamicHandler.cfg, asString(fallback), fbValue);\r\n }\r\n if (isDefaultValid(defValue)) {\r\n // We have a valid default so break out of the look\r\n break;\r\n }\r\n }\r\n }\r\n // If the value is still not defined and we have a default value then use that\r\n if (!isDefaultValid(defValue) && isDefaultValid(cfgDefaults.v)) {\r\n defValue = cfgDefaults.v;\r\n }\r\n return defValue;\r\n}\r\n/**\r\n * Recursively resolve the default value\r\n * @param dynamicHandler\r\n * @param theConfig\r\n * @param cfgDefaults\r\n * @returns\r\n */\r\nfunction _resolveDefaultValue(dynamicHandler, theConfig, cfgDefaults) {\r\n var theValue = cfgDefaults;\r\n if (cfgDefaults && _isConfigDefaults(cfgDefaults)) {\r\n theValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);\r\n }\r\n if (theValue) {\r\n if (_isConfigDefaults(theValue)) {\r\n theValue = _resolveDefaultValue(dynamicHandler, theConfig, theValue);\r\n }\r\n var newValue_1;\r\n if (isArray(theValue)) {\r\n newValue_1 = [];\r\n newValue_1[_DYN_LENGTH /* @min:%2elength */] = theValue[_DYN_LENGTH /* @min:%2elength */];\r\n }\r\n else if (isPlainObject(theValue)) {\r\n newValue_1 = {};\r\n }\r\n if (newValue_1) {\r\n objForEachKey(theValue, function (key, value) {\r\n if (value && _isConfigDefaults(value)) {\r\n value = _resolveDefaultValue(dynamicHandler, theConfig, value);\r\n }\r\n newValue_1[key] = value;\r\n });\r\n theValue = newValue_1;\r\n }\r\n }\r\n return theValue;\r\n}\r\n/**\r\n * Applies the default value on the config property and makes sure that it's dynamic\r\n * @param theConfig\r\n * @param name\r\n * @param defaultValue\r\n */\r\nexport function _applyDefaultValue(dynamicHandler, theConfig, name, defaultValue) {\r\n // Resolve the initial config value from the provided value or use the defined default\r\n var isValid;\r\n var setFn;\r\n var defValue;\r\n var cfgDefaults = defaultValue;\r\n var mergeDf;\r\n var reference;\r\n var readOnly;\r\n if (_isConfigDefaults(cfgDefaults)) {\r\n // looks like a IConfigDefault\r\n isValid = cfgDefaults.isVal;\r\n setFn = cfgDefaults.set;\r\n readOnly = cfgDefaults[_DYN_RD_ONLY /* @min:%2erdOnly */];\r\n mergeDf = cfgDefaults.mrg;\r\n reference = cfgDefaults.ref;\r\n if (!reference && isUndefined(reference)) {\r\n reference = !!mergeDf;\r\n }\r\n defValue = _getDefault(dynamicHandler, theConfig, cfgDefaults);\r\n }\r\n else {\r\n defValue = defaultValue;\r\n }\r\n // Set the value to the default value;\r\n var theValue;\r\n var usingDefault = true;\r\n var cfgValue = theConfig[name];\r\n // try and get and user provided values\r\n if (cfgValue || !isNullOrUndefined(cfgValue)) {\r\n // Use the defined theConfig[name] value\r\n theValue = cfgValue;\r\n usingDefault = false;\r\n // The values are different and we have a special default value check, which is used to\r\n // override config values like empty strings to continue using the default\r\n if (isValid && theValue !== defValue && !isValid(theValue)) {\r\n theValue = defValue;\r\n usingDefault = true;\r\n }\r\n if (setFn) {\r\n theValue = setFn(theValue, defValue, theConfig);\r\n usingDefault = theValue === defValue;\r\n }\r\n }\r\n if (!usingDefault) {\r\n if (isPlainObject(theValue) || isArray(defValue)) {\r\n // we are using the user supplied value and it's an object\r\n if (mergeDf && defValue && (isPlainObject(defValue) || isArray(defValue))) {\r\n // Resolve/apply the defaults\r\n objForEachKey(defValue, function (dfName, dfValue) {\r\n // Sets the value and makes it dynamic (if it doesn't already exist)\r\n _applyDefaultValue(dynamicHandler, theValue, dfName, dfValue);\r\n });\r\n }\r\n }\r\n }\r\n else if (defValue) {\r\n // Just resolve the default\r\n theValue = _resolveDefaultValue(dynamicHandler, theConfig, defValue);\r\n }\r\n else {\r\n theValue = defValue;\r\n }\r\n // if (theValue && usingDefault && (isPlainObject(theValue) || isArray(theValue))) {\r\n // theValue = _cfgDeepCopy(theValue);\r\n // }\r\n // Needed to ensure that the (potentially) new field is dynamic even if null/undefined\r\n dynamicHandler.set(theConfig, name, theValue);\r\n if (reference) {\r\n dynamicHandler.ref(theConfig, name);\r\n }\r\n if (readOnly) {\r\n dynamicHandler[_DYN_RD_ONLY /* @min:%2erdOnly */](theConfig, name);\r\n }\r\n}\r\n//# sourceMappingURL=ConfigDefaults.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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -7,7 +7,7 @@
7
7
  import { dumpObj, objDefineProp, objForEachKey } from "@nevware21/ts-utils";
8
8
  import { createUniqueNamespace } from "../JavaScriptSDK/DataCacheHelper";
9
9
  import { STR_NOT_DYNAMIC_ERROR, STR_WARN_TO_CONSOLE } from "../JavaScriptSDK/InternalConstants";
10
- import { _DYN_CONFIGURABLE, _DYN_ENUMERABLE, _DYN_LOGGER, _DYN_NOTIFY, _DYN_SET_DF, _DYN_THROW_INTERNAL, _DYN_WATCH } from "../__DynamicConstants";
10
+ import { _DYN_CONFIGURABLE, _DYN_ENUMERABLE, _DYN_LOGGER, _DYN_NOTIFY, _DYN_RD_ONLY, _DYN_SET_DF, _DYN_THROW_INTERNAL, _DYN_WATCH } from "../__DynamicConstants";
11
11
  import { _applyDefaultValue } from "./ConfigDefaults";
12
12
  import { _makeDynamicObject, _setDynamicProperty } from "./DynamicProperty";
13
13
  import { _createState } from "./DynamicState";
@@ -88,7 +88,7 @@ function _createDynamicHandler(logger, target, inPlace) {
88
88
  _a[_DYN_SET_DF /* @min:setDf */] = _applyDefaults,
89
89
  _a[_DYN_WATCH /* @min:watch */] = _watch,
90
90
  _a.ref = _ref,
91
- _a.rdOnly = _rdOnly,
91
+ _a[_DYN_RD_ONLY /* @min:rdOnly */] = _rdOnly,
92
92
  _a._block = _block,
93
93
  _a);
94
94
  objDefineProp(cfgHandler, "uid", (_b = {},
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicConfig.js.map","sources":["DynamicConfig.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dumpObj, objDefineProp, objForEachKey } from \"@nevware21/ts-utils\";\r\nimport { createUniqueNamespace } from \"../JavaScriptSDK/DataCacheHelper\";\r\nimport { STR_NOT_DYNAMIC_ERROR, STR_WARN_TO_CONSOLE } from \"../JavaScriptSDK/InternalConstants\";\r\nimport { _DYN_CONFIGURABLE, _DYN_ENUMERABLE, _DYN_LOGGER, _DYN_NOTIFY, _DYN_SET_DF, _DYN_THROW_INTERNAL, _DYN_WATCH } from \"../__DynamicConstants\";\r\nimport { _applyDefaultValue } from \"./ConfigDefaults\";\r\nimport { _makeDynamicObject, _setDynamicProperty } from \"./DynamicProperty\";\r\nimport { _createState } from \"./DynamicState\";\r\nimport { CFG_HANDLER_LINK, _cfgDeepCopy, getDynamicConfigHandler, throwInvalidAccess } from \"./DynamicSupport\";\r\n/**\r\n * Identifies a function which will be re-called whenever any of it's accessed configuration values\r\n * change.\r\n * @param configHandler - The callback that will be called for the initial request and then whenever any\r\n * accessed configuration changes are identified.\r\n */\r\nfunction _createAndUseHandler(state, configHandler) {\r\n var handler = {\r\n fn: configHandler,\r\n rm: function () {\r\n // Clear all references to the handler so it can be garbage collected\r\n // This will also cause this handler to never get called and eventually removed\r\n handler.fn = null;\r\n state = null;\r\n configHandler = null;\r\n }\r\n };\r\n state.use(handler, configHandler);\r\n return handler;\r\n}\r\n/**\r\n * Creates the dynamic config handler and associates with the target config as the root object\r\n * @param target - The config that you want to be root of the dynamic config\r\n * @param inPlace - Should the passed config be converted in-place or a new proxy returned\r\n * @returns The existing dynamic handler or a new instance with the provided config values\r\n */\r\nfunction _createDynamicHandler(logger, target, inPlace) {\r\n var _a, _b;\r\n var dynamicHandler = getDynamicConfigHandler(target);\r\n if (dynamicHandler) {\r\n // The passed config is already dynamic so return it's tracker\r\n return dynamicHandler;\r\n }\r\n var uid = createUniqueNamespace(\"dyncfg\", true);\r\n var newTarget = (target && inPlace !== false) ? target : _cfgDeepCopy(target);\r\n var theState;\r\n function _notifyWatchers() {\r\n theState[_DYN_NOTIFY /* @min:%2enotify */]();\r\n }\r\n function _setValue(target, name, value) {\r\n return _setDynamicProperty(theState, target, name, value);\r\n }\r\n function _watch(configHandler) {\r\n return _createAndUseHandler(theState, configHandler);\r\n }\r\n function _block(configHandler) {\r\n theState.use(null, configHandler);\r\n }\r\n function _ref(target, name) {\r\n // Make sure it's dynamic and mark as referenced with it's current value\r\n return _setDynamicProperty(theState, target, name, target[name], true);\r\n }\r\n function _rdOnly(target, name) {\r\n // Make sure it's dynamic and mark as readonly with it's current value\r\n return _setDynamicProperty(theState, target, name, target[name], false, true);\r\n }\r\n function _applyDefaults(theConfig, defaultValues) {\r\n if (defaultValues) {\r\n // Resolve/apply the defaults\r\n objForEachKey(defaultValues, function (name, value) {\r\n // Sets the value and makes it dynamic (if it doesn't already exist)\r\n _applyDefaultValue(cfgHandler, theConfig, name, value);\r\n });\r\n }\r\n return theConfig;\r\n }\r\n var cfgHandler = (_a = {\r\n uid: null,\r\n cfg: newTarget\r\n },\r\n _a[_DYN_LOGGER /* @min:logger */] = logger,\r\n _a[_DYN_NOTIFY /* @min:notify */] = _notifyWatchers,\r\n _a.set = _setValue,\r\n _a[_DYN_SET_DF /* @min:setDf */] = _applyDefaults,\r\n _a[_DYN_WATCH /* @min:watch */] = _watch,\r\n _a.ref = _ref,\r\n _a.rdOnly = _rdOnly,\r\n _a._block = _block,\r\n _a);\r\n objDefineProp(cfgHandler, \"uid\", (_b = {},\r\n _b[_DYN_CONFIGURABLE /* @min:configurable */] = false,\r\n _b[_DYN_ENUMERABLE /* @min:enumerable */] = false,\r\n _b.writable = false,\r\n _b.value = uid,\r\n _b));\r\n theState = _createState(cfgHandler);\r\n // Setup tracking for all defined default keys\r\n _makeDynamicObject(theState, newTarget);\r\n return cfgHandler;\r\n}\r\n/**\r\n * Log an invalid access message to the console\r\n * @param message\r\n */\r\nfunction _logInvalidAccess(logger, message) {\r\n if (logger) {\r\n logger[STR_WARN_TO_CONSOLE /* @min:%2ewarnToConsole */](message);\r\n logger[_DYN_THROW_INTERNAL /* @min:%2ethrowInternal */](2 /* eLoggingSeverity.WARNING */, 108 /* _eInternalMessageId.DynamicConfigException */, message);\r\n }\r\n else {\r\n // We don't have a logger so just throw an exception\r\n throwInvalidAccess(message);\r\n }\r\n}\r\n/**\r\n * Create or return a dynamic version of the passed config, if it is not already dynamic\r\n * @param config - The config to be converted into a dynamic config\r\n * @param defaultConfig - The default values to apply on the config if the properties don't already exist\r\n * @param inPlace - Should the config be converted in-place into a dynamic config or a new instance returned, defaults to true\r\n * @returns The dynamic config handler for the config (whether new or existing)\r\n */\r\nexport function createDynamicConfig(config, defaultConfig, logger, inPlace) {\r\n var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);\r\n if (defaultConfig) {\r\n dynamicHandler[_DYN_SET_DF /* @min:%2esetDf */](dynamicHandler.cfg, defaultConfig);\r\n }\r\n return dynamicHandler;\r\n}\r\n/**\r\n * Watch and track changes for accesses to the current config, the provided config MUST already be\r\n * a dynamic config or a child accessed via the dynamic config\r\n * @param config\r\n * @param configHandler\r\n * @param logger - The logger instance to use if there is no existing handler\r\n * @returns A watcher handler instance that can be used to remove itself when being unloaded\r\n * @throws TypeError if the provided config is not a dynamic config instance\r\n */\r\nexport function onConfigChange(config, configHandler, logger) {\r\n var handler = config[CFG_HANDLER_LINK] || config;\r\n if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {\r\n return handler[_DYN_WATCH /* @min:%2ewatch */](configHandler);\r\n }\r\n _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));\r\n createDynamicConfig(config, null, logger)[_DYN_WATCH /* @min:%2ewatch */](configHandler);\r\n}\r\n//# sourceMappingURL=DynamicConfig.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"}
1
+ {"version":3,"file":"DynamicConfig.js.map","sources":["DynamicConfig.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dumpObj, objDefineProp, objForEachKey } from \"@nevware21/ts-utils\";\r\nimport { createUniqueNamespace } from \"../JavaScriptSDK/DataCacheHelper\";\r\nimport { STR_NOT_DYNAMIC_ERROR, STR_WARN_TO_CONSOLE } from \"../JavaScriptSDK/InternalConstants\";\r\nimport { _DYN_CONFIGURABLE, _DYN_ENUMERABLE, _DYN_LOGGER, _DYN_NOTIFY, _DYN_RD_ONLY, _DYN_SET_DF, _DYN_THROW_INTERNAL, _DYN_WATCH } from \"../__DynamicConstants\";\r\nimport { _applyDefaultValue } from \"./ConfigDefaults\";\r\nimport { _makeDynamicObject, _setDynamicProperty } from \"./DynamicProperty\";\r\nimport { _createState } from \"./DynamicState\";\r\nimport { CFG_HANDLER_LINK, _cfgDeepCopy, getDynamicConfigHandler, throwInvalidAccess } from \"./DynamicSupport\";\r\n/**\r\n * Identifies a function which will be re-called whenever any of it's accessed configuration values\r\n * change.\r\n * @param configHandler - The callback that will be called for the initial request and then whenever any\r\n * accessed configuration changes are identified.\r\n */\r\nfunction _createAndUseHandler(state, configHandler) {\r\n var handler = {\r\n fn: configHandler,\r\n rm: function () {\r\n // Clear all references to the handler so it can be garbage collected\r\n // This will also cause this handler to never get called and eventually removed\r\n handler.fn = null;\r\n state = null;\r\n configHandler = null;\r\n }\r\n };\r\n state.use(handler, configHandler);\r\n return handler;\r\n}\r\n/**\r\n * Creates the dynamic config handler and associates with the target config as the root object\r\n * @param target - The config that you want to be root of the dynamic config\r\n * @param inPlace - Should the passed config be converted in-place or a new proxy returned\r\n * @returns The existing dynamic handler or a new instance with the provided config values\r\n */\r\nfunction _createDynamicHandler(logger, target, inPlace) {\r\n var _a, _b;\r\n var dynamicHandler = getDynamicConfigHandler(target);\r\n if (dynamicHandler) {\r\n // The passed config is already dynamic so return it's tracker\r\n return dynamicHandler;\r\n }\r\n var uid = createUniqueNamespace(\"dyncfg\", true);\r\n var newTarget = (target && inPlace !== false) ? target : _cfgDeepCopy(target);\r\n var theState;\r\n function _notifyWatchers() {\r\n theState[_DYN_NOTIFY /* @min:%2enotify */]();\r\n }\r\n function _setValue(target, name, value) {\r\n return _setDynamicProperty(theState, target, name, value);\r\n }\r\n function _watch(configHandler) {\r\n return _createAndUseHandler(theState, configHandler);\r\n }\r\n function _block(configHandler) {\r\n theState.use(null, configHandler);\r\n }\r\n function _ref(target, name) {\r\n // Make sure it's dynamic and mark as referenced with it's current value\r\n return _setDynamicProperty(theState, target, name, target[name], true);\r\n }\r\n function _rdOnly(target, name) {\r\n // Make sure it's dynamic and mark as readonly with it's current value\r\n return _setDynamicProperty(theState, target, name, target[name], false, true);\r\n }\r\n function _applyDefaults(theConfig, defaultValues) {\r\n if (defaultValues) {\r\n // Resolve/apply the defaults\r\n objForEachKey(defaultValues, function (name, value) {\r\n // Sets the value and makes it dynamic (if it doesn't already exist)\r\n _applyDefaultValue(cfgHandler, theConfig, name, value);\r\n });\r\n }\r\n return theConfig;\r\n }\r\n var cfgHandler = (_a = {\r\n uid: null,\r\n cfg: newTarget\r\n },\r\n _a[_DYN_LOGGER /* @min:logger */] = logger,\r\n _a[_DYN_NOTIFY /* @min:notify */] = _notifyWatchers,\r\n _a.set = _setValue,\r\n _a[_DYN_SET_DF /* @min:setDf */] = _applyDefaults,\r\n _a[_DYN_WATCH /* @min:watch */] = _watch,\r\n _a.ref = _ref,\r\n _a[_DYN_RD_ONLY /* @min:rdOnly */] = _rdOnly,\r\n _a._block = _block,\r\n _a);\r\n objDefineProp(cfgHandler, \"uid\", (_b = {},\r\n _b[_DYN_CONFIGURABLE /* @min:configurable */] = false,\r\n _b[_DYN_ENUMERABLE /* @min:enumerable */] = false,\r\n _b.writable = false,\r\n _b.value = uid,\r\n _b));\r\n theState = _createState(cfgHandler);\r\n // Setup tracking for all defined default keys\r\n _makeDynamicObject(theState, newTarget);\r\n return cfgHandler;\r\n}\r\n/**\r\n * Log an invalid access message to the console\r\n * @param message\r\n */\r\nfunction _logInvalidAccess(logger, message) {\r\n if (logger) {\r\n logger[STR_WARN_TO_CONSOLE /* @min:%2ewarnToConsole */](message);\r\n logger[_DYN_THROW_INTERNAL /* @min:%2ethrowInternal */](2 /* eLoggingSeverity.WARNING */, 108 /* _eInternalMessageId.DynamicConfigException */, message);\r\n }\r\n else {\r\n // We don't have a logger so just throw an exception\r\n throwInvalidAccess(message);\r\n }\r\n}\r\n/**\r\n * Create or return a dynamic version of the passed config, if it is not already dynamic\r\n * @param config - The config to be converted into a dynamic config\r\n * @param defaultConfig - The default values to apply on the config if the properties don't already exist\r\n * @param inPlace - Should the config be converted in-place into a dynamic config or a new instance returned, defaults to true\r\n * @returns The dynamic config handler for the config (whether new or existing)\r\n */\r\nexport function createDynamicConfig(config, defaultConfig, logger, inPlace) {\r\n var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);\r\n if (defaultConfig) {\r\n dynamicHandler[_DYN_SET_DF /* @min:%2esetDf */](dynamicHandler.cfg, defaultConfig);\r\n }\r\n return dynamicHandler;\r\n}\r\n/**\r\n * Watch and track changes for accesses to the current config, the provided config MUST already be\r\n * a dynamic config or a child accessed via the dynamic config\r\n * @param config\r\n * @param configHandler\r\n * @param logger - The logger instance to use if there is no existing handler\r\n * @returns A watcher handler instance that can be used to remove itself when being unloaded\r\n * @throws TypeError if the provided config is not a dynamic config instance\r\n */\r\nexport function onConfigChange(config, configHandler, logger) {\r\n var handler = config[CFG_HANDLER_LINK] || config;\r\n if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {\r\n return handler[_DYN_WATCH /* @min:%2ewatch */](configHandler);\r\n }\r\n _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));\r\n createDynamicConfig(config, null, logger)[_DYN_WATCH /* @min:%2ewatch */](configHandler);\r\n}\r\n//# sourceMappingURL=DynamicConfig.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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,12 +1,12 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
7
  import { arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from "@nevware21/ts-utils";
8
8
  import { throwAggregationError } from "../JavaScriptSDK/AggregationError";
9
- import { _DYN_CANCEL, _DYN_LENGTH, _DYN_LOGGER, _DYN_NOTIFY, _DYN_PUSH, _DYN_SET_DF, _DYN_THROW_INTERNAL } from "../__DynamicConstants";
9
+ import { _DYN_CANCEL, _DYN_LENGTH, _DYN_LOGGER, _DYN_NOTIFY, _DYN_PUSH, _DYN_RD_ONLY, _DYN_SET_DF, _DYN_THROW_INTERNAL } from "../__DynamicConstants";
10
10
  var symPrefix = "[[ai_";
11
11
  var symPostfix = "]]";
12
12
  export function _createState(cfgHandler) {
@@ -34,7 +34,7 @@ export function _createState(cfgHandler) {
34
34
  set: cfgHandler.set.bind(cfgHandler),
35
35
  setDf: cfgHandler[_DYN_SET_DF /* @min:%2esetDf */].bind(cfgHandler),
36
36
  ref: cfgHandler.ref.bind(cfgHandler),
37
- rdOnly: cfgHandler.rdOnly.bind(cfgHandler)
37
+ rdOnly: cfgHandler[_DYN_RD_ONLY /* @min:%2erdOnly */].bind(cfgHandler)
38
38
  });
39
39
  }
40
40
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicState.js.map","sources":["DynamicState.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from \"@nevware21/ts-utils\";\r\nimport { throwAggregationError } from \"../JavaScriptSDK/AggregationError\";\r\nimport { _DYN_CANCEL, _DYN_LENGTH, _DYN_LOGGER, _DYN_NOTIFY, _DYN_PUSH, _DYN_SET_DF, _DYN_THROW_INTERNAL } from \"../__DynamicConstants\";\r\nvar symPrefix = \"[[ai_\";\r\nvar symPostfix = \"]]\";\r\nexport function _createState(cfgHandler) {\r\n var _a;\r\n var dynamicPropertySymbol = newSymbol(symPrefix + \"get\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyReadOnly = newSymbol(symPrefix + \"ro\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyReferenced = newSymbol(symPrefix + \"rf\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyDetail = newSymbol(symPrefix + \"dtl\" + cfgHandler.uid + symPostfix);\r\n var _waitingHandlers = null;\r\n var _watcherTimer = null;\r\n var theState;\r\n function _useHandler(activeHandler, callback) {\r\n var prevWatcher = theState.act;\r\n try {\r\n theState.act = activeHandler;\r\n if (activeHandler && activeHandler[dynamicPropertyDetail]) {\r\n // Clear out the previously tracked details for this handler, so that access are re-evaluated\r\n arrForEach(activeHandler[dynamicPropertyDetail], function (detail) {\r\n detail.clr(activeHandler);\r\n });\r\n activeHandler[dynamicPropertyDetail] = [];\r\n }\r\n callback({\r\n cfg: cfgHandler.cfg,\r\n set: cfgHandler.set.bind(cfgHandler),\r\n setDf: cfgHandler[_DYN_SET_DF /* @min:%2esetDf */].bind(cfgHandler),\r\n ref: cfgHandler.ref.bind(cfgHandler),\r\n rdOnly: cfgHandler.rdOnly.bind(cfgHandler)\r\n });\r\n }\r\n catch (e) {\r\n var logger = cfgHandler[_DYN_LOGGER /* @min:%2elogger */];\r\n if (logger) {\r\n // Don't let one individual failure break everyone\r\n logger[_DYN_THROW_INTERNAL /* @min:%2ethrowInternal */](1 /* eLoggingSeverity.CRITICAL */, 107 /* _eInternalMessageId.ConfigWatcherException */, dumpObj(e));\r\n }\r\n // Re-throw the exception so that any true \"error\" is reported back to the called\r\n throw e;\r\n }\r\n finally {\r\n theState.act = prevWatcher || null;\r\n }\r\n }\r\n function _notifyWatchers() {\r\n if (_waitingHandlers) {\r\n var notifyHandlers = _waitingHandlers;\r\n _waitingHandlers = null;\r\n // Stop any timer as we are running them now anyway\r\n _watcherTimer && _watcherTimer[_DYN_CANCEL /* @min:%2ecancel */]();\r\n _watcherTimer = null;\r\n var watcherFailures_1 = [];\r\n // Now run the handlers\r\n arrForEach(notifyHandlers, function (handler) {\r\n if (handler) {\r\n if (handler[dynamicPropertyDetail]) {\r\n arrForEach(handler[dynamicPropertyDetail], function (detail) {\r\n // Clear out this handler from previously tracked details, so that access are re-evaluated\r\n detail.clr(handler);\r\n });\r\n handler[dynamicPropertyDetail] = null;\r\n }\r\n // The handler may have self removed as part of another handler so re-check\r\n if (handler.fn) {\r\n try {\r\n _useHandler(handler, handler.fn);\r\n }\r\n catch (e) {\r\n // Don't let a single failing watcher cause other watches to fail\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n }\r\n });\r\n // During notification we may have had additional updates -- so notify those updates as well\r\n if (_waitingHandlers) {\r\n try {\r\n _notifyWatchers();\r\n }\r\n catch (e) {\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n if (watcherFailures_1[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n throwAggregationError(\"Watcher error(s): \", watcherFailures_1);\r\n }\r\n }\r\n }\r\n function _addWatcher(detail) {\r\n if (detail && detail.h[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n if (!_waitingHandlers) {\r\n _waitingHandlers = [];\r\n }\r\n if (!_watcherTimer) {\r\n _watcherTimer = scheduleTimeout(function () {\r\n _watcherTimer = null;\r\n _notifyWatchers();\r\n }, 0);\r\n }\r\n // Add all of the handlers for this detail (if not already present) - using normal for-loop for performance\r\n for (var idx = 0; idx < detail.h[_DYN_LENGTH /* @min:%2elength */]; idx++) {\r\n var handler = detail.h[idx];\r\n // Add this handler to the collection of handlers to re-execute\r\n if (handler && arrIndexOf(_waitingHandlers, handler) === -1) {\r\n _waitingHandlers[_DYN_PUSH /* @min:%2epush */](handler);\r\n }\r\n }\r\n }\r\n }\r\n function _trackHandler(handler, detail) {\r\n if (handler) {\r\n var details = handler[dynamicPropertyDetail] = handler[dynamicPropertyDetail] || [];\r\n if (arrIndexOf(details, detail) === -1) {\r\n // If this detail is not already listed as tracked then add it so that we re-evaluate it's usage\r\n details[_DYN_PUSH /* @min:%2epush */](detail);\r\n }\r\n }\r\n }\r\n theState = (_a = {\r\n prop: dynamicPropertySymbol,\r\n ro: dynamicPropertyReadOnly,\r\n rf: dynamicPropertyReferenced,\r\n hdlr: cfgHandler,\r\n add: _addWatcher\r\n },\r\n _a[_DYN_NOTIFY /* @min:notify */] = _notifyWatchers,\r\n _a.use = _useHandler,\r\n _a.trk = _trackHandler,\r\n _a);\r\n return theState;\r\n}\r\n//# sourceMappingURL=DynamicState.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"}
1
+ {"version":3,"file":"DynamicState.js.map","sources":["DynamicState.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from \"@nevware21/ts-utils\";\r\nimport { throwAggregationError } from \"../JavaScriptSDK/AggregationError\";\r\nimport { _DYN_CANCEL, _DYN_LENGTH, _DYN_LOGGER, _DYN_NOTIFY, _DYN_PUSH, _DYN_RD_ONLY, _DYN_SET_DF, _DYN_THROW_INTERNAL } from \"../__DynamicConstants\";\r\nvar symPrefix = \"[[ai_\";\r\nvar symPostfix = \"]]\";\r\nexport function _createState(cfgHandler) {\r\n var _a;\r\n var dynamicPropertySymbol = newSymbol(symPrefix + \"get\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyReadOnly = newSymbol(symPrefix + \"ro\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyReferenced = newSymbol(symPrefix + \"rf\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyDetail = newSymbol(symPrefix + \"dtl\" + cfgHandler.uid + symPostfix);\r\n var _waitingHandlers = null;\r\n var _watcherTimer = null;\r\n var theState;\r\n function _useHandler(activeHandler, callback) {\r\n var prevWatcher = theState.act;\r\n try {\r\n theState.act = activeHandler;\r\n if (activeHandler && activeHandler[dynamicPropertyDetail]) {\r\n // Clear out the previously tracked details for this handler, so that access are re-evaluated\r\n arrForEach(activeHandler[dynamicPropertyDetail], function (detail) {\r\n detail.clr(activeHandler);\r\n });\r\n activeHandler[dynamicPropertyDetail] = [];\r\n }\r\n callback({\r\n cfg: cfgHandler.cfg,\r\n set: cfgHandler.set.bind(cfgHandler),\r\n setDf: cfgHandler[_DYN_SET_DF /* @min:%2esetDf */].bind(cfgHandler),\r\n ref: cfgHandler.ref.bind(cfgHandler),\r\n rdOnly: cfgHandler[_DYN_RD_ONLY /* @min:%2erdOnly */].bind(cfgHandler)\r\n });\r\n }\r\n catch (e) {\r\n var logger = cfgHandler[_DYN_LOGGER /* @min:%2elogger */];\r\n if (logger) {\r\n // Don't let one individual failure break everyone\r\n logger[_DYN_THROW_INTERNAL /* @min:%2ethrowInternal */](1 /* eLoggingSeverity.CRITICAL */, 107 /* _eInternalMessageId.ConfigWatcherException */, dumpObj(e));\r\n }\r\n // Re-throw the exception so that any true \"error\" is reported back to the called\r\n throw e;\r\n }\r\n finally {\r\n theState.act = prevWatcher || null;\r\n }\r\n }\r\n function _notifyWatchers() {\r\n if (_waitingHandlers) {\r\n var notifyHandlers = _waitingHandlers;\r\n _waitingHandlers = null;\r\n // Stop any timer as we are running them now anyway\r\n _watcherTimer && _watcherTimer[_DYN_CANCEL /* @min:%2ecancel */]();\r\n _watcherTimer = null;\r\n var watcherFailures_1 = [];\r\n // Now run the handlers\r\n arrForEach(notifyHandlers, function (handler) {\r\n if (handler) {\r\n if (handler[dynamicPropertyDetail]) {\r\n arrForEach(handler[dynamicPropertyDetail], function (detail) {\r\n // Clear out this handler from previously tracked details, so that access are re-evaluated\r\n detail.clr(handler);\r\n });\r\n handler[dynamicPropertyDetail] = null;\r\n }\r\n // The handler may have self removed as part of another handler so re-check\r\n if (handler.fn) {\r\n try {\r\n _useHandler(handler, handler.fn);\r\n }\r\n catch (e) {\r\n // Don't let a single failing watcher cause other watches to fail\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n }\r\n });\r\n // During notification we may have had additional updates -- so notify those updates as well\r\n if (_waitingHandlers) {\r\n try {\r\n _notifyWatchers();\r\n }\r\n catch (e) {\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n if (watcherFailures_1[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n throwAggregationError(\"Watcher error(s): \", watcherFailures_1);\r\n }\r\n }\r\n }\r\n function _addWatcher(detail) {\r\n if (detail && detail.h[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n if (!_waitingHandlers) {\r\n _waitingHandlers = [];\r\n }\r\n if (!_watcherTimer) {\r\n _watcherTimer = scheduleTimeout(function () {\r\n _watcherTimer = null;\r\n _notifyWatchers();\r\n }, 0);\r\n }\r\n // Add all of the handlers for this detail (if not already present) - using normal for-loop for performance\r\n for (var idx = 0; idx < detail.h[_DYN_LENGTH /* @min:%2elength */]; idx++) {\r\n var handler = detail.h[idx];\r\n // Add this handler to the collection of handlers to re-execute\r\n if (handler && arrIndexOf(_waitingHandlers, handler) === -1) {\r\n _waitingHandlers[_DYN_PUSH /* @min:%2epush */](handler);\r\n }\r\n }\r\n }\r\n }\r\n function _trackHandler(handler, detail) {\r\n if (handler) {\r\n var details = handler[dynamicPropertyDetail] = handler[dynamicPropertyDetail] || [];\r\n if (arrIndexOf(details, detail) === -1) {\r\n // If this detail is not already listed as tracked then add it so that we re-evaluate it's usage\r\n details[_DYN_PUSH /* @min:%2epush */](detail);\r\n }\r\n }\r\n }\r\n theState = (_a = {\r\n prop: dynamicPropertySymbol,\r\n ro: dynamicPropertyReadOnly,\r\n rf: dynamicPropertyReferenced,\r\n hdlr: cfgHandler,\r\n add: _addWatcher\r\n },\r\n _a[_DYN_NOTIFY /* @min:notify */] = _notifyWatchers,\r\n _a.use = _useHandler,\r\n _a.trk = _trackHandler,\r\n _a);\r\n return theState;\r\n}\r\n//# sourceMappingURL=DynamicState.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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-04
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2302-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5