@tanstack/solid-store
Advanced tools
| "use strict"; | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
| const solidJs = require("solid-js"); | ||
| const store$1 = require("solid-js/store"); | ||
| const store = require("@tanstack/store"); | ||
| function useStore(store2, selector = (d) => d) { | ||
| const [slice, setSlice] = store$1.createStore({ | ||
| value: selector(store2.state) | ||
| }); | ||
| const unsub = store2.subscribe(() => { | ||
| const newValue = selector(store2.state); | ||
| setSlice("value", store$1.reconcile(newValue)); | ||
| }); | ||
| solidJs.onCleanup(() => { | ||
| unsub(); | ||
| }); | ||
| return () => slice.value; | ||
| } | ||
| exports.useStore = useStore; | ||
| Object.keys(store).forEach((k) => { | ||
| if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
| enumerable: true, | ||
| get: () => store[k] | ||
| }); | ||
| }); | ||
| //# sourceMappingURL=index.cjs.map |
| {"version":3,"file":"index.cjs","sources":["../../src/index.tsx"],"sourcesContent":["import { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport type { AnyUpdater, Store } from '@tanstack/store'\nimport type { Accessor } from 'solid-js'\n\nexport * from '@tanstack/store'\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport function useStore<\n TState,\n TSelected = NoInfer<TState>,\n TUpdater extends AnyUpdater = AnyUpdater,\n>(\n store: Store<TState, TUpdater>,\n selector: (state: NoInfer<TState>) => TSelected = (d) => d as any,\n): Accessor<TSelected> {\n const [slice, setSlice] = createStore({\n value: selector(store.state),\n })\n\n const unsub = store.subscribe(() => {\n const newValue = selector(store.state)\n setSlice('value', reconcile(newValue))\n })\n\n onCleanup(() => {\n unsub()\n })\n\n return () => slice.value\n}\n"],"names":["useStore","store","selector","d","slice","setSlice","createStore","value","state","unsub","subscribe","newValue","reconcile","onCleanup"],"mappings":";;;;;AASO,SAASA,SAKdC,QACAC,WAAmDC,CAAAA,MAAMA,GACpC;AACrB,QAAM,CAACC,OAAOC,QAAQ,IAAIC,oBAAY;AAAA,IACpCC,OAAOL,SAASD,OAAMO,KAAK;AAAA,EAAA,CAC5B;AAEKC,QAAAA,QAAQR,OAAMS,UAAU,MAAM;AAC5BC,UAAAA,WAAWT,SAASD,OAAMO,KAAK;AAC5B,aAAA,SAASI,kBAAUD,QAAQ,CAAC;AAAA,EAAA,CACtC;AAEDE,UAAAA,UAAU,MAAM;AACR;EAAA,CACP;AAED,SAAO,MAAMT,MAAMG;AACrB;;;;;;;;"} |
| import { AnyUpdater, Store } from '@tanstack/store'; | ||
| import { Accessor } from 'solid-js'; | ||
| export * from '@tanstack/store'; | ||
| export type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
| export declare function useStore<TState, TSelected = NoInfer<TState>, TUpdater extends AnyUpdater = AnyUpdater>(store: Store<TState, TUpdater>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>; |
| import { AnyUpdater, Store } from '@tanstack/store'; | ||
| import { Accessor } from 'solid-js'; | ||
| export * from '@tanstack/store'; | ||
| export type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
| export declare function useStore<TState, TSelected = NoInfer<TState>, TUpdater extends AnyUpdater = AnyUpdater>(store: Store<TState, TUpdater>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>; |
| import { onCleanup } from "solid-js"; | ||
| import { createStore, reconcile } from "solid-js/store"; | ||
| export * from "@tanstack/store"; | ||
| function useStore(store, selector = (d) => d) { | ||
| const [slice, setSlice] = createStore({ | ||
| value: selector(store.state) | ||
| }); | ||
| const unsub = store.subscribe(() => { | ||
| const newValue = selector(store.state); | ||
| setSlice("value", reconcile(newValue)); | ||
| }); | ||
| onCleanup(() => { | ||
| unsub(); | ||
| }); | ||
| return () => slice.value; | ||
| } | ||
| export { | ||
| useStore | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport type { AnyUpdater, Store } from '@tanstack/store'\nimport type { Accessor } from 'solid-js'\n\nexport * from '@tanstack/store'\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport function useStore<\n TState,\n TSelected = NoInfer<TState>,\n TUpdater extends AnyUpdater = AnyUpdater,\n>(\n store: Store<TState, TUpdater>,\n selector: (state: NoInfer<TState>) => TSelected = (d) => d as any,\n): Accessor<TSelected> {\n const [slice, setSlice] = createStore({\n value: selector(store.state),\n })\n\n const unsub = store.subscribe(() => {\n const newValue = selector(store.state)\n setSlice('value', reconcile(newValue))\n })\n\n onCleanup(() => {\n unsub()\n })\n\n return () => slice.value\n}\n"],"names":["useStore","store","selector","d","slice","setSlice","createStore","value","state","unsub","subscribe","newValue","reconcile","onCleanup"],"mappings":";;;AASO,SAASA,SAKdC,OACAC,WAAmDC,CAAAA,MAAMA,GACpC;AACrB,QAAM,CAACC,OAAOC,QAAQ,IAAIC,YAAY;AAAA,IACpCC,OAAOL,SAASD,MAAMO,KAAK;AAAA,EAAA,CAC5B;AAEKC,QAAAA,QAAQR,MAAMS,UAAU,MAAM;AAC5BC,UAAAA,WAAWT,SAASD,MAAMO,KAAK;AAC5B,aAAA,SAASI,UAAUD,QAAQ,CAAC;AAAA,EAAA,CACtC;AAEDE,YAAU,MAAM;AACR;EAAA,CACP;AAED,SAAO,MAAMT,MAAMG;AACrB;"} |
| import type { AnyUpdater, Store } from '@tanstack/store'; | ||
| import type { Accessor } from 'solid-js'; | ||
| export * from '@tanstack/store'; | ||
| export type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
| export declare function useStore<TState, TSelected = NoInfer<TState>, TUpdater extends AnyUpdater = AnyUpdater>(store: Store<TState, TUpdater>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>; |
| import { onCleanup } from 'solid-js'; | ||
| import { createStore, reconcile } from 'solid-js/store'; | ||
| export * from '@tanstack/store'; | ||
| export function useStore(store, selector = (d) => d) { | ||
| const [slice, setSlice] = createStore({ | ||
| value: selector(store.state), | ||
| }); | ||
| const unsub = store.subscribe(() => { | ||
| const newValue = selector(store.state); | ||
| setSlice('value', reconcile(newValue)); | ||
| }); | ||
| onCleanup(() => { | ||
| unsub(); | ||
| }); | ||
| return () => slice.value; | ||
| } | ||
| //# sourceMappingURL=index.jsx.map |
| {"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAIvD,cAAc,iBAAiB,CAAA;AAI/B,MAAM,UAAU,QAAQ,CAKtB,KAA8B,EAC9B,WAAkD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAQ;IAEjE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAC;QACpC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;KAC7B,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,EAAE,CAAA;IACT,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAA;AAC1B,CAAC"} |
| import { onCleanup } from 'solid-js' | ||
| import { createStore, reconcile } from 'solid-js/store' | ||
| import type { AnyUpdater, Store } from '@tanstack/store' | ||
| import type { Accessor } from 'solid-js' | ||
| export * from '@tanstack/store' | ||
| export type NoInfer<T> = [T][T extends any ? 0 : never] | ||
| export function useStore< | ||
| TState, | ||
| TSelected = NoInfer<TState>, | ||
| TUpdater extends AnyUpdater = AnyUpdater, | ||
| >( | ||
| store: Store<TState, TUpdater>, | ||
| selector: (state: NoInfer<TState>) => TSelected = (d) => d as any, | ||
| ): Accessor<TSelected> { | ||
| const [slice, setSlice] = createStore({ | ||
| value: selector(store.state), | ||
| }) | ||
| const unsub = store.subscribe(() => { | ||
| const newValue = selector(store.state) | ||
| setSlice('value', reconcile(newValue)) | ||
| }) | ||
| onCleanup(() => { | ||
| unsub() | ||
| }) | ||
| return () => slice.value | ||
| } |
+14
-10
| { | ||
| "name": "@tanstack/solid-store", | ||
| "version": "0.5.4", | ||
| "version": "0.5.5", | ||
| "description": "Framework agnostic type-safe store w/ reactive framework adapters", | ||
@@ -23,14 +23,18 @@ "author": "Tanner Linsley", | ||
| "type": "module", | ||
| "types": "dist/index.d.ts", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.js", | ||
| "types": "dist/esm/index.d.ts", | ||
| "main": "dist/cjs/index.cjs", | ||
| "module": "dist/esm/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "solid": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| "types": "./dist/source/index.d.ts", | ||
| "default": "./dist/source/index.jsx" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| "types": "./dist/esm/index.d.ts", | ||
| "default": "./dist/esm/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/index.d.cts", | ||
| "default": "./dist/cjs/index.cjs" | ||
| } | ||
@@ -46,6 +50,6 @@ }, | ||
| "dependencies": { | ||
| "@tanstack/store": "0.5.4" | ||
| "@tanstack/store": "0.5.5" | ||
| }, | ||
| "devDependencies": { | ||
| "solid-js": "^1.7.8", | ||
| "solid-js": "^1.8.18", | ||
| "vite-plugin-solid": "^2.10.2" | ||
@@ -52,0 +56,0 @@ }, |
| import type { AnyUpdater, Store } from '@tanstack/store'; | ||
| import type { Accessor } from 'solid-js'; | ||
| export * from '@tanstack/store'; | ||
| export type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
| export declare function useStore<TState, TSelected = NoInfer<TState>, TUpdater extends AnyUpdater = AnyUpdater>(store: Store<TState, TUpdater>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>; |
| import { onCleanup } from 'solid-js'; | ||
| import { createStore, reconcile } from 'solid-js/store'; | ||
| export * from '@tanstack/store'; | ||
| export function useStore(store, selector = (d) => d) { | ||
| const [slice, setSlice] = createStore({ | ||
| value: selector(store.state), | ||
| }); | ||
| const unsub = store.subscribe(() => { | ||
| const newValue = selector(store.state); | ||
| setSlice('value', reconcile(newValue)); | ||
| }); | ||
| onCleanup(() => { | ||
| unsub(); | ||
| }); | ||
| return () => slice.value; | ||
| } | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAIvD,cAAc,iBAAiB,CAAA;AAI/B,MAAM,UAAU,QAAQ,CAKtB,KAA8B,EAC9B,WAAkD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAQ;IAEjE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAC;QACpC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;KAC7B,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,EAAE,CAAA;IACT,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAA;AAC1B,CAAC"} |
-32
| import { onCleanup } from 'solid-js' | ||
| import { createStore, reconcile } from 'solid-js/store' | ||
| import type { AnyUpdater, Store } from '@tanstack/store' | ||
| import type { Accessor } from 'solid-js' | ||
| export * from '@tanstack/store' | ||
| export type NoInfer<T> = [T][T extends any ? 0 : never] | ||
| export function useStore< | ||
| TState, | ||
| TSelected = NoInfer<TState>, | ||
| TUpdater extends AnyUpdater = AnyUpdater, | ||
| >( | ||
| store: Store<TState, TUpdater>, | ||
| selector: (state: NoInfer<TState>) => TSelected = (d) => d as any, | ||
| ): Accessor<TSelected> { | ||
| const [slice, setSlice] = createStore({ | ||
| value: selector(store.state), | ||
| }) | ||
| const unsub = store.subscribe(() => { | ||
| const newValue = selector(store.state) | ||
| setSlice('value', reconcile(newValue)) | ||
| }) | ||
| onCleanup(() => { | ||
| unsub() | ||
| }) | ||
| return () => slice.value | ||
| } |
9853
108.71%12
100%98
108.51%+ Added
- Removed
Updated