@tamagui/use-window-dimensions 1.14.0 → 1.14.2

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
@@ -1,2 +1,47 @@
1
- "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var l=(e,t)=>{for(var i in t)s(e,i,{get:t[i],enumerable:!0})},S=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of m(t))!f.call(e,o)&&o!==i&&s(e,o,{get:()=>t[o],enumerable:!(n=u(t,o))||n.enumerable});return e};var d=e=>S(s({},"__esModule",{value:!0}),e);var w={};l(w,{useWindowDimensions:()=>p});module.exports=d(w);var r=require("@tamagui/constants"),c=require("react"),a=require("react-native");const h={fontScale:1,height:800,width:600,scale:1};function p(){const e=(0,a.useWindowDimensions)();if(process.env.TAMAGUI_TARGET!="web")return e;const[t,i]=(0,c.useState)(h);return(0,r.useIsomorphicLayoutEffect)(()=>{i(e)},[e.height,e.width,e.fontScale,e.scale]),t}0&&(module.exports={useWindowDimensions});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ useWindowDimensions: () => useWindowDimensions
22
+ });
23
+ module.exports = __toCommonJS(src_exports);
24
+ var import_constants = require("@tamagui/constants");
25
+ var import_react = require("react");
26
+ var import_react_native = require("react-native");
27
+ const initialValue = {
28
+ fontScale: 1,
29
+ height: 800,
30
+ width: 600,
31
+ scale: 1
32
+ };
33
+ function useWindowDimensions() {
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);
38
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
39
+ setState(current);
40
+ }, [current.height, current.width, current.fontScale, current.scale]);
41
+ return state;
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ useWindowDimensions
46
+ });
2
47
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0C,8BAC1CC,EAAyB,iBACzBC,EAGO,wBAMP,MAAMC,EAA2B,CAC/B,UAAW,EACX,OAAQ,IACR,MAAO,IACP,MAAO,CACT,EAEO,SAASL,GAAsB,CACpC,MAAMM,KAAU,EAAAC,qBAAsB,EAEtC,GAAI,QAAQ,IAAI,gBAAkB,MAAO,OAAOD,EAEhD,KAAM,CAACE,EAAOC,CAAQ,KAAI,YAASJ,CAAY,EAE/C,sCAA0B,IAAM,CAC9BI,EAASH,CAAO,CAElB,EAAG,CAACA,EAAQ,OAAQA,EAAQ,MAAOA,EAAQ,UAAWA,EAAQ,KAAK,CAAC,EAE7DE,CACT",
6
- "names": ["src_exports", "__export", "useWindowDimensions", "__toCommonJS", "import_constants", "import_react", "import_react_native", "initialValue", "current", "useWindowDimensionsRN", "state", "setState"]
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
+ "names": ["useWindowDimensionsRN"]
7
7
  }
package/dist/esm/index.js CHANGED
@@ -1,2 +1,25 @@
1
- import{useIsomorphicLayoutEffect as o}from"@tamagui/constants";import{useState as s}from"react";import{useWindowDimensions as n}from"react-native";const r={fontScale:1,height:800,width:600,scale:1};function f(){const e=n();if(process.env.TAMAGUI_TARGET!="web")return e;const[t,i]=s(r);return o(()=>{i(e)},[e.height,e.width,e.fontScale,e.scale]),t}export{f as useWindowDimensions};
1
+ import { useIsomorphicLayoutEffect } from "@tamagui/constants";
2
+ import { useState } from "react";
3
+ import {
4
+ useWindowDimensions as useWindowDimensionsRN
5
+ } from "react-native";
6
+ const initialValue = {
7
+ fontScale: 1,
8
+ height: 800,
9
+ width: 600,
10
+ scale: 1
11
+ };
12
+ function useWindowDimensions() {
13
+ const current = useWindowDimensionsRN();
14
+ if (process.env.TAMAGUI_TARGET != "web")
15
+ return current;
16
+ const [state, setState] = useState(initialValue);
17
+ useIsomorphicLayoutEffect(() => {
18
+ setState(current);
19
+ }, [current.height, current.width, current.fontScale, current.scale]);
20
+ return state;
21
+ }
22
+ export {
23
+ useWindowDimensions
24
+ };
2
25
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
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,OAAS,6BAAAA,MAAiC,qBAC1C,OAAS,YAAAC,MAAgB,QACzB,OAEE,uBAAuBC,MAClB,eAMP,MAAMC,EAA2B,CAC/B,UAAW,EACX,OAAQ,IACR,MAAO,IACP,MAAO,CACT,EAEO,SAASC,GAAsB,CACpC,MAAMC,EAAUH,EAAsB,EAEtC,GAAI,QAAQ,IAAI,gBAAkB,MAAO,OAAOG,EAEhD,KAAM,CAACC,EAAOC,CAAQ,EAAIN,EAASE,CAAY,EAE/C,OAAAH,EAA0B,IAAM,CAC9BO,EAASF,CAAO,CAElB,EAAG,CAACA,EAAQ,OAAQA,EAAQ,MAAOA,EAAQ,UAAWA,EAAQ,KAAK,CAAC,EAE7DC,CACT",
6
- "names": ["useIsomorphicLayoutEffect", "useState", "useWindowDimensionsRN", "initialValue", "useWindowDimensions", "current", "state", "setState"]
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
+ "names": []
7
7
  }
@@ -1,2 +1,25 @@
1
- import{useIsomorphicLayoutEffect as o}from"@tamagui/constants";import{useState as s}from"react";import{useWindowDimensions as n}from"react-native";const r={fontScale:1,height:800,width:600,scale:1};function f(){const e=n();if(process.env.TAMAGUI_TARGET!="web")return e;const[t,i]=s(r);return o(()=>{i(e)},[e.height,e.width,e.fontScale,e.scale]),t}export{f as useWindowDimensions};
1
+ import { useIsomorphicLayoutEffect } from "@tamagui/constants";
2
+ import { useState } from "react";
3
+ import {
4
+ useWindowDimensions as useWindowDimensionsRN
5
+ } from "react-native";
6
+ const initialValue = {
7
+ fontScale: 1,
8
+ height: 800,
9
+ width: 600,
10
+ scale: 1
11
+ };
12
+ function useWindowDimensions() {
13
+ const current = useWindowDimensionsRN();
14
+ if (process.env.TAMAGUI_TARGET != "web")
15
+ return current;
16
+ const [state, setState] = useState(initialValue);
17
+ useIsomorphicLayoutEffect(() => {
18
+ setState(current);
19
+ }, [current.height, current.width, current.fontScale, current.scale]);
20
+ return state;
21
+ }
22
+ export {
23
+ useWindowDimensions
24
+ };
2
25
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
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,OAAS,6BAAAA,MAAiC,qBAC1C,OAAS,YAAAC,MAAgB,QACzB,OAEE,uBAAuBC,MAClB,eAMP,MAAMC,EAA2B,CAC/B,UAAW,EACX,OAAQ,IACR,MAAO,IACP,MAAO,CACT,EAEO,SAASC,GAAsB,CACpC,MAAMC,EAAUH,EAAsB,EAEtC,GAAI,QAAQ,IAAI,gBAAkB,MAAO,OAAOG,EAEhD,KAAM,CAACC,EAAOC,CAAQ,EAAIN,EAASE,CAAY,EAE/C,OAAAH,EAA0B,IAAM,CAC9BO,EAASF,CAAO,CAElB,EAAG,CAACA,EAAQ,OAAQA,EAAQ,MAAOA,EAAQ,UAAWA,EAAQ,KAAK,CAAC,EAE7DC,CACT",
6
- "names": ["useIsomorphicLayoutEffect", "useState", "useWindowDimensionsRN", "initialValue", "useWindowDimensions", "current", "state", "setState"]
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
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-window-dimensions",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
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.14.0"
29
+ "@tamagui/constants": "1.14.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@tamagui/build": "1.14.0",
32
+ "@tamagui/build": "1.14.2",
33
33
  "@types/react": "^18.0.15",
34
34
  "react": "^18.2.0",
35
35
  "react-native": "^0.71.4"