native-fn 1.0.41 → 1.0.43

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.
Files changed (78) hide show
  1. package/dist/native.cjs +380 -1
  2. package/dist/native.min.cjs +1 -1
  3. package/dist/native.min.mjs +1 -1
  4. package/dist/native.mjs +380 -1
  5. package/dist/native.umd.js +380 -1
  6. package/dist/native.umd.min.js +1 -1
  7. package/dist/plugin/app/index.cjs +262 -98
  8. package/dist/plugin/app/index.d.ts +18 -0
  9. package/dist/plugin/app/index.min.cjs +1 -1
  10. package/dist/plugin/app/index.min.mjs +1 -1
  11. package/dist/plugin/app/index.mjs +262 -98
  12. package/dist/plugin/app/index.umd.js +262 -98
  13. package/dist/plugin/app/index.umd.min.js +1 -1
  14. package/dist/plugin/app/src/constants/platform.d.ts +21 -12
  15. package/dist/plugin/app/src/types/platform.d.ts +17 -0
  16. package/dist/plugin/app/src/utils/create-custom-error.d.ts +5 -0
  17. package/dist/plugin/app/src/utils/create-hidden-element.d.ts +1 -1
  18. package/dist/plugin/app/src/utils/dynamic-import.d.ts +1 -0
  19. package/dist/plugin/camera/index.cjs +248 -86
  20. package/dist/plugin/camera/index.min.cjs +1 -1
  21. package/dist/plugin/camera/index.min.mjs +1 -1
  22. package/dist/plugin/camera/index.mjs +248 -86
  23. package/dist/plugin/camera/index.umd.js +248 -86
  24. package/dist/plugin/camera/index.umd.min.js +1 -1
  25. package/dist/plugin/camera/src/constants/platform.d.ts +21 -12
  26. package/dist/plugin/camera/src/types/platform.d.ts +17 -0
  27. package/dist/plugin/camera/src/utils/create-custom-error.d.ts +5 -0
  28. package/dist/plugin/camera/src/utils/create-hidden-element.d.ts +1 -1
  29. package/dist/plugin/camera/src/utils/dynamic-import.d.ts +1 -0
  30. package/dist/plugin/clipboard/index.cjs +7 -4
  31. package/dist/plugin/clipboard/index.min.cjs +1 -1
  32. package/dist/plugin/clipboard/index.min.mjs +1 -1
  33. package/dist/plugin/clipboard/index.mjs +7 -4
  34. package/dist/plugin/clipboard/index.umd.js +7 -4
  35. package/dist/plugin/clipboard/index.umd.min.js +1 -1
  36. package/dist/plugin/clipboard/src/constants/platform.d.ts +21 -12
  37. package/dist/plugin/clipboard/src/types/platform.d.ts +17 -0
  38. package/dist/plugin/clipboard/src/utils/create-custom-error.d.ts +5 -0
  39. package/dist/plugin/clipboard/src/utils/create-hidden-element.d.ts +1 -1
  40. package/dist/plugin/clipboard/src/utils/dynamic-import.d.ts +1 -0
  41. package/dist/plugin/fullscreen/index.cjs +241 -82
  42. package/dist/plugin/fullscreen/index.min.cjs +1 -1
  43. package/dist/plugin/fullscreen/index.min.mjs +1 -1
  44. package/dist/plugin/fullscreen/index.mjs +241 -82
  45. package/dist/plugin/fullscreen/index.umd.js +241 -82
  46. package/dist/plugin/fullscreen/index.umd.min.js +1 -1
  47. package/dist/plugin/fullscreen/src/constants/platform.d.ts +21 -12
  48. package/dist/plugin/fullscreen/src/types/platform.d.ts +17 -0
  49. package/dist/plugin/fullscreen/src/utils/create-custom-error.d.ts +5 -0
  50. package/dist/plugin/fullscreen/src/utils/create-hidden-element.d.ts +1 -1
  51. package/dist/plugin/fullscreen/src/utils/dynamic-import.d.ts +1 -0
  52. package/dist/plugin/platform/index.cjs +7 -7
  53. package/dist/plugin/platform/index.d.ts +18 -0
  54. package/dist/plugin/platform/index.min.cjs +1 -1
  55. package/dist/plugin/platform/index.min.mjs +1 -1
  56. package/dist/plugin/platform/index.mjs +7 -7
  57. package/dist/plugin/platform/index.umd.js +7 -7
  58. package/dist/plugin/platform/index.umd.min.js +1 -1
  59. package/dist/plugin/platform/src/constants/platform.d.ts +19 -0
  60. package/dist/plugin/platform/src/utils/create-custom-error.d.ts +5 -0
  61. package/dist/plugin/platform/src/utils/dynamic-import.d.ts +1 -0
  62. package/dist/plugin/theme/index.cjs +252 -91
  63. package/dist/plugin/theme/index.min.cjs +1 -1
  64. package/dist/plugin/theme/index.min.mjs +1 -1
  65. package/dist/plugin/theme/index.mjs +252 -91
  66. package/dist/plugin/theme/index.umd.js +252 -91
  67. package/dist/plugin/theme/index.umd.min.js +1 -1
  68. package/dist/plugin/theme/src/constants/platform.d.ts +21 -12
  69. package/dist/plugin/theme/src/types/platform.d.ts +17 -0
  70. package/dist/plugin/theme/src/utils/create-custom-error.d.ts +5 -0
  71. package/dist/plugin/theme/src/utils/create-hidden-element.d.ts +1 -1
  72. package/dist/plugin/theme/src/utils/dynamic-import.d.ts +1 -0
  73. package/dist/src/constants/platform.d.ts +21 -12
  74. package/dist/src/types/platform.d.ts +17 -0
  75. package/dist/src/utils/create-custom-error.d.ts +5 -0
  76. package/dist/src/utils/create-hidden-element.d.ts +1 -1
  77. package/dist/src/utils/dynamic-import.d.ts +1 -0
  78. package/package.json +1 -8
@@ -1 +1 @@
1
- function t(t,e){void 0===e&&(e=!0);var n=globalThis.document.createElement(t);return"width"in n&&(n.width="0"),"height"in n&&(n.height="0"),"border"in n&&(n.border="0"),"frameBorder"in n&&(n.frameBorder="0"),"scrolling"in n&&(n.scrolling="no"),"cellPadding"in n&&(n.cellPadding="0"),"cellSpacing"in n&&(n.cellSpacing="0"),"frame"in n&&(n.frame="void"),"rules"in n&&(n.rules="none"),"noWrap"in n&&(n.noWrap=!0),n.tabIndex=-1,n.setAttribute("role","presentation"),e?(n.style.width="1px",n.style.height="1px"):(n.setAttribute("aria-hidden","true"),n.style.width="0",n.style.height="0",n.style.zIndex="-9999",n.style.display="none",n.style.visibility="hidden",n.style.pointerEvents="none"),n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.padding="0",n.style.margin="0",n.style.border="none",n.style.outline="none",n.style.clip="rect(1px, 1px, 1px, 1px)",n.style.clipPath="inset(50%)",n.style.overflow="hidden",n.style.whiteSpace="nowrap",n}function e(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r="",o=0;o<e.length-2;o++){var i=e[o];void 0!==i&&(r=r+i.charAt(0).toUpperCase()+i.slice(1))}return r}function n(){this.returnValue=!1}function r(){this.cancelBubble=!0}var o=/(animation)(start|iteration|end|cancel)|(transition)(start|run|end|cancel)|(fullscreen)(change|error)|(lost|got)(pointer)(capture)|(pointer)(lock)(change|error)|(pointer)(cancel|down|enter|leave|move|out|over|up)/i,i=["","webkit","moz","ms","MS","o","O"],a={wheel:["wheel","mousewheel","DOMMouseScroll"],focus:["focus","focusin"],blur:["blur","focusout"],beforeinput:["beforeinput","textInput"]},l={useStd:void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener,add:function(t,e){void 0===e&&(e={callback:null,options:!1});var o=e.callback;if(void 0!==t&&null!==o){var i=l.withVender(t,e.type),a=e.options;if("function"==typeof t.addEventListener)try{return t.addEventListener(i,o,a)}catch(t){}if("function"==typeof t.addListener)if("boolean"==typeof t.matches)try{return t.addListener(o)}catch(t){}else try{return t.addListener(i,o)}catch(t){}return"function"==typeof t.attachEvent?o.__ieWrapper?t.attachEvent("on"+i,o.__ieWrapper):t.attachEvent("on"+i,o.__ieWrapper=function(e){void 0===e&&(e=globalThis.event),void 0!==e&&(e.currentTarget=t,"function"!=typeof e.preventDefault&&(e.preventDefault=n),"function"!=typeof e.stopPropagation&&(e.stopPropagation=r),"function"==typeof o?o.call(t,e):o&&"function"==typeof o.handleEvent&&o.handleEvent.call(t,e))}):void 0}},remove:function(t,e){void 0===e&&(e={callback:null,options:!1});var n=e.callback;if(void 0!==t&&null!==n){var r=l.withVender(t,e.type),o=e.options;if("function"==typeof t.removeEventListener)try{return t.removeEventListener(r,n,o)}catch(t){}if("function"==typeof t.removeListener)if("boolean"==typeof t.matches)try{return t.removeListener(n)}catch(t){}else try{return t.removeListener(r,n)}catch(t){}if("function"!=typeof t.detachEvent);else{var i=n.__ieWrapper;void 0!==i&&(t.detachEvent("on"+r,i),delete n.__ieWrapper)}}},withVender:function(t,n){if(void 0===n)return"";if("webkitEnterFullscreen"in t&&["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"].indexOf(n)>-1)return n;var r;r=n in a?a[n]:o.test(n)?[n,n.replace(o,e)]:[n];for(var l=0;l<i.length;l++)for(var c=0;c<r.length;c++){var u=i[l]+r[c];if(void 0!==t["on"+u])return u}return""}};function c(t){return null!==t&&"object"==typeof t}function u(t){return c(t)||function(t){return Array.isArray(t)}(t)}function s(t){if(function(t){return c(t)&&"innerHTML"in t}(t))return t.innerHTML;if(u(t))try{return JSON.stringify(t)}catch(e){return""+t}else if("string"!=typeof t)return""+t;return t}function d(){return function(){if("isSecureContext"in window)return globalThis.isSecureContext;var t=location.protocol,e=location.hostname;return"https:"===t||"localhost"===e||"127.0.0.1"===e||"[::1]"===e}()&&"undefined"!=typeof navigator&&"clipboard"in navigator}function p(e){return function(e){if(!globalThis.getSelection||!globalThis.document.createRange)return!1;var n=t("div");n.contentEditable="true",n.innerHTML=e,n.style.whiteSpace="pre",n.style.userSelect="text",n.style.setProperty("-webkit-user-select","text"),n.style.setProperty("-moz-user-select","text"),n.style.setProperty("-ms-user-select","text"),globalThis.document.body.appendChild(n);var r=globalThis.getSelection(),o=globalThis.document.createRange(),i=function(t){try{null!==t.clipboardData&&"function"==typeof t.clipboardData.setData&&(t.preventDefault(),t.clipboardData.setData("text/html",e),t.clipboardData.setData("text/plain",e))}catch(t){}};l.add(globalThis.document,{type:"copy",callback:i,options:{once:!0,capture:!0}});try{if(null===r)return h(n,r,i),!1;r.removeAllRanges(),o.selectNodeContents(n),r.addRange(o);var a=globalThis.document.execCommand("copy");return h(n,r,i),a}catch(t){return h(n,r,i),!1}}(e)||function(t){var e=window.clipboardData;if(void 0!==e&&"function"==typeof e.setData)try{return e.setData("Text",t)}catch(t){return!1}return!1}(e)}function f(){return function(){var e=t("div");e.contentEditable="true",globalThis.document.body.appendChild(e),e.focus();var n=null,r=function(t){try{null!==t.clipboardData&&"function"==typeof t.clipboardData.getData&&(t.preventDefault(),n=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain")||null)}catch(t){}};l.add(globalThis.document,{type:"paste",callback:r,options:{once:!0,capture:!0}});try{return globalThis.document.execCommand("paste")||n||(n=e.innerHTML||e.textContent||null),v(e,r),n}catch(t){return v(e,r),null}}()||function(){var t=window.clipboardData;if(void 0!==t&&"function"==typeof t.getData)try{return t.getData("Text")||null}catch(t){return null}return null}()||""}function h(t,e,n){null!==e&&e.removeAllRanges(),globalThis.document.body.removeChild(t),l.remove(globalThis.document,{type:"copy",callback:n})}function v(t,e){globalThis.document.body.removeChild(t),l.remove(globalThis.document,{type:"paste",callback:e})}var y={copy:function(t){var e=s(t);return d()&&("write"in navigator.clipboard||"writeText"in navigator.clipboard)?function(t){try{if("ClipboardItem"in window&&"write"in navigator.clipboard)return navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([t],{type:"text/plain"})})]).then((function(){return!0})).catch((function(){return!1}));if("writeText"in navigator.clipboard)return navigator.clipboard.writeText(t).then((function(){return!0})).catch((function(){return!1}))}catch(t){return Promise.resolve(!1)}return Promise.resolve(!1)}(e).then((function(t){return!!t||p(e)})).catch((function(){return p(e)})):Promise.resolve(p(e))},paste:function(){return d()&&("read"in navigator.clipboard||"readText"in navigator.clipboard)?function(){try{if("ClipboardItem"in window&&"read"in navigator.clipboard)return navigator.clipboard.read().then((function(t){if(0===t.length)return Promise.resolve(null);for(var e=t[0],n=e.types,r=0;r<n.length;r++)if("text/html"===n[r])return e.getType("text/html").then((function(t){return t.text()})).catch((function(){return null}));for(r=0;r<n.length;r++)if("text/plain"===n[r])return e.getType("text/plain").then((function(t){return t.text()})).catch((function(){return null}));return Promise.resolve(null)})).catch((function(){return null}));if("readText"in navigator.clipboard)return navigator.clipboard.readText().then((function(t){return t})).catch((function(){return null}))}catch(t){return Promise.resolve(null)}return Promise.resolve(null)}().then((function(t){return null!==t?t:f()})).catch((function(){return f()})):Promise.resolve(f())}},b={installed:!1,name:"Clipboard",module:{copy:y.copy,paste:y.paste},Constants:{},Errors:{}};export{b as default};
1
+ function t(t,e){if(void 0===e&&(e=!0),void 0!==globalThis.document){var n=globalThis.document.createElement(t);return"width"in n&&(n.width="0"),"height"in n&&(n.height="0"),"border"in n&&(n.border="0"),"frameBorder"in n&&(n.frameBorder="0"),"scrolling"in n&&(n.scrolling="no"),"cellPadding"in n&&(n.cellPadding="0"),"cellSpacing"in n&&(n.cellSpacing="0"),"frame"in n&&(n.frame="void"),"rules"in n&&(n.rules="none"),"noWrap"in n&&(n.noWrap=!0),n.tabIndex=-1,n.setAttribute("role","presentation"),e?(n.style.width="1px",n.style.height="1px"):(n.setAttribute("aria-hidden","true"),n.style.width="0",n.style.height="0",n.style.zIndex="-9999",n.style.display="none",n.style.visibility="hidden",n.style.pointerEvents="none"),n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.padding="0",n.style.margin="0",n.style.border="none",n.style.outline="none",n.style.clip="rect(1px, 1px, 1px, 1px)",n.style.clipPath="inset(50%)",n.style.overflow="hidden",n.style.whiteSpace="nowrap",n}}function e(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r="",o=0;o<e.length-2;o++){var i=e[o];void 0!==i&&(r=r+i.charAt(0).toUpperCase()+i.slice(1))}return r}function n(){this.returnValue=!1}function r(){this.cancelBubble=!0}var o=/(animation)(start|iteration|end|cancel)|(transition)(start|run|end|cancel)|(fullscreen)(change|error)|(lost|got)(pointer)(capture)|(pointer)(lock)(change|error)|(pointer)(cancel|down|enter|leave|move|out|over|up)/i,i=["","webkit","moz","ms","MS","o","O"],a={wheel:["wheel","mousewheel","DOMMouseScroll"],focus:["focus","focusin"],blur:["blur","focusout"],beforeinput:["beforeinput","textInput"]},l={useStd:void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener,add:function(t,e){void 0===e&&(e={callback:null,options:!1});var o=e.callback;if(void 0!==t&&null!==o){var i=l.withVender(t,e.type),a=e.options;if("function"==typeof t.addEventListener)try{return t.addEventListener(i,o,a)}catch(t){}if("function"==typeof t.addListener)if("boolean"==typeof t.matches)try{return t.addListener(o)}catch(t){}else try{return t.addListener(i,o)}catch(t){}return"function"==typeof t.attachEvent?o.__ieWrapper?t.attachEvent("on"+i,o.__ieWrapper):t.attachEvent("on"+i,o.__ieWrapper=function(e){void 0===e&&(e=globalThis.event),void 0!==e&&(e.currentTarget=t,"function"!=typeof e.preventDefault&&(e.preventDefault=n),"function"!=typeof e.stopPropagation&&(e.stopPropagation=r),"function"==typeof o?o.call(t,e):o&&"function"==typeof o.handleEvent&&o.handleEvent.call(t,e))}):void 0}},remove:function(t,e){void 0===e&&(e={callback:null,options:!1});var n=e.callback;if(void 0!==t&&null!==n){var r=l.withVender(t,e.type),o=e.options;if("function"==typeof t.removeEventListener)try{return t.removeEventListener(r,n,o)}catch(t){}if("function"==typeof t.removeListener)if("boolean"==typeof t.matches)try{return t.removeListener(n)}catch(t){}else try{return t.removeListener(r,n)}catch(t){}if("function"!=typeof t.detachEvent);else{var i=n.__ieWrapper;void 0!==i&&(t.detachEvent("on"+r,i),delete n.__ieWrapper)}}},withVender:function(t,n){if(void 0===n)return"";if("webkitEnterFullscreen"in t&&["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"].indexOf(n)>-1)return n;var r;r=n in a?a[n]:o.test(n)?[n,n.replace(o,e)]:[n];for(var l=0;l<i.length;l++)for(var c=0;c<r.length;c++){var u=i[l]+r[c];if(void 0!==t["on"+u])return u}return""}};function c(t){return null!==t&&"object"==typeof t}function u(t){return c(t)||function(t){return Array.isArray(t)}(t)}function s(t){if(function(t){return c(t)&&"innerHTML"in t}(t))return t.innerHTML;if(u(t))try{return JSON.stringify(t)}catch(e){return""+t}else if("string"!=typeof t)return""+t;return t}function d(){return function(){if("isSecureContext"in window)return globalThis.isSecureContext;var t=location.protocol,e=location.hostname;return"https:"===t||"localhost"===e||"127.0.0.1"===e||"[::1]"===e}()&&"undefined"!=typeof navigator&&"clipboard"in navigator}function p(e){return function(e){if(!globalThis.getSelection||!globalThis.document.createRange)return!1;var n=t("div");if(void 0===n)return!1;n.contentEditable="true",n.innerHTML=e,n.style.whiteSpace="pre",n.style.userSelect="text",n.style.setProperty("-webkit-user-select","text"),n.style.setProperty("-moz-user-select","text"),n.style.setProperty("-ms-user-select","text"),globalThis.document.body.appendChild(n);var r=globalThis.getSelection(),o=globalThis.document.createRange(),i=function(t){try{null!==t.clipboardData&&"function"==typeof t.clipboardData.setData&&(t.preventDefault(),t.clipboardData.setData("text/html",e),t.clipboardData.setData("text/plain",e))}catch(t){}};l.add(globalThis.document,{type:"copy",callback:i,options:{once:!0,capture:!0}});try{if(null===r)return h(n,r,i),!1;r.removeAllRanges(),o.selectNodeContents(n),r.addRange(o);var a=globalThis.document.execCommand("copy");return h(n,r,i),a}catch(t){return h(n,r,i),!1}}(e)||function(t){var e=window.clipboardData;if(void 0!==e&&"function"==typeof e.setData)try{return e.setData("Text",t)}catch(t){return!1}return!1}(e)}function f(){return function(){var e=t("div");if(void 0===e)return null;e.contentEditable="true",globalThis.document.body.appendChild(e),e.focus();var n=null,r=function(t){try{null!==t.clipboardData&&"function"==typeof t.clipboardData.getData&&(t.preventDefault(),n=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain")||null)}catch(t){}};l.add(globalThis.document,{type:"paste",callback:r,options:{once:!0,capture:!0}});try{return globalThis.document.execCommand("paste")||n||(n=e.innerHTML||e.textContent||null),v(e,r),n}catch(t){return v(e,r),null}}()||function(){var t=window.clipboardData;if(void 0!==t&&"function"==typeof t.getData)try{return t.getData("Text")||null}catch(t){return null}return null}()||""}function h(t,e,n){null!==e&&e.removeAllRanges(),globalThis.document.body.removeChild(t),l.remove(globalThis.document,{type:"copy",callback:n})}function v(t,e){globalThis.document.body.removeChild(t),l.remove(globalThis.document,{type:"paste",callback:e})}var b={installed:!1,name:"Clipboard",module:{copy:function(t){var e=s(t);return d()&&("write"in navigator.clipboard||"writeText"in navigator.clipboard)?function(t){try{if("ClipboardItem"in window&&"write"in navigator.clipboard)return navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([t],{type:"text/plain"})})]).then((function(){return!0})).catch((function(){return!1}));if("writeText"in navigator.clipboard)return navigator.clipboard.writeText(t).then((function(){return!0})).catch((function(){return!1}))}catch(t){return Promise.resolve(!1)}return Promise.resolve(!1)}(e).then((function(t){return!!t||p(e)})).catch((function(){return p(e)})):Promise.resolve(p(e))},paste:function(){return d()&&("read"in navigator.clipboard||"readText"in navigator.clipboard)?function(){try{if("ClipboardItem"in window&&"read"in navigator.clipboard)return navigator.clipboard.read().then((function(t){if(0===t.length)return Promise.resolve(null);for(var e=t[0],n=e.types,r=0;r<n.length;r++)if("text/html"===n[r])return e.getType("text/html").then((function(t){return t.text()})).catch((function(){return null}));for(r=0;r<n.length;r++)if("text/plain"===n[r])return e.getType("text/plain").then((function(t){return t.text()})).catch((function(){return null}));return Promise.resolve(null)})).catch((function(){return null}));if("readText"in navigator.clipboard)return navigator.clipboard.readText().then((function(t){return t})).catch((function(){return null}))}catch(t){return Promise.resolve(null)}return Promise.resolve(null)}().then((function(t){return null!==t?t:f()})).catch((function(){return f()})):Promise.resolve(f())}},Constants:{},Errors:{}};export{b as default};
@@ -1,5 +1,7 @@
1
1
  function createHiddenElement(tagName, focusable) {
2
2
  if (focusable === void 0) { focusable = true; }
3
+ if (typeof globalThis.document === 'undefined')
4
+ return undefined;
3
5
  var element = globalThis.document.createElement(tagName);
4
6
  if ('width' in element)
5
7
  element.width = '0';
@@ -291,6 +293,8 @@ function copyViaSelection(text) {
291
293
  if (!globalThis.getSelection || !globalThis.document.createRange)
292
294
  return false;
293
295
  var div = createHiddenElement('div');
296
+ if (div === undefined)
297
+ return false;
294
298
  div.contentEditable = 'true';
295
299
  div.innerHTML = text;
296
300
  div.style.whiteSpace = 'pre';
@@ -414,6 +418,8 @@ function pasteViaClipboardAPI() {
414
418
  }
415
419
  function pasteViaSelection() {
416
420
  var div = createHiddenElement('div');
421
+ if (div === undefined)
422
+ return null;
417
423
  div.contentEditable = 'true';
418
424
  globalThis.document.body.appendChild(div);
419
425
  div.focus();
@@ -473,10 +479,7 @@ var ClipboardUtils = {
473
479
  paste: paste
474
480
  };
475
481
 
476
- var Clipboard = {
477
- copy: ClipboardUtils.copy,
478
- paste: ClipboardUtils.paste,
479
- };
482
+ var Clipboard = ClipboardUtils;
480
483
 
481
484
  var NativeClipboardPlugin = {
482
485
  installed: false,
@@ -6,6 +6,8 @@
6
6
 
7
7
  function createHiddenElement(tagName, focusable) {
8
8
  if (focusable === void 0) { focusable = true; }
9
+ if (typeof globalThis.document === 'undefined')
10
+ return undefined;
9
11
  var element = globalThis.document.createElement(tagName);
10
12
  if ('width' in element)
11
13
  element.width = '0';
@@ -297,6 +299,8 @@
297
299
  if (!globalThis.getSelection || !globalThis.document.createRange)
298
300
  return false;
299
301
  var div = createHiddenElement('div');
302
+ if (div === undefined)
303
+ return false;
300
304
  div.contentEditable = 'true';
301
305
  div.innerHTML = text;
302
306
  div.style.whiteSpace = 'pre';
@@ -420,6 +424,8 @@
420
424
  }
421
425
  function pasteViaSelection() {
422
426
  var div = createHiddenElement('div');
427
+ if (div === undefined)
428
+ return null;
423
429
  div.contentEditable = 'true';
424
430
  globalThis.document.body.appendChild(div);
425
431
  div.focus();
@@ -479,10 +485,7 @@
479
485
  paste: paste
480
486
  };
481
487
 
482
- var Clipboard = {
483
- copy: ClipboardUtils.copy,
484
- paste: ClipboardUtils.paste,
485
- };
488
+ var Clipboard = ClipboardUtils;
486
489
 
487
490
  var NativeClipboardPlugin = {
488
491
  installed: false,
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Clipboard=t()}(this,(function(){"use strict";function e(e,t){void 0===t&&(t=!0);var n=globalThis.document.createElement(e);return"width"in n&&(n.width="0"),"height"in n&&(n.height="0"),"border"in n&&(n.border="0"),"frameBorder"in n&&(n.frameBorder="0"),"scrolling"in n&&(n.scrolling="no"),"cellPadding"in n&&(n.cellPadding="0"),"cellSpacing"in n&&(n.cellSpacing="0"),"frame"in n&&(n.frame="void"),"rules"in n&&(n.rules="none"),"noWrap"in n&&(n.noWrap=!0),n.tabIndex=-1,n.setAttribute("role","presentation"),t?(n.style.width="1px",n.style.height="1px"):(n.setAttribute("aria-hidden","true"),n.style.width="0",n.style.height="0",n.style.zIndex="-9999",n.style.display="none",n.style.visibility="hidden",n.style.pointerEvents="none"),n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.padding="0",n.style.margin="0",n.style.border="none",n.style.outline="none",n.style.clip="rect(1px, 1px, 1px, 1px)",n.style.clipPath="inset(50%)",n.style.overflow="hidden",n.style.whiteSpace="nowrap",n}function t(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r="",o=0;o<t.length-2;o++){var i=t[o];void 0!==i&&(r=r+i.charAt(0).toUpperCase()+i.slice(1))}return r}function n(){this.returnValue=!1}function r(){this.cancelBubble=!0}var o=/(animation)(start|iteration|end|cancel)|(transition)(start|run|end|cancel)|(fullscreen)(change|error)|(lost|got)(pointer)(capture)|(pointer)(lock)(change|error)|(pointer)(cancel|down|enter|leave|move|out|over|up)/i,i=["","webkit","moz","ms","MS","o","O"],a={wheel:["wheel","mousewheel","DOMMouseScroll"],focus:["focus","focusin"],blur:["blur","focusout"],beforeinput:["beforeinput","textInput"]},l={useStd:void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener,add:function(e,t){void 0===t&&(t={callback:null,options:!1});var o=t.callback;if(void 0!==e&&null!==o){var i=l.withVender(e,t.type),a=t.options;if("function"==typeof e.addEventListener)try{return e.addEventListener(i,o,a)}catch(e){}if("function"==typeof e.addListener)if("boolean"==typeof e.matches)try{return e.addListener(o)}catch(e){}else try{return e.addListener(i,o)}catch(e){}return"function"==typeof e.attachEvent?o.__ieWrapper?e.attachEvent("on"+i,o.__ieWrapper):e.attachEvent("on"+i,o.__ieWrapper=function(t){void 0===t&&(t=globalThis.event),void 0!==t&&(t.currentTarget=e,"function"!=typeof t.preventDefault&&(t.preventDefault=n),"function"!=typeof t.stopPropagation&&(t.stopPropagation=r),"function"==typeof o?o.call(e,t):o&&"function"==typeof o.handleEvent&&o.handleEvent.call(e,t))}):void 0}},remove:function(e,t){void 0===t&&(t={callback:null,options:!1});var n=t.callback;if(void 0!==e&&null!==n){var r=l.withVender(e,t.type),o=t.options;if("function"==typeof e.removeEventListener)try{return e.removeEventListener(r,n,o)}catch(e){}if("function"==typeof e.removeListener)if("boolean"==typeof e.matches)try{return e.removeListener(n)}catch(e){}else try{return e.removeListener(r,n)}catch(e){}if("function"!=typeof e.detachEvent);else{var i=n.__ieWrapper;void 0!==i&&(e.detachEvent("on"+r,i),delete n.__ieWrapper)}}},withVender:function(e,n){if(void 0===n)return"";if("webkitEnterFullscreen"in e&&["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"].indexOf(n)>-1)return n;var r;r=n in a?a[n]:o.test(n)?[n,n.replace(o,t)]:[n];for(var l=0;l<i.length;l++)for(var c=0;c<r.length;c++){var u=i[l]+r[c];if(void 0!==e["on"+u])return u}return""}};function c(e){return null!==e&&"object"==typeof e}function u(e){return c(e)||function(e){return Array.isArray(e)}(e)}function s(e){if(function(e){return c(e)&&"innerHTML"in e}(e))return e.innerHTML;if(u(e))try{return JSON.stringify(e)}catch(t){return""+e}else if("string"!=typeof e)return""+e;return e}function d(){return function(){if("isSecureContext"in window)return globalThis.isSecureContext;var e=location.protocol,t=location.hostname;return"https:"===e||"localhost"===t||"127.0.0.1"===t||"[::1]"===t}()&&"undefined"!=typeof navigator&&"clipboard"in navigator}function p(t){return function(t){if(!globalThis.getSelection||!globalThis.document.createRange)return!1;var n=e("div");n.contentEditable="true",n.innerHTML=t,n.style.whiteSpace="pre",n.style.userSelect="text",n.style.setProperty("-webkit-user-select","text"),n.style.setProperty("-moz-user-select","text"),n.style.setProperty("-ms-user-select","text"),globalThis.document.body.appendChild(n);var r=globalThis.getSelection(),o=globalThis.document.createRange(),i=function(e){try{null!==e.clipboardData&&"function"==typeof e.clipboardData.setData&&(e.preventDefault(),e.clipboardData.setData("text/html",t),e.clipboardData.setData("text/plain",t))}catch(e){}};l.add(globalThis.document,{type:"copy",callback:i,options:{once:!0,capture:!0}});try{if(null===r)return h(n,r,i),!1;r.removeAllRanges(),o.selectNodeContents(n),r.addRange(o);var a=globalThis.document.execCommand("copy");return h(n,r,i),a}catch(e){return h(n,r,i),!1}}(t)||function(e){var t=window.clipboardData;if(void 0!==t&&"function"==typeof t.setData)try{return t.setData("Text",e)}catch(e){return!1}return!1}(t)}function f(){return function(){var t=e("div");t.contentEditable="true",globalThis.document.body.appendChild(t),t.focus();var n=null,r=function(e){try{null!==e.clipboardData&&"function"==typeof e.clipboardData.getData&&(e.preventDefault(),n=e.clipboardData.getData("text/html")||e.clipboardData.getData("text/plain")||null)}catch(e){}};l.add(globalThis.document,{type:"paste",callback:r,options:{once:!0,capture:!0}});try{return globalThis.document.execCommand("paste")||n||(n=t.innerHTML||t.textContent||null),v(t,r),n}catch(e){return v(t,r),null}}()||function(){var e=window.clipboardData;if(void 0!==e&&"function"==typeof e.getData)try{return e.getData("Text")||null}catch(e){return null}return null}()||""}function h(e,t,n){null!==t&&t.removeAllRanges(),globalThis.document.body.removeChild(e),l.remove(globalThis.document,{type:"copy",callback:n})}function v(e,t){globalThis.document.body.removeChild(e),l.remove(globalThis.document,{type:"paste",callback:t})}var y={copy:function(e){var t=s(e);return d()&&("write"in navigator.clipboard||"writeText"in navigator.clipboard)?function(e){try{if("ClipboardItem"in window&&"write"in navigator.clipboard)return navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})})]).then((function(){return!0})).catch((function(){return!1}));if("writeText"in navigator.clipboard)return navigator.clipboard.writeText(e).then((function(){return!0})).catch((function(){return!1}))}catch(e){return Promise.resolve(!1)}return Promise.resolve(!1)}(t).then((function(e){return!!e||p(t)})).catch((function(){return p(t)})):Promise.resolve(p(t))},paste:function(){return d()&&("read"in navigator.clipboard||"readText"in navigator.clipboard)?function(){try{if("ClipboardItem"in window&&"read"in navigator.clipboard)return navigator.clipboard.read().then((function(e){if(0===e.length)return Promise.resolve(null);for(var t=e[0],n=t.types,r=0;r<n.length;r++)if("text/html"===n[r])return t.getType("text/html").then((function(e){return e.text()})).catch((function(){return null}));for(r=0;r<n.length;r++)if("text/plain"===n[r])return t.getType("text/plain").then((function(e){return e.text()})).catch((function(){return null}));return Promise.resolve(null)})).catch((function(){return null}));if("readText"in navigator.clipboard)return navigator.clipboard.readText().then((function(e){return e})).catch((function(){return null}))}catch(e){return Promise.resolve(null)}return Promise.resolve(null)}().then((function(e){return null!==e?e:f()})).catch((function(){return f()})):Promise.resolve(f())}};return{installed:!1,name:"Clipboard",module:{copy:y.copy,paste:y.paste},Constants:{},Errors:{}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Clipboard=t()}(this,(function(){"use strict";function e(e,t){if(void 0===t&&(t=!0),void 0!==globalThis.document){var n=globalThis.document.createElement(e);return"width"in n&&(n.width="0"),"height"in n&&(n.height="0"),"border"in n&&(n.border="0"),"frameBorder"in n&&(n.frameBorder="0"),"scrolling"in n&&(n.scrolling="no"),"cellPadding"in n&&(n.cellPadding="0"),"cellSpacing"in n&&(n.cellSpacing="0"),"frame"in n&&(n.frame="void"),"rules"in n&&(n.rules="none"),"noWrap"in n&&(n.noWrap=!0),n.tabIndex=-1,n.setAttribute("role","presentation"),t?(n.style.width="1px",n.style.height="1px"):(n.setAttribute("aria-hidden","true"),n.style.width="0",n.style.height="0",n.style.zIndex="-9999",n.style.display="none",n.style.visibility="hidden",n.style.pointerEvents="none"),n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.padding="0",n.style.margin="0",n.style.border="none",n.style.outline="none",n.style.clip="rect(1px, 1px, 1px, 1px)",n.style.clipPath="inset(50%)",n.style.overflow="hidden",n.style.whiteSpace="nowrap",n}}function t(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r="",o=0;o<t.length-2;o++){var i=t[o];void 0!==i&&(r=r+i.charAt(0).toUpperCase()+i.slice(1))}return r}function n(){this.returnValue=!1}function r(){this.cancelBubble=!0}var o=/(animation)(start|iteration|end|cancel)|(transition)(start|run|end|cancel)|(fullscreen)(change|error)|(lost|got)(pointer)(capture)|(pointer)(lock)(change|error)|(pointer)(cancel|down|enter|leave|move|out|over|up)/i,i=["","webkit","moz","ms","MS","o","O"],a={wheel:["wheel","mousewheel","DOMMouseScroll"],focus:["focus","focusin"],blur:["blur","focusout"],beforeinput:["beforeinput","textInput"]},l={useStd:void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener,add:function(e,t){void 0===t&&(t={callback:null,options:!1});var o=t.callback;if(void 0!==e&&null!==o){var i=l.withVender(e,t.type),a=t.options;if("function"==typeof e.addEventListener)try{return e.addEventListener(i,o,a)}catch(e){}if("function"==typeof e.addListener)if("boolean"==typeof e.matches)try{return e.addListener(o)}catch(e){}else try{return e.addListener(i,o)}catch(e){}return"function"==typeof e.attachEvent?o.__ieWrapper?e.attachEvent("on"+i,o.__ieWrapper):e.attachEvent("on"+i,o.__ieWrapper=function(t){void 0===t&&(t=globalThis.event),void 0!==t&&(t.currentTarget=e,"function"!=typeof t.preventDefault&&(t.preventDefault=n),"function"!=typeof t.stopPropagation&&(t.stopPropagation=r),"function"==typeof o?o.call(e,t):o&&"function"==typeof o.handleEvent&&o.handleEvent.call(e,t))}):void 0}},remove:function(e,t){void 0===t&&(t={callback:null,options:!1});var n=t.callback;if(void 0!==e&&null!==n){var r=l.withVender(e,t.type),o=t.options;if("function"==typeof e.removeEventListener)try{return e.removeEventListener(r,n,o)}catch(e){}if("function"==typeof e.removeListener)if("boolean"==typeof e.matches)try{return e.removeListener(n)}catch(e){}else try{return e.removeListener(r,n)}catch(e){}if("function"!=typeof e.detachEvent);else{var i=n.__ieWrapper;void 0!==i&&(e.detachEvent("on"+r,i),delete n.__ieWrapper)}}},withVender:function(e,n){if(void 0===n)return"";if("webkitEnterFullscreen"in e&&["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"].indexOf(n)>-1)return n;var r;r=n in a?a[n]:o.test(n)?[n,n.replace(o,t)]:[n];for(var l=0;l<i.length;l++)for(var c=0;c<r.length;c++){var u=i[l]+r[c];if(void 0!==e["on"+u])return u}return""}};function c(e){return null!==e&&"object"==typeof e}function u(e){return c(e)||function(e){return Array.isArray(e)}(e)}function s(e){if(function(e){return c(e)&&"innerHTML"in e}(e))return e.innerHTML;if(u(e))try{return JSON.stringify(e)}catch(t){return""+e}else if("string"!=typeof e)return""+e;return e}function d(){return function(){if("isSecureContext"in window)return globalThis.isSecureContext;var e=location.protocol,t=location.hostname;return"https:"===e||"localhost"===t||"127.0.0.1"===t||"[::1]"===t}()&&"undefined"!=typeof navigator&&"clipboard"in navigator}function f(t){return function(t){if(!globalThis.getSelection||!globalThis.document.createRange)return!1;var n=e("div");if(void 0===n)return!1;n.contentEditable="true",n.innerHTML=t,n.style.whiteSpace="pre",n.style.userSelect="text",n.style.setProperty("-webkit-user-select","text"),n.style.setProperty("-moz-user-select","text"),n.style.setProperty("-ms-user-select","text"),globalThis.document.body.appendChild(n);var r=globalThis.getSelection(),o=globalThis.document.createRange(),i=function(e){try{null!==e.clipboardData&&"function"==typeof e.clipboardData.setData&&(e.preventDefault(),e.clipboardData.setData("text/html",t),e.clipboardData.setData("text/plain",t))}catch(e){}};l.add(globalThis.document,{type:"copy",callback:i,options:{once:!0,capture:!0}});try{if(null===r)return h(n,r,i),!1;r.removeAllRanges(),o.selectNodeContents(n),r.addRange(o);var a=globalThis.document.execCommand("copy");return h(n,r,i),a}catch(e){return h(n,r,i),!1}}(t)||function(e){var t=window.clipboardData;if(void 0!==t&&"function"==typeof t.setData)try{return t.setData("Text",e)}catch(e){return!1}return!1}(t)}function p(){return function(){var t=e("div");if(void 0===t)return null;t.contentEditable="true",globalThis.document.body.appendChild(t),t.focus();var n=null,r=function(e){try{null!==e.clipboardData&&"function"==typeof e.clipboardData.getData&&(e.preventDefault(),n=e.clipboardData.getData("text/html")||e.clipboardData.getData("text/plain")||null)}catch(e){}};l.add(globalThis.document,{type:"paste",callback:r,options:{once:!0,capture:!0}});try{return globalThis.document.execCommand("paste")||n||(n=t.innerHTML||t.textContent||null),v(t,r),n}catch(e){return v(t,r),null}}()||function(){var e=window.clipboardData;if(void 0!==e&&"function"==typeof e.getData)try{return e.getData("Text")||null}catch(e){return null}return null}()||""}function h(e,t,n){null!==t&&t.removeAllRanges(),globalThis.document.body.removeChild(e),l.remove(globalThis.document,{type:"copy",callback:n})}function v(e,t){globalThis.document.body.removeChild(e),l.remove(globalThis.document,{type:"paste",callback:t})}return{installed:!1,name:"Clipboard",module:{copy:function(e){var t=s(e);return d()&&("write"in navigator.clipboard||"writeText"in navigator.clipboard)?function(e){try{if("ClipboardItem"in window&&"write"in navigator.clipboard)return navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})})]).then((function(){return!0})).catch((function(){return!1}));if("writeText"in navigator.clipboard)return navigator.clipboard.writeText(e).then((function(){return!0})).catch((function(){return!1}))}catch(e){return Promise.resolve(!1)}return Promise.resolve(!1)}(t).then((function(e){return!!e||f(t)})).catch((function(){return f(t)})):Promise.resolve(f(t))},paste:function(){return d()&&("read"in navigator.clipboard||"readText"in navigator.clipboard)?function(){try{if("ClipboardItem"in window&&"read"in navigator.clipboard)return navigator.clipboard.read().then((function(e){if(0===e.length)return Promise.resolve(null);for(var t=e[0],n=t.types,r=0;r<n.length;r++)if("text/html"===n[r])return t.getType("text/html").then((function(e){return e.text()})).catch((function(){return null}));for(r=0;r<n.length;r++)if("text/plain"===n[r])return t.getType("text/plain").then((function(e){return e.text()})).catch((function(){return null}));return Promise.resolve(null)})).catch((function(){return null}));if("readText"in navigator.clipboard)return navigator.clipboard.readText().then((function(e){return e})).catch((function(){return null}))}catch(e){return Promise.resolve(null)}return Promise.resolve(null)}().then((function(e){return null!==e?e:p()})).catch((function(){return p()})):Promise.resolve(p())}},Constants:{},Errors:{}}}));
@@ -1,3 +1,22 @@
1
+ import { PlatformInstance } from "../types/platform";
2
+ declare global {
3
+ interface Navigator {
4
+ userAgentData?: UserAgentData;
5
+ }
6
+ }
7
+ interface ModernUserAgentDataBrand {
8
+ brand: string;
9
+ version: string;
10
+ }
11
+ type UserAgentDataBrand = ModernUserAgentDataBrand | string | null | undefined;
12
+ interface UserAgentDataValues {
13
+ brands?: UserAgentDataBrand[];
14
+ fullVersionList?: UserAgentDataBrand[];
15
+ platformVersion?: string | null | undefined;
16
+ }
17
+ interface UserAgentData {
18
+ getHighEntropyValues?(hints: string[]): Promise<UserAgentDataValues>;
19
+ }
1
20
  export declare enum OS {
2
21
  Unknown = "Unknown",
3
22
  Android = "Android",
@@ -33,15 +52,5 @@ export declare enum Browsers {
33
52
  IE = "IE",
34
53
  SamsungInternet = "SamsungInternet"
35
54
  }
36
- export declare let DEVICE_NAME: Devices;
37
- export declare let OS_NAME: OS;
38
- export declare let OS_VERSION: string;
39
- export declare let ENGINE_NAME: Engines;
40
- export declare let ENGINE_VERSION: string;
41
- export declare let BROWSER_NAME: Browsers;
42
- export declare let BROWSER_VERSION: string;
43
- export declare const RENDERER: string;
44
- export declare const IS_WEBVIEW: boolean;
45
- export declare const IS_MOBILE: boolean;
46
- export declare const IS_DESKTOP: boolean;
47
- export declare const IS_STANDALONE: boolean;
55
+ declare const Platform: PlatformInstance;
56
+ export default Platform;
@@ -0,0 +1,17 @@
1
+ import { Browsers, Devices, Engines, OS } from "../constants/platform";
2
+ export declare interface PlatformInstance {
3
+ os: OS;
4
+ device: Devices;
5
+ engine: Engines;
6
+ browser: Browsers;
7
+ osVersion: string;
8
+ engineVersion: string;
9
+ browserVersion: string;
10
+ renderer: string;
11
+ userAgent: string;
12
+ isWebview: boolean;
13
+ isStandalone: boolean;
14
+ isMobile: boolean;
15
+ isDesktop: boolean;
16
+ isNodeJS: boolean;
17
+ }
@@ -1 +1,6 @@
1
+ declare global {
2
+ interface ErrorConstructor {
3
+ captureStackTrace?: (targetObject: object, constructorOpt?: Function) => void;
4
+ }
5
+ }
1
6
  export default function createCustomError(name: string, Base?: ErrorConstructor): ErrorConstructor;
@@ -1 +1 @@
1
- export default function createHiddenElement<K extends keyof HTMLElementTagNameMap>(tagName: K, focusable?: boolean): HTMLElementTagNameMap[K];
1
+ export default function createHiddenElement<K extends keyof HTMLElementTagNameMap>(tagName: K, focusable?: boolean): HTMLElementTagNameMap[K] | undefined;
@@ -0,0 +1 @@
1
+ export default function dynamicImport<T = any>(moduleName: string): Promise<T | null>;
@@ -1,6 +1,22 @@
1
1
  'use strict';
2
2
 
3
- var USER_AGENT = navigator.userAgent;
3
+ function dynamicImport(moduleName) {
4
+ if ('require' in globalThis && typeof globalThis.require === 'function') {
5
+ try {
6
+ return Promise.resolve(globalThis.require(moduleName));
7
+ }
8
+ catch (_) {
9
+ return Promise.resolve(null);
10
+ }
11
+ }
12
+ return import(moduleName)
13
+ .then(function (module) {
14
+ return (module.default || module);
15
+ })
16
+ .catch(function () {
17
+ return Promise.resolve(null);
18
+ });
19
+ }
4
20
 
5
21
  var OS;
6
22
  (function (OS) {
@@ -41,46 +57,22 @@ var Browsers;
41
57
  Browsers["IE"] = "IE";
42
58
  Browsers["SamsungInternet"] = "SamsungInternet";
43
59
  })(Browsers || (Browsers = {}));
44
- var DEVICE_NAME = Devices.Unknown;
45
- var OS_NAME = OS.Unknown;
46
- Engines.Unknown;
47
- Browsers.Unknown;
48
- function resolveWindowsVersion(string) {
49
- if (string === undefined)
50
- return '';
51
- var mapped = {
52
- '4.90': 'ME',
53
- 'NT3.51': 'NT 3.11',
54
- 'NT4.0': 'NT 4.0',
55
- 'NT 5.0': '2000',
56
- 'NT 5.1': 'XP',
57
- 'NT 5.2': 'XP',
58
- 'NT 6.0': 'Vista',
59
- 'NT 6.1': '7',
60
- 'NT 6.2': '8',
61
- 'NT 6.3': '8.1',
62
- 'NT 6.4': '10',
63
- 'NT 10.0': '10',
64
- 'ARM': 'RT'
65
- }[string];
66
- if (mapped !== undefined)
67
- return mapped;
68
- return string;
69
- }
70
- function resolveUnderscoreVersion(string) {
71
- if (string === undefined)
72
- return '';
73
- return string.replace(/_/g, '.');
74
- }
75
- function resolveVersion(string, resolver) {
76
- if (typeof resolver === 'function')
77
- return resolver(string);
78
- if (typeof resolver === 'string')
79
- return resolver;
80
- if (string === undefined)
81
- return '';
82
- return string;
83
- }
60
+ var Platform = {
61
+ device: Devices.Unknown,
62
+ os: OS.Unknown,
63
+ osVersion: '',
64
+ engine: Engines.Unknown,
65
+ engineVersion: '',
66
+ browser: Browsers.Unknown,
67
+ browserVersion: '',
68
+ renderer: getRenderer(),
69
+ userAgent: navigator.userAgent,
70
+ isWebview: false,
71
+ isMobile: false,
72
+ isDesktop: false,
73
+ isStandalone: false,
74
+ isNodeJS: getIsNode(),
75
+ };
84
76
  var OS_RESOLVER_MAP = [
85
77
  [/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
86
78
  [/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, OS.Windows, resolveWindowsVersion],
@@ -139,73 +131,240 @@ var BROWSER_RESOLVER_MAP = [
139
131
  [/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
140
132
  [/firefox\/([\w.]+)/i, Browsers.Firefox],
141
133
  ];
134
+ function resolveWindowsVersion(string) {
135
+ if (string === undefined)
136
+ return '';
137
+ var mapped = {
138
+ '4.90': 'ME',
139
+ 'NT3.51': 'NT 3.11',
140
+ 'NT4.0': 'NT 4.0',
141
+ 'NT 5.0': '2000',
142
+ 'NT 5.1': 'XP',
143
+ 'NT 5.2': 'XP',
144
+ 'NT 6.0': 'Vista',
145
+ 'NT 6.1': '7',
146
+ 'NT 6.2': '8',
147
+ 'NT 6.3': '8.1',
148
+ 'NT 6.4': '10',
149
+ 'NT 10.0': '10',
150
+ 'ARM': 'RT'
151
+ }[string];
152
+ if (mapped !== undefined)
153
+ return mapped;
154
+ return string;
155
+ }
156
+ function resolveUnderscoreVersion(string) {
157
+ if (string === undefined)
158
+ return '';
159
+ return string.replace(/_/g, '.');
160
+ }
161
+ function resolveVersion(string, resolver) {
162
+ if (typeof resolver === 'function')
163
+ return resolver(string);
164
+ if (typeof resolver === 'string')
165
+ return resolver;
166
+ if (string === undefined)
167
+ return '';
168
+ return string;
169
+ }
170
+ function normalizeBrand(entry) {
171
+ if (entry === null || entry === undefined)
172
+ return { brand: '', version: '' };
173
+ if (typeof entry === 'string')
174
+ return { brand: entry, version: '' };
175
+ return { brand: entry.brand, version: entry.version };
176
+ }
177
+ function getRenderer() {
178
+ if (typeof globalThis.document === 'undefined')
179
+ return '';
180
+ var canvas = globalThis.document.createElement('canvas');
181
+ if (typeof canvas.getContext !== 'function')
182
+ return '';
183
+ var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
184
+ if (context === null)
185
+ return '';
186
+ if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
187
+ var extension = context.getExtension('WEBGL_debug_renderer_info');
188
+ if (extension === null)
189
+ return context.getParameter(context.RENDERER);
190
+ else
191
+ return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
192
+ }
193
+ else {
194
+ return '';
195
+ }
196
+ }
197
+ function getIsStandalone(os) {
198
+ if (!('matchMedia' in globalThis))
199
+ return false;
200
+ if (os === OS.iOS)
201
+ return 'standalone' in navigator && !!navigator.standalone;
202
+ return globalThis.matchMedia('(display-mode: standalone)').matches;
203
+ }
204
+ function getIsWebview() {
205
+ return /; ?wv|applewebkit(?!.*safari)/i.test(Platform.userAgent);
206
+ }
207
+ function getIsNode() {
208
+ return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
209
+ }
210
+ function getNodeOSVersion(string) {
211
+ var parts = string.split('.');
212
+ return {
213
+ major: parseInt(parts[0] || '0'),
214
+ minor: parseInt(parts[1] || '0'),
215
+ build: parseInt(parts[2] || '0')
216
+ };
217
+ }
142
218
  for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
143
219
  var map = OS_RESOLVER_MAP[i];
144
220
  var regexp = map[0];
145
221
  var os = map[1];
146
222
  var resolver = map[2];
147
- var matched = USER_AGENT.match(regexp);
223
+ var matched = Platform.userAgent.match(regexp);
148
224
  if (matched !== null) {
149
- OS_NAME = os;
150
- resolveVersion(matched[1], resolver);
225
+ Platform.os = os;
226
+ Platform.osVersion = resolveVersion(matched[1], resolver);
151
227
  if (os === OS.iOS || os === OS.Android)
152
- DEVICE_NAME = Devices.Mobile;
228
+ Platform.device = Devices.Mobile;
153
229
  else if (os === OS.Windows || os === OS.MacOS)
154
- DEVICE_NAME = Devices.Desktop;
230
+ Platform.device = Devices.Desktop;
155
231
  break;
156
232
  }
157
233
  }
158
234
  for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
159
235
  var map = ENGINE_RESOLVER_MAP[i];
160
236
  var regexp = map[0];
161
- map[1];
237
+ var engine = map[1];
162
238
  var resolver = map[2];
163
- var matched = USER_AGENT.match(regexp);
239
+ var matched = Platform.userAgent.match(regexp);
164
240
  if (matched !== null) {
165
- resolveVersion(matched[1], resolver);
241
+ Platform.engine = engine;
242
+ Platform.engineVersion = resolveVersion(matched[1], resolver);
166
243
  break;
167
244
  }
168
245
  }
169
246
  for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
170
247
  var map = BROWSER_RESOLVER_MAP[i];
171
248
  var regexp = map[0];
172
- map[1];
249
+ var browser = map[1];
173
250
  var resolver = map[2];
174
- var matched = USER_AGENT.match(regexp);
251
+ var matched = Platform.userAgent.match(regexp);
175
252
  if (matched !== null) {
176
- resolveVersion(matched[1], resolver);
253
+ Platform.browser = browser;
254
+ Platform.browserVersion = resolveVersion(matched[1], resolver);
177
255
  break;
178
256
  }
179
257
  }
180
- ((function () {
181
- if (typeof globalThis.document === 'undefined')
182
- return '';
183
- var canvas = globalThis.document.createElement('canvas');
184
- if (typeof canvas.getContext !== 'function')
185
- return '';
186
- var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
187
- if (context === null)
188
- return '';
189
- if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
190
- var extension = context.getExtension('WEBGL_debug_renderer_info');
191
- if (extension === null)
192
- return context.getParameter(context.RENDERER);
193
- else
194
- return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
195
- }
196
- else {
197
- return '';
198
- }
199
- }))();
200
- DEVICE_NAME === Devices.Mobile;
201
- DEVICE_NAME === Devices.Desktop;
202
- ((function () {
203
- if (!('matchMedia' in globalThis))
204
- return false;
205
- if (OS_NAME === OS.iOS)
206
- return 'standalone' in navigator && !!navigator.standalone;
207
- return globalThis.matchMedia('(display-mode: standalone)').matches;
208
- }))();
258
+ if (Platform.isNodeJS) {
259
+ dynamicImport('os')
260
+ .then(function (os) {
261
+ if (os === null)
262
+ return;
263
+ var platform = os.platform();
264
+ var release = os.release();
265
+ var version = getNodeOSVersion(release);
266
+ switch (platform) {
267
+ case 'win32':
268
+ Platform.os = OS.Windows;
269
+ if (version.major === 10 && version.minor === 0 && version.build >= 22000)
270
+ Platform.osVersion = '11';
271
+ else if (version.major === 10 && version.minor === 0 && version.build < 22000)
272
+ Platform.osVersion = '10';
273
+ else if (version.major === 6 && version.minor === 3)
274
+ Platform.osVersion = '8.1';
275
+ else if (version.major === 6 && version.minor === 2)
276
+ Platform.osVersion = '8';
277
+ else if (version.major === 6 && version.minor === 1)
278
+ Platform.osVersion = '7';
279
+ else if (version.major === 6 && version.minor === 0)
280
+ Platform.osVersion = 'Vista';
281
+ else if (version.major === 5 && version.minor === 1)
282
+ Platform.osVersion = 'XP';
283
+ else if (version.major === 5 && version.minor === 2)
284
+ Platform.osVersion = 'XP';
285
+ else if (version.major === 5 && version.minor === 0)
286
+ Platform.osVersion = '2000';
287
+ else if (version.major === 4 && version.minor === 90)
288
+ Platform.osVersion = 'ME';
289
+ else if (version.major === 4 && version.minor === 0)
290
+ Platform.osVersion = 'NT 4.0';
291
+ else if (version.major === 3 && version.minor === 51)
292
+ Platform.osVersion = 'NT 3.11';
293
+ else
294
+ Platform.osVersion = release;
295
+ break;
296
+ case 'darwin':
297
+ Platform.os = OS.MacOS;
298
+ if (version.major >= 24)
299
+ Platform.osVersion = '' + (version.major - 9);
300
+ else if (version.major === 23)
301
+ Platform.osVersion = '14';
302
+ else if (version.major === 22)
303
+ Platform.osVersion = '13';
304
+ else if (version.major === 21)
305
+ Platform.osVersion = '12';
306
+ else if (version.major === 20)
307
+ Platform.osVersion = '11';
308
+ else if (version.major === 19)
309
+ Platform.osVersion = '10.15';
310
+ else if (version.major === 18)
311
+ Platform.osVersion = '10.14';
312
+ else if (version.major === 17)
313
+ Platform.osVersion = '10.13';
314
+ else if (version.major === 16)
315
+ Platform.osVersion = '10.12';
316
+ else if (version.major === 15)
317
+ Platform.osVersion = '10.11';
318
+ else if (version.major === 14)
319
+ Platform.osVersion = '10.10';
320
+ else if (version.major === 13)
321
+ Platform.osVersion = '10.9';
322
+ else if (version.major >= 5 && version.major <= 12)
323
+ Platform.osVersion = '10.' + (version.major - 4);
324
+ else
325
+ Platform.osVersion = release;
326
+ break;
327
+ case 'android':
328
+ Platform.os = OS.Android;
329
+ Platform.osVersion = release;
330
+ break;
331
+ case 'linux':
332
+ if (/android/i.test(release)) {
333
+ Platform.os = OS.Android;
334
+ Platform.osVersion = release;
335
+ }
336
+ break;
337
+ }
338
+ });
339
+ }
340
+ if (navigator.userAgentData !== undefined && navigator.userAgentData.getHighEntropyValues !== undefined) {
341
+ navigator
342
+ .userAgentData
343
+ .getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
344
+ .then(function (result) {
345
+ var brands = result.fullVersionList || result.brands || [];
346
+ var platformVersion = result.platformVersion;
347
+ for (var i = 0; i < brands.length; i++) {
348
+ var brand = normalizeBrand(brands[i]);
349
+ var brandName = brand.brand;
350
+ var brandVersion = brand.version;
351
+ if (/not.a.brand/i.test(brandName))
352
+ continue;
353
+ if (brandName === "Chromium")
354
+ Platform.engineVersion = brandVersion;
355
+ }
356
+ if (typeof platformVersion === 'string') {
357
+ if (Platform.os === OS.Windows && parseInt(platformVersion.replace(/[^\d.]/g, '').split('.')[0], 10) >= 13)
358
+ Platform.osVersion = '11';
359
+ else
360
+ Platform.osVersion = platformVersion;
361
+ }
362
+ });
363
+ }
364
+ Platform.isMobile = Platform.device === Devices.Mobile;
365
+ Platform.isDesktop = Platform.device === Devices.Desktop;
366
+ Platform.isWebview = getIsWebview();
367
+ Platform.isStandalone = getIsStandalone(Platform.os);
209
368
 
210
369
  var API_VARIANTS = {
211
370
  standard: {
@@ -267,7 +426,7 @@ function detectApi() {
267
426
  return null;
268
427
  }
269
428
  function isIOS() {
270
- return OS.iOS === OS_NAME;
429
+ return OS.iOS === Platform.os;
271
430
  }
272
431
  function createFullscreenUtils() {
273
432
  var api = detectApi();