@microsoft/sp-component-base 1.22.0-beta.2 → 1.22.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +1 -1
  2. package/lib/BaseComponent.d.ts +115 -0
  3. package/lib/BaseComponent.d.ts.map +1 -0
  4. package/lib/BaseComponent.js +162 -0
  5. package/lib/BaseComponentContext.d.ts +142 -0
  6. package/lib/BaseComponentContext.d.ts.map +1 -0
  7. package/lib/BaseComponentContext.js +221 -0
  8. package/lib/DynamicDataProvider.d.ts +166 -0
  9. package/lib/DynamicDataProvider.d.ts.map +1 -0
  10. package/lib/DynamicDataProvider.js +420 -0
  11. package/lib/DynamicDataSourceManager.d.ts +160 -0
  12. package/lib/DynamicDataSourceManager.d.ts.map +1 -0
  13. package/lib/DynamicDataSourceManager.js +382 -0
  14. package/lib/DynamicProperty.d.ts +204 -0
  15. package/lib/DynamicProperty.d.ts.map +1 -0
  16. package/lib/DynamicProperty.js +390 -0
  17. package/lib/EnsureIsolatedDomainUrl.d.ts +9 -0
  18. package/lib/EnsureIsolatedDomainUrl.d.ts.map +1 -0
  19. package/lib/EnsureIsolatedDomainUrl.js +26 -0
  20. package/lib/IComponentPosition.d.ts +28 -0
  21. package/lib/IComponentPosition.d.ts.map +1 -0
  22. package/lib/IComponentPosition.js +2 -0
  23. package/lib/IComponentPropertyMetadata.d.ts +100 -0
  24. package/lib/IComponentPropertyMetadata.d.ts.map +1 -0
  25. package/lib/IComponentPropertyMetadata.js +2 -0
  26. package/lib/ISerializedServerProcessedData.d.ts +166 -0
  27. package/lib/ISerializedServerProcessedData.d.ts.map +1 -0
  28. package/lib/ISerializedServerProcessedData.js +28 -0
  29. package/lib/LegacyThirdPartyFabricCoreLoader.d.ts +40 -0
  30. package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +1 -0
  31. package/lib/LegacyThirdPartyFabricCoreLoader.js +90 -0
  32. package/lib/PropertyMetadataProcessor.d.ts +54 -0
  33. package/lib/PropertyMetadataProcessor.d.ts.map +1 -0
  34. package/lib/PropertyMetadataProcessor.js +297 -0
  35. package/lib/ShimmerFactory.d.ts +17 -0
  36. package/lib/ShimmerFactory.d.ts.map +1 -0
  37. package/lib/ShimmerFactory.js +62 -0
  38. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +17 -0
  39. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +1 -0
  40. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +17 -0
  41. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +9247 -0
  42. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +11165 -0
  43. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +2063 -0
  44. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +2164 -0
  45. package/lib/chunks/legacy-third-party-fabric-core/iconDefinitions.css +6 -0
  46. package/lib/common/Flights.d.ts +3 -0
  47. package/lib/common/Flights.d.ts.map +1 -0
  48. package/lib/common/Flights.js +10 -0
  49. package/lib/common/KillSwitches.d.ts +2 -0
  50. package/lib/common/KillSwitches.d.ts.map +1 -0
  51. package/lib/common/KillSwitches.js +5 -0
  52. package/lib/dataCollector/IWebPartLoadData.d.ts +140 -0
  53. package/lib/dataCollector/IWebPartLoadData.d.ts.map +1 -0
  54. package/lib/dataCollector/IWebPartLoadData.js +40 -0
  55. package/lib/dataCollector/WebPartLoadDataCollector.d.ts +14 -0
  56. package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +1 -0
  57. package/lib/dataCollector/WebPartLoadDataCollector.js +137 -0
  58. package/lib/index.d.ts +34 -0
  59. package/lib/index.d.ts.map +1 -0
  60. package/lib/index.js +27 -0
  61. package/lib/loc/Strings.resx.d.ts +44 -0
  62. package/lib/loc/Strings.resx.json +1 -0
  63. package/lib/sp-component-base.manifest.json +9 -0
  64. package/lib/styles/shimmer.module.scss.css +11 -0
  65. package/lib/teams/DeferredTeamsAppsClient.d.ts +17 -0
  66. package/lib/teams/DeferredTeamsAppsClient.d.ts.map +1 -0
  67. package/lib/teams/DeferredTeamsAppsClient.js +39 -0
  68. package/lib/teams/ITeamsAppCatalog.d.ts +72 -0
  69. package/lib/teams/ITeamsAppCatalog.d.ts.map +1 -0
  70. package/lib/teams/ITeamsAppCatalog.js +2 -0
  71. package/lib/teams/TeamsAppsClient.d.ts +113 -0
  72. package/lib/teams/TeamsAppsClient.d.ts.map +1 -0
  73. package/lib/teams/TeamsAppsClient.js +440 -0
  74. package/lib/test-api/MockComponent.d.ts +8 -0
  75. package/lib/test-api/MockComponent.d.ts.map +1 -0
  76. package/lib/test-api/MockComponent.js +31 -0
  77. package/lib/test-api/MockComponentContext.d.ts +6 -0
  78. package/lib/test-api/MockComponentContext.d.ts.map +1 -0
  79. package/lib/test-api/MockComponentContext.js +27 -0
  80. package/lib/test-api/index.d.ts +3 -0
  81. package/lib/test-api/index.d.ts.map +1 -0
  82. package/lib/test-api/index.js +3 -0
  83. package/lib/themeProvider/ThemeProvider.d.ts +71 -0
  84. package/lib/themeProvider/ThemeProvider.d.ts.map +1 -0
  85. package/lib/themeProvider/ThemeProvider.js +99 -0
  86. package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts +26 -0
  87. package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +1 -0
  88. package/lib/themeProvider/themeInterfaces/IFontStyles.js +2 -0
  89. package/lib/themeProvider/themeInterfaces/IPalette.d.ts +7 -0
  90. package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +1 -0
  91. package/lib/themeProvider/themeInterfaces/IPalette.js +2 -0
  92. package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts +56 -0
  93. package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +1 -0
  94. package/lib/themeProvider/themeInterfaces/ISemanticColors.js +2 -0
  95. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +7 -0
  96. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +1 -0
  97. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +2 -0
  98. package/lib/themeProvider/themeInterfaces/ITheme.d.ts +16 -0
  99. package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +1 -0
  100. package/lib/themeProvider/themeInterfaces/ITheme.js +2 -0
  101. package/package.json +15 -15
@@ -319,7 +319,7 @@
319
319
  "@msinternal/sp-telemetry": {
320
320
  "type": "component",
321
321
  "id": "8217e442-8ed3-41fd-957d-b112e841286a",
322
- "version": "0.35.36"
322
+ "version": "0.35.55"
323
323
  }
324
324
  }
325
325
  }
@@ -0,0 +1,115 @@
1
+ import type { ServiceScope, ISPEventObserver } from '@microsoft/sp-core-library';
2
+ import type { IClientSideComponentManifest } from '@microsoft/sp-module-interfaces';
3
+ import type BaseComponentContext from './BaseComponentContext';
4
+ /**
5
+ * The base class for client-side components such as BaseClientSideWebPart or BaseExtension.
6
+ *
7
+ * @public
8
+ */
9
+ export default abstract class BaseComponent implements ISPEventObserver {
10
+ /**
11
+ * Use the context object to access common services and state associated with the component.
12
+ *
13
+ * @remarks
14
+ *
15
+ * Child classes are expected to override this field by redeclaring it with a specialized type.
16
+ * It is meant to be a read-only property; the type cannot be declared as read-only in the base class
17
+ * (because it is initialized outside the constructor), but child classes should redeclare
18
+ * it as readonly.
19
+ *
20
+ * @privateRemarks
21
+ *
22
+ * This is a workaround for a missing compiler feature. If the compiler issue is resolved,
23
+ * then we can convert "context" to an ordinary property getter.
24
+ * https://github.com/Microsoft/TypeScript/issues/338
25
+ */
26
+ protected context?: BaseComponentContext;
27
+ /**
28
+ * Stores whether or not this component has a dynamic data source.
29
+ * @internal
30
+ */
31
+ protected _isWebPartAndContainsDynamicDataSource: boolean;
32
+ private _isDisposed;
33
+ /**
34
+ * Returns the dynamic data source id for the current instance of the component.
35
+ *
36
+ * @internal
37
+ */
38
+ get _dynamicDataSourceId(): string;
39
+ /** @internal */
40
+ constructor();
41
+ /**
42
+ * Disposes the component.
43
+ *
44
+ * @remarks
45
+ * Third-party code generally does not need to call this method; it's invoked
46
+ * automatically when the lifecycle ends for a web part or extension. To perform
47
+ * custom cleanup when your component is disposed, override the {@link BaseComponent.onDispose}
48
+ * method.
49
+ */
50
+ dispose(): void;
51
+ /**
52
+ * Returns whether or not this component contains a dynamic data source.
53
+ * @internal
54
+ */
55
+ get _containsDynamicDataSource(): boolean;
56
+ /**
57
+ * @internal
58
+ */
59
+ set _containsDynamicDataSource(val: boolean);
60
+ /**
61
+ * Returns true if the component has been already disposed.
62
+ */
63
+ get isDisposed(): boolean;
64
+ /**
65
+ * Provides access to the manifest for the client-side component.
66
+ * virtual
67
+ * @remarks
68
+ * Child classes can override this with more specialized manifest types.
69
+ */
70
+ get manifest(): IClientSideComponentManifest;
71
+ /**
72
+ * This event method is called at the end of the component's lifecycle.
73
+ * It provides an opportunity to release any associated resources, cancel any
74
+ * outstanding requests, etc.
75
+ * virtual
76
+ */
77
+ protected onDispose(): void;
78
+ /**
79
+ * A unique identifier for the instance of the component.
80
+ *
81
+ * @remarks
82
+ * A component implementation can be loaded multiple times on the page.
83
+ * For example, if the component is a charting web part, multiple instances of this web part
84
+ * could be added to the SharePoint canvas. The instanceId uniquely identifies each
85
+ * of these instances.
86
+ */
87
+ get instanceId(): string;
88
+ /**
89
+ * Returns the component identifier as defined in the component's associated manifest.
90
+ *
91
+ * @remarks
92
+ * Each client-side component has an associated manifest that is used by the sp-loader to load its scripts,
93
+ * and which may include additional metadata about the component. The manifest is uniquely identified using
94
+ * a text string containing a lower case GUID value.
95
+ */
96
+ get componentId(): string;
97
+ /**
98
+ * @internal
99
+ */
100
+ protected _initializeContext(context: BaseComponentContext): void;
101
+ /**
102
+ * This event method allows a component to add custom services to its
103
+ * {@link @microsoft/sp-core-library#ServiceScope}.
104
+ *
105
+ * @remarks
106
+ * This event method is fired before {@link @microsoft/sp-core-library#ServiceScope | ServiceScope.finish()}
107
+ * is called, allowing the component to provide custom services.
108
+ *
109
+ * virtual
110
+ *
111
+ * @alpha
112
+ */
113
+ protected onProvideServices(serviceScope: ServiceScope): void;
114
+ }
115
+ //# sourceMappingURL=BaseComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseComponent.d.ts","sourceRoot":"","sources":["../src/BaseComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,aAAc,YAAW,gBAAgB;IACrE;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,SAAS,CAAC,sCAAsC,EAAE,OAAO,CAAS;IAElE,OAAO,CAAC,WAAW,CAAkB;IAErC;;;;OAIG;IACH,IAAW,oBAAoB,IAAI,MAAM,CAExC;IAED,gBAAgB;;IAKhB;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI;IAWtB;;;OAGG;IACH,IAAW,0BAA0B,IAAI,OAAO,CAE/C;IAED;;OAEG;IACH,IAAW,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAEjD;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,4BAA4B,CAElD;IAED;;;;;OAKG;IACH,SAAS,CAAC,SAAS,IAAI,IAAI;IAI3B;;;;;;;;OAQG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;;;;;;OAOG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAiBjE;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;CAG9D"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * The base class for client-side components such as BaseClientSideWebPart or BaseExtension.
3
+ *
4
+ * @public
5
+ */
6
+ var BaseComponent = /** @class */ (function () {
7
+ /** @internal */
8
+ function BaseComponent() {
9
+ /**
10
+ * Stores whether or not this component has a dynamic data source.
11
+ * @internal
12
+ */
13
+ this._isWebPartAndContainsDynamicDataSource = false;
14
+ this._isDisposed = false;
15
+ // empty block
16
+ }
17
+ Object.defineProperty(BaseComponent.prototype, "_dynamicDataSourceId", {
18
+ /**
19
+ * Returns the dynamic data source id for the current instance of the component.
20
+ *
21
+ * @internal
22
+ */
23
+ get: function () {
24
+ return "".concat(this.manifest.componentType, ".").concat(this.manifest.id, ".").concat(this.instanceId);
25
+ },
26
+ enumerable: false,
27
+ configurable: true
28
+ });
29
+ /**
30
+ * Disposes the component.
31
+ *
32
+ * @remarks
33
+ * Third-party code generally does not need to call this method; it's invoked
34
+ * automatically when the lifecycle ends for a web part or extension. To perform
35
+ * custom cleanup when your component is disposed, override the {@link BaseComponent.onDispose}
36
+ * method.
37
+ */
38
+ BaseComponent.prototype.dispose = function () {
39
+ if (!this._isDisposed) {
40
+ this.onDispose();
41
+ this.context.dispose();
42
+ delete this.context;
43
+ this._isDisposed = true;
44
+ }
45
+ };
46
+ Object.defineProperty(BaseComponent.prototype, "_containsDynamicDataSource", {
47
+ /**
48
+ * Returns whether or not this component contains a dynamic data source.
49
+ * @internal
50
+ */
51
+ get: function () {
52
+ return this._isWebPartAndContainsDynamicDataSource;
53
+ },
54
+ /**
55
+ * @internal
56
+ */
57
+ set: function (val) {
58
+ this._isWebPartAndContainsDynamicDataSource = this.manifest.componentType === 'WebPart' ? val : false;
59
+ },
60
+ enumerable: false,
61
+ configurable: true
62
+ });
63
+ Object.defineProperty(BaseComponent.prototype, "isDisposed", {
64
+ /**
65
+ * Returns true if the component has been already disposed.
66
+ */
67
+ get: function () {
68
+ return this._isDisposed;
69
+ },
70
+ enumerable: false,
71
+ configurable: true
72
+ });
73
+ Object.defineProperty(BaseComponent.prototype, "manifest", {
74
+ /**
75
+ * Provides access to the manifest for the client-side component.
76
+ * virtual
77
+ * @remarks
78
+ * Child classes can override this with more specialized manifest types.
79
+ */
80
+ get: function () {
81
+ return this.context.manifest;
82
+ },
83
+ enumerable: false,
84
+ configurable: true
85
+ });
86
+ /**
87
+ * This event method is called at the end of the component's lifecycle.
88
+ * It provides an opportunity to release any associated resources, cancel any
89
+ * outstanding requests, etc.
90
+ * virtual
91
+ */
92
+ BaseComponent.prototype.onDispose = function () {
93
+ // (empty block)
94
+ };
95
+ Object.defineProperty(BaseComponent.prototype, "instanceId", {
96
+ /**
97
+ * A unique identifier for the instance of the component.
98
+ *
99
+ * @remarks
100
+ * A component implementation can be loaded multiple times on the page.
101
+ * For example, if the component is a charting web part, multiple instances of this web part
102
+ * could be added to the SharePoint canvas. The instanceId uniquely identifies each
103
+ * of these instances.
104
+ */
105
+ get: function () {
106
+ return this.context.instanceId;
107
+ },
108
+ enumerable: false,
109
+ configurable: true
110
+ });
111
+ Object.defineProperty(BaseComponent.prototype, "componentId", {
112
+ /**
113
+ * Returns the component identifier as defined in the component's associated manifest.
114
+ *
115
+ * @remarks
116
+ * Each client-side component has an associated manifest that is used by the sp-loader to load its scripts,
117
+ * and which may include additional metadata about the component. The manifest is uniquely identified using
118
+ * a text string containing a lower case GUID value.
119
+ */
120
+ get: function () {
121
+ return this.context.manifest.id;
122
+ },
123
+ enumerable: false,
124
+ configurable: true
125
+ });
126
+ /**
127
+ * @internal
128
+ */
129
+ BaseComponent.prototype._initializeContext = function (context) {
130
+ this.context = context;
131
+ this.onProvideServices(context.serviceScope);
132
+ /*
133
+ * Calling finish on an already finished servicescope will throw.
134
+ * Hence, checking it before finishing the servicescope.
135
+ *
136
+ * In the case of ApplicationCustomizers, it's context is calling 'finish'
137
+ * on the service scope. Hence, it is required to have the below check.
138
+ */
139
+ if (!context.serviceScope._isFinished) {
140
+ context.serviceScope.finish();
141
+ }
142
+ this.context._initializeDynamicData(this, context.serviceScope);
143
+ };
144
+ /**
145
+ * This event method allows a component to add custom services to its
146
+ * {@link @microsoft/sp-core-library#ServiceScope}.
147
+ *
148
+ * @remarks
149
+ * This event method is fired before {@link @microsoft/sp-core-library#ServiceScope | ServiceScope.finish()}
150
+ * is called, allowing the component to provide custom services.
151
+ *
152
+ * virtual
153
+ *
154
+ * @alpha
155
+ */
156
+ BaseComponent.prototype.onProvideServices = function (serviceScope) {
157
+ // empty block
158
+ };
159
+ return BaseComponent;
160
+ }());
161
+ export default BaseComponent;
162
+ //# sourceMappingURL=BaseComponent.js.map
@@ -0,0 +1,142 @@
1
+ import { type ServiceScope, type IDisposable } from '@microsoft/sp-core-library';
2
+ import type { IClientSideComponentManifest } from '@microsoft/sp-module-interfaces';
3
+ import { PageContext } from '@microsoft/sp-page-context';
4
+ import { HttpClient, SPHttpClient, AadHttpClientFactory, AadTokenProviderFactory, MSGraphClientFactory } from '@microsoft/sp-http';
5
+ import type BaseComponent from './BaseComponent';
6
+ import DynamicDataProvider from './DynamicDataProvider';
7
+ import DynamicDataSourceManager from './DynamicDataSourceManager';
8
+ /**
9
+ * Constructor parameters for a BaseComponentContext.
10
+ *
11
+ * @internal
12
+ */
13
+ export interface IComponentContextParameters {
14
+ /**
15
+ * The manager's ServiceScope, which will be used to create the child
16
+ * ServiceScope for the associated context.
17
+ */
18
+ readonly parentServiceScope: ServiceScope;
19
+ /**
20
+ * The client-side component manifest.
21
+ */
22
+ readonly manifest: IClientSideComponentManifest;
23
+ /**
24
+ * Logging service tag
25
+ */
26
+ readonly loggingTag: string;
27
+ /**
28
+ * Instance id for the client-side component.
29
+ */
30
+ readonly instanceId: string;
31
+ }
32
+ /**
33
+ * The base class for context objects for client-side components.
34
+ *
35
+ * @remarks
36
+ * A "context" object is a collection of well-known services and other
37
+ * objects that are likely to be needed by business logic that interacts with a
38
+ * associated component. Each component type has its own specialized subclass
39
+ * of BaseComponentContext, e.g. WebPartContext for web parts, ExtensionContext for
40
+ * client-side extensions, and so on.
41
+ *
42
+ * @privateRemarks
43
+ *
44
+ * NOTE: The context object is a convenience that avoids the overhead of
45
+ * properly factoring the dependencies for every class in a project.
46
+ * If lots of members are added to the context without discipline, it can
47
+ * easily devolve into a poor engineering practice (where "everything depends
48
+ * on everything else"). Think carefully before adding more objects to the context object.
49
+ * Is it really a core scenario? Is it unnecessarily coupling your package to another
50
+ * package? Is there a better place to put the object?
51
+ *
52
+ * Only add data properties or well-defined classes with ubiquitous applicability.
53
+ * Never add loose functions, callbacks, or settable properties to the context.
54
+ *
55
+ * @public
56
+ */
57
+ declare abstract class BaseComponentContext implements IDisposable {
58
+ /**
59
+ * Manifest for the client-side component.
60
+ */
61
+ readonly manifest: IClientSideComponentManifest;
62
+ private _serviceScope;
63
+ private _instanceId;
64
+ private _pageContext;
65
+ private _dynamicDataProvider;
66
+ private _dynamicDataSourceManager;
67
+ private _isDisposed;
68
+ private _httpClient;
69
+ private _spHttpClient;
70
+ private _aadClientFactory;
71
+ private _aadTokenFactory;
72
+ private _msGraphClientFactory;
73
+ private _isServedFromLocalhost;
74
+ /** @internal */
75
+ constructor(parameters: IComponentContextParameters);
76
+ /**
77
+ * Returns true if the context is disposed.
78
+ */
79
+ get isDisposed(): boolean;
80
+ /**
81
+ * Disposes the base component context.
82
+ */
83
+ dispose(): void;
84
+ /**
85
+ * The associated {@link @microsoft/sp-core-library#ServiceScope} for this component.
86
+ * @remarks
87
+ * A child service scope is created for each client-side component.
88
+ */
89
+ get serviceScope(): ServiceScope;
90
+ /**
91
+ * {@inheritDoc BaseComponent.instanceId}
92
+ */
93
+ get instanceId(): string;
94
+ /**
95
+ * The page context provides standard definitions for common SharePoint objects
96
+ * that need to be shared between the client-side application, web parts, and other
97
+ * components.
98
+ */
99
+ get pageContext(): PageContext;
100
+ /**
101
+ * Creates a Dynamic Data Provider for the component.
102
+ *
103
+ * @param component - Component tied to the Dynamic Data Provider
104
+ * @param serviceScope - ServiceScope to consume the Dynamic Data Manager from. Must be finished.
105
+ * @internal
106
+ */
107
+ _initializeDynamicData(component: BaseComponent, serviceScope: ServiceScope): void;
108
+ /**
109
+ * Returns the Dynamic Data Provider associated with the component.
110
+ */
111
+ get dynamicDataProvider(): DynamicDataProvider;
112
+ /**
113
+ * Returns the Dynamic Data Source Manager associated with the component.
114
+ */
115
+ get dynamicDataSourceManager(): DynamicDataSourceManager;
116
+ /**
117
+ * The instance of AadHttpClientFactory created for this instance of component
118
+ */
119
+ get aadHttpClientFactory(): AadHttpClientFactory;
120
+ /**
121
+ * The instance of AadTokenProviderFactory created for this instance of component
122
+ */
123
+ get aadTokenProviderFactory(): AadTokenProviderFactory;
124
+ /**
125
+ * The instance of MSGraphClientFactory created for this instance of component
126
+ */
127
+ get msGraphClientFactory(): MSGraphClientFactory;
128
+ /**
129
+ * The instance of HttpClient created for this instance of component
130
+ */
131
+ get httpClient(): HttpClient;
132
+ /**
133
+ * The instance of SpHttpClient created for this instance of component
134
+ */
135
+ get spHttpClient(): SPHttpClient;
136
+ /**
137
+ * Returns true if the solution is being served from localhost
138
+ */
139
+ get isServedFromLocalhost(): boolean;
140
+ }
141
+ export default BaseComponentContext;
142
+ //# sourceMappingURL=BaseComponentContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseComponentContext.d.ts","sourceRoot":"","sources":["../src/BaseComponentContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,WAAW,EAEjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,4BAA4B,CAAC;IAEhD;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,uBAAe,oBAAqB,YAAW,WAAW;IACxD;;OAEG;IACH,SAAgB,QAAQ,EAAE,4BAA4B,CAAC;IAEvD,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,yBAAyB,CAAuC;IACxE,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,sBAAsB,CAAkB;IAEhD,gBAAgB;gBACG,UAAU,EAAE,2BAA2B;IA0C1D;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;OAEG;IACI,OAAO,IAAI,IAAI;IAkBtB;;;;OAIG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;;;OAIG;IACH,IAAW,WAAW,IAAI,WAAW,CAEpC;IAED;;;;;;OAMG;IACI,sBAAsB,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI;IAKzF;;OAEG;IACH,IAAW,mBAAmB,IAAI,mBAAmB,CAEpD;IAED;;OAEG;IACH,IAAW,wBAAwB,IAAI,wBAAwB,CAE9D;IAED;;OAEG;IACH,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAED;;OAEG;IACH,IAAW,uBAAuB,IAAI,uBAAuB,CAE5D;IAED;;OAEG;IACH,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,UAAU,CAElC;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED;;OAEG;IACH,IAAW,qBAAqB,IAAI,OAAO,CAE1C;CACF;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,221 @@
1
+ import { Validate, _ClientManifestData } from '@microsoft/sp-core-library';
2
+ import { _LogSource, _logSourceServiceKey } from '@microsoft/sp-diagnostics';
3
+ import { PageContext } from '@microsoft/sp-page-context';
4
+ import { HttpClient, SPHttpClient, AadHttpClientFactory, AadTokenProviderFactory, MSGraphClientFactory } from '@microsoft/sp-http';
5
+ import DynamicDataProvider from './DynamicDataProvider';
6
+ import DynamicDataSourceManager from './DynamicDataSourceManager';
7
+ /**
8
+ * The base class for context objects for client-side components.
9
+ *
10
+ * @remarks
11
+ * A "context" object is a collection of well-known services and other
12
+ * objects that are likely to be needed by business logic that interacts with a
13
+ * associated component. Each component type has its own specialized subclass
14
+ * of BaseComponentContext, e.g. WebPartContext for web parts, ExtensionContext for
15
+ * client-side extensions, and so on.
16
+ *
17
+ * @privateRemarks
18
+ *
19
+ * NOTE: The context object is a convenience that avoids the overhead of
20
+ * properly factoring the dependencies for every class in a project.
21
+ * If lots of members are added to the context without discipline, it can
22
+ * easily devolve into a poor engineering practice (where "everything depends
23
+ * on everything else"). Think carefully before adding more objects to the context object.
24
+ * Is it really a core scenario? Is it unnecessarily coupling your package to another
25
+ * package? Is there a better place to put the object?
26
+ *
27
+ * Only add data properties or well-defined classes with ubiquitous applicability.
28
+ * Never add loose functions, callbacks, or settable properties to the context.
29
+ *
30
+ * @public
31
+ */
32
+ var BaseComponentContext = /** @class */ (function () {
33
+ /** @internal */
34
+ function BaseComponentContext(parameters) {
35
+ var _this = this;
36
+ this._isDisposed = false;
37
+ this._isServedFromLocalhost = false;
38
+ Validate.isNotNullOrUndefined(parameters, 'parameters');
39
+ Validate.isNotNullOrUndefined(parameters.manifest, 'manifest');
40
+ this.manifest = parameters.manifest;
41
+ var loaderConfig = this.manifest.loaderConfig;
42
+ if (loaderConfig && loaderConfig.internalModuleBaseUrls && loaderConfig.internalModuleBaseUrls.length) {
43
+ this._isServedFromLocalhost = /^http(s)?\:\/\/(localhost|127.0.0.1)/gim.test(loaderConfig.internalModuleBaseUrls[0]);
44
+ }
45
+ Validate.isNotNullOrUndefined(parameters.parentServiceScope, 'parentServiceScope');
46
+ this._serviceScope = parameters.parentServiceScope.startNewChild();
47
+ // TODO: VSO:507790 Reconcile this with ClientSideWebPartManager._createWebPartTag()
48
+ Validate.isNotNullOrUndefined(parameters.loggingTag, 'loggingTag');
49
+ this.serviceScope.provide(_logSourceServiceKey, _LogSource.create(parameters.loggingTag));
50
+ Validate.isNonemptyString(parameters.instanceId, 'instanceId');
51
+ this._instanceId = parameters.instanceId;
52
+ this._httpClient = this.serviceScope.createDefaultAndProvide(HttpClient.serviceKey);
53
+ this._spHttpClient = this.serviceScope.createDefaultAndProvide(SPHttpClient.serviceKey);
54
+ this._msGraphClientFactory = this.serviceScope.createDefaultAndProvide(MSGraphClientFactory.serviceKey);
55
+ this._aadClientFactory = this.serviceScope.createDefaultAndProvide(AadHttpClientFactory.serviceKey);
56
+ this._aadTokenFactory = this.serviceScope.createDefaultAndProvide(AadTokenProviderFactory.serviceKey);
57
+ this.serviceScope.provide(_ClientManifestData.serviceKey, new _ClientManifestData(this.serviceScope, this.manifest));
58
+ // Consume services
59
+ this.serviceScope.whenFinished(function () {
60
+ _this._pageContext = _this.serviceScope.consume(PageContext.serviceKey);
61
+ });
62
+ this._dynamicDataProvider = new DynamicDataProvider();
63
+ this._dynamicDataSourceManager = new DynamicDataSourceManager();
64
+ }
65
+ Object.defineProperty(BaseComponentContext.prototype, "isDisposed", {
66
+ /**
67
+ * Returns true if the context is disposed.
68
+ */
69
+ get: function () {
70
+ return this._isDisposed;
71
+ },
72
+ enumerable: false,
73
+ configurable: true
74
+ });
75
+ /**
76
+ * Disposes the base component context.
77
+ */
78
+ BaseComponentContext.prototype.dispose = function () {
79
+ if (!this._isDisposed) {
80
+ if (this._dynamicDataProvider) {
81
+ this._dynamicDataProvider.dispose();
82
+ }
83
+ if (this._dynamicDataSourceManager) {
84
+ this._dynamicDataSourceManager.dispose();
85
+ }
86
+ delete this._serviceScope;
87
+ delete this._pageContext;
88
+ delete this._dynamicDataProvider;
89
+ delete this._dynamicDataSourceManager;
90
+ this._isDisposed = true;
91
+ }
92
+ };
93
+ Object.defineProperty(BaseComponentContext.prototype, "serviceScope", {
94
+ /**
95
+ * The associated {@link @microsoft/sp-core-library#ServiceScope} for this component.
96
+ * @remarks
97
+ * A child service scope is created for each client-side component.
98
+ */
99
+ get: function () {
100
+ return this._serviceScope;
101
+ },
102
+ enumerable: false,
103
+ configurable: true
104
+ });
105
+ Object.defineProperty(BaseComponentContext.prototype, "instanceId", {
106
+ /**
107
+ * {@inheritDoc BaseComponent.instanceId}
108
+ */
109
+ get: function () {
110
+ return this._instanceId;
111
+ },
112
+ enumerable: false,
113
+ configurable: true
114
+ });
115
+ Object.defineProperty(BaseComponentContext.prototype, "pageContext", {
116
+ /**
117
+ * The page context provides standard definitions for common SharePoint objects
118
+ * that need to be shared between the client-side application, web parts, and other
119
+ * components.
120
+ */
121
+ get: function () {
122
+ return this._pageContext;
123
+ },
124
+ enumerable: false,
125
+ configurable: true
126
+ });
127
+ /**
128
+ * Creates a Dynamic Data Provider for the component.
129
+ *
130
+ * @param component - Component tied to the Dynamic Data Provider
131
+ * @param serviceScope - ServiceScope to consume the Dynamic Data Manager from. Must be finished.
132
+ * @internal
133
+ */
134
+ BaseComponentContext.prototype._initializeDynamicData = function (component, serviceScope) {
135
+ this._dynamicDataProvider._initialize(component, serviceScope);
136
+ this._dynamicDataSourceManager._initialize(component, serviceScope);
137
+ };
138
+ Object.defineProperty(BaseComponentContext.prototype, "dynamicDataProvider", {
139
+ /**
140
+ * Returns the Dynamic Data Provider associated with the component.
141
+ */
142
+ get: function () {
143
+ return this._dynamicDataProvider;
144
+ },
145
+ enumerable: false,
146
+ configurable: true
147
+ });
148
+ Object.defineProperty(BaseComponentContext.prototype, "dynamicDataSourceManager", {
149
+ /**
150
+ * Returns the Dynamic Data Source Manager associated with the component.
151
+ */
152
+ get: function () {
153
+ return this._dynamicDataSourceManager;
154
+ },
155
+ enumerable: false,
156
+ configurable: true
157
+ });
158
+ Object.defineProperty(BaseComponentContext.prototype, "aadHttpClientFactory", {
159
+ /**
160
+ * The instance of AadHttpClientFactory created for this instance of component
161
+ */
162
+ get: function () {
163
+ return this._aadClientFactory;
164
+ },
165
+ enumerable: false,
166
+ configurable: true
167
+ });
168
+ Object.defineProperty(BaseComponentContext.prototype, "aadTokenProviderFactory", {
169
+ /**
170
+ * The instance of AadTokenProviderFactory created for this instance of component
171
+ */
172
+ get: function () {
173
+ return this._aadTokenFactory;
174
+ },
175
+ enumerable: false,
176
+ configurable: true
177
+ });
178
+ Object.defineProperty(BaseComponentContext.prototype, "msGraphClientFactory", {
179
+ /**
180
+ * The instance of MSGraphClientFactory created for this instance of component
181
+ */
182
+ get: function () {
183
+ return this._msGraphClientFactory;
184
+ },
185
+ enumerable: false,
186
+ configurable: true
187
+ });
188
+ Object.defineProperty(BaseComponentContext.prototype, "httpClient", {
189
+ /**
190
+ * The instance of HttpClient created for this instance of component
191
+ */
192
+ get: function () {
193
+ return this._httpClient;
194
+ },
195
+ enumerable: false,
196
+ configurable: true
197
+ });
198
+ Object.defineProperty(BaseComponentContext.prototype, "spHttpClient", {
199
+ /**
200
+ * The instance of SpHttpClient created for this instance of component
201
+ */
202
+ get: function () {
203
+ return this._spHttpClient;
204
+ },
205
+ enumerable: false,
206
+ configurable: true
207
+ });
208
+ Object.defineProperty(BaseComponentContext.prototype, "isServedFromLocalhost", {
209
+ /**
210
+ * Returns true if the solution is being served from localhost
211
+ */
212
+ get: function () {
213
+ return this._isServedFromLocalhost;
214
+ },
215
+ enumerable: false,
216
+ configurable: true
217
+ });
218
+ return BaseComponentContext;
219
+ }());
220
+ export default BaseComponentContext;
221
+ //# sourceMappingURL=BaseComponentContext.js.map