@ezuikit/utils-tools 1.0.0-alpha.3 → 1.0.0-alpha.4

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  *
3
- * @ezuikit/utils-tools v1.0.0-alpha.3
4
- * Copyright (c) 2024-2-20 Ezviz-OpenBiz
3
+ * @ezuikit/utils-tools v1.0.0-alpha.4
4
+ * Copyright (c) 2024-2-26 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 i=n.split("&"),t=0;t<i.length;t++){var l=i[t].split("=");r[l[0]]=decodeURIComponent(l[1])}return r};function n(n){var r={};if(/^ezopen:\/\//.test(n)){if(n.includes("@")){var i=n.indexOf("@"),t=n.indexOf("//");r.validateCode=n.substring(t+2,i),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 l=r.pathname.split("/"),o=l[2].split(".");return r.deviceSerial=l[1],r.channelNo=o[0],r.type=o[o.length-1],"live"===r.type&&(r.definition=o.length>2?o[1]:"sd"),"rec"===r.type&&(r.recType=o.length>2?o[1]:""),r.searchParams=e(n),r}return{}}function r(r,i){var t=null!=i?i:{},l=t.type,o=t.channelNo,a=t.recType,c=t.definition,s=t.deviceSerial,p=(null!=i?i:{}).search;if(l||o||a||c||p){var u=n(r);if(p){var d=Object.assign({},u.searchParams,e("?"+p.replace("?","")));p=Object.entries(d).reduce((function(e,n){var r=n[0],i=n[1];return""===i?e:e+=r+"="+encodeURIComponent(i)+"&"}),"?").replace(/&$/,"")}else p=u.search;return u.origin+"/"+(null!=s?s:u.deviceSerial)+"/"+(null!=o?o:u.channelNo)+("rec"===l&&a?"."+a:"")+("live"===l&&"hd"===c?"."+c:"")+"."+(null!=l?l:u.type)+p}return r}function i(e){return/^http[s]?:\/\//.test(e)}function t(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 l(e,n){return Object.entries(e).reduce((function(e,r){var i=r[0],t=r[1];return n.includes(i)&&(e[i]=t),e}),{})}export{e as getQuery,i as isHttp,t as isMobile,n as parseEzopenUrl,l as pick,r as switchEzopenUrl};
8
+ var e=function(e){var n=e.split("?")[1],r={};if(n)for(var i=n.split("&"),t=0;t<i.length;t++){var o=i[t].split("=");r[o[0]]=decodeURIComponent(o[1])}return r};function n(n){var r={};if(/^ezopen:\/\//.test(n)){if(n.includes("@")){var i=n.indexOf("@"),t=n.indexOf("//");r.validateCode=n.substring(t+2,i),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,i){var t=null!=i?i:{},o=t.type,a=t.recType,l=t.search,c=t.definition,s=t.channelNo,p=t.deviceSerial;if(o||s||a||c||l){var d=n(r);if(l){var u=Object.assign({},d.searchParams,e("?"+l.replace("?","")));l=Object.entries(u).reduce((function(e,n){var r=n[0],i=n[1];return""===i?e:e+=r+"="+encodeURIComponent(i)+"&"}),"?").replace(/&$/,"")}else l=d.search;return o=o||d.type,a=a||d.recType,c=c||d.definition,s=s||d.channelNo,p=p||d.deviceSerial,d.origin+"/"+p+"/"+s+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===c?"."+c:"")+"."+o+l}return r}function i(e){return/^http[s]?:\/\//.test(e)}function t(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 i=r[0],t=r[1];return n.includes(i)&&(e[i]=t),e}),{})}export{e as getQuery,i as isHttp,t 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.3
4
- * Copyright (c) 2024-2-20 Ezviz-OpenBiz
3
+ * @ezuikit/utils-tools v1.0.0-alpha.4
4
+ * Copyright (c) 2024-2-26 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("/"),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.channelNo,a=i.recType,s=i.definition,c=i.deviceSerial,p=(null!=t?t:{}).search;if(o||l||a||s||p){var u=r(n);if(p){var d=Object.assign({},u.searchParams,e("?"+p.replace("?","")));p=Object.entries(d).reduce((function(e,r){var n=r[0],t=r[1];return""===t?e:e+=n+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else p=u.search;return u.origin+"/"+(null!=c?c:u.deviceSerial)+"/"+(null!=l?l:u.channelNo)+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===s?"."+s:"")+"."+(null!=o?o:u.type)+p}return n};
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("/"),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=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,a=i.recType,s=i.search,l=i.definition,c=i.channelNo,p=i.deviceSerial;if(o||c||a||l||s){var d=r(n);if(s){var u=Object.assign({},d.searchParams,e("?"+s.replace("?","")));s=Object.entries(u).reduce((function(e,r){var n=r[0],t=r[1];return""===t?e:e+=n+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else s=d.search;return o=o||d.type,a=a||d.recType,l=l||d.definition,c=c||d.channelNo,p=p||d.deviceSerial,d.origin+"/"+p+"/"+c+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===l?"."+l:"")+"."+o+s}return n};
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  *
3
- * @ezuikit/utils-tools v1.0.0-alpha.3
4
- * Copyright (c) 2024-2-20 Ezviz-OpenBiz
3
+ * @ezuikit/utils-tools v1.0.0-alpha.4
4
+ * Copyright (c) 2024-2-26 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],i={};if(n)for(var r=n.split("&"),t=0;t<r.length;t++){var o=r[t].split("=");i[o[0]]=decodeURIComponent(o[1])}return i};function i(e){var i={};if(/^ezopen:\/\//.test(e)){if(e.includes("@")){var r=e.indexOf("@"),t=e.indexOf("//");i.validateCode=e.substring(t+2,r),e=e.replace(i.validateCode+"@","")}i.protocol=e.split("//")[0],i.search=e.split("?")[1]?"?"+e.split("?")[1]:"",i.hostname=e.split("/")[2],i.origin=i.protocol+"//"+i.hostname,i.pathname=e.split("?")[0].replace(i.origin,""),i.href=e;var o=i.pathname.split("/"),l=o[2].split(".");return i.deviceSerial=o[1],i.channelNo=l[0],i.type=l[l.length-1],"live"===i.type&&(i.definition=l.length>2?l[1]:"sd"),"rec"===i.type&&(i.recType=l.length>2?l[1]:""),i.searchParams=n(e),i}return{}}e.getQuery=n,e.isHttp=function(e){return/^http[s]?:\/\//.test(e)},e.isMobile=function(e){var n,i;return!!((null!=e?e:null==(i=window)||null==(n=i.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=i,e.pick=function(e,n){return Object.entries(e).reduce((function(e,i){var r=i[0],t=i[1];return n.includes(r)&&(e[r]=t),e}),{})},e.switchEzopenUrl=function(e,r){var t=null!=r?r:{},o=t.type,l=t.channelNo,a=t.recType,s=t.definition,c=t.deviceSerial,p=(null!=r?r:{}).search;if(o||l||a||s||p){var u=i(e);if(p){var d=Object.assign({},u.searchParams,n("?"+p.replace("?","")));p=Object.entries(d).reduce((function(e,n){var i=n[0],r=n[1];return""===r?e:e+=i+"="+encodeURIComponent(r)+"&"}),"?").replace(/&$/,"")}else p=u.search;return u.origin+"/"+(null!=c?c:u.deviceSerial)+"/"+(null!=l?l:u.channelNo)+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===s?"."+s:"")+"."+(null!=o?o:u.type)+p}return e}}));
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],i={};if(n)for(var r=n.split("&"),t=0;t<r.length;t++){var o=r[t].split("=");i[o[0]]=decodeURIComponent(o[1])}return i};function i(e){var i={};if(/^ezopen:\/\//.test(e)){if(e.includes("@")){var r=e.indexOf("@"),t=e.indexOf("//");i.validateCode=e.substring(t+2,r),e=e.replace(i.validateCode+"@","")}i.protocol=e.split("//")[0],i.search=e.split("?")[1]?"?"+e.split("?")[1]:"",i.hostname=e.split("/")[2],i.origin=i.protocol+"//"+i.hostname,i.pathname=e.split("?")[0].replace(i.origin,""),i.href=e;var o=i.pathname.split("/"),a=o[2].split(".");return i.deviceSerial=o[1],i.channelNo=a[0],i.type=a[a.length-1],"live"===i.type&&(i.definition=a.length>2?a[1]:"sd"),"rec"===i.type&&(i.recType=a.length>2?a[1]:""),i.searchParams=n(e),i}return{}}e.getQuery=n,e.isHttp=function(e){return/^http[s]?:\/\//.test(e)},e.isMobile=function(e){var n,i;return!!((null!=e?e:null==(i=window)||null==(n=i.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=i,e.pick=function(e,n){return Object.entries(e).reduce((function(e,i){var r=i[0],t=i[1];return n.includes(r)&&(e[r]=t),e}),{})},e.switchEzopenUrl=function(e,r){var t=null!=r?r:{},o=t.type,a=t.recType,l=t.search,s=t.definition,c=t.channelNo,p=t.deviceSerial;if(o||c||a||s||l){var d=i(e);if(l){var u=Object.assign({},d.searchParams,n("?"+l.replace("?","")));l=Object.entries(u).reduce((function(e,n){var i=n[0],r=n[1];return""===r?e:e+=i+"="+encodeURIComponent(r)+"&"}),"?").replace(/&$/,"")}else l=d.search;return o=o||d.type,a=a||d.recType,s=s||d.definition,c=c||d.channelNo,p=p||d.deviceSerial,d.origin+"/"+p+"/"+c+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===s?"."+s:"")+"."+o+l}return e}}));
@@ -1,3 +1,5 @@
1
+ export type EzopenType = 'live' | 'rec' | string;
2
+ export type EzopenRecType = 'cloud' | string;
1
3
  export interface EzopenURL {
2
4
  protocol: string;
3
5
  search?: string;
@@ -10,9 +12,9 @@ export interface EzopenURL {
10
12
  channelNo: string;
11
13
  validateCode?: string;
12
14
  /** 播放类型 直播 | 回放 */
13
- type: 'live' | 'rec' | string;
15
+ type: EzopenType;
14
16
  /** 回放存储类型 */
15
- recType?: 'cloud' | string;
17
+ recType?: EzopenRecType;
16
18
  /** 清晰度 */
17
19
  definition?: 'sd' | 'hd';
18
20
  }
@@ -29,8 +31,8 @@ export declare function parseEzopenUrl(url: string): Partial<EzopenURL>;
29
31
  export interface SwitchEzpoenOptions {
30
32
  deviceSerial?: string;
31
33
  channelNo?: string;
32
- type?: 'live' | 'rec';
33
- recType?: 'cloud';
34
+ type?: EzopenType;
35
+ recType?: EzopenRecType;
34
36
  definition?: 'hd' | 'sd';
35
37
  search?: string;
36
38
  }
@@ -1,6 +1,6 @@
1
- import { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions } from './ezopenUrl';
1
+ import { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType } 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, isHttp, isMobile, getQuery, pick };
6
+ export { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, type EzopenType, type EzopenRecType, 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",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "tools utils",
5
5
  "main": "dist/index.js",
6
6
  "umd": "dist/index.umd.js",