@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.
- package/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +136 -141
- package/dist/{chunk.legacy-third-party-fabric-core-localfont_none_9e84ea19c68fdc8b9094.js → chunk.legacy-third-party-fabric-core-localfont_none_b7f7978a3e90166c361b.js} +1 -1
- package/dist/chunk.teams-apps-client_none_27d3c7c1d01080e4f131.js +2 -0
- package/dist/index-internal-beta.d.ts +30 -8
- package/dist/index-internal-public.d.ts +30 -8
- package/dist/index-internal.d.ts +30 -8
- package/dist/sp-component-base_default_8d535b51fa18aa47002b.js +22 -0
- package/dist/sp-component-base_en-us_8ce25dfb69a7786caece.js +22 -0
- package/dist/sp-component-base_qps-ploc_4fec831895d90df8aa7a.js +22 -0
- package/dist/sp-component-base_qps-ploca_b80610c8dff04dcec755.js +22 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-commonjs/BaseComponent.js +110 -145
- package/lib-commonjs/BaseComponentContext.js +126 -183
- package/lib-commonjs/DynamicDataProvider.js +251 -268
- package/lib-commonjs/DynamicDataSourceManager.js +218 -241
- package/lib-commonjs/DynamicProperty.js +232 -280
- package/lib-commonjs/EnsureIsolatedDomainUrl.js +14 -14
- package/lib-commonjs/IComponentPosition.js +8 -3
- package/lib-commonjs/IComponentPropertyMetadata.js +10 -3
- package/lib-commonjs/ISerializedServerProcessedData.js +24 -21
- package/lib-commonjs/LegacyThirdPartyFabricCoreLoader.js +53 -87
- package/lib-commonjs/PropertyMetadataProcessor.js +117 -150
- package/lib-commonjs/RenderableComponentContext.js +37 -0
- package/lib-commonjs/ShimmerFactory.js +66 -51
- package/lib-commonjs/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +6 -4
- package/lib-commonjs/common/Flights.js +22 -10
- package/lib-commonjs/common/KillSwitches.js +13 -6
- package/lib-commonjs/dataCollector/IWebPartLoadData.js +35 -30
- package/lib-commonjs/dataCollector/WebPartLoadDataCollector.js +82 -91
- package/lib-commonjs/index.js +78 -38
- package/lib-commonjs/teams/DeferredTeamsAppsClient.js +30 -52
- package/lib-commonjs/teams/ITeamsAppCatalog.js +10 -3
- package/lib-commonjs/teams/TeamsAppsClient.js +189 -231
- package/lib-commonjs/test-api/MockComponent.js +38 -23
- package/lib-commonjs/test-api/MockComponentContext.js +21 -14
- package/lib-commonjs/test-api/index.js +21 -7
- package/lib-commonjs/themeProvider/ThemeProvider.js +68 -82
- package/lib-commonjs/themeProvider/themeInterfaces/IFontStyles.js +5 -2
- package/lib-commonjs/themeProvider/themeInterfaces/IPalette.js +10 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ISemanticColors.js +59 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ISemanticTextColors.js +10 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ITheme.js +5 -2
- package/{lib → lib-dts}/BaseComponent.d.ts +8 -8
- package/{lib → lib-dts}/BaseComponentContext.d.ts +5 -5
- package/lib-dts/RenderableComponentContext.d.ts +35 -0
- package/{lib → lib-dts}/index.d.ts +1 -0
- package/lib-esm/BaseComponent.js +123 -0
- package/lib-esm/BaseComponentContext.js +157 -0
- package/lib-esm/DynamicDataProvider.js +401 -0
- package/lib-esm/DynamicDataSourceManager.js +358 -0
- package/lib-esm/DynamicProperty.js +344 -0
- package/{lib → lib-esm}/EnsureIsolatedDomainUrl.js +6 -6
- package/lib-esm/IComponentPosition.js +5 -0
- package/lib-esm/IComponentPropertyMetadata.js +7 -0
- package/lib-esm/ISerializedServerProcessedData.js +24 -0
- package/lib-esm/LegacyThirdPartyFabricCoreLoader.js +76 -0
- package/{lib → lib-esm}/PropertyMetadataProcessor.js +92 -127
- package/lib-esm/RenderableComponentContext.js +26 -0
- package/lib-esm/ShimmerFactory.js +74 -0
- package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +3 -3
- package/{lib → lib-esm}/common/Flights.js +4 -3
- package/{lib → lib-esm}/common/KillSwitches.js +3 -2
- package/lib-esm/dataCollector/IWebPartLoadData.js +33 -0
- package/lib-esm/dataCollector/WebPartLoadDataCollector.js +125 -0
- package/{lib → lib-esm}/index.js +4 -3
- package/lib-esm/teams/DeferredTeamsAppsClient.js +32 -0
- package/lib-esm/teams/ITeamsAppCatalog.js +9 -0
- package/lib-esm/teams/TeamsAppsClient.js +395 -0
- package/lib-esm/test-api/MockComponent.js +38 -0
- package/{lib → lib-esm}/test-api/MockComponentContext.js +10 -11
- package/{lib → lib-esm}/test-api/index.js +2 -1
- package/lib-esm/themeProvider/ThemeProvider.js +79 -0
- package/lib-esm/themeProvider/themeInterfaces/IFontStyles.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/IPalette.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/ISemanticColors.js +56 -0
- package/lib-esm/themeProvider/themeInterfaces/ISemanticTextColors.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/ITheme.js +7 -0
- package/package.json +41 -14
- package/dist/chunk.teams-apps-client_none_f9872389cb6ea9ad28e2.js +0 -2
- package/dist/sp-component-base_default_5ba07be39b0dc8968f7b.js +0 -2
- package/dist/sp-component-base_en-us_eb9bebb3acce0ae83f1c.js +0 -2
- package/dist/sp-component-base_qps-ploc_45f37623d87c3d848f2a.js +0 -2
- package/dist/sp-component-base_qps-ploca_b3f3b7bf97c4185b0fd6.js +0 -2
- package/lib/BaseComponent.d.ts.map +0 -1
- package/lib/BaseComponent.js +0 -161
- package/lib/BaseComponentContext.d.ts.map +0 -1
- package/lib/BaseComponentContext.js +0 -222
- package/lib/DynamicDataProvider.d.ts.map +0 -1
- package/lib/DynamicDataProvider.js +0 -420
- package/lib/DynamicDataSourceManager.d.ts.map +0 -1
- package/lib/DynamicDataSourceManager.js +0 -382
- package/lib/DynamicProperty.d.ts.map +0 -1
- package/lib/DynamicProperty.js +0 -390
- package/lib/EnsureIsolatedDomainUrl.d.ts.map +0 -1
- package/lib/IComponentPosition.d.ts.map +0 -1
- package/lib/IComponentPosition.js +0 -2
- package/lib/IComponentPropertyMetadata.d.ts.map +0 -1
- package/lib/IComponentPropertyMetadata.js +0 -2
- package/lib/ISerializedServerProcessedData.d.ts.map +0 -1
- package/lib/ISerializedServerProcessedData.js +0 -28
- package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +0 -1
- package/lib/LegacyThirdPartyFabricCoreLoader.js +0 -90
- package/lib/PropertyMetadataProcessor.d.ts.map +0 -1
- package/lib/ShimmerFactory.d.ts.map +0 -1
- package/lib/ShimmerFactory.js +0 -62
- package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +0 -1
- package/lib/common/Flights.d.ts.map +0 -1
- package/lib/common/KillSwitches.d.ts.map +0 -1
- package/lib/dataCollector/IWebPartLoadData.d.ts.map +0 -1
- package/lib/dataCollector/IWebPartLoadData.js +0 -40
- package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +0 -1
- package/lib/dataCollector/WebPartLoadDataCollector.js +0 -137
- package/lib/index.d.ts.map +0 -1
- package/lib/teams/DeferredTeamsAppsClient.d.ts.map +0 -1
- package/lib/teams/DeferredTeamsAppsClient.js +0 -39
- package/lib/teams/ITeamsAppCatalog.d.ts.map +0 -1
- package/lib/teams/ITeamsAppCatalog.js +0 -2
- package/lib/teams/TeamsAppsClient.d.ts.map +0 -1
- package/lib/teams/TeamsAppsClient.js +0 -440
- package/lib/test-api/MockComponent.d.ts.map +0 -1
- package/lib/test-api/MockComponent.js +0 -31
- package/lib/test-api/MockComponentContext.d.ts.map +0 -1
- package/lib/test-api/index.d.ts.map +0 -1
- package/lib/themeProvider/ThemeProvider.d.ts.map +0 -1
- package/lib/themeProvider/ThemeProvider.js +0 -99
- package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/IFontStyles.js +0 -2
- package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/IPalette.js +0 -2
- package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ISemanticColors.js +0 -2
- package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +0 -2
- package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ITheme.js +0 -2
- /package/{lib → lib-dts}/DynamicDataProvider.d.ts +0 -0
- /package/{lib → lib-dts}/DynamicDataSourceManager.d.ts +0 -0
- /package/{lib → lib-dts}/DynamicProperty.d.ts +0 -0
- /package/{lib → lib-dts}/EnsureIsolatedDomainUrl.d.ts +0 -0
- /package/{lib → lib-dts}/IComponentPosition.d.ts +0 -0
- /package/{lib → lib-dts}/IComponentPropertyMetadata.d.ts +0 -0
- /package/{lib → lib-dts}/ISerializedServerProcessedData.d.ts +0 -0
- /package/{lib → lib-dts}/LegacyThirdPartyFabricCoreLoader.d.ts +0 -0
- /package/{lib → lib-dts}/PropertyMetadataProcessor.d.ts +0 -0
- /package/{lib → lib-dts}/ShimmerFactory.d.ts +0 -0
- /package/{lib → lib-dts}/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +0 -0
- /package/{lib → lib-dts}/common/Flights.d.ts +0 -0
- /package/{lib → lib-dts}/common/KillSwitches.d.ts +0 -0
- /package/{lib → lib-dts}/dataCollector/IWebPartLoadData.d.ts +0 -0
- /package/{lib → lib-dts}/dataCollector/WebPartLoadDataCollector.d.ts +0 -0
- /package/{lib → lib-dts}/loc/Strings.resx.d.ts +0 -0
- /package/{lib → lib-dts}/teams/DeferredTeamsAppsClient.d.ts +0 -0
- /package/{lib → lib-dts}/teams/ITeamsAppCatalog.d.ts +0 -0
- /package/{lib → lib-dts}/teams/TeamsAppsClient.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/MockComponent.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/MockComponentContext.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/index.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/ThemeProvider.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/IFontStyles.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/IPalette.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticColors.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ITheme.d.ts +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/iconDefinitions.css +0 -0
- /package/{lib → lib-esm}/loc/Strings.resx.json +0 -0
- /package/{lib → lib-esm}/sp-component-base.manifest.json +0 -0
- /package/{lib → lib-esm}/styles/shimmer.module.scss.css +0 -0
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import { Validate, Guid } from '@microsoft/sp-core-library';
|
|
2
|
-
import { _EngagementLogger, _LogEntry, _LogType } from '@microsoft/sp-diagnostics';
|
|
3
|
-
import { _DynamicDataUtilities } from '@microsoft/sp-dynamic-data';
|
|
4
|
-
import * as lodash from '@microsoft/sp-lodash-subset';
|
|
5
|
-
/**
|
|
6
|
-
* The Dynamic Data Provider allows components to consume Dynamic Data.
|
|
7
|
-
* It allows components to request Dynamic Data sources and register/unregister to those.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
var DynamicDataProvider = /** @class */ (function () {
|
|
12
|
-
function DynamicDataProvider() {
|
|
13
|
-
this._isDisposed = false;
|
|
14
|
-
this._isInitialized = false;
|
|
15
|
-
this._isSourcesChangedEventListenerAdded = false;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
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
|
-
*/
|
|
24
|
-
DynamicDataProvider.prototype._initialize = function (component, serviceScope) {
|
|
25
|
-
Validate.isNotNullOrUndefined(component, 'component');
|
|
26
|
-
Validate.isNotNullOrUndefined(serviceScope, 'serviceScope');
|
|
27
|
-
this._component = component;
|
|
28
|
-
// Initialize all the required datastructures
|
|
29
|
-
this._pendingRegistrations = new Map();
|
|
30
|
-
this._dynamicDataManager = serviceScope.consume(_DynamicDataUtilities.IDynamicDataManagerServiceKey);
|
|
31
|
-
this._isInitialized = true;
|
|
32
|
-
// Method bindings
|
|
33
|
-
this._onSourcesChanged = this._onSourcesChanged.bind(this);
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Disposes the Dynamic Data Provider.
|
|
37
|
-
*/
|
|
38
|
-
DynamicDataProvider.prototype.dispose = function () {
|
|
39
|
-
if (!this._isDisposed) {
|
|
40
|
-
delete this._pendingRegistrations;
|
|
41
|
-
this._dynamicDataManager.sourcesChangedEvent.remove(this._component, this._onSourcesChanged);
|
|
42
|
-
delete this._dynamicDataManager;
|
|
43
|
-
delete this._component;
|
|
44
|
-
this._isInitialized = false;
|
|
45
|
-
this._isDisposed = true;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
Object.defineProperty(DynamicDataProvider.prototype, "isDisposed", {
|
|
49
|
-
/**
|
|
50
|
-
* Returns true if the Dynamic Data Provider is disposed.
|
|
51
|
-
*/
|
|
52
|
-
get: function () {
|
|
53
|
-
return this._isDisposed;
|
|
54
|
-
},
|
|
55
|
-
enumerable: false,
|
|
56
|
-
configurable: true
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(DynamicDataProvider.prototype, "_isProviderInitialized", {
|
|
59
|
-
/**
|
|
60
|
-
* Returns true if the Dynamic Data Provider is intialized.
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
get: function () {
|
|
64
|
-
return this._isInitialized;
|
|
65
|
-
},
|
|
66
|
-
enumerable: false,
|
|
67
|
-
configurable: true
|
|
68
|
-
});
|
|
69
|
-
Object.defineProperty(DynamicDataProvider.prototype, "_dynamicDataSourceId", {
|
|
70
|
-
/**
|
|
71
|
-
* Returns the dynamic data source id for the current instance of the component.
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
|
-
get: function () {
|
|
75
|
-
return this._component._dynamicDataSourceId;
|
|
76
|
-
},
|
|
77
|
-
enumerable: false,
|
|
78
|
-
configurable: true
|
|
79
|
-
});
|
|
80
|
-
/**
|
|
81
|
-
* Registers a callback for updates when a Dynamic Data source is changed.
|
|
82
|
-
* This happens when any property is updated within the source.
|
|
83
|
-
*
|
|
84
|
-
* @privateRemarks
|
|
85
|
-
* We register the source, only if the source is available else defer the registration
|
|
86
|
-
* to when the availableSources change.
|
|
87
|
-
*
|
|
88
|
-
* @param sourceId - Id of the Dynamic Data Source.
|
|
89
|
-
* @param callback - Function to execute when the source updates its data.
|
|
90
|
-
*/
|
|
91
|
-
DynamicDataProvider.prototype.registerSourceChanged = function (sourceId, callback) {
|
|
92
|
-
this._assertNotDisposed();
|
|
93
|
-
this._assertInitialized();
|
|
94
|
-
Validate.isNonemptyString(sourceId, 'sourceId');
|
|
95
|
-
Validate.isNotNullOrUndefined(callback, 'callback');
|
|
96
|
-
var availableSourceIds = this.getAvailableSources().map(function (source) { return source.id; });
|
|
97
|
-
if (availableSourceIds.indexOf(sourceId) !== -1) {
|
|
98
|
-
// requested source is available
|
|
99
|
-
this._dynamicDataManager.registerSourceChanged(sourceId, this._component, callback);
|
|
100
|
-
this._logFeatureEntry('RegisterSourceChanged', { sourceId: sourceId });
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
// requested source is NOT available
|
|
104
|
-
this._addPendingRegistration({ id: sourceId, callback: callback });
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Unregisters a callback for updates when a Dynamic Data source is changed.
|
|
109
|
-
*
|
|
110
|
-
* @param sourceId - Id of the Dynamic Data Source.
|
|
111
|
-
* @param callback - Function to remove from the registration. Must be the same it was registered with.
|
|
112
|
-
*/
|
|
113
|
-
DynamicDataProvider.prototype.unregisterSourceChanged = function (sourceId, callback) {
|
|
114
|
-
this._assertNotDisposed();
|
|
115
|
-
this._assertInitialized();
|
|
116
|
-
Validate.isNonemptyString(sourceId, 'sourceId');
|
|
117
|
-
Validate.isNotNullOrUndefined(callback, 'callback');
|
|
118
|
-
var registration = { id: sourceId, callback: callback };
|
|
119
|
-
if (!this._isRegistrationPending(registration)) {
|
|
120
|
-
// Source is already registered.
|
|
121
|
-
this._dynamicDataManager.unregisterSourceChanged(sourceId, this._component, callback);
|
|
122
|
-
this._logFeatureEntry('UnregisterSourceChanged', { sourceId: sourceId });
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// Source is in pending state
|
|
126
|
-
this._removePendingRegistration(registration);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Registers a callback for updates when a property is changed in a Dynamic Data source.
|
|
131
|
-
*
|
|
132
|
-
* @privateRemarks
|
|
133
|
-
* We register the source, only if the source is available else defer the registration
|
|
134
|
-
* to when the availableSources change.
|
|
135
|
-
*
|
|
136
|
-
* @param sourceId - Id of the Dynamic Data Source.
|
|
137
|
-
* @param propertyId - Id of the property of the source.
|
|
138
|
-
* @param callback - Function to execute when the source updates its data.
|
|
139
|
-
*/
|
|
140
|
-
DynamicDataProvider.prototype.registerPropertyChanged = function (sourceId, propertyId, callback) {
|
|
141
|
-
this._assertNotDisposed();
|
|
142
|
-
this._assertInitialized();
|
|
143
|
-
Validate.isNonemptyString(sourceId, 'sourceId');
|
|
144
|
-
Validate.isNonemptyString(propertyId, 'propertyId');
|
|
145
|
-
Validate.isNotNullOrUndefined(callback, 'callback');
|
|
146
|
-
var availableSourceIds = this.getAvailableSources().map(function (source) { return source.id; });
|
|
147
|
-
if (availableSourceIds.indexOf(sourceId) !== -1) {
|
|
148
|
-
// requested source is available
|
|
149
|
-
this._dynamicDataManager.registerPropertyChanged(sourceId, propertyId, this._component, callback);
|
|
150
|
-
this._logFeatureEntry('RegisterPropertyChanged', { sourceId: sourceId, propertyId: propertyId });
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
// requested source is NOT available
|
|
154
|
-
this._addPendingRegistration({ id: sourceId, propertyId: propertyId, callback: callback });
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Unregisters a callback for updates when a property is changed in a Dynamic Data source.
|
|
159
|
-
*
|
|
160
|
-
* @privateRemarks
|
|
161
|
-
* If the sourceId is present in _registeredSourcesForPropertyChanged then
|
|
162
|
-
* it removes from sourceID from the set _registeredSourcesForPropertyChanged and
|
|
163
|
-
* invokes unregisterPropertyChanged event on the DynamicDataManager
|
|
164
|
-
*
|
|
165
|
-
* else if the sourceId is present in _pendingSourcesForPropertyChanged then
|
|
166
|
-
* it just removes the sourceId from the set _pendingSourcesForPropertyChanged
|
|
167
|
-
*
|
|
168
|
-
* @param sourceId - Id of the Dynamic Data Source.
|
|
169
|
-
* @param propertyId - Id of the property of the source.
|
|
170
|
-
* @param callback - Function to remove from the registration. Must be the same it was registered with.
|
|
171
|
-
*/
|
|
172
|
-
DynamicDataProvider.prototype.unregisterPropertyChanged = function (sourceId, propertyId, callback) {
|
|
173
|
-
this._assertNotDisposed();
|
|
174
|
-
this._assertInitialized();
|
|
175
|
-
Validate.isNonemptyString(sourceId, 'sourceId');
|
|
176
|
-
Validate.isNonemptyString(propertyId, 'propertyId');
|
|
177
|
-
Validate.isNotNullOrUndefined(callback, 'callback');
|
|
178
|
-
var registration = {
|
|
179
|
-
id: sourceId,
|
|
180
|
-
callback: callback,
|
|
181
|
-
propertyId: propertyId
|
|
182
|
-
};
|
|
183
|
-
// registration is in pending state.
|
|
184
|
-
if (!this._isRegistrationPending(registration)) {
|
|
185
|
-
this._dynamicDataManager.unregisterPropertyChanged(sourceId, propertyId, this._component, callback);
|
|
186
|
-
this._logFeatureEntry('UnregisterPropertyChanged', { sourceId: sourceId, propertyId: propertyId });
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
// Already registered.
|
|
190
|
-
this._removePendingRegistration(registration);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Registers a callback to an event that raises when the list of available Dynamic Data Sources is updated.
|
|
195
|
-
*
|
|
196
|
-
* @param callback - Function to execute when the sources are updated.
|
|
197
|
-
*/
|
|
198
|
-
DynamicDataProvider.prototype.registerAvailableSourcesChanged = function (callback) {
|
|
199
|
-
Validate.isNotNullOrUndefined(callback, 'callback');
|
|
200
|
-
this._assertNotDisposed();
|
|
201
|
-
this._assertInitialized();
|
|
202
|
-
this._dynamicDataManager.sourcesChangedEvent.add(this._component, callback);
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Unregisters a callback to an event that raises when the list of available Dynamic Data Sources is updated.
|
|
206
|
-
*
|
|
207
|
-
* @privateRemarks
|
|
208
|
-
* This api is used by the consumer of the dynamic data.
|
|
209
|
-
*
|
|
210
|
-
* @param callback - Function to remove from the registration. Must be the same it was registered with.
|
|
211
|
-
*/
|
|
212
|
-
DynamicDataProvider.prototype.unregisterAvailableSourcesChanged = function (callback) {
|
|
213
|
-
Validate.isNotNullOrUndefined(callback, 'callback');
|
|
214
|
-
this._assertNotDisposed();
|
|
215
|
-
this._assertInitialized();
|
|
216
|
-
this._dynamicDataManager.sourcesChangedEvent.remove(this._component, callback);
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* Returns a list with all available Dynamic Data Sources.
|
|
220
|
-
*
|
|
221
|
-
* @returns Read-only array with all available sources.
|
|
222
|
-
*/
|
|
223
|
-
DynamicDataProvider.prototype.getAvailableSources = function () {
|
|
224
|
-
this._assertNotDisposed();
|
|
225
|
-
this._assertInitialized();
|
|
226
|
-
return this._dynamicDataManager.getSources();
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* Returns a list of all the available Dynamic Data Sources which have same component id.
|
|
230
|
-
*
|
|
231
|
-
* @returns Read-only array of available sources with same component id.
|
|
232
|
-
* @alpha
|
|
233
|
-
*/
|
|
234
|
-
DynamicDataProvider.prototype.getAvailableSourcesByComponentId = function (componentId) {
|
|
235
|
-
this._assertNotDisposed();
|
|
236
|
-
this._assertInitialized();
|
|
237
|
-
var sources = [];
|
|
238
|
-
this._dynamicDataManager.getSources().forEach(function (source) {
|
|
239
|
-
if (componentId.equals(Guid.tryParse(source.metadata.componentId) || Guid.empty)) {
|
|
240
|
-
sources.push(source);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
return sources;
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* Returns a Dynamic Data Source, by its id.
|
|
247
|
-
* If the source is not present, it returns undefined.
|
|
248
|
-
*
|
|
249
|
-
* @param id - Id of the Dynamic Data Source.
|
|
250
|
-
*/
|
|
251
|
-
DynamicDataProvider.prototype.tryGetSource = function (id) {
|
|
252
|
-
this._assertNotDisposed();
|
|
253
|
-
this._assertInitialized();
|
|
254
|
-
Validate.isNotNullOrUndefined(id, 'id');
|
|
255
|
-
return this._dynamicDataManager.tryGetSource(id);
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* Returns specific data from a source based on a Dynamic Data reference.
|
|
259
|
-
*
|
|
260
|
-
* @param dataReference - Dynamic Data Reference.
|
|
261
|
-
* @internal
|
|
262
|
-
*/
|
|
263
|
-
DynamicDataProvider.prototype._getData = function (dataReference) {
|
|
264
|
-
this._assertNotDisposed();
|
|
265
|
-
this._assertInitialized();
|
|
266
|
-
Validate.isNotNullOrUndefined(dataReference, 'dataReference');
|
|
267
|
-
var dataSource = this._dynamicDataManager.tryGetSource(dataReference.sourceId);
|
|
268
|
-
if (!dataSource) {
|
|
269
|
-
return undefined;
|
|
270
|
-
}
|
|
271
|
-
var data = dataSource.getPropertyValue(dataReference.property);
|
|
272
|
-
if (data && dataReference.propertyPath) {
|
|
273
|
-
// multiple levels of sub-properties are separated by '.' in the property path.
|
|
274
|
-
var subpaths = dataReference.propertyPath.split('.');
|
|
275
|
-
subpaths.forEach(function (subpath) {
|
|
276
|
-
// If sub-property yields to an array value, then the path to the sub-property
|
|
277
|
-
// will have [*] appended after the name of the sub-property.
|
|
278
|
-
// Hence separating out to get the subPropertyName.
|
|
279
|
-
var subpathElements = subpath.split(DynamicDataProvider._jsonPathArrayRegex);
|
|
280
|
-
var subProperty = subpathElements[0];
|
|
281
|
-
// If the supplied reference has an array([*]) notation, then we extract the data
|
|
282
|
-
// accordingly. [*] means all the entries and if there is a number instead of the '*'
|
|
283
|
-
// then extract that specific entry.
|
|
284
|
-
if (data) {
|
|
285
|
-
if (Array.isArray(data)) {
|
|
286
|
-
var dataItems_1 = [];
|
|
287
|
-
data.forEach(function (item) {
|
|
288
|
-
if (item.hasOwnProperty(subProperty)) {
|
|
289
|
-
dataItems_1.push(item[subProperty]);
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
/*
|
|
293
|
-
* If a specific entry is asked, we return it else we return all the entries,
|
|
294
|
-
* essentially it is treated as [*].
|
|
295
|
-
*/
|
|
296
|
-
var index = subpathElements[1];
|
|
297
|
-
if (subpathElements.length > 1) {
|
|
298
|
-
/**
|
|
299
|
-
* This means that the current subpath element is an array type, an array inside an array.
|
|
300
|
-
* Since the subpath element is an array, we are normalizing the existing dataItems object
|
|
301
|
-
* i.e., dataItems will have an array of array objects.
|
|
302
|
-
*/
|
|
303
|
-
var tempDataItems_1 = [];
|
|
304
|
-
dataItems_1.forEach(function (dataItem) {
|
|
305
|
-
dataItem.forEach(function (internalItem) { return tempDataItems_1.push(internalItem); });
|
|
306
|
-
});
|
|
307
|
-
dataItems_1 = tempDataItems_1;
|
|
308
|
-
}
|
|
309
|
-
if (!isNaN(parseInt(index, 10))) {
|
|
310
|
-
data = dataItems_1[index];
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
data = dataItems_1;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
else if (data.hasOwnProperty(subProperty)) {
|
|
317
|
-
// data is an object type
|
|
318
|
-
data = data[subProperty];
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
// If the control is here, it means that the subProperty was not found in data.
|
|
322
|
-
// Hence the next iteration would get data as undefined.
|
|
323
|
-
data = undefined;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
return data;
|
|
329
|
-
};
|
|
330
|
-
DynamicDataProvider.prototype._onSourcesChanged = function () {
|
|
331
|
-
var _this = this;
|
|
332
|
-
var availableSourceIds = this.getAvailableSources().map(function (source) { return source.id; });
|
|
333
|
-
// Registering to sourceChanged event
|
|
334
|
-
this._pendingRegistrations.forEach(function (src) {
|
|
335
|
-
// register to sourceChanged event, if the source is available.
|
|
336
|
-
if (availableSourceIds.indexOf(src.id) !== -1) {
|
|
337
|
-
// Source is available
|
|
338
|
-
if (!src.propertyId) {
|
|
339
|
-
// No propertyId, means register to sourceChanged event.
|
|
340
|
-
_this._dynamicDataManager.registerSourceChanged(src.id, _this._component, src.callback);
|
|
341
|
-
_this._logFeatureEntry('RegisterSourceChanged', { sourceId: src.id });
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
// With propertyId, means register to propertyChanged event.
|
|
345
|
-
_this._dynamicDataManager.registerPropertyChanged(src.id, src.propertyId, _this._component, src.callback);
|
|
346
|
-
_this._logFeatureEntry('RegisterPropertyChanged', { sourceId: src.id, propertyId: src.propertyId });
|
|
347
|
-
}
|
|
348
|
-
_this._removePendingRegistration(src);
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
};
|
|
352
|
-
DynamicDataProvider.prototype._assertNotDisposed = function () {
|
|
353
|
-
if (this.isDisposed) {
|
|
354
|
-
throw new Error('Dynamic Data Provider has been disposed');
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
DynamicDataProvider.prototype._assertInitialized = function () {
|
|
358
|
-
if (!this._isInitialized) {
|
|
359
|
-
throw new Error('Dynamic Data Provider has not been initialized.');
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* Adds the registration to the pending registrations if not already added.
|
|
364
|
-
* Also adds a listener to the _DynamicDataManager's sourcesChangedEvent.
|
|
365
|
-
*/
|
|
366
|
-
DynamicDataProvider.prototype._addPendingRegistration = function (registration) {
|
|
367
|
-
if (!this._isRegistrationPending(registration)) {
|
|
368
|
-
this._pendingRegistrations.set(registration.id + (registration.propertyId || ''), {
|
|
369
|
-
id: registration.id,
|
|
370
|
-
propertyId: registration.propertyId,
|
|
371
|
-
callback: registration.callback
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
if (!this._isSourcesChangedEventListenerAdded) {
|
|
375
|
-
this._dynamicDataManager.sourcesChangedEvent.add(this._component, this._onSourcesChanged);
|
|
376
|
-
this._isSourcesChangedEventListenerAdded = true;
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* Removes the pending registration and then, if there are no more pending registrations
|
|
381
|
-
* remove the 'sourcesChangedEvent' listener.
|
|
382
|
-
*/
|
|
383
|
-
DynamicDataProvider.prototype._removePendingRegistration = function (registration) {
|
|
384
|
-
this._pendingRegistrations.delete(registration.id + (registration.propertyId || ''));
|
|
385
|
-
if (this._pendingRegistrations.size === 0) {
|
|
386
|
-
this._dynamicDataManager.sourcesChangedEvent.remove(this._component, this._onSourcesChanged);
|
|
387
|
-
this._isSourcesChangedEventListenerAdded = false;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
/**
|
|
391
|
-
* Returns true if the incoming source is already added to the _pendingRegistrations Map.
|
|
392
|
-
*
|
|
393
|
-
* @param incomingRegistration - registration to be checked.
|
|
394
|
-
*/
|
|
395
|
-
DynamicDataProvider.prototype._isRegistrationPending = function (incomingRegistration) {
|
|
396
|
-
return this._pendingRegistrations.has(incomingRegistration.id + (incomingRegistration.propertyId || ''));
|
|
397
|
-
};
|
|
398
|
-
/**
|
|
399
|
-
* Logs a feature event with any extra data from the producer of the event.
|
|
400
|
-
* @param logFeature - Name of the feature to log.
|
|
401
|
-
* @param contextualProps - Contextual log properties of the feature event.
|
|
402
|
-
*/
|
|
403
|
-
DynamicDataProvider.prototype._logFeatureEntry = function (logFeature, contextualProps) {
|
|
404
|
-
var isInternal = this._component.manifest.isInternal || false;
|
|
405
|
-
var logProperties = {
|
|
406
|
-
alias: this._component.manifest.alias,
|
|
407
|
-
isInternal: isInternal.toString()
|
|
408
|
-
};
|
|
409
|
-
var logEntry = new _LogEntry('DynamicDataProvider', logFeature, _LogType.Event, lodash.merge(logProperties, contextualProps));
|
|
410
|
-
_EngagementLogger.logEventWithLogEntry(logEntry);
|
|
411
|
-
};
|
|
412
|
-
/**
|
|
413
|
-
* Regular expression to evaluate arrays in a json path expression.
|
|
414
|
-
* @internal
|
|
415
|
-
*/
|
|
416
|
-
DynamicDataProvider._jsonPathArrayRegex = new RegExp(/\[|\]/);
|
|
417
|
-
return DynamicDataProvider;
|
|
418
|
-
}());
|
|
419
|
-
export default DynamicDataProvider;
|
|
420
|
-
//# sourceMappingURL=DynamicDataProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicDataSourceManager.d.ts","sourceRoot":"","sources":["../src/DynamicDataSourceManager.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAkB,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAEL,KAAK,qBAAqB,EAG1B,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAGhC,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAKjD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,YAAW,WAAW;IAClE,OAAO,CAAC,mBAAmB,CAAmC;IAC9D,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,IAAI,CAA6C;IACzD,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,UAAU,CAA8D;IAEhF;;;;;;OAMG;IACI,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI;IAW9E;;OAEG;IACI,OAAO,IAAI,IAAI;IActB;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;;OAGG;IACH,IAAW,OAAO,IAAI,kBAAkB,GAAG,SAAS,CAEnD;IAED;;;;OAIG;IACI,gBAAgB,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,IAAI;IAmBvE;;;;;OAKG;IACI,mBAAmB,IAAI,IAAI;IAOlC;;;;;;;OAOG;IACI,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQtD;;;;;;OAMG;IACI,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,0BAA0B,CAAC,GAAG,IAAI;IAc1E;;;OAGG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,OAAO,CAAC,YAAY;IA2BpB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAMtB;;;;OAIG;IAEH,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAI/B;;;;;;;;;;OAUG;IAEH,OAAO,CAAC,iBAAiB;IA2CzB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAIpC;;;OAGG;IAEH,OAAO,CAAC,sBAAsB;IAI9B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,0BAA0B;IA0ClC;;;OAGG;IACH,OAAO,CAAC,+BAA+B;IAIvC,OAAO,CAAC,cAAc;IAyBtB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,mBAAmB;IAM3B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CAezB"}
|