@ezuikit/utils-tools 1.0.1 → 1.0.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.
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/types/addVc.d.ts +20 -0
- package/dist/types/getStaticPath.d.ts +11 -0
- package/dist/types/index.d.ts +3 -1
- 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.2
|
|
4
|
+
* Copyright (c) 2024-5-22 Ezviz-OpenBiz
|
|
5
5
|
* Released under MIT the License.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
var e=function(e){var n=e.split("?")[1],
|
|
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};
|
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.2
|
|
4
|
+
* Copyright (c) 2024-5-22 Ezviz-OpenBiz
|
|
5
5
|
* Released under MIT the License.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
"use strict";var e=function(e){var
|
|
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};
|
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.2
|
|
4
|
+
* Copyright (c) 2024-5-22 Ezviz-OpenBiz
|
|
5
5
|
* Released under MIT the License.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
!function(e,
|
|
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}}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取SDK支持的视频编码
|
|
3
|
+
* @example
|
|
4
|
+
* ```
|
|
5
|
+
* getVC() // 1
|
|
6
|
+
* ```
|
|
7
|
+
*/
|
|
8
|
+
export declare const getQueryVC: (CODECS: string[]) => number;
|
|
9
|
+
/**
|
|
10
|
+
* @description 接受一个URL和一个可选的“vc”参数,并返回带有“vc”的URL` 添加或更新了参数。
|
|
11
|
+
* @param {string} url url 地址
|
|
12
|
+
* @param {string[]} codecs 支持的编码格式
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* addVc("https://open.y7.com/xxxxxx.m3u8?a=111", ["h264", "h265"]) // https://open.y7.com/xxxxxx.m3u8?a=111&vc=3
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function addVc(url: string, codecs?: string[]): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 采用一个路径和一个可选的基本URL,并返回一个规范化的静态路径URL。
|
|
3
|
+
* @param {string} path path参数是表示静态资源路径的字符串,例如图像、脚本或样式表。
|
|
4
|
+
* @param {string=} base getStaticPath 函数中的base参数是一个字符串表示将用于解析静态路径的基本URL或路径。如果相对路径是在path`参数中提供,base参数将用作要解析的基本URL
|
|
5
|
+
* @return {string} 处理输入path后的最终URL路径
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* getStaticPath("./")
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function getStaticPath(path: string, base?: string): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ import { isHttp } from './isHttp';
|
|
|
3
3
|
import { isMobile } from './isMobile';
|
|
4
4
|
import { getQuery } from './query';
|
|
5
5
|
import { pick } from './pick';
|
|
6
|
-
|
|
6
|
+
import { getStaticPath } from './getStaticPath';
|
|
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 };
|