@ezuikit/utils-tools 1.0.0-alpha.1 → 1.0.0-alpha.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/dist/index.esm.js CHANGED
@@ -1 +1,8 @@
1
- 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)){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 t=r.pathname.split("/"),i=t[2].split(".");return r.deviceSerial=t[1],r.channelNo=i[0],r.type=i[i.length-1],"live"===r.type&&(r.definition=i.length>2?i[1]:"sd"),"rec"===r.type&&(r.recType=i.length>2?i[1]:""),r.searchParams=e(n),r}return{}}function r(r,t){var i=null!=t?t:{},o=i.type,l=i.channelNo,a=i.recType,c=i.definition,s=i.deviceSerial,p=(null!=t?t:{}).search;if(o||l||a||c||p){var u=n(r);if(p){var h=Object.assign({},u.searchParams,e("?"+p.replace("?","")));p=Object.entries(h).reduce((function(e,n){var r=n[0],t=n[1];return e+=r+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else p=u.search;return u.origin+"/"+(null!=s?s:u.deviceSerial)+"/"+(null!=l?l:u.channelNo)+("rec"===o&&a?"."+a:"")+("live"===o&&"hd"===c?"."+c:"")+"."+(null!=o?o:u.type)+p}return r}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};
1
+ /*
2
+ *
3
+ * @ezuikit/utils-tools v1.0.0-alpha.3
4
+ * Copyright (c) 2024-2-20 Ezviz-OpenBiz
5
+ * Released under MIT the License.
6
+ *
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};
package/dist/index.js CHANGED
@@ -1 +1,8 @@
1
- "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)){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 t=n.pathname.split("/"),i=t[2].split(".");return n.deviceSerial=t[1],n.channelNo=i[0],n.type=i[i.length-1],"live"===n.type&&(n.definition=i.length>2?i[1]:"sd"),"rec"===n.type&&(n.recType=i.length>2?i[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,s=i.recType,a=i.definition,c=i.deviceSerial,p=(null!=t?t:{}).search;if(o||l||s||a||p){var u=r(n);if(p){var h=Object.assign({},u.searchParams,e("?"+p.replace("?","")));p=Object.entries(h).reduce((function(e,r){var n=r[0],t=r[1];return e+=n+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else p=u.search;return u.origin+"/"+(null!=c?c:u.deviceSerial)+"/"+(null!=l?l:u.channelNo)+("rec"===o&&s?"."+s:"")+("live"===o&&"hd"===a?"."+a:"")+"."+(null!=o?o:u.type)+p}return n};
1
+ /*
2
+ *
3
+ * @ezuikit/utils-tools v1.0.0-alpha.3
4
+ * Copyright (c) 2024-2-20 Ezviz-OpenBiz
5
+ * Released under MIT the License.
6
+ *
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};
package/dist/index.umd.js CHANGED
@@ -1 +1,8 @@
1
- !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],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 r(e){var r={};if(/^ezopen:\/\//.test(e)){r.protocol=e.split("//")[0],r.search=e.split("?")[1]?"?"+e.split("?")[1]:"",r.hostname=e.split("/")[2],r.origin=r.protocol+"//"+r.hostname,r.pathname=e.split("?")[0].replace(r.origin,""),r.href=e;var t=r.pathname.split("/"),i=t[2].split(".");return r.deviceSerial=t[1],r.channelNo=i[0],r.type=i[i.length-1],"live"===r.type&&(r.definition=i.length>2?i[1]:"sd"),"rec"===r.type&&(r.recType=i.length>2?i[1]:""),r.searchParams=n(e),r}return{}}e.getQuery=n,e.isHttp=function(e){return/^http[s]?:\/\//.test(e)},e.isMobile=function(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)},e.parseEzopenUrl=r,e.pick=function(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}),{})},e.switchEzopenUrl=function(e,t){var i=null!=t?t:{},o=i.type,l=i.channelNo,s=i.recType,a=i.definition,c=i.deviceSerial,p=(null!=t?t:{}).search;if(o||l||s||a||p){var u=r(e);if(p){var d=Object.assign({},u.searchParams,n("?"+p.replace("?","")));p=Object.entries(d).reduce((function(e,n){var r=n[0],t=n[1];return e+=r+"="+encodeURIComponent(t)+"&"}),"?").replace(/&$/,"")}else p=u.search;return u.origin+"/"+(null!=c?c:u.deviceSerial)+"/"+(null!=l?l:u.channelNo)+("rec"===o&&s?"."+s:"")+("live"===o&&"hd"===a?"."+a:"")+"."+(null!=o?o:u.type)+p}return e}}));
1
+ /*
2
+ *
3
+ * @ezuikit/utils-tools v1.0.0-alpha.3
4
+ * Copyright (c) 2024-2-20 Ezviz-OpenBiz
5
+ * Released under MIT the License.
6
+ *
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,6 +8,7 @@ export interface EzopenURL {
8
8
  hostname: string;
9
9
  deviceSerial: string;
10
10
  channelNo: string;
11
+ validateCode?: string;
11
12
  /** 播放类型 直播 | 回放 */
12
13
  type: 'live' | 'rec' | string;
13
14
  /** 回放存储类型 */
@@ -34,7 +35,7 @@ export interface SwitchEzpoenOptions {
34
35
  search?: string;
35
36
  }
36
37
  /**
37
- * @description exopen 协议播放地址切换
38
+ * @description exopen 协议播放地址切换(search 中值为空会覆盖url中的值并移除这个参数)
38
39
  * @param {string} url exopen 协议播放地址
39
40
  * @param {SwitchEzpoenOptions} options
40
41
  * @returns
@@ -1,6 +1,6 @@
1
- import { parseEzopenUrl, switchEzopenUrl } from './ezopenUrl';
1
+ import { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions } 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, isHttp, isMobile, getQuery, pick };
6
+ export { parseEzopenUrl, switchEzopenUrl, type EzopenURL, type SwitchEzpoenOptions, 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.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "tools utils",
5
5
  "main": "dist/index.js",
6
6
  "umd": "dist/index.umd.js",