@quiltt/core 3.6.9 → 3.6.11

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
@@ -1,5 +1,17 @@
1
1
  # @quiltt/core
2
2
 
3
+ ## 3.6.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#271](https://github.com/quiltt/quiltt-js/pull/271) [`a9ea2a7`](https://github.com/quiltt/quiltt-js/commit/a9ea2a7c6592dd5245183996ce0d26ffb53f2ed9) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Add 'rol' to private claims
8
+
9
+ ## 3.6.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [#268](https://github.com/quiltt/quiltt-js/pull/268) [`8a82094`](https://github.com/quiltt/quiltt-js/commit/8a82094a709d0d7e1478ec32142be33825323708) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Migrate linter to Biome
14
+
3
15
  ## 3.6.9
4
16
 
5
17
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { ApolloLink, Observable as Observable$1 } from '@apollo/client/core/index.js';
3
3
  import { print } from 'graphql';
4
- import { c as createConsumer } from './index-client-Bp2EphG9.js';
4
+ import { c as createConsumer } from './index-client-1u-DL-7m.js';
5
5
 
6
6
  /**
7
7
  * An error and type safe wrapper for localStorage.
@@ -13,8 +13,8 @@ import { c as createConsumer } from './index-client-Bp2EphG9.js';
13
13
  this.observers = {};
14
14
  this.isEnabled = ()=>{
15
15
  try {
16
- localStorage.setItem(`quiltt.ping`, 'pong');
17
- localStorage.removeItem(`quiltt.ping`);
16
+ localStorage.setItem('quiltt.ping', 'pong');
17
+ localStorage.removeItem('quiltt.ping');
18
18
  return true;
19
19
  } catch (error) {
20
20
  return false;
@@ -61,7 +61,7 @@ import { c as createConsumer } from './index-client-Bp2EphG9.js';
61
61
  // if there is a key, then trigger the related updates. If there is not key
62
62
  // it means that a record has been removed and everything needs to be rechecked.
63
63
  this.handleStorageEvent = (event)=>{
64
- if (event.key && event.key.includes('quiltt.')) {
64
+ if (event.key?.includes('quiltt.')) {
65
65
  const newState = event.newValue ? JSON.parse(event.newValue) : null;
66
66
  if (this.observers[event.key]) {
67
67
  this.observers[event.key].forEach((update)=>update(newState));
@@ -105,7 +105,7 @@ import { c as createConsumer } from './index-client-Bp2EphG9.js';
105
105
 
106
106
  /**
107
107
  * This is designed to support effectively an in memory key value store singleton,
108
- * similar to localstorage, but allows you to subscribe to changes within the current
108
+ * similar to localStorage, but allows you to subscribe to changes within the current
109
109
  * window.
110
110
  */ class MemoryStorage {
111
111
  constructor(){
@@ -113,9 +113,8 @@ import { c as createConsumer } from './index-client-Bp2EphG9.js';
113
113
  this.get = (key)=>{
114
114
  if (this.observables[key]) {
115
115
  return this.observables[key].get();
116
- } else {
117
- return undefined;
118
116
  }
117
+ return undefined;
119
118
  };
120
119
  this.set = (key, state)=>{
121
120
  if (!this.observables[key]) {
@@ -204,7 +203,7 @@ import { c as createConsumer } from './index-client-Bp2EphG9.js';
204
203
  */ const GlobalStorage = new Storage();
205
204
 
206
205
  var name = "@quiltt/core";
207
- var version$1 = "3.6.9";
206
+ var version$1 = "3.6.11";
208
207
 
209
208
  const QUILTT_API_INSECURE = (()=>{
210
209
  try {
@@ -253,7 +252,7 @@ class ActionCableLink extends ApolloLink {
253
252
  request(operation, _next) {
254
253
  const token = GlobalStorage.get('session');
255
254
  if (!token) {
256
- console.warn(`QuilttClient attempted to send an unauthenticated Subscription`);
255
+ console.warn('QuilttClient attempted to send an unauthenticated Subscription');
257
256
  return null;
258
257
  }
259
258
  if (!this.cables[token]) {
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { d as debugging } from './SubscriptionLink-client-CO7h3iAK.js';
2
+ import { d as debugging } from './SubscriptionLink-client-Be2B_Wkn.js';
3
3
 
4
4
  var adapters = {
5
5
  logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,
@@ -33,6 +33,7 @@ class ConnectionMonitor {
33
33
  start() {
34
34
  if (!this.isRunning()) {
35
35
  this.startedAt = now();
36
+ // biome-ignore lint/performance/noDelete: <explanation>
36
37
  delete this.stoppedAt;
37
38
  this.startPolling();
38
39
  addEventListener('visibilitychange', this.visibilityDidChange);
@@ -56,6 +57,7 @@ class ConnectionMonitor {
56
57
  recordConnect() {
57
58
  this.reconnectAttempts = 0;
58
59
  this.recordPing();
60
+ // biome-ignore lint/performance/noDelete: <explanation>
59
61
  delete this.disconnectedAt;
60
62
  logger.log('ConnectionMonitor recorded connect');
61
63
  }
@@ -79,7 +81,7 @@ class ConnectionMonitor {
79
81
  }
80
82
  getPollInterval() {
81
83
  const { staleThreshold, reconnectionBackoffRate } = this.constructor;
82
- const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10));
84
+ const backoff = (1 + reconnectionBackoffRate) ** Math.min(this.reconnectAttempts, 10);
83
85
  const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate;
84
86
  const jitter = jitterMax * Math.random();
85
87
  return staleThreshold * 1000 * backoff * (1 + jitter);
@@ -158,28 +160,26 @@ class Connection {
158
160
  if (this.isOpen()) {
159
161
  this.webSocket.send(JSON.stringify(data));
160
162
  return true;
161
- } else {
162
- return false;
163
163
  }
164
+ return false;
164
165
  }
165
166
  open() {
166
167
  if (this.isActive()) {
167
168
  logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`);
168
169
  return false;
169
- } else {
170
- const socketProtocols = [
171
- ...protocols,
172
- ...this.consumer.subprotocols || []
173
- ];
174
- logger.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`);
175
- if (this.webSocket) {
176
- this.uninstallEventHandlers();
177
- }
178
- this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols);
179
- this.installEventHandlers();
180
- this.monitor.start();
181
- return true;
182
170
  }
171
+ const socketProtocols = [
172
+ ...protocols,
173
+ ...this.consumer.subprotocols || []
174
+ ];
175
+ logger.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`);
176
+ if (this.webSocket) {
177
+ this.uninstallEventHandlers();
178
+ }
179
+ this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols);
180
+ this.installEventHandlers();
181
+ this.monitor.start();
182
+ return true;
183
183
  }
184
184
  close({ allowReconnect } = {
185
185
  allowReconnect: true
@@ -246,7 +246,7 @@ class Connection {
246
246
  }
247
247
  uninstallEventHandlers() {
248
248
  for(const eventName in this.events){
249
- this.webSocket[`on${eventName}`] = function() {};
249
+ this.webSocket[`on${eventName}`] = ()=>{};
250
250
  }
251
251
  }
252
252
  }
@@ -278,11 +278,10 @@ Connection.prototype.events = {
278
278
  return this.subscriptions.notify(identifier, 'connected', {
279
279
  reconnected: true
280
280
  });
281
- } else {
282
- return this.subscriptions.notify(identifier, 'connected', {
283
- reconnected: false
284
- });
285
281
  }
282
+ return this.subscriptions.notify(identifier, 'connected', {
283
+ reconnected: false
284
+ });
286
285
  case message_types.rejection:
287
286
  return this.subscriptions.reject(identifier);
288
287
  default:
@@ -315,7 +314,7 @@ Connection.prototype.events = {
315
314
  }
316
315
  };
317
316
 
318
- const extend = function(object, properties) {
317
+ const extend = (object, properties)=>{
319
318
  if (properties !== null) {
320
319
  for(const key in properties){
321
320
  const value = properties[key];
@@ -325,6 +324,7 @@ const extend = function(object, properties) {
325
324
  return object;
326
325
  };
327
326
  class Subscription {
327
+ // biome-ignore lint/style/useDefaultParameterLast: <explanation>
328
328
  constructor(consumer, params = {}, mixin){
329
329
  this.consumer = consumer;
330
330
  this.identifier = JSON.stringify(params);
@@ -539,13 +539,12 @@ function createWebSocketURL(url) {
539
539
  if (url && !/^wss?:/i.test(url)) {
540
540
  const a = document.createElement('a');
541
541
  a.href = url;
542
- // eslint-disable-next-line no-self-assign
542
+ // biome-ignore lint/correctness/noSelfAssign: <explanation>
543
543
  a.href = a.href;
544
544
  a.protocol = a.protocol.replace('http', 'ws');
545
545
  return a.href;
546
- } else {
547
- return url;
548
546
  }
547
+ return url;
549
548
  }
550
549
 
551
550
  function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {
package/dist/index.d.ts CHANGED
@@ -339,7 +339,7 @@ declare class LocalStorage<T> {
339
339
 
340
340
  /**
341
341
  * This is designed to support effectively an in memory key value store singleton,
342
- * similar to localstorage, but allows you to subscribe to changes within the current
342
+ * similar to localStorage, but allows you to subscribe to changes within the current
343
343
  * window.
344
344
  */
345
345
  declare class MemoryStorage<T> {
@@ -402,11 +402,7 @@ declare const endpointAuth: string;
402
402
  declare const endpointGraphQL: string;
403
403
  declare const endpointWebsockets: string;
404
404
 
405
- type JsonWebToken<T> = {
406
- token: string;
407
- claims: Claims<T>;
408
- };
409
- type Claims<T> = RegisteredClaims & T;
405
+ type AdminRole = 'manager' | 'core' | 'basic';
410
406
  type RegisteredClaims = {
411
407
  iss: string;
412
408
  sub: string;
@@ -422,6 +418,12 @@ type PrivateClaims = {
422
418
  cid: string;
423
419
  aid: string;
424
420
  ver: number;
421
+ rol: AdminRole;
422
+ };
423
+ type Claims<T> = RegisteredClaims & T;
424
+ type JsonWebToken<T> = {
425
+ token: string;
426
+ claims: Claims<T>;
425
427
  };
426
428
  type QuilttJWT = JsonWebToken<PrivateClaims>;
427
429
  declare const JsonWebTokenParse: <T>(token: Maybe<string> | undefined) => Maybe<JsonWebToken<T>> | undefined;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ApolloLink, ApolloClient } from '@apollo/client/index.js';
2
2
  export { InMemoryCache, gql, useMutation, useQuery, useSubscription } from '@apollo/client/index.js';
3
- import { G as GlobalStorage, e as endpointGraphQL, v as version, d as debugging, S as SubscriptionLink, a as endpointAuth } from './SubscriptionLink-client-CO7h3iAK.js';
4
- export { L as LocalStorage, M as MemoryStorage, O as Observable, b as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-client-CO7h3iAK.js';
3
+ import { G as GlobalStorage, e as endpointGraphQL, v as version, d as debugging, S as SubscriptionLink, a as endpointAuth } from './SubscriptionLink-client-Be2B_Wkn.js';
4
+ export { L as LocalStorage, M as MemoryStorage, O as Observable, b as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-client-Be2B_Wkn.js';
5
5
  import { BatchHttpLink as BatchHttpLink$1 } from '@apollo/client/link/batch-http/index.js';
6
6
  import crossfetch from 'cross-fetch';
7
7
  import { onError } from '@apollo/client/link/error/index.js';
@@ -25,7 +25,7 @@ var ConnectorSDKEventType;
25
25
  request(operation, forward) {
26
26
  const token = GlobalStorage.get('session');
27
27
  if (!token) {
28
- console.warn(`QuilttLink attempted to send an unauthenticated Query`);
28
+ console.warn('QuilttLink attempted to send an unauthenticated Query');
29
29
  return null;
30
30
  }
31
31
  operation.setContext(({ headers = {} })=>({
@@ -142,7 +142,7 @@ const RETRIES = 10 // 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500 = 8.2
142
142
  if (retry && (response.status >= 500 || response.status === 429)) {
143
143
  throw new Error('Retryable failure');
144
144
  }
145
- throw new Error('HTTP error with status ' + response.status);
145
+ throw new Error(`HTTP error with status ${response.status}`);
146
146
  } catch (error) {
147
147
  if (retry) {
148
148
  const currentRetriesRemaining = retriesRemaining !== undefined ? retriesRemaining : RETRIES;
@@ -254,7 +254,7 @@ const JsonWebTokenParse = (token)=>{
254
254
  const [_header, payload, _signature] = token.split('.');
255
255
  try {
256
256
  return {
257
- token: token,
257
+ token,
258
258
  claims: JSON.parse(atob(payload))
259
259
  };
260
260
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/core",
3
- "version": "3.6.9",
3
+ "version": "3.6.11",
4
4
  "description": "Javascript API client and utilities for Quiltt",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -35,22 +35,16 @@
35
35
  "dependencies": {
36
36
  "@apollo/client": "^3.9.9",
37
37
  "cross-fetch": "^4.0.0",
38
- "graphql": "^16.8.1",
39
- "graphql-ruby-client": "^1.13.3"
38
+ "graphql": "^16.9.0",
39
+ "graphql-ruby-client": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@trivago/prettier-plugin-sort-imports": "4.1.1",
43
- "@types/node": "20.12.7",
44
- "@types/react": "18.2.73",
45
- "@typescript-eslint/eslint-plugin": "5.60.1",
46
- "@typescript-eslint/parser": "5.60.1",
47
- "bunchee": "4.4.8",
48
- "eslint": "8.43.0",
49
- "eslint-config-prettier": "8.8.0",
50
- "eslint-plugin-prettier": "4.2.1",
51
- "prettier": "2.8.8",
52
- "rimraf": "5.0.5",
53
- "typescript": "5.4.3"
42
+ "@biomejs/biome": "1.8.3",
43
+ "@types/node": "20.14.10",
44
+ "@types/react": "18.3.3",
45
+ "bunchee": "5.2.2",
46
+ "rimraf": "6.0.0",
47
+ "typescript": "5.5.3"
54
48
  },
55
49
  "publishConfig": {
56
50
  "access": "public"
@@ -59,7 +53,7 @@
59
53
  "build": "bunchee",
60
54
  "clean": "rimraf .turbo dist",
61
55
  "dev": "bunchee --watch",
62
- "lint": "TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix",
56
+ "lint": "TIMING=1 biome check src/ --fix",
63
57
  "typecheck": "tsc --project tsconfig.json --noEmit"
64
58
  }
65
59
  }
@@ -1,11 +1,6 @@
1
1
  import type { Maybe } from './types'
2
2
 
3
- export type JsonWebToken<T> = {
4
- token: string // Raw JWT Token
5
- claims: Claims<T>
6
- }
7
-
8
- export type Claims<T> = RegisteredClaims & T
3
+ type AdminRole = 'manager' | 'core' | 'basic'
9
4
 
10
5
  export type RegisteredClaims = {
11
6
  iss: string // (issuer): Issuer of the JWT
@@ -23,6 +18,14 @@ export type PrivateClaims = {
23
18
  cid: string // Client ID
24
19
  aid: string // Administrator ID
25
20
  ver: number // Session Token Version
21
+ rol: AdminRole // Administrator Role
22
+ }
23
+
24
+ export type Claims<T> = RegisteredClaims & T
25
+
26
+ export type JsonWebToken<T> = {
27
+ token: string // Raw JWT Token
28
+ claims: Claims<T>
26
29
  }
27
30
 
28
31
  export type QuilttJWT = JsonWebToken<PrivateClaims>
@@ -42,7 +45,7 @@ export const JsonWebTokenParse = <T>(
42
45
  const [_header, payload, _signature] = token.split('.')
43
46
 
44
47
  try {
45
- return { token: token, claims: JSON.parse(atob(payload)) }
48
+ return { token, claims: JSON.parse(atob(payload)) }
46
49
  } catch (error) {
47
50
  console.error(`Invalid Session Token: ${error}`)
48
51
  }
@@ -37,7 +37,7 @@ class ActionCableLink extends ApolloLink {
37
37
  const token = GlobalStorage.get('session')
38
38
 
39
39
  if (!token) {
40
- console.warn(`QuilttClient attempted to send an unauthenticated Subscription`)
40
+ console.warn('QuilttClient attempted to send an unauthenticated Subscription')
41
41
  return null
42
42
  }
43
43
 
@@ -14,7 +14,7 @@ export class AuthLink extends ApolloLink {
14
14
  const token = GlobalStorage.get('session')
15
15
 
16
16
  if (!token) {
17
- console.warn(`QuilttLink attempted to send an unauthenticated Query`)
17
+ console.warn('QuilttLink attempted to send an unauthenticated Query')
18
18
  return null
19
19
  }
20
20
 
@@ -24,28 +24,26 @@ class Connection {
24
24
  if (this.isOpen()) {
25
25
  this.webSocket.send(JSON.stringify(data))
26
26
  return true
27
- } else {
28
- return false
29
27
  }
28
+ return false
30
29
  }
31
30
 
32
31
  open() {
33
32
  if (this.isActive()) {
34
33
  logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)
35
34
  return false
36
- } else {
37
- const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]
38
- logger.log(
39
- `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`
40
- )
41
- if (this.webSocket) {
42
- this.uninstallEventHandlers()
43
- }
44
- this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)
45
- this.installEventHandlers()
46
- this.monitor.start()
47
- return true
48
35
  }
36
+ const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]
37
+ logger.log(
38
+ `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`
39
+ )
40
+ if (this.webSocket) {
41
+ this.uninstallEventHandlers()
42
+ }
43
+ this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)
44
+ this.installEventHandlers()
45
+ this.monitor.start()
46
+ return true
49
47
  }
50
48
 
51
49
  close({ allowReconnect } = { allowReconnect: true }) {
@@ -122,7 +120,7 @@ class Connection {
122
120
 
123
121
  uninstallEventHandlers() {
124
122
  for (const eventName in this.events) {
125
- this.webSocket[`on${eventName}`] = function () {}
123
+ this.webSocket[`on${eventName}`] = () => {}
126
124
  }
127
125
  }
128
126
  }
@@ -152,9 +150,8 @@ Connection.prototype.events = {
152
150
  if (this.reconnectAttempted) {
153
151
  this.reconnectAttempted = false
154
152
  return this.subscriptions.notify(identifier, 'connected', { reconnected: true })
155
- } else {
156
- return this.subscriptions.notify(identifier, 'connected', { reconnected: false })
157
153
  }
154
+ return this.subscriptions.notify(identifier, 'connected', { reconnected: false })
158
155
  case message_types.rejection:
159
156
  return this.subscriptions.reject(identifier)
160
157
  default:
@@ -18,6 +18,7 @@ class ConnectionMonitor {
18
18
  start() {
19
19
  if (!this.isRunning()) {
20
20
  this.startedAt = now()
21
+ // biome-ignore lint/performance/noDelete: <explanation>
21
22
  delete this.stoppedAt
22
23
  this.startPolling()
23
24
  addEventListener('visibilitychange', this.visibilityDidChange)
@@ -47,6 +48,7 @@ class ConnectionMonitor {
47
48
  recordConnect() {
48
49
  this.reconnectAttempts = 0
49
50
  this.recordPing()
51
+ // biome-ignore lint/performance/noDelete: <explanation>
50
52
  delete this.disconnectedAt
51
53
  logger.log('ConnectionMonitor recorded connect')
52
54
  }
@@ -76,7 +78,7 @@ class ConnectionMonitor {
76
78
 
77
79
  getPollInterval() {
78
80
  const { staleThreshold, reconnectionBackoffRate } = this.constructor
79
- const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))
81
+ const backoff = (1 + reconnectionBackoffRate) ** Math.min(this.reconnectAttempts, 10)
80
82
  const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate
81
83
  const jitter = jitterMax * Math.random()
82
84
  return staleThreshold * 1000 * backoff * (1 + jitter)
@@ -75,13 +75,12 @@ export function createWebSocketURL(url: string | (() => string)): string {
75
75
  if (url && !/^wss?:/i.test(url)) {
76
76
  const a = document.createElement('a')
77
77
  a.href = url
78
- // eslint-disable-next-line no-self-assign
78
+ // biome-ignore lint/correctness/noSelfAssign: <explanation>
79
79
  a.href = a.href
80
80
  a.protocol = a.protocol.replace('http', 'ws')
81
81
  return a.href
82
- } else {
83
- return url
84
82
  }
83
+ return url
85
84
  }
86
85
 
87
86
  export default Consumer
@@ -2,7 +2,7 @@ import type { Consumer } from './consumer'
2
2
 
3
3
  export type Data = { [id: string]: string | object | null | undefined }
4
4
 
5
- const extend = function (object: Data, properties: Data) {
5
+ const extend = (object: Data, properties: Data) => {
6
6
  if (properties !== null) {
7
7
  for (const key in properties) {
8
8
  const value = properties[key]
@@ -16,6 +16,7 @@ export class Subscription {
16
16
  consumer: Consumer
17
17
  identifier: string
18
18
 
19
+ // biome-ignore lint/style/useDefaultParameterLast: <explanation>
19
20
  constructor(consumer: Consumer, params: Data = {}, mixin: Data) {
20
21
  this.consumer = consumer
21
22
  this.identifier = JSON.stringify(params)
@@ -79,7 +79,7 @@ export class Subscriptions {
79
79
  }
80
80
 
81
81
  notify(subscription: Subscription, callbackName: string, ...args: any[]) {
82
- let subscriptions
82
+ let subscriptions: Array<Subscription>
83
83
  if (typeof subscription === 'string') {
84
84
  subscriptions = this.findAll(subscription)
85
85
  } else {
@@ -55,7 +55,7 @@ export const fetchWithRetry = async <T>(
55
55
  throw new Error('Retryable failure')
56
56
  }
57
57
 
58
- throw new Error('HTTP error with status ' + response.status)
58
+ throw new Error(`HTTP error with status ${response.status}`)
59
59
  } catch (error) {
60
60
  if (retry) {
61
61
  const currentRetriesRemaining = retriesRemaining !== undefined ? retriesRemaining : RETRIES
@@ -1,5 +1,5 @@
1
- import type { Maybe } from '../types'
2
1
  import type { Observer } from '../Observable'
2
+ import type { Maybe } from '../types'
3
3
 
4
4
  /**
5
5
  * An error and type safe wrapper for localStorage.
@@ -18,8 +18,8 @@ export class LocalStorage<T> {
18
18
 
19
19
  isEnabled = (): boolean => {
20
20
  try {
21
- localStorage.setItem(`quiltt.ping`, 'pong')
22
- localStorage.removeItem(`quiltt.ping`)
21
+ localStorage.setItem('quiltt.ping', 'pong')
22
+ localStorage.removeItem('quiltt.ping')
23
23
  return true
24
24
  } catch (error) {
25
25
  return false
@@ -78,7 +78,7 @@ export class LocalStorage<T> {
78
78
  // if there is a key, then trigger the related updates. If there is not key
79
79
  // it means that a record has been removed and everything needs to be rechecked.
80
80
  private handleStorageEvent = (event: StorageEvent) => {
81
- if (event.key && event.key.includes('quiltt.')) {
81
+ if (event.key?.includes('quiltt.')) {
82
82
  const newState = event.newValue ? JSON.parse(event.newValue) : null
83
83
 
84
84
  if (this.observers[event.key]) {
@@ -5,7 +5,7 @@ import type { Observer } from '../Observable'
5
5
 
6
6
  /**
7
7
  * This is designed to support effectively an in memory key value store singleton,
8
- * similar to localstorage, but allows you to subscribe to changes within the current
8
+ * similar to localStorage, but allows you to subscribe to changes within the current
9
9
  * window.
10
10
  */
11
11
  export class MemoryStorage<T> {
@@ -14,9 +14,8 @@ export class MemoryStorage<T> {
14
14
  get = (key: string) => {
15
15
  if (this.observables[key]) {
16
16
  return this.observables[key].get()
17
- } else {
18
- return undefined
19
17
  }
18
+ return undefined
20
19
  }
21
20
 
22
21
  set = (key: string, state: Maybe<T> | undefined): void => {