@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,44 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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', {
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
this._logFeatureEntry('RegisterSourceChanged', {
|
|
83
|
+
sourceId: sourceId
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
106
86
|
// requested source is NOT available
|
|
107
|
-
this._addPendingRegistration({
|
|
87
|
+
this._addPendingRegistration({
|
|
88
|
+
id: sourceId,
|
|
89
|
+
callback: callback
|
|
90
|
+
});
|
|
108
91
|
}
|
|
109
|
-
}
|
|
92
|
+
}
|
|
110
93
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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', {
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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', {
|
|
154
|
-
|
|
155
|
-
|
|
138
|
+
this._logFeatureEntry('RegisterPropertyChanged', {
|
|
139
|
+
sourceId: sourceId,
|
|
140
|
+
propertyId: propertyId
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
156
143
|
// requested source is NOT available
|
|
157
|
-
this._addPendingRegistration({
|
|
144
|
+
this._addPendingRegistration({
|
|
145
|
+
id: sourceId,
|
|
146
|
+
propertyId: propertyId,
|
|
147
|
+
callback: callback
|
|
148
|
+
});
|
|
158
149
|
}
|
|
159
|
-
}
|
|
150
|
+
}
|
|
160
151
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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', {
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
241
|
-
this._dynamicDataManager.getSources().forEach(
|
|
242
|
-
if (componentId.equals(
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
244
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(id, 'id');
|
|
258
245
|
return this._dynamicDataManager.tryGetSource(id);
|
|
259
|
-
}
|
|
246
|
+
}
|
|
260
247
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
270
|
-
|
|
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
|
-
|
|
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
|
-
|
|
278
|
-
subpaths.forEach(
|
|
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
|
-
|
|
283
|
-
|
|
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
|
-
|
|
290
|
-
data.forEach(
|
|
275
|
+
let dataItems = [];
|
|
276
|
+
data.forEach((item)=>{
|
|
291
277
|
if (item.hasOwnProperty(subProperty)) {
|
|
292
|
-
|
|
278
|
+
dataItems.push(item[subProperty]);
|
|
293
279
|
}
|
|
294
280
|
});
|
|
295
281
|
/*
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
294
|
+
dataItems = tempDataItems;
|
|
311
295
|
}
|
|
312
296
|
if (!isNaN(parseInt(index, 10))) {
|
|
313
|
-
data =
|
|
297
|
+
data = dataItems[index];
|
|
298
|
+
} else {
|
|
299
|
+
data = dataItems;
|
|
314
300
|
}
|
|
315
|
-
|
|
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
|
-
|
|
334
|
-
|
|
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(
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
349
|
-
|
|
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
|
-
|
|
335
|
+
this._removePendingRegistration(src);
|
|
352
336
|
}
|
|
353
337
|
});
|
|
354
|
-
}
|
|
355
|
-
|
|
338
|
+
}
|
|
339
|
+
_assertNotDisposed() {
|
|
356
340
|
if (this.isDisposed) {
|
|
357
341
|
throw new Error('Dynamic Data Provider has been disposed');
|
|
358
342
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
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
|
-
|
|
367
|
-
|
|
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
|
-
|
|
384
|
-
|
|
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
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|