@tanstack/solid-store 0.5.7 → 0.7.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/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +6 -2
- package/dist/esm/index.d.ts +6 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/source/index.d.ts +6 -2
- package/dist/source/index.jsx.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +14 -7
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.tsx"],"sourcesContent":["import { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.tsx"],"sourcesContent":["import { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport type { Derived, Store } from '@tanstack/store'\nimport type { Accessor } from 'solid-js'\n\nexport * from '@tanstack/store'\n\n/**\n * @private\n */\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: Store<TState, any>,\n selector?: (state: NoInfer<TState>) => TSelected,\n): Accessor<TSelected>\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: Derived<TState, any>,\n selector?: (state: NoInfer<TState>) => TSelected,\n): Accessor<TSelected>\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: Store<TState, any> | Derived<TState, any>,\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":";;;;;AAoBO,SAASA,SACdC,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,UAAA;AAAA,EAAA,CACP;AAED,SAAO,MAAMT,MAAMG;AACrB;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Derived, Store } from '@tanstack/store';
|
|
2
2
|
import { Accessor } from 'solid-js';
|
|
3
3
|
export * from '@tanstack/store';
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
4
7
|
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
5
|
-
export declare function useStore<TState, TSelected = NoInfer<TState
|
|
8
|
+
export declare function useStore<TState, TSelected = NoInfer<TState>>(store: Store<TState, any>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>;
|
|
9
|
+
export declare function useStore<TState, TSelected = NoInfer<TState>>(store: Derived<TState, any>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Derived, Store } from '@tanstack/store';
|
|
2
2
|
import { Accessor } from 'solid-js';
|
|
3
3
|
export * from '@tanstack/store';
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
4
7
|
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
5
|
-
export declare function useStore<TState, TSelected = NoInfer<TState
|
|
8
|
+
export declare function useStore<TState, TSelected = NoInfer<TState>>(store: Store<TState, any>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>;
|
|
9
|
+
export declare function useStore<TState, TSelected = NoInfer<TState>>(store: Derived<TState, any>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>;
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport type { Derived, Store } from '@tanstack/store'\nimport type { Accessor } from 'solid-js'\n\nexport * from '@tanstack/store'\n\n/**\n * @private\n */\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: Store<TState, any>,\n selector?: (state: NoInfer<TState>) => TSelected,\n): Accessor<TSelected>\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: Derived<TState, any>,\n selector?: (state: NoInfer<TState>) => TSelected,\n): Accessor<TSelected>\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: Store<TState, any> | Derived<TState, any>,\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":";;;AAoBO,SAASA,SACdC,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,UAAA;AAAA,EAAA,CACP;AAED,SAAO,MAAMT,MAAMG;AACrB;"}
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Derived, Store } from '@tanstack/store';
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
3
|
export * from '@tanstack/store';
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
4
7
|
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
5
|
-
export declare function useStore<TState, TSelected = NoInfer<TState
|
|
8
|
+
export declare function useStore<TState, TSelected = NoInfer<TState>>(store: Store<TState, any>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>;
|
|
9
|
+
export declare function useStore<TState, TSelected = NoInfer<TState>>(store: Derived<TState, any>, selector?: (state: NoInfer<TState>) => TSelected): Accessor<TSelected>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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;
|
|
1
|
+
{"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;AAe/B,MAAM,UAAU,QAAQ,CACtB,KAAgD,EAChD,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-store",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Framework agnostic type-safe store w/ reactive framework adapters",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"src"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tanstack/store": "0.
|
|
49
|
+
"@tanstack/store": "0.7.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"solid-js": "^1.9.3",
|
|
53
|
-
"vite-plugin-solid": "^2.
|
|
53
|
+
"vite-plugin-solid": "^2.11.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"solid-js": "^1.6.0"
|
package/src/index.tsx
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { onCleanup } from 'solid-js'
|
|
2
2
|
import { createStore, reconcile } from 'solid-js/store'
|
|
3
|
-
import type {
|
|
3
|
+
import type { Derived, Store } from '@tanstack/store'
|
|
4
4
|
import type { Accessor } from 'solid-js'
|
|
5
5
|
|
|
6
6
|
export * from '@tanstack/store'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
8
11
|
export type NoInfer<T> = [T][T extends any ? 0 : never]
|
|
9
12
|
|
|
10
|
-
export function useStore<
|
|
11
|
-
TState,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
store:
|
|
13
|
+
export function useStore<TState, TSelected = NoInfer<TState>>(
|
|
14
|
+
store: Store<TState, any>,
|
|
15
|
+
selector?: (state: NoInfer<TState>) => TSelected,
|
|
16
|
+
): Accessor<TSelected>
|
|
17
|
+
export function useStore<TState, TSelected = NoInfer<TState>>(
|
|
18
|
+
store: Derived<TState, any>,
|
|
19
|
+
selector?: (state: NoInfer<TState>) => TSelected,
|
|
20
|
+
): Accessor<TSelected>
|
|
21
|
+
export function useStore<TState, TSelected = NoInfer<TState>>(
|
|
22
|
+
store: Store<TState, any> | Derived<TState, any>,
|
|
16
23
|
selector: (state: NoInfer<TState>) => TSelected = (d) => d as any,
|
|
17
24
|
): Accessor<TSelected> {
|
|
18
25
|
const [slice, setSlice] = createStore({
|