@microsoft/sp-component-base 1.23.1 → 1.24.0-beta.2

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 (171) hide show
  1. package/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +136 -141
  2. package/dist/{chunk.legacy-third-party-fabric-core-localfont_none_9e84ea19c68fdc8b9094.js → chunk.legacy-third-party-fabric-core-localfont_none_b7f7978a3e90166c361b.js} +1 -1
  3. package/dist/chunk.teams-apps-client_none_27d3c7c1d01080e4f131.js +2 -0
  4. package/dist/index-internal-beta.d.ts +30 -8
  5. package/dist/index-internal-public.d.ts +30 -8
  6. package/dist/index-internal.d.ts +30 -8
  7. package/dist/sp-component-base_default_8d535b51fa18aa47002b.js +22 -0
  8. package/dist/sp-component-base_en-us_8ce25dfb69a7786caece.js +22 -0
  9. package/dist/sp-component-base_qps-ploc_4fec831895d90df8aa7a.js +22 -0
  10. package/dist/sp-component-base_qps-ploca_b80610c8dff04dcec755.js +22 -0
  11. package/dist/tsdoc-metadata.json +1 -1
  12. package/lib-commonjs/BaseComponent.js +110 -145
  13. package/lib-commonjs/BaseComponentContext.js +126 -183
  14. package/lib-commonjs/DynamicDataProvider.js +251 -268
  15. package/lib-commonjs/DynamicDataSourceManager.js +218 -241
  16. package/lib-commonjs/DynamicProperty.js +232 -280
  17. package/lib-commonjs/EnsureIsolatedDomainUrl.js +14 -14
  18. package/lib-commonjs/IComponentPosition.js +8 -3
  19. package/lib-commonjs/IComponentPropertyMetadata.js +10 -3
  20. package/lib-commonjs/ISerializedServerProcessedData.js +24 -21
  21. package/lib-commonjs/LegacyThirdPartyFabricCoreLoader.js +53 -87
  22. package/lib-commonjs/PropertyMetadataProcessor.js +117 -150
  23. package/lib-commonjs/RenderableComponentContext.js +37 -0
  24. package/lib-commonjs/ShimmerFactory.js +66 -51
  25. package/lib-commonjs/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +6 -4
  26. package/lib-commonjs/common/Flights.js +22 -10
  27. package/lib-commonjs/common/KillSwitches.js +13 -6
  28. package/lib-commonjs/dataCollector/IWebPartLoadData.js +35 -30
  29. package/lib-commonjs/dataCollector/WebPartLoadDataCollector.js +82 -91
  30. package/lib-commonjs/index.js +78 -38
  31. package/lib-commonjs/teams/DeferredTeamsAppsClient.js +30 -52
  32. package/lib-commonjs/teams/ITeamsAppCatalog.js +10 -3
  33. package/lib-commonjs/teams/TeamsAppsClient.js +189 -231
  34. package/lib-commonjs/test-api/MockComponent.js +38 -23
  35. package/lib-commonjs/test-api/MockComponentContext.js +21 -14
  36. package/lib-commonjs/test-api/index.js +21 -7
  37. package/lib-commonjs/themeProvider/ThemeProvider.js +68 -82
  38. package/lib-commonjs/themeProvider/themeInterfaces/IFontStyles.js +5 -2
  39. package/lib-commonjs/themeProvider/themeInterfaces/IPalette.js +10 -3
  40. package/lib-commonjs/themeProvider/themeInterfaces/ISemanticColors.js +59 -3
  41. package/lib-commonjs/themeProvider/themeInterfaces/ISemanticTextColors.js +10 -3
  42. package/lib-commonjs/themeProvider/themeInterfaces/ITheme.js +5 -2
  43. package/{lib → lib-dts}/BaseComponent.d.ts +8 -8
  44. package/{lib → lib-dts}/BaseComponentContext.d.ts +5 -5
  45. package/lib-dts/RenderableComponentContext.d.ts +35 -0
  46. package/{lib → lib-dts}/index.d.ts +1 -0
  47. package/lib-esm/BaseComponent.js +123 -0
  48. package/lib-esm/BaseComponentContext.js +157 -0
  49. package/lib-esm/DynamicDataProvider.js +401 -0
  50. package/lib-esm/DynamicDataSourceManager.js +358 -0
  51. package/lib-esm/DynamicProperty.js +344 -0
  52. package/{lib → lib-esm}/EnsureIsolatedDomainUrl.js +6 -6
  53. package/lib-esm/IComponentPosition.js +5 -0
  54. package/lib-esm/IComponentPropertyMetadata.js +7 -0
  55. package/lib-esm/ISerializedServerProcessedData.js +24 -0
  56. package/lib-esm/LegacyThirdPartyFabricCoreLoader.js +76 -0
  57. package/{lib → lib-esm}/PropertyMetadataProcessor.js +92 -127
  58. package/lib-esm/RenderableComponentContext.js +26 -0
  59. package/lib-esm/ShimmerFactory.js +74 -0
  60. package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +3 -3
  61. package/{lib → lib-esm}/common/Flights.js +4 -3
  62. package/{lib → lib-esm}/common/KillSwitches.js +3 -2
  63. package/lib-esm/dataCollector/IWebPartLoadData.js +33 -0
  64. package/lib-esm/dataCollector/WebPartLoadDataCollector.js +125 -0
  65. package/{lib → lib-esm}/index.js +4 -3
  66. package/lib-esm/teams/DeferredTeamsAppsClient.js +32 -0
  67. package/lib-esm/teams/ITeamsAppCatalog.js +9 -0
  68. package/lib-esm/teams/TeamsAppsClient.js +395 -0
  69. package/lib-esm/test-api/MockComponent.js +38 -0
  70. package/{lib → lib-esm}/test-api/MockComponentContext.js +10 -11
  71. package/{lib → lib-esm}/test-api/index.js +2 -1
  72. package/lib-esm/themeProvider/ThemeProvider.js +79 -0
  73. package/lib-esm/themeProvider/themeInterfaces/IFontStyles.js +7 -0
  74. package/lib-esm/themeProvider/themeInterfaces/IPalette.js +7 -0
  75. package/lib-esm/themeProvider/themeInterfaces/ISemanticColors.js +56 -0
  76. package/lib-esm/themeProvider/themeInterfaces/ISemanticTextColors.js +7 -0
  77. package/lib-esm/themeProvider/themeInterfaces/ITheme.js +7 -0
  78. package/package.json +41 -14
  79. package/dist/chunk.teams-apps-client_none_f9872389cb6ea9ad28e2.js +0 -2
  80. package/dist/sp-component-base_default_5ba07be39b0dc8968f7b.js +0 -2
  81. package/dist/sp-component-base_en-us_eb9bebb3acce0ae83f1c.js +0 -2
  82. package/dist/sp-component-base_qps-ploc_45f37623d87c3d848f2a.js +0 -2
  83. package/dist/sp-component-base_qps-ploca_b3f3b7bf97c4185b0fd6.js +0 -2
  84. package/lib/BaseComponent.d.ts.map +0 -1
  85. package/lib/BaseComponent.js +0 -161
  86. package/lib/BaseComponentContext.d.ts.map +0 -1
  87. package/lib/BaseComponentContext.js +0 -222
  88. package/lib/DynamicDataProvider.d.ts.map +0 -1
  89. package/lib/DynamicDataProvider.js +0 -420
  90. package/lib/DynamicDataSourceManager.d.ts.map +0 -1
  91. package/lib/DynamicDataSourceManager.js +0 -382
  92. package/lib/DynamicProperty.d.ts.map +0 -1
  93. package/lib/DynamicProperty.js +0 -390
  94. package/lib/EnsureIsolatedDomainUrl.d.ts.map +0 -1
  95. package/lib/IComponentPosition.d.ts.map +0 -1
  96. package/lib/IComponentPosition.js +0 -2
  97. package/lib/IComponentPropertyMetadata.d.ts.map +0 -1
  98. package/lib/IComponentPropertyMetadata.js +0 -2
  99. package/lib/ISerializedServerProcessedData.d.ts.map +0 -1
  100. package/lib/ISerializedServerProcessedData.js +0 -28
  101. package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +0 -1
  102. package/lib/LegacyThirdPartyFabricCoreLoader.js +0 -90
  103. package/lib/PropertyMetadataProcessor.d.ts.map +0 -1
  104. package/lib/ShimmerFactory.d.ts.map +0 -1
  105. package/lib/ShimmerFactory.js +0 -62
  106. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +0 -1
  107. package/lib/common/Flights.d.ts.map +0 -1
  108. package/lib/common/KillSwitches.d.ts.map +0 -1
  109. package/lib/dataCollector/IWebPartLoadData.d.ts.map +0 -1
  110. package/lib/dataCollector/IWebPartLoadData.js +0 -40
  111. package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +0 -1
  112. package/lib/dataCollector/WebPartLoadDataCollector.js +0 -137
  113. package/lib/index.d.ts.map +0 -1
  114. package/lib/teams/DeferredTeamsAppsClient.d.ts.map +0 -1
  115. package/lib/teams/DeferredTeamsAppsClient.js +0 -39
  116. package/lib/teams/ITeamsAppCatalog.d.ts.map +0 -1
  117. package/lib/teams/ITeamsAppCatalog.js +0 -2
  118. package/lib/teams/TeamsAppsClient.d.ts.map +0 -1
  119. package/lib/teams/TeamsAppsClient.js +0 -440
  120. package/lib/test-api/MockComponent.d.ts.map +0 -1
  121. package/lib/test-api/MockComponent.js +0 -31
  122. package/lib/test-api/MockComponentContext.d.ts.map +0 -1
  123. package/lib/test-api/index.d.ts.map +0 -1
  124. package/lib/themeProvider/ThemeProvider.d.ts.map +0 -1
  125. package/lib/themeProvider/ThemeProvider.js +0 -99
  126. package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +0 -1
  127. package/lib/themeProvider/themeInterfaces/IFontStyles.js +0 -2
  128. package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +0 -1
  129. package/lib/themeProvider/themeInterfaces/IPalette.js +0 -2
  130. package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +0 -1
  131. package/lib/themeProvider/themeInterfaces/ISemanticColors.js +0 -2
  132. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +0 -1
  133. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +0 -2
  134. package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +0 -1
  135. package/lib/themeProvider/themeInterfaces/ITheme.js +0 -2
  136. /package/{lib → lib-dts}/DynamicDataProvider.d.ts +0 -0
  137. /package/{lib → lib-dts}/DynamicDataSourceManager.d.ts +0 -0
  138. /package/{lib → lib-dts}/DynamicProperty.d.ts +0 -0
  139. /package/{lib → lib-dts}/EnsureIsolatedDomainUrl.d.ts +0 -0
  140. /package/{lib → lib-dts}/IComponentPosition.d.ts +0 -0
  141. /package/{lib → lib-dts}/IComponentPropertyMetadata.d.ts +0 -0
  142. /package/{lib → lib-dts}/ISerializedServerProcessedData.d.ts +0 -0
  143. /package/{lib → lib-dts}/LegacyThirdPartyFabricCoreLoader.d.ts +0 -0
  144. /package/{lib → lib-dts}/PropertyMetadataProcessor.d.ts +0 -0
  145. /package/{lib → lib-dts}/ShimmerFactory.d.ts +0 -0
  146. /package/{lib → lib-dts}/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +0 -0
  147. /package/{lib → lib-dts}/common/Flights.d.ts +0 -0
  148. /package/{lib → lib-dts}/common/KillSwitches.d.ts +0 -0
  149. /package/{lib → lib-dts}/dataCollector/IWebPartLoadData.d.ts +0 -0
  150. /package/{lib → lib-dts}/dataCollector/WebPartLoadDataCollector.d.ts +0 -0
  151. /package/{lib → lib-dts}/loc/Strings.resx.d.ts +0 -0
  152. /package/{lib → lib-dts}/teams/DeferredTeamsAppsClient.d.ts +0 -0
  153. /package/{lib → lib-dts}/teams/ITeamsAppCatalog.d.ts +0 -0
  154. /package/{lib → lib-dts}/teams/TeamsAppsClient.d.ts +0 -0
  155. /package/{lib → lib-dts}/test-api/MockComponent.d.ts +0 -0
  156. /package/{lib → lib-dts}/test-api/MockComponentContext.d.ts +0 -0
  157. /package/{lib → lib-dts}/test-api/index.d.ts +0 -0
  158. /package/{lib → lib-dts}/themeProvider/ThemeProvider.d.ts +0 -0
  159. /package/{lib → lib-dts}/themeProvider/themeInterfaces/IFontStyles.d.ts +0 -0
  160. /package/{lib → lib-dts}/themeProvider/themeInterfaces/IPalette.d.ts +0 -0
  161. /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticColors.d.ts +0 -0
  162. /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +0 -0
  163. /package/{lib → lib-dts}/themeProvider/themeInterfaces/ITheme.d.ts +0 -0
  164. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +0 -0
  165. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +0 -0
  166. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +0 -0
  167. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +0 -0
  168. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/iconDefinitions.css +0 -0
  169. /package/{lib → lib-esm}/loc/Strings.resx.json +0 -0
  170. /package/{lib → lib-esm}/sp-component-base.manifest.json +0 -0
  171. /package/{lib → lib-esm}/styles/shimmer.module.scss.css +0 -0
