resonare 0.2.0 → 0.3.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.
- package/README.md +329 -270
- package/dist/index.d.ts +219 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lite-react.d.ts +27 -22
- package/dist/lite-react.d.ts.map +1 -1
- package/dist/lite-react.js +1 -1
- package/dist/lite-react.js.map +1 -1
- package/dist/lite-solid.d.ts +42 -0
- package/dist/lite-solid.d.ts.map +1 -0
- package/dist/lite-solid.js +2 -0
- package/dist/lite-solid.js.map +1 -0
- package/dist/lite-svelte.d.ts +41 -0
- package/dist/lite-svelte.d.ts.map +1 -0
- package/dist/lite-svelte.js +2 -0
- package/dist/lite-svelte.js.map +1 -0
- package/dist/lite-vue.d.ts +49 -0
- package/dist/lite-vue.d.ts.map +1 -0
- package/dist/lite-vue.js +2 -0
- package/dist/lite-vue.js.map +1 -0
- package/dist/lite.d.ts +103 -22
- package/dist/lite.d.ts.map +1 -1
- package/dist/lite.js +1 -1
- package/dist/lite.js.map +1 -1
- package/dist/react.d.ts +47 -38
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/solid.d.ts +84 -0
- package/dist/solid.d.ts.map +1 -0
- package/dist/solid.js +2 -0
- package/dist/solid.js.map +1 -0
- package/dist/storage-BqWA8jeP.js +2 -0
- package/dist/storage-BqWA8jeP.js.map +1 -0
- package/dist/storage-CsXjZKyt.d.ts +65 -0
- package/dist/storage-CsXjZKyt.d.ts.map +1 -0
- package/dist/svelte.d.ts +86 -0
- package/dist/svelte.d.ts.map +1 -0
- package/dist/svelte.js +2 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.d.ts +82 -0
- package/dist/vue.d.ts.map +1 -0
- package/dist/vue.js +2 -0
- package/dist/vue.js.map +1 -0
- package/package.json +67 -32
- package/dist/storage-B5xjLRee.js +0 -2
- package/dist/storage-B5xjLRee.js.map +0 -1
- package/dist/storage-DGYV332J.d.ts +0 -23
- package/dist/storage-DGYV332J.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-BqWA8jeP.js","names":["DEFAULT_KEY","DEFAULT_LITE_KEY","toScriptJson","value","toScriptFunction","source","handler","localStorageAdapter","type","key","listener","e","cb","abortController","memoryStorageAdapter","storage","channel"],"sources":["../src/constants.ts","../src/script.ts","../src/storage.ts"],"sourcesContent":["export const DEFAULT_KEY = 'resonare'\nexport const DEFAULT_LITE_KEY = 'resonare/lite'\n","/**\n * `JSON.stringify` for embedding in an inline `<script>`: `<` is escaped so a\n * value containing `</script>` cannot close the tag.\n */\nexport const toScriptJson = (value: unknown): string => {\n return JSON.stringify(value).replace(/</g, '\\\\u003c')\n}\n\n/**\n * Source of `handler` as a JavaScript expression. Object-method shorthand\n * (`handler() {}`) stringifies to something that is not an expression on its\n * own, so it is wrapped back into an object literal.\n */\nexport const toScriptFunction = (handler: Function): string => {\n const source = String(handler)\n\n return /^(async\\s*)?(function\\b|\\(|[\\w$]+\\s*=>)/.test(source)\n ? source\n : `Object.values({${source}})[0]`\n}\n","import { DEFAULT_KEY } from './constants'\n\n/**\n * Where a store saves its state. Values are strings: the full store saves\n * JSON, the lite store saves the theme name.\n */\nexport type StorageAdapter = {\n /** Returns the saved value, or `null` when nothing is saved. */\n get: () => string | null\n /** Saves a value. */\n set: (value: string) => void\n /** Optional: tells other tabs about a value just saved with `set`. */\n broadcast?: (value: string) => void\n /**\n * Optional: calls `cb` when another tab saves a value (`null` when it clears\n * it). Returns a function that stops watching. Used by `store.sync()`.\n */\n watch?: (cb: (value: string | null) => void) => () => void\n}\n\n/**\n * What a store's `storage` option takes: a function that creates the adapter.\n * `abortController` is aborted when the store is destroyed; use it to remove\n * listeners.\n */\nexport type StorageAdapterCreate = ({\n abortController,\n}: {\n abortController: AbortController\n}) => StorageAdapter\n\n/**\n * Shape of the built-in adapters such as `localStorageAdapter`: takes options\n * (like the key) and returns a {@link StorageAdapterCreate}.\n */\nexport type StorageAdapterCreator<Options> = (\n options: Options\n) => StorageAdapterCreate\n\n/**\n * Saves the store in `localStorage` (default) or `sessionStorage` under `key`,\n * and supports `store.sync()` across tabs. If storage is blocked or full,\n * reads return nothing and writes are skipped.\n *\n * @example\n * import { createThemeStore, localStorageAdapter } from 'resonare'\n *\n * const store = createThemeStore(\n * { colorMode: { options: ['light', 'dark'] } },\n * { storage: localStorageAdapter({ key: 'app', type: 'localStorage' }) }\n * )\n */\nexport const localStorageAdapter: StorageAdapterCreator<{\n key: string\n type?: 'localStorage' | 'sessionStorage'\n}> = ({ key, type = 'localStorage' }) => {\n return ({ abortController }) => {\n return {\n // Storage access throws when it is blocked (e.g. cookies disabled,\n // sandboxed iframes) or full.\n get: () => {\n try {\n return window[type].getItem(key)\n } catch {\n return null\n }\n },\n\n set: (value) => {\n try {\n window[type].setItem(key, value)\n } catch {}\n },\n\n watch: (cb) => {\n const listener = (e: StorageEvent) => {\n if (e.storageArea === window[type] && e.key === key) {\n cb(e.newValue)\n }\n }\n\n // Passing the controller as options (it has `signal`) removes the\n // listener when the store is destroyed.\n addEventListener('storage', listener, abortController)\n\n return () => {\n removeEventListener('storage', listener)\n }\n },\n }\n }\n}\n\n/**\n * Keeps the store in memory only, and supports `store.sync()` across tabs\n * through `BroadcastChannel`. Use it when you save the state yourself (e.g.\n * `toPersist()` to a database) and don't want it in `localStorage`.\n *\n * @example\n * import { createThemeStore, memoryStorageAdapter } from 'resonare'\n *\n * const store = createThemeStore(\n * { colorMode: { options: ['light', 'dark'] } },\n * { storage: memoryStorageAdapter({ key: 'app' }) }\n * )\n */\nexport const memoryStorageAdapter: StorageAdapterCreator<{\n key: string\n}> = ({ key }) => {\n return ({ abortController }) => {\n const storage = new Map<string, string>()\n\n const channel = new BroadcastChannel(DEFAULT_KEY)\n\n // An open channel keeps a Node process alive.\n abortController.signal.addEventListener('abort', () => {\n channel.close()\n })\n\n return {\n get: () => {\n return storage.get(key) ?? null\n },\n\n set: (value) => {\n storage.set(key, value)\n },\n\n broadcast: (value) => {\n channel.postMessage({ key, value })\n },\n\n watch: (cb) => {\n const listener = (e: MessageEvent) => {\n if (e.data.key === key) {\n storage.set(key, e.data.value)\n\n cb(e.data.value)\n }\n }\n\n channel.addEventListener('message', listener)\n\n return () => {\n channel.removeEventListener('message', listener)\n }\n },\n }\n }\n}\n"],"mappings":"AAAA,MAAaA,EAAc,WACdC,EAAmB,gBCGnBC,EAAgB,GACpB,KAAK,UAAUC,CAAK,CAAC,CAAC,QAAQ,KAAM,SAAS,EAQzCC,EAAoB,GAA8B,CAC7D,IAAMC,EAAS,OAAOC,CAAO,EAE7B,MAAO,0CAA0C,KAAKD,CAAM,EACxDA,EACA,kBAAkBA,EAAO,MAC/B,ECiCaE,GAGP,CAAE,MAAK,OAAO,mBACV,CAAE,sBACD,CAGL,QAAW,CACT,GAAI,CACF,OAAO,OAAOC,EAAK,CAAC,QAAQC,CAAG,CACjC,MAAQ,CACN,OAAO,IACT,CACF,EAEA,IAAM,GAAU,CACd,GAAI,CACF,OAAOD,EAAK,CAAC,QAAQC,EAAKN,CAAK,CACjC,MAAQ,CAAC,CACX,EAEA,MAAQ,GAAO,CACb,IAAMO,EAAY,GAAoB,CAChCC,EAAE,cAAgB,OAAOH,IAASG,EAAE,MAAQF,GAC9CG,EAAGD,EAAE,QAAQ,CAEjB,EAMA,OAFA,iBAAiB,UAAWD,EAAUG,CAAe,MAExC,CACX,oBAAoB,UAAWH,CAAQ,CACzC,CACF,CACF,GAiBSI,GAEP,CAAE,UACE,CAAE,qBAAsB,CAC9B,IAAMC,kBAAU,IAAI,IAEdC,EAAU,IAAI,iBAAiBhB,CAAW,EAOhD,OAJAa,EAAgB,OAAO,iBAAiB,YAAe,CACrDG,EAAQ,MAAM,CAChB,CAAC,EAEM,CACL,QACSD,EAAQ,IAAIN,CAAG,GAAK,KAG7B,IAAM,GAAU,CACdM,EAAQ,IAAIN,EAAKN,CAAK,CACxB,EAEA,UAAY,GAAU,CACpBa,EAAQ,YAAY,CAAE,MAAK,OAAM,CAAC,CACpC,EAEA,MAAQ,GAAO,CACb,IAAMN,EAAY,GAAoB,CAChCC,EAAE,KAAK,MAAQF,IACjBM,EAAQ,IAAIN,EAAKE,EAAE,KAAK,KAAK,EAE7BC,EAAGD,EAAE,KAAK,KAAK,EAEnB,EAIA,OAFAK,EAAQ,iBAAiB,UAAWN,CAAQ,MAE/B,CACXM,EAAQ,oBAAoB,UAAWN,CAAQ,CACjD,CACF,CACF,CACF,E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a store saves its state. Values are strings: the full store saves
|
|
3
|
+
* JSON, the lite store saves the theme name.
|
|
4
|
+
*/
|
|
5
|
+
type StorageAdapter = {
|
|
6
|
+
/** Returns the saved value, or `null` when nothing is saved. */
|
|
7
|
+
get: () => string | null;
|
|
8
|
+
/** Saves a value. */
|
|
9
|
+
set: (value: string) => void;
|
|
10
|
+
/** Optional: tells other tabs about a value just saved with `set`. */
|
|
11
|
+
broadcast?: (value: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Optional: calls `cb` when another tab saves a value (`null` when it clears
|
|
14
|
+
* it). Returns a function that stops watching. Used by `store.sync()`.
|
|
15
|
+
*/
|
|
16
|
+
watch?: (cb: (value: string | null) => void) => () => void;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* What a store's `storage` option takes: a function that creates the adapter.
|
|
20
|
+
* `abortController` is aborted when the store is destroyed; use it to remove
|
|
21
|
+
* listeners.
|
|
22
|
+
*/
|
|
23
|
+
type StorageAdapterCreate = ({ abortController }: {
|
|
24
|
+
abortController: AbortController;
|
|
25
|
+
}) => StorageAdapter;
|
|
26
|
+
/**
|
|
27
|
+
* Shape of the built-in adapters such as `localStorageAdapter`: takes options
|
|
28
|
+
* (like the key) and returns a {@link StorageAdapterCreate}.
|
|
29
|
+
*/
|
|
30
|
+
type StorageAdapterCreator<Options> = (options: Options) => StorageAdapterCreate;
|
|
31
|
+
/**
|
|
32
|
+
* Saves the store in `localStorage` (default) or `sessionStorage` under `key`,
|
|
33
|
+
* and supports `store.sync()` across tabs. If storage is blocked or full,
|
|
34
|
+
* reads return nothing and writes are skipped.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* import { createThemeStore, localStorageAdapter } from 'resonare'
|
|
38
|
+
*
|
|
39
|
+
* const store = createThemeStore(
|
|
40
|
+
* { colorMode: { options: ['light', 'dark'] } },
|
|
41
|
+
* { storage: localStorageAdapter({ key: 'app', type: 'localStorage' }) }
|
|
42
|
+
* )
|
|
43
|
+
*/
|
|
44
|
+
declare const localStorageAdapter: StorageAdapterCreator<{
|
|
45
|
+
key: string;
|
|
46
|
+
type?: 'localStorage' | 'sessionStorage';
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Keeps the store in memory only, and supports `store.sync()` across tabs
|
|
50
|
+
* through `BroadcastChannel`. Use it when you save the state yourself (e.g.
|
|
51
|
+
* `toPersist()` to a database) and don't want it in `localStorage`.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* import { createThemeStore, memoryStorageAdapter } from 'resonare'
|
|
55
|
+
*
|
|
56
|
+
* const store = createThemeStore(
|
|
57
|
+
* { colorMode: { options: ['light', 'dark'] } },
|
|
58
|
+
* { storage: memoryStorageAdapter({ key: 'app' }) }
|
|
59
|
+
* )
|
|
60
|
+
*/
|
|
61
|
+
declare const memoryStorageAdapter: StorageAdapterCreator<{
|
|
62
|
+
key: string;
|
|
63
|
+
}>;
|
|
64
|
+
export { memoryStorageAdapter as a, localStorageAdapter as i, StorageAdapterCreate as n, StorageAdapterCreator as r, StorageAdapter as t };
|
|
65
|
+
//# sourceMappingURL=storage-CsXjZKyt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-CsXjZKyt.d.ts","names":[],"sources":["../src/storage.ts"],"mappings":";;;;KAMY;;EAEV;;EAEA,MAAM;;EAEN,aAAa;;;;;EAKb,SAAS,KAAK;;;;;;;KAQJ,0BACV;EAEA,iBAAiB;MACb;;;;;KAMM,sBAAsB,YAChC,SAAS,YACN;;;;;;;;;;;;;;cAeQ,qBAAqB;EAChC;EACA;;;;;;;;;;;;;;;cAoDW,sBAAsB;EACjC"}
|
package/dist/svelte.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ThemeStore, ThemeStoreConfig, Themes } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the store's state (`themes`, `resolvedThemes`,
|
|
4
|
+
* `resolvedSystemThemes`), each read through `.current`, and its methods.
|
|
5
|
+
* `.current` is reactive in templates, `$derived` and `$effect`, and the store
|
|
6
|
+
* is subscribed only while something reads it. Hydration needs nothing extra:
|
|
7
|
+
* Svelte fixes any markup that differs from the server's.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <script lang="ts">
|
|
11
|
+
* import { useResonare } from 'resonare/svelte'
|
|
12
|
+
*
|
|
13
|
+
* const { themes, setThemes } = useResonare(store)
|
|
14
|
+
* </script>
|
|
15
|
+
*
|
|
16
|
+
* <p>Color mode: {themes.current.colorMode}</p>
|
|
17
|
+
* <button onclick={() => setThemes({ colorMode: 'dark' })}>Dark</button>
|
|
18
|
+
*/
|
|
19
|
+
export declare function useResonare<T extends ThemeStoreConfig>(store: ThemeStore<T>): {
|
|
20
|
+
themes: {
|
|
21
|
+
readonly current: Themes<T>;
|
|
22
|
+
};
|
|
23
|
+
resolvedThemes: {
|
|
24
|
+
readonly current: Themes<T>;
|
|
25
|
+
};
|
|
26
|
+
resolvedSystemThemes: {
|
|
27
|
+
readonly current: { [K in { [K in keyof T]: T[K] extends {
|
|
28
|
+
options: ReadonlyArray<infer U>;
|
|
29
|
+
} ? U extends {
|
|
30
|
+
media: ReadonlyArray<unknown>;
|
|
31
|
+
} ? K : never : never; }[keyof T]]: T[K] extends {
|
|
32
|
+
options: ReadonlyArray<infer U>;
|
|
33
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
34
|
+
value: string;
|
|
35
|
+
media?: readonly [string, string, string] | undefined;
|
|
36
|
+
} ? U extends {
|
|
37
|
+
media: ReadonlyArray<unknown>;
|
|
38
|
+
} ? never : U["value"] : never : never; };
|
|
39
|
+
};
|
|
40
|
+
destroy: () => void;
|
|
41
|
+
restore: () => void;
|
|
42
|
+
setThemes: (themes: Partial<Themes<T>> | ((currentThemes: Themes<T>) => Partial<Themes<T>>)) => void;
|
|
43
|
+
subscribe: (callback: (value: {
|
|
44
|
+
themes: Themes<T>;
|
|
45
|
+
resolvedThemes: Themes<T>;
|
|
46
|
+
resolvedSystemThemes: { [K in { [K in keyof T]: T[K] extends {
|
|
47
|
+
options: ReadonlyArray<infer U>;
|
|
48
|
+
} ? U extends {
|
|
49
|
+
media: ReadonlyArray<unknown>;
|
|
50
|
+
} ? K : never : never; }[keyof T]]: T[K] extends {
|
|
51
|
+
options: ReadonlyArray<infer U>;
|
|
52
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
53
|
+
value: string;
|
|
54
|
+
media?: readonly [string, string, string] | undefined;
|
|
55
|
+
} ? U extends {
|
|
56
|
+
media: ReadonlyArray<unknown>;
|
|
57
|
+
} ? never : U["value"] : never : never; };
|
|
58
|
+
}) => void) => () => void;
|
|
59
|
+
sync: () => (() => void) | undefined;
|
|
60
|
+
toPersist: () => {
|
|
61
|
+
themes: Partial<Themes<T>>;
|
|
62
|
+
systemOptions: {
|
|
63
|
+
[x: string]: [string, string];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
updateSystemOption: <K extends { [K in keyof T]: T[K] extends {
|
|
67
|
+
options: ReadonlyArray<infer U>;
|
|
68
|
+
} ? U extends {
|
|
69
|
+
media: ReadonlyArray<unknown>;
|
|
70
|
+
} ? K : never : never; }[keyof T]>(themeKey: K, pair: [T[K] extends {
|
|
71
|
+
options: ReadonlyArray<infer U>;
|
|
72
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
73
|
+
value: string;
|
|
74
|
+
media?: readonly [string, string, string] | undefined;
|
|
75
|
+
} ? U extends {
|
|
76
|
+
media: ReadonlyArray<unknown>;
|
|
77
|
+
} ? never : U["value"] : never : never, T[K] extends {
|
|
78
|
+
options: ReadonlyArray<infer U>;
|
|
79
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
80
|
+
value: string;
|
|
81
|
+
media?: readonly [string, string, string] | undefined;
|
|
82
|
+
} ? U extends {
|
|
83
|
+
media: ReadonlyArray<unknown>;
|
|
84
|
+
} ? never : U["value"] : never : never]) => void;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte.d.ts","names":["_$_0.Themes"],"sources":["../src/svelte.ts"],"mappings":";;;;;;;;;;;;;;;;;;wBAqBgB,YAAY,UAAU,kBAAkB,OAAO,WAAW;;aA0BhE,SAAOA,OAAA;;;aAKP,SAAOA,OAAA;;;aAKP,YAAO,QAAA,WAAA,IAAA,EAAA"}
|
package/dist/svelte.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createSubscriber as e}from"svelte/reactivity";function t(t){let{destroy:n,getSnapshot:r,restore:i,setThemes:a,subscribe:o,sync:s,toPersist:c,updateSystemOption:l}=t,u=e(e=>o(()=>{e()})),d=()=>(u(),r());return{themes:{get current(){return d().themes}},resolvedThemes:{get current(){return d().resolvedThemes}},resolvedSystemThemes:{get current(){return d().resolvedSystemThemes}},destroy:n,restore:i,setThemes:a,subscribe:o,sync:s,toPersist:c,updateSystemOption:l}}export{t as useResonare};
|
|
2
|
+
//# sourceMappingURL=svelte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte.js","names":["useResonare","store","track","createSubscriber","subscribe","update","read","getSnapshot"],"sources":["../src/svelte.ts"],"sourcesContent":["import { createSubscriber } from 'svelte/reactivity'\n\nimport type { ThemeStore, ThemeStoreConfig } from '.'\n\n/**\n * Returns the store's state (`themes`, `resolvedThemes`,\n * `resolvedSystemThemes`), each read through `.current`, and its methods.\n * `.current` is reactive in templates, `$derived` and `$effect`, and the store\n * is subscribed only while something reads it. Hydration needs nothing extra:\n * Svelte fixes any markup that differs from the server's.\n *\n * @example\n * <script lang=\"ts\">\n * import { useResonare } from 'resonare/svelte'\n *\n * const { themes, setThemes } = useResonare(store)\n * </script>\n *\n * <p>Color mode: {themes.current.colorMode}</p>\n * <button onclick={() => setThemes({ colorMode: 'dark' })}>Dark</button>\n */\nexport function useResonare<T extends ThemeStoreConfig>(store: ThemeStore<T>) {\n const {\n destroy,\n getSnapshot,\n restore,\n setThemes,\n subscribe,\n sync,\n toPersist,\n updateSystemOption,\n } = store\n\n const track = createSubscriber((update) => {\n return subscribe(() => {\n update()\n })\n })\n\n const read = () => {\n track()\n\n return getSnapshot()\n }\n\n return {\n themes: {\n get current() {\n return read().themes\n },\n },\n resolvedThemes: {\n get current() {\n return read().resolvedThemes\n },\n },\n resolvedSystemThemes: {\n get current() {\n return read().resolvedSystemThemes\n },\n },\n destroy,\n restore,\n setThemes,\n subscribe,\n sync,\n toPersist,\n updateSystemOption,\n }\n}\n"],"mappings":"A,qDAqBA,SAAgBA,EAAwC,EAAsB,CAC5E,GAAM,CACJ,UACA,cACA,UACA,YACA,YACA,OACA,YACA,sBACEC,EAEEC,EAAQC,EAAkB,GACvBC,MAAgB,CACrBC,EAAO,CACT,CAAC,CACF,EAEKC,OACJJ,EAAM,EAECK,EAAY,GAGrB,MAAO,CACL,OAAQ,CACN,IAAI,SAAU,CACZ,OAAOD,EAAK,CAAC,CAAC,MAChB,CACF,EACA,eAAgB,CACd,IAAI,SAAU,CACZ,OAAOA,EAAK,CAAC,CAAC,cAChB,CACF,EACA,qBAAsB,CACpB,IAAI,SAAU,CACZ,OAAOA,EAAK,CAAC,CAAC,oBAChB,CACF,EACA,UACA,UACA,YACA,YACA,OACA,YACA,oBACF,CACF,C"}
|
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ThemeStore, ThemeStoreConfig, Themes } from "./index.js";
|
|
2
|
+
import { ComputedRef } from "vue";
|
|
3
|
+
type UseResonareOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Set this in server-rendered apps. The first render then uses the server
|
|
6
|
+
* state so hydration matches the server HTML, and switches to the live state
|
|
7
|
+
* once mounted. Leave it off in client-only apps, where it would show the
|
|
8
|
+
* server state for one frame.
|
|
9
|
+
*/
|
|
10
|
+
hydrate?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns the store's state as computed refs (`themes`, `resolvedThemes`,
|
|
14
|
+
* `resolvedSystemThemes`) and its methods. Call it in `setup` (or inside an
|
|
15
|
+
* `effectScope`); the subscription ends when the component unmounts or the
|
|
16
|
+
* scope stops.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <script setup lang="ts">
|
|
20
|
+
* import { useResonare } from 'resonare/vue'
|
|
21
|
+
*
|
|
22
|
+
* // hydrate: true only in server-rendered apps
|
|
23
|
+
* const { themes, setThemes } = useResonare(store, { hydrate: true })
|
|
24
|
+
* </script>
|
|
25
|
+
*
|
|
26
|
+
* <template>
|
|
27
|
+
* <p>Color mode: {{ themes.colorMode }}</p>
|
|
28
|
+
* <button @click="setThemes({ colorMode: 'dark' })">Dark</button>
|
|
29
|
+
* </template>
|
|
30
|
+
*/
|
|
31
|
+
export declare function useResonare<T extends ThemeStoreConfig>(store: ThemeStore<T>, { hydrate }?: UseResonareOptions): {
|
|
32
|
+
themes: ComputedRef<Themes<T>>;
|
|
33
|
+
resolvedThemes: ComputedRef<Themes<T>>;
|
|
34
|
+
resolvedSystemThemes: ComputedRef<ReturnType<ThemeStore<T>['getSnapshot']>['resolvedSystemThemes']>;
|
|
35
|
+
destroy: () => void;
|
|
36
|
+
restore: () => void;
|
|
37
|
+
setThemes: (themes: Partial<Themes<T>> | ((currentThemes: Themes<T>) => Partial<Themes<T>>)) => void;
|
|
38
|
+
subscribe: (callback: (value: {
|
|
39
|
+
themes: Themes<T>;
|
|
40
|
+
resolvedThemes: Themes<T>;
|
|
41
|
+
resolvedSystemThemes: { [K in { [K in keyof T]: T[K] extends {
|
|
42
|
+
options: ReadonlyArray<infer U>;
|
|
43
|
+
} ? U extends {
|
|
44
|
+
media: ReadonlyArray<unknown>;
|
|
45
|
+
} ? K : never : never; }[keyof T]]: T[K] extends {
|
|
46
|
+
options: ReadonlyArray<infer U>;
|
|
47
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
48
|
+
value: string;
|
|
49
|
+
media?: readonly [string, string, string] | undefined;
|
|
50
|
+
} ? U extends {
|
|
51
|
+
media: ReadonlyArray<unknown>;
|
|
52
|
+
} ? never : U["value"] : never : never; };
|
|
53
|
+
}) => void) => () => void;
|
|
54
|
+
sync: () => (() => void) | undefined;
|
|
55
|
+
toPersist: () => {
|
|
56
|
+
themes: Partial<Themes<T>>;
|
|
57
|
+
systemOptions: {
|
|
58
|
+
[x: string]: [string, string];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
updateSystemOption: <K extends { [K in keyof T]: T[K] extends {
|
|
62
|
+
options: ReadonlyArray<infer U>;
|
|
63
|
+
} ? U extends {
|
|
64
|
+
media: ReadonlyArray<unknown>;
|
|
65
|
+
} ? K : never : never; }[keyof T]>(themeKey: K, pair: [T[K] extends {
|
|
66
|
+
options: ReadonlyArray<infer U>;
|
|
67
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
68
|
+
value: string;
|
|
69
|
+
media?: readonly [string, string, string] | undefined;
|
|
70
|
+
} ? U extends {
|
|
71
|
+
media: ReadonlyArray<unknown>;
|
|
72
|
+
} ? never : U["value"] : never : never, T[K] extends {
|
|
73
|
+
options: ReadonlyArray<infer U>;
|
|
74
|
+
} ? U extends string | number | boolean ? U : U extends {
|
|
75
|
+
value: string;
|
|
76
|
+
media?: readonly [string, string, string] | undefined;
|
|
77
|
+
} ? U extends {
|
|
78
|
+
media: ReadonlyArray<unknown>;
|
|
79
|
+
} ? never : U["value"] : never : never]) => void;
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";;KAYK;;;;;;;EAOH;;;;;;;;;;;;;;;;;;;;;wBAsBc,YAAY,UAAU,kBACpC,OAAO,WAAW,MAChB,YAAmB;EAkDb,QAAA,YAAY,OAAO;EAGnB,gBAAA,YAAY,OAAO;EAGnB,sBAAA,YACJ,WAAW,WAAW"}
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{computed as e,getCurrentInstance as t,onMounted as n,onScopeDispose as r,onUnmounted as i,shallowRef as a}from"vue";function o(o,{hydrate:s=!1}={}){let{destroy:c,getServerSnapshot:l,getSnapshot:u,restore:d,setThemes:f,subscribe:p,sync:m,toPersist:h,updateSystemOption:g}=o,_=t(),v=a(s&&_?l():u()),y,b=()=>{v.value=u(),y=p(e=>{v.value=e})},x=()=>{y?.()};return _?(n(b),i(x)):(b(),r(x)),{themes:e(()=>v.value.themes),resolvedThemes:e(()=>v.value.resolvedThemes),resolvedSystemThemes:e(()=>v.value.resolvedSystemThemes),destroy:c,restore:d,setThemes:f,subscribe:p,sync:m,toPersist:h,updateSystemOption:g}}export{o as useResonare};
|
|
2
|
+
//# sourceMappingURL=vue.js.map
|
package/dist/vue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.js","names":["useResonare","store","instance","getCurrentInstance","snapshot","shallowRef","hydrate","getServerSnapshot","getSnapshot","unsubscribe","start","subscribe","value","stop","onMounted","onUnmounted","onScopeDispose","computed"],"sources":["../src/vue.ts"],"sourcesContent":["import {\n type ComputedRef,\n computed,\n getCurrentInstance,\n onMounted,\n onScopeDispose,\n onUnmounted,\n shallowRef,\n} from 'vue'\n\nimport type { ThemeStore, ThemeStoreConfig, Themes } from '.'\n\ntype UseResonareOptions = {\n /**\n * Set this in server-rendered apps. The first render then uses the server\n * state so hydration matches the server HTML, and switches to the live state\n * once mounted. Leave it off in client-only apps, where it would show the\n * server state for one frame.\n */\n hydrate?: boolean\n}\n\n/**\n * Returns the store's state as computed refs (`themes`, `resolvedThemes`,\n * `resolvedSystemThemes`) and its methods. Call it in `setup` (or inside an\n * `effectScope`); the subscription ends when the component unmounts or the\n * scope stops.\n *\n * @example\n * <script setup lang=\"ts\">\n * import { useResonare } from 'resonare/vue'\n *\n * // hydrate: true only in server-rendered apps\n * const { themes, setThemes } = useResonare(store, { hydrate: true })\n * </script>\n *\n * <template>\n * <p>Color mode: {{ themes.colorMode }}</p>\n * <button @click=\"setThemes({ colorMode: 'dark' })\">Dark</button>\n * </template>\n */\nexport function useResonare<T extends ThemeStoreConfig>(\n store: ThemeStore<T>,\n { hydrate = false }: UseResonareOptions = {}\n) {\n const {\n destroy,\n getServerSnapshot,\n getSnapshot,\n restore,\n setThemes,\n subscribe,\n sync,\n toPersist,\n updateSystemOption,\n } = store\n\n const instance = getCurrentInstance()\n\n const snapshot = shallowRef(\n hydrate && instance ? getServerSnapshot() : getSnapshot()\n )\n\n let unsubscribe: (() => unknown) | undefined\n\n const start = () => {\n snapshot.value = getSnapshot()\n\n unsubscribe = subscribe((value) => {\n snapshot.value = value\n })\n }\n\n const stop = () => {\n unsubscribe?.()\n }\n\n // Components subscribe on mount, which never runs during server rendering,\n // so the server never holds a subscription. Lifecycle hooks are used because\n // server rendering may set up components without an active effect scope.\n if (instance) {\n onMounted(start)\n\n onUnmounted(stop)\n } else {\n start()\n\n onScopeDispose(stop)\n }\n\n return {\n themes: computed(() => {\n return snapshot.value.themes\n }) as ComputedRef<Themes<T>>,\n resolvedThemes: computed(() => {\n return snapshot.value.resolvedThemes\n }) as ComputedRef<Themes<T>>,\n resolvedSystemThemes: computed(() => {\n return snapshot.value.resolvedSystemThemes\n }) as ComputedRef<\n ReturnType<ThemeStore<T>['getSnapshot']>['resolvedSystemThemes']\n >,\n destroy,\n restore,\n setThemes,\n subscribe,\n sync,\n toPersist,\n updateSystemOption,\n }\n}\n"],"mappings":"A,2HAyCA,SAAgBA,EACd,EACA,CAAE,UAAU,IAA8B,CAAC,EAC3C,CACA,GAAM,CACJ,UACA,oBACA,cACA,UACA,YACA,YACA,OACA,YACA,sBACEC,EAEEC,EAAWC,EAAmB,EAE9BC,EAAWC,EACfC,GAAWJ,EAAWK,EAAkB,EAAIC,EAAY,CAC1D,EAEIC,EAEEC,MAAc,CAClB,EAAS,MAAQF,EAAY,EAE7B,EAAcG,EAAW,GAAU,CACjC,EAAS,MAAQC,CACnB,CAAC,CACH,EAEMC,MAAa,CACjBJ,IAAc,CAChB,EAeA,OAVIP,GACFY,EAAUJ,CAAK,EAEfK,EAAYF,CAAI,IAEhBH,EAAM,EAENM,EAAeH,CAAI,GAGd,CACL,OAAQI,MACCb,EAAS,MAAM,MACvB,EACD,eAAgBa,MACPb,EAAS,MAAM,cACvB,EACD,qBAAsBa,MACbb,EAAS,MAAM,oBACvB,EAGD,UACA,UACA,YACA,YACA,OACA,YACA,oBACF,CACF,C"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resonare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Resonare",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"theming",
|
|
7
6
|
"dark mode",
|
|
7
|
+
"theming",
|
|
8
8
|
"user preferences"
|
|
9
9
|
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "Si Phuoc <phuoc317049@gmail.com>",
|
|
10
12
|
"repository": {
|
|
11
13
|
"type": "git",
|
|
12
14
|
"url": "https://github.com/phuoccss/resonare.git",
|
|
13
15
|
"directory": "resonare"
|
|
14
16
|
},
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
18
20
|
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
19
23
|
"exports": {
|
|
20
24
|
".": {
|
|
21
25
|
"types": "./dist/index.d.ts",
|
|
@@ -25,6 +29,18 @@
|
|
|
25
29
|
"types": "./dist/react.d.ts",
|
|
26
30
|
"import": "./dist/react.js"
|
|
27
31
|
},
|
|
32
|
+
"./solid": {
|
|
33
|
+
"types": "./dist/solid.d.ts",
|
|
34
|
+
"import": "./dist/solid.js"
|
|
35
|
+
},
|
|
36
|
+
"./svelte": {
|
|
37
|
+
"types": "./dist/svelte.d.ts",
|
|
38
|
+
"import": "./dist/svelte.js"
|
|
39
|
+
},
|
|
40
|
+
"./vue": {
|
|
41
|
+
"types": "./dist/vue.d.ts",
|
|
42
|
+
"import": "./dist/vue.js"
|
|
43
|
+
},
|
|
28
44
|
"./lite": {
|
|
29
45
|
"types": "./dist/lite.d.ts",
|
|
30
46
|
"import": "./dist/lite.js"
|
|
@@ -32,47 +48,66 @@
|
|
|
32
48
|
"./lite/react": {
|
|
33
49
|
"types": "./dist/lite-react.d.ts",
|
|
34
50
|
"import": "./dist/lite-react.js"
|
|
51
|
+
},
|
|
52
|
+
"./lite/solid": {
|
|
53
|
+
"types": "./dist/lite-solid.d.ts",
|
|
54
|
+
"import": "./dist/lite-solid.js"
|
|
55
|
+
},
|
|
56
|
+
"./lite/svelte": {
|
|
57
|
+
"types": "./dist/lite-svelte.d.ts",
|
|
58
|
+
"import": "./dist/lite-svelte.js"
|
|
59
|
+
},
|
|
60
|
+
"./lite/vue": {
|
|
61
|
+
"types": "./dist/lite-vue.d.ts",
|
|
62
|
+
"import": "./dist/lite-vue.js"
|
|
35
63
|
}
|
|
36
64
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"dist"
|
|
40
|
-
],
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"react-compiler-runtime": "1.0.0"
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
43
67
|
},
|
|
44
68
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@types/
|
|
48
|
-
"@types/react": "19.
|
|
49
|
-
"@vitejs/plugin-react": "6.
|
|
50
|
-
"babel-plugin-react-compiler": "1.0.0",
|
|
69
|
+
"@size-limit/preset-small-lib": "14.3.0",
|
|
70
|
+
"@types/node": "26.6.6",
|
|
71
|
+
"@types/react": "19.3.0",
|
|
72
|
+
"@types/react-dom": "19.3.0",
|
|
73
|
+
"@vitejs/plugin-react": "6.1.2",
|
|
51
74
|
"cross-env": "10.1.0",
|
|
52
|
-
"jsdom": "
|
|
53
|
-
"react": "
|
|
54
|
-
"react
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
75
|
+
"jsdom": "30.1.3",
|
|
76
|
+
"oxc-transform-react": "0.156.0",
|
|
77
|
+
"react": "19.3.1",
|
|
78
|
+
"react-dom": "19.3.1",
|
|
79
|
+
"size-limit": "14.3.0",
|
|
80
|
+
"solid-js": "1.9.18",
|
|
81
|
+
"svelte": "5.57.3",
|
|
82
|
+
"typescript": "7.0.2",
|
|
83
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
84
|
+
"vite-plus": "1.4.0",
|
|
85
|
+
"vue": "3.5.44"
|
|
60
86
|
},
|
|
61
87
|
"peerDependencies": {
|
|
62
|
-
"react": "^
|
|
88
|
+
"react": "^19.0.0",
|
|
89
|
+
"solid-js": "^1.6.0",
|
|
90
|
+
"svelte": "^5.7.0",
|
|
91
|
+
"vue": "^3.2.0"
|
|
63
92
|
},
|
|
64
93
|
"peerDependenciesMeta": {
|
|
65
94
|
"react": {
|
|
66
95
|
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"solid-js": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"svelte": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"vue": {
|
|
104
|
+
"optional": true
|
|
67
105
|
}
|
|
68
106
|
},
|
|
69
|
-
"publishConfig": {
|
|
70
|
-
"access": "public"
|
|
71
|
-
},
|
|
72
107
|
"scripts": {
|
|
73
|
-
"build": "
|
|
74
|
-
"dev": "
|
|
108
|
+
"build": "vp pack",
|
|
109
|
+
"dev": "vp pack --watch",
|
|
75
110
|
"size": "pnpm build && size-limit",
|
|
76
|
-
"test": "
|
|
111
|
+
"test": "vp test"
|
|
77
112
|
}
|
|
78
113
|
}
|
package/dist/storage-B5xjLRee.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=`resonare`,t=`resonare/lite`,n=({key:e,type:t=`localStorage`})=>({abortController:n})=>({get:()=>window[t].getItem(e),set:n=>{window[t].setItem(e,n)},watch:r=>{let i=new AbortController;return window.addEventListener(`storage`,n=>{n.storageArea===window[t]&&n.key===e&&r(n.newValue)},{signal:AbortSignal.any([n.signal,i.signal])}),()=>{i.abort()}}}),r=({key:t})=>({abortController:n})=>{let r=new Map,i=new BroadcastChannel(e);return{get:()=>r.get(t)??null,set:e=>{r.set(t,e)},broadcast:e=>{i.postMessage({key:t,value:e})},watch:e=>{let r=new AbortController;return i.addEventListener(`message`,n=>{n.data.key===t&&e(n.data.value)},{signal:AbortSignal.any([n.signal,r.signal])}),()=>{r.abort()}}}};export{t as i,r as n,e as r,n as t};
|
|
2
|
-
//# sourceMappingURL=storage-B5xjLRee.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage-B5xjLRee.js","names":["DEFAULT_KEY","DEFAULT_LITE_KEY","DEFAULT_KEY","StorageAdapter","get","set","value","broadcast","watch","cb","StorageAdapterCreate","abortController","AbortController","StorageAdapterCreator","options","Options","localStorageAdapter","key","type","window","getItem","setItem","controller","addEventListener","e","storageArea","newValue","signal","AbortSignal","any","abort","memoryStorageAdapter","storage","Map","channel","BroadcastChannel","postMessage","data"],"sources":["../src/constants.ts","../src/storage.ts"],"sourcesContent":["export const DEFAULT_KEY = 'resonare'\nexport const DEFAULT_LITE_KEY = 'resonare/lite'\n","import { DEFAULT_KEY } from './constants'\n\nexport type StorageAdapter = {\n\tget: () => string | null\n\tset: (value: string) => void\n\tbroadcast?: (value: string) => void\n\twatch?: (cb: (value: string | null) => void) => () => void\n}\n\nexport type StorageAdapterCreate = ({\n\tabortController,\n}: {\n\tabortController: AbortController\n}) => StorageAdapter\n\nexport type StorageAdapterCreator<Options> = (\n\toptions: Options,\n) => StorageAdapterCreate\n\nexport const localStorageAdapter: StorageAdapterCreator<{\n\tkey: string\n\ttype?: 'localStorage' | 'sessionStorage'\n}> = ({ key, type = 'localStorage' }) => {\n\treturn ({ abortController }) => {\n\t\treturn {\n\t\t\tget: () => {\n\t\t\t\treturn window[type].getItem(key)\n\t\t\t},\n\n\t\t\tset: (value) => {\n\t\t\t\twindow[type].setItem(key, value)\n\t\t\t},\n\n\t\t\twatch: (cb) => {\n\t\t\t\tconst controller = new AbortController()\n\n\t\t\t\twindow.addEventListener(\n\t\t\t\t\t'storage',\n\t\t\t\t\t(e) => {\n\t\t\t\t\t\tif (e.storageArea !== window[type]) return\n\n\t\t\t\t\t\tif (e.key !== key) return\n\n\t\t\t\t\t\tcb(e.newValue)\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tsignal: AbortSignal.any([\n\t\t\t\t\t\t\tabortController.signal,\n\t\t\t\t\t\t\tcontroller.signal,\n\t\t\t\t\t\t]),\n\t\t\t\t\t},\n\t\t\t\t)\n\n\t\t\t\treturn () => {\n\t\t\t\t\tcontroller.abort()\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n}\n\nexport const memoryStorageAdapter: StorageAdapterCreator<{\n\tkey: string\n}> = ({ key }) => {\n\treturn ({ abortController }) => {\n\t\tconst storage = new Map<string, string>()\n\n\t\tconst channel = new BroadcastChannel(DEFAULT_KEY)\n\n\t\treturn {\n\t\t\tget: () => {\n\t\t\t\treturn storage.get(key) ?? null\n\t\t\t},\n\n\t\t\tset: (value) => {\n\t\t\t\tstorage.set(key, value)\n\t\t\t},\n\n\t\t\tbroadcast: (value) => {\n\t\t\t\tchannel.postMessage({ key, value })\n\t\t\t},\n\n\t\t\twatch: (cb) => {\n\t\t\t\tconst controller = new AbortController()\n\n\t\t\t\tchannel.addEventListener(\n\t\t\t\t\t'message',\n\t\t\t\t\t(e) => {\n\t\t\t\t\t\tif (e.data.key !== key) return\n\n\t\t\t\t\t\tcb(e.data.value)\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tsignal: AbortSignal.any([\n\t\t\t\t\t\t\tabortController.signal,\n\t\t\t\t\t\t\tcontroller.signal,\n\t\t\t\t\t\t]),\n\t\t\t\t\t},\n\t\t\t\t)\n\n\t\t\t\treturn () => {\n\t\t\t\t\tcontroller.abort()\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n}\n"],"mappings":"AAAA,MAAaA,EAAc,WACdC,EAAmB,gBCkBnBe,GAGP,CAAEC,MAAKC,OAAO,mBACX,CAAEP,sBACF,CACNP,QACQe,OAAOD,EAAK,CAACE,QAAQH,CAAG,EAGhCZ,IAAMC,GAAU,CACfa,OAAOD,EAAK,CAACG,QAAQJ,EAAKX,CAAK,CAChC,EAEAE,MAAQC,GAAO,CACd,IAAMa,EAAa,IAAIV,gBAmBvB,OAjBAO,OAAOI,iBACN,UACCC,GAAM,CACFA,EAAEC,cAAgBN,OAAOD,IAEzBM,EAAEP,MAAQA,GAEdR,EAAGe,EAAEE,QAAQ,CACd,EACA,CACCC,OAAQC,YAAYC,IAAI,CACvBlB,EAAgBgB,OAChBL,EAAWK,MAAM,CACjB,CACF,CACD,MAEa,CACZL,EAAWQ,MAAM,CAClB,CACD,CACD,GAIWC,GAEP,CAAEd,UACC,CAAEN,qBAAsB,CAC/B,IAAMqB,EAAU,IAAIC,IAEdC,EAAU,IAAIC,iBAAiBjC,CAAW,EAEhD,MAAO,CACNE,QACQ4B,EAAQ5B,IAAIa,CAAG,GAAK,KAG5BZ,IAAMC,GAAU,CACf0B,EAAQ3B,IAAIY,EAAKX,CAAK,CACvB,EAEAC,UAAYD,GAAU,CACrB4B,EAAQE,YAAY,CAAEnB,MAAKX,OAAM,CAAC,CACnC,EAEAE,MAAQC,GAAO,CACd,IAAMa,EAAa,IAAIV,gBAiBvB,OAfAsB,EAAQX,iBACP,UACCC,GAAM,CACFA,EAAEa,KAAKpB,MAAQA,GAEnBR,EAAGe,EAAEa,KAAK/B,KAAK,CAChB,EACA,CACCqB,OAAQC,YAAYC,IAAI,CACvBlB,EAAgBgB,OAChBL,EAAWK,MAAM,CACjB,CACF,CACD,MAEa,CACZL,EAAWQ,MAAM,CAClB,CACD,CACD,CACD"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/storage.d.ts
|
|
2
|
-
type StorageAdapter = {
|
|
3
|
-
get: () => string | null;
|
|
4
|
-
set: (value: string) => void;
|
|
5
|
-
broadcast?: (value: string) => void;
|
|
6
|
-
watch?: (cb: (value: string | null) => void) => () => void;
|
|
7
|
-
};
|
|
8
|
-
type StorageAdapterCreate = ({
|
|
9
|
-
abortController
|
|
10
|
-
}: {
|
|
11
|
-
abortController: AbortController;
|
|
12
|
-
}) => StorageAdapter;
|
|
13
|
-
type StorageAdapterCreator<Options> = (options: Options) => StorageAdapterCreate;
|
|
14
|
-
declare const localStorageAdapter: StorageAdapterCreator<{
|
|
15
|
-
key: string;
|
|
16
|
-
type?: 'localStorage' | 'sessionStorage';
|
|
17
|
-
}>;
|
|
18
|
-
declare const memoryStorageAdapter: StorageAdapterCreator<{
|
|
19
|
-
key: string;
|
|
20
|
-
}>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { memoryStorageAdapter as a, localStorageAdapter as i, StorageAdapterCreate as n, StorageAdapterCreator as r, StorageAdapter as t };
|
|
23
|
-
//# sourceMappingURL=storage-DGYV332J.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage-DGYV332J.d.ts","names":[],"sources":["../src/storage.ts"],"mappings":";KAEY,cAAA;EACX,GAAA;EACA,GAAA,GAAM,KAAA;EACN,SAAA,IAAa,KAAA;EACb,KAAA,IAAS,EAAA,GAAK,KAAA;AAAA;AAAA,KAGH,oBAAA;EACX;AAAA;EAEA,eAAA,EAAiB,eAAA;AAAA,MACZ,cAAA;AAAA,KAEM,qBAAA,aACX,OAAA,EAAS,OAAA,KACL,oBAAoB;AAAA,cAEZ,mBAAA,EAAqB,qBAAqB;EACtD,GAAA;EACA,IAAA;AAAA;AAAA,cAwCY,oBAAA,EAAsB,qBAAqB;EACvD,GAAG;AAAA"}
|