@jetbrains/ring-ui-built 6.0.52 → 6.0.54-beta.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.
@@ -112,4 +112,4 @@ var ThemeProvider = /*#__PURE__*/forwardRef(function ThemeProvider(_ref2, ref) {
112
112
  });
113
113
  var Theme$1 = Theme;
114
114
 
115
- export { Theme$1 as T, WithThemeClasses as W, ThemeProvider as a, ThemeContext as b, useThemeClasses as c, applyTheme as d, modules_59717246 as m, useTheme as u };
115
+ export { GLOBAL_DARK_CLASS_NAME as G, Theme$1 as T, WithThemeClasses as W, ThemeProvider as a, ThemeContext as b, useThemeClasses as c, applyTheme as d, modules_59717246 as m, useTheme as u };
@@ -129,7 +129,7 @@ export default class Auth implements HTTPAuth {
129
129
  listeners: Listeners<AuthPayloadMap>;
130
130
  http: HTTP;
131
131
  private _service;
132
- readonly _storage: AuthStorage<number> | null;
132
+ readonly _storage: AuthStorage<number>;
133
133
  private _responseParser;
134
134
  private readonly _requestBuilder;
135
135
  _backgroundFlow: BackgroundFlow | null;
@@ -174,7 +174,7 @@ export default class Auth implements HTTPAuth {
174
174
  /**
175
175
  * @return {Promise.<object>}
176
176
  */
177
- getUser(accessToken?: string | null | undefined): Promise<any> | undefined;
177
+ getUser(accessToken?: string | null | undefined): Promise<any>;
178
178
  /**
179
179
  * @return {Promise.<object>}
180
180
  */
@@ -197,7 +197,7 @@ export default class Auth implements HTTPAuth {
197
197
  */
198
198
  login(): Promise<void>;
199
199
  switchUser(): Promise<void>;
200
- _makeStateFromResponse(authResponse: AuthResponse): AuthState;
200
+ _makeStateFromResponse(authResponse: AuthResponse): AuthState | null;
201
201
  /**
202
202
  * Check if the hash contains an access token.
203
203
  * If it does, extract the state, compare with
@@ -137,7 +137,7 @@ var Auth = /*#__PURE__*/function () {
137
137
  _defineProperty(this, "listeners", new Listeners());
138
138
  _defineProperty(this, "http", void 0);
139
139
  _defineProperty(this, "_service", {});
140
- _defineProperty(this, "_storage", null);
140
+ _defineProperty(this, "_storage", void 0);
141
141
  _defineProperty(this, "_responseParser", new AuthResponseParser());
142
142
  _defineProperty(this, "_requestBuilder", null);
143
143
  _defineProperty(this, "_backgroundFlow", void 0);
@@ -1402,22 +1402,23 @@ var Auth = /*#__PURE__*/function () {
1402
1402
  value: function _makeStateFromResponse(authResponse) {
1403
1403
  var state = authResponse.state;
1404
1404
  if (!state) {
1405
- return {};
1405
+ throw new Error('No state in AuthResponse');
1406
1406
  }
1407
1407
  var defaultScope = this.config.scope;
1408
+ var urlFromState = null;
1408
1409
  try {
1409
- var urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1410
- if (urlFromState.origin !== window.location.origin) {
1411
- return {};
1412
- }
1413
- return {
1414
- restoreLocation: state,
1415
- created: Date.now(),
1416
- scopes: defaultScope
1417
- };
1418
- } catch (e) {
1419
- return {};
1410
+ urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1411
+ } catch (_unused2) {
1412
+ return null;
1420
1413
  }
1414
+ if (urlFromState.origin !== window.location.origin) {
1415
+ throw new Error("State contains URL with different origin: \"".concat(state, "\""));
1416
+ }
1417
+ return {
1418
+ restoreLocation: state,
1419
+ created: Date.now(),
1420
+ scopes: defaultScope
1421
+ };
1421
1422
  }
1422
1423
  /**
1423
1424
  * Check if the hash contains an access token.
@@ -1431,8 +1432,7 @@ var Auth = /*#__PURE__*/function () {
1431
1432
  key: "_checkForAuthResponse",
1432
1433
  value: (function () {
1433
1434
  var _checkForAuthResponse2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1434
- var _this$_storage12;
1435
- var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage13;
1435
+ var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage12;
1436
1436
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1437
1437
  while (1) switch (_context20.prev = _context20.next) {
1438
1438
  case 0:
@@ -1449,34 +1449,42 @@ var Auth = /*#__PURE__*/function () {
1449
1449
  return _context20.abrupt("return", undefined);
1450
1450
  case 5:
1451
1451
  stateId = authResponse.state, scope = authResponse.scope, expiresIn = authResponse.expiresIn, accessToken = authResponse.accessToken;
1452
- _context20.next = 8;
1453
- return stateId && ((_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.getState(stateId));
1454
- case 8:
1455
- _context20.t0 = _context20.sent;
1456
- if (_context20.t0) {
1457
- _context20.next = 11;
1452
+ newState = null;
1453
+ if (!stateId) {
1454
+ _context20.next = 12;
1458
1455
  break;
1459
1456
  }
1460
- _context20.t0 = this._makeStateFromResponse(authResponse);
1461
- case 11:
1462
- newState = _context20.t0;
1457
+ _context20.next = 10;
1458
+ return this._storage.getState(stateId);
1459
+ case 10:
1460
+ newState = _context20.sent;
1461
+ if (!newState) {
1462
+ newState = this._makeStateFromResponse(authResponse);
1463
+ }
1464
+ case 12:
1465
+ if (newState) {
1466
+ _context20.next = 14;
1467
+ break;
1468
+ }
1469
+ throw new Error("Could not create state where stateId=\"".concat(stateId, "\""));
1470
+ case 14:
1463
1471
  scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
1464
1472
  effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
1465
1473
  expires = TokenValidator._epoch() + effectiveExpiresIn;
1466
1474
  if (!(accessToken != null)) {
1467
- _context20.next = 18;
1475
+ _context20.next = 20;
1468
1476
  break;
1469
1477
  }
1470
- _context20.next = 18;
1471
- return (_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.saveToken({
1478
+ _context20.next = 20;
1479
+ return (_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.saveToken({
1472
1480
  accessToken,
1473
1481
  scopes,
1474
1482
  expires,
1475
1483
  lifeTime: effectiveExpiresIn
1476
1484
  });
1477
- case 18:
1485
+ case 20:
1478
1486
  return _context20.abrupt("return", newState);
1479
- case 19:
1487
+ case 21:
1480
1488
  case "end":
1481
1489
  return _context20.stop();
1482
1490
  }
@@ -1491,7 +1499,7 @@ var Auth = /*#__PURE__*/function () {
1491
1499
  key: "_checkForStateRestoration",
1492
1500
  value: function () {
1493
1501
  var _checkForStateRestoration2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1494
- var _this$_storage14;
1502
+ var _this$_storage13;
1495
1503
  var authResponse, stateId;
1496
1504
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1497
1505
  while (1) switch (_context21.prev = _context21.next) {
@@ -1502,7 +1510,7 @@ var Auth = /*#__PURE__*/function () {
1502
1510
  }
1503
1511
  stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
1504
1512
  _context21.next = 5;
1505
- return stateId && ((_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.getState(stateId));
1513
+ return stateId && ((_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.getState(stateId));
1506
1514
  case 5:
1507
1515
  _context21.t0 = _context21.sent;
1508
1516
  if (_context21.t0) {
@@ -2,7 +2,6 @@ import { _ as _defineProperty, a as _inherits, b as _createClass, c as _objectWi
2
2
  import { PureComponent } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
5
- import deprecate from 'util-deprecate';
6
5
  import joinDataTestAttributes from '../global/data-tests.js';
7
6
  import { m as modules_6c9187df } from '../_helpers/badge.js';
8
7
  import { jsx } from 'react/jsx-runtime';
@@ -12,11 +11,6 @@ import 'core-js/modules/es.object.entries.js';
12
11
  import 'core-js/modules/es.object.to-string.js';
13
12
 
14
13
  var _excluded = ["gray", "valid", "invalid", "disabled", "className", "children", "data-test"];
15
- var warn = deprecate(function () {}, 'Badge is deprecated and will be removed in RingUI 7.0. Use Tag instead.');
16
- /**
17
- * @name Badge
18
- */
19
- // TODO remove in 7.0
20
14
  var Badge = /*#__PURE__*/function (_PureComponent) {
21
15
  function Badge() {
22
16
  _classCallCheck(this, Badge);
@@ -26,7 +20,6 @@ var Badge = /*#__PURE__*/function (_PureComponent) {
26
20
  return _createClass(Badge, [{
27
21
  key: "render",
28
22
  value: function render() {
29
- warn();
30
23
  var _this$props = this.props,
31
24
  gray = _this$props.gray,
32
25
  valid = _this$props.valid,
@@ -12,7 +12,6 @@ import 'core-js/modules/es.object.entries.js';
12
12
  import 'core-js/modules/es.object.to-string.js';
13
13
  import '../link/clickableLink.js';
14
14
  import '../_helpers/link.js';
15
- import 'util-deprecate';
16
15
  import '../_helpers/badge.js';
17
16
 
18
17
  var items = [{
@@ -7,6 +7,7 @@ declare enum Theme {
7
7
  export declare const ThemeContext: import("react").Context<{
8
8
  theme: Theme.LIGHT | Theme.DARK;
9
9
  }>;
10
+ export declare const GLOBAL_DARK_CLASS_NAME = "ring-ui-theme-dark";
10
11
  export declare function useTheme(): Theme.LIGHT | Theme.DARK;
11
12
  export declare function useThemeClasses(theme: Theme): string;
12
13
  export interface WithThemeClassesProps {
@@ -4,7 +4,7 @@ import 'classnames';
4
4
  import 'react-dom';
5
5
  import '../popup/popup.target.js';
6
6
  import '../popup/popup.js';
7
- export { b as ThemeContext, a as ThemeProvider, W as WithThemeClasses, d as applyTheme, T as default, u as useTheme, c as useThemeClasses } from '../_helpers/theme.js';
7
+ export { G as GLOBAL_DARK_CLASS_NAME, b as ThemeContext, a as ThemeProvider, W as WithThemeClasses, d as applyTheme, T as default, u as useTheme, c as useThemeClasses } from '../_helpers/theme.js';
8
8
  import './get-uid.js';
9
9
  import 'react/jsx-runtime';
10
10
  import 'prop-types';
@@ -48,7 +48,7 @@ var Shortcuts = /*#__PURE__*/function () {
48
48
  });
49
49
  _defineProperty(this, "_defaultFilter", function (e, element, key) {
50
50
  // if the element or its parents have the class "ring-js-shortcuts" then no need to stop
51
- if (element === document || !(element instanceof HTMLElement) || key == null || element.matches(_this.ALLOW_SHORTCUTS_SELECTOR) || (element.dataset.enabledShortcuts != null ? element.dataset.enabledShortcuts.split(',').includes(key) : element.closest(_this.ALLOW_SHORTCUTS_SELECTOR) != null)) {
51
+ if (element === document || !(element instanceof HTMLElement) || key == null || element.matches(_this.ALLOW_SHORTCUTS_SELECTOR) || element.closest(_this.ALLOW_SHORTCUTS_SELECTOR) != null || element.dataset.enabledShortcuts != null && element.dataset.enabledShortcuts.split(',').includes(key)) {
52
52
  return false;
53
53
  }
54
54
  var elementContentEditableAttribute = element.contentEditable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui-built",
3
- "version": "6.0.52",
3
+ "version": "6.0.54-beta.0",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",