markdown-flow-ui 0.2.7-dev.1 → 0.2.7-dev.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i,l=/iPad|Tablet/i,o=e=>{const i=window.navigator?.userAgent??"";return{hasMobileUserAgent:a.test(i),hasTabletLikeUserAgent:l.test(i)}},s=({hasMobileUserAgent:e,hasTabletLikeUserAgent:n})=>e||n,d=e=>e?.includes("landscape")?!0:e?.includes("portrait")?!1:null,c=({matchMediaLandscape:e,orientationType:n,innerWidth:i,innerHeight:t})=>{const r=d(n);return r!==null?r:typeof e=="boolean"?e:typeof i!="number"||typeof t!="number"?!1:i>t},u=e=>s(o()),b=e=>{const n=window,i=typeof n.matchMedia=="function"?n.matchMedia("(orientation: landscape)").matches:void 0;return c({matchMediaLandscape:i,orientationType:n.screen?.orientation?.type,innerWidth:n.innerWidth,innerHeight:n.innerHeight})},p=(e,n)=>{const i=window,t=i.screen?.orientation;return i.addEventListener("orientationchange",e),t?.addEventListener?.("change",e),()=>{i.removeEventListener("orientationchange",e),t?.removeEventListener?.("change",e)}};exports.getMobileDeviceCapabilities=o;exports.isLandscapeViewport=b;exports.isMobileDevice=u;exports.resolveMobileDevice=s;exports.resolveMobileViewportLandscape=c;exports.subscribeMobileDeviceChange=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i,d=/iPad|Tablet/i,s=e=>{const n=window.navigator?.userAgent??"";return{hasMobileUserAgent:l.test(n),hasTabletLikeUserAgent:d.test(n)}},c=({hasMobileUserAgent:e,hasTabletLikeUserAgent:i})=>e||i,u=e=>e?.includes("landscape")?!0:e?.includes("portrait")?!1:null,a=({matchMediaLandscape:e,orientationType:i,screenWidth:n,screenHeight:t})=>{const r=u(i);return r!==null?r:typeof e=="boolean"?e:typeof n!="number"||typeof t!="number"?!1:n>t},b=e=>c(s()),v=e=>{const i=window,n=typeof i.matchMedia=="function"?i.matchMedia("(orientation: landscape)").matches:void 0;return a({matchMediaLandscape:n,orientationType:i.screen?.orientation?.type,screenWidth:i.screen?.width,screenHeight:i.screen?.height})},p=(e,i)=>{const n=window,t=n.screen?.orientation;let r=n.innerWidth;const o=()=>{n.innerWidth!==r&&(r=n.innerWidth,e())};return n.addEventListener("orientationchange",e),n.addEventListener("resize",o),t?.addEventListener?.("change",e),()=>{n.removeEventListener("orientationchange",e),n.removeEventListener("resize",o),t?.removeEventListener?.("change",e)}};exports.getMobileDeviceCapabilities=s;exports.isLandscapeViewport=v;exports.isMobileDevice=b;exports.resolveMobileDevice=c;exports.resolveMobileViewportLandscape=a;exports.subscribeMobileDeviceChange=p;
2
2
  //# sourceMappingURL=mobileDevice.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mobileDevice.cjs.js","sources":["../../src/lib/mobileDevice.ts"],"sourcesContent":["export type MobileDeviceCapabilities = {\n hasMobileUserAgent: boolean;\n hasTabletLikeUserAgent: boolean;\n};\n\nexport type MobileViewportOrientation = {\n matchMediaLandscape?: boolean;\n orientationType?: string;\n innerWidth?: number;\n innerHeight?: number;\n};\n\nconst MOBILE_USER_AGENT_PATTERN =\n /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i;\nconst TABLET_USER_AGENT_PATTERN = /iPad|Tablet/i;\n\nexport const getMobileDeviceCapabilities = (\n win?: Window\n): MobileDeviceCapabilities => {\n const currentWindow = win ?? window;\n const userAgent = currentWindow.navigator?.userAgent ?? \"\";\n\n return {\n hasMobileUserAgent: MOBILE_USER_AGENT_PATTERN.test(userAgent),\n hasTabletLikeUserAgent: TABLET_USER_AGENT_PATTERN.test(userAgent),\n };\n};\n\nexport const resolveMobileDevice = ({\n hasMobileUserAgent,\n hasTabletLikeUserAgent,\n}: MobileDeviceCapabilities): boolean => {\n return hasMobileUserAgent || hasTabletLikeUserAgent;\n};\n\nconst resolveLandscapeFromOrientationType = (\n orientationType?: string\n): boolean | null => {\n if (orientationType?.includes(\"landscape\")) {\n return true;\n }\n\n if (orientationType?.includes(\"portrait\")) {\n return false;\n }\n\n return null;\n};\n\nexport const resolveMobileViewportLandscape = ({\n matchMediaLandscape,\n orientationType,\n innerWidth,\n innerHeight,\n}: MobileViewportOrientation): boolean => {\n const orientationLandscape =\n resolveLandscapeFromOrientationType(orientationType);\n\n if (orientationLandscape !== null) {\n return orientationLandscape;\n }\n\n if (typeof matchMediaLandscape === \"boolean\") {\n return matchMediaLandscape;\n }\n\n if (typeof innerWidth !== \"number\" || typeof innerHeight !== \"number\") {\n return false;\n }\n\n return innerWidth > innerHeight;\n};\n\nexport const isMobileDevice = (win?: Window): boolean =>\n resolveMobileDevice(getMobileDeviceCapabilities(win));\n\nexport const isLandscapeViewport = (win?: Window): boolean => {\n const currentWindow = win ?? window;\n const matchMediaLandscape =\n typeof currentWindow.matchMedia === \"function\"\n ? currentWindow.matchMedia(\"(orientation: landscape)\").matches\n : undefined;\n\n return resolveMobileViewportLandscape({\n matchMediaLandscape,\n orientationType: currentWindow.screen?.orientation?.type,\n innerWidth: currentWindow.innerWidth,\n innerHeight: currentWindow.innerHeight,\n });\n};\n\nexport const subscribeMobileDeviceChange = (\n onChange: () => void,\n win?: Window\n) => {\n const currentWindow = win ?? window;\n const screenOrientation = currentWindow.screen?.orientation;\n\n currentWindow.addEventListener(\"orientationchange\", onChange);\n screenOrientation?.addEventListener?.(\"change\", onChange);\n\n return () => {\n currentWindow.removeEventListener(\"orientationchange\", onChange);\n screenOrientation?.removeEventListener?.(\"change\", onChange);\n };\n};\n"],"names":["MOBILE_USER_AGENT_PATTERN","TABLET_USER_AGENT_PATTERN","getMobileDeviceCapabilities","win","userAgent","resolveMobileDevice","hasMobileUserAgent","hasTabletLikeUserAgent","resolveLandscapeFromOrientationType","orientationType","resolveMobileViewportLandscape","matchMediaLandscape","innerWidth","innerHeight","orientationLandscape","isMobileDevice","isLandscapeViewport","currentWindow","subscribeMobileDeviceChange","onChange","screenOrientation"],"mappings":"gFAYA,MAAMA,EACJ,mEACIC,EAA4B,eAErBC,EACXC,GAC6B,CAE7B,MAAMC,EADuB,OACG,WAAW,WAAa,GAExD,MAAO,CACL,mBAAoBJ,EAA0B,KAAKI,CAAS,EAC5D,uBAAwBH,EAA0B,KAAKG,CAAS,CAAA,CAEpE,EAEaC,EAAsB,CAAC,CAClC,mBAAAC,EACA,uBAAAC,CACF,IACSD,GAAsBC,EAGzBC,EACJC,GAEIA,GAAiB,SAAS,WAAW,EAChC,GAGLA,GAAiB,SAAS,UAAU,EAC/B,GAGF,KAGIC,EAAiC,CAAC,CAC7C,oBAAAC,EACA,gBAAAF,EACA,WAAAG,EACA,YAAAC,CACF,IAA0C,CACxC,MAAMC,EACJN,EAAoCC,CAAe,EAErD,OAAIK,IAAyB,KACpBA,EAGL,OAAOH,GAAwB,UAC1BA,EAGL,OAAOC,GAAe,UAAY,OAAOC,GAAgB,SACpD,GAGFD,EAAaC,CACtB,EAEaE,EAAkBZ,GAC7BE,EAAoBH,EAA+B,CAAC,EAEzCc,EAAuBb,GAA0B,CAC5D,MAAMc,EAAuB,OACvBN,EACJ,OAAOM,EAAc,YAAe,WAChCA,EAAc,WAAW,0BAA0B,EAAE,QACrD,OAEN,OAAOP,EAA+B,CACpC,oBAAAC,EACA,gBAAiBM,EAAc,QAAQ,aAAa,KACpD,WAAYA,EAAc,WAC1B,YAAaA,EAAc,WAAA,CAC5B,CACH,EAEaC,EAA8B,CACzCC,EACAhB,IACG,CACH,MAAMc,EAAuB,OACvBG,EAAoBH,EAAc,QAAQ,YAEhD,OAAAA,EAAc,iBAAiB,oBAAqBE,CAAQ,EAC5DC,GAAmB,mBAAmB,SAAUD,CAAQ,EAEjD,IAAM,CACXF,EAAc,oBAAoB,oBAAqBE,CAAQ,EAC/DC,GAAmB,sBAAsB,SAAUD,CAAQ,CAC7D,CACF"}
1
+ {"version":3,"file":"mobileDevice.cjs.js","sources":["../../src/lib/mobileDevice.ts"],"sourcesContent":["export type MobileDeviceCapabilities = {\n hasMobileUserAgent: boolean;\n hasTabletLikeUserAgent: boolean;\n};\n\nexport type MobileViewportOrientation = {\n matchMediaLandscape?: boolean;\n orientationType?: string;\n innerWidth?: number;\n innerHeight?: number;\n screenWidth?: number;\n screenHeight?: number;\n};\n\nconst MOBILE_USER_AGENT_PATTERN =\n /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i;\nconst TABLET_USER_AGENT_PATTERN = /iPad|Tablet/i;\n\nexport const getMobileDeviceCapabilities = (\n win?: Window\n): MobileDeviceCapabilities => {\n const currentWindow = win ?? window;\n const userAgent = currentWindow.navigator?.userAgent ?? \"\";\n\n return {\n hasMobileUserAgent: MOBILE_USER_AGENT_PATTERN.test(userAgent),\n hasTabletLikeUserAgent: TABLET_USER_AGENT_PATTERN.test(userAgent),\n };\n};\n\nexport const resolveMobileDevice = ({\n hasMobileUserAgent,\n hasTabletLikeUserAgent,\n}: MobileDeviceCapabilities): boolean => {\n return hasMobileUserAgent || hasTabletLikeUserAgent;\n};\n\nconst resolveLandscapeFromOrientationType = (\n orientationType?: string\n): boolean | null => {\n if (orientationType?.includes(\"landscape\")) {\n return true;\n }\n\n if (orientationType?.includes(\"portrait\")) {\n return false;\n }\n\n return null;\n};\n\nexport const resolveMobileViewportLandscape = ({\n matchMediaLandscape,\n orientationType,\n screenWidth,\n screenHeight,\n}: MobileViewportOrientation): boolean => {\n const orientationLandscape =\n resolveLandscapeFromOrientationType(orientationType);\n\n if (orientationLandscape !== null) {\n return orientationLandscape;\n }\n\n if (typeof matchMediaLandscape === \"boolean\") {\n return matchMediaLandscape;\n }\n\n if (typeof screenWidth !== \"number\" || typeof screenHeight !== \"number\") {\n return false;\n }\n\n return screenWidth > screenHeight;\n};\n\nexport const isMobileDevice = (win?: Window): boolean =>\n resolveMobileDevice(getMobileDeviceCapabilities(win));\n\nexport const isLandscapeViewport = (win?: Window): boolean => {\n const currentWindow = win ?? window;\n const matchMediaLandscape =\n typeof currentWindow.matchMedia === \"function\"\n ? currentWindow.matchMedia(\"(orientation: landscape)\").matches\n : undefined;\n\n return resolveMobileViewportLandscape({\n matchMediaLandscape,\n orientationType: currentWindow.screen?.orientation?.type,\n innerWidth: currentWindow.innerWidth,\n innerHeight: currentWindow.innerHeight,\n screenWidth: currentWindow.screen?.width,\n screenHeight: currentWindow.screen?.height,\n });\n};\n\nexport const subscribeMobileDeviceChange = (\n onChange: () => void,\n win?: Window\n) => {\n const currentWindow = win ?? window;\n const screenOrientation = currentWindow.screen?.orientation;\n let lastWidth = currentWindow.innerWidth;\n\n const handleResize = () => {\n if (currentWindow.innerWidth === lastWidth) {\n return;\n }\n lastWidth = currentWindow.innerWidth;\n onChange();\n };\n\n currentWindow.addEventListener(\"orientationchange\", onChange);\n currentWindow.addEventListener(\"resize\", handleResize);\n screenOrientation?.addEventListener?.(\"change\", onChange);\n\n return () => {\n currentWindow.removeEventListener(\"orientationchange\", onChange);\n currentWindow.removeEventListener(\"resize\", handleResize);\n screenOrientation?.removeEventListener?.(\"change\", onChange);\n };\n};\n"],"names":["MOBILE_USER_AGENT_PATTERN","TABLET_USER_AGENT_PATTERN","getMobileDeviceCapabilities","win","userAgent","resolveMobileDevice","hasMobileUserAgent","hasTabletLikeUserAgent","resolveLandscapeFromOrientationType","orientationType","resolveMobileViewportLandscape","matchMediaLandscape","screenWidth","screenHeight","orientationLandscape","isMobileDevice","isLandscapeViewport","currentWindow","subscribeMobileDeviceChange","onChange","screenOrientation","lastWidth","handleResize"],"mappings":"gFAcA,MAAMA,EACJ,mEACIC,EAA4B,eAErBC,EACXC,GAC6B,CAE7B,MAAMC,EADuB,OACG,WAAW,WAAa,GAExD,MAAO,CACL,mBAAoBJ,EAA0B,KAAKI,CAAS,EAC5D,uBAAwBH,EAA0B,KAAKG,CAAS,CAAA,CAEpE,EAEaC,EAAsB,CAAC,CAClC,mBAAAC,EACA,uBAAAC,CACF,IACSD,GAAsBC,EAGzBC,EACJC,GAEIA,GAAiB,SAAS,WAAW,EAChC,GAGLA,GAAiB,SAAS,UAAU,EAC/B,GAGF,KAGIC,EAAiC,CAAC,CAC7C,oBAAAC,EACA,gBAAAF,EACA,YAAAG,EACA,aAAAC,CACF,IAA0C,CACxC,MAAMC,EACJN,EAAoCC,CAAe,EAErD,OAAIK,IAAyB,KACpBA,EAGL,OAAOH,GAAwB,UAC1BA,EAGL,OAAOC,GAAgB,UAAY,OAAOC,GAAiB,SACtD,GAGFD,EAAcC,CACvB,EAEaE,EAAkBZ,GAC7BE,EAAoBH,EAA+B,CAAC,EAEzCc,EAAuBb,GAA0B,CAC5D,MAAMc,EAAuB,OACvBN,EACJ,OAAOM,EAAc,YAAe,WAChCA,EAAc,WAAW,0BAA0B,EAAE,QACrD,OAEN,OAAOP,EAA+B,CACpC,oBAAAC,EACA,gBAAiBM,EAAc,QAAQ,aAAa,KAGpD,YAAaA,EAAc,QAAQ,MACnC,aAAcA,EAAc,QAAQ,MAAA,CACrC,CACH,EAEaC,EAA8B,CACzCC,EACAhB,IACG,CACH,MAAMc,EAAuB,OACvBG,EAAoBH,EAAc,QAAQ,YAChD,IAAII,EAAYJ,EAAc,WAE9B,MAAMK,EAAe,IAAM,CACrBL,EAAc,aAAeI,IAGjCA,EAAYJ,EAAc,WAC1BE,EAAA,EACF,EAEA,OAAAF,EAAc,iBAAiB,oBAAqBE,CAAQ,EAC5DF,EAAc,iBAAiB,SAAUK,CAAY,EACrDF,GAAmB,mBAAmB,SAAUD,CAAQ,EAEjD,IAAM,CACXF,EAAc,oBAAoB,oBAAqBE,CAAQ,EAC/DF,EAAc,oBAAoB,SAAUK,CAAY,EACxDF,GAAmB,sBAAsB,SAAUD,CAAQ,CAC7D,CACF"}
@@ -7,10 +7,12 @@ export type MobileViewportOrientation = {
7
7
  orientationType?: string;
8
8
  innerWidth?: number;
9
9
  innerHeight?: number;
10
+ screenWidth?: number;
11
+ screenHeight?: number;
10
12
  };
11
13
  export declare const getMobileDeviceCapabilities: (win?: Window) => MobileDeviceCapabilities;
12
14
  export declare const resolveMobileDevice: ({ hasMobileUserAgent, hasTabletLikeUserAgent, }: MobileDeviceCapabilities) => boolean;
13
- export declare const resolveMobileViewportLandscape: ({ matchMediaLandscape, orientationType, innerWidth, innerHeight, }: MobileViewportOrientation) => boolean;
15
+ export declare const resolveMobileViewportLandscape: ({ matchMediaLandscape, orientationType, screenWidth, screenHeight, }: MobileViewportOrientation) => boolean;
14
16
  export declare const isMobileDevice: (win?: Window) => boolean;
15
17
  export declare const isLandscapeViewport: (win?: Window) => boolean;
16
18
  export declare const subscribeMobileDeviceChange: (onChange: () => void, win?: Window) => () => void;
@@ -1,40 +1,44 @@
1
- const o = /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i, s = /iPad|Tablet/i, c = (e) => {
2
- const t = window.navigator?.userAgent ?? "";
1
+ const s = /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i, c = /iPad|Tablet/i, a = (e) => {
2
+ const n = window.navigator?.userAgent ?? "";
3
3
  return {
4
- hasMobileUserAgent: o.test(t),
5
- hasTabletLikeUserAgent: s.test(t)
4
+ hasMobileUserAgent: s.test(n),
5
+ hasTabletLikeUserAgent: c.test(n)
6
6
  };
7
- }, a = ({
7
+ }, d = ({
8
8
  hasMobileUserAgent: e,
9
- hasTabletLikeUserAgent: n
10
- }) => e || n, d = (e) => e?.includes("landscape") ? !0 : e?.includes("portrait") ? !1 : null, l = ({
9
+ hasTabletLikeUserAgent: t
10
+ }) => e || t, l = (e) => e?.includes("landscape") ? !0 : e?.includes("portrait") ? !1 : null, u = ({
11
11
  matchMediaLandscape: e,
12
- orientationType: n,
13
- innerWidth: t,
14
- innerHeight: i
12
+ orientationType: t,
13
+ screenWidth: n,
14
+ screenHeight: i
15
15
  }) => {
16
- const r = d(n);
17
- return r !== null ? r : typeof e == "boolean" ? e : typeof t != "number" || typeof i != "number" ? !1 : t > i;
18
- }, u = (e) => a(c()), p = (e) => {
19
- const n = window, t = typeof n.matchMedia == "function" ? n.matchMedia("(orientation: landscape)").matches : void 0;
20
- return l({
21
- matchMediaLandscape: t,
22
- orientationType: n.screen?.orientation?.type,
23
- innerWidth: n.innerWidth,
24
- innerHeight: n.innerHeight
16
+ const r = l(t);
17
+ return r !== null ? r : typeof e == "boolean" ? e : typeof n != "number" || typeof i != "number" ? !1 : n > i;
18
+ }, p = (e) => d(a()), v = (e) => {
19
+ const t = window, n = typeof t.matchMedia == "function" ? t.matchMedia("(orientation: landscape)").matches : void 0;
20
+ return u({
21
+ matchMediaLandscape: n,
22
+ orientationType: t.screen?.orientation?.type,
23
+ screenWidth: t.screen?.width,
24
+ screenHeight: t.screen?.height
25
25
  });
26
- }, b = (e, n) => {
27
- const t = window, i = t.screen?.orientation;
28
- return t.addEventListener("orientationchange", e), i?.addEventListener?.("change", e), () => {
29
- t.removeEventListener("orientationchange", e), i?.removeEventListener?.("change", e);
26
+ }, w = (e, t) => {
27
+ const n = window, i = n.screen?.orientation;
28
+ let r = n.innerWidth;
29
+ const o = () => {
30
+ n.innerWidth !== r && (r = n.innerWidth, e());
31
+ };
32
+ return n.addEventListener("orientationchange", e), n.addEventListener("resize", o), i?.addEventListener?.("change", e), () => {
33
+ n.removeEventListener("orientationchange", e), n.removeEventListener("resize", o), i?.removeEventListener?.("change", e);
30
34
  };
31
35
  };
32
36
  export {
33
- c as getMobileDeviceCapabilities,
34
- p as isLandscapeViewport,
35
- u as isMobileDevice,
36
- a as resolveMobileDevice,
37
- l as resolveMobileViewportLandscape,
38
- b as subscribeMobileDeviceChange
37
+ a as getMobileDeviceCapabilities,
38
+ v as isLandscapeViewport,
39
+ p as isMobileDevice,
40
+ d as resolveMobileDevice,
41
+ u as resolveMobileViewportLandscape,
42
+ w as subscribeMobileDeviceChange
39
43
  };
40
44
  //# sourceMappingURL=mobileDevice.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mobileDevice.es.js","sources":["../../src/lib/mobileDevice.ts"],"sourcesContent":["export type MobileDeviceCapabilities = {\n hasMobileUserAgent: boolean;\n hasTabletLikeUserAgent: boolean;\n};\n\nexport type MobileViewportOrientation = {\n matchMediaLandscape?: boolean;\n orientationType?: string;\n innerWidth?: number;\n innerHeight?: number;\n};\n\nconst MOBILE_USER_AGENT_PATTERN =\n /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i;\nconst TABLET_USER_AGENT_PATTERN = /iPad|Tablet/i;\n\nexport const getMobileDeviceCapabilities = (\n win?: Window\n): MobileDeviceCapabilities => {\n const currentWindow = win ?? window;\n const userAgent = currentWindow.navigator?.userAgent ?? \"\";\n\n return {\n hasMobileUserAgent: MOBILE_USER_AGENT_PATTERN.test(userAgent),\n hasTabletLikeUserAgent: TABLET_USER_AGENT_PATTERN.test(userAgent),\n };\n};\n\nexport const resolveMobileDevice = ({\n hasMobileUserAgent,\n hasTabletLikeUserAgent,\n}: MobileDeviceCapabilities): boolean => {\n return hasMobileUserAgent || hasTabletLikeUserAgent;\n};\n\nconst resolveLandscapeFromOrientationType = (\n orientationType?: string\n): boolean | null => {\n if (orientationType?.includes(\"landscape\")) {\n return true;\n }\n\n if (orientationType?.includes(\"portrait\")) {\n return false;\n }\n\n return null;\n};\n\nexport const resolveMobileViewportLandscape = ({\n matchMediaLandscape,\n orientationType,\n innerWidth,\n innerHeight,\n}: MobileViewportOrientation): boolean => {\n const orientationLandscape =\n resolveLandscapeFromOrientationType(orientationType);\n\n if (orientationLandscape !== null) {\n return orientationLandscape;\n }\n\n if (typeof matchMediaLandscape === \"boolean\") {\n return matchMediaLandscape;\n }\n\n if (typeof innerWidth !== \"number\" || typeof innerHeight !== \"number\") {\n return false;\n }\n\n return innerWidth > innerHeight;\n};\n\nexport const isMobileDevice = (win?: Window): boolean =>\n resolveMobileDevice(getMobileDeviceCapabilities(win));\n\nexport const isLandscapeViewport = (win?: Window): boolean => {\n const currentWindow = win ?? window;\n const matchMediaLandscape =\n typeof currentWindow.matchMedia === \"function\"\n ? currentWindow.matchMedia(\"(orientation: landscape)\").matches\n : undefined;\n\n return resolveMobileViewportLandscape({\n matchMediaLandscape,\n orientationType: currentWindow.screen?.orientation?.type,\n innerWidth: currentWindow.innerWidth,\n innerHeight: currentWindow.innerHeight,\n });\n};\n\nexport const subscribeMobileDeviceChange = (\n onChange: () => void,\n win?: Window\n) => {\n const currentWindow = win ?? window;\n const screenOrientation = currentWindow.screen?.orientation;\n\n currentWindow.addEventListener(\"orientationchange\", onChange);\n screenOrientation?.addEventListener?.(\"change\", onChange);\n\n return () => {\n currentWindow.removeEventListener(\"orientationchange\", onChange);\n screenOrientation?.removeEventListener?.(\"change\", onChange);\n };\n};\n"],"names":["MOBILE_USER_AGENT_PATTERN","TABLET_USER_AGENT_PATTERN","getMobileDeviceCapabilities","win","userAgent","resolveMobileDevice","hasMobileUserAgent","hasTabletLikeUserAgent","resolveLandscapeFromOrientationType","orientationType","resolveMobileViewportLandscape","matchMediaLandscape","innerWidth","innerHeight","orientationLandscape","isMobileDevice","isLandscapeViewport","currentWindow","subscribeMobileDeviceChange","onChange","screenOrientation"],"mappings":"AAYA,MAAMA,IACJ,oEACIC,IAA4B,gBAErBC,IAA8B,CACzCC,MAC6B;AAE7B,QAAMC,IADuB,OACG,WAAW,aAAa;AAExD,SAAO;AAAA,IACL,oBAAoBJ,EAA0B,KAAKI,CAAS;AAAA,IAC5D,wBAAwBH,EAA0B,KAAKG,CAAS;AAAA,EAAA;AAEpE,GAEaC,IAAsB,CAAC;AAAA,EAClC,oBAAAC;AAAA,EACA,wBAAAC;AACF,MACSD,KAAsBC,GAGzBC,IAAsC,CAC1CC,MAEIA,GAAiB,SAAS,WAAW,IAChC,KAGLA,GAAiB,SAAS,UAAU,IAC/B,KAGF,MAGIC,IAAiC,CAAC;AAAA,EAC7C,qBAAAC;AAAA,EACA,iBAAAF;AAAA,EACA,YAAAG;AAAA,EACA,aAAAC;AACF,MAA0C;AACxC,QAAMC,IACJN,EAAoCC,CAAe;AAErD,SAAIK,MAAyB,OACpBA,IAGL,OAAOH,KAAwB,YAC1BA,IAGL,OAAOC,KAAe,YAAY,OAAOC,KAAgB,WACpD,KAGFD,IAAaC;AACtB,GAEaE,IAAiB,CAACZ,MAC7BE,EAAoBH,EAA+B,CAAC,GAEzCc,IAAsB,CAACb,MAA0B;AAC5D,QAAMc,IAAuB,QACvBN,IACJ,OAAOM,EAAc,cAAe,aAChCA,EAAc,WAAW,0BAA0B,EAAE,UACrD;AAEN,SAAOP,EAA+B;AAAA,IACpC,qBAAAC;AAAA,IACA,iBAAiBM,EAAc,QAAQ,aAAa;AAAA,IACpD,YAAYA,EAAc;AAAA,IAC1B,aAAaA,EAAc;AAAA,EAAA,CAC5B;AACH,GAEaC,IAA8B,CACzCC,GACAhB,MACG;AACH,QAAMc,IAAuB,QACvBG,IAAoBH,EAAc,QAAQ;AAEhD,SAAAA,EAAc,iBAAiB,qBAAqBE,CAAQ,GAC5DC,GAAmB,mBAAmB,UAAUD,CAAQ,GAEjD,MAAM;AACX,IAAAF,EAAc,oBAAoB,qBAAqBE,CAAQ,GAC/DC,GAAmB,sBAAsB,UAAUD,CAAQ;AAAA,EAC7D;AACF;"}
1
+ {"version":3,"file":"mobileDevice.es.js","sources":["../../src/lib/mobileDevice.ts"],"sourcesContent":["export type MobileDeviceCapabilities = {\n hasMobileUserAgent: boolean;\n hasTabletLikeUserAgent: boolean;\n};\n\nexport type MobileViewportOrientation = {\n matchMediaLandscape?: boolean;\n orientationType?: string;\n innerWidth?: number;\n innerHeight?: number;\n screenWidth?: number;\n screenHeight?: number;\n};\n\nconst MOBILE_USER_AGENT_PATTERN =\n /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i;\nconst TABLET_USER_AGENT_PATTERN = /iPad|Tablet/i;\n\nexport const getMobileDeviceCapabilities = (\n win?: Window\n): MobileDeviceCapabilities => {\n const currentWindow = win ?? window;\n const userAgent = currentWindow.navigator?.userAgent ?? \"\";\n\n return {\n hasMobileUserAgent: MOBILE_USER_AGENT_PATTERN.test(userAgent),\n hasTabletLikeUserAgent: TABLET_USER_AGENT_PATTERN.test(userAgent),\n };\n};\n\nexport const resolveMobileDevice = ({\n hasMobileUserAgent,\n hasTabletLikeUserAgent,\n}: MobileDeviceCapabilities): boolean => {\n return hasMobileUserAgent || hasTabletLikeUserAgent;\n};\n\nconst resolveLandscapeFromOrientationType = (\n orientationType?: string\n): boolean | null => {\n if (orientationType?.includes(\"landscape\")) {\n return true;\n }\n\n if (orientationType?.includes(\"portrait\")) {\n return false;\n }\n\n return null;\n};\n\nexport const resolveMobileViewportLandscape = ({\n matchMediaLandscape,\n orientationType,\n screenWidth,\n screenHeight,\n}: MobileViewportOrientation): boolean => {\n const orientationLandscape =\n resolveLandscapeFromOrientationType(orientationType);\n\n if (orientationLandscape !== null) {\n return orientationLandscape;\n }\n\n if (typeof matchMediaLandscape === \"boolean\") {\n return matchMediaLandscape;\n }\n\n if (typeof screenWidth !== \"number\" || typeof screenHeight !== \"number\") {\n return false;\n }\n\n return screenWidth > screenHeight;\n};\n\nexport const isMobileDevice = (win?: Window): boolean =>\n resolveMobileDevice(getMobileDeviceCapabilities(win));\n\nexport const isLandscapeViewport = (win?: Window): boolean => {\n const currentWindow = win ?? window;\n const matchMediaLandscape =\n typeof currentWindow.matchMedia === \"function\"\n ? currentWindow.matchMedia(\"(orientation: landscape)\").matches\n : undefined;\n\n return resolveMobileViewportLandscape({\n matchMediaLandscape,\n orientationType: currentWindow.screen?.orientation?.type,\n innerWidth: currentWindow.innerWidth,\n innerHeight: currentWindow.innerHeight,\n screenWidth: currentWindow.screen?.width,\n screenHeight: currentWindow.screen?.height,\n });\n};\n\nexport const subscribeMobileDeviceChange = (\n onChange: () => void,\n win?: Window\n) => {\n const currentWindow = win ?? window;\n const screenOrientation = currentWindow.screen?.orientation;\n let lastWidth = currentWindow.innerWidth;\n\n const handleResize = () => {\n if (currentWindow.innerWidth === lastWidth) {\n return;\n }\n lastWidth = currentWindow.innerWidth;\n onChange();\n };\n\n currentWindow.addEventListener(\"orientationchange\", onChange);\n currentWindow.addEventListener(\"resize\", handleResize);\n screenOrientation?.addEventListener?.(\"change\", onChange);\n\n return () => {\n currentWindow.removeEventListener(\"orientationchange\", onChange);\n currentWindow.removeEventListener(\"resize\", handleResize);\n screenOrientation?.removeEventListener?.(\"change\", onChange);\n };\n};\n"],"names":["MOBILE_USER_AGENT_PATTERN","TABLET_USER_AGENT_PATTERN","getMobileDeviceCapabilities","win","userAgent","resolveMobileDevice","hasMobileUserAgent","hasTabletLikeUserAgent","resolveLandscapeFromOrientationType","orientationType","resolveMobileViewportLandscape","matchMediaLandscape","screenWidth","screenHeight","orientationLandscape","isMobileDevice","isLandscapeViewport","currentWindow","subscribeMobileDeviceChange","onChange","screenOrientation","lastWidth","handleResize"],"mappings":"AAcA,MAAMA,IACJ,oEACIC,IAA4B,gBAErBC,IAA8B,CACzCC,MAC6B;AAE7B,QAAMC,IADuB,OACG,WAAW,aAAa;AAExD,SAAO;AAAA,IACL,oBAAoBJ,EAA0B,KAAKI,CAAS;AAAA,IAC5D,wBAAwBH,EAA0B,KAAKG,CAAS;AAAA,EAAA;AAEpE,GAEaC,IAAsB,CAAC;AAAA,EAClC,oBAAAC;AAAA,EACA,wBAAAC;AACF,MACSD,KAAsBC,GAGzBC,IAAsC,CAC1CC,MAEIA,GAAiB,SAAS,WAAW,IAChC,KAGLA,GAAiB,SAAS,UAAU,IAC/B,KAGF,MAGIC,IAAiC,CAAC;AAAA,EAC7C,qBAAAC;AAAA,EACA,iBAAAF;AAAA,EACA,aAAAG;AAAA,EACA,cAAAC;AACF,MAA0C;AACxC,QAAMC,IACJN,EAAoCC,CAAe;AAErD,SAAIK,MAAyB,OACpBA,IAGL,OAAOH,KAAwB,YAC1BA,IAGL,OAAOC,KAAgB,YAAY,OAAOC,KAAiB,WACtD,KAGFD,IAAcC;AACvB,GAEaE,IAAiB,CAACZ,MAC7BE,EAAoBH,EAA+B,CAAC,GAEzCc,IAAsB,CAACb,MAA0B;AAC5D,QAAMc,IAAuB,QACvBN,IACJ,OAAOM,EAAc,cAAe,aAChCA,EAAc,WAAW,0BAA0B,EAAE,UACrD;AAEN,SAAOP,EAA+B;AAAA,IACpC,qBAAAC;AAAA,IACA,iBAAiBM,EAAc,QAAQ,aAAa;AAAA,IAGpD,aAAaA,EAAc,QAAQ;AAAA,IACnC,cAAcA,EAAc,QAAQ;AAAA,EAAA,CACrC;AACH,GAEaC,IAA8B,CACzCC,GACAhB,MACG;AACH,QAAMc,IAAuB,QACvBG,IAAoBH,EAAc,QAAQ;AAChD,MAAII,IAAYJ,EAAc;AAE9B,QAAMK,IAAe,MAAM;AACzB,IAAIL,EAAc,eAAeI,MAGjCA,IAAYJ,EAAc,YAC1BE,EAAA;AAAA,EACF;AAEA,SAAAF,EAAc,iBAAiB,qBAAqBE,CAAQ,GAC5DF,EAAc,iBAAiB,UAAUK,CAAY,GACrDF,GAAmB,mBAAmB,UAAUD,CAAQ,GAEjD,MAAM;AACX,IAAAF,EAAc,oBAAoB,qBAAqBE,CAAQ,GAC/DF,EAAc,oBAAoB,UAAUK,CAAY,GACxDF,GAAmB,sBAAsB,UAAUD,CAAQ;AAAA,EAC7D;AACF;"}
package/package.json CHANGED
@@ -174,7 +174,7 @@
174
174
  ]
175
175
  }
176
176
  },
177
- "version": "0.2.7-dev.1",
177
+ "version": "0.2.7-dev.2",
178
178
  "type": "module",
179
179
  "exports": {
180
180
  ".": {