@@ -1,47 +1,39 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
5
- var sp_core_library_1 = require("@microsoft/sp-core-library");
6
- var sp_dynamic_data_1 = require("@microsoft/sp-dynamic-data");
7
- var lodash = tslib_1.__importStar(require("@microsoft/sp-lodash-subset"));
8
- var sp_lodash_subset_1 = require("@microsoft/sp-lodash-subset");
9
- var DynamicDataProvider_1 = tslib_1.__importDefault(require("./DynamicDataProvider"));
10
- var Strings_resx_1 = tslib_1.__importDefault(require("./loc/Strings.resx"));
11
- var KillSwitches_1 = require("./common/KillSwitches");
12
- /**
13
- * The Dynamic Data Source Manager is responsible for:
14
- * - Constructing the dynamic data source
15
- * - Allowing initialization of the dynamic data source by a component
16
- * - Allowing data source to update its metadata and notify when data has been updated.
17
- *
18
- * @public
19
- */
20
- var DynamicDataSourceManager = /** @class */ (function () {
21
- function DynamicDataSourceManager() {
22
- this._src = undefined;
23
- this._isDisposed = false;
24
- this._isInitialized = false;
25
- this._logSource = sp_diagnostics_1._LogSource.create('DynamicDataSourceManager');
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DynamicDataSourceManager;
26
9
  }
10
+ });
11
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ const _spdiagnostics = require("@microsoft/sp-diagnostics");
14
+ const _spcorelibrary = require("@microsoft/sp-core-library");
15
+ const _spdynamicdata = require("@microsoft/sp-dynamic-data");
16
+ const _splodashsubset = /*#__PURE__*/ _interop_require_wildcard._(require("@microsoft/sp-lodash-subset"));
17
+ const _DynamicDataProvider = /*#__PURE__*/ _interop_require_default._(require("./DynamicDataProvider"));
18
+ const _Stringsresx = /*#__PURE__*/ _interop_require_default._(require("./loc/Strings.resx"));
19
+ const _KillSwitches = require("./common/KillSwitches");
20
+ class DynamicDataSourceManager {
27
21
  /**
28
- * Initializes the Dynamic Data source manager for a specific component.
29
- *
30
- * @param component - Component on which the source is being constructed.
31
- *
32
- * @internal
33
- */
34
- DynamicDataSourceManager.prototype._initialize = function (component, serviceScope) {
35
- sp_core_library_1.Validate.isNotNullOrUndefined(component, 'component');
36
- sp_core_library_1.Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
22
+ * Initializes the Dynamic Data source manager for a specific component.
23
+ *
24
+ * @param component - Component on which the source is being constructed.
25
+ *
26
+ * @internal
27
+ */ _initialize(component, serviceScope) {
28
+ _spcorelibrary.Validate.isNotNullOrUndefined(component, 'component');
29
+ _spcorelibrary.Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
37
30
  this._component = component;
38
- this._dynamicDataManager = serviceScope.consume(sp_dynamic_data_1._DynamicDataUtilities.IDynamicDataManagerServiceKey);
31
+ this._dynamicDataManager = serviceScope.consume(_spdynamicdata._DynamicDataUtilities.IDynamicDataManagerServiceKey);
39
32
  this._isInitialized = true;
40
- };
33
+ }
41
34
  /**
42
- * Disposes the resources held by the Dynamic Data source.
43
- */
44
- DynamicDataSourceManager.prototype.dispose = function () {
35
+ * Disposes the resources held by the Dynamic Data source.
36
+ */ dispose() {
45
37
  if (!this._isDisposed) {
46
38
  if (this._src) {
47
39
  this._dynamicDataManager.removeSource(this._src.id);
@@ -52,109 +44,92 @@ var DynamicDataSourceManager = /** @class */ (function () {
52
44
  this._isInitialized = false;
53
45
  this._isDisposed = true;
54
46
  }
55
- };
56
- Object.defineProperty(DynamicDataSourceManager.prototype, "isDisposed", {
57
- /**
58
- * Returns true if the DynamicDataSourceManager is disposed.
59
- */
60
- get: function () {
61
- return this._isDisposed;
62
- },
63
- enumerable: false,
64
- configurable: true
65
- });
66
- Object.defineProperty(DynamicDataSourceManager.prototype, "_source", {
67
- /**
68
- * Returns the source of DynamicDataSourceManager.
69
- * @internal
70
- */
71
- get: function () {
72
- return this._src;
73
- },
74
- enumerable: false,
75
- configurable: true
76
- });
47
+ }
77
48
  /**
78
- * Initializes the Dynamic Data Source for the component.
79
- *
80
- * @param callableFunctions - Set of methods that are exposed through the Dynamic Data Source
81
- */
82
- DynamicDataSourceManager.prototype.initializeSource = function (callableFunctions) {
49
+ * Returns true if the DynamicDataSourceManager is disposed.
50
+ */ get isDisposed() {
51
+ return this._isDisposed;
52
+ }
53
+ /**
54
+ * Returns the source of DynamicDataSourceManager.
55
+ * @internal
56
+ */ get _source() {
57
+ return this._src;
58
+ }
59
+ /**
60
+ * Initializes the Dynamic Data Source for the component.
61
+ *
62
+ * @param callableFunctions - Set of methods that are exposed through the Dynamic Data Source
63
+ */ initializeSource(callableFunctions) {
83
64
  this._assertNotDisposed();
84
65
  this._assertInitialized();
85
66
  if (this._src) {
86
- throw new Error(Strings_resx_1.default.SourceAlreadyInitialized);
67
+ throw new Error(_Stringsresx.default.SourceAlreadyInitialized);
87
68
  }
88
69
  this._callableFunctions = callableFunctions;
89
70
  this._src = this._buildSource(this._component);
90
71
  this._dynamicDataManager.addSource(this._src);
91
- if (!(0, KillSwitches_1.isExemptWebPartWithDynamicDataFromLazyLoadKSActivated)()) {
72
+ if (!(0, _KillSwitches.isExemptWebPartWithDynamicDataFromLazyLoadKSActivated)()) {
92
73
  this._component._containsDynamicDataSource = true;
93
74
  }
94
- this._logFeatureEntry('DynamicDataSourceInitialized', { sourceId: this._src.id });
95
- };
75
+ this._logFeatureEntry('DynamicDataSourceInitialized', {
76
+ sourceId: this._src.id
77
+ });
78
+ }
96
79
  /**
97
- * Notifies that this source has updated its properties.
98
- *
99
- * When invoked, it enables to broadcast the notification to all the consumers who have
100
- * registered to this notification from this source.
101
- */
102
- DynamicDataSourceManager.prototype.notifySourceChanged = function () {
80
+ * Notifies that this source has updated its properties.
81
+ *
82
+ * When invoked, it enables to broadcast the notification to all the consumers who have
83
+ * registered to this notification from this source.
84
+ */ notifySourceChanged() {
103
85
  this._assertNotDisposed();
104
86
  this._assertInitialized();
105
87
  this._assertSourceExists();
106
88
  this._dynamicDataManager.notifySourceChanged(this._src.id);
107
- };
89
+ }
108
90
  /**
109
- * Notifies that this source has updated a specific property.
110
- *
111
- * When invoked, it enables to broadcast the notification to all the consumers who have
112
- * registered to this notification from this source.
113
- *
114
- * @param propertyId - Id of the updated property in the source.
115
- */
116
- DynamicDataSourceManager.prototype.notifyPropertyChanged = function (propertyId) {
117
- sp_core_library_1.Validate.isNonemptyString(propertyId, 'propertyId');
91
+ * Notifies that this source has updated a specific property.
92
+ *
93
+ * When invoked, it enables to broadcast the notification to all the consumers who have
94
+ * registered to this notification from this source.
95
+ *
96
+ * @param propertyId - Id of the updated property in the source.
97
+ */ notifyPropertyChanged(propertyId) {
98
+ _spcorelibrary.Validate.isNonemptyString(propertyId, 'propertyId');
118
99
  this._assertNotDisposed();
119
100
  this._assertInitialized();
120
101
  this._assertSourceExists();
121
102
  this._dynamicDataManager.notifyPropertyChanged(this._src.id, propertyId);
122
- };
103
+ }
123
104
  /**
124
- * Updates the metadata of the Dynamic Data Source.
125
- * It allows to update fields like title or description.
126
- * Auto-generated fields like alias, componentId or instanceId cannot be updated.
127
- *
128
- * @param metadata - Partial of the metadata.
129
- */
130
- DynamicDataSourceManager.prototype.updateMetadata = function (metadata) {
105
+ * Updates the metadata of the Dynamic Data Source.
106
+ * It allows to update fields like title or description.
107
+ * Auto-generated fields like alias, componentId or instanceId cannot be updated.
108
+ *
109
+ * @param metadata - Partial of the metadata.
110
+ */ updateMetadata(metadata) {
131
111
  this._assertNotDisposed();
132
112
  this._assertInitialized();
133
113
  this._assertSourceExists();
134
- sp_core_library_1.Validate.isNotNullOrUndefined(metadata, 'metadata');
114
+ _spcorelibrary.Validate.isNotNullOrUndefined(metadata, 'metadata');
135
115
  // Ensure that auto-generated properties are not updated.
136
116
  metadata.alias = undefined;
137
117
  metadata.componentId = undefined;
138
118
  metadata.instanceId = undefined;
139
- (0, sp_lodash_subset_1.merge)(this._src.metadata, metadata);
140
- };
141
- Object.defineProperty(DynamicDataSourceManager.prototype, "sourceId", {
142
- /**
143
- * Returns the Id of the current DataSource.
144
- * If the component did not initialize as a dynamic data source, then it returns an empty string.
145
- */
146
- get: function () {
147
- return this._src ? this._src.id : '';
148
- },
149
- enumerable: false,
150
- configurable: true
151
- });
152
- DynamicDataSourceManager.prototype._buildSource = function (component) {
119
+ (0, _splodashsubset.merge)(this._src.metadata, metadata);
120
+ }
121
+ /**
122
+ * Returns the Id of the current DataSource.
123
+ * If the component did not initialize as a dynamic data source, then it returns an empty string.
124
+ */ get sourceId() {
125
+ return this._src ? this._src.id : '';
126
+ }
127
+ _buildSource(component) {
153
128
  // If the source is returning non-empty allowed events then, it has to define
154
129
  // 'sendEvent' event handler as well.
155
130
  if (this._callableFunctions.allowedEvents && this._callableFunctions.allowedEvents.length > 0) {
156
131
  if (!this._callableFunctions.sendEvent) {
157
- throw new Error(Strings_resx_1.default.NoSendEventWhenAllowedEventsIsNonEmpty);
132
+ throw new Error(_Stringsresx.default.NoSendEventWhenAllowedEventsIsNonEmpty);
158
133
  }
159
134
  }
160
135
  return {
@@ -171,120 +146,112 @@ var DynamicDataSourceManager = /** @class */ (function () {
171
146
  allowedEventsAsync: this._allowedEventsAsync.bind(this),
172
147
  sendEvent: this._sendEvent.bind(this)
173
148
  };
174
- };
149
+ }
175
150
  /**
176
- * This is the allowedEvents() that the DynamicDataSource actually exposes.
177
- * It does a copy of the data to ensure the consumer doesn't modify the source.
178
- */
179
- DynamicDataSourceManager.prototype._allowedEvents = function () {
180
- return this._callableFunctions.allowedEvents
181
- ? (0, sp_lodash_subset_1.cloneDeep)(this._callableFunctions.allowedEvents())
182
- : undefined;
183
- };
151
+ * This is the allowedEvents() that the DynamicDataSource actually exposes.
152
+ * It does a copy of the data to ensure the consumer doesn't modify the source.
153
+ */ _allowedEvents() {
154
+ return this._callableFunctions.allowedEvents ? (0, _splodashsubset.cloneDeep)(this._callableFunctions.allowedEvents()) : undefined;
155
+ }
184
156
  /**
185
- * This is the sendEvent() that the consumer invokes to send an event to the source, with data.
186
- * @param eventName - Name of the event
187
- * @param data - Associated data
188
- */
189
- DynamicDataSourceManager.prototype._sendEvent = function (eventName, data) {
157
+ * This is the sendEvent() that the consumer invokes to send an event to the source, with data.
158
+ * @param eventName - Name of the event
159
+ * @param data - Associated data
160
+ */ _sendEvent(eventName, data) {
190
161
  this._assertValidEvent(eventName);
191
162
  this._callableFunctions.sendEvent(eventName, data);
192
- };
163
+ }
193
164
  /**
194
- * This is the getPropertyDefinitions() that the DynamicDataSource actually exposes.
195
- * It does a copy of the data to ensure the consumer doesn't modify the source.
196
- * This assumes that the component has dynamic data and has a controller.
197
- */
198
- DynamicDataSourceManager.prototype._getPropertyDefinitions = function () {
199
- return (0, sp_lodash_subset_1.cloneDeep)(this._callableFunctions.getPropertyDefinitions());
200
- };
165
+ * This is the getPropertyDefinitions() that the DynamicDataSource actually exposes.
166
+ * It does a copy of the data to ensure the consumer doesn't modify the source.
167
+ * This assumes that the component has dynamic data and has a controller.
168
+ */ _getPropertyDefinitions() {
169
+ return (0, _splodashsubset.cloneDeep)(this._callableFunctions.getPropertyDefinitions());
170
+ }
201
171
  /**
202
- * This is the getPropertyValue() that the DynamicDataSource actually exposes.
203
- * It does a copy of the data to ensure the consumer doesn't modify the source.
204
- * This assumes that the component has the source initialized.
205
- * If there is no value returned, it checks whether the propertyId is incorrect or the value is actually undefined.
206
- *
207
- * @remarks
208
- * If the property value associated with the property id, is an array then the
209
- * propertyId will have [*] notation appended at the end to support valid JSON Path notation.
210
- * Hence when reading the property id, we account for that and extract the name accordingly.
211
- */
212
- DynamicDataSourceManager.prototype._getPropertyValue = function (propertyId) {
213
- sp_core_library_1.Validate.isNotNullOrUndefined(propertyId, 'propertyId');
214
- var qosMonitor = new sp_diagnostics_1._QosMonitor('DynamicDataSourceManager._getPropertyValue');
215
- var paths = propertyId.split(DynamicDataProvider_1.default._jsonPathArrayRegex);
172
+ * This is the getPropertyValue() that the DynamicDataSource actually exposes.
173
+ * It does a copy of the data to ensure the consumer doesn't modify the source.
174
+ * This assumes that the component has the source initialized.
175
+ * If there is no value returned, it checks whether the propertyId is incorrect or the value is actually undefined.
176
+ *
177
+ * @remarks
178
+ * If the property value associated with the property id, is an array then the
179
+ * propertyId will have [*] notation appended at the end to support valid JSON Path notation.
180
+ * Hence when reading the property id, we account for that and extract the name accordingly.
181
+ */ _getPropertyValue(propertyId) {
182
+ _spcorelibrary.Validate.isNotNullOrUndefined(propertyId, 'propertyId');
183
+ const qosMonitor = new _spdiagnostics._QosMonitor('DynamicDataSourceManager._getPropertyValue');
184
+ const paths = propertyId.split(_DynamicDataProvider.default._jsonPathArrayRegex);
216
185
  try {
217
- var propertyValue = this._callableFunctions.getPropertyValue(paths.shift());
186
+ let propertyValue = this._callableFunctions.getPropertyValue(paths.shift());
218
187
  if (paths.length > 0) {
219
188
  if (!isNaN(parseInt(paths[0], 10)) && Array.isArray(propertyValue)) {
220
189
  propertyValue = propertyValue[paths[0]];
221
190
  }
222
191
  }
223
192
  if (propertyValue === undefined) {
224
- if (
225
- // This code can be slow if there is a many property definitions (O(n) for number of properties).
193
+ if (// This code can be slow if there is a many property definitions (O(n) for number of properties).
226
194
  // It's done this way to prioritize memory consumption instead of CPU cycles as this is an optional feature,
227
195
  // so if it's not used there is no memory footprint
228
- this._callableFunctions.getPropertyDefinitions().filter(function (def) { return def.id === propertyId; }).length ===
229
- 0 &&
230
- this._src // Check that the source exists to get its title
196
+ this._callableFunctions.getPropertyDefinitions().filter((def)=>def.id === propertyId).length === 0 && this._src // Check that the source exists to get its title
231
197
  ) {
232
- throw new Error("Property \"".concat(propertyId, "\" doesn't exist in source \"").concat(this._src.metadata.title, "\""));
198
+ throw new Error(`Property "${propertyId}" doesn't exist in source "${this._src.metadata.title}"`);
233
199
  }
234
200
  }
235
201
  // DO NOT log propertyValue it can contain PII.
236
- qosMonitor.writeSuccess(tslib_1.__assign(tslib_1.__assign({}, ((this._src && this._src.metadata) || {})), { sourceId: this._src && this._src.id, propertyId: propertyId }));
237
- return (0, sp_lodash_subset_1.cloneDeep)(propertyValue);
238
- }
239
- catch (error) {
240
- qosMonitor.writeUnexpectedFailure('NoPropertyId', error, { propertyId: propertyId });
241
- sp_diagnostics_1._TraceLogger.logErrorData({
202
+ qosMonitor.writeSuccess({
203
+ ...this._src && this._src.metadata || {},
204
+ sourceId: this._src && this._src.id,
205
+ propertyId
206
+ });
207
+ return (0, _splodashsubset.cloneDeep)(propertyValue);
208
+ } catch (error) {
209
+ qosMonitor.writeUnexpectedFailure('NoPropertyId', error, {
210
+ propertyId
211
+ });
212
+ _spdiagnostics._TraceLogger.logErrorData({
242
213
  source: this._logSource,
243
214
  error: error
244
215
  });
245
216
  return undefined;
246
217
  }
247
- };
218
+ }
248
219
  /**
249
- * Returns the real time value of the property.
250
- */
251
- DynamicDataSourceManager.prototype._getPropertyDefinitionsAsync = function () {
220
+ * Returns the real time value of the property.
221
+ */ _getPropertyDefinitionsAsync() {
252
222
  return Promise.resolve(this._getPropertyDefinitions());
253
- };
223
+ }
254
224
  /**
255
- * Returns the real time value of the property.
256
- * @param propertyId - property id for which the value is requested.
257
- */
258
- DynamicDataSourceManager.prototype._getPropertyValueAsync = function (propertyId) {
225
+ * Returns the real time value of the property.
226
+ * @param propertyId - property id for which the value is requested.
227
+ */ _getPropertyValueAsync(propertyId) {
259
228
  return Promise.resolve(this._getPropertyValue(propertyId));
260
- };
229
+ }
261
230
  /**
262
- * This is the allowedEvents() that the DynamicDataSource actually exposes.
263
- * It does a copy of the data to ensure the consumer doesn't modify the source.
264
- */
265
- DynamicDataSourceManager.prototype._allowedEventsAsync = function () {
231
+ * This is the allowedEvents() that the DynamicDataSource actually exposes.
232
+ * It does a copy of the data to ensure the consumer doesn't modify the source.
233
+ */ _allowedEventsAsync() {
266
234
  return Promise.resolve(this._allowedEvents());
267
- };
235
+ }
268
236
  /**
269
- * This is the getPropertyValueSchema() that the DynamicDataSource actually exposes.
270
- * It does a copy of the data to ensure the consumer doesn't modify the source.
271
- * If the source doesn't provide the annotated value, then it falls back to whatever
272
- * 'getPropertyValue' returns as the sample value and metadata would be undefined.
273
- *
274
- * @remarks
275
- * If the property value associated with the property id, is an array then the
276
- * propertyId will have [*] notation appended at the end to support valid JSON Path notation.
277
- * Hence when reading the property id, we account for that and extract the name accordingly.
278
- *
279
- * @param propertyId - property id for which the schema is requested.
280
- */
281
- DynamicDataSourceManager.prototype._getAnnotatedPropertyValue = function (propertyId) {
282
- sp_core_library_1.Validate.isNotNullOrUndefined(propertyId, 'propertyId');
283
- var qosMonitor = new sp_diagnostics_1._QosMonitor('DynamicDataSourceManager._getAnnotatedPropertyValue');
284
- var annotatedPropertyValue;
285
- var getAnnotatedPropertyValue = this._callableFunctions.getAnnotatedPropertyValue;
237
+ * This is the getPropertyValueSchema() that the DynamicDataSource actually exposes.
238
+ * It does a copy of the data to ensure the consumer doesn't modify the source.
239
+ * If the source doesn't provide the annotated value, then it falls back to whatever
240
+ * 'getPropertyValue' returns as the sample value and metadata would be undefined.
241
+ *
242
+ * @remarks
243
+ * If the property value associated with the property id, is an array then the
244
+ * propertyId will have [*] notation appended at the end to support valid JSON Path notation.
245
+ * Hence when reading the property id, we account for that and extract the name accordingly.
246
+ *
247
+ * @param propertyId - property id for which the schema is requested.
248
+ */ _getAnnotatedPropertyValue(propertyId) {
249
+ _spcorelibrary.Validate.isNotNullOrUndefined(propertyId, 'propertyId');
250
+ const qosMonitor = new _spdiagnostics._QosMonitor('DynamicDataSourceManager._getAnnotatedPropertyValue');
251
+ let annotatedPropertyValue;
252
+ const { getAnnotatedPropertyValue } = this._callableFunctions;
286
253
  if (getAnnotatedPropertyValue) {
287
- var paths = propertyId.split(DynamicDataProvider_1.default._jsonPathArrayRegex);
254
+ const paths = propertyId.split(_DynamicDataProvider.default._jsonPathArrayRegex);
288
255
  try {
289
256
  annotatedPropertyValue = this._callableFunctions.getAnnotatedPropertyValue(paths.shift());
290
257
  if (paths.length > 0) {
@@ -292,11 +259,17 @@ var DynamicDataSourceManager = /** @class */ (function () {
292
259
  annotatedPropertyValue = annotatedPropertyValue[paths[0]];
293
260
  }
294
261
  }
295
- qosMonitor.writeSuccess(tslib_1.__assign(tslib_1.__assign({}, ((this._src && this._src.metadata) || {})), { sourceId: this._src && this._src.id, annotatedPropertyValue: annotatedPropertyValue, propertyId: propertyId }));
296
- }
297
- catch (error) {
298
- qosMonitor.writeExpectedFailure('NoAnnotatedPropertyValue', error, { annotatedPropertyValue: annotatedPropertyValue });
299
- sp_diagnostics_1._TraceLogger.logErrorData({
262
+ qosMonitor.writeSuccess({
263
+ ...this._src && this._src.metadata || {},
264
+ sourceId: this._src && this._src.id,
265
+ annotatedPropertyValue,
266
+ propertyId
267
+ });
268
+ } catch (error) {
269
+ qosMonitor.writeExpectedFailure('NoAnnotatedPropertyValue', error, {
270
+ annotatedPropertyValue
271
+ });
272
+ _spdiagnostics._TraceLogger.logErrorData({
300
273
  source: this._logSource,
301
274
  error: error
302
275
  });
@@ -310,23 +283,22 @@ var DynamicDataSourceManager = /** @class */ (function () {
310
283
  };
311
284
  }
312
285
  return annotatedPropertyValue;
313
- };
286
+ }
314
287
  /**
315
- * Returns the annotated value of the property.
316
- * @param propertyId - property id for which the value is requested.
317
- */
318
- DynamicDataSourceManager.prototype._getAnnotatedPropertyValueAsync = function (propertyId) {
288
+ * Returns the annotated value of the property.
289
+ * @param propertyId - property id for which the value is requested.
290
+ */ _getAnnotatedPropertyValueAsync(propertyId) {
319
291
  return Promise.resolve(this._getAnnotatedPropertyValue(propertyId));
320
- };
321
- DynamicDataSourceManager.prototype._buildMetadata = function (component) {
322
- var metadata = {
292
+ }
293
+ _buildMetadata(component) {
294
+ const metadata = {
323
295
  title: component.manifest.alias,
324
296
  alias: component.manifest.alias,
325
297
  componentId: component.componentId,
326
298
  instanceId: component.instanceId
327
299
  };
328
300
  // Web parts have properties "title" and "description" that should go to the source by default.
329
- var componentWithMetadata = component;
301
+ const componentWithMetadata = component;
330
302
  if (componentWithMetadata.title) {
331
303
  metadata.title = componentWithMetadata.title;
332
304
  }
@@ -334,51 +306,56 @@ var DynamicDataSourceManager = /** @class */ (function () {
334
306
  metadata.description = componentWithMetadata.description;
335
307
  }
336
308
  return metadata;
337
- };
309
+ }
338
310
  /**
339
- * Asserts if the event is a valid event on the source.
340
- *
341
- * Its an invalid event in two cases:
342
- * 1. When '_allowedEvent()' api returns undefined
343
- * 2. When the event name is not one of the allowed events on the source.
344
- *
345
- * @param eventName - Name of the event.
346
- */
347
- DynamicDataSourceManager.prototype._assertValidEvent = function (eventName) {
348
- if (!this._allowedEvents() || (0, sp_lodash_subset_1.findIndex)(this._allowedEvents(), { name: eventName }) === -1) {
349
- throw new Error(sp_core_library_1.Text.format(Strings_resx_1.default.InvalidEvent, eventName, this._src.metadata.title));
311
+ * Asserts if the event is a valid event on the source.
312
+ *
313
+ * Its an invalid event in two cases:
314
+ * 1. When '_allowedEvent()' api returns undefined
315
+ * 2. When the event name is not one of the allowed events on the source.
316
+ *
317
+ * @param eventName - Name of the event.
318
+ */ _assertValidEvent(eventName) {
319
+ if (!this._allowedEvents() || (0, _splodashsubset.findIndex)(this._allowedEvents(), {
320
+ name: eventName
321
+ }) === -1) {
322
+ throw new Error(_spcorelibrary.Text.format(_Stringsresx.default.InvalidEvent, eventName, this._src.metadata.title));
350
323
  }
351
- };
352
- DynamicDataSourceManager.prototype._assertNotDisposed = function () {
324
+ }
325
+ _assertNotDisposed() {
353
326
  if (this.isDisposed) {
354
- throw new Error(Strings_resx_1.default.DynamicDataSourceManagerIsDisposed);
327
+ throw new Error(_Stringsresx.default.DynamicDataSourceManagerIsDisposed);
355
328
  }
356
- };
357
- DynamicDataSourceManager.prototype._assertInitialized = function () {
329
+ }
330
+ _assertInitialized() {
358
331
  if (!this._isInitialized) {
359
- throw new Error(Strings_resx_1.default.DynamicDataSourceManagerIsNotInitialized);
332
+ throw new Error(_Stringsresx.default.DynamicDataSourceManagerIsNotInitialized);
360
333
  }
361
- };
362
- DynamicDataSourceManager.prototype._assertSourceExists = function () {
334
+ }
335
+ _assertSourceExists() {
363
336
  if (!this._src) {
364
- throw new Error(Strings_resx_1.default.DynamicDataSourceIsNotInitialized);
337
+ throw new Error(_Stringsresx.default.DynamicDataSourceIsNotInitialized);
365
338
  }
366
- };
339
+ }
367
340
  /**
368
- * Logs a feature event.
369
- * @param logFeature - Name of the feature to log.
370
- * @param contextualProps - Contextual log properties of the feature event.
371
- */
372
- DynamicDataSourceManager.prototype._logFeatureEntry = function (logFeature, contextualProps) {
373
- var isInternal = this._component.manifest.isInternal || false;
374
- var logProperties = {
341
+ * Logs a feature event.
342
+ * @param logFeature - Name of the feature to log.
343
+ * @param contextualProps - Contextual log properties of the feature event.
344
+ */ _logFeatureEntry(logFeature, contextualProps) {
345
+ const isInternal = this._component.manifest.isInternal || false;
346
+ const logProperties = {
375
347
  alias: this._component.manifest.alias,
376
348
  isInternal: isInternal.toString()
377
349
  };
378
- var logEntry = new sp_diagnostics_1._LogEntry('DynamicDataSourceManager', logFeature, sp_diagnostics_1._LogType.Event, lodash.merge(logProperties, contextualProps));
379
- sp_diagnostics_1._EngagementLogger.logEventWithLogEntry(logEntry);
380
- };
381
- return DynamicDataSourceManager;
382
- }());
383
- exports.default = DynamicDataSourceManager;
384
- //# sourceMappingURL=DynamicDataSourceManager.js.map
350
+ const logEntry = new _spdiagnostics._LogEntry('DynamicDataSourceManager', logFeature, _spdiagnostics._LogType.Event, _splodashsubset.merge(logProperties, contextualProps));
351
+ _spdiagnostics._EngagementLogger.logEventWithLogEntry(logEntry);
352
+ }
353
+ constructor(){
354
+ this._src = undefined;
355
+ this._isDisposed = false;
356
+ this._isInitialized = false;
357
+ this._logSource = _spdiagnostics._LogSource.create('DynamicDataSourceManager');
358
+ }
359
+ }
360
+
361
+ //# sourceMappingURL=./DynamicDataSourceManager.js.map