@ezuikit/utils-tools 1.0.3 → 1.0.4-beta.1
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/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/types/ezopenUrl.d.ts +9 -3
- package/dist/types/pick.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
*
|
|
3
|
-
* @ezuikit/utils-tools v1.0.
|
|
4
|
-
* Copyright (c) 2024-
|
|
3
|
+
* @ezuikit/utils-tools v1.0.4-beta.1
|
|
4
|
+
* Copyright (c) 2024-10-29 Ezviz-OpenBiz
|
|
5
5
|
* Released under MIT the License.
|
|
6
6
|
*
|
|
7
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&&(r.recType=
|
|
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};
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
*
|
|
3
|
-
* @ezuikit/utils-tools v1.0.
|
|
4
|
-
* Copyright (c) 2024-
|
|
3
|
+
* @ezuikit/utils-tools v1.0.4-beta.1
|
|
4
|
+
* Copyright (c) 2024-10-29 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=
|
|
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};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
*
|
|
3
|
-
* @ezuikit/utils-tools v1.0.
|
|
4
|
-
* Copyright (c) 2024-
|
|
3
|
+
* @ezuikit/utils-tools v1.0.4-beta.1
|
|
4
|
+
* Copyright (c) 2024-10-29 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 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("/"),
|
|
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}}));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
/** 播放类型 live/rec */
|
|
1
2
|
export type EzopenType = 'live' | 'rec' | string;
|
|
3
|
+
/** 现在仅支持 cloud */
|
|
2
4
|
export type EzopenRecType = 'cloud' | string;
|
|
5
|
+
/** 直播的清晰度 */
|
|
3
6
|
export type EzopenDefinition = 'sd' | 'hd' | string;
|
|
7
|
+
/** ezopen 协议地址 解析后的结果 */
|
|
4
8
|
export interface EzopenURL {
|
|
5
9
|
protocol: string;
|
|
6
10
|
search?: string;
|
|
7
|
-
searchParams?: Record<string,
|
|
11
|
+
searchParams?: Record<string, string | number>;
|
|
8
12
|
pathname: string;
|
|
9
13
|
origin: string;
|
|
10
14
|
href: string;
|
|
@@ -22,7 +26,7 @@ export interface EzopenURL {
|
|
|
22
26
|
/**
|
|
23
27
|
* @description 解析ezopen 协议 url
|
|
24
28
|
* @param {string} url ezopen url
|
|
25
|
-
* @returns {
|
|
29
|
+
* @returns {EzopenURL}
|
|
26
30
|
*
|
|
27
31
|
* ```ts
|
|
28
32
|
* parseEzopenUrl("ezopen://open.ys7.com/C116331000/1.cloud.rec?a=00000&b=23&c=%E4%BD%A0%E5%A5%BD%E5%95%8A")
|
|
@@ -33,7 +37,9 @@ export interface SwitchEzpoenOptions {
|
|
|
33
37
|
deviceSerial?: string;
|
|
34
38
|
channelNo?: string;
|
|
35
39
|
type?: EzopenType;
|
|
40
|
+
/** 仅 rec */
|
|
36
41
|
recType?: EzopenRecType;
|
|
42
|
+
/** 仅 live */
|
|
37
43
|
definition?: EzopenDefinition;
|
|
38
44
|
search?: string;
|
|
39
45
|
validateCode?: string;
|
|
@@ -42,7 +48,7 @@ export interface SwitchEzpoenOptions {
|
|
|
42
48
|
* @description exopen 协议播放地址切换(search 中值为空会覆盖url中的值并移除这个参数)
|
|
43
49
|
* @param {string} url exopen 协议播放地址
|
|
44
50
|
* @param {SwitchEzpoenOptions} options
|
|
45
|
-
* @returns
|
|
51
|
+
* @returns {string}
|
|
46
52
|
*
|
|
47
53
|
* @example
|
|
48
54
|
* ```ts
|
package/dist/types/pick.d.ts
CHANGED