@tamagui/use-window-dimensions 1.2.7 → 1.2.8

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 CHANGED
@@ -31,8 +31,10 @@ const initialValue = {
31
31
  scale: 1
32
32
  };
33
33
  function useWindowDimensions() {
34
- const [state, setState] = (0, import_react.useState)(initialValue);
35
34
  const current = (0, import_react_native.useWindowDimensions)();
35
+ if (process.env.TAMAGUI_TARGET != "web")
36
+ return current;
37
+ const [state, setState] = (0, import_react.useState)(initialValue);
36
38
  (0, import_constants.useIsomorphicLayoutEffect)(() => {
37
39
  setState(current);
38
40
  }, [current.height, current.width, current.fontScale, current.scale]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\nimport {\n ScaledSize,\n useWindowDimensions as useWindowDimensionsRN,\n} 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 [state, setState] = useState(initialValue)\n const current = useWindowDimensionsRN()\n\n useIsomorphicLayoutEffect(() => {\n setState(current)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [current.height, current.width, current.fontScale, current.scale])\n\n return state\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAyB;AACzB,0BAGO;AAMP,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,YAAY;AAC/C,QAAM,cAAU,oBAAAA,qBAAsB;AAEtC,kDAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
4
+ "sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\nimport {\n ScaledSize,\n useWindowDimensions as useWindowDimensionsRN\n} 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 \n if (process.env.TAMAGUI_TARGET != 'web') return current\n \n const [state, setState] = useState(initialValue)\n\n useIsomorphicLayoutEffect(() => {\n setState(current)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [current.height, current.width, current.fontScale, current.scale])\n\n return state\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAyB;AACzB,0BAGO;AAMP,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,cAAU,oBAAAA,qBAAsB;AAEtC,MAAI,QAAQ,IAAI,kBAAkB;AAAO,WAAO;AAEhD,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,YAAY;AAE/C,kDAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
6
6
  "names": ["useWindowDimensionsRN"]
7
7
  }
package/dist/esm/index.js CHANGED
@@ -10,8 +10,10 @@ const initialValue = {
10
10
  scale: 1
11
11
  };
12
12
  function useWindowDimensions() {
13
- const [state, setState] = useState(initialValue);
14
13
  const current = useWindowDimensionsRN();
14
+ if (process.env.TAMAGUI_TARGET != "web")
15
+ return current;
16
+ const [state, setState] = useState(initialValue);
15
17
  useIsomorphicLayoutEffect(() => {
16
18
  setState(current);
17
19
  }, [current.height, current.width, current.fontScale, current.scale]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\nimport {\n ScaledSize,\n useWindowDimensions as useWindowDimensionsRN,\n} 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 [state, setState] = useState(initialValue)\n const current = useWindowDimensionsRN()\n\n useIsomorphicLayoutEffect(() => {\n setState(current)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [current.height, current.width, current.fontScale, current.scale])\n\n return state\n}\n"],
5
- "mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB;AAAA,EAEE,uBAAuB;AAAA,OAClB;AAMP,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,YAAY;AAC/C,QAAM,UAAU,sBAAsB;AAEtC,4BAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
4
+ "sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\nimport {\n ScaledSize,\n useWindowDimensions as useWindowDimensionsRN\n} 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 \n if (process.env.TAMAGUI_TARGET != 'web') return current\n \n const [state, setState] = useState(initialValue)\n\n useIsomorphicLayoutEffect(() => {\n setState(current)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [current.height, current.width, current.fontScale, current.scale])\n\n return state\n}\n"],
5
+ "mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB;AAAA,EAEE,uBAAuB;AAAA,OAClB;AAMP,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,UAAU,sBAAsB;AAEtC,MAAI,QAAQ,IAAI,kBAAkB;AAAO,WAAO;AAEhD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,YAAY;AAE/C,4BAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
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.2.7",
3
+ "version": "1.2.8",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -18,10 +18,10 @@
18
18
  "clean:build": "tamagui-build clean:build"
19
19
  },
20
20
  "dependencies": {
21
- "@tamagui/constants": "^1.2.7"
21
+ "@tamagui/constants": "^1.2.8"
22
22
  },
23
23
  "devDependencies": {
24
- "@tamagui/build": "^1.2.7",
24
+ "@tamagui/build": "^1.2.8",
25
25
  "@types/react": "^18.0.15",
26
26
  "react": "^18.2.0",
27
27
  "react-native": "*"
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import { useIsomorphicLayoutEffect } from '@tamagui/constants'
2
2
  import { useState } from 'react'
3
3
  import {
4
4
  ScaledSize,
5
- useWindowDimensions as useWindowDimensionsRN,
5
+ useWindowDimensions as useWindowDimensionsRN
6
6
  } from 'react-native'
7
7
 
8
8
  /**
@@ -17,8 +17,11 @@ const initialValue: ScaledSize = {
17
17
  }
18
18
 
19
19
  export function useWindowDimensions() {
20
- const [state, setState] = useState(initialValue)
21
20
  const current = useWindowDimensionsRN()
21
+
22
+ if (process.env.TAMAGUI_TARGET != 'web') return current
23
+
24
+ const [state, setState] = useState(initialValue)
22
25
 
23
26
  useIsomorphicLayoutEffect(() => {
24
27
  setState(current)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAEX,MAAM,cAAc,CAAA;AAarB,wBAAgB,mBAAmB,eAUlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAEX,MAAM,cAAc,CAAA;AAarB,wBAAgB,mBAAmB,eAalC"}