@tamagui/use-window-dimensions 1.0.1-beta.185

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,45 @@
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_react = require("react");
25
+ var import_react_native = require("react-native");
26
+ let lastKnownValue = {
27
+ fontScale: 1,
28
+ height: 800,
29
+ width: 600,
30
+ scale: 1
31
+ };
32
+ function useWindowDimensions() {
33
+ const next = (0, import_react_native.useWindowDimensions)();
34
+ const [current, setCurrent] = (0, import_react.useState)(lastKnownValue);
35
+ if (next !== current) {
36
+ setCurrent(next);
37
+ lastKnownValue = next;
38
+ }
39
+ return current;
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ useWindowDimensions
44
+ });
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["import { useState } from 'react'\nimport { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'\n\n/**\n * SSR safe useWindowDimensions\n */\n\nlet lastKnownValue: ScaledSize = {\n fontScale: 1,\n height: 800,\n width: 600,\n scale: 1,\n}\n\nexport function useWindowDimensions() {\n const next = useWindowDimensionsRN()\n const [current, setCurrent] = useState(lastKnownValue)\n\n if (next !== current) {\n setCurrent(next)\n lastKnownValue = next\n }\n\n return current\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,0BAAyE;AAMzE,IAAI,iBAA6B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,WAAO,oBAAAA,qBAAsB;AACnC,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,cAAc;AAErD,MAAI,SAAS,SAAS;AACpB,eAAW,IAAI;AACf,qBAAiB;AAAA,EACnB;AAEA,SAAO;AACT;",
6
+ "names": ["useWindowDimensionsRN"]
7
+ }
@@ -0,0 +1,21 @@
1
+ import { useState } from "react";
2
+ import { useWindowDimensions as useWindowDimensionsRN } from "react-native";
3
+ let lastKnownValue = {
4
+ fontScale: 1,
5
+ height: 800,
6
+ width: 600,
7
+ scale: 1
8
+ };
9
+ function useWindowDimensions() {
10
+ const next = useWindowDimensionsRN();
11
+ const [current, setCurrent] = useState(lastKnownValue);
12
+ if (next !== current) {
13
+ setCurrent(next);
14
+ lastKnownValue = next;
15
+ }
16
+ return current;
17
+ }
18
+ export {
19
+ useWindowDimensions
20
+ };
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["import { useState } from 'react'\nimport { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'\n\n/**\n * SSR safe useWindowDimensions\n */\n\nlet lastKnownValue: ScaledSize = {\n fontScale: 1,\n height: 800,\n width: 600,\n scale: 1,\n}\n\nexport function useWindowDimensions() {\n const next = useWindowDimensionsRN()\n const [current, setCurrent] = useState(lastKnownValue)\n\n if (next !== current) {\n setCurrent(next)\n lastKnownValue = next\n }\n\n return current\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAqB,uBAAuB,6BAA6B;AAMzE,IAAI,iBAA6B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,OAAO,sBAAsB;AACnC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,cAAc;AAErD,MAAI,SAAS,SAAS;AACpB,eAAW,IAAI;AACf,qBAAiB;AAAA,EACnB;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@tamagui/use-window-dimensions",
3
+ "version": "1.0.1-beta.185",
4
+ "types": "./types/index.d.ts",
5
+ "main": "dist/cjs",
6
+ "module": "dist/esm",
7
+ "files": [
8
+ "src",
9
+ "types",
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tamagui-build",
14
+ "watch": "tamagui-build --watch",
15
+ "lint": "eslint",
16
+ "lint:fix": "yarn lint --fix",
17
+ "clean": "tamagui-build clean",
18
+ "clean:build": "tamagui-build clean:build"
19
+ },
20
+ "dependencies": {
21
+ "@tamagui/use-debounce": "^1.0.1-beta.185",
22
+ "@tamagui/use-force-update": "^1.0.1-beta.185",
23
+ "react": "*"
24
+ },
25
+ "devDependencies": {
26
+ "@tamagui/build": "^1.0.1-beta.185",
27
+ "@types/react": "^18.0.15",
28
+ "react-native": "*"
29
+ },
30
+ "peerDependencies": {
31
+ "react-native": "*"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
37
+ }
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { useState } from 'react'
2
+ import { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'
3
+
4
+ /**
5
+ * SSR safe useWindowDimensions
6
+ */
7
+
8
+ let lastKnownValue: ScaledSize = {
9
+ fontScale: 1,
10
+ height: 800,
11
+ width: 600,
12
+ scale: 1,
13
+ }
14
+
15
+ export function useWindowDimensions() {
16
+ const next = useWindowDimensionsRN()
17
+ const [current, setCurrent] = useState(lastKnownValue)
18
+
19
+ if (next !== current) {
20
+ setCurrent(next)
21
+ lastKnownValue = next
22
+ }
23
+
24
+ return current
25
+ }
@@ -0,0 +1,3 @@
1
+ import { ScaledSize } from 'react-native';
2
+ export declare function useWindowDimensions(): ScaledSize;
3
+ //# sourceMappingURL=index.d.ts.map