@ezuikit/utils-tools 1.0.4 → 1.1.0-alpha.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.
@@ -0,0 +1 @@
1
+ No third parties dependencies
package/dist/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*
2
- *
3
- * @ezuikit/utils-tools v1.0.4
4
- * Copyright (c) 2024-10-29 Ezviz-OpenBiz
5
- * Released under MIT the License.
6
- *
2
+ * @ezuikit/utils-tools v1.1.0-alpha.2
3
+ * tools utils
4
+ * Copyright (c) 2025-07-19 Ezviz-OpenBiz
5
+ * Released under the MIT License.
7
6
  */
8
- "use strict";var e=function(e){var t=e.split("?")[1],r={};if(t)for(var n=t.split("&"),i=0;i<n.length;i++){var o=n[i].split("=");r[o[0]]=decodeURIComponent(o[1])}return r};function t(t){var r={};if(/^ezopen:\/\//.test(t)){if(t.includes("@")){var n=t.indexOf("@"),i=t.indexOf("//");r.validateCode=t.substring(i+2,n),t=t.replace(r.validateCode+"@","")}r.protocol=t.split("//")[0],r.search=t.split("?")[1]?"?"+t.split("?")[1]:"",r.hostname=t.split("/")[2],r.origin=r.protocol+"//"+r.hostname,r.pathname=t.split("?")[0].replace(r.origin,""),r.href=t;var o=r.pathname.split("/"),a=o[2].split(".");return r.deviceSerial=o[1],r.channelNo=a[0],r.type=a[a.length-1],"live"===r.type&&(r.definition=a.length>2?a[1]:"sd"),"rec"===r.type&&o[2]&&(r.recType=o[2].includes(".cloud.")?"cloud":""),r.searchParams=e(t),r}return{}}var r={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};exports.addVc=function(e,t){void 0===t&&(t=["h264"]);var n=(t||["h264"]).reduce((function(e,t){return t=t.toLowerCase(),e+(r[t]||0)}),0),i=e.split("?")[0],o=e.split("?")[1];return o=(o||"").split("&").filter((function(e){return!/^vc=\d?/.test(e)})).join("&"),i+"?"+(o+=(o?"&":"")+"vc="+n)},exports.getQuery=e,exports.getStaticPath=function(e,t){void 0===t&&(t="");var r=/^(https?:\/\/|^\/\/)/;if(""===e||void 0===e)return"";if(r.test(e))return e;e=e.replace(/\/+/g,"/"),t=r.test(t||"")?t:window.location.href;try{return new URL(e,t).href}catch(t){return e}},exports.isHttp=function(e){return/^http[s]?:\/\//.test(e)},exports.isMobile=function(e){var t,r;return!!((null!=e?e:null==(r=window)||null==(t=r.navigator)?void 0:t.userAgent)||"").match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)},exports.parseEzopenUrl=t,exports.pick=function(e,t){return Object.entries(e).reduce((function(e,r){var n=r[0],i=r[1];return t.includes(n)&&(e[n]=i),e}),{})},exports.switchEzopenUrl=function(r,n){var i=null!=n?n:{},o=i.type,a=i.recType,l=i.search,c=i.definition,s=i.channelNo,p=i.deviceSerial,u=i.validateCode,d=t(r);if(l){var h=Object.assign({},d.searchParams,e("?"+l.replace("?","")));l=Object.entries(h).reduce((function(e,t){var r=t[0],n=t[1];return""===n?e:e+=r+"="+encodeURIComponent(n)+"&"}),"?").replace(/&$/,"")}else l=d.search;return o=o||d.type,a=null!=a?a:d.recType,c=null!=c?c:d.definition,s=s||d.channelNo,p=p||d.deviceSerial,u=null!=u?u:d.validateCode,d.protocol+"//"+(u?u+"@":"")+d.hostname+"/"+p+"/"+s+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+l};
7
+ "use strict";const getQuery=url=>{const query=url.split("?")[1],obj={};if(query){const vars=query.split("&");for(let i=0;i<vars.length;i++){const pair=vars[i].split("=");obj[pair[0]]=decodeURIComponent(pair[1])}}return obj};function parseEzopenUrl(url){const obj={};if(/^ezopen:\/\//.test(url)){if(url.includes("@")){const endIndex=url.indexOf("@"),startIndex=url.indexOf("//");obj.validateCode=url.substring(startIndex+2,endIndex),url=url.replace(obj.validateCode+"@","")}obj.protocol=url.split("//")[0],obj.search=url.split("?")[1]?"?"+url.split("?")[1]:"",obj.hostname=url.split("/")[2],obj.origin=obj.protocol+"//"+obj.hostname,obj.pathname=url.split("?")[0].replace(obj.origin,""),obj.href=url;const pathnames=obj.pathname.split("/"),lastPath=pathnames[2].split(".");return obj.deviceSerial=pathnames[1],obj.channelNo=lastPath[0],obj.type=lastPath[lastPath.length-1],"live"===obj.type&&(obj.definition=lastPath.length>2?lastPath[1]:"sd"),"rec"===obj.type&&pathnames[2]&&(obj.recType=pathnames[2].includes(".cloud.")?"cloud":""),obj.searchParams=getQuery(url),obj}return{}}const codec={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};exports.addVc=function(url){const vc=((arguments.length>1&&void 0!==arguments[1]?arguments[1]:["h264"])||["h264"]).reduce(((acc,key)=>(key=key.toLowerCase(),acc+(codec[key]||0))),0),host=url.split("?")[0];let query=url.split("?")[1];return query=(query||"").split("&").filter((item=>!/^vc=\d?/.test(item))).join("&"),query+=`${query?"&":""}vc=${vc}`,host+"?"+query},exports.getQuery=getQuery,exports.getStaticPath=function(path){let base=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const protocolReg=/^(https?:\/\/|^\/\/)/;if(""===path||void 0===path)return"";if(protocolReg.test(path))return path;path=path.replace(/\/+/g,"/"),base=protocolReg.test(base||"")?base:window.location.href;try{return new URL(path,base).href}catch(error){return path}},exports.isHttp=function(url){return/^http[s]?:\/\//.test(url)},exports.isMobile=function(agent){var _navigator;return!!((null!=agent?agent:null==(_navigator=navigator)?void 0:_navigator.userAgent)||"").match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)},exports.parseEzopenUrl=parseEzopenUrl,exports.pick=function(obj,keys){return Object.entries(obj).reduce(((acc,_ref)=>{let[key,value]=_ref;return keys.includes(key)&&(acc[key]=value),acc}),{})},exports.switchEzopenUrl=function(url,options){let{type:type,recType:recType,search:search,definition:definition,channelNo:channelNo,deviceSerial:deviceSerial,validateCode:validateCode}=null!=options?options:{};const obj=parseEzopenUrl(url);if(search){const ns=Object.assign({},obj.searchParams,getQuery("?"+search.replace("?","")));search=Object.entries(ns).reduce(((acc,_ref)=>{let[key,value]=_ref;return""===value?acc:acc+=`${key}=${encodeURIComponent(value)}&`}),"?").replace(/&$/,"")}else search=obj.search;return type=type||obj.type,recType=null!=recType?recType:obj.recType,definition=null!=definition?definition:obj.definition,channelNo=channelNo||obj.channelNo,deviceSerial=deviceSerial||obj.deviceSerial,validateCode=null!=validateCode?validateCode:obj.validateCode,`${obj.protocol}//${validateCode?`${validateCode}@`:""}${obj.hostname}/${deviceSerial}/${channelNo}${"rec"===type&&recType?"."+recType:""}${"live"===type&&"hd"===definition?"."+definition:""}.${type}${search}`};
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ /*
2
+ * @ezuikit/utils-tools v1.1.0-alpha.2
3
+ * tools utils
4
+ * Copyright (c) 2025-07-19 Ezviz-OpenBiz
5
+ * Released under the MIT License.
6
+ */
7
+ const getQuery=url=>{const query=url.split("?")[1],obj={};if(query){const vars=query.split("&");for(let i=0;i<vars.length;i++){const pair=vars[i].split("=");obj[pair[0]]=decodeURIComponent(pair[1])}}return obj};function parseEzopenUrl(url){const obj={};if(/^ezopen:\/\//.test(url)){if(url.includes("@")){const endIndex=url.indexOf("@"),startIndex=url.indexOf("//");obj.validateCode=url.substring(startIndex+2,endIndex),url=url.replace(obj.validateCode+"@","")}obj.protocol=url.split("//")[0],obj.search=url.split("?")[1]?"?"+url.split("?")[1]:"",obj.hostname=url.split("/")[2],obj.origin=obj.protocol+"//"+obj.hostname,obj.pathname=url.split("?")[0].replace(obj.origin,""),obj.href=url;const pathnames=obj.pathname.split("/"),lastPath=pathnames[2].split(".");return obj.deviceSerial=pathnames[1],obj.channelNo=lastPath[0],obj.type=lastPath[lastPath.length-1],"live"===obj.type&&(obj.definition=lastPath.length>2?lastPath[1]:"sd"),"rec"===obj.type&&pathnames[2]&&(obj.recType=pathnames[2].includes(".cloud.")?"cloud":""),obj.searchParams=getQuery(url),obj}return{}}function switchEzopenUrl(url,options){let{type:type,recType:recType,search:search,definition:definition,channelNo:channelNo,deviceSerial:deviceSerial,validateCode:validateCode}=null!=options?options:{};const obj=parseEzopenUrl(url);if(search){const ns=Object.assign({},obj.searchParams,getQuery("?"+search.replace("?","")));search=Object.entries(ns).reduce(((acc,_ref)=>{let[key,value]=_ref;return""===value?acc:acc+=`${key}=${encodeURIComponent(value)}&`}),"?").replace(/&$/,"")}else search=obj.search;return type=type||obj.type,recType=null!=recType?recType:obj.recType,definition=null!=definition?definition:obj.definition,channelNo=channelNo||obj.channelNo,deviceSerial=deviceSerial||obj.deviceSerial,validateCode=null!=validateCode?validateCode:obj.validateCode,`${obj.protocol}//${validateCode?`${validateCode}@`:""}${obj.hostname}/${deviceSerial}/${channelNo}${"rec"===type&&recType?"."+recType:""}${"live"===type&&"hd"===definition?"."+definition:""}.${type}${search}`}function isHttp(url){return/^http[s]?:\/\//.test(url)}function isMobile(agent){var _navigator;return!!((null!=agent?agent:null==(_navigator=navigator)?void 0:_navigator.userAgent)||"").match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)}function pick(obj,keys){return Object.entries(obj).reduce(((acc,_ref)=>{let[key,value]=_ref;return keys.includes(key)&&(acc[key]=value),acc}),{})}function getStaticPath(path){let base=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const protocolReg=/^(https?:\/\/|^\/\/)/;if(""===path||void 0===path)return"";if(protocolReg.test(path))return path;path=path.replace(/\/+/g,"/"),base=protocolReg.test(base||"")?base:window.location.href;try{return new URL(path,base).href}catch(error){return path}}const codec={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};function addVc(url){const vc=((arguments.length>1&&void 0!==arguments[1]?arguments[1]:["h264"])||["h264"]).reduce(((acc,key)=>(key=key.toLowerCase(),acc+(codec[key]||0))),0);const host=url.split("?")[0];let query=url.split("?")[1];return query=(query||"").split("&").filter((item=>!/^vc=\d?/.test(item))).join("&"),query+=`${query?"&":""}vc=${vc}`,host+"?"+query}export{addVc,getQuery,getStaticPath,isHttp,isMobile,parseEzopenUrl,pick,switchEzopenUrl};
package/dist/index.umd.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*
2
- *
3
- * @ezuikit/utils-tools v1.0.4
4
- * Copyright (c) 2024-10-29 Ezviz-OpenBiz
5
- * Released under MIT the License.
6
- *
2
+ * @ezuikit/utils-tools v1.1.0-alpha.2
3
+ * tools utils
4
+ * Copyright (c) 2025-07-19 Ezviz-OpenBiz
5
+ * Released under the MIT License.
7
6
  */
8
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Tools={})}(this,(function(e){"use strict";var t=function(e){var t=e.split("?")[1],n={};if(t)for(var r=t.split("&"),i=0;i<r.length;i++){var o=r[i].split("=");n[o[0]]=decodeURIComponent(o[1])}return n};function n(e){var n={};if(/^ezopen:\/\//.test(e)){if(e.includes("@")){var r=e.indexOf("@"),i=e.indexOf("//");n.validateCode=e.substring(i+2,r),e=e.replace(n.validateCode+"@","")}n.protocol=e.split("//")[0],n.search=e.split("?")[1]?"?"+e.split("?")[1]:"",n.hostname=e.split("/")[2],n.origin=n.protocol+"//"+n.hostname,n.pathname=e.split("?")[0].replace(n.origin,""),n.href=e;var o=n.pathname.split("/"),l=o[2].split(".");return n.deviceSerial=o[1],n.channelNo=l[0],n.type=l[l.length-1],"live"===n.type&&(n.definition=l.length>2?l[1]:"sd"),"rec"===n.type&&o[2]&&(n.recType=o[2].includes(".cloud.")?"cloud":""),n.searchParams=t(e),n}return{}}var r={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};e.addVc=function(e,t){void 0===t&&(t=["h264"]);var n=(t||["h264"]).reduce((function(e,t){return t=t.toLowerCase(),e+(r[t]||0)}),0),i=e.split("?")[0],o=e.split("?")[1];return o=(o||"").split("&").filter((function(e){return!/^vc=\d?/.test(e)})).join("&"),i+"?"+(o+=(o?"&":"")+"vc="+n)},e.getQuery=t,e.getStaticPath=function(e,t){void 0===t&&(t="");var n=/^(https?:\/\/|^\/\/)/;if(""===e||void 0===e)return"";if(n.test(e))return e;e=e.replace(/\/+/g,"/"),t=n.test(t||"")?t:window.location.href;try{return new URL(e,t).href}catch(t){return e}},e.isHttp=function(e){return/^http[s]?:\/\//.test(e)},e.isMobile=function(e){var t,n;return!!((null!=e?e:null==(n=window)||null==(t=n.navigator)?void 0:t.userAgent)||"").match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)},e.parseEzopenUrl=n,e.pick=function(e,t){return Object.entries(e).reduce((function(e,n){var r=n[0],i=n[1];return t.includes(r)&&(e[r]=i),e}),{})},e.switchEzopenUrl=function(e,r){var i=null!=r?r:{},o=i.type,l=i.recType,a=i.search,c=i.definition,s=i.channelNo,d=i.deviceSerial,p=i.validateCode,u=n(e);if(a){var f=Object.assign({},u.searchParams,t("?"+a.replace("?","")));a=Object.entries(f).reduce((function(e,t){var n=t[0],r=t[1];return""===r?e:e+=n+"="+encodeURIComponent(r)+"&"}),"?").replace(/&$/,"")}else a=u.search;return o=o||u.type,l=null!=l?l:u.recType,c=null!=c?c:u.definition,s=s||u.channelNo,d=d||u.deviceSerial,p=null!=p?p:u.validateCode,u.protocol+"//"+(p?p+"@":"")+u.hostname+"/"+d+"/"+s+("rec"===o&&l?"."+l:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+a}}));
7
+ !function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).Tools={})}(this,(function(exports){"use strict";var getQuery=function(url){var query=url.split("?")[1],obj={};if(query)for(var vars=query.split("&"),i=0;i<vars.length;i++){var pair=vars[i].split("=");obj[pair[0]]=decodeURIComponent(pair[1])}return obj};function parseEzopenUrl(url){var obj={};if(/^ezopen:\/\//.test(url)){if(url.includes("@")){var endIndex=url.indexOf("@"),startIndex=url.indexOf("//");obj.validateCode=url.substring(startIndex+2,endIndex),url=url.replace(obj.validateCode+"@","")}obj.protocol=url.split("//")[0],obj.search=url.split("?")[1]?"?"+url.split("?")[1]:"",obj.hostname=url.split("/")[2],obj.origin=obj.protocol+"//"+obj.hostname,obj.pathname=url.split("?")[0].replace(obj.origin,""),obj.href=url;var pathnames=obj.pathname.split("/"),lastPath=pathnames[2].split(".");return obj.deviceSerial=pathnames[1],obj.channelNo=lastPath[0],obj.type=lastPath[lastPath.length-1],"live"===obj.type&&(obj.definition=lastPath.length>2?lastPath[1]:"sd"),"rec"===obj.type&&pathnames[2]&&(obj.recType=pathnames[2].includes(".cloud.")?"cloud":""),obj.searchParams=getQuery(url),obj}return{}}var codec={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};exports.addVc=function(url,codecs){void 0===codecs&&(codecs=["h264"]);var vc=(codecs||["h264"]).reduce((function(acc,key){return key=key.toLowerCase(),acc+(codec[key]||0)}),0),host=url.split("?")[0],query=url.split("?")[1];return query=(query||"").split("&").filter((function(item){return!/^vc=\d?/.test(item)})).join("&"),host+"?"+(query+=(query?"&":"")+"vc="+vc)},exports.getQuery=getQuery,exports.getStaticPath=function(path,base){void 0===base&&(base="");var protocolReg=/^(https?:\/\/|^\/\/)/;if(""===path||void 0===path)return"";if(protocolReg.test(path))return path;path=path.replace(/\/+/g,"/"),base=protocolReg.test(base||"")?base:window.location.href;try{return new URL(path,base).href}catch(error){return path}},exports.isHttp=function(url){return/^http[s]?:\/\//.test(url)},exports.isMobile=function(agent){var _navigator;return!!((null!=agent?agent:null==(_navigator=navigator)?void 0:_navigator.userAgent)||"").match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)},exports.parseEzopenUrl=parseEzopenUrl,exports.pick=function(obj,keys){return Object.entries(obj).reduce((function(acc,param){var key=param[0],value=param[1];return keys.includes(key)&&(acc[key]=value),acc}),{})},exports.switchEzopenUrl=function(url,options){var _ref=null!=options?options:{},type=_ref.type,recType=_ref.recType,search=_ref.search,definition=_ref.definition,channelNo=_ref.channelNo,deviceSerial=_ref.deviceSerial,validateCode=_ref.validateCode,obj=parseEzopenUrl(url);if(search){var ns=Object.assign({},obj.searchParams,getQuery("?"+search.replace("?","")));search=Object.entries(ns).reduce((function(acc,param){var key=param[0],value=param[1];return""===value?acc:acc+=key+"="+encodeURIComponent(value)+"&"}),"?").replace(/&$/,"")}else search=obj.search;return type=type||obj.type,recType=null!=recType?recType:obj.recType,definition=null!=definition?definition:obj.definition,channelNo=channelNo||obj.channelNo,deviceSerial=deviceSerial||obj.deviceSerial,validateCode=null!=validateCode?validateCode:obj.validateCode,obj.protocol+"//"+(validateCode?validateCode+"@":"")+obj.hostname+"/"+deviceSerial+"/"+channelNo+("rec"===type&&recType?"."+recType:"")+("live"===type&&"hd"===definition?"."+definition:"")+"."+type+search}}));
@@ -5,4 +5,4 @@ import { getQuery } from './query';
5
5
  import { pick } from './pick';
6
6
  import { getStaticPath } from './getStaticPath';
7
7
  import { addVc } from './addVc';
8
- export { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType, type EzopenDefinition, isHttp, isMobile, getQuery, pick, getStaticPath, addVc };
8
+ export { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType, type EzopenDefinition, isHttp, isMobile, getQuery, pick, getStaticPath, addVc, };
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@ezuikit/utils-tools",
3
- "version": "1.0.4",
3
+ "version": "1.1.0-alpha.2",
4
4
  "description": "tools utils",
5
5
  "main": "dist/index.js",
6
6
  "umd": "dist/index.umd.js",
7
7
  "types": "dist/types/index.d.ts",
8
- "module": "dist/index.esm.js",
8
+ "module": "dist/index.mjs",
9
9
  "exports": {
10
10
  "types": "./dist/types/index.d.ts",
11
- "import": "./dist/index.esm.js",
11
+ "import": "./dist/index.mjs",
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "scripts": {
15
- "dev": "cross-env NODE_ENV=development rollup --config rollup.config.js --bundleConfigAsCjs --watch",
16
- "build": "cross-env NODE_ENV=production npm run clean && rollup --config rollup.config.js --bundleConfigAsCjs && npm run types && npm run docs",
15
+ "dev": "cross-env NODE_ENV=development rollup --config rollup.config.mjs --watch",
16
+ "build": "npm run clean && cross-env NODE_ENV=production rollup --config rollup.config.mjs && npm run types && npm run docs",
17
17
  "types": "tsc src/index.ts --emitDeclarationOnly --declaration --declarationDir dist/types",
18
18
  "docs": "rimraf docs && typedoc --out docs src",
19
19
  "prebuild": "npm run clean",
@@ -21,17 +21,19 @@
21
21
  "test:watch": "jest --coverage --watch",
22
22
  "clean": "rimraf docs dist coverage",
23
23
  "lint": "eslint .",
24
- "fmt": "prettier --write \"packages/**/src/**/*.{js,ts,json,md}\""
24
+ "fmt": "prettier --write \"src/*.{ts,tsx,js,mjs,cjs,jsx,md,html}\""
25
25
  },
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
29
  "keywords": [
30
- "logger",
31
30
  "ezuikit",
32
31
  "ezuikit-utils",
33
32
  "utils"
34
33
  ],
34
+ "devDependencies": {
35
+ "@config/rollup": "workspace: *"
36
+ },
35
37
  "author": "Ezviz-OpenBiz",
36
38
  "license": "MIT",
37
39
  "publishConfig": {
package/dist/index.esm.js DELETED
@@ -1,8 +0,0 @@
1
- /*
2
- *
3
- * @ezuikit/utils-tools v1.0.4
4
- * Copyright (c) 2024-10-29 Ezviz-OpenBiz
5
- * Released under MIT the License.
6
- *
7
- */
8
- var e=function(e){var n=e.split("?")[1],r={};if(n)for(var t=n.split("&"),i=0;i<t.length;i++){var o=t[i].split("=");r[o[0]]=decodeURIComponent(o[1])}return r};function n(n){var r={};if(/^ezopen:\/\//.test(n)){if(n.includes("@")){var t=n.indexOf("@"),i=n.indexOf("//");r.validateCode=n.substring(i+2,t),n=n.replace(r.validateCode+"@","")}r.protocol=n.split("//")[0],r.search=n.split("?")[1]?"?"+n.split("?")[1]:"",r.hostname=n.split("/")[2],r.origin=r.protocol+"//"+r.hostname,r.pathname=n.split("?")[0].replace(r.origin,""),r.href=n;var o=r.pathname.split("/"),a=o[2].split(".");return r.deviceSerial=o[1],r.channelNo=a[0],r.type=a[a.length-1],"live"===r.type&&(r.definition=a.length>2?a[1]:"sd"),"rec"===r.type&&o[2]&&(r.recType=o[2].includes(".cloud.")?"cloud":""),r.searchParams=e(n),r}return{}}function r(r,t){var i=null!=t?t:{},o=i.type,a=i.recType,l=i.search,c=i.definition,s=i.channelNo,u=i.deviceSerial,d=i.validateCode,p=n(r);if(l){var v=Object.assign({},p.searchParams,e("?"+l.replace("?","")));l=Object.entries(v).reduce((function(e,n){var r=n[0],t=n[1];return""===t?e:e+=r+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else l=p.search;return o=o||p.type,a=null!=a?a:p.recType,c=null!=c?c:p.definition,s=s||p.channelNo,u=u||p.deviceSerial,d=null!=d?d:p.validateCode,p.protocol+"//"+(d?d+"@":"")+p.hostname+"/"+u+"/"+s+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+l}function t(e){return/^http[s]?:\/\//.test(e)}function i(e){var n,r;return!!((null!=e?e:null==(r=window)||null==(n=r.navigator)?void 0:n.userAgent)||"").match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)}function o(e,n){return Object.entries(e).reduce((function(e,r){var t=r[0],i=r[1];return n.includes(t)&&(e[t]=i),e}),{})}function a(e,n){void 0===n&&(n="");var r=/^(https?:\/\/|^\/\/)/;if(""===e||void 0===e)return"";if(r.test(e))return e;e=e.replace(/\/+/g,"/"),n=r.test(n||"")?n:window.location.href;try{return new URL(e,n).href}catch(n){return e}}var l={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};function c(e,n){void 0===n&&(n=["h264"]);var r=(n||["h264"]).reduce((function(e,n){return n=n.toLowerCase(),e+(l[n]||0)}),0),t=e.split("?")[0],i=e.split("?")[1];return i=(i||"").split("&").filter((function(e){return!/^vc=\d?/.test(e)})).join("&"),t+"?"+(i+=(i?"&":"")+"vc="+r)}export{c as addVc,e as getQuery,a as getStaticPath,t as isHttp,i as isMobile,n as parseEzopenUrl,o as pick,r as switchEzopenUrl};