@ezuikit/utils-tools 1.0.0-alpha.4 → 1.0.0-alpha.6
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 +4 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +14 -14
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
*
|
|
3
|
-
* @ezuikit/utils-tools v1.0.0-alpha.
|
|
4
|
-
* Copyright (c) 2024-
|
|
3
|
+
* @ezuikit/utils-tools v1.0.0-alpha.6
|
|
4
|
+
* Copyright (c) 2024-3-1 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
|
|
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,d=i.validateCode,u=n(r);if(l){var h=Object.assign({},u.searchParams,e("?"+l.replace("?","")));l=Object.entries(h).reduce((function(e,n){var r=n[0],t=n[1];return""===t?e:e+=r+"="+encodeURIComponent(t)+"&"}),"?").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 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}),{})}export{e as getQuery,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.0-alpha.
|
|
4
|
-
* Copyright (c) 2024-
|
|
3
|
+
* @ezuikit/utils-tools v1.0.0-alpha.6
|
|
4
|
+
* Copyright (c) 2024-3-1 Ezviz-OpenBiz
|
|
5
5
|
* Released under MIT the License.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
"use strict";var e=function(e){var r=e.split("?")[1],n={};if(r)for(var t=r.split("&"),i=0;i<t.length;i++){var o=t[i].split("=");n[o[0]]=decodeURIComponent(o[1])}return n};function r(r){var n={};if(/^ezopen:\/\//.test(r)){if(r.includes("@")){var t=r.indexOf("@"),i=r.indexOf("//");n.validateCode=r.substring(i+2,t),r=r.replace(n.validateCode+"@","")}n.protocol=r.split("//")[0],n.search=r.split("?")[1]?"?"+r.split("?")[1]:"",n.hostname=r.split("/")[2],n.origin=n.protocol+"//"+n.hostname,n.pathname=r.split("?")[0].replace(n.origin,""),n.href=r;var o=n.pathname.split("/"),
|
|
8
|
+
"use strict";var e=function(e){var r=e.split("?")[1],n={};if(r)for(var t=r.split("&"),i=0;i<t.length;i++){var o=t[i].split("=");n[o[0]]=decodeURIComponent(o[1])}return n};function r(r){var n={};if(/^ezopen:\/\//.test(r)){if(r.includes("@")){var t=r.indexOf("@"),i=r.indexOf("//");n.validateCode=r.substring(i+2,t),r=r.replace(n.validateCode+"@","")}n.protocol=r.split("//")[0],n.search=r.split("?")[1]?"?"+r.split("?")[1]:"",n.hostname=r.split("/")[2],n.origin=n.protocol+"//"+n.hostname,n.pathname=r.split("?")[0].replace(n.origin,""),n.href=r;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=e(r),n}return{}}exports.getQuery=e,exports.isHttp=function(e){return/^http[s]?:\/\//.test(e)},exports.isMobile=function(e){var r,n;return!!((null!=e?e:null==(n=window)||null==(r=n.navigator)?void 0:r.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=r,exports.pick=function(e,r){return Object.entries(e).reduce((function(e,n){var t=n[0],i=n[1];return r.includes(t)&&(e[t]=i),e}),{})},exports.switchEzopenUrl=function(n,t){var i=null!=t?t:{},o=i.type,l=i.recType,a=i.search,s=i.definition,c=i.channelNo,p=i.deviceSerial,d=i.validateCode,u=r(n);if(a){var h=Object.assign({},u.searchParams,e("?"+a.replace("?","")));a=Object.entries(h).reduce((function(e,r){var n=r[0],t=r[1];return""===t?e:e+=n+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else a=u.search;return o=o||u.type,l=null!=l?l: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&&l?"."+l:"")+("live"===o&&"hd"===s?"."+s:"")+"."+o+a};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
*
|
|
3
|
-
* @ezuikit/utils-tools v1.0.0-alpha.
|
|
4
|
-
* Copyright (c) 2024-
|
|
3
|
+
* @ezuikit/utils-tools v1.0.0-alpha.6
|
|
4
|
+
* Copyright (c) 2024-3-1 Ezviz-OpenBiz
|
|
5
5
|
* Released under MIT the License.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).Tools={})}(this,(function(e){"use strict";var n=function(e){var n=e.split("?")[1],
|
|
8
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).Tools={})}(this,(function(e){"use strict";var n=function(e){var n=e.split("?")[1],t={};if(n)for(var i=n.split("&"),r=0;r<i.length;r++){var o=i[r].split("=");t[o[0]]=decodeURIComponent(o[1])}return t};function t(e){var t={};if(/^ezopen:\/\//.test(e)){if(e.includes("@")){var i=e.indexOf("@"),r=e.indexOf("//");t.validateCode=e.substring(r+2,i),e=e.replace(t.validateCode+"@","")}t.protocol=e.split("//")[0],t.search=e.split("?")[1]?"?"+e.split("?")[1]:"",t.hostname=e.split("/")[2],t.origin=t.protocol+"//"+t.hostname,t.pathname=e.split("?")[0].replace(t.origin,""),t.href=e;var o=t.pathname.split("/"),l=o[2].split(".");return t.deviceSerial=o[1],t.channelNo=l[0],t.type=l[l.length-1],"live"===t.type&&(t.definition=l.length>2?l[1]:"sd"),"rec"===t.type&&(t.recType=l.length>2?l[1]:""),t.searchParams=n(e),t}return{}}e.getQuery=n,e.isHttp=function(e){return/^http[s]?:\/\//.test(e)},e.isMobile=function(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)},e.parseEzopenUrl=t,e.pick=function(e,n){return Object.entries(e).reduce((function(e,t){var i=t[0],r=t[1];return n.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,s=r.definition,c=r.channelNo,p=r.deviceSerial,d=r.validateCode,u=t(e);if(a){var f=Object.assign({},u.searchParams,n("?"+a.replace("?","")));a=Object.entries(f).reduce((function(e,n){var t=n[0],i=n[1];return""===i?e:e+=t+"="+encodeURIComponent(i)+"&"}),"?").replace(/&$/,"")}else a=u.search;return o=o||u.type,l=null!=l?l: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&&l?"."+l:"")+("live"===o&&"hd"===s?"."+s:"")+"."+o+a}}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type EzopenType = 'live' | 'rec' | string;
|
|
2
2
|
export type EzopenRecType = 'cloud' | string;
|
|
3
|
+
export type EzopenDefinition = 'sd' | 'hd' | string;
|
|
3
4
|
export interface EzopenURL {
|
|
4
5
|
protocol: string;
|
|
5
6
|
search?: string;
|
|
@@ -16,7 +17,7 @@ export interface EzopenURL {
|
|
|
16
17
|
/** 回放存储类型 */
|
|
17
18
|
recType?: EzopenRecType;
|
|
18
19
|
/** 清晰度 */
|
|
19
|
-
definition?:
|
|
20
|
+
definition?: EzopenDefinition;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* @description 解析ezopen 协议 url
|
|
@@ -33,8 +34,9 @@ export interface SwitchEzpoenOptions {
|
|
|
33
34
|
channelNo?: string;
|
|
34
35
|
type?: EzopenType;
|
|
35
36
|
recType?: EzopenRecType;
|
|
36
|
-
definition?:
|
|
37
|
+
definition?: EzopenDefinition;
|
|
37
38
|
search?: string;
|
|
39
|
+
validateCode?: string;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* @description exopen 协议播放地址切换(search 中值为空会覆盖url中的值并移除这个参数)
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType } from './ezopenUrl';
|
|
1
|
+
import { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType, type EzopenDefinition } from './ezopenUrl';
|
|
2
2
|
import { isHttp } from './isHttp';
|
|
3
3
|
import { isMobile } from './isMobile';
|
|
4
4
|
import { getQuery } from './query';
|
|
5
5
|
import { pick } from './pick';
|
|
6
|
-
export { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType, isHttp, isMobile, getQuery, pick };
|
|
6
|
+
export { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType, type EzopenDefinition, isHttp, isMobile, getQuery, pick };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezuikit/utils-tools",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "tools utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"umd": "dist/index.umd.js",
|
|
@@ -11,18 +11,6 @@
|
|
|
11
11
|
"import": "./dist/index.esm.js",
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
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",
|
|
17
|
-
"types": "tsc src/index.ts --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
18
|
-
"docs": "rimraf docs && typedoc --out docs src",
|
|
19
|
-
"prebuild": "npm run clean",
|
|
20
|
-
"test": "jest --coverage",
|
|
21
|
-
"test:watch": "jest --coverage --watch",
|
|
22
|
-
"clean": "rimraf docs dist coverage",
|
|
23
|
-
"lint": "eslint .",
|
|
24
|
-
"fmt": "prettier --write \"packages/**/src/**/*.{js,ts,json,md}\""
|
|
25
|
-
},
|
|
26
14
|
"files": [
|
|
27
15
|
"dist"
|
|
28
16
|
],
|
|
@@ -37,5 +25,17 @@
|
|
|
37
25
|
"publishConfig": {
|
|
38
26
|
"access": "public",
|
|
39
27
|
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "cross-env NODE_ENV=development rollup --config rollup.config.js --bundleConfigAsCjs --watch",
|
|
31
|
+
"build": "cross-env NODE_ENV=production npm run clean && rollup --config rollup.config.js --bundleConfigAsCjs && npm run types && npm run docs",
|
|
32
|
+
"types": "tsc src/index.ts --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
33
|
+
"docs": "rimraf docs && typedoc --out docs src",
|
|
34
|
+
"prebuild": "npm run clean",
|
|
35
|
+
"test": "jest --coverage",
|
|
36
|
+
"test:watch": "jest --coverage --watch",
|
|
37
|
+
"clean": "rimraf docs dist coverage",
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"fmt": "prettier --write \"packages/**/src/**/*.{js,ts,json,md}\""
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|