@tamagui/use-store 1.32.2 → 1.32.3
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/useAsyncExternalStore.js +8 -6
- package/dist/cjs/useAsyncExternalStore.js.map +1 -1
- package/dist/cjs/useStore.js +1 -1
- package/dist/esm/useAsyncExternalStore.js +8 -6
- package/dist/esm/useAsyncExternalStore.js.map +1 -1
- package/dist/esm/useStore.js +1 -1
- package/package.json +2 -2
- package/src/useAsyncExternalStore.tsx +8 -6
- package/src/useStore.tsx +1 -1
- package/types/useAsyncExternalStore.d.ts.map +1 -1
|
@@ -24,13 +24,15 @@ module.exports = __toCommonJS(useAsyncExternalStore_exports);
|
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
function useAsyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
26
26
|
const [storeState, setStoreState] = (0, import_react.useState)(getServerSnapshot);
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (typeof document !== "undefined") {
|
|
28
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
29
|
+
return subscribe((next) => {
|
|
30
|
+
(0, import_react.startTransition)(() => {
|
|
31
|
+
setStoreState(getSnapshot(next));
|
|
32
|
+
});
|
|
31
33
|
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
+
}, [subscribe]);
|
|
35
|
+
}
|
|
34
36
|
return storeState;
|
|
35
37
|
}
|
|
36
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useAsyncExternalStore.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2D;AAEpD,SAAS,sBACd,WACA,aACA,mBACA;AACA,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,iBAAiB;AAE9D,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2D;AAEpD,SAAS,sBACd,WACA,aACA,mBACA;AACA,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,iBAAiB;AAE9D,MAAI,OAAO,aAAa,aAAa;AACnC,sCAAgB,MAAM;AACpB,aAAO,UAAU,CAAC,SAAc;AAC9B,0CAAgB,MAAM;AACpB,wBAAc,YAAY,IAAI,CAAC;AAAA,QACjC,CAAC;AAAA,MACH,CAAC;AAAA,IACH,GAAG,CAAC,SAAS,CAAC;AAAA,EAChB;AAEA,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/cjs/useStore.js
CHANGED
|
@@ -41,7 +41,7 @@ var import_Store = require("./Store");
|
|
|
41
41
|
var import_useAsyncExternalStore = require("./useAsyncExternalStore");
|
|
42
42
|
var import_useStoreDebug = require("./useStoreDebug");
|
|
43
43
|
const idFn = (_) => _;
|
|
44
|
-
const shouldUseSyncDefault = typeof window
|
|
44
|
+
const shouldUseSyncDefault = typeof window === "undefined" || !window.location.hash.includes(`use-async-store`);
|
|
45
45
|
function useStore(StoreKlass, props, options = import_constants.defaultOptions) {
|
|
46
46
|
const selectorCb = (0, import_react.useCallback)(options.selector || idFn, []);
|
|
47
47
|
const selector = options.selector ? selectorCb : options.selector;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { startTransition, useLayoutEffect, useState } from "react";
|
|
2
2
|
function useAsyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
3
3
|
const [storeState, setStoreState] = useState(getServerSnapshot);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
if (typeof document !== "undefined") {
|
|
5
|
+
useLayoutEffect(() => {
|
|
6
|
+
return subscribe((next) => {
|
|
7
|
+
startTransition(() => {
|
|
8
|
+
setStoreState(getSnapshot(next));
|
|
9
|
+
});
|
|
8
10
|
});
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
+
}, [subscribe]);
|
|
12
|
+
}
|
|
11
13
|
return storeState;
|
|
12
14
|
}
|
|
13
15
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useAsyncExternalStore.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iBAAiB,iBAAiB,gBAAgB;AAEpD,SAAS,sBACd,WACA,aACA,mBACA;AACA,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,iBAAiB;AAE9D,
|
|
4
|
+
"mappings": "AAAA,SAAS,iBAAiB,iBAAiB,gBAAgB;AAEpD,SAAS,sBACd,WACA,aACA,mBACA;AACA,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,iBAAiB;AAE9D,MAAI,OAAO,aAAa,aAAa;AACnC,oBAAgB,MAAM;AACpB,aAAO,UAAU,CAAC,SAAc;AAC9B,wBAAgB,MAAM;AACpB,wBAAc,YAAY,IAAI,CAAC;AAAA,QACjC,CAAC;AAAA,MACH,CAAC;AAAA,IACH,GAAG,CAAC,SAAS,CAAC;AAAA,EAChB;AAEA,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/useStore.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import { useAsyncExternalStore } from "./useAsyncExternalStore";
|
|
19
19
|
import { DebugStores, useCurrentComponent } from "./useStoreDebug";
|
|
20
20
|
const idFn = (_) => _;
|
|
21
|
-
const shouldUseSyncDefault = typeof window
|
|
21
|
+
const shouldUseSyncDefault = typeof window === "undefined" || !window.location.hash.includes(`use-async-store`);
|
|
22
22
|
function useStore(StoreKlass, props, options = defaultOptions) {
|
|
23
23
|
const selectorCb = useCallback(options.selector || idFn, []);
|
|
24
24
|
const selector = options.selector ? selectorCb : options.selector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-store",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.3",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@tamagui/build": "1.32.
|
|
30
|
+
"@tamagui/build": "1.32.3",
|
|
31
31
|
"@testing-library/react": "^13.4.0",
|
|
32
32
|
"react": "^18.2.0",
|
|
33
33
|
"vitest": "^0.26.3"
|
|
@@ -7,13 +7,15 @@ export function useAsyncExternalStore(
|
|
|
7
7
|
) {
|
|
8
8
|
const [storeState, setStoreState] = useState(getServerSnapshot)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
if (typeof document !== 'undefined') {
|
|
11
|
+
useLayoutEffect(() => {
|
|
12
|
+
return subscribe((next: any) => {
|
|
13
|
+
startTransition(() => {
|
|
14
|
+
setStoreState(getSnapshot(next))
|
|
15
|
+
})
|
|
14
16
|
})
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
+
}, [subscribe])
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
return storeState
|
|
19
21
|
}
|
package/src/useStore.tsx
CHANGED
|
@@ -24,7 +24,7 @@ import { DebugStores, useCurrentComponent } from './useStoreDebug'
|
|
|
24
24
|
|
|
25
25
|
const idFn = (_) => _
|
|
26
26
|
const shouldUseSyncDefault =
|
|
27
|
-
typeof window
|
|
27
|
+
typeof window === 'undefined' || !window.location.hash.includes(`use-async-store`)
|
|
28
28
|
|
|
29
29
|
// no singleton, just react
|
|
30
30
|
export function useStore<A extends Store<B>, B extends Object>(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncExternalStore.d.ts","sourceRoot":"","sources":["../src/useAsyncExternalStore.tsx"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,IAAI,EACvC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,EAChC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"useAsyncExternalStore.d.ts","sourceRoot":"","sources":["../src/useAsyncExternalStore.tsx"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,IAAI,EACvC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,EAChC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,OAexC"}
|