@mui/x-license 7.7.1 → 7.9.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,171 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.9.0
7
+
8
+ _Jul 5, 2024_
9
+
10
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🔄 Add loading overlay variants, including a skeleton loader option to the Data Grid component. See [Loading overlay docs](https://mui.com/x/react-data-grid/overlays/#loading-overlay) for more details.
13
+ - 🌳 Add `selectItem` and `getItemDOMElement` methods to the TreeView component public API
14
+ - ⛏️ Make the `usePickersTranslations` hook public in the pickers component
15
+ - 🐞 Bugfixes
16
+
17
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
18
+
19
+ ### Data Grid
20
+
21
+ #### `@mui/x-data-grid@7.9.0`
22
+
23
+ - [DataGrid] Add skeleton loading overlay support (#13293) @KenanYusuf
24
+ - [DataGrid] Fix pagination when `pagination={undefined}` (#13349) @sai6855
25
+
26
+ #### `@mui/x-data-grid-pro@7.9.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
27
+
28
+ Same changes as in `@mui/x-data-grid@7.9.0`.
29
+
30
+ #### `@mui/x-data-grid-premium@7.9.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
31
+
32
+ Same changes as in `@mui/x-data-grid-pro@7.9.0`.
33
+
34
+ ### Date and Time Pickers
35
+
36
+ #### `@mui/x-date-pickers@7.9.0`
37
+
38
+ - [pickers] Make the `usePickersTranslations` hook public (#13657) @flaviendelangle
39
+
40
+ #### `@mui/x-date-pickers-pro@7.9.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
41
+
42
+ Same changes as in `@mui/x-date-pickers@7.9.0`.
43
+
44
+ ### Charts
45
+
46
+ #### `@mui/x-charts@7.9.0`
47
+
48
+ - [charts] Add Heatmap (unreleased) (#13209) @alexfauquette
49
+ - [charts] Add initial `Zoom&Pan` to the Pro charts (unreleased) (#13405) @JCQuintas
50
+ - [charts] Fix Axis Highlight on horizontal bar charts regression (#13717) @JCQuintas
51
+ - [charts] Improve charts interaction for mobile users (#13692) @JCQuintas
52
+ - [charts] Add documentation on how to disable the tooltip on charts (#13724) @JCQuintas
53
+
54
+ ### Tree View
55
+
56
+ #### `@mui/x-tree-view@7.9.0`
57
+
58
+ - [TreeView] Add `selectItem` and `getItemDOMElement` methods to the public API (#13485) @flaviendelangle
59
+
60
+ ### Docs
61
+
62
+ - [docs] Fix custom "no results overlay" demo in dark mode (#13715) @KenanYusuf
63
+
64
+ ### Core
65
+
66
+ - [core] Add `react_next` workflow in CircleCI (#13360) @cherniavskii
67
+ - [core] Create a new package to share utils across X packages (#13528) @flaviendelangle
68
+ - [core] Fix dependency setup (#13684) @LukasTy
69
+ - [core] Remove `jscodeshift-add-imports` package (#13720) @LukasTy
70
+ - [code-infra] Cleanup monorepo and `@mui/docs` usage (#13713) @LukasTy
71
+
72
+ ## 7.8.0
73
+
74
+ _Jun 28, 2024_
75
+
76
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
77
+
78
+ - 🛰 Introduce server-side data source for improved server integration in the Data Grid.
79
+
80
+ Supports server-side pagination, sorting and filtering on plain and tree data, and automatic caching.
81
+
82
+ To enable, provide a `getRows` function to the `unstable_dataSource` prop on the Data Grid component.
83
+
84
+ ```tsx
85
+ const dataSource = {
86
+ getRows: async (params: GridServerGetRowsParams) => {
87
+ const data = await fetch(
88
+ `https://api.example.com/data?${new URLSearchParams({
89
+ page: params.page,
90
+ pageSize: params.pageSize,
91
+ sortModel: JSON.stringify(params.sortModel),
92
+ filterModel: JSON.stringify(params.filterModel),
93
+ }).toString()}`,
94
+ );
95
+ return {
96
+ rows: data.rows,
97
+ totalRows: data.totalRows,
98
+ };
99
+ },
100
+ }
101
+ <DataGridPro
102
+ unstable_dataSource={dataSource}
103
+ {...otherProps}
104
+ />
105
+ ```
106
+
107
+ See [server-side data documentation](https://mui.com/x/react-data-grid/server-side-data/) for more details.
108
+
109
+ - 📈 Support Date data on the BarChart component
110
+ - ↕️ Support custom column sort icons on the Data Grid
111
+ - 🖱️ Support modifying the expansion trigger on the Tree View components
112
+
113
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
114
+
115
+ ### Data Grid
116
+
117
+ #### `@mui/x-data-grid@7.8.0`
118
+
119
+ - [DataGrid] Add `columnHeaderSortIcon` slot (#13563) @arminmeh
120
+ - [DataGrid] Fix dimensions lag issue after autosize (#13587) @MBilalShafi
121
+ - [DataGrid] Fix print export failure when `hideFooter` option is set (#13034) @tarunrajput
122
+
123
+ #### `@mui/x-data-grid-pro@7.8.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
124
+
125
+ Same changes as in `@mui/x-data-grid@7.8.0`, plus:
126
+
127
+ - [DataGridPro] Fix multi-sorting indicator being cut off (#13625) @KenanYusuf
128
+ - [DataGridPro] Server-side tree data support (#12317) @MBilalShafi
129
+
130
+ #### `@mui/x-data-grid-premium@7.8.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
131
+
132
+ Same changes as in `@mui/x-data-grid-pro@7.8.0`.
133
+
134
+ ### Date and Time Pickers
135
+
136
+ #### `@mui/x-date-pickers@7.8.0`
137
+
138
+ - [fields] Fix section clearing behavior on Android (#13652) @LukasTy
139
+
140
+ #### `@mui/x-date-pickers-pro@7.8.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
141
+
142
+ Same changes as in `@mui/x-date-pickers@7.8.0`.
143
+
144
+ ### Charts
145
+
146
+ #### `@mui/x-charts@7.8.0`
147
+
148
+ - [charts] Fix line chart props not passing correct event handlers (#13609) @JCQuintas
149
+ - [charts] Support BarChart with `Date` data (#13471) @alexfauquette
150
+ - [charts] Support RTL for y-axis (#13614) @alexfauquette
151
+ - [charts] Use default values instead of non-null assertion to prevent error being thrown (#13637) @JCQuintas
152
+
153
+ ### Tree View
154
+
155
+ #### `@mui/x-tree-view@7.8.0`
156
+
157
+ - [TreeView] Add `expansionTrigger` prop (#13533) @noraleonte
158
+ - [TreeView] Support experimental features from plugin's dependencies (#13632) @flaviendelangle
159
+
160
+ ### Docs
161
+
162
+ - [docs] Add callout for `Luxon` `throwOnInvalid` support (#13621) @LukasTy
163
+ - [docs] Add "Overlays" section to the Data Grid documentation (#13624) @KenanYusuf
164
+
165
+ ### Core
166
+
167
+ - [core] Add eslint rule to restrict import from `../internals` root (#13633) @JCQuintas
168
+ - [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
169
+ - [license] Allow usage of charts and tree view pro package for old premium licenses (#13619) @flaviendelangle
170
+
6
171
  ## 7.7.1
7
172
 
8
173
  _Jun 21, 2024_
@@ -44,7 +209,7 @@ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
44
209
  - [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
45
210
  - [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
46
211
  - [pickers] Fix controlled `view` behavior (#13552) @LukasTy
47
- - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
212
+ - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
48
213
 
49
214
  #### `@mui/x-date-pickers-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
215
 
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { MuiCommercialPackageName } from '../useLicenseVerifier';
2
+ import { MuiCommercialPackageName } from '../utils/commercialPackages';
3
3
  interface WatermarkProps {
4
4
  packageName: MuiCommercialPackageName;
5
5
  releaseInfo: string;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-license v7.7.1
2
+ * @mui/x-license v7.9.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-license v7.7.1
2
+ * @mui/x-license v7.9.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -4,7 +4,6 @@ import { verifyLicense } from '../verifyLicense/verifyLicense';
4
4
  import { LicenseInfo } from '../utils/licenseInfo';
5
5
  import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from '../utils/licenseErrorMessageUtils';
6
6
  import { LICENSE_STATUS } from '../utils/licenseStatus';
7
- import { extractAcceptedScopes, extractProductScope } from '../utils/licenseScope';
8
7
  import MuiLicenseInfoContext from '../Unstable_LicenseInfoProvider/MuiLicenseInfoContext';
9
8
  export const sharedLicenseStatuses = {};
10
9
  export function useLicenseVerifier(packageName, releaseInfo) {
@@ -18,14 +17,11 @@ export function useLicenseVerifier(packageName, releaseInfo) {
18
17
  if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
19
18
  return sharedLicenseStatuses[packageName].licenseVerifier;
20
19
  }
21
- const acceptedScopes = extractAcceptedScopes(packageName);
22
- const productScope = extractProductScope(packageName);
23
20
  const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
24
21
  const licenseStatus = verifyLicense({
25
22
  releaseInfo,
26
23
  licenseKey,
27
- acceptedScopes,
28
- productScope
24
+ packageName
29
25
  });
30
26
  const fullPackageName = `@mui/${packageName}`;
31
27
  if (licenseStatus.status === LICENSE_STATUS.Valid) {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,12 +1,2 @@
1
1
  export const LICENSE_SCOPES = ['pro', 'premium'];
2
- export const PRODUCT_SCOPES = ['data-grid', 'date-pickers', 'charts', 'tree-view'];
3
- export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
4
- export const extractProductScope = packageName => {
5
- // extract the part between "x-" and "-pro"/"-premium"
6
- const regex = /x-(.*?)(-pro|-premium)?$/;
7
- const match = packageName.match(regex);
8
- return match[1];
9
- };
10
- export const extractAcceptedScopes = packageName => {
11
- return packageName.includes('premium') ? LICENSE_SCOPES.filter(scope => scope.includes('premium')) : LICENSE_SCOPES;
12
- };
2
+ export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
@@ -11,7 +11,20 @@ const getDefaultReleaseDate = () => {
11
11
  export function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
12
12
  return base64Encode(releaseDate.getTime().toString());
13
13
  }
14
+ function isLicenseScopeSufficient(packageName, licenseScope) {
15
+ let acceptedScopes;
16
+ if (packageName.includes('-pro')) {
17
+ acceptedScopes = ['pro', 'premium'];
18
+ } else if (packageName.includes('-premium')) {
19
+ acceptedScopes = ['premium'];
20
+ } else {
21
+ acceptedScopes = [];
22
+ }
23
+ return acceptedScopes.includes(licenseScope);
24
+ }
14
25
  const expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
26
+ const PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN = ['x-data-grid-pro', 'x-date-pickers-pro'];
27
+
15
28
  /**
16
29
  * Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
17
30
  */
@@ -79,8 +92,7 @@ const decodeLicense = encodedLicense => {
79
92
  export function verifyLicense({
80
93
  releaseInfo,
81
94
  licenseKey,
82
- acceptedScopes,
83
- productScope
95
+ packageName
84
96
  }) {
85
97
  if (!releaseInfo) {
86
98
  throw new Error('MUI X: The release information is missing. Not able to validate license.');
@@ -154,19 +166,18 @@ export function verifyLicense({
154
166
  status: LICENSE_STATUS.Invalid
155
167
  };
156
168
  }
157
- if (license.planVersion === 'initial') {
158
- // 'charts-pro' or 'tree-view-pro' can only be used with a newer license
159
- if (productScope === 'charts' || productScope === 'tree-view') {
160
- return {
161
- status: LICENSE_STATUS.NotAvailableInInitialProPlan
162
- };
163
- }
164
- }
165
- if (!acceptedScopes.includes(license.scope)) {
169
+ if (!isLicenseScopeSufficient(packageName, license.scope)) {
166
170
  return {
167
171
  status: LICENSE_STATUS.OutOfScope
168
172
  };
169
173
  }
174
+
175
+ // 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
176
+ if (license.planVersion === 'initial' && license.scope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
177
+ return {
178
+ status: LICENSE_STATUS.NotAvailableInInitialProPlan
179
+ };
180
+ }
170
181
  return {
171
182
  status: LICENSE_STATUS.Valid
172
183
  };
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-license v7.7.1
2
+ * @mui/x-license v7.9.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -12,7 +12,6 @@ var _verifyLicense = require("../verifyLicense/verifyLicense");
12
12
  var _licenseInfo = require("../utils/licenseInfo");
13
13
  var _licenseErrorMessageUtils = require("../utils/licenseErrorMessageUtils");
14
14
  var _licenseStatus = require("../utils/licenseStatus");
15
- var _licenseScope = require("../utils/licenseScope");
16
15
  var _MuiLicenseInfoContext = _interopRequireDefault(require("../Unstable_LicenseInfoProvider/MuiLicenseInfoContext"));
17
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -28,14 +27,11 @@ function useLicenseVerifier(packageName, releaseInfo) {
28
27
  if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
29
28
  return sharedLicenseStatuses[packageName].licenseVerifier;
30
29
  }
31
- const acceptedScopes = (0, _licenseScope.extractAcceptedScopes)(packageName);
32
- const productScope = (0, _licenseScope.extractProductScope)(packageName);
33
30
  const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
34
31
  const licenseStatus = (0, _verifyLicense.verifyLicense)({
35
32
  releaseInfo,
36
33
  licenseKey,
37
- acceptedScopes,
38
- productScope
34
+ packageName
39
35
  });
40
36
  const fullPackageName = `@mui/${packageName}`;
41
37
  if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.Valid) {
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -3,18 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.extractProductScope = exports.extractAcceptedScopes = exports.PRODUCT_SCOPES = exports.PLAN_VERSIONS = exports.LICENSE_SCOPES = void 0;
6
+ exports.PLAN_VERSIONS = exports.LICENSE_SCOPES = void 0;
7
7
  const LICENSE_SCOPES = exports.LICENSE_SCOPES = ['pro', 'premium'];
8
- const PRODUCT_SCOPES = exports.PRODUCT_SCOPES = ['data-grid', 'date-pickers', 'charts', 'tree-view'];
9
- const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024'];
10
- const extractProductScope = packageName => {
11
- // extract the part between "x-" and "-pro"/"-premium"
12
- const regex = /x-(.*?)(-pro|-premium)?$/;
13
- const match = packageName.match(regex);
14
- return match[1];
15
- };
16
- exports.extractProductScope = extractProductScope;
17
- const extractAcceptedScopes = packageName => {
18
- return packageName.includes('premium') ? LICENSE_SCOPES.filter(scope => scope.includes('premium')) : LICENSE_SCOPES;
19
- };
20
- exports.extractAcceptedScopes = extractAcceptedScopes;
8
+ const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024'];
@@ -18,7 +18,20 @@ const getDefaultReleaseDate = () => {
18
18
  function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
19
19
  return (0, _base.base64Encode)(releaseDate.getTime().toString());
20
20
  }
21
+ function isLicenseScopeSufficient(packageName, licenseScope) {
22
+ let acceptedScopes;
23
+ if (packageName.includes('-pro')) {
24
+ acceptedScopes = ['pro', 'premium'];
25
+ } else if (packageName.includes('-premium')) {
26
+ acceptedScopes = ['premium'];
27
+ } else {
28
+ acceptedScopes = [];
29
+ }
30
+ return acceptedScopes.includes(licenseScope);
31
+ }
21
32
  const expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
33
+ const PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN = ['x-data-grid-pro', 'x-date-pickers-pro'];
34
+
22
35
  /**
23
36
  * Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
24
37
  */
@@ -86,8 +99,7 @@ const decodeLicense = encodedLicense => {
86
99
  function verifyLicense({
87
100
  releaseInfo,
88
101
  licenseKey,
89
- acceptedScopes,
90
- productScope
102
+ packageName
91
103
  }) {
92
104
  if (!releaseInfo) {
93
105
  throw new Error('MUI X: The release information is missing. Not able to validate license.');
@@ -161,19 +173,18 @@ function verifyLicense({
161
173
  status: _licenseStatus.LICENSE_STATUS.Invalid
162
174
  };
163
175
  }
164
- if (license.planVersion === 'initial') {
165
- // 'charts-pro' or 'tree-view-pro' can only be used with a newer license
166
- if (productScope === 'charts' || productScope === 'tree-view') {
167
- return {
168
- status: _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan
169
- };
170
- }
171
- }
172
- if (!acceptedScopes.includes(license.scope)) {
176
+ if (!isLicenseScopeSufficient(packageName, license.scope)) {
173
177
  return {
174
178
  status: _licenseStatus.LICENSE_STATUS.OutOfScope
175
179
  };
176
180
  }
181
+
182
+ // 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
183
+ if (license.planVersion === 'initial' && license.scope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
184
+ return {
185
+ status: _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan
186
+ };
187
+ }
177
188
  return {
178
189
  status: _licenseStatus.LICENSE_STATUS.Valid
179
190
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-license",
3
- "version": "7.7.1",
3
+ "version": "7.9.0",
4
4
  "description": "MUI X License verification",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.24.7",
28
- "@mui/utils": "^5.15.20"
28
+ "@mui/utils": "^5.16.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "react": "^17.0.0 || ^18.0.0"
@@ -1,2 +1 @@
1
1
  export { useLicenseVerifier } from './useLicenseVerifier';
2
- export type { MuiCommercialPackageName } from './useLicenseVerifier';
@@ -1,5 +1,5 @@
1
1
  import { LicenseStatus } from '../utils/licenseStatus';
2
- export type MuiCommercialPackageName = 'x-data-grid-pro' | 'x-data-grid-premium' | 'x-date-pickers-pro' | 'x-tree-view-pro' | 'x-charts-pro';
2
+ import { MuiCommercialPackageName } from '../utils/commercialPackages';
3
3
  export declare const sharedLicenseStatuses: {
4
4
  [packageName in MuiCommercialPackageName]?: {
5
5
  key: string | undefined;
@@ -4,7 +4,6 @@ import { verifyLicense } from '../verifyLicense/verifyLicense';
4
4
  import { LicenseInfo } from '../utils/licenseInfo';
5
5
  import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from '../utils/licenseErrorMessageUtils';
6
6
  import { LICENSE_STATUS } from '../utils/licenseStatus';
7
- import { extractAcceptedScopes, extractProductScope } from '../utils/licenseScope';
8
7
  import MuiLicenseInfoContext from '../Unstable_LicenseInfoProvider/MuiLicenseInfoContext';
9
8
  export const sharedLicenseStatuses = {};
10
9
  export function useLicenseVerifier(packageName, releaseInfo) {
@@ -18,14 +17,11 @@ export function useLicenseVerifier(packageName, releaseInfo) {
18
17
  if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
19
18
  return sharedLicenseStatuses[packageName].licenseVerifier;
20
19
  }
21
- const acceptedScopes = extractAcceptedScopes(packageName);
22
- const productScope = extractProductScope(packageName);
23
20
  const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
24
21
  const licenseStatus = verifyLicense({
25
22
  releaseInfo,
26
23
  licenseKey,
27
- acceptedScopes,
28
- productScope
24
+ packageName
29
25
  });
30
26
  const fullPackageName = `@mui/${packageName}`;
31
27
  if (licenseStatus.status === LICENSE_STATUS.Valid) {
@@ -0,0 +1 @@
1
+ export type MuiCommercialPackageName = 'x-data-grid-pro' | 'x-data-grid-premium' | 'x-date-pickers-pro' | 'x-tree-view-pro' | 'x-charts-pro';
@@ -0,0 +1 @@
1
+ export {};
package/utils/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './licenseInfo';
3
3
  export * from './licenseStatus';
4
4
  export type { LicenseScope } from './licenseScope';
5
5
  export type { LicensingModel } from './licensingModel';
6
+ export type { MuiCommercialPackageName } from './commercialPackages';
@@ -1,8 +1,4 @@
1
1
  export declare const LICENSE_SCOPES: readonly ["pro", "premium"];
2
- export declare const PRODUCT_SCOPES: readonly ["data-grid", "date-pickers", "charts", "tree-view"];
3
2
  export declare const PLAN_VERSIONS: readonly ["initial", "Q3-2024"];
4
3
  export type LicenseScope = (typeof LICENSE_SCOPES)[number];
5
- export type ProductScope = (typeof PRODUCT_SCOPES)[number];
6
4
  export type PlanVersion = (typeof PLAN_VERSIONS)[number];
7
- export declare const extractProductScope: (packageName: string) => ProductScope;
8
- export declare const extractAcceptedScopes: (packageName: string) => readonly LicenseScope[];
@@ -1,12 +1,2 @@
1
1
  export const LICENSE_SCOPES = ['pro', 'premium'];
2
- export const PRODUCT_SCOPES = ['data-grid', 'date-pickers', 'charts', 'tree-view'];
3
- export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
4
- export const extractProductScope = packageName => {
5
- // extract the part between "x-" and "-pro"/"-premium"
6
- const regex = /x-(.*?)(-pro|-premium)?$/;
7
- const match = packageName.match(regex);
8
- return match[1];
9
- };
10
- export const extractAcceptedScopes = packageName => {
11
- return packageName.includes('premium') ? LICENSE_SCOPES.filter(scope => scope.includes('premium')) : LICENSE_SCOPES;
12
- };
2
+ export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
@@ -1,11 +1,10 @@
1
1
  import { LicenseStatus } from '../utils/licenseStatus';
2
- import { LicenseScope, ProductScope } from '../utils/licenseScope';
2
+ import { MuiCommercialPackageName } from '../utils/commercialPackages';
3
3
  export declare function generateReleaseInfo(releaseDate?: Date): string;
4
- export declare function verifyLicense({ releaseInfo, licenseKey, acceptedScopes, productScope, }: {
4
+ export declare function verifyLicense({ releaseInfo, licenseKey, packageName, }: {
5
5
  releaseInfo: string;
6
6
  licenseKey?: string;
7
- acceptedScopes: readonly LicenseScope[];
8
- productScope: ProductScope;
7
+ packageName: MuiCommercialPackageName;
9
8
  }): {
10
9
  status: LicenseStatus;
11
10
  meta?: any;
@@ -11,7 +11,20 @@ const getDefaultReleaseDate = () => {
11
11
  export function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
12
12
  return base64Encode(releaseDate.getTime().toString());
13
13
  }
14
+ function isLicenseScopeSufficient(packageName, licenseScope) {
15
+ let acceptedScopes;
16
+ if (packageName.includes('-pro')) {
17
+ acceptedScopes = ['pro', 'premium'];
18
+ } else if (packageName.includes('-premium')) {
19
+ acceptedScopes = ['premium'];
20
+ } else {
21
+ acceptedScopes = [];
22
+ }
23
+ return acceptedScopes.includes(licenseScope);
24
+ }
14
25
  const expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
26
+ const PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN = ['x-data-grid-pro', 'x-date-pickers-pro'];
27
+
15
28
  /**
16
29
  * Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
17
30
  */
@@ -79,8 +92,7 @@ const decodeLicense = encodedLicense => {
79
92
  export function verifyLicense({
80
93
  releaseInfo,
81
94
  licenseKey,
82
- acceptedScopes,
83
- productScope
95
+ packageName
84
96
  }) {
85
97
  if (!releaseInfo) {
86
98
  throw new Error('MUI X: The release information is missing. Not able to validate license.');
@@ -154,19 +166,18 @@ export function verifyLicense({
154
166
  status: LICENSE_STATUS.Invalid
155
167
  };
156
168
  }
157
- if (license.planVersion === 'initial') {
158
- // 'charts-pro' or 'tree-view-pro' can only be used with a newer license
159
- if (productScope === 'charts' || productScope === 'tree-view') {
160
- return {
161
- status: LICENSE_STATUS.NotAvailableInInitialProPlan
162
- };
163
- }
164
- }
165
- if (!acceptedScopes.includes(license.scope)) {
169
+ if (!isLicenseScopeSufficient(packageName, license.scope)) {
166
170
  return {
167
171
  status: LICENSE_STATUS.OutOfScope
168
172
  };
169
173
  }
174
+
175
+ // 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
176
+ if (license.planVersion === 'initial' && license.scope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
177
+ return {
178
+ status: LICENSE_STATUS.NotAvailableInInitialProPlan
179
+ };
180
+ }
170
181
  return {
171
182
  status: LICENSE_STATUS.Valid
172
183
  };