@tamagui/constants 1.0.1-beta.187

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,74 @@
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 constants_exports = {};
20
+ __export(constants_exports, {
21
+ isAndroid: () => isAndroid,
22
+ isChrome: () => isChrome,
23
+ isClient: () => isClient,
24
+ isIOS: () => isIOS,
25
+ isRSC: () => isRSC,
26
+ isServer: () => isServer,
27
+ isTouchable: () => isTouchable,
28
+ isWeb: () => isWeb,
29
+ isWebTouchable: () => isWebTouchable,
30
+ isWindowDefined: () => isWindowDefined,
31
+ useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect
32
+ });
33
+ module.exports = __toCommonJS(constants_exports);
34
+ var import_react = require("react");
35
+ var import_react_native = require("react-native");
36
+ const import_meta = {};
37
+ var _a, _b;
38
+ const isAndroid = ((_a = import_react_native.Platform) == null ? void 0 : _a.OS) === "android";
39
+ const isIOS = ((_b = import_react_native.Platform) == null ? void 0 : _b.OS) === "ios";
40
+ const isWeb = process.env.TAMAGUI_TARGET === "web";
41
+ const isWindowDefined = typeof window !== "undefined";
42
+ const isServer = isWeb && !isWindowDefined;
43
+ const isClient = isWeb && isWindowDefined;
44
+ const isRSC = process.env.ENABLE_RSC ? import_meta.env ? import_meta.env.SSR : false : false;
45
+ const idFn = () => {
46
+ };
47
+ const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? import_react.useEffect : import_react.useLayoutEffect;
48
+ const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
49
+ const isWebTouchable = isClient && "ontouchstart" in window;
50
+ const isTouchable = !isWeb || isWebTouchable;
51
+ if (process.env.NODE_ENV === "development") {
52
+ if (!process.env.TAMAGUI_TARGET) {
53
+ console.warn(`Must set TAMAGUI_TARGET to "web" or "native"`);
54
+ } else if (isClient && process.env.TAMAGUI_TARGET !== "web" && process.env.TAMAGUI_IGNORE_TARGET !== "1") {
55
+ console.warn(
56
+ `Must set TAMAGUI_TARGET to "web" for web apps - if you have window defined outside of the browser, set TAMAGUI_IGNORE_TARGET=1 to hide this`
57
+ );
58
+ }
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ isAndroid,
63
+ isChrome,
64
+ isClient,
65
+ isIOS,
66
+ isRSC,
67
+ isServer,
68
+ isTouchable,
69
+ isWeb,
70
+ isWebTouchable,
71
+ isWindowDefined,
72
+ useIsomorphicLayoutEffect
73
+ });
74
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/constants.ts"],
4
+ "sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = process.env.TAMAGUI_TARGET === 'web'\nexport const isWindowDefined = typeof window !== 'undefined'\nexport const isServer = isWeb && !isWindowDefined\nexport const isClient = isWeb && isWindowDefined\n\n// may want to move to VITE_RSC_BUILD\nexport const isRSC = process.env.ENABLE_RSC\n ? // note this is statically analyzed so no funny business, just access it without optional chaining\n // @ts-ignore\n import.meta.env\n ? // @ts-ignore\n import.meta.env.SSR\n : false\n : false\n\nconst idFn = () => {}\nexport const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const isWebTouchable = isClient && 'ontouchstart' in window\nexport const isTouchable = !isWeb || isWebTouchable\n\nif (process.env.NODE_ENV === 'development') {\n if (!process.env.TAMAGUI_TARGET) {\n // eslint-disable-next-line no-console\n console.warn(`Must set TAMAGUI_TARGET to \"web\" or \"native\"`)\n } else if (\n isClient &&\n process.env.TAMAGUI_TARGET !== 'web' &&\n process.env.TAMAGUI_IGNORE_TARGET !== '1'\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n `Must set TAMAGUI_TARGET to \"web\" for web apps - if you have window defined outside of the browser, set TAMAGUI_IGNORE_TARGET=1 to hide this`\n )\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,0BAAyB;AADzB;AAAA;AAGO,MAAM,cAAY,yDAAU,QAAO;AACnC,MAAM,UAAQ,yDAAU,QAAO;AAC/B,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,kBAAkB,OAAO,WAAW;AAC1C,MAAM,WAAW,SAAS,CAAC;AAC3B,MAAM,WAAW,SAAS;AAG1B,MAAM,QAAQ,QAAQ,IAAI,aAG7B,YAAY,MAEV,YAAY,IAAI,MAChB,QACF;AAEJ,MAAM,OAAO,MAAM;AAAC;AACb,MAAM,4BAA4B,QAAQ,OAAO,WAAW,yBAAY;AACxE,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,iBAAiB,YAAY,kBAAkB;AACrD,MAAM,cAAc,CAAC,SAAS;AAErC,IAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,MAAI,CAAC,QAAQ,IAAI,gBAAgB;AAE/B,YAAQ,KAAK,8CAA8C;AAAA,EAC7D,WACE,YACA,QAAQ,IAAI,mBAAmB,SAC/B,QAAQ,IAAI,0BAA0B,KACtC;AAEA,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,62 @@
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 constants_native_exports = {};
20
+ __export(constants_native_exports, {
21
+ isAndroid: () => isAndroid,
22
+ isChrome: () => isChrome,
23
+ isClient: () => isClient,
24
+ isIOS: () => isIOS,
25
+ isRSC: () => isRSC,
26
+ isServer: () => isServer,
27
+ isTouchable: () => isTouchable,
28
+ isWeb: () => isWeb,
29
+ isWebTouchable: () => isWebTouchable,
30
+ isWindowDefined: () => isWindowDefined,
31
+ useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect
32
+ });
33
+ module.exports = __toCommonJS(constants_native_exports);
34
+ var import_react = require("react");
35
+ var import_react_native = require("react-native");
36
+ var _a, _b;
37
+ const isAndroid = ((_a = import_react_native.Platform) == null ? void 0 : _a.OS) === "android";
38
+ const isIOS = ((_b = import_react_native.Platform) == null ? void 0 : _b.OS) === "ios";
39
+ const isWeb = false;
40
+ const isWindowDefined = false;
41
+ const isServer = false;
42
+ const isClient = false;
43
+ const isRSC = false;
44
+ const useIsomorphicLayoutEffect = import_react.useLayoutEffect;
45
+ const isChrome = false;
46
+ const isWebTouchable = false;
47
+ const isTouchable = true;
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ isAndroid,
51
+ isChrome,
52
+ isClient,
53
+ isIOS,
54
+ isRSC,
55
+ isServer,
56
+ isTouchable,
57
+ isWeb,
58
+ isWebTouchable,
59
+ isWindowDefined,
60
+ useIsomorphicLayoutEffect
61
+ });
62
+ //# sourceMappingURL=constants.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/constants.native.ts"],
4
+ "sourcesContent": ["import { useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = false\nexport const isWindowDefined = false\nexport const isServer = false\nexport const isClient = false\nexport const isRSC = false\nexport const useIsomorphicLayoutEffect = useLayoutEffect\nexport const isChrome = false\nexport const isWebTouchable = false\nexport const isTouchable = true\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,0BAAyB;AADzB;AAGO,MAAM,cAAY,yDAAU,QAAO;AACnC,MAAM,UAAQ,yDAAU,QAAO;AAC/B,MAAM,QAAQ;AACd,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,4BAA4B;AAClC,MAAM,WAAW;AACjB,MAAM,iBAAiB;AACvB,MAAM,cAAc;",
6
+ "names": []
7
+ }
@@ -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,39 @@
1
+ var _a, _b;
2
+ import { useEffect, useLayoutEffect } from "react";
3
+ import { Platform } from "react-native";
4
+ const isAndroid = ((_a = Platform) == null ? void 0 : _a.OS) === "android";
5
+ const isIOS = ((_b = Platform) == null ? void 0 : _b.OS) === "ios";
6
+ const isWeb = process.env.TAMAGUI_TARGET === "web";
7
+ const isWindowDefined = typeof window !== "undefined";
8
+ const isServer = isWeb && !isWindowDefined;
9
+ const isClient = isWeb && isWindowDefined;
10
+ const isRSC = process.env.ENABLE_RSC ? import.meta.env ? import.meta.env.SSR : false : false;
11
+ const idFn = () => {
12
+ };
13
+ const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect;
14
+ const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
15
+ const isWebTouchable = isClient && "ontouchstart" in window;
16
+ const isTouchable = !isWeb || isWebTouchable;
17
+ if (process.env.NODE_ENV === "development") {
18
+ if (!process.env.TAMAGUI_TARGET) {
19
+ console.warn(`Must set TAMAGUI_TARGET to "web" or "native"`);
20
+ } else if (isClient && process.env.TAMAGUI_TARGET !== "web" && process.env.TAMAGUI_IGNORE_TARGET !== "1") {
21
+ console.warn(
22
+ `Must set TAMAGUI_TARGET to "web" for web apps - if you have window defined outside of the browser, set TAMAGUI_IGNORE_TARGET=1 to hide this`
23
+ );
24
+ }
25
+ }
26
+ export {
27
+ isAndroid,
28
+ isChrome,
29
+ isClient,
30
+ isIOS,
31
+ isRSC,
32
+ isServer,
33
+ isTouchable,
34
+ isWeb,
35
+ isWebTouchable,
36
+ isWindowDefined,
37
+ useIsomorphicLayoutEffect
38
+ };
39
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/constants.ts"],
4
+ "sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = process.env.TAMAGUI_TARGET === 'web'\nexport const isWindowDefined = typeof window !== 'undefined'\nexport const isServer = isWeb && !isWindowDefined\nexport const isClient = isWeb && isWindowDefined\n\n// may want to move to VITE_RSC_BUILD\nexport const isRSC = process.env.ENABLE_RSC\n ? // note this is statically analyzed so no funny business, just access it without optional chaining\n // @ts-ignore\n import.meta.env\n ? // @ts-ignore\n import.meta.env.SSR\n : false\n : false\n\nconst idFn = () => {}\nexport const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const isWebTouchable = isClient && 'ontouchstart' in window\nexport const isTouchable = !isWeb || isWebTouchable\n\nif (process.env.NODE_ENV === 'development') {\n if (!process.env.TAMAGUI_TARGET) {\n // eslint-disable-next-line no-console\n console.warn(`Must set TAMAGUI_TARGET to \"web\" or \"native\"`)\n } else if (\n isClient &&\n process.env.TAMAGUI_TARGET !== 'web' &&\n process.env.TAMAGUI_IGNORE_TARGET !== '1'\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n `Must set TAMAGUI_TARGET to \"web\" for web apps - if you have window defined outside of the browser, set TAMAGUI_IGNORE_TARGET=1 to hide this`\n )\n }\n}\n"],
5
+ "mappings": "AAAA;AAAA,SAAS,WAAW,uBAAuB;AAC3C,SAAS,gBAAgB;AAElB,MAAM,cAAY,qCAAU,QAAO;AACnC,MAAM,UAAQ,qCAAU,QAAO;AAC/B,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,kBAAkB,OAAO,WAAW;AAC1C,MAAM,WAAW,SAAS,CAAC;AAC3B,MAAM,WAAW,SAAS;AAG1B,MAAM,QAAQ,QAAQ,IAAI,aAG7B,YAAY,MAEV,YAAY,IAAI,MAChB,QACF;AAEJ,MAAM,OAAO,MAAM;AAAC;AACb,MAAM,4BAA4B,QAAQ,OAAO,WAAW,YAAY;AACxE,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,iBAAiB,YAAY,kBAAkB;AACrD,MAAM,cAAc,CAAC,SAAS;AAErC,IAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,MAAI,CAAC,QAAQ,IAAI,gBAAgB;AAE/B,YAAQ,KAAK,8CAA8C;AAAA,EAC7D,WACE,YACA,QAAQ,IAAI,mBAAmB,SAC/B,QAAQ,IAAI,0BAA0B,KACtC;AAEA,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ var _a, _b;
2
+ import { useLayoutEffect } from "react";
3
+ import { Platform } from "react-native";
4
+ const isAndroid = ((_a = Platform) == null ? void 0 : _a.OS) === "android";
5
+ const isIOS = ((_b = Platform) == null ? void 0 : _b.OS) === "ios";
6
+ const isWeb = false;
7
+ const isWindowDefined = false;
8
+ const isServer = false;
9
+ const isClient = false;
10
+ const isRSC = false;
11
+ const useIsomorphicLayoutEffect = useLayoutEffect;
12
+ const isChrome = false;
13
+ const isWebTouchable = false;
14
+ const isTouchable = true;
15
+ export {
16
+ isAndroid,
17
+ isChrome,
18
+ isClient,
19
+ isIOS,
20
+ isRSC,
21
+ isServer,
22
+ isTouchable,
23
+ isWeb,
24
+ isWebTouchable,
25
+ isWindowDefined,
26
+ useIsomorphicLayoutEffect
27
+ };
28
+ //# sourceMappingURL=constants.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/constants.native.ts"],
4
+ "sourcesContent": ["import { useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = false\nexport const isWindowDefined = false\nexport const isServer = false\nexport const isClient = false\nexport const isRSC = false\nexport const useIsomorphicLayoutEffect = useLayoutEffect\nexport const isChrome = false\nexport const isWebTouchable = false\nexport const isTouchable = true\n"],
5
+ "mappings": "AAAA;AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAElB,MAAM,cAAY,qCAAU,QAAO;AACnC,MAAM,UAAQ,qCAAU,QAAO;AAC/B,MAAM,QAAQ;AACd,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,4BAA4B;AAClC,MAAM,WAAW;AACjB,MAAM,iBAAiB;AACvB,MAAM,cAAc;",
6
+ "names": []
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,35 @@
1
+ {
2
+ "name": "@tamagui/constants",
3
+ "version": "1.0.1-beta.187",
4
+ "types": "./types/constants.d.ts",
5
+ "main": "dist/cjs/constants",
6
+ "module": "dist/esm/constants",
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
+ "react": "*"
22
+ },
23
+ "devDependencies": {
24
+ "@tamagui/build": "^1.0.1-beta.187",
25
+ "@types/react": "^18.0.15",
26
+ "react-native": "*"
27
+ },
28
+ "peerDependencies": {
29
+ "react-native": "*"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
35
+ }
@@ -0,0 +1,14 @@
1
+ import { useLayoutEffect } from 'react'
2
+ import { Platform } from 'react-native'
3
+
4
+ export const isAndroid = Platform?.OS === 'android'
5
+ export const isIOS = Platform?.OS === 'ios'
6
+ export const isWeb = false
7
+ export const isWindowDefined = false
8
+ export const isServer = false
9
+ export const isClient = false
10
+ export const isRSC = false
11
+ export const useIsomorphicLayoutEffect = useLayoutEffect
12
+ export const isChrome = false
13
+ export const isWebTouchable = false
14
+ export const isTouchable = true
@@ -0,0 +1,41 @@
1
+ import { useEffect, useLayoutEffect } from 'react'
2
+ import { Platform } from 'react-native'
3
+
4
+ export const isAndroid = Platform?.OS === 'android'
5
+ export const isIOS = Platform?.OS === 'ios'
6
+ export const isWeb = process.env.TAMAGUI_TARGET === 'web'
7
+ export const isWindowDefined = typeof window !== 'undefined'
8
+ export const isServer = isWeb && !isWindowDefined
9
+ export const isClient = isWeb && isWindowDefined
10
+
11
+ // may want to move to VITE_RSC_BUILD
12
+ export const isRSC = process.env.ENABLE_RSC
13
+ ? // note this is statically analyzed so no funny business, just access it without optional chaining
14
+ // @ts-ignore
15
+ import.meta.env
16
+ ? // @ts-ignore
17
+ import.meta.env.SSR
18
+ : false
19
+ : false
20
+
21
+ const idFn = () => {}
22
+ export const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect
23
+ export const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')
24
+ export const isWebTouchable = isClient && 'ontouchstart' in window
25
+ export const isTouchable = !isWeb || isWebTouchable
26
+
27
+ if (process.env.NODE_ENV === 'development') {
28
+ if (!process.env.TAMAGUI_TARGET) {
29
+ // eslint-disable-next-line no-console
30
+ console.warn(`Must set TAMAGUI_TARGET to "web" or "native"`)
31
+ } else if (
32
+ isClient &&
33
+ process.env.TAMAGUI_TARGET !== 'web' &&
34
+ process.env.TAMAGUI_IGNORE_TARGET !== '1'
35
+ ) {
36
+ // eslint-disable-next-line no-console
37
+ console.warn(
38
+ `Must set TAMAGUI_TARGET to "web" for web apps - if you have window defined outside of the browser, set TAMAGUI_IGNORE_TARGET=1 to hide this`
39
+ )
40
+ }
41
+ }
@@ -0,0 +1,13 @@
1
+ import { useLayoutEffect } from 'react';
2
+ export declare const isAndroid: boolean;
3
+ export declare const isIOS: boolean;
4
+ export declare const isWeb: boolean;
5
+ export declare const isWindowDefined: boolean;
6
+ export declare const isServer: boolean;
7
+ export declare const isClient: boolean;
8
+ export declare const isRSC: any;
9
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
10
+ export declare const isChrome: boolean;
11
+ export declare const isWebTouchable: boolean;
12
+ export declare const isTouchable: boolean;
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { useLayoutEffect } from 'react';
2
+ export declare const isAndroid: boolean;
3
+ export declare const isIOS: boolean;
4
+ export declare const isWeb = false;
5
+ export declare const isWindowDefined = false;
6
+ export declare const isServer = false;
7
+ export declare const isClient = false;
8
+ export declare const isRSC = false;
9
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
10
+ export declare const isChrome = false;
11
+ export declare const isWebTouchable = false;
12
+ export declare const isTouchable = true;
13
+ //# sourceMappingURL=constants.native.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { ScaledSize } from 'react-native';
2
+ export declare function useWindowDimensions(): ScaledSize;
3
+ //# sourceMappingURL=index.d.ts.map