@ezuikit/utils-tools 1.0.2 → 1.0.3

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.
package/README.md CHANGED
@@ -1 +1 @@
1
- ## 工具
1
+ ## 工具
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  *
3
- * @ezuikit/utils-tools v1.0.2
4
- * Copyright (c) 2024-5-22 Ezviz-OpenBiz
3
+ * @ezuikit/utils-tools v1.0.3
4
+ * Copyright (c) 2024-7-31 Ezviz-OpenBiz
5
5
  * Released under MIT the License.
6
6
  *
7
7
  */
8
- var e=function(e){var n=e.split("?")[1],t={};if(n)for(var r=n.split("&"),i=0;i<r.length;i++){var o=r[i].split("=");t[o[0]]=decodeURIComponent(o[1])}return t};function n(n){var t={};if(/^ezopen:\/\//.test(n)){if(n.includes("@")){var r=n.indexOf("@"),i=n.indexOf("//");t.validateCode=n.substring(i+2,r),n=n.replace(t.validateCode+"@","")}t.protocol=n.split("//")[0],t.search=n.split("?")[1]?"?"+n.split("?")[1]:"",t.hostname=n.split("/")[2],t.origin=t.protocol+"//"+t.hostname,t.pathname=n.split("?")[0].replace(t.origin,""),t.href=n;var o=t.pathname.split("/"),a=o[2].split(".");return t.deviceSerial=o[1],t.channelNo=a[0],t.type=a[a.length-1],"live"===t.type&&(t.definition=a.length>2?a[1]:"sd"),"rec"===t.type&&(t.recType=a.length>2?a[1]:""),t.searchParams=e(n),t}return{}}function t(t,r){var i=null!=r?r:{},o=i.type,a=i.recType,l=i.search,c=i.definition,s=i.channelNo,p=i.deviceSerial,d=i.validateCode,u=n(t);if(l){var v=Object.assign({},u.searchParams,e("?"+l.replace("?","")));l=Object.entries(v).reduce((function(e,n){var t=n[0],r=n[1];return""===r?e:e+=t+"="+encodeURIComponent(r)+"&"}),"?").replace(/&$/,"")}else l=u.search;return o=o||u.type,a=null!=a?a:u.recType,c=null!=c?c:u.definition,s=s||u.channelNo,p=p||u.deviceSerial,d=null!=d?d:u.validateCode,u.protocol+"//"+(d?d+"@":"")+u.hostname+"/"+p+"/"+s+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+l}function r(e){return/^http[s]?:\/\//.test(e)}function i(e){var n,t;return!!((null!=e?e:null==(t=window)||null==(n=t.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,t){var r=t[0],i=t[1];return n.includes(r)&&(e[r]=i),e}),{})}function a(e,n){void 0===n&&(n="");var t=/^(https?:\/\/|^\/\/)/;return t.test(e)?e:(e=e.replace(/\/+/g,"/"),n=t.test(n||"")?n:window.location.href,new URL(e,n).href)}var l={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32};function c(e,n){void 0===n&&(n=["h264"]);var t=(n||["h264"]).reduce((function(e,n){return n=n.toLowerCase(),e+(l[n]||0)}),0),r=e.split("?")[0],i=e.split("?")[1];return i=(i||"").split("&").filter((function(e){return!/^vc=\d?/.test(e)})).join("&"),r+"?"+(i+=(i?"&":"")+"vc="+t)}export{c as addVc,e as getQuery,a as getStaticPath,r as isHttp,i as isMobile,n as parseEzopenUrl,o as pick,t as switchEzopenUrl};
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&&(r.recType=a.length>2?a[1]:""),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,p=i.deviceSerial,u=i.validateCode,d=n(r);if(l){var v=Object.assign({},d.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=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}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};
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  *
3
- * @ezuikit/utils-tools v1.0.2
4
- * Copyright (c) 2024-5-22 Ezviz-OpenBiz
3
+ * @ezuikit/utils-tools v1.0.3
4
+ * Copyright (c) 2024-7-31 Ezviz-OpenBiz
5
5
  * Released under MIT the License.
6
6
  *
7
7
  */
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&&(r.recType=a.length>2?a[1]:""),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?:\/\/|^\/\/)/;return r.test(e)?e:(e=e.replace(/\/+/g,"/"),t=r.test(t||"")?t:window.location.href,new URL(e,t).href)},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,s=i.definition,c=i.channelNo,p=i.deviceSerial,d=i.validateCode,u=t(r);if(l){var h=Object.assign({},u.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=u.search;return o=o||u.type,a=null!=a?a:u.recType,s=null!=s?s:u.definition,c=c||u.channelNo,p=p||u.deviceSerial,d=null!=d?d:u.validateCode,u.protocol+"//"+(d?d+"@":"")+u.hostname+"/"+p+"/"+c+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===s?"."+s:"")+"."+o+l};
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&&(r.recType=a.length>2?a[1]:""),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,s=i.definition,c=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,s=null!=s?s:d.definition,c=c||d.channelNo,p=p||d.deviceSerial,u=null!=u?u:d.validateCode,d.protocol+"//"+(u?u+"@":"")+d.hostname+"/"+p+"/"+c+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===s?"."+s:"")+"."+o+l};
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  *
3
- * @ezuikit/utils-tools v1.0.2
4
- * Copyright (c) 2024-5-22 Ezviz-OpenBiz
3
+ * @ezuikit/utils-tools v1.0.3
4
+ * Copyright (c) 2024-7-31 Ezviz-OpenBiz
5
5
  * Released under MIT the License.
6
6
  *
7
7
  */
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 i=t.split("&"),r=0;r<i.length;r++){var o=i[r].split("=");n[o[0]]=decodeURIComponent(o[1])}return n};function n(e){var n={};if(/^ezopen:\/\//.test(e)){if(e.includes("@")){var i=e.indexOf("@"),r=e.indexOf("//");n.validateCode=e.substring(r+2,i),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&&(n.recType=l.length>2?l[1]:""),n.searchParams=t(e),n}return{}}var i={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+(i[t]||0)}),0),r=e.split("?")[0],o=e.split("?")[1];return o=(o||"").split("&").filter((function(e){return!/^vc=\d?/.test(e)})).join("&"),r+"?"+(o+=(o?"&":"")+"vc="+n)},e.getQuery=t,e.getStaticPath=function(e,t){void 0===t&&(t="");var n=/^(https?:\/\/|^\/\/)/;return n.test(e)?e:(e=e.replace(/\/+/g,"/"),t=n.test(t||"")?t:window.location.href,new URL(e,t).href)},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 i=n[0],r=n[1];return t.includes(i)&&(e[i]=r),e}),{})},e.switchEzopenUrl=function(e,i){var r=null!=i?i:{},o=r.type,l=r.recType,a=r.search,c=r.definition,s=r.channelNo,p=r.deviceSerial,d=r.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],i=t[1];return""===i?e:e+=n+"="+encodeURIComponent(i)+"&"}),"?").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,p=p||u.deviceSerial,d=null!=d?d:u.validateCode,u.protocol+"//"+(d?d+"@":"")+u.hostname+"/"+p+"/"+s+("rec"===o&&l?"."+l:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+a}}));
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("/"),a=o[2].split(".");return n.deviceSerial=o[1],n.channelNo=a[0],n.type=a[a.length-1],"live"===n.type&&(n.definition=a.length>2?a[1]:"sd"),"rec"===n.type&&(n.recType=a.length>2?a[1]:""),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,a=i.recType,l=i.search,c=i.definition,s=i.channelNo,p=i.deviceSerial,d=i.validateCode,u=n(e);if(l){var f=Object.assign({},u.searchParams,t("?"+l.replace("?","")));l=Object.entries(f).reduce((function(e,t){var n=t[0],r=t[1];return""===r?e:e+=n+"="+encodeURIComponent(r)+"&"}),"?").replace(/&$/,"")}else l=u.search;return o=o||u.type,a=null!=a?a:u.recType,c=null!=c?c:u.definition,s=s||u.channelNo,p=p||u.deviceSerial,d=null!=d?d:u.validateCode,u.protocol+"//"+(d?d+"@":"")+u.hostname+"/"+p+"/"+s+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+l}}));
@@ -5,7 +5,17 @@
5
5
  * @return {string} 处理输入path后的最终URL路径
6
6
  * @example
7
7
  * ```ts
8
- * getStaticPath("./")
8
+ *
9
+ * // base url is https://www.ezviz.com
10
+ * getStaticPath("./") // https://www.ezviz.com
11
+ * getStaticPath("http://www.open.com/staitc") //
12
+ * getStaticPath("http://www.open.com/staitc/") //
13
+ * getStaticPath("https://www.open.com/static") //
14
+ * getStaticPath("https://www.open.com/static/") //
15
+ * getStaticPath("//www.open.com/api") //
16
+ * getStaticPath("//www.open.com/api/") //
17
+ * getStaticPath("/static") // https://www.ezviz.com/static
18
+ * getStaticPath("/static/") // https://www.ezviz.com/static
9
19
  * ```
10
20
  */
11
21
  export declare function getStaticPath(path: string, base?: string): string;
@@ -10,4 +10,4 @@
10
10
  * pick({a: "1", b: "b"}, ['a']) // => {a: 'a'}
11
11
  * ```
12
12
  */
13
- export declare function pick(obj: object, keys: string[]): {};
13
+ export declare function pick(obj: Record<string | number, any>, keys: string[]): {};
@@ -1 +1 @@
1
- export declare const getQuery: (url: string) => Record<string, any>;
1
+ export declare const getQuery: (url: string) => Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezuikit/utils-tools",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "tools utils",
5
5
  "main": "dist/index.js",
6
6
  "umd": "dist/index.umd.js",