@tamagui/react-native-media-driver 1.0.1-rc.0.4

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,34 @@
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 createMedia_exports = {};
20
+ __export(createMedia_exports, {
21
+ createMedia: () => createMedia
22
+ });
23
+ module.exports = __toCommonJS(createMedia_exports);
24
+ var import_core = require("@tamagui/core");
25
+ var import_matchMedia = require("./matchMedia");
26
+ function createMedia(media) {
27
+ (0, import_core.setupMatchMedia)(import_matchMedia.matchMedia);
28
+ return media;
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ createMedia
33
+ });
34
+ //# sourceMappingURL=createMedia.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createMedia.ts"],
4
+ "sourcesContent": ["import { setupMatchMedia } from '@tamagui/core'\nimport { matchMedia } from './matchMedia'\n\nexport function createMedia<A extends Object>(media: A): A{\n setupMatchMedia(matchMedia)\n return media\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAChC,wBAA2B;AAEpB,SAAS,YAA8B,OAAY;AACxD,mCAAgB,4BAAU;AAC1B,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,20 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./createMedia"), module.exports);
19
+ __reExport(src_exports, require("./matchMedia"), module.exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './createMedia'\nexport * from './matchMedia'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;AACA,wBAAc,yBADd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
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 matchMedia_exports = {};
20
+ __export(matchMedia_exports, {
21
+ matchMedia: () => matchMedia
22
+ });
23
+ module.exports = __toCommonJS(matchMedia_exports);
24
+ var import_mediaQueryList = require("./mediaQueryList");
25
+ const matchMedia = (query) => new import_mediaQueryList.NativeMediaQueryList(query);
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ matchMedia
29
+ });
30
+ //# sourceMappingURL=matchMedia.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/matchMedia.ts"],
4
+ "sourcesContent": ["import { MatchMedia } from '@tamagui/core'\nimport { NativeMediaQueryList } from './mediaQueryList'\n\nexport const matchMedia: MatchMedia = (query) => new NativeMediaQueryList(query)"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAqC;AAE9B,MAAM,aAAyB,CAAC,UAAU,IAAI,2CAAqB,KAAK;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
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 matchMedia_native_exports = {};
20
+ __export(matchMedia_native_exports, {
21
+ matchMedia: () => matchMedia
22
+ });
23
+ module.exports = __toCommonJS(matchMedia_native_exports);
24
+ var import_mediaQueryList = require("./mediaQueryList");
25
+ const matchMedia = (query) => new import_mediaQueryList.NativeMediaQueryList(query);
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ matchMedia
29
+ });
30
+ //# sourceMappingURL=matchMedia.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/matchMedia.native.ts"],
4
+ "sourcesContent": ["import { MatchMedia } from '@tamagui/core'\n\nimport { NativeMediaQueryList } from './mediaQueryList'\n\nexport const matchMedia: MatchMedia = (query) => new NativeMediaQueryList(query)\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAAqC;AAE9B,MAAM,aAAyB,CAAC,UAAU,IAAI,2CAAqB,KAAK;",
6
+ "names": []
7
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var mediaQueryList_exports = {};
26
+ __export(mediaQueryList_exports, {
27
+ NativeMediaQueryList: () => NativeMediaQueryList
28
+ });
29
+ module.exports = __toCommonJS(mediaQueryList_exports);
30
+ var import_css_mediaquery = __toESM(require("css-mediaquery"));
31
+ var import_react_native = require("react-native");
32
+ class NativeMediaQueryList {
33
+ constructor(query) {
34
+ this.query = query;
35
+ this.listeners = [];
36
+ this.notify();
37
+ import_react_native.Dimensions.addEventListener("change", () => {
38
+ this.notify();
39
+ });
40
+ }
41
+ get orientation() {
42
+ const windowDimensions = import_react_native.Dimensions.get("window");
43
+ return windowDimensions.height > windowDimensions.width ? "portrait" : "landscape";
44
+ }
45
+ notify() {
46
+ this.listeners.forEach((listener) => {
47
+ listener(this.orientation);
48
+ });
49
+ }
50
+ addListener(listener) {
51
+ this.listeners.push(listener);
52
+ }
53
+ removeListener(listener) {
54
+ const index = this.listeners.indexOf(listener);
55
+ if (index !== -1)
56
+ this.listeners.splice(index, 1);
57
+ }
58
+ get matches() {
59
+ const windowDimensions = import_react_native.Dimensions.get("window");
60
+ const matches = import_css_mediaquery.default.match(this.query, {
61
+ type: "screen",
62
+ orientation: this.orientation,
63
+ ...windowDimensions,
64
+ "device-width": windowDimensions.width,
65
+ "device-height": windowDimensions.height
66
+ });
67
+ return matches;
68
+ }
69
+ }
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ NativeMediaQueryList
73
+ });
74
+ //# sourceMappingURL=mediaQueryList.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/mediaQueryList.ts"],
4
+ "sourcesContent": ["import mediaQuery from 'css-mediaquery'\nimport { Dimensions } from 'react-native'\nimport { MediaQueryList } from '@tamagui/core'\n\ntype Orientation = 'landscape' | 'portrait';\n\ntype Listener = (orientation: Orientation) => void;\n\nexport class NativeMediaQueryList implements MediaQueryList {\n private listeners: Listener[] = []\n \n private get orientation(): Orientation {\n const windowDimensions = Dimensions.get('window')\n return windowDimensions.height > windowDimensions.width ? 'portrait' : 'landscape'\n }\n\n constructor(private query: string) {\n this.notify()\n Dimensions.addEventListener('change', () => {\n this.notify()\n });\n }\n\n private notify() {\n this.listeners.forEach((listener) => {\n listener(this.orientation)\n })\n }\n\n addListener(listener: Listener) {\n this.listeners.push(listener)\n }\n\n removeListener(listener: Listener) {\n const index = this.listeners.indexOf(listener)\n if (index !== -1) this.listeners.splice(index, 1)\n }\n\n get matches(): boolean {\n const windowDimensions = Dimensions.get(\"window\")\n const matches = mediaQuery.match(this.query, {\n type: \"screen\",\n orientation: this.orientation,\n ...windowDimensions,\n \"device-width\": windowDimensions.width,\n \"device-height\": windowDimensions.height,\n })\n return matches\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAuB;AACvB,0BAA2B;AAOpB,MAAM,qBAA+C;AAAA,EAQ1D,YAAoB,OAAe;AAAf;AAPpB,SAAQ,YAAwB,CAAC;AAQ/B,SAAK,OAAO;AACZ,mCAAW,iBAAiB,UAAU,MAAM;AAC1C,WAAK,OAAO;AAAA,IACd,CAAC;AAAA,EACH;AAAA,EAVA,IAAY,cAA2B;AACrC,UAAM,mBAAmB,+BAAW,IAAI,QAAQ;AAChD,WAAO,iBAAiB,SAAS,iBAAiB,QAAQ,aAAa;AAAA,EACzE;AAAA,EASQ,SAAS;AACf,SAAK,UAAU,QAAQ,CAAC,aAAa;AACnC,eAAS,KAAK,WAAW;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,YAAY,UAAoB;AAC9B,SAAK,UAAU,KAAK,QAAQ;AAAA,EAC9B;AAAA,EAEA,eAAe,UAAoB;AACjC,UAAM,QAAQ,KAAK,UAAU,QAAQ,QAAQ;AAC7C,QAAI,UAAU;AAAI,WAAK,UAAU,OAAO,OAAO,CAAC;AAAA,EAClD;AAAA,EAEA,IAAI,UAAmB;AACrB,UAAM,mBAAmB,+BAAW,IAAI,QAAQ;AAChD,UAAM,UAAU,sBAAAA,QAAW,MAAM,KAAK,OAAO;AAAA,MAC3C,MAAM;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,GAAG;AAAA,MACH,gBAAgB,iBAAiB;AAAA,MACjC,iBAAiB,iBAAiB;AAAA,IACpC,CAAC;AACD,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["mediaQuery"]
7
+ }
@@ -0,0 +1,10 @@
1
+ import { setupMatchMedia } from "@tamagui/core";
2
+ import { matchMedia } from "./matchMedia";
3
+ function createMedia(media) {
4
+ setupMatchMedia(matchMedia);
5
+ return media;
6
+ }
7
+ export {
8
+ createMedia
9
+ };
10
+ //# sourceMappingURL=createMedia.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createMedia.ts"],
4
+ "sourcesContent": ["import { setupMatchMedia } from '@tamagui/core'\nimport { matchMedia } from './matchMedia'\n\nexport function createMedia<A extends Object>(media: A): A{\n setupMatchMedia(matchMedia)\n return media\n}\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAEpB,SAAS,YAA8B,OAAY;AACxD,kBAAgB,UAAU;AAC1B,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./createMedia";
2
+ export * from "./matchMedia";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './createMedia'\nexport * from './matchMedia'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ import { NativeMediaQueryList } from "./mediaQueryList";
2
+ const matchMedia = (query) => new NativeMediaQueryList(query);
3
+ export {
4
+ matchMedia
5
+ };
6
+ //# sourceMappingURL=matchMedia.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/matchMedia.ts"],
4
+ "sourcesContent": ["import { MatchMedia } from '@tamagui/core'\nimport { NativeMediaQueryList } from './mediaQueryList'\n\nexport const matchMedia: MatchMedia = (query) => new NativeMediaQueryList(query)"],
5
+ "mappings": "AACA,SAAS,4BAA4B;AAE9B,MAAM,aAAyB,CAAC,UAAU,IAAI,qBAAqB,KAAK;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ import { NativeMediaQueryList } from "./mediaQueryList";
2
+ const matchMedia = (query) => new NativeMediaQueryList(query);
3
+ export {
4
+ matchMedia
5
+ };
6
+ //# sourceMappingURL=matchMedia.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/matchMedia.native.ts"],
4
+ "sourcesContent": ["import { MatchMedia } from '@tamagui/core'\n\nimport { NativeMediaQueryList } from './mediaQueryList'\n\nexport const matchMedia: MatchMedia = (query) => new NativeMediaQueryList(query)\n"],
5
+ "mappings": "AAEA,SAAS,4BAA4B;AAE9B,MAAM,aAAyB,CAAC,UAAU,IAAI,qBAAqB,KAAK;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
1
+ import mediaQuery from "css-mediaquery";
2
+ import { Dimensions } from "react-native";
3
+ class NativeMediaQueryList {
4
+ constructor(query) {
5
+ this.query = query;
6
+ this.listeners = [];
7
+ this.notify();
8
+ Dimensions.addEventListener("change", () => {
9
+ this.notify();
10
+ });
11
+ }
12
+ get orientation() {
13
+ const windowDimensions = Dimensions.get("window");
14
+ return windowDimensions.height > windowDimensions.width ? "portrait" : "landscape";
15
+ }
16
+ notify() {
17
+ this.listeners.forEach((listener) => {
18
+ listener(this.orientation);
19
+ });
20
+ }
21
+ addListener(listener) {
22
+ this.listeners.push(listener);
23
+ }
24
+ removeListener(listener) {
25
+ const index = this.listeners.indexOf(listener);
26
+ if (index !== -1)
27
+ this.listeners.splice(index, 1);
28
+ }
29
+ get matches() {
30
+ const windowDimensions = Dimensions.get("window");
31
+ const matches = mediaQuery.match(this.query, {
32
+ type: "screen",
33
+ orientation: this.orientation,
34
+ ...windowDimensions,
35
+ "device-width": windowDimensions.width,
36
+ "device-height": windowDimensions.height
37
+ });
38
+ return matches;
39
+ }
40
+ }
41
+ export {
42
+ NativeMediaQueryList
43
+ };
44
+ //# sourceMappingURL=mediaQueryList.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/mediaQueryList.ts"],
4
+ "sourcesContent": ["import mediaQuery from 'css-mediaquery'\nimport { Dimensions } from 'react-native'\nimport { MediaQueryList } from '@tamagui/core'\n\ntype Orientation = 'landscape' | 'portrait';\n\ntype Listener = (orientation: Orientation) => void;\n\nexport class NativeMediaQueryList implements MediaQueryList {\n private listeners: Listener[] = []\n \n private get orientation(): Orientation {\n const windowDimensions = Dimensions.get('window')\n return windowDimensions.height > windowDimensions.width ? 'portrait' : 'landscape'\n }\n\n constructor(private query: string) {\n this.notify()\n Dimensions.addEventListener('change', () => {\n this.notify()\n });\n }\n\n private notify() {\n this.listeners.forEach((listener) => {\n listener(this.orientation)\n })\n }\n\n addListener(listener: Listener) {\n this.listeners.push(listener)\n }\n\n removeListener(listener: Listener) {\n const index = this.listeners.indexOf(listener)\n if (index !== -1) this.listeners.splice(index, 1)\n }\n\n get matches(): boolean {\n const windowDimensions = Dimensions.get(\"window\")\n const matches = mediaQuery.match(this.query, {\n type: \"screen\",\n orientation: this.orientation,\n ...windowDimensions,\n \"device-width\": windowDimensions.width,\n \"device-height\": windowDimensions.height,\n })\n return matches\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,gBAAgB;AACvB,SAAS,kBAAkB;AAOpB,MAAM,qBAA+C;AAAA,EAQ1D,YAAoB,OAAe;AAAf;AAPpB,SAAQ,YAAwB,CAAC;AAQ/B,SAAK,OAAO;AACZ,eAAW,iBAAiB,UAAU,MAAM;AAC1C,WAAK,OAAO;AAAA,IACd,CAAC;AAAA,EACH;AAAA,EAVA,IAAY,cAA2B;AACrC,UAAM,mBAAmB,WAAW,IAAI,QAAQ;AAChD,WAAO,iBAAiB,SAAS,iBAAiB,QAAQ,aAAa;AAAA,EACzE;AAAA,EASQ,SAAS;AACf,SAAK,UAAU,QAAQ,CAAC,aAAa;AACnC,eAAS,KAAK,WAAW;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,YAAY,UAAoB;AAC9B,SAAK,UAAU,KAAK,QAAQ;AAAA,EAC9B;AAAA,EAEA,eAAe,UAAoB;AACjC,UAAM,QAAQ,KAAK,UAAU,QAAQ,QAAQ;AAC7C,QAAI,UAAU;AAAI,WAAK,UAAU,OAAO,OAAO,CAAC;AAAA,EAClD;AAAA,EAEA,IAAI,UAAmB;AACrB,UAAM,mBAAmB,WAAW,IAAI,QAAQ;AAChD,UAAM,UAAU,WAAW,MAAM,KAAK,OAAO;AAAA,MAC3C,MAAM;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,GAAG;AAAA,MACH,gBAAgB,iBAAiB;AAAA,MACjC,iBAAiB,iBAAiB;AAAA,IACpC,CAAC;AACD,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@tamagui/react-native-media-driver",
3
+ "version": "1.0.1-rc.0.4",
4
+ "source": "src/index.ts",
5
+ "main": "dist/cjs",
6
+ "module": "dist/esm",
7
+ "types": "./types/index.d.ts",
8
+ "license": "MIT",
9
+ "files": [
10
+ "src",
11
+ "types",
12
+ "dist"
13
+ ],
14
+ "sideEffects": true,
15
+ "dependencies": {
16
+ "@tamagui/core": "^1.0.1-rc.0.4",
17
+ "css-mediaquery": "^0.1.2"
18
+ },
19
+ "devDependencies": {
20
+ "@tamagui/build": "^1.0.1-rc.0.4",
21
+ "react-native": "*"
22
+ },
23
+ "peerDependencies": {
24
+ "react-native": "*"
25
+ },
26
+ "scripts": {
27
+ "build": "tamagui-build",
28
+ "watch": "tamagui-build --watch",
29
+ "clean": "tamagui-build clean",
30
+ "clean:build": "tamagui-build clean:build"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ import { setupMatchMedia } from '@tamagui/core'
2
+ import { matchMedia } from './matchMedia'
3
+
4
+ export function createMedia<A extends Object>(media: A): A{
5
+ setupMatchMedia(matchMedia)
6
+ return media
7
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './createMedia'
2
+ export * from './matchMedia'
@@ -0,0 +1,4 @@
1
+ import { MatchMedia } from '@tamagui/core'
2
+ import { NativeMediaQueryList } from './mediaQueryList'
3
+
4
+ export const matchMedia: MatchMedia = (query) => new NativeMediaQueryList(query)
@@ -0,0 +1,50 @@
1
+ import mediaQuery from 'css-mediaquery'
2
+ import { Dimensions } from 'react-native'
3
+ import { MediaQueryList } from '@tamagui/core'
4
+
5
+ type Orientation = 'landscape' | 'portrait';
6
+
7
+ type Listener = (orientation: Orientation) => void;
8
+
9
+ export class NativeMediaQueryList implements MediaQueryList {
10
+ private listeners: Listener[] = []
11
+
12
+ private get orientation(): Orientation {
13
+ const windowDimensions = Dimensions.get('window')
14
+ return windowDimensions.height > windowDimensions.width ? 'portrait' : 'landscape'
15
+ }
16
+
17
+ constructor(private query: string) {
18
+ this.notify()
19
+ Dimensions.addEventListener('change', () => {
20
+ this.notify()
21
+ });
22
+ }
23
+
24
+ private notify() {
25
+ this.listeners.forEach((listener) => {
26
+ listener(this.orientation)
27
+ })
28
+ }
29
+
30
+ addListener(listener: Listener) {
31
+ this.listeners.push(listener)
32
+ }
33
+
34
+ removeListener(listener: Listener) {
35
+ const index = this.listeners.indexOf(listener)
36
+ if (index !== -1) this.listeners.splice(index, 1)
37
+ }
38
+
39
+ get matches(): boolean {
40
+ const windowDimensions = Dimensions.get("window")
41
+ const matches = mediaQuery.match(this.query, {
42
+ type: "screen",
43
+ orientation: this.orientation,
44
+ ...windowDimensions,
45
+ "device-width": windowDimensions.width,
46
+ "device-height": windowDimensions.height,
47
+ })
48
+ return matches
49
+ }
50
+ }
@@ -0,0 +1,2 @@
1
+ export declare function createMedia<A extends Object>(media: A): A;
2
+ //# sourceMappingURL=createMedia.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './createMedia';
2
+ export * from './matchMedia';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { MatchMedia } from '@tamagui/core';
2
+ export declare const matchMedia: MatchMedia;
3
+ //# sourceMappingURL=matchMedia.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { MediaQueryList } from '@tamagui/core';
2
+ declare type Orientation = 'landscape' | 'portrait';
3
+ declare type Listener = (orientation: Orientation) => void;
4
+ export declare class NativeMediaQueryList implements MediaQueryList {
5
+ private query;
6
+ private listeners;
7
+ private get orientation();
8
+ constructor(query: string);
9
+ private notify;
10
+ addListener(listener: Listener): void;
11
+ removeListener(listener: Listener): void;
12
+ get matches(): boolean;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=mediaQueryList.d.ts.map