@inglorious/web 6.27.0 → 6.27.1

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/README.md CHANGED
@@ -1741,7 +1741,7 @@ const types = {
1741
1741
  }
1742
1742
  ```
1743
1743
 
1744
- Preferences answers with promises, so in the native app the entity starts with its defaults and gets the stored fields back a moment later, through `storageRestore`. In a browser it is `localStorage` itself.
1744
+ Preferences answers with promises, so in the native app the entity starts with its defaults and gets the stored fields back a moment later, through `storageRestore`. In a browser it uses `localStorage`.
1745
1745
 
1746
1746
  It works as Supabase's session storage too, so signing in survives the same clean-ups:
1747
1747
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "6.27.0",
3
+ "version": "6.27.1",
4
4
  "description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
5
5
  "author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "contributors": [
@@ -162,7 +162,7 @@
162
162
  "lit-html": "^3.3.3"
163
163
  },
164
164
  "peerDependencies": {
165
- "@inglorious/store": "^12.6.0"
165
+ "@inglorious/store": "^12.6.1"
166
166
  },
167
167
  "devDependencies": {
168
168
  "@inglorious/eslint-config": "1.2.0",
@@ -20,7 +20,7 @@ export function isNative() {
20
20
  * A storage for `withStorage` that survives the operating system clearing the
21
21
  * WebView's data: in a native app, Capacitor Preferences (`Preferences` from
22
22
  * `@capacitor/preferences`, given as `plugin`), answering with promises; in a
23
- * browser, `localStorage` itself. It also serves as Supabase's `auth.storage`,
23
+ * browser, `localStorage`, looked up at each call. It also serves as Supabase's `auth.storage`,
24
24
  * keeping the session there too.
25
25
  *
26
26
  * @param {{ plugin?: { get(options: { key: string }): Promise<{ value: string | null }>, set(options: { key: string, value: string }): Promise<void>, remove(options: { key: string }): Promise<void> } }} [config]
@@ -33,7 +33,13 @@ export function isNative() {
33
33
  * }
34
34
  */
35
35
  export function createNativeStorage({ plugin } = {}) {
36
- if (!plugin || !isNative()) return globalThis.localStorage
36
+ if (!plugin || !isNative()) {
37
+ return {
38
+ getItem: (key) => globalThis.localStorage?.getItem(key) ?? null,
39
+ setItem: (key, value) => globalThis.localStorage?.setItem(key, value),
40
+ removeItem: (key) => globalThis.localStorage?.removeItem(key),
41
+ }
42
+ }
37
43
 
38
44
  return {
39
45
  getItem: async (key) => (await plugin.get({ key })).value,
package/types/mobile.d.ts CHANGED
@@ -14,7 +14,7 @@ export interface NativeStorage {
14
14
  removeItem(key: string): void | Promise<void>
15
15
  }
16
16
 
17
- /** Capacitor Preferences in a native app, `localStorage` itself in a browser. */
17
+ /** Capacitor Preferences in a native app, `localStorage` in a browser. */
18
18
  export declare function createNativeStorage(config?: {
19
19
  plugin?: PreferencesPlugin
20
- }): NativeStorage | Storage | undefined
20
+ }): NativeStorage