@tamagui/use-window-dimensions 1.74.2 → 1.74.4
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.
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/constants";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
import { Dimensions } from "react-native";
|
|
4
|
+
const initialValue = {
|
|
5
|
+
height: 800,
|
|
6
|
+
width: 600
|
|
7
|
+
};
|
|
8
|
+
function configureInitialWindowDimensions(next) {
|
|
9
|
+
Object.assign(initialValue, next);
|
|
10
|
+
}
|
|
11
|
+
Dimensions.addEventListener("change", () => {
|
|
12
|
+
cbs.forEach((cb) => cb(window));
|
|
13
|
+
});
|
|
14
|
+
const cbs = /* @__PURE__ */ new Set();
|
|
15
|
+
function subscribe(cb) {
|
|
16
|
+
return cbs.add(cb), () => cbs.delete(cb);
|
|
17
|
+
}
|
|
18
|
+
function useWindowDimensions({
|
|
19
|
+
serverValue = initialValue
|
|
20
|
+
} = {}) {
|
|
21
|
+
return useSyncExternalStore(
|
|
22
|
+
subscribe,
|
|
23
|
+
() => Dimensions.get("window"),
|
|
24
|
+
() => isWeb ? serverValue : Dimensions.get("window")
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
configureInitialWindowDimensions,
|
|
29
|
+
useWindowDimensions
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,4BAA4B;AACrC,SAAS,kBAA8B;AAWvC,MAAM,eAAqB;AAAA,EACzB,QAAQ;AAAA,EACR,OAAO;AACT;AAEO,SAAS,iCAAiC,MAAY;AAC3D,SAAO,OAAO,cAAc,IAAI;AAClC;AAEA,WAAW,iBAAiB,UAAU,MAAM;AAC1C,MAAI,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;AAChC,CAAC;AAED,MAAM,MAAM,oBAAI,IAAc;AAI9B,SAAS,UAAU,IAAwB;AACzC,aAAI,IAAI,EAAE,GACH,MAAM,IAAI,OAAO,EAAE;AAC5B;AAEO,SAAS,oBAAoB;AAAA,EAClC,cAAc;AAChB,IAA4B,CAAC,GAAG;AAC9B,SAAO;AAAA,IACL;AAAA,IACA,MAAM,WAAW,IAAI,QAAQ;AAAA,IAC7B,MAAO,QAAQ,cAAc,WAAW,IAAI,QAAQ;AAAA,EACtD;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-window-dimensions",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.4",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@tamagui/constants": "1.74.
|
|
29
|
+
"@tamagui/constants": "1.74.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.74.
|
|
32
|
+
"@tamagui/build": "1.74.4",
|
|
33
33
|
"react": "^18.2.0",
|
|
34
34
|
"react-native": "^0.72.1"
|
|
35
35
|
},
|