Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@taptap/tds-msg

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taptap/tds-msg - npm Package Compare versions

Comparing version 0.2.14 to 0.2.15

2

dist/TdsClient.iife.js

@@ -703,3 +703,3 @@ var TdsClient = (function () {

TdsMsgClient.prototype.sendMessage = function (data) {
window.top.postMessage(data, this.tdsOrigin);
window.parent.postMessage(data, this.tdsOrigin);
};

@@ -706,0 +706,0 @@ /**

@@ -16,3 +16,3 @@ var TdsClient=function(){"use strict";function t(t){var e={exports:{}};return t(e,e.exports),e.exports}t((function(t){function e(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(n)}t.exports=e}));

***************************************************************************** */
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,s=t((function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||t,i),a=n?n+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,r,o=[];if(0===this._eventsCount)return o;for(r in t=this._events)e.call(t,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},c.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},c.prototype.emit=function(t,e,r,o,s,i){var c=n?n+t:t;if(!this._events[c])return!1;var a,u,f=this._events[c],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,r),!0;case 4:return f.fn.call(f.context,e,r,o),!0;case 5:return f.fn.call(f.context,e,r,o,s),!0;case 6:return f.fn.call(f.context,e,r,o,s,i),!0}for(u=1,a=new Array(l-1);u<l;u++)a[u-1]=arguments[u];f.fn.apply(f.context,a)}else{var p,E=f.length;for(u=0;u<E;u++)switch(f[u].once&&this.removeListener(t,f[u].fn,void 0,!0),l){case 1:f[u].fn.call(f[u].context);break;case 2:f[u].fn.call(f[u].context,e);break;case 3:f[u].fn.call(f[u].context,e,r);break;case 4:f[u].fn.call(f[u].context,e,r,o);break;default:if(!a)for(p=1,a=new Array(l-1);p<l;p++)a[p-1]=arguments[p];f[u].fn.apply(f[u].context,a)}}return!0},c.prototype.on=function(t,e,n){return s(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return s(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,r,o){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==e||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var a=0,u=[],f=c.length;a<f;a++)(c[a].fn!==e||o&&!c[a].once||r&&c[a].context!==r)&&u.push(c[a]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&i(this,e)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,t.exports=c}));!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(t){t.TAP_MESSAGE_TYPE_READY="tdsMsg.ready",t.TAP_MESSAGE_TYPE_GO="tdsMsg.go",t.TAP_MESSAGE_TYPE_MESSAGE="tdsMsg.message",t.TAP_MESSAGE_TYPE_ERROR="tdsMsg.error",t.TAP_MESSAGE_TYPE_REFRESH_TICKET="tdsMsg.refreshTicket",t.TAP_MESSAGE_TYPE_SYNC_PATH="tdsMsg.syncPath"}(o||(o={}));var i=function(t){function e(e){var n=t.call(this)||this;return n.fn=e,n.debug=!1,window.addEventListener("message",(function(t){n.debug&&window.console.log("[TdsMsg]<"+t.origin+">:",t.data),n.fn(t)}),!1),n}return n(e,t),e.prototype.destroy=function(){window.removeEventListener("message",this.fn)},e}(s),c=function(){this.time=(new Date).getTime()},a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}return n(e,t),e}(c),u=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=o.TAP_MESSAGE_TYPE_SYNC_PATH,n}return n(e,t),e}(c),f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.TAP_MESSAGE_TYPE_READY,e}return n(e,t),e}(c);!function(t){function e(e,n,r){var s=t.call(this)||this;return s.path=e,s.ticket=n,s.payload=r,s.type=o.TAP_MESSAGE_TYPE_GO,s}n(e,t)}(c);var l=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=o.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(c),p=function(t){function e(e,n){var r=t.call(this)||this;return r.code=e,r.payload=n,r.type=o.TAP_MESSAGE_TYPE_ERROR,r}return n(e,t),e}(c);function E(t,e){return e.indexOf("*")>-1?(console.warn("[TdsMsg]: 警告,正在使用通配符校验域名,请勿在生产模式使用通配符校验域名。"),function(t){var e=t.replace(/([.-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)):t===e}return function(t){function e(n,r){var s=void 0===r?{}:r,i=s.onGo,c=s.onMessage,a=t.call(this,(function(t){var r=t.origin;if(E(r,n))if(a.ready){var s=t.data;switch(s.type){case o.TAP_MESSAGE_TYPE_ERROR:return void console.warn("[TdsMsgClient]: tdsClient 理应不接受error事件");case o.TAP_MESSAGE_TYPE_GO:return s.path?void a.emit(e.ClientEventGo,s):void console.warn("[TdsMsgClient]: 跳转必须包含path");case o.TAP_MESSAGE_TYPE_MESSAGE:a.emit(e.ClientEventMessage,s);break;case o.TAP_MESSAGE_TYPE_READY:console.warn("[TdsMsgClient]: tdsClient 理应不接受Ready事件");break;default:return}}else console.warn("[TdsMsgClient]: 子页尚未初始化完毕");else console.warn("[TdsMsgClient]: 试图在非 Tds 域名下接收数据, origin: "+r+", 目标 Tds Origin: "+n)}))||this;return a.tdsOrigin=n,a.ready=!1,i&&"function"==typeof i&&a.on(e.ClientEventGo,i),c&&"function"==typeof c&&a.on(e.ClientEventMessage,c),a}return n(e,t),e.prototype.sendMessage=function(t){window.top.postMessage(t,this.tdsOrigin)},e.prototype.setReady=function(){this.ready=!0,this.sendMessage(new e.ClientReady)},e.prototype.setError=function(t,n){void 0===n&&(n={}),this.sendMessage(new e.ClientError(t,n))},e.prototype.sendMsg=function(t){this.sendMessage(new e.ClientMsg(t))},e.prototype.syncPath=function(t){this.sendMessage(new e.ClientSyncPath({path:t}))},e.prototype.refreshTicket=function(){this.sendMessage(new e.ClientRefreshTicket)},e.ClientReady=f,e.ClientError=p,e.ClientMsg=l,e.ClientRefreshTicket=a,e.ClientSyncPath=u,e.ERROR_CODE=r,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(i)}();
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,s=t((function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||t,i),a=n?n+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,r,o=[];if(0===this._eventsCount)return o;for(r in t=this._events)e.call(t,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},c.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},c.prototype.emit=function(t,e,r,o,s,i){var c=n?n+t:t;if(!this._events[c])return!1;var a,u,f=this._events[c],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,r),!0;case 4:return f.fn.call(f.context,e,r,o),!0;case 5:return f.fn.call(f.context,e,r,o,s),!0;case 6:return f.fn.call(f.context,e,r,o,s,i),!0}for(u=1,a=new Array(l-1);u<l;u++)a[u-1]=arguments[u];f.fn.apply(f.context,a)}else{var p,E=f.length;for(u=0;u<E;u++)switch(f[u].once&&this.removeListener(t,f[u].fn,void 0,!0),l){case 1:f[u].fn.call(f[u].context);break;case 2:f[u].fn.call(f[u].context,e);break;case 3:f[u].fn.call(f[u].context,e,r);break;case 4:f[u].fn.call(f[u].context,e,r,o);break;default:if(!a)for(p=1,a=new Array(l-1);p<l;p++)a[p-1]=arguments[p];f[u].fn.apply(f[u].context,a)}}return!0},c.prototype.on=function(t,e,n){return s(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return s(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,r,o){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==e||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var a=0,u=[],f=c.length;a<f;a++)(c[a].fn!==e||o&&!c[a].once||r&&c[a].context!==r)&&u.push(c[a]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&i(this,e)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,t.exports=c}));!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(t){t.TAP_MESSAGE_TYPE_READY="tdsMsg.ready",t.TAP_MESSAGE_TYPE_GO="tdsMsg.go",t.TAP_MESSAGE_TYPE_MESSAGE="tdsMsg.message",t.TAP_MESSAGE_TYPE_ERROR="tdsMsg.error",t.TAP_MESSAGE_TYPE_REFRESH_TICKET="tdsMsg.refreshTicket",t.TAP_MESSAGE_TYPE_SYNC_PATH="tdsMsg.syncPath"}(o||(o={}));var i=function(t){function e(e){var n=t.call(this)||this;return n.fn=e,n.debug=!1,window.addEventListener("message",(function(t){n.debug&&window.console.log("[TdsMsg]<"+t.origin+">:",t.data),n.fn(t)}),!1),n}return n(e,t),e.prototype.destroy=function(){window.removeEventListener("message",this.fn)},e}(s),c=function(){this.time=(new Date).getTime()},a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}return n(e,t),e}(c),u=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=o.TAP_MESSAGE_TYPE_SYNC_PATH,n}return n(e,t),e}(c),f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.TAP_MESSAGE_TYPE_READY,e}return n(e,t),e}(c);!function(t){function e(e,n,r){var s=t.call(this)||this;return s.path=e,s.ticket=n,s.payload=r,s.type=o.TAP_MESSAGE_TYPE_GO,s}n(e,t)}(c);var l=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=o.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(c),p=function(t){function e(e,n){var r=t.call(this)||this;return r.code=e,r.payload=n,r.type=o.TAP_MESSAGE_TYPE_ERROR,r}return n(e,t),e}(c);function E(t,e){return e.indexOf("*")>-1?(console.warn("[TdsMsg]: 警告,正在使用通配符校验域名,请勿在生产模式使用通配符校验域名。"),function(t){var e=t.replace(/([.-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)):t===e}return function(t){function e(n,r){var s=void 0===r?{}:r,i=s.onGo,c=s.onMessage,a=t.call(this,(function(t){var r=t.origin;if(E(r,n))if(a.ready){var s=t.data;switch(s.type){case o.TAP_MESSAGE_TYPE_ERROR:return void console.warn("[TdsMsgClient]: tdsClient 理应不接受error事件");case o.TAP_MESSAGE_TYPE_GO:return s.path?void a.emit(e.ClientEventGo,s):void console.warn("[TdsMsgClient]: 跳转必须包含path");case o.TAP_MESSAGE_TYPE_MESSAGE:a.emit(e.ClientEventMessage,s);break;case o.TAP_MESSAGE_TYPE_READY:console.warn("[TdsMsgClient]: tdsClient 理应不接受Ready事件");break;default:return}}else console.warn("[TdsMsgClient]: 子页尚未初始化完毕");else console.warn("[TdsMsgClient]: 试图在非 Tds 域名下接收数据, origin: "+r+", 目标 Tds Origin: "+n)}))||this;return a.tdsOrigin=n,a.ready=!1,i&&"function"==typeof i&&a.on(e.ClientEventGo,i),c&&"function"==typeof c&&a.on(e.ClientEventMessage,c),a}return n(e,t),e.prototype.sendMessage=function(t){window.parent.postMessage(t,this.tdsOrigin)},e.prototype.setReady=function(){this.ready=!0,this.sendMessage(new e.ClientReady)},e.prototype.setError=function(t,n){void 0===n&&(n={}),this.sendMessage(new e.ClientError(t,n))},e.prototype.sendMsg=function(t){this.sendMessage(new e.ClientMsg(t))},e.prototype.syncPath=function(t){this.sendMessage(new e.ClientSyncPath({path:t}))},e.prototype.refreshTicket=function(){this.sendMessage(new e.ClientRefreshTicket)},e.ClientReady=f,e.ClientError=p,e.ClientMsg=l,e.ClientRefreshTicket=a,e.ClientSyncPath=u,e.ERROR_CODE=r,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(i)}();
//# sourceMappingURL=TdsClient.iife.min.js.map

@@ -706,3 +706,3 @@ (function (global, factory) {

TdsMsgClient.prototype.sendMessage = function (data) {
window.top.postMessage(data, this.tdsOrigin);
window.parent.postMessage(data, this.tdsOrigin);
};

@@ -709,0 +709,0 @@ /**

@@ -16,3 +16,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TdsClient=e()}(this,(function(){"use strict";function t(t){var e={exports:{}};return t(e,e.exports),e.exports}t((function(t){function e(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(n)}t.exports=e}));

***************************************************************************** */
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}var o,r,s=t((function(t){var e=Object.prototype.hasOwnProperty,n="~";function o(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,o,s,i){if("function"!=typeof o)throw new TypeError("The listener must be a function");var c=new r(o,s||t,i),a=n?n+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,o,r=[];if(0===this._eventsCount)return r;for(o in t=this._events)e.call(t,o)&&r.push(n?o.slice(1):o);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},c.prototype.listeners=function(t){var e=n?n+t:t,o=this._events[e];if(!o)return[];if(o.fn)return[o.fn];for(var r=0,s=o.length,i=new Array(s);r<s;r++)i[r]=o[r].fn;return i},c.prototype.listenerCount=function(t){var e=n?n+t:t,o=this._events[e];return o?o.fn?1:o.length:0},c.prototype.emit=function(t,e,o,r,s,i){var c=n?n+t:t;if(!this._events[c])return!1;var a,f,u=this._events[c],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,o),!0;case 4:return u.fn.call(u.context,e,o,r),!0;case 5:return u.fn.call(u.context,e,o,r,s),!0;case 6:return u.fn.call(u.context,e,o,r,s,i),!0}for(f=1,a=new Array(l-1);f<l;f++)a[f-1]=arguments[f];u.fn.apply(u.context,a)}else{var p,E=u.length;for(f=0;f<E;f++)switch(u[f].once&&this.removeListener(t,u[f].fn,void 0,!0),l){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,e);break;case 3:u[f].fn.call(u[f].context,e,o);break;case 4:u[f].fn.call(u[f].context,e,o,r);break;default:if(!a)for(p=1,a=new Array(l-1);p<l;p++)a[p-1]=arguments[p];u[f].fn.apply(u[f].context,a)}}return!0},c.prototype.on=function(t,e,n){return s(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return s(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,o,r){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==e||r&&!c.once||o&&c.context!==o||i(this,s);else{for(var a=0,f=[],u=c.length;a<u;a++)(c[a].fn!==e||r&&!c[a].once||o&&c[a].context!==o)&&f.push(c[a]);f.length?this._events[s]=1===f.length?f[0]:f:i(this,s)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&i(this,e)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,t.exports=c}));!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(o||(o={})),function(t){t.TAP_MESSAGE_TYPE_READY="tdsMsg.ready",t.TAP_MESSAGE_TYPE_GO="tdsMsg.go",t.TAP_MESSAGE_TYPE_MESSAGE="tdsMsg.message",t.TAP_MESSAGE_TYPE_ERROR="tdsMsg.error",t.TAP_MESSAGE_TYPE_REFRESH_TICKET="tdsMsg.refreshTicket",t.TAP_MESSAGE_TYPE_SYNC_PATH="tdsMsg.syncPath"}(r||(r={}));var i=function(t){function e(e){var n=t.call(this)||this;return n.fn=e,n.debug=!1,window.addEventListener("message",(function(t){n.debug&&window.console.log("[TdsMsg]<"+t.origin+">:",t.data),n.fn(t)}),!1),n}return n(e,t),e.prototype.destroy=function(){window.removeEventListener("message",this.fn)},e}(s),c=function(){this.time=(new Date).getTime()},a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=r.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}return n(e,t),e}(c),f=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=r.TAP_MESSAGE_TYPE_SYNC_PATH,n}return n(e,t),e}(c),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=r.TAP_MESSAGE_TYPE_READY,e}return n(e,t),e}(c);!function(t){function e(e,n,o){var s=t.call(this)||this;return s.path=e,s.ticket=n,s.payload=o,s.type=r.TAP_MESSAGE_TYPE_GO,s}n(e,t)}(c);var l=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=r.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(c),p=function(t){function e(e,n){var o=t.call(this)||this;return o.code=e,o.payload=n,o.type=r.TAP_MESSAGE_TYPE_ERROR,o}return n(e,t),e}(c);function E(t,e){return e.indexOf("*")>-1?(console.warn("[TdsMsg]: 警告,正在使用通配符校验域名,请勿在生产模式使用通配符校验域名。"),function(t){var e=t.replace(/([.-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)):t===e}return function(t){function e(n,o){var s=void 0===o?{}:o,i=s.onGo,c=s.onMessage,a=t.call(this,(function(t){var o=t.origin;if(E(o,n))if(a.ready){var s=t.data;switch(s.type){case r.TAP_MESSAGE_TYPE_ERROR:return void console.warn("[TdsMsgClient]: tdsClient 理应不接受error事件");case r.TAP_MESSAGE_TYPE_GO:return s.path?void a.emit(e.ClientEventGo,s):void console.warn("[TdsMsgClient]: 跳转必须包含path");case r.TAP_MESSAGE_TYPE_MESSAGE:a.emit(e.ClientEventMessage,s);break;case r.TAP_MESSAGE_TYPE_READY:console.warn("[TdsMsgClient]: tdsClient 理应不接受Ready事件");break;default:return}}else console.warn("[TdsMsgClient]: 子页尚未初始化完毕");else console.warn("[TdsMsgClient]: 试图在非 Tds 域名下接收数据, origin: "+o+", 目标 Tds Origin: "+n)}))||this;return a.tdsOrigin=n,a.ready=!1,i&&"function"==typeof i&&a.on(e.ClientEventGo,i),c&&"function"==typeof c&&a.on(e.ClientEventMessage,c),a}return n(e,t),e.prototype.sendMessage=function(t){window.top.postMessage(t,this.tdsOrigin)},e.prototype.setReady=function(){this.ready=!0,this.sendMessage(new e.ClientReady)},e.prototype.setError=function(t,n){void 0===n&&(n={}),this.sendMessage(new e.ClientError(t,n))},e.prototype.sendMsg=function(t){this.sendMessage(new e.ClientMsg(t))},e.prototype.syncPath=function(t){this.sendMessage(new e.ClientSyncPath({path:t}))},e.prototype.refreshTicket=function(){this.sendMessage(new e.ClientRefreshTicket)},e.ClientReady=u,e.ClientError=p,e.ClientMsg=l,e.ClientRefreshTicket=a,e.ClientSyncPath=f,e.ERROR_CODE=o,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(i)}));
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}var o,r,s=t((function(t){var e=Object.prototype.hasOwnProperty,n="~";function o(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,o,s,i){if("function"!=typeof o)throw new TypeError("The listener must be a function");var c=new r(o,s||t,i),a=n?n+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,o,r=[];if(0===this._eventsCount)return r;for(o in t=this._events)e.call(t,o)&&r.push(n?o.slice(1):o);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},c.prototype.listeners=function(t){var e=n?n+t:t,o=this._events[e];if(!o)return[];if(o.fn)return[o.fn];for(var r=0,s=o.length,i=new Array(s);r<s;r++)i[r]=o[r].fn;return i},c.prototype.listenerCount=function(t){var e=n?n+t:t,o=this._events[e];return o?o.fn?1:o.length:0},c.prototype.emit=function(t,e,o,r,s,i){var c=n?n+t:t;if(!this._events[c])return!1;var a,f,u=this._events[c],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,o),!0;case 4:return u.fn.call(u.context,e,o,r),!0;case 5:return u.fn.call(u.context,e,o,r,s),!0;case 6:return u.fn.call(u.context,e,o,r,s,i),!0}for(f=1,a=new Array(l-1);f<l;f++)a[f-1]=arguments[f];u.fn.apply(u.context,a)}else{var p,E=u.length;for(f=0;f<E;f++)switch(u[f].once&&this.removeListener(t,u[f].fn,void 0,!0),l){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,e);break;case 3:u[f].fn.call(u[f].context,e,o);break;case 4:u[f].fn.call(u[f].context,e,o,r);break;default:if(!a)for(p=1,a=new Array(l-1);p<l;p++)a[p-1]=arguments[p];u[f].fn.apply(u[f].context,a)}}return!0},c.prototype.on=function(t,e,n){return s(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return s(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,o,r){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==e||r&&!c.once||o&&c.context!==o||i(this,s);else{for(var a=0,f=[],u=c.length;a<u;a++)(c[a].fn!==e||r&&!c[a].once||o&&c[a].context!==o)&&f.push(c[a]);f.length?this._events[s]=1===f.length?f[0]:f:i(this,s)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&i(this,e)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,t.exports=c}));!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(o||(o={})),function(t){t.TAP_MESSAGE_TYPE_READY="tdsMsg.ready",t.TAP_MESSAGE_TYPE_GO="tdsMsg.go",t.TAP_MESSAGE_TYPE_MESSAGE="tdsMsg.message",t.TAP_MESSAGE_TYPE_ERROR="tdsMsg.error",t.TAP_MESSAGE_TYPE_REFRESH_TICKET="tdsMsg.refreshTicket",t.TAP_MESSAGE_TYPE_SYNC_PATH="tdsMsg.syncPath"}(r||(r={}));var i=function(t){function e(e){var n=t.call(this)||this;return n.fn=e,n.debug=!1,window.addEventListener("message",(function(t){n.debug&&window.console.log("[TdsMsg]<"+t.origin+">:",t.data),n.fn(t)}),!1),n}return n(e,t),e.prototype.destroy=function(){window.removeEventListener("message",this.fn)},e}(s),c=function(){this.time=(new Date).getTime()},a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=r.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}return n(e,t),e}(c),f=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=r.TAP_MESSAGE_TYPE_SYNC_PATH,n}return n(e,t),e}(c),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=r.TAP_MESSAGE_TYPE_READY,e}return n(e,t),e}(c);!function(t){function e(e,n,o){var s=t.call(this)||this;return s.path=e,s.ticket=n,s.payload=o,s.type=r.TAP_MESSAGE_TYPE_GO,s}n(e,t)}(c);var l=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=r.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(c),p=function(t){function e(e,n){var o=t.call(this)||this;return o.code=e,o.payload=n,o.type=r.TAP_MESSAGE_TYPE_ERROR,o}return n(e,t),e}(c);function E(t,e){return e.indexOf("*")>-1?(console.warn("[TdsMsg]: 警告,正在使用通配符校验域名,请勿在生产模式使用通配符校验域名。"),function(t){var e=t.replace(/([.-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)):t===e}return function(t){function e(n,o){var s=void 0===o?{}:o,i=s.onGo,c=s.onMessage,a=t.call(this,(function(t){var o=t.origin;if(E(o,n))if(a.ready){var s=t.data;switch(s.type){case r.TAP_MESSAGE_TYPE_ERROR:return void console.warn("[TdsMsgClient]: tdsClient 理应不接受error事件");case r.TAP_MESSAGE_TYPE_GO:return s.path?void a.emit(e.ClientEventGo,s):void console.warn("[TdsMsgClient]: 跳转必须包含path");case r.TAP_MESSAGE_TYPE_MESSAGE:a.emit(e.ClientEventMessage,s);break;case r.TAP_MESSAGE_TYPE_READY:console.warn("[TdsMsgClient]: tdsClient 理应不接受Ready事件");break;default:return}}else console.warn("[TdsMsgClient]: 子页尚未初始化完毕");else console.warn("[TdsMsgClient]: 试图在非 Tds 域名下接收数据, origin: "+o+", 目标 Tds Origin: "+n)}))||this;return a.tdsOrigin=n,a.ready=!1,i&&"function"==typeof i&&a.on(e.ClientEventGo,i),c&&"function"==typeof c&&a.on(e.ClientEventMessage,c),a}return n(e,t),e.prototype.sendMessage=function(t){window.parent.postMessage(t,this.tdsOrigin)},e.prototype.setReady=function(){this.ready=!0,this.sendMessage(new e.ClientReady)},e.prototype.setError=function(t,n){void 0===n&&(n={}),this.sendMessage(new e.ClientError(t,n))},e.prototype.sendMsg=function(t){this.sendMessage(new e.ClientMsg(t))},e.prototype.syncPath=function(t){this.sendMessage(new e.ClientSyncPath({path:t}))},e.prototype.refreshTicket=function(){this.sendMessage(new e.ClientRefreshTicket)},e.ClientReady=u,e.ClientError=p,e.ClientMsg=l,e.ClientRefreshTicket=a,e.ClientSyncPath=f,e.ERROR_CODE=o,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(i)}));
//# sourceMappingURL=TdsClient.umd.min.js.map

@@ -700,3 +700,3 @@ function createCommonjsModule(fn) {

TdsMsgClient.prototype.sendMessage = function (data) {
window.top.postMessage(data, this.tdsOrigin);
window.parent.postMessage(data, this.tdsOrigin);
};

@@ -703,0 +703,0 @@ /**

{
"name": "@taptap/tds-msg",
"version": "0.2.14",
"version": "0.2.15",
"license": "MIT",

@@ -5,0 +5,0 @@ "module": "es/client.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc