pinia-react 1.1.2 → 1.2.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/dist/index.d.ts +4 -0
- package/dist/index.js +7 -4
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ interface StoreDefinition<Id extends string = string, S extends StateTree = Stat
|
|
|
40
40
|
* Id of the store. Used by map helpers.
|
|
41
41
|
*/
|
|
42
42
|
$id: Id;
|
|
43
|
+
/**
|
|
44
|
+
* Return to store for use within non-functional components
|
|
45
|
+
*/
|
|
46
|
+
$getStore: () => Store<Id, S, G, A>;
|
|
43
47
|
}
|
|
44
48
|
type PiniaPluginContext<Id extends string = string, S extends StateTree = StateTree, G = _GettersTree<S>, A = _ActionsTree> = {
|
|
45
49
|
options: DefineStoreOptions<Id, S, G, A>;
|
package/dist/index.js
CHANGED
|
@@ -93,9 +93,7 @@ function defineStore(id, options) {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
pinia._state.set(id, $state);
|
|
96
|
-
const store = reactive(Object.assign(baseStore, toRefs($state), Object.keys(actions ?? []).reduce((x, y) => Object.assign(x, { [y]:
|
|
97
|
-
return actions[y].call(store, ...args);
|
|
98
|
-
} }), {}), Object.keys(getters || {}).reduce((computedGetters, name) => {
|
|
96
|
+
const store = reactive(Object.assign(baseStore, toRefs($state), Object.keys(actions ?? []).reduce((x, y) => Object.assign(x, { [y]: (...args) => actions[y].call(store, ...args) }), {}), Object.keys(getters || {}).reduce((computedGetters, name) => {
|
|
99
97
|
computedGetters[name] = markRaw(computed(() => {
|
|
100
98
|
return getters?.[name].call(store, store);
|
|
101
99
|
}));
|
|
@@ -130,7 +128,7 @@ function defineStore(id, options) {
|
|
|
130
128
|
effectMap.delete(_id.current);
|
|
131
129
|
};
|
|
132
130
|
}, []);
|
|
133
|
-
useSyncExternalStore(subscribe, () => storeSnapshotRef.current, () =>
|
|
131
|
+
useSyncExternalStore(subscribe, () => storeSnapshotRef.current, () => storeSnapshotRef.current);
|
|
134
132
|
let effect = effectMap.get(_id.current);
|
|
135
133
|
if (!effect) {
|
|
136
134
|
const fn = () => {
|
|
@@ -152,6 +150,11 @@ function defineStore(id, options) {
|
|
|
152
150
|
return store;
|
|
153
151
|
}
|
|
154
152
|
useStore.$id = id;
|
|
153
|
+
useStore.$getStore = () => {
|
|
154
|
+
if (!pinia._store.has(id)) createStore();
|
|
155
|
+
const store = pinia._store.get(id);
|
|
156
|
+
return store;
|
|
157
|
+
};
|
|
155
158
|
return useStore;
|
|
156
159
|
}
|
|
157
160
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinia-react",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://github.com/savageKarl/pinia-react#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"prepare": "npx simple-git-hooks",
|
|
29
29
|
"build": "tsdown",
|
|
30
30
|
"dev": "tsdown --watch",
|
|
31
|
-
"playground": "vite --config playground/vite.config.ts",
|
|
31
|
+
"playground-react": "vite --config playground/react/vite.config.ts",
|
|
32
|
+
"playground-nextjs": "pnpm next dev ./playground/nextjs",
|
|
32
33
|
"test": "vitest",
|
|
33
34
|
"semantic-release": "semantic-release",
|
|
34
35
|
"format": "pnpm exec biome check --write"
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@types/react-dom": "^19.1.4",
|
|
62
63
|
"@vitejs/plugin-react": "^5.0.0",
|
|
63
64
|
"jsdom": "^26.1.0",
|
|
65
|
+
"next": "^15.4.6",
|
|
64
66
|
"semantic-release": "^24.2.7",
|
|
65
67
|
"simple-git-hooks": "^2.13.1",
|
|
66
68
|
"tsdown": "^0.13.3",
|