@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 +46 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +24 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +24 -1
- package/dist/esm/index.mjs.map +2 -2
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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": "
|
|
6
|
-
"names": ["
|
|
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
|
|
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
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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,
|
|
6
|
-
"names": [
|
|
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/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import{useIsomorphicLayoutEffect
|
|
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
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -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,
|
|
6
|
-
"names": [
|
|
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.
|
|
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.
|
|
29
|
+
"@tamagui/constants": "1.14.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.14.
|
|
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"
|