@tamagui/use-window-dimensions 1.0.1-beta.186 → 1.0.1-beta.188
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.js +5 -9
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +5 -9
- package/dist/esm/index.js.map +2 -2
- package/package.json +3 -4
- package/src/index.ts +5 -11
package/dist/cjs/index.js
CHANGED
|
@@ -21,22 +21,18 @@ __export(src_exports, {
|
|
|
21
21
|
useWindowDimensions: () => useWindowDimensions
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(src_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_use_did_finish_ssr = require("@tamagui/use-did-finish-ssr");
|
|
25
25
|
var import_react_native = require("react-native");
|
|
26
|
-
|
|
26
|
+
const initialValue = {
|
|
27
27
|
fontScale: 1,
|
|
28
28
|
height: 800,
|
|
29
29
|
width: 600,
|
|
30
30
|
scale: 1
|
|
31
31
|
};
|
|
32
32
|
function useWindowDimensions() {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
setCurrent(next);
|
|
37
|
-
lastKnownValue = next;
|
|
38
|
-
}
|
|
39
|
-
return current;
|
|
33
|
+
const current = (0, import_react_native.useWindowDimensions)();
|
|
34
|
+
const didFinishSSR = (0, import_use_did_finish_ssr.useDidFinishSSR)();
|
|
35
|
+
return didFinishSSR ? current : initialValue;
|
|
40
36
|
}
|
|
41
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
38
|
0 && (module.exports = {
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'\nimport { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'\n\n/**\n * SSR safe useWindowDimensions\n */\n\nconst initialValue: ScaledSize = {\n fontScale: 1,\n height: 800,\n width: 600,\n scale: 1,\n}\n\nexport function useWindowDimensions() {\n const current = useWindowDimensionsRN()\n const didFinishSSR = useDidFinishSSR()\n return didFinishSSR ? current : initialValue\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAgC;AAChC,0BAAyE;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,cAAU,oBAAAA,qBAAsB;AACtC,QAAM,mBAAe,2CAAgB;AACrC,SAAO,eAAe,UAAU;AAClC;",
|
|
6
6
|
"names": ["useWindowDimensionsRN"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDidFinishSSR } from "@tamagui/use-did-finish-ssr";
|
|
2
2
|
import { useWindowDimensions as useWindowDimensionsRN } from "react-native";
|
|
3
|
-
|
|
3
|
+
const initialValue = {
|
|
4
4
|
fontScale: 1,
|
|
5
5
|
height: 800,
|
|
6
6
|
width: 600,
|
|
7
7
|
scale: 1
|
|
8
8
|
};
|
|
9
9
|
function useWindowDimensions() {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
setCurrent(next);
|
|
14
|
-
lastKnownValue = next;
|
|
15
|
-
}
|
|
16
|
-
return current;
|
|
10
|
+
const current = useWindowDimensionsRN();
|
|
11
|
+
const didFinishSSR = useDidFinishSSR();
|
|
12
|
+
return didFinishSSR ? current : initialValue;
|
|
17
13
|
}
|
|
18
14
|
export {
|
|
19
15
|
useWindowDimensions
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'\nimport { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'\n\n/**\n * SSR safe useWindowDimensions\n */\n\nconst initialValue: ScaledSize = {\n fontScale: 1,\n height: 800,\n width: 600,\n scale: 1,\n}\n\nexport function useWindowDimensions() {\n const current = useWindowDimensionsRN()\n const didFinishSSR = useDidFinishSSR()\n return didFinishSSR ? current : initialValue\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAqB,uBAAuB,6BAA6B;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,UAAU,sBAAsB;AACtC,QAAM,eAAe,gBAAgB;AACrC,SAAO,eAAe,UAAU;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-window-dimensions",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.188",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,12 +18,11 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/use-
|
|
22
|
-
"@tamagui/use-force-update": "^1.0.1-beta.186",
|
|
21
|
+
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.188",
|
|
23
22
|
"react": "*"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
25
|
+
"@tamagui/build": "^1.0.1-beta.188",
|
|
27
26
|
"@types/react": "^18.0.15",
|
|
28
27
|
"react-native": "*"
|
|
29
28
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'
|
|
2
2
|
import { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* SSR safe useWindowDimensions
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const initialValue: ScaledSize = {
|
|
9
9
|
fontScale: 1,
|
|
10
10
|
height: 800,
|
|
11
11
|
width: 600,
|
|
@@ -13,13 +13,7 @@ let lastKnownValue: ScaledSize = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function useWindowDimensions() {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
if (next !== current) {
|
|
20
|
-
setCurrent(next)
|
|
21
|
-
lastKnownValue = next
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return current
|
|
16
|
+
const current = useWindowDimensionsRN()
|
|
17
|
+
const didFinishSSR = useDidFinishSSR()
|
|
18
|
+
return didFinishSSR ? current : initialValue
|
|
25
19
|
}
|