@jetbrains/ring-ui-built 7.0.0-beta.4 → 7.0.0-beta.5

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.
@@ -19,7 +19,7 @@ import 'core-js/modules/es.string.replace.js';
19
19
  import 'core-js/modules/es.string.trim.js';
20
20
  import '@jetbrains/icons/chevron-down';
21
21
  import '@jetbrains/icons/close-12px';
22
- import 'deep-equal';
22
+ import 'dequal';
23
23
  import '../dropdown/dropdown.js';
24
24
  import '../global/data-tests.js';
25
25
  import '../global/typescript-utils.js';
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import Storage from '../storage/storage';
2
3
  import { UserAgreementAttrs, UserAgreementTranslations } from './user-agreement';
3
4
  export declare const showMessage = "userAgreementShow";
4
5
  export declare const hideMessage = "userAgreementHide";
@@ -42,7 +43,7 @@ export default class UserAgreementService {
42
43
  interval: number;
43
44
  container: HTMLDivElement;
44
45
  reactRoot: import("react-dom/client").Root;
45
- storage: import("../storage/storage").StorageInterface;
46
+ storage: Storage;
46
47
  checkingPromise: Promise<[Agreement, Consent]> | null;
47
48
  guest: boolean | null | undefined;
48
49
  userAgreement: Agreement;
@@ -1,7 +1,7 @@
1
1
  import { _ as _defineProperty, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
2
2
  import 'core-js/modules/web.dom-collections.iterator.js';
3
3
  import { createRoot } from 'react-dom/client';
4
- import ActualStorage from '../storage/storage.js';
4
+ import LocalStorage from '../storage/storage__local.js';
5
5
  import alertService from '../alert-service/alert-service.js';
6
6
  import Link from '../link/link.js';
7
7
  import Alert from '../alert/alert.js';
@@ -9,9 +9,6 @@ import Group from '../group/group.js';
9
9
  import { ControlsHeightContext, getGlobalControlsHeight } from '../global/controls-height.js';
10
10
  import UserAgreement from './user-agreement.js';
11
11
  import { jsx, jsxs } from 'react/jsx-runtime';
12
- import '../storage/storage__local.js';
13
- import '../storage/storage__fallback.js';
14
- import 'deep-equal';
15
12
  import '../global/get-uid.js';
16
13
  import '../alert/container.js';
17
14
  import 'react';
@@ -91,7 +88,7 @@ class UserAgreementService {
91
88
  _defineProperty(this, "interval", ONE_HOUR);
92
89
  _defineProperty(this, "container", document.createElement('div'));
93
90
  _defineProperty(this, "reactRoot", createRoot(this.container));
94
- _defineProperty(this, "storage", new ActualStorage());
91
+ _defineProperty(this, "storage", new LocalStorage());
95
92
  _defineProperty(this, "checkingPromise", null);
96
93
  _defineProperty(this, "guest", false);
97
94
  _defineProperty(this, "userAgreement", DEFAULT_AGREEMENT);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui-built",
3
- "version": "7.0.0-beta.4",
3
+ "version": "7.0.0-beta.5",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -93,7 +93,6 @@
93
93
  "classnames": "^2.5.1",
94
94
  "combokeys": "^3.0.1",
95
95
  "date-fns": "^3.6.0",
96
- "deep-equal": "^2.2.3",
97
96
  "element-resize-detector": "^1.2.4",
98
97
  "es6-error": "^4.1.1",
99
98
  "fastdom": "^1.0.12",
@@ -1,79 +0,0 @@
1
- import { StorageInterface, StorageConfig } from './storage';
2
- /**
3
- * @prop {string} cookieName
4
- *
5
- * @param {{cookieName: string}} config
6
- * @param {{checkDelay: number}} config
7
- * @param {{type: string}} config
8
- * @return {FallbackStorage}
9
- * @constructor
10
- */
11
- export default class FallbackStorage implements StorageInterface {
12
- static DEFAULT_COOKIE_NAME: string;
13
- static DEFAULT_SESSION_COOKIE_NAME: string;
14
- static DEFAULT_CHECK_DELAY: number;
15
- static COOKIE_EXPIRES: number;
16
- /**
17
- * Maximum storage size
18
- * @see http://browsercookielimits.squawky.net/
19
- * @type {number}
20
- */
21
- static QUOTA: number;
22
- /**
23
- * @param {string} name
24
- * @param {string} value
25
- * @param {number} days
26
- * @private
27
- */
28
- private static _createCookie;
29
- /**
30
- *
31
- * @param {string} name
32
- * @return {string}
33
- * @private
34
- */
35
- private static _readCookie;
36
- cookieName: string;
37
- checkDelay: number;
38
- expires: number | null;
39
- constructor(config?: StorageConfig);
40
- /**
41
- * @return {Promise}
42
- * @private
43
- */
44
- private _read;
45
- /**
46
- * @param data
47
- * @return {Promise}
48
- * @private
49
- */
50
- private _write;
51
- /**
52
- * @param {string} key
53
- * @return {Promise}
54
- */
55
- get(key: string): Promise<any>;
56
- /**
57
- * @param {string} key
58
- * @param {object} value
59
- * @return {Promise}
60
- */
61
- set<T>(key: string, value: T | null): Promise<T | null>;
62
- /**
63
- * @param {string} key
64
- * @return {Promise}
65
- */
66
- remove(key: string): Promise<void>;
67
- /**
68
- *
69
- * @param {function(string, value)} callback
70
- * @return {Promise}
71
- */
72
- each<R>(callback: (item: string, value: unknown) => R | Promise<R>): Promise<Awaited<R>[]>;
73
- /**
74
- * @param {string} key
75
- * @param {Function} callback
76
- * @return {Function}
77
- */
78
- on<T>(key: string, callback: (value: T | null) => void): () => void;
79
- }
@@ -1,180 +0,0 @@
1
- import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/web.dom-collections.iterator.js';
3
- import deepEqual from 'deep-equal';
4
-
5
- const DEFAULT_CHECK_DELAY = 3000;
6
- const COOKIE_EXPIRES = 365;
7
- const QUOTA = 4093;
8
- // eslint-disable-next-line @typescript-eslint/no-magic-numbers
9
- const SECONDS_IN_DAY = 24 * 60 * 60 * 1000;
10
- /**
11
- * @prop {string} cookieName
12
- *
13
- * @param {{cookieName: string}} config
14
- * @param {{checkDelay: number}} config
15
- * @param {{type: string}} config
16
- * @return {FallbackStorage}
17
- * @constructor
18
- */
19
- class FallbackStorage {
20
- /**
21
- * @param {string} name
22
- * @param {string} value
23
- * @param {number} days
24
- * @private
25
- */
26
- static _createCookie(name, value, days) {
27
- let date;
28
- let expires;
29
- if (days) {
30
- date = new Date();
31
- date.setTime(date.getTime() + days * SECONDS_IN_DAY);
32
- expires = "; expires=".concat(date.toUTCString());
33
- } else {
34
- expires = ';';
35
- }
36
- document.cookie = "".concat(name, "=").concat(value).concat(expires, "; path=/");
37
- }
38
- /**
39
- *
40
- * @param {string} name
41
- * @return {string}
42
- * @private
43
- */
44
- static _readCookie(name) {
45
- const nameEQ = "".concat(name, "=");
46
- const cookies = document.cookie.split(';');
47
- let cookie;
48
- for (let i = 0; i < cookies.length; i++) {
49
- cookie = cookies[i];
50
- while (cookie.charAt(0) === ' ') {
51
- cookie = cookie.substring(1, cookie.length);
52
- }
53
- if (cookie.indexOf(nameEQ) === 0) {
54
- return cookie.substring(nameEQ.length, cookie.length);
55
- }
56
- }
57
- return undefined;
58
- }
59
- constructor() {
60
- let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
61
- _defineProperty(this, "cookieName", void 0);
62
- _defineProperty(this, "checkDelay", void 0);
63
- _defineProperty(this, "expires", void 0);
64
- const session = config.type === 'session';
65
- this.cookieName = config.cookieName || (session ? FallbackStorage.DEFAULT_SESSION_COOKIE_NAME : FallbackStorage.DEFAULT_COOKIE_NAME);
66
- this.checkDelay = config.checkDelay || FallbackStorage.DEFAULT_CHECK_DELAY;
67
- this.expires = session ? FallbackStorage.COOKIE_EXPIRES : null;
68
- }
69
- /**
70
- * @return {Promise}
71
- * @private
72
- */
73
- _read() {
74
- return new Promise((resolve, reject) => {
75
- const rawData = FallbackStorage._readCookie(this.cookieName);
76
- if (rawData != null) {
77
- resolve(JSON.parse(decodeURIComponent(rawData)));
78
- } else {
79
- reject();
80
- }
81
- }).catch(() => ({}));
82
- }
83
- /**
84
- * @param data
85
- * @return {Promise}
86
- * @private
87
- */
88
- _write(data) {
89
- return new Promise(resolve => {
90
- const stringData = encodeURIComponent(JSON.stringify(data));
91
- FallbackStorage._createCookie(this.cookieName, stringData === '{}' ? '' : stringData, this.expires);
92
- return resolve(data);
93
- });
94
- }
95
- /**
96
- * @param {string} key
97
- * @return {Promise}
98
- */
99
- get(key) {
100
- return this._read().then(data => data[key] || null);
101
- }
102
- /**
103
- * @param {string} key
104
- * @param {object} value
105
- * @return {Promise}
106
- */
107
- async set(key, value) {
108
- const data = await this._read();
109
- if (key) {
110
- if (value != null) {
111
- data[key] = value;
112
- } else {
113
- Reflect.deleteProperty(data, key);
114
- }
115
- }
116
- await this._write(data);
117
- return value;
118
- }
119
- /**
120
- * @param {string} key
121
- * @return {Promise}
122
- */
123
- async remove(key) {
124
- await this.set(key, null);
125
- }
126
- /**
127
- *
128
- * @param {function(string, value)} callback
129
- * @return {Promise}
130
- */
131
- each(callback) {
132
- if (typeof callback !== 'function') {
133
- return Promise.reject(new Error('Callback is not a function'));
134
- }
135
- return this._read().then(data => {
136
- const promises = [];
137
- for (const key in data) {
138
- if (data.hasOwnProperty(key)) {
139
- promises.push(callback(key, data[key]));
140
- }
141
- }
142
- return Promise.all(promises);
143
- });
144
- }
145
- /**
146
- * @param {string} key
147
- * @param {Function} callback
148
- * @return {Function}
149
- */
150
- on(key, callback) {
151
- let stop = false;
152
- const checkForChange = oldValue => {
153
- this.get(key).then(newValue => {
154
- if (stop) {
155
- return;
156
- }
157
- if (!deepEqual(oldValue, newValue)) {
158
- callback(newValue);
159
- }
160
- window.setTimeout(() => checkForChange(oldValue), this.checkDelay);
161
- });
162
- };
163
- this.get(key).then(checkForChange);
164
- return () => {
165
- stop = true;
166
- };
167
- }
168
- }
169
- _defineProperty(FallbackStorage, "DEFAULT_COOKIE_NAME", 'localStorage');
170
- _defineProperty(FallbackStorage, "DEFAULT_SESSION_COOKIE_NAME", 'sessionStorage');
171
- _defineProperty(FallbackStorage, "DEFAULT_CHECK_DELAY", DEFAULT_CHECK_DELAY);
172
- _defineProperty(FallbackStorage, "COOKIE_EXPIRES", COOKIE_EXPIRES);
173
- /**
174
- * Maximum storage size
175
- * @see http://browsercookielimits.squawky.net/
176
- * @type {number}
177
- */
178
- _defineProperty(FallbackStorage, "QUOTA", QUOTA);
179
-
180
- export { FallbackStorage as default };