@plq/use-persisted-state 1.4.1 → 1.4.2

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 (63) hide show
  1. package/lib/create-async-persisted-state.d.ts.map +1 -1
  2. package/lib/create-async-persisted-state.js +10 -50
  3. package/lib/create-async-persisted-state.js.map +1 -1
  4. package/lib/create-persisted-state.d.ts.map +1 -1
  5. package/lib/create-persisted-state.js +4 -16
  6. package/lib/create-persisted-state.js.map +1 -1
  7. package/lib/index.d.ts.map +1 -1
  8. package/lib/storages/chrome-storage.d.ts.map +1 -1
  9. package/lib/storages/chrome-storage.js +6 -15
  10. package/lib/storages/chrome-storage.js.map +1 -1
  11. package/lib/storages/local-storage.d.ts.map +1 -1
  12. package/lib/storages/local-storage.js +1 -2
  13. package/lib/storages/local-storage.js.map +1 -1
  14. package/lib/storages/session-storage.d.ts.map +1 -1
  15. package/lib/storages/session-storage.js +1 -2
  16. package/lib/storages/session-storage.js.map +1 -1
  17. package/lib/utils/change-notifier.d.ts +1 -8
  18. package/lib/utils/change-notifier.d.ts.map +1 -1
  19. package/lib/utils/change-notifier.js +1 -10
  20. package/lib/utils/change-notifier.js.map +1 -1
  21. package/lib/utils/create-web-storage.d.ts +1 -8
  22. package/lib/utils/create-web-storage.d.ts.map +1 -1
  23. package/lib/utils/create-web-storage.js +5 -17
  24. package/lib/utils/create-web-storage.js.map +1 -1
  25. package/lib/utils/extension-storage.d.ts +2 -12
  26. package/lib/utils/extension-storage.d.ts.map +1 -1
  27. package/lib/utils/extension-storage.js +3 -14
  28. package/lib/utils/extension-storage.js.map +1 -1
  29. package/lib/utils/get-new-item.d.ts +1 -12
  30. package/lib/utils/get-new-item.d.ts.map +1 -1
  31. package/lib/utils/get-new-item.js +2 -16
  32. package/lib/utils/get-new-item.js.map +1 -1
  33. package/lib/utils/get-persisted-value.d.ts +1 -7
  34. package/lib/utils/get-persisted-value.d.ts.map +1 -1
  35. package/lib/utils/get-persisted-value.js +3 -13
  36. package/lib/utils/get-persisted-value.js.map +1 -1
  37. package/lib/utils/is-async-storage.d.ts +1 -7
  38. package/lib/utils/is-async-storage.d.ts.map +1 -1
  39. package/lib/utils/is-async-storage.js +6 -25
  40. package/lib/utils/is-async-storage.js.map +1 -1
  41. package/lib/utils/storage-event-router.d.ts +1 -5
  42. package/lib/utils/storage-event-router.d.ts.map +1 -1
  43. package/lib/utils/storage-event-router.js +3 -14
  44. package/lib/utils/storage-event-router.js.map +1 -1
  45. package/lib/utils/use-storage-handler.d.ts +1 -10
  46. package/lib/utils/use-storage-handler.d.ts.map +1 -1
  47. package/lib/utils/use-storage-handler.js +10 -57
  48. package/lib/utils/use-storage-handler.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/create-async-persisted-state.ts +10 -50
  51. package/src/create-persisted-state.ts +4 -16
  52. package/src/index.ts +1 -4
  53. package/src/storages/chrome-storage.ts +6 -18
  54. package/src/storages/local-storage.ts +1 -2
  55. package/src/storages/session-storage.ts +1 -2
  56. package/src/utils/change-notifier.ts +1 -10
  57. package/src/utils/create-web-storage.ts +5 -17
  58. package/src/utils/extension-storage.ts +3 -14
  59. package/src/utils/get-new-item.ts +2 -16
  60. package/src/utils/get-persisted-value.ts +3 -13
  61. package/src/utils/is-async-storage.ts +6 -26
  62. package/src/utils/storage-event-router.ts +3 -14
  63. package/src/utils/use-storage-handler.ts +11 -68
@@ -1 +1 @@
1
- {"version":3,"file":"create-async-persisted-state.d.ts","sourceRoot":"","sources":["../src/create-async-persisted-state.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAA;AAEtE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,YAAY,EACtE,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,GACT,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CA+IvC"}
1
+ {"version":3,"file":"create-async-persisted-state.d.ts","sourceRoot":"","sources":["../src/create-async-persisted-state.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAA;AAEtE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,YAAY,EACtE,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,GACT,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAuGvC"}
@@ -44,19 +44,10 @@ const get_new_item_1 = __importDefault(require("./utils/get-new-item"));
44
44
  const get_persisted_value_1 = __importDefault(require("./utils/get-persisted-value"));
45
45
  function createAsyncPersistedState(storageKey, storage) {
46
46
  const safeStorageKey = `persisted_state_hook:${storageKey}`;
47
- // Every hook this factory makes lives in one entry, and storing a value means
48
- // reading that entry, merging one key into it and writing all of it back, with
49
- // a suspension point on either side of the merge. Left to overlap, a second
50
- // writer merges into a snapshot taken before the first one landed and stores
51
- // it: the first writer's key is gone from storage while its value is still on
52
- // screen, and nothing reports the disagreement. It is the entry, not the hook,
53
- // that has to be taken one at a time, so the chain belongs to the factory.
47
+ // Storing is read-merge-write on one shared entry, so overlapping writers would drop each other's keys.
54
48
  let entryWrites = Promise.resolve();
55
49
  const clear = () => {
56
- // Removing the entry changes it as much as storing does, so it takes its turn
57
- // in the same chain. Outside it, a write already queued lands after the
58
- // removal and brings back what was cleared - and "clear this data" is the one
59
- // request that cannot be allowed to half happen.
50
+ // In the same chain as writes, or a queued write lands after the removal and restores what was cleared.
60
51
  const removal = entryWrites.then(() => storage.remove(safeStorageKey));
61
52
  entryWrites = removal.catch(() => undefined);
62
53
  return removal;
@@ -69,65 +60,39 @@ function createAsyncPersistedState(storageKey, storage) {
69
60
  newItem = (0, get_new_item_1.default)(key, persistedItem[safeStorageKey], newValue);
70
61
  }
71
62
  catch {
72
- // Refused, and reported where it was refused. A write replaces the whole
73
- // entry, so an entry that cannot be read is one no write can be built on
74
- // without dropping every other hook's key; skipping leaves the bytes for
75
- // a repair to reach. The caller keeps what it set, unpersisted.
63
+ // A write replaces the whole entry, so an unreadable one is skipped rather than rebuilt without other keys.
76
64
  return;
77
65
  }
78
- // Recorded before the write, because the backend may report it before the
79
- // promise settles.
80
66
  (0, use_storage_handler_1.recordOwnWrite)(pendingOwnWrites, newItem);
81
67
  await storage.set({ [safeStorageKey]: newItem });
82
68
  });
83
- // The chain has to outlive a failed write, or one backend rejection stops
84
- // every later write on this entry. The rejection itself is not swallowed: it
85
- // stays on the promise handed back to the caller that asked for the write.
69
+ // The chain must outlive a failed write; the rejection still reaches the caller through `write`.
86
70
  entryWrites = write.catch(() => undefined);
87
71
  return write;
88
72
  };
89
73
  const usePersistedState = (key, initialValue) => {
90
74
  const [state, setState] = (0, react_1.useState)(initialValue);
91
- // The setter must resolve updater functions against the last value applied,
92
- // not against the one captured by the render that created it. Reading the
93
- // render closure collapses updates batched into a single event.
75
+ // Updater functions must resolve against the last applied value, not the render closure's.
94
76
  const latestValue = (0, react_1.useRef)(state);
95
- // Whether anything has already put a value in place. A load that settles after
96
- // the caller set one must not revert it, and no signal local to the load can
97
- // answer this: the write it loses to happens outside the load entirely.
77
+ // A load that settles after the caller set a value must not revert it.
98
78
  const hasAppliedValue = (0, react_1.useRef)(false);
99
79
  const applyValue = (0, react_1.useCallback)((value) => {
100
80
  latestValue.current = value;
101
81
  hasAppliedValue.current = true;
102
82
  setState(value);
103
83
  }, []);
104
- // The entries this hook has written and not yet seen reported back.
105
84
  const pendingOwnWrites = (0, react_1.useRef)([]);
106
85
  const setPersistedState = (0, react_1.useCallback)(async (newState) => {
107
86
  const newValue = (0, get_new_value_1.default)(newState, latestValue.current);
108
- // Applied before the write is even queued: the caller sees its value at
109
- // once, and only the trip to storage waits its turn.
110
87
  applyValue(newValue);
111
88
  await commitEntry(key, newValue, pendingOwnWrites);
112
89
  }, [key, applyValue]);
113
- // As in `useState`, the value the load falls back to is the one given on the
114
- // first render. Later identities of an inline object must not reload, or the
115
- // effect re-runs on every render and never settles.
90
+ // The first render's initial value: reloading on a later identity would re-run the effect forever.
116
91
  const mountInitialValue = (0, react_1.useRef)(initialValue);
117
- // Subscribed before the load below, and the order is load-bearing: React runs
118
- // effects in declaration order, so reading first would leave an interval
119
- // between the read and the subscription in which a write belongs to neither
120
- // and is lost. Reading last covers everything written before the subscription
121
- // began, and the listener covers everything after.
92
+ // Subscribed before the load: effects run in declaration order, and reading first would lose writes in between.
122
93
  (0, use_storage_handler_1.default)(key, safeStorageKey, applyValue, storage, initialValue, pendingOwnWrites);
123
94
  (0, react_1.useEffect)(() => {
124
- // Two separate questions, and one cell cannot hold both: whether this load
125
- // is still the current one, which only the closure it belongs to can answer,
126
- // and whether a value has been applied meanwhile, which outlives it. A load
127
- // abandoned by a key change would otherwise read the flag its successor had
128
- // just set, apply the previous key's value and shut the successor out. The
129
- // second question is also what makes subscribing first safe: a value the
130
- // listener delivers while the load is in flight is not overwritten by it.
95
+ // Separate from `hasAppliedValue`: only this closure knows whether its own load is still current.
131
96
  let isCancelled = false;
132
97
  hasAppliedValue.current = false;
133
98
  const loadPersistedValue = async () => {
@@ -138,12 +103,7 @@ function createAsyncPersistedState(storageKey, storage) {
138
103
  applyValue((0, get_persisted_value_1.default)(key, mountInitialValue.current, persist[safeStorageKey]));
139
104
  }
140
105
  catch (err) {
141
- // An extension backend rejects on a quota error or an invalidated
142
- // extension context. Nothing awaits this load, so an unclaimed
143
- // rejection terminates the process on Node 15+ and surfaces as an
144
- // uncaught error in the browser. The initial value is already in
145
- // state, so the mount stands on it and the failure is reported rather
146
- // than swallowed, as the synchronous path reports its own.
106
+ // Nothing awaits this load, so an unclaimed rejection would surface as an uncaught error.
147
107
  console.error("use-persisted-state: Can't read value from storage", err);
148
108
  }
149
109
  };
@@ -1 +1 @@
1
- {"version":3,"file":"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IACnC,CAAC,CAAA;IAED,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;AACnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-persisted-state.d.ts","sourceRoot":"","sources":["../src/create-persisted-state.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAA;AAOtE,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC,CA0E/G"}
1
+ {"version":3,"file":"create-persisted-state.d.ts","sourceRoot":"","sources":["../src/create-persisted-state.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAA;AAOtE,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC,CA8D/G"}
@@ -49,29 +49,20 @@ function createPersistedState(storageKey, storage) {
49
49
  };
50
50
  const readPersisted = (key, initialValue) => (0, get_persisted_value_1.default)(key, initialValue, storage.get(safeStorageKey)[safeStorageKey]);
51
51
  const usePersistedState = (key, initialValue) => {
52
- // Reading through the initializer keeps the storage out of the render path:
53
- // the hook runs on every render of every consuming component, so a re-read is
54
- // only warranted when the key it is asked for actually changes.
52
+ // Read through the initializer: the hook runs on every render, so storage stays out of the render path.
55
53
  const [state, setState] = (0, react_1.useState)(() => readPersisted(key, initialValue));
56
- // The setter must resolve updater functions against the last value applied,
57
- // not against the one captured by the render that created it. Reading the
58
- // render closure collapses updates batched into a single event.
54
+ // Updater functions must resolve against the last applied value, not the render closure's.
59
55
  const latestValue = (0, react_1.useRef)(state);
60
56
  const applyValue = (0, react_1.useCallback)((value) => {
61
57
  latestValue.current = value;
62
58
  setState(value);
63
59
  }, []);
64
- // A mounted hook handed a different key has to show that key's value before
65
- // anything can be written, or the next update stores the previous key's value
66
- // under the new key and destroys what was there. Adjusting during render ties
67
- // the re-read to the change itself, where an effect would cost a read and a
68
- // second render on every mount as well.
60
+ // A new key must be read before anything is written, or the next update stores the old key's value under it.
69
61
  const renderedKey = (0, react_1.useRef)(key);
70
62
  if (renderedKey.current !== key) {
71
63
  renderedKey.current = key;
72
64
  applyValue(readPersisted(key, initialValue));
73
65
  }
74
- // The entries this hook has written and not yet seen reported back.
75
66
  const pendingOwnWrites = (0, react_1.useRef)([]);
76
67
  const setPersistedState = (0, react_1.useCallback)((newState) => {
77
68
  const newValue = (0, get_new_value_1.default)(newState, latestValue.current);
@@ -82,10 +73,7 @@ function createPersistedState(storageKey, storage) {
82
73
  newItem = (0, get_new_item_1.default)(key, persistedItem, newValue);
83
74
  }
84
75
  catch {
85
- // Refused, and reported where it was refused. A write replaces the whole
86
- // entry, so an entry that cannot be read is one no write can be built on
87
- // without dropping every other hook's key; skipping leaves the bytes for
88
- // a repair to reach. The caller keeps what it set, unpersisted.
76
+ // A write replaces the whole entry, so an unreadable one is skipped rather than rebuilt without other keys.
89
77
  return;
90
78
  }
91
79
  (0, use_storage_handler_1.recordOwnWrite)(pendingOwnWrites, newItem);
@@ -1 +1 @@
1
- {"version":3,"file":"create-persisted-state.js","sourceRoot":"","sources":["../src/create-persisted-state.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,uCA0EC;AApFD,iCAAqD;AAKrD,mFAA+E;AAC/E,0EAA+C;AAC/C,wEAA6C;AAC7C,sFAA2D;AAE3D,SAAwB,oBAAoB,CAAC,UAAkB,EAAE,OAAgB;IAC/E,MAAM,cAAc,GAAG,wBAAwB,UAAU,EAAE,CAAA;IAC3D,MAAM,KAAK,GAAG,GAAS,E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AC1E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAMrF,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACvH,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,CAAC,SAAS,OAAO,GAAG,YAAY,EAC3E,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GACT,CAAC,cAAc,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAM9C;AAED,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAGrF,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACvH,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"chrome-storage.d.ts","sourceRoot":"","sources":["../../src/storages/chrome-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA+BrD,QAAA,MAAM,KAAK,cAA+C,CAAA;AAC1D,QAAA,MAAM,IAAI,cAA6C,CAAA;AACvD,QAAA,MAAM,OAAO,cAAmD,CAAA;AAEhE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"chrome-storage.d.ts","sourceRoot":"","sources":["../../src/storages/chrome-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAmBrD,QAAA,MAAM,KAAK,cAA+C,CAAA;AAC1D,QAAA,MAAM,IAAI,cAA6C,CAAA;AACvD,QAAA,MAAM,OAAO,cAAmD,CAAA;AAEhE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA"}
@@ -6,22 +6,13 @@ const registry = (0, extension_storage_1.createListenerRegistry)();
6
6
  chrome.storage.onChanged.addListener((changes, area) => {
7
7
  registry.fire((0, extension_storage_1.toStorageChanges)(changes), area);
8
8
  });
9
- // chrome.storage is callback-based, unlike its promise-based firefox counterpart.
9
+ // Passing no callback selects the promise form; the callback form leaves failures in `runtime.lastError`.
10
+ // Called through `storage`: a torn-off `StorageArea` method throws `Illegal invocation`, unlike firefox's.
11
+ // `get` stays `async` so asking whether this storage is asynchronous costs no round trip to the extension.
10
12
  const createStorage = (storage, area) => ({
11
- // Declared async, like the firefox adapter, so that asking whether this
12
- // storage is asynchronous can be answered from the function itself instead of
13
- // by calling it — a call here costs a round trip to the extension process.
14
- get: async (keys) => new Promise(resolve => {
15
- storage.get(keys, items => {
16
- resolve((0, extension_storage_1.toStoredItems)(items));
17
- });
18
- }),
19
- set: items => new Promise(resolve => {
20
- storage.set(items, resolve);
21
- }),
22
- remove: keys => new Promise(resolve => {
23
- storage.remove(keys, resolve);
24
- }),
13
+ get: async (keys) => (0, extension_storage_1.toStoredItems)(await storage.get(keys)),
14
+ set: items => storage.set(items),
15
+ remove: keys => storage.remove(keys),
25
16
  onChanged: registry.createOnChanged(area),
26
17
  });
27
18
  const local = createStorage(chrome.storage.local, 'local');
@@ -1 +1 @@
1
- {"version":3,"file":"chrome-storage.js","sourceRoot":"","sources":["../../src/storages/chrome-storage.ts"],"names":[],"mappings":";;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O,EAAE,SAAS,CAAC,CAAA;AAE1C,0BAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/storages/local-storage.ts"],"names":[],"mappings":";AAIA,wBAA4F"}
1
+ {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/storages/local-storage.ts"],"names":[],"mappings":";AAGA,wBAA4F"}
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const create_web_storage_1 = __importDefault(require("../utils/create-web-storage"));
7
- // The typeof guard keeps this import from throwing on server runtimes (SSR),
8
- // where the browser storage globals are not defined.
7
+ // The typeof guard keeps this import from throwing on server runtimes, where the global is not defined.
9
8
  exports.default = (0, create_web_storage_1.default)(typeof localStorage !== 'undefined' ? localStorage : undefined);
10
9
  //# sourceMappingURL=local-storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../src/storages/local-storage.ts"],"names":[],"mappings":";;;;;AAAA,qFAAuD;AAEvD,6EAA6E;AAC7E,qDAAqD;AACrD,kBAAe,IAAA,4BAAa,EAAC,OAAO,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA"}
1
+ {"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../src/storages/local-storage.ts"],"names":[],"mappings":";;;;;AAAA,qFAAuD;AAEvD,wGAAwG;AACxG,kBAAe,IAAA,4BAAa,EAAC,OAAO,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../src/storages/session-storage.ts"],"names":[],"mappings":";AAIA,wBAAgG"}
1
+ {"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../src/storages/session-storage.ts"],"names":[],"mappings":";AAGA,wBAAgG"}
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const create_web_storage_1 = __importDefault(require("../utils/create-web-storage"));
7
- // The typeof guard keeps this import from throwing on server runtimes (SSR),
8
- // where the browser storage globals are not defined.
7
+ // The typeof guard keeps this import from throwing on server runtimes, where the global is not defined.
9
8
  exports.default = (0, create_web_storage_1.default)(typeof sessionStorage !== 'undefined' ? sessionStorage : undefined);
10
9
  //# sourceMappingURL=session-storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../src/storages/session-storage.ts"],"names":[],"mappings":";;;;;AAAA,qFAAuD;AAEvD,6EAA6E;AAC7E,qDAAqD;AACrD,kBAAe,IAAA,4BAAa,EAAC,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA"}
1
+ {"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../src/storages/session-storage.ts"],"names":[],"mappings":";;;;;AAAA,qFAAuD;AAEvD,wGAAwG;AACxG,kBAAe,IAAA,4BAAa,EAAC,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA"}
@@ -6,13 +6,6 @@ export interface ChangeNotifier {
6
6
  hasListeners(): boolean;
7
7
  onChanged: StorageChangeEvent;
8
8
  }
9
- /**
10
- * Holds the subscribers of a single change source. Each adapter — and, for the
11
- * extension backends, each storage area — owns one, so a change never reaches
12
- * listeners that subscribed elsewhere.
13
- *
14
- * Routing a backend's events to the right notifier stays with the adapter: the
15
- * extensions demultiplex one event by area name, the DOM one by storage object.
16
- */
9
+ /** Holds the subscribers of a single change source, so a change never reaches listeners that subscribed elsewhere. */
17
10
  export declare function createChangeNotifier(): ChangeNotifier;
18
11
  //# sourceMappingURL=change-notifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-notifier.d.ts","sourceRoot":"","sources":["../../src/utils/change-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAyB,MAAM,mBAAmB,CAAA;AAEjG,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,GAAG,IAAI,CAAA;IACrD,YAAY,IAAI,OAAO,CAAA;IACvB,SAAS,EAAE,kBAAkB,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CA0BrD"}
1
+ {"version":3,"file":"change-notifier.d.ts","sourceRoot":"","sources":["../../src/utils/change-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAyB,MAAM,mBAAmB,CAAA;AAEjG,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,GAAG,IAAI,CAAA;IACrD,YAAY,IAAI,OAAO,CAAA;IACvB,SAAS,EAAE,kBAAkB,CAAA;CAC9B;AAED,sHAAsH;AACtH,wBAAgB,oBAAoB,IAAI,cAAc,CAwBrD"}
@@ -1,14 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createChangeNotifier = createChangeNotifier;
4
- /**
5
- * Holds the subscribers of a single change source. Each adapter — and, for the
6
- * extension backends, each storage area — owns one, so a change never reaches
7
- * listeners that subscribed elsewhere.
8
- *
9
- * Routing a backend's events to the right notifier stays with the adapter: the
10
- * extensions demultiplex one event by area name, the DOM one by storage object.
11
- */
4
+ /** Holds the subscribers of a single change source, so a change never reaches listeners that subscribed elsewhere. */
12
5
  function createChangeNotifier() {
13
6
  const listeners = new Set();
14
7
  return {
@@ -17,8 +10,6 @@ function createChangeNotifier() {
17
10
  listener(changes);
18
11
  }
19
12
  },
20
- // Lets an adapter release a shared resource once nobody is listening; the
21
- // set behind onChanged stays the only count, so the two cannot drift.
22
13
  hasListeners() {
23
14
  return listeners.size > 0;
24
15
  },
@@ -1 +1 @@
1
- {"version":3,"file":"change-notifier.js","sourceRoot":"","sources":["../../src/utils/change-notifier.ts"],"names":[],"mappings":";;AAgBA,oDA0BC;AAlCD;;;;;;;GAOG;AACH,SAAgB,oBAAoB;IAClC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAA;IAElD,OAAO;QACL,IAAI,CAAC,OAAO;YACV,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,QAAQ,CAAC,OAAO,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;QACD,0EAA0E;QAC1E,sEAAsE;QACtE,YAAY;YACV,OAAO,SAAS,CAAC,IAAI,GAAG,CAAC,CAAA;QAC3B,CAAC;QACD,SAAS,EAAE;YACT,WAAW,CAAC,QAAQ;gBAClB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACzB,CAAC;YACD,cAAc,CAAC,QAAQ;gBACrB,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC;YACD,WAAW,CAAC,QAAQ;gBAClB,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAChC,CAAC;SACF;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"change-notifier.js","sourceRoot":"","sources":["../../src/utils/change-notifier.ts"],"names":[],"mappings":";;AASA,oDAwBC;AAzBD,sHAAsH;AACtH,SAAgB,oBAAoB;IAClC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAA;IAElD,OAAO;QACL,IAAI,CAAC,OAAO;YACV,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,QAAQ,CAAC,OAAO,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;QACD,YAAY;YACV,OAAO,SAAS,CAAC,IAAI,GAAG,CAAC,CAAA;QAC3B,CAAC;QACD,SAAS,EAAE;YACT,WAAW,CAAC,QAAQ;gBAClB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACzB,CAAC;YACD,cAAc,CAAC,QAAQ;gBACrB,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC;YACD,WAAW,CAAC,QAAQ;gBAClB,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAChC,CAAC;SACF;KACF,CAAA;AACH,CAAC"}
@@ -1,12 +1,5 @@
1
1
  import type { Storage } from '../@types/storage';
2
- /**
3
- * Adapts a Web Storage area to the library's `Storage` contract.
4
- *
5
- * Pass `undefined` where the global is missing, as it is on a server: the
6
- * adapter then reads back nothing and **silently discards every write**, so a
7
- * consumer keeps its initial value instead of the import throwing. Listeners
8
- * are still accepted and reported, they simply never fire.
9
- */
2
+ /** Adapts a Web Storage area. With `undefined`, as on a server, it reads back nothing and discards every write. */
10
3
  declare const _default: (storage: globalThis.Storage | undefined) => Storage;
11
4
  export default _default;
12
5
  //# sourceMappingURL=create-web-storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-web-storage.d.ts","sourceRoot":"","sources":["../../src/utils/create-web-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAqC,MAAM,mBAAmB,CAAA;AAQnF;;;;;;;GAOG;yBACa,SAAS,UAAU,CAAC,OAAO,GAAG,SAAS,KAAG,OAAO;AAAjE,wBAqFC"}
1
+ {"version":3,"file":"create-web-storage.d.ts","sourceRoot":"","sources":["../../src/utils/create-web-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAqC,MAAM,mBAAmB,CAAA;AAQnF,mHAAmH;yBACnG,SAAS,UAAU,CAAC,OAAO,GAAG,SAAS,KAAG,OAAO;AAAjE,wBAgFC"}
@@ -5,20 +5,11 @@ const storage_event_router_1 = require("./storage-event-router");
5
5
  function toKeyList(keys) {
6
6
  return Array.isArray(keys) ? keys : [keys];
7
7
  }
8
- /**
9
- * Adapts a Web Storage area to the library's `Storage` contract.
10
- *
11
- * Pass `undefined` where the global is missing, as it is on a server: the
12
- * adapter then reads back nothing and **silently discards every write**, so a
13
- * consumer keeps its initial value instead of the import throwing. Listeners
14
- * are still accepted and reported, they simply never fire.
15
- */
8
+ /** Adapts a Web Storage area. With `undefined`, as on a server, it reads back nothing and discards every write. */
16
9
  exports.default = (storage) => {
17
- // Per-instance notifier: the localStorage and sessionStorage adapters must not
18
- // share listeners, or a write to one area notifies subscribers of the other.
10
+ // Per instance: the localStorage and sessionStorage adapters must not share listeners.
19
11
  const notifier = (0, change_notifier_1.createChangeNotifier)();
20
- // Only a missing global is inert. Anything else a caller passes has to fail
21
- // on first use instead of swallowing their writes.
12
+ // Only a missing global is inert; anything else a caller passes has to fail on first use.
22
13
  if (storage === undefined) {
23
14
  return {
24
15
  get: () => ({}),
@@ -28,9 +19,7 @@ exports.default = (storage) => {
28
19
  };
29
20
  }
30
21
  const route = { storage, fire: notifier.fire };
31
- // The DOM subscription is shared and reference counted: an adapter joins it
32
- // with its first listener and lets go with its last, so factory calls nobody
33
- // listens to leave nothing attached to the global object.
22
+ // The DOM subscription is shared and reference counted, so adapters nobody listens to attach nothing.
34
23
  const onChanged = {
35
24
  addListener(listener) {
36
25
  notifier.onChanged.addListener(listener);
@@ -50,8 +39,7 @@ exports.default = (storage) => {
50
39
  const result = {};
51
40
  for (const key of toKeyList(keys)) {
52
41
  const item = storage.getItem(key);
53
- // `null` is the only answer that means absence: an empty string is a
54
- // value the caller stored, and reporting it as a missing key loses it.
42
+ // `null` is the only answer meaning absence; an empty string is a value the caller stored.
55
43
  if (item !== null)
56
44
  result[key] = item;
57
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-web-storage.js","sourceRoot":"","sources":["../../src/utils/create-web-storage.ts"],"names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,EAAE,CAAC;gBAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;gBAErC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;gBAEvB,OAAO,CAAC,GAAG,CAAC,GAAG;oBACb,QAAQ;oBACR,QAAQ,EAAE,IAAI;iBACf,CAAA;YACH,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC;gBAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC7D,CAAC;QACD,SAAS;KACV,CAAA;AACH,CAAC,CAAA"}
@@ -1,12 +1,7 @@
1
1
  import type { StorageChange, StorageChangeEvent } from '../@types/storage';
2
2
  declare const TRACKED_AREAS: readonly ["local", "sync", "managed"];
3
3
  export type Area = (typeof TRACKED_AREAS)[number];
4
- /**
5
- * Extension storage holds arbitrary JSON, while this library only ever writes
6
- * serialized strings. Anything else under a key belongs to other code and is
7
- * reported as absent — which is what effectively happened before, once such a
8
- * value reached `JSON.parse` and the hook fell back to its initial value.
9
- */
4
+ /** Extension storage holds arbitrary JSON; this library writes only strings, so anything else reads as absent. */
10
5
  export declare function toStoredValue(value: unknown): string | null | undefined;
11
6
  export declare function toStorageChanges(changes: {
12
7
  [key: string]: {
@@ -27,12 +22,7 @@ export interface ListenerRegistry {
27
22
  }, area: string): void;
28
23
  createOnChanged(area: Area): StorageChangeEvent;
29
24
  }
30
- /**
31
- * Demultiplexes an extension's single `onChanged` event, which names the area
32
- * that changed, to one notifier per area. Each adapter owns its own registry,
33
- * so a change in one browser's storage never reaches listeners registered on
34
- * another's.
35
- */
25
+ /** Demultiplexes an extension's single `onChanged` event to one notifier per area, one registry per adapter. */
36
26
  export declare function createListenerRegistry(): ListenerRegistry;
37
27
  export {};
38
28
  //# sourceMappingURL=extension-storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension-storage.d.ts","sourceRoot":"","sources":["../../src/utils/extension-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAG1E,QAAA,MAAM,aAAa,uCAAwC,CAAA;AAE3D,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAQjD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAIvE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAAG;IACxG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAC7B,CAWA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAQ1F;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnE,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAA;CAChD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAiBzD"}
1
+ {"version":3,"file":"extension-storage.d.ts","sourceRoot":"","sources":["../../src/utils/extension-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAG1E,QAAA,MAAM,aAAa,uCAAwC,CAAA;AAE3D,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAOjD,kHAAkH;AAClH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAIvE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAAG;IACxG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAC7B,CAWA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAQ1F;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnE,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAA;CAChD;AAED,gHAAgH;AAChH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAiBzD"}
@@ -6,17 +6,11 @@ exports.toStoredItems = toStoredItems;
6
6
  exports.createListenerRegistry = createListenerRegistry;
7
7
  const change_notifier_1 = require("./change-notifier");
8
8
  const TRACKED_AREAS = ['local', 'sync', 'managed'];
9
- // Both browsers also report `session` changes, an area this library does not
10
- // expose. Dispatching one would read an undefined notifier and throw.
9
+ // Both browsers also report `session`, an area this library does not expose; dispatching one would throw.
11
10
  function isTrackedArea(area) {
12
11
  return TRACKED_AREAS.includes(area);
13
12
  }
14
- /**
15
- * Extension storage holds arbitrary JSON, while this library only ever writes
16
- * serialized strings. Anything else under a key belongs to other code and is
17
- * reported as absent — which is what effectively happened before, once such a
18
- * value reached `JSON.parse` and the hook fell back to its initial value.
19
- */
13
+ /** Extension storage holds arbitrary JSON; this library writes only strings, so anything else reads as absent. */
20
14
  function toStoredValue(value) {
21
15
  if (value === undefined)
22
16
  return;
@@ -40,12 +34,7 @@ function toStoredItems(items) {
40
34
  }
41
35
  return result;
42
36
  }
43
- /**
44
- * Demultiplexes an extension's single `onChanged` event, which names the area
45
- * that changed, to one notifier per area. Each adapter owns its own registry,
46
- * so a change in one browser's storage never reaches listeners registered on
47
- * another's.
48
- */
37
+ /** Demultiplexes an extension's single `onChanged` event to one notifier per area, one registry per adapter. */
49
38
  function createListenerRegistry() {
50
39
  const notifiers = {
51
40
  local: (0, change_notifier_1.createChangeNotifier)(),
@@ -1 +1 @@
1
- {"version":3,"file":"extension-storage.js","sourceRoot":"","sources":["../../src/utils/extension-storage.ts"],"names":[],"mappings":";;AAmBA,sCAIC;AAED,4CAaC;AAED,sCAQC;AAaD,wDAiBC;AA7ED,uDAA6E;AAE7E,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAU,CAAA;AAI3D,6EAA6E;AAC7E,sEAAsE;AACtE,SAAS,aAAa,CAAC,IAAY;IACjC,OAAQ,aAAmC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC5D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAM;IAE/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACjD,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAsE;IAGrG,MAAM,MAAM,GAAqC,EAAE,CAAA;IAEnD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,GAAG;YACZ,QAAQ,EAAE,aAAa,CAAC,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C,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/B,CAAC;QACD,eAAe,CAAC,IAAI;YAClB,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,14 +1,3 @@
1
- /**
2
- * Merges `newValue` under `key` into the serialized entry a factory shares between all of its
3
- * hooks, and returns the entry to store.
4
- *
5
- * Reports and throws when the entry cannot be merged into, rather than answering with one built
6
- * from nothing. What this returns is written over the whole entry, so an unreadable entry is the
7
- * one case with nothing safe to return: every other hook's key would be replaced with nothing,
8
- * and the bytes a repair still needs would go with them.
9
- *
10
- * @throws {SyntaxError} when the entry is not valid JSON.
11
- * @throws {TypeError} when the entry is valid JSON but not an object of keys.
12
- */
1
+ /** Merges `newValue` under `key` into the shared entry, throwing rather than rebuilding one it cannot read. */
13
2
  export default function getNewItem<T>(key: string, persistedItem: string, newValue: T): string;
14
3
  //# sourceMappingURL=get-new-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-new-item.d.ts","sourceRoot":"","sources":["../../src/utils/get-new-item.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAwB7F"}
1
+ {"version":3,"file":"get-new-item.d.ts","sourceRoot":"","sources":["../../src/utils/get-new-item.ts"],"names":[],"mappings":"AAEA,+GAA+G;AAC/G,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAqB7F"}
@@ -2,18 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = getNewItem;
4
4
  const is_1 = require("@plq/is");
5
- /**
6
- * Merges `newValue` under `key` into the serialized entry a factory shares between all of its
7
- * hooks, and returns the entry to store.
8
- *
9
- * Reports and throws when the entry cannot be merged into, rather than answering with one built
10
- * from nothing. What this returns is written over the whole entry, so an unreadable entry is the
11
- * one case with nothing safe to return: every other hook's key would be replaced with nothing,
12
- * and the bytes a repair still needs would go with them.
13
- *
14
- * @throws {SyntaxError} when the entry is not valid JSON.
15
- * @throws {TypeError} when the entry is valid JSON but not an object of keys.
16
- */
5
+ /** Merges `newValue` under `key` into the shared entry, throwing rather than rebuilding one it cannot read. */
17
6
  function getNewItem(key, persistedItem, newValue) {
18
7
  let persist;
19
8
  try {
@@ -24,10 +13,7 @@ function getNewItem(key, persistedItem, newValue) {
24
13
  throw err;
25
14
  }
26
15
  if (!(0, is_1.isObject)(persist)) {
27
- // A shared backend can leave any JSON under the key, and neither a primitive nor an array
28
- // survives being merged into: `JSON.stringify` unwraps the first back to itself and keeps the
29
- // second an array, so the value being set disappears with the property added to it. A stored
30
- // `null` did not even get that far - it threw out of `Object.assign` and into the caller.
16
+ // Neither a primitive nor an array survives being merged into: the value being set would disappear.
31
17
  const err = new TypeError('the stored entry is not an object of keys');
32
18
  console.error("use-persisted-state: Can't write value to storage", err);
33
19
  throw err;
@@ -1 +1 @@
1
- {"version":3,"file":"get-new-item.js","sourceRoot":"","sources":["../../src/utils/get-new-item.ts"],"names":[],"mappings":";;AAcA,6BAwBC;AAtCD,gCAAkC;AAElC;;;;;;;;;;;GAWG;AACH,SAAwB,UAAU,CAAI,GAAW,EAAE,aAAqB,EAAE,QAAW;IACnF,IAAI,OAAgB,CAAA;IAEpB,IAAI,CAAC;QACH,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,mDAAmD,EAAE,GAAG,CAAC,CAAA;QAEvE,MAAM,G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E,CAAC,CAAA;AACxD,CAAC"}
@@ -1,9 +1,3 @@
1
- /**
2
- * Resolves the value a hook starts from: the persisted entry for `key` when the stored payload
3
- * carries one, the initial value otherwise.
4
- *
5
- * Presence is decided by the key rather than by the value, so a persisted `null` comes back as
6
- * the value the user set instead of being mistaken for an absence and replaced.
7
- */
1
+ /** Resolves a hook's starting value by key presence, so a persisted `null` is not mistaken for an absence. */
8
2
  export default function getPersistedValue<T>(key: string, initialValue: T | (() => T), persist?: string): T;
9
3
  //# sourceMappingURL=get-persisted-value.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-persisted-value.d.ts","sourceRoot":"","sources":["../../src/utils/get-persisted-value.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAwB1G"}
1
+ {"version":3,"file":"get-persisted-value.d.ts","sourceRoot":"","sources":["../../src/utils/get-persisted-value.ts"],"names":[],"mappings":"AAEA,8GAA8G;AAC9G,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAoB1G"}