@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,44 +1,39 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var sp_core_library_1 = require("@microsoft/sp-core-library");
5
- var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
6
- var sp_dynamic_data_1 = require("@microsoft/sp-dynamic-data");
7
- var lodash = tslib_1.__importStar(require("@microsoft/sp-lodash-subset"));
8
- /**
9
- * The Dynamic Data Provider allows components to consume Dynamic Data.
10
- * It allows components to request Dynamic Data sources and register/unregister to those.
11
- *
12
- * @public
13
- */
14
- var DynamicDataProvider = /** @class */ (function () {
15
- function DynamicDataProvider() {
16
- this._isDisposed = false;
17
- this._isInitialized = false;
18
- this._isSourcesChangedEventListenerAdded = false;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DynamicDataProvider;
19
9
  }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _spcorelibrary = require("@microsoft/sp-core-library");
13
+ const _spdiagnostics = require("@microsoft/sp-diagnostics");
14
+ const _spdynamicdata = require("@microsoft/sp-dynamic-data");
15
+ const _splodashsubset = /*#__PURE__*/ _interop_require_wildcard._(require("@microsoft/sp-lodash-subset"));
16
+ class DynamicDataProvider {
20
17
  /**
21
- * Initializes the Dynamic Data Provider for a specific component.
22
- *
23
- * @param component - Component that is going to use the Dynamic Data Provider.
24
- *
25
- * @internal
26
- */
27
- DynamicDataProvider.prototype._initialize = function (component, serviceScope) {
28
- sp_core_library_1.Validate.isNotNullOrUndefined(component, 'component');
29
- sp_core_library_1.Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
18
+ * Initializes the Dynamic Data Provider for a specific component.
19
+ *
20
+ * @param component - Component that is going to use the Dynamic Data Provider.
21
+ *
22
+ * @internal
23
+ */ _initialize(component, serviceScope) {
24
+ _spcorelibrary.Validate.isNotNullOrUndefined(component, 'component');
25
+ _spcorelibrary.Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
30
26
  this._component = component;
31
27
  // Initialize all the required datastructures
32
28
  this._pendingRegistrations = new Map();
33
- this._dynamicDataManager = serviceScope.consume(sp_dynamic_data_1._DynamicDataUtilities.IDynamicDataManagerServiceKey);
29
+ this._dynamicDataManager = serviceScope.consume(_spdynamicdata._DynamicDataUtilities.IDynamicDataManagerServiceKey);
34
30
  this._isInitialized = true;
35
31
  // Method bindings
36
32
  this._onSourcesChanged = this._onSourcesChanged.bind(this);
37
- };
33
+ }
38
34
  /**
39
- * Disposes the Dynamic Data Provider.
40
- */
41
- DynamicDataProvider.prototype.dispose = function () {
35
+ * Disposes the Dynamic Data Provider.
36
+ */ dispose() {
42
37
  if (!this._isDisposed) {
43
38
  delete this._pendingRegistrations;
44
39
  this._dynamicDataManager.sourcesChangedEvent.remove(this._component, this._onSourcesChanged);
@@ -47,138 +42,133 @@ var DynamicDataProvider = /** @class */ (function () {
47
42
  this._isInitialized = false;
48
43
  this._isDisposed = true;
49
44
  }
50
- };
51
- Object.defineProperty(DynamicDataProvider.prototype, "isDisposed", {
52
- /**
53
- * Returns true if the Dynamic Data Provider is disposed.
54
- */
55
- get: function () {
56
- return this._isDisposed;
57
- },
58
- enumerable: false,
59
- configurable: true
60
- });
61
- Object.defineProperty(DynamicDataProvider.prototype, "_isProviderInitialized", {
62
- /**
63
- * Returns true if the Dynamic Data Provider is intialized.
64
- * @internal
65
- */
66
- get: function () {
67
- return this._isInitialized;
68
- },
69
- enumerable: false,
70
- configurable: true
71
- });
72
- Object.defineProperty(DynamicDataProvider.prototype, "_dynamicDataSourceId", {
73
- /**
74
- * Returns the dynamic data source id for the current instance of the component.
75
- * @internal
76
- */
77
- get: function () {
78
- return this._component._dynamicDataSourceId;
79
- },
80
- enumerable: false,
81
- configurable: true
82
- });
45
+ }
83
46
  /**
84
- * Registers a callback for updates when a Dynamic Data source is changed.
85
- * This happens when any property is updated within the source.
86
- *
87
- * @privateRemarks
88
- * We register the source, only if the source is available else defer the registration
89
- * to when the availableSources change.
90
- *
91
- * @param sourceId - Id of the Dynamic Data Source.
92
- * @param callback - Function to execute when the source updates its data.
93
- */
94
- DynamicDataProvider.prototype.registerSourceChanged = function (sourceId, callback) {
47
+ * Returns true if the Dynamic Data Provider is disposed.
48
+ */ get isDisposed() {
49
+ return this._isDisposed;
50
+ }
51
+ /**
52
+ * Returns true if the Dynamic Data Provider is intialized.
53
+ * @internal
54
+ */ get _isProviderInitialized() {
55
+ return this._isInitialized;
56
+ }
57
+ /**
58
+ * Returns the dynamic data source id for the current instance of the component.
59
+ * @internal
60
+ */ get _dynamicDataSourceId() {
61
+ return this._component._dynamicDataSourceId;
62
+ }
63
+ /**
64
+ * Registers a callback for updates when a Dynamic Data source is changed.
65
+ * This happens when any property is updated within the source.
66
+ *
67
+ * @privateRemarks
68
+ * We register the source, only if the source is available else defer the registration
69
+ * to when the availableSources change.
70
+ *
71
+ * @param sourceId - Id of the Dynamic Data Source.
72
+ * @param callback - Function to execute when the source updates its data.
73
+ */ registerSourceChanged(sourceId, callback) {
95
74
  this._assertNotDisposed();
96
75
  this._assertInitialized();
97
- sp_core_library_1.Validate.isNonemptyString(sourceId, 'sourceId');
98
- sp_core_library_1.Validate.isNotNullOrUndefined(callback, 'callback');
99
- var availableSourceIds = this.getAvailableSources().map(function (source) { return source.id; });
76
+ _spcorelibrary.Validate.isNonemptyString(sourceId, 'sourceId');
77
+ _spcorelibrary.Validate.isNotNullOrUndefined(callback, 'callback');
78
+ const availableSourceIds = this.getAvailableSources().map((source)=>source.id);
100
79
  if (availableSourceIds.indexOf(sourceId) !== -1) {
101
80
  // requested source is available
102
81
  this._dynamicDataManager.registerSourceChanged(sourceId, this._component, callback);
103
- this._logFeatureEntry('RegisterSourceChanged', { sourceId: sourceId });
104
- }
105
- else {
82
+ this._logFeatureEntry('RegisterSourceChanged', {
83
+ sourceId: sourceId
84
+ });
85
+ } else {
106
86
  // requested source is NOT available
107
- this._addPendingRegistration({ id: sourceId, callback: callback });
87
+ this._addPendingRegistration({
88
+ id: sourceId,
89
+ callback: callback
90
+ });
108
91
  }
109
- };
92
+ }
110
93
  /**
111
- * Unregisters a callback for updates when a Dynamic Data source is changed.
112
- *
113
- * @param sourceId - Id of the Dynamic Data Source.
114
- * @param callback - Function to remove from the registration. Must be the same it was registered with.
115
- */
116
- DynamicDataProvider.prototype.unregisterSourceChanged = function (sourceId, callback) {
94
+ * Unregisters a callback for updates when a Dynamic Data source is changed.
95
+ *
96
+ * @param sourceId - Id of the Dynamic Data Source.
97
+ * @param callback - Function to remove from the registration. Must be the same it was registered with.
98
+ */ unregisterSourceChanged(sourceId, callback) {
117
99
  this._assertNotDisposed();
118
100
  this._assertInitialized();
119
- sp_core_library_1.Validate.isNonemptyString(sourceId, 'sourceId');
120
- sp_core_library_1.Validate.isNotNullOrUndefined(callback, 'callback');
121
- var registration = { id: sourceId, callback: callback };
101
+ _spcorelibrary.Validate.isNonemptyString(sourceId, 'sourceId');
102
+ _spcorelibrary.Validate.isNotNullOrUndefined(callback, 'callback');
103
+ const registration = {
104
+ id: sourceId,
105
+ callback: callback
106
+ };
122
107
  if (!this._isRegistrationPending(registration)) {
123
108
  // Source is already registered.
124
109
  this._dynamicDataManager.unregisterSourceChanged(sourceId, this._component, callback);
125
- this._logFeatureEntry('UnregisterSourceChanged', { sourceId: sourceId });
126
- }
127
- else {
110
+ this._logFeatureEntry('UnregisterSourceChanged', {
111
+ sourceId: sourceId
112
+ });
113
+ } else {
128
114
  // Source is in pending state
129
115
  this._removePendingRegistration(registration);
130
116
  }
131
- };
117
+ }
132
118
  /**
133
- * Registers a callback for updates when a property is changed in a Dynamic Data source.
134
- *
135
- * @privateRemarks
136
- * We register the source, only if the source is available else defer the registration
137
- * to when the availableSources change.
138
- *
139
- * @param sourceId - Id of the Dynamic Data Source.
140
- * @param propertyId - Id of the property of the source.
141
- * @param callback - Function to execute when the source updates its data.
142
- */
143
- DynamicDataProvider.prototype.registerPropertyChanged = function (sourceId, propertyId, callback) {
119
+ * Registers a callback for updates when a property is changed in a Dynamic Data source.
120
+ *
121
+ * @privateRemarks
122
+ * We register the source, only if the source is available else defer the registration
123
+ * to when the availableSources change.
124
+ *
125
+ * @param sourceId - Id of the Dynamic Data Source.
126
+ * @param propertyId - Id of the property of the source.
127
+ * @param callback - Function to execute when the source updates its data.
128
+ */ registerPropertyChanged(sourceId, propertyId, callback) {
144
129
  this._assertNotDisposed();
145
130
  this._assertInitialized();
146
- sp_core_library_1.Validate.isNonemptyString(sourceId, 'sourceId');
147
- sp_core_library_1.Validate.isNonemptyString(propertyId, 'propertyId');
148
- sp_core_library_1.Validate.isNotNullOrUndefined(callback, 'callback');
149
- var availableSourceIds = this.getAvailableSources().map(function (source) { return source.id; });
131
+ _spcorelibrary.Validate.isNonemptyString(sourceId, 'sourceId');
132
+ _spcorelibrary.Validate.isNonemptyString(propertyId, 'propertyId');
133
+ _spcorelibrary.Validate.isNotNullOrUndefined(callback, 'callback');
134
+ const availableSourceIds = this.getAvailableSources().map((source)=>source.id);
150
135
  if (availableSourceIds.indexOf(sourceId) !== -1) {
151
136
  // requested source is available
152
137
  this._dynamicDataManager.registerPropertyChanged(sourceId, propertyId, this._component, callback);
153
- this._logFeatureEntry('RegisterPropertyChanged', { sourceId: sourceId, propertyId: propertyId });
154
- }
155
- else {
138
+ this._logFeatureEntry('RegisterPropertyChanged', {
139
+ sourceId: sourceId,
140
+ propertyId: propertyId
141
+ });
142
+ } else {
156
143
  // requested source is NOT available
157
- this._addPendingRegistration({ id: sourceId, propertyId: propertyId, callback: callback });
144
+ this._addPendingRegistration({
145
+ id: sourceId,
146
+ propertyId: propertyId,
147
+ callback: callback
148
+ });
158
149
  }
159
- };
150
+ }
160
151
  /**
161
- * Unregisters a callback for updates when a property is changed in a Dynamic Data source.
162
- *
163
- * @privateRemarks
164
- * If the sourceId is present in _registeredSourcesForPropertyChanged then
165
- * it removes from sourceID from the set _registeredSourcesForPropertyChanged and
166
- * invokes unregisterPropertyChanged event on the DynamicDataManager
167
- *
168
- * else if the sourceId is present in _pendingSourcesForPropertyChanged then
169
- * it just removes the sourceId from the set _pendingSourcesForPropertyChanged
170
- *
171
- * @param sourceId - Id of the Dynamic Data Source.
172
- * @param propertyId - Id of the property of the source.
173
- * @param callback - Function to remove from the registration. Must be the same it was registered with.
174
- */
175
- DynamicDataProvider.prototype.unregisterPropertyChanged = function (sourceId, propertyId, callback) {
152
+ * Unregisters a callback for updates when a property is changed in a Dynamic Data source.
153
+ *
154
+ * @privateRemarks
155
+ * If the sourceId is present in _registeredSourcesForPropertyChanged then
156
+ * it removes from sourceID from the set _registeredSourcesForPropertyChanged and
157
+ * invokes unregisterPropertyChanged event on the DynamicDataManager
158
+ *
159
+ * else if the sourceId is present in _pendingSourcesForPropertyChanged then
160
+ * it just removes the sourceId from the set _pendingSourcesForPropertyChanged
161
+ *
162
+ * @param sourceId - Id of the Dynamic Data Source.
163
+ * @param propertyId - Id of the property of the source.
164
+ * @param callback - Function to remove from the registration. Must be the same it was registered with.
165
+ */ unregisterPropertyChanged(sourceId, propertyId, callback) {
176
166
  this._assertNotDisposed();
177
167
  this._assertInitialized();
178
- sp_core_library_1.Validate.isNonemptyString(sourceId, 'sourceId');
179
- sp_core_library_1.Validate.isNonemptyString(propertyId, 'propertyId');
180
- sp_core_library_1.Validate.isNotNullOrUndefined(callback, 'callback');
181
- var registration = {
168
+ _spcorelibrary.Validate.isNonemptyString(sourceId, 'sourceId');
169
+ _spcorelibrary.Validate.isNonemptyString(propertyId, 'propertyId');
170
+ _spcorelibrary.Validate.isNotNullOrUndefined(callback, 'callback');
171
+ const registration = {
182
172
  id: sourceId,
183
173
  callback: callback,
184
174
  propertyId: propertyId
@@ -186,141 +176,132 @@ var DynamicDataProvider = /** @class */ (function () {
186
176
  // registration is in pending state.
187
177
  if (!this._isRegistrationPending(registration)) {
188
178
  this._dynamicDataManager.unregisterPropertyChanged(sourceId, propertyId, this._component, callback);
189
- this._logFeatureEntry('UnregisterPropertyChanged', { sourceId: sourceId, propertyId: propertyId });
190
- }
191
- else {
179
+ this._logFeatureEntry('UnregisterPropertyChanged', {
180
+ sourceId: sourceId,
181
+ propertyId: propertyId
182
+ });
183
+ } else {
192
184
  // Already registered.
193
185
  this._removePendingRegistration(registration);
194
186
  }
195
- };
187
+ }
196
188
  /**
197
- * Registers a callback to an event that raises when the list of available Dynamic Data Sources is updated.
198
- *
199
- * @param callback - Function to execute when the sources are updated.
200
- */
201
- DynamicDataProvider.prototype.registerAvailableSourcesChanged = function (callback) {
202
- sp_core_library_1.Validate.isNotNullOrUndefined(callback, 'callback');
189
+ * Registers a callback to an event that raises when the list of available Dynamic Data Sources is updated.
190
+ *
191
+ * @param callback - Function to execute when the sources are updated.
192
+ */ registerAvailableSourcesChanged(callback) {
193
+ _spcorelibrary.Validate.isNotNullOrUndefined(callback, 'callback');
203
194
  this._assertNotDisposed();
204
195
  this._assertInitialized();
205
196
  this._dynamicDataManager.sourcesChangedEvent.add(this._component, callback);
206
- };
197
+ }
207
198
  /**
208
- * Unregisters a callback to an event that raises when the list of available Dynamic Data Sources is updated.
209
- *
210
- * @privateRemarks
211
- * This api is used by the consumer of the dynamic data.
212
- *
213
- * @param callback - Function to remove from the registration. Must be the same it was registered with.
214
- */
215
- DynamicDataProvider.prototype.unregisterAvailableSourcesChanged = function (callback) {
216
- sp_core_library_1.Validate.isNotNullOrUndefined(callback, 'callback');
199
+ * Unregisters a callback to an event that raises when the list of available Dynamic Data Sources is updated.
200
+ *
201
+ * @privateRemarks
202
+ * This api is used by the consumer of the dynamic data.
203
+ *
204
+ * @param callback - Function to remove from the registration. Must be the same it was registered with.
205
+ */ unregisterAvailableSourcesChanged(callback) {
206
+ _spcorelibrary.Validate.isNotNullOrUndefined(callback, 'callback');
217
207
  this._assertNotDisposed();
218
208
  this._assertInitialized();
219
209
  this._dynamicDataManager.sourcesChangedEvent.remove(this._component, callback);
220
- };
210
+ }
221
211
  /**
222
- * Returns a list with all available Dynamic Data Sources.
223
- *
224
- * @returns Read-only array with all available sources.
225
- */
226
- DynamicDataProvider.prototype.getAvailableSources = function () {
212
+ * Returns a list with all available Dynamic Data Sources.
213
+ *
214
+ * @returns Read-only array with all available sources.
215
+ */ getAvailableSources() {
227
216
  this._assertNotDisposed();
228
217
  this._assertInitialized();
229
218
  return this._dynamicDataManager.getSources();
230
- };
219
+ }
231
220
  /**
232
- * Returns a list of all the available Dynamic Data Sources which have same component id.
233
- *
234
- * @returns Read-only array of available sources with same component id.
235
- * @alpha
236
- */
237
- DynamicDataProvider.prototype.getAvailableSourcesByComponentId = function (componentId) {
221
+ * Returns a list of all the available Dynamic Data Sources which have same component id.
222
+ *
223
+ * @returns Read-only array of available sources with same component id.
224
+ * @alpha
225
+ */ getAvailableSourcesByComponentId(componentId) {
238
226
  this._assertNotDisposed();
239
227
  this._assertInitialized();
240
- var sources = [];
241
- this._dynamicDataManager.getSources().forEach(function (source) {
242
- if (componentId.equals(sp_core_library_1.Guid.tryParse(source.metadata.componentId) || sp_core_library_1.Guid.empty)) {
228
+ const sources = [];
229
+ this._dynamicDataManager.getSources().forEach((source)=>{
230
+ if (componentId.equals(_spcorelibrary.Guid.tryParse(source.metadata.componentId) || _spcorelibrary.Guid.empty)) {
243
231
  sources.push(source);
244
232
  }
245
233
  });
246
234
  return sources;
247
- };
235
+ }
248
236
  /**
249
- * Returns a Dynamic Data Source, by its id.
250
- * If the source is not present, it returns undefined.
251
- *
252
- * @param id - Id of the Dynamic Data Source.
253
- */
254
- DynamicDataProvider.prototype.tryGetSource = function (id) {
237
+ * Returns a Dynamic Data Source, by its id.
238
+ * If the source is not present, it returns undefined.
239
+ *
240
+ * @param id - Id of the Dynamic Data Source.
241
+ */ tryGetSource(id) {
255
242
  this._assertNotDisposed();
256
243
  this._assertInitialized();
257
- sp_core_library_1.Validate.isNotNullOrUndefined(id, 'id');
244
+ _spcorelibrary.Validate.isNotNullOrUndefined(id, 'id');
258
245
  return this._dynamicDataManager.tryGetSource(id);
259
- };
246
+ }
260
247
  /**
261
- * Returns specific data from a source based on a Dynamic Data reference.
262
- *
263
- * @param dataReference - Dynamic Data Reference.
264
- * @internal
265
- */
266
- DynamicDataProvider.prototype._getData = function (dataReference) {
248
+ * Returns specific data from a source based on a Dynamic Data reference.
249
+ *
250
+ * @param dataReference - Dynamic Data Reference.
251
+ * @internal
252
+ */ _getData(dataReference) {
267
253
  this._assertNotDisposed();
268
254
  this._assertInitialized();
269
- sp_core_library_1.Validate.isNotNullOrUndefined(dataReference, 'dataReference');
270
- var dataSource = this._dynamicDataManager.tryGetSource(dataReference.sourceId);
255
+ _spcorelibrary.Validate.isNotNullOrUndefined(dataReference, 'dataReference');
256
+ const dataSource = this._dynamicDataManager.tryGetSource(dataReference.sourceId);
271
257
  if (!dataSource) {
272
258
  return undefined;
273
259
  }
274
- var data = dataSource.getPropertyValue(dataReference.property);
260
+ let data = dataSource.getPropertyValue(dataReference.property);
275
261
  if (data && dataReference.propertyPath) {
276
262
  // multiple levels of sub-properties are separated by '.' in the property path.
277
- var subpaths = dataReference.propertyPath.split('.');
278
- subpaths.forEach(function (subpath) {
263
+ const subpaths = dataReference.propertyPath.split('.');
264
+ subpaths.forEach((subpath)=>{
279
265
  // If sub-property yields to an array value, then the path to the sub-property
280
266
  // will have [*] appended after the name of the sub-property.
281
267
  // Hence separating out to get the subPropertyName.
282
- var subpathElements = subpath.split(DynamicDataProvider._jsonPathArrayRegex);
283
- var subProperty = subpathElements[0];
268
+ const subpathElements = subpath.split(DynamicDataProvider._jsonPathArrayRegex);
269
+ const subProperty = subpathElements[0];
284
270
  // If the supplied reference has an array([*]) notation, then we extract the data
285
271
  // accordingly. [*] means all the entries and if there is a number instead of the '*'
286
272
  // then extract that specific entry.
287
273
  if (data) {
288
274
  if (Array.isArray(data)) {
289
- var dataItems_1 = [];
290
- data.forEach(function (item) {
275
+ let dataItems = [];
276
+ data.forEach((item)=>{
291
277
  if (item.hasOwnProperty(subProperty)) {
292
- dataItems_1.push(item[subProperty]);
278
+ dataItems.push(item[subProperty]);
293
279
  }
294
280
  });
295
281
  /*
296
- * If a specific entry is asked, we return it else we return all the entries,
297
- * essentially it is treated as [*].
298
- */
299
- var index = subpathElements[1];
282
+ * If a specific entry is asked, we return it else we return all the entries,
283
+ * essentially it is treated as [*].
284
+ */ const index = subpathElements[1];
300
285
  if (subpathElements.length > 1) {
301
286
  /**
302
- * This means that the current subpath element is an array type, an array inside an array.
303
- * Since the subpath element is an array, we are normalizing the existing dataItems object
304
- * i.e., dataItems will have an array of array objects.
305
- */
306
- var tempDataItems_1 = [];
307
- dataItems_1.forEach(function (dataItem) {
308
- dataItem.forEach(function (internalItem) { return tempDataItems_1.push(internalItem); });
287
+ * This means that the current subpath element is an array type, an array inside an array.
288
+ * Since the subpath element is an array, we are normalizing the existing dataItems object
289
+ * i.e., dataItems will have an array of array objects.
290
+ */ const tempDataItems = [];
291
+ dataItems.forEach((dataItem)=>{
292
+ dataItem.forEach((internalItem)=>tempDataItems.push(internalItem));
309
293
  });
310
- dataItems_1 = tempDataItems_1;
294
+ dataItems = tempDataItems;
311
295
  }
312
296
  if (!isNaN(parseInt(index, 10))) {
313
- data = dataItems_1[index];
297
+ data = dataItems[index];
298
+ } else {
299
+ data = dataItems;
314
300
  }
315
- else {
316
- data = dataItems_1;
317
- }
318
- }
319
- else if (data.hasOwnProperty(subProperty)) {
301
+ } else if (data.hasOwnProperty(subProperty)) {
320
302
  // data is an object type
321
303
  data = data[subProperty];
322
- }
323
- else {
304
+ } else {
324
305
  // If the control is here, it means that the subProperty was not found in data.
325
306
  // Hence the next iteration would get data as undefined.
326
307
  data = undefined;
@@ -329,44 +310,46 @@ var DynamicDataProvider = /** @class */ (function () {
329
310
  });
330
311
  }
331
312
  return data;
332
- };
333
- DynamicDataProvider.prototype._onSourcesChanged = function () {
334
- var _this = this;
335
- var availableSourceIds = this.getAvailableSources().map(function (source) { return source.id; });
313
+ }
314
+ _onSourcesChanged() {
315
+ const availableSourceIds = this.getAvailableSources().map((source)=>source.id);
336
316
  // Registering to sourceChanged event
337
- this._pendingRegistrations.forEach(function (src) {
317
+ this._pendingRegistrations.forEach((src)=>{
338
318
  // register to sourceChanged event, if the source is available.
339
319
  if (availableSourceIds.indexOf(src.id) !== -1) {
340
320
  // Source is available
341
321
  if (!src.propertyId) {
342
322
  // No propertyId, means register to sourceChanged event.
343
- _this._dynamicDataManager.registerSourceChanged(src.id, _this._component, src.callback);
344
- _this._logFeatureEntry('RegisterSourceChanged', { sourceId: src.id });
345
- }
346
- else {
323
+ this._dynamicDataManager.registerSourceChanged(src.id, this._component, src.callback);
324
+ this._logFeatureEntry('RegisterSourceChanged', {
325
+ sourceId: src.id
326
+ });
327
+ } else {
347
328
  // With propertyId, means register to propertyChanged event.
348
- _this._dynamicDataManager.registerPropertyChanged(src.id, src.propertyId, _this._component, src.callback);
349
- _this._logFeatureEntry('RegisterPropertyChanged', { sourceId: src.id, propertyId: src.propertyId });
329
+ this._dynamicDataManager.registerPropertyChanged(src.id, src.propertyId, this._component, src.callback);
330
+ this._logFeatureEntry('RegisterPropertyChanged', {
331
+ sourceId: src.id,
332
+ propertyId: src.propertyId
333
+ });
350
334
  }
351
- _this._removePendingRegistration(src);
335
+ this._removePendingRegistration(src);
352
336
  }
353
337
  });
354
- };
355
- DynamicDataProvider.prototype._assertNotDisposed = function () {
338
+ }
339
+ _assertNotDisposed() {
356
340
  if (this.isDisposed) {
357
341
  throw new Error('Dynamic Data Provider has been disposed');
358
342
  }
359
- };
360
- DynamicDataProvider.prototype._assertInitialized = function () {
343
+ }
344
+ _assertInitialized() {
361
345
  if (!this._isInitialized) {
362
346
  throw new Error('Dynamic Data Provider has not been initialized.');
363
347
  }
364
- };
348
+ }
365
349
  /**
366
- * Adds the registration to the pending registrations if not already added.
367
- * Also adds a listener to the _DynamicDataManager's sourcesChangedEvent.
368
- */
369
- DynamicDataProvider.prototype._addPendingRegistration = function (registration) {
350
+ * Adds the registration to the pending registrations if not already added.
351
+ * Also adds a listener to the _DynamicDataManager's sourcesChangedEvent.
352
+ */ _addPendingRegistration(registration) {
370
353
  if (!this._isRegistrationPending(registration)) {
371
354
  this._pendingRegistrations.set(registration.id + (registration.propertyId || ''), {
372
355
  id: registration.id,
@@ -378,46 +361,46 @@ var DynamicDataProvider = /** @class */ (function () {
378
361
  this._dynamicDataManager.sourcesChangedEvent.add(this._component, this._onSourcesChanged);
379
362
  this._isSourcesChangedEventListenerAdded = true;
380
363
  }
381
- };
364
+ }
382
365
  /**
383
- * Removes the pending registration and then, if there are no more pending registrations
384
- * remove the 'sourcesChangedEvent' listener.
385
- */
386
- DynamicDataProvider.prototype._removePendingRegistration = function (registration) {
366
+ * Removes the pending registration and then, if there are no more pending registrations
367
+ * remove the 'sourcesChangedEvent' listener.
368
+ */ _removePendingRegistration(registration) {
387
369
  this._pendingRegistrations.delete(registration.id + (registration.propertyId || ''));
388
370
  if (this._pendingRegistrations.size === 0) {
389
371
  this._dynamicDataManager.sourcesChangedEvent.remove(this._component, this._onSourcesChanged);
390
372
  this._isSourcesChangedEventListenerAdded = false;
391
373
  }
392
- };
374
+ }
393
375
  /**
394
- * Returns true if the incoming source is already added to the _pendingRegistrations Map.
395
- *
396
- * @param incomingRegistration - registration to be checked.
397
- */
398
- DynamicDataProvider.prototype._isRegistrationPending = function (incomingRegistration) {
376
+ * Returns true if the incoming source is already added to the _pendingRegistrations Map.
377
+ *
378
+ * @param incomingRegistration - registration to be checked.
379
+ */ _isRegistrationPending(incomingRegistration) {
399
380
  return this._pendingRegistrations.has(incomingRegistration.id + (incomingRegistration.propertyId || ''));
400
- };
381
+ }
401
382
  /**
402
- * Logs a feature event with any extra data from the producer of the event.
403
- * @param logFeature - Name of the feature to log.
404
- * @param contextualProps - Contextual log properties of the feature event.
405
- */
406
- DynamicDataProvider.prototype._logFeatureEntry = function (logFeature, contextualProps) {
407
- var isInternal = this._component.manifest.isInternal || false;
408
- var logProperties = {
383
+ * Logs a feature event with any extra data from the producer of the event.
384
+ * @param logFeature - Name of the feature to log.
385
+ * @param contextualProps - Contextual log properties of the feature event.
386
+ */ _logFeatureEntry(logFeature, contextualProps) {
387
+ const isInternal = this._component.manifest.isInternal || false;
388
+ const logProperties = {
409
389
  alias: this._component.manifest.alias,
410
390
  isInternal: isInternal.toString()
411
391
  };
412
- var logEntry = new sp_diagnostics_1._LogEntry('DynamicDataProvider', logFeature, sp_diagnostics_1._LogType.Event, lodash.merge(logProperties, contextualProps));
413
- sp_diagnostics_1._EngagementLogger.logEventWithLogEntry(logEntry);
414
- };
415
- /**
416
- * Regular expression to evaluate arrays in a json path expression.
417
- * @internal
418
- */
419
- DynamicDataProvider._jsonPathArrayRegex = new RegExp(/\[|\]/);
420
- return DynamicDataProvider;
421
- }());
422
- exports.default = DynamicDataProvider;
423
- //# sourceMappingURL=DynamicDataProvider.js.map
392
+ const logEntry = new _spdiagnostics._LogEntry('DynamicDataProvider', logFeature, _spdiagnostics._LogType.Event, _splodashsubset.merge(logProperties, contextualProps));
393
+ _spdiagnostics._EngagementLogger.logEventWithLogEntry(logEntry);
394
+ }
395
+ constructor(){
396
+ this._isDisposed = false;
397
+ this._isInitialized = false;
398
+ this._isSourcesChangedEventListenerAdded = false;
399
+ }
400
+ }
401
+ /**
402
+ * Regular expression to evaluate arrays in a json path expression.
403
+ * @internal
404
+ */ DynamicDataProvider._jsonPathArrayRegex = new RegExp(/\[|\]/);
405
+
406
+ //# sourceMappingURL=./DynamicDataProvider.js.map