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.3.0 to 0.3.1

16

CHANGELOG.md

@@ -0,1 +1,17 @@

## [0.3.1](https://github.com/TapTap/tds-msg-kit/compare/v0.3.0...v0.3.1) (2022-08-31)
### Bug Fixes
* client syncPath add options params ([aa8cf40](https://github.com/TapTap/tds-msg-kit/commit/aa8cf4070a2355cfe11ae6d55c497ab28b4021e9))
* format code ([db84151](https://github.com/TapTap/tds-msg-kit/commit/db84151ae7560775260b9b8f36c67bbe95aac883))
* modify action type name ([0abaa95](https://github.com/TapTap/tds-msg-kit/commit/0abaa95cfddf56f0ea75b665c7f4c6d8fd785240))
### Features
* add optional params to SyncPath paylod.resolve [#11](https://github.com/TapTap/tds-msg-kit/issues/11) ([9583d11](https://github.com/TapTap/tds-msg-kit/commit/9583d11b05dceaa9e0b58b473262f0155976c559))
# [0.3.0](https://github.com/TapTap/tds-msg-kit/compare/v0.2.15...v0.3.0) (2022-08-13)

@@ -2,0 +18,0 @@

5

dist/client.d.ts

@@ -1,2 +0,2 @@

import { TdsCallback, TdsMsg, TdsMsgError, TdsMsgMessage, TdsMsgReady, TdsMsgSubject, TdsMsgRefreshTicket, TdsMsgSyncPath, ERROR_CODE } from './common';
import { TdsCallback, TdsMsg, TdsMsgError, TdsMsgMessage, TdsMsgReady, TdsMsgSubject, TdsMsgRefreshTicket, TdsMsgSyncPath, ERROR_CODE, SyncPathPayload } from './common';
declare class TdsMsgClient extends TdsMsgSubject {

@@ -47,4 +47,5 @@ private readonly tdsOrigin;

* @param path
* @param options
*/
syncPath(path: string): void;
syncPath(path: string, options?: SyncPathPayload['options']): void;
/**

@@ -51,0 +52,0 @@ * 用于主动要求服务端更新 ticket 使用

22

dist/common.d.ts

@@ -29,2 +29,12 @@ import EventEmitter from 'eventemitter3';

}
export declare enum ACTION_TYPE {
PUSH = "PUSH",
REPLACE = "REPLACE"
}
export declare type SyncPathPayload = {
path: string;
options?: {
action: ACTION_TYPE;
};
};
export declare type TdsCallback = (tdsMsg: TdsMsg) => void;

@@ -71,12 +81,6 @@ /**

*/
export declare class TdsMsgSyncPath extends TdsMsgBase implements TdsMsg<{
path: string;
}> {
payload: {
path: any;
};
export declare class TdsMsgSyncPath extends TdsMsgBase implements TdsMsg<SyncPathPayload> {
payload: SyncPathPayload;
type: TDS_MESSAGE_TYPE;
constructor(payload: {
path: any;
});
constructor(payload: SyncPathPayload);
}

@@ -83,0 +87,0 @@ /**

@@ -490,2 +490,9 @@ var TdsClient = (function () {

})(ERROR_CODE || (ERROR_CODE = {}));
var ACTION_TYPE;
(function (ACTION_TYPE) {
ACTION_TYPE["PUSH"] = "PUSH";
ACTION_TYPE["REPLACE"] = "REPLACE";
})(ACTION_TYPE || (ACTION_TYPE = {}));
/**

@@ -809,8 +816,10 @@ * Tds 消息类型

* @param path
* @param options
*/
TdsMsgClient.prototype.syncPath = function (path) {
TdsMsgClient.prototype.syncPath = function (path, options) {
this.sendMessage(new TdsMsgClient.ClientSyncPath({
path: path
path: path,
options: options
}));

@@ -817,0 +826,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})),i=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function c(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(r=t[n],o=e[n],!(r===o||i(r)&&i(o)))return!1;var r,o;return!0}!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 a=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),u=function(){this.time=(new Date).getTime()},f=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}(u),l=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}(u),p=function(t){function e(e){var n=t.call(this)||this;return n.origin=e,n.type=o.TAP_MESSAGE_TYPE_READY,n}return n(e,t),e}(u);!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)}(u);var E=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}(u),h=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}(u);var _=function(t,e){void 0===e&&(e=c);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&e(r,n.lastArgs))return n.lastResult;var s=t.apply(this,r);return n={lastResult:s,lastArgs:r,lastThis:this},s}return r.clear=function(){n=null},r}((function(t,e){return function(t){var e=t.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)}));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(function(t,e){return e.indexOf("*")>-1?_(t,e):t===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(t){this.ready=!0,this.sendMessage(new e.ClientReady(t))},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=p,e.ClientError=h,e.ClientMsg=E,e.ClientRefreshTicket=f,e.ClientSyncPath=l,e.ERROR_CODE=r,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(a)}();
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,i=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})),c=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function a(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(r=t[n],o=e[n],!(r===o||c(r)&&c(o)))return!1;var r,o;return!0}!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(t){t.PUSH="PUSH",t.REPLACE="REPLACE"}(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"}(s||(s={}));var u=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}(i),f=function(){this.time=(new Date).getTime()},l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=s.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}return n(e,t),e}(f),p=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=s.TAP_MESSAGE_TYPE_SYNC_PATH,n}return n(e,t),e}(f),E=function(t){function e(e){var n=t.call(this)||this;return n.origin=e,n.type=s.TAP_MESSAGE_TYPE_READY,n}return n(e,t),e}(f);!function(t){function e(e,n,r){var o=t.call(this)||this;return o.path=e,o.ticket=n,o.payload=r,o.type=s.TAP_MESSAGE_TYPE_GO,o}n(e,t)}(f);var h=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=s.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(f),_=function(t){function e(e,n){var r=t.call(this)||this;return r.code=e,r.payload=n,r.type=s.TAP_MESSAGE_TYPE_ERROR,r}return n(e,t),e}(f);var v=function(t,e){void 0===e&&(e=a);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&e(r,n.lastArgs))return n.lastResult;var s=t.apply(this,r);return n={lastResult:s,lastArgs:r,lastThis:this},s}return r.clear=function(){n=null},r}((function(t,e){return function(t){var e=t.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)}));return function(t){function e(n,r){var o=void 0===r?{}:r,i=o.onGo,c=o.onMessage,a=t.call(this,(function(t){var r=t.origin;if(function(t,e){return e.indexOf("*")>-1?v(t,e):t===e}(r,n))if(a.ready){var o=t.data;switch(o.type){case s.TAP_MESSAGE_TYPE_ERROR:return void console.warn("[TdsMsgClient]: tdsClient 理应不接受error事件");case s.TAP_MESSAGE_TYPE_GO:return o.path?void a.emit(e.ClientEventGo,o):void console.warn("[TdsMsgClient]: 跳转必须包含path");case s.TAP_MESSAGE_TYPE_MESSAGE:a.emit(e.ClientEventMessage,o);break;case s.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(t){this.ready=!0,this.sendMessage(new e.ClientReady(t))},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,n){this.sendMessage(new e.ClientSyncPath({path:t,options:n}))},e.prototype.refreshTicket=function(){this.sendMessage(new e.ClientRefreshTicket)},e.ClientReady=E,e.ClientError=_,e.ClientMsg=h,e.ClientRefreshTicket=l,e.ClientSyncPath=p,e.ERROR_CODE=r,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(u)}();
//# sourceMappingURL=TdsClient.iife.min.js.map

@@ -493,2 +493,9 @@ (function (global, factory) {

})(ERROR_CODE || (ERROR_CODE = {}));
var ACTION_TYPE;
(function (ACTION_TYPE) {
ACTION_TYPE["PUSH"] = "PUSH";
ACTION_TYPE["REPLACE"] = "REPLACE";
})(ACTION_TYPE || (ACTION_TYPE = {}));
/**

@@ -812,8 +819,10 @@ * Tds 消息类型

* @param path
* @param options
*/
TdsMsgClient.prototype.syncPath = function (path) {
TdsMsgClient.prototype.syncPath = function (path, options) {
this.sendMessage(new TdsMsgClient.ClientSyncPath({
path: path
path: path,
options: options
}));

@@ -820,0 +829,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 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,h=f.length;for(u=0;u<h;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})),i=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function c(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(r=t[n],o=e[n],!(r===o||i(r)&&i(o)))return!1;var r,o;return!0}!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 a=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),u=function(){this.time=(new Date).getTime()},f=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}(u),l=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}(u),p=function(t){function e(e){var n=t.call(this)||this;return n.origin=e,n.type=o.TAP_MESSAGE_TYPE_READY,n}return n(e,t),e}(u);!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)}(u);var h=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}(u),E=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}(u);var _=function(t,e){void 0===e&&(e=c);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&e(r,n.lastArgs))return n.lastResult;var s=t.apply(this,r);return n={lastResult:s,lastArgs:r,lastThis:this},s}return r.clear=function(){n=null},r}((function(t,e){return function(t){var e=t.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)}));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(function(t,e){return e.indexOf("*")>-1?_(t,e):t===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(t){this.ready=!0,this.sendMessage(new e.ClientReady(t))},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=p,e.ClientError=E,e.ClientMsg=h,e.ClientRefreshTicket=f,e.ClientSyncPath=l,e.ERROR_CODE=r,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(a)}));
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,i=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})),c=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function a(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(r=t[n],o=e[n],!(r===o||c(r)&&c(o)))return!1;var r,o;return!0}!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(t){t.PUSH="PUSH",t.REPLACE="REPLACE"}(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"}(s||(s={}));var u=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}(i),f=function(){this.time=(new Date).getTime()},l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=s.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}return n(e,t),e}(f),p=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=s.TAP_MESSAGE_TYPE_SYNC_PATH,n}return n(e,t),e}(f),E=function(t){function e(e){var n=t.call(this)||this;return n.origin=e,n.type=s.TAP_MESSAGE_TYPE_READY,n}return n(e,t),e}(f);!function(t){function e(e,n,r){var o=t.call(this)||this;return o.path=e,o.ticket=n,o.payload=r,o.type=s.TAP_MESSAGE_TYPE_GO,o}n(e,t)}(f);var h=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=s.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(f),_=function(t){function e(e,n){var r=t.call(this)||this;return r.code=e,r.payload=n,r.type=s.TAP_MESSAGE_TYPE_ERROR,r}return n(e,t),e}(f);var y=function(t,e){void 0===e&&(e=a);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&e(r,n.lastArgs))return n.lastResult;var s=t.apply(this,r);return n={lastResult:s,lastArgs:r,lastThis:this},s}return r.clear=function(){n=null},r}((function(t,e){return function(t){var e=t.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)}));return function(t){function e(n,r){var o=void 0===r?{}:r,i=o.onGo,c=o.onMessage,a=t.call(this,(function(t){var r=t.origin;if(function(t,e){return e.indexOf("*")>-1?y(t,e):t===e}(r,n))if(a.ready){var o=t.data;switch(o.type){case s.TAP_MESSAGE_TYPE_ERROR:return void console.warn("[TdsMsgClient]: tdsClient 理应不接受error事件");case s.TAP_MESSAGE_TYPE_GO:return o.path?void a.emit(e.ClientEventGo,o):void console.warn("[TdsMsgClient]: 跳转必须包含path");case s.TAP_MESSAGE_TYPE_MESSAGE:a.emit(e.ClientEventMessage,o);break;case s.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(t){this.ready=!0,this.sendMessage(new e.ClientReady(t))},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,n){this.sendMessage(new e.ClientSyncPath({path:t,options:n}))},e.prototype.refreshTicket=function(){this.sendMessage(new e.ClientRefreshTicket)},e.ClientReady=E,e.ClientError=_,e.ClientMsg=h,e.ClientRefreshTicket=l,e.ClientSyncPath=p,e.ERROR_CODE=r,e.ClientEventGo="onGo",e.ClientEventMessage="onMessage",e}(u)}));
//# sourceMappingURL=TdsClient.umd.min.js.map

@@ -490,2 +490,9 @@ var TdsServer = (function () {

})(ERROR_CODE || (ERROR_CODE = {}));
var ACTION_TYPE;
(function (ACTION_TYPE) {
ACTION_TYPE["PUSH"] = "PUSH";
ACTION_TYPE["REPLACE"] = "REPLACE";
})(ACTION_TYPE || (ACTION_TYPE = {}));
/**

@@ -492,0 +499,0 @@ * Tds 消息类型

@@ -16,3 +16,3 @@ var TdsServer=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,i=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 i(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,i||t,s),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 s(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,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},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,i,s){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,i),!0;case 6:return f.fn.call(f.context,e,r,o,i,s),!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 v,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(v=1,a=new Array(l-1);v<l;v++)a[v-1]=arguments[v];f[u].fn.apply(f[u].context,a)}}return!0},c.prototype.on=function(t,e,n){return i(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return i(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,r,o){var i=n?n+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var c=this._events[i];if(c.fn)c.fn!==e||o&&!c.once||r&&c.context!==r||s(this,i);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[i]=1===u.length?u[0]:u:s(this,i)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&s(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})),s=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function c(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(r=t[n],o=e[n],!(r===o||s(r)&&s(o)))return!1;var r,o;return!0}!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 a=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}(i),u=function(){this.time=(new Date).getTime()};!function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}n(e,t)}(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}n(e,t)}(u),function(t){function e(e){var n=t.call(this)||this;return n.origin=e,n.type=o.TAP_MESSAGE_TYPE_READY,n}n(e,t)}(u);var f=function(t){function e(e,n,r){var i=t.call(this)||this;return i.path=e,i.ticket=n,i.payload=r,i.type=o.TAP_MESSAGE_TYPE_GO,i}return n(e,t),e}(u),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}(u);!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}n(e,t)}(u);var v=function(t,e){void 0===e&&(e=c);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&e(r,n.lastArgs))return n.lastResult;var i=t.apply(this,r);return n={lastResult:i,lastArgs:r,lastThis:this},i}return r.clear=function(){n=null},r}((function(t,e){return function(t){var e=t.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)}));function E(t,e){return e.indexOf("*")>-1?v(t,e):t===e}return function(t){function e(n,r,i){var s=void 0===i?{}:i,c=s.onError,a=s.onReady,u=s.onMessage,f=s.onRefreshTicket,l=s.onSyncPath,v=t.call(this,(function(t){if(E(t.origin,n)){var r=t.data;switch(v.emit(e.ServerEventAll,r),r.type){case o.TAP_MESSAGE_TYPE_READY:return console.log("[TdsMsgServer]: TapMsgClient 准备就绪"),v.ready=!0,r.origin&&E(r.origin,n)&&(v.targetOrigin=r.origin),void v.emit(e.ServerEventReady,r);case o.TAP_MESSAGE_TYPE_MESSAGE:return void v.emit(e.ServerEventMessage,r);case o.TAP_MESSAGE_TYPE_GO:return void console.log("[TdsMsgServer]: 服务端理应不接收 Go");case o.TAP_MESSAGE_TYPE_ERROR:return void v.emit(e.ServerEventError,r);case o.TAP_MESSAGE_TYPE_REFRESH_TICKET:return void v.emit(e.ServerEventRefreshTicket,r);case o.TAP_MESSAGE_TYPE_SYNC_PATH:return void v.emit(e.ServerEventSyncPath,r)}}}))||this;return v.host=n,v.iframe=r,v.ready=!1,c&&"function"==typeof c&&v.on(e.ServerEventError,c),l&&"function"==typeof l&&v.on(e.ServerEventSyncPath,l),f&&"function"==typeof f&&v.on(e.ServerEventRefreshTicket,f),u&&"function"==typeof u&&v.on(e.ServerEventMessage,u),a&&"function"==typeof a&&v.on(e.ServerEventReady,a),v}return n(e,t),Object.defineProperty(e.prototype,"origin",{get:function(){return this.host+"/tap-dm/wait"},enumerable:!1,configurable:!0}),e.prototype.sendMessage=function(t){var e,n,r,o=this.iframe();o&&(null===(n=null===(e=o.contentWindow)||void 0===e?void 0:e.postMessage)||void 0===n||n.call(e,t,null!==(r=this.targetOrigin)&&void 0!==r?r:this.host))},e.prototype.go=function(t,e,n){this.sendMessage(new f(t,e,n))},e.prototype.msg=function(t){this.sendMessage(new l(t))},e.TdsMsgGo=f,e.ERROR_CODE=r,e.ServerEventReady="onReady",e.ServerEventMessage="onMessage",e.ServerEventError="onError",e.ServerEventRefreshTicket="onRefreshTicket",e.ServerEventSyncPath="onSyncPath",e.ServerEventAll="onAll",e}(a)}();
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,i,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 i(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,i||t,s),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 s(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,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},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,i,s){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,i),!0;case 6:return f.fn.call(f.context,e,r,o,i,s),!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 v,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(v=1,a=new Array(l-1);v<l;v++)a[v-1]=arguments[v];f[u].fn.apply(f[u].context,a)}}return!0},c.prototype.on=function(t,e,n){return i(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return i(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,r,o){var i=n?n+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var c=this._events[i];if(c.fn)c.fn!==e||o&&!c.once||r&&c.context!==r||s(this,i);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[i]=1===u.length?u[0]:u:s(this,i)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&s(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})),c=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function a(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(r=t[n],o=e[n],!(r===o||c(r)&&c(o)))return!1;var r,o;return!0}!function(t){t[t.TICKET_EXPIRED=100]="TICKET_EXPIRED",t[t.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(t){t.PUSH="PUSH",t.REPLACE="REPLACE"}(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"}(i||(i={}));var u=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),f=function(){this.time=(new Date).getTime()};!function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=i.TAP_MESSAGE_TYPE_REFRESH_TICKET,e}n(e,t)}(f),function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=i.TAP_MESSAGE_TYPE_SYNC_PATH,n}n(e,t)}(f),function(t){function e(e){var n=t.call(this)||this;return n.origin=e,n.type=i.TAP_MESSAGE_TYPE_READY,n}n(e,t)}(f);var l=function(t){function e(e,n,r){var o=t.call(this)||this;return o.path=e,o.ticket=n,o.payload=r,o.type=i.TAP_MESSAGE_TYPE_GO,o}return n(e,t),e}(f),v=function(t){function e(e){var n=t.call(this)||this;return n.payload=e,n.type=i.TAP_MESSAGE_TYPE_MESSAGE,n}return n(e,t),e}(f);!function(t){function e(e,n){var r=t.call(this)||this;return r.code=e,r.payload=n,r.type=i.TAP_MESSAGE_TYPE_ERROR,r}n(e,t)}(f);var E=function(t,e){void 0===e&&(e=a);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&e(r,n.lastArgs))return n.lastResult;var i=t.apply(this,r);return n={lastResult:i,lastArgs:r,lastThis:this},i}return r.clear=function(){n=null},r}((function(t,e){return function(t){var e=t.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+e+"$")}(e).test(t)}));function p(t,e){return e.indexOf("*")>-1?E(t,e):t===e}return function(t){function e(n,r,o){var s=void 0===o?{}:o,c=s.onError,a=s.onReady,u=s.onMessage,f=s.onRefreshTicket,l=s.onSyncPath,v=t.call(this,(function(t){if(p(t.origin,n)){var r=t.data;switch(v.emit(e.ServerEventAll,r),r.type){case i.TAP_MESSAGE_TYPE_READY:return console.log("[TdsMsgServer]: TapMsgClient 准备就绪"),v.ready=!0,r.origin&&p(r.origin,n)&&(v.targetOrigin=r.origin),void v.emit(e.ServerEventReady,r);case i.TAP_MESSAGE_TYPE_MESSAGE:return void v.emit(e.ServerEventMessage,r);case i.TAP_MESSAGE_TYPE_GO:return void console.log("[TdsMsgServer]: 服务端理应不接收 Go");case i.TAP_MESSAGE_TYPE_ERROR:return void v.emit(e.ServerEventError,r);case i.TAP_MESSAGE_TYPE_REFRESH_TICKET:return void v.emit(e.ServerEventRefreshTicket,r);case i.TAP_MESSAGE_TYPE_SYNC_PATH:return void v.emit(e.ServerEventSyncPath,r)}}}))||this;return v.host=n,v.iframe=r,v.ready=!1,c&&"function"==typeof c&&v.on(e.ServerEventError,c),l&&"function"==typeof l&&v.on(e.ServerEventSyncPath,l),f&&"function"==typeof f&&v.on(e.ServerEventRefreshTicket,f),u&&"function"==typeof u&&v.on(e.ServerEventMessage,u),a&&"function"==typeof a&&v.on(e.ServerEventReady,a),v}return n(e,t),Object.defineProperty(e.prototype,"origin",{get:function(){return this.host+"/tap-dm/wait"},enumerable:!1,configurable:!0}),e.prototype.sendMessage=function(t){var e,n,r,o=this.iframe();o&&(null===(n=null===(e=o.contentWindow)||void 0===e?void 0:e.postMessage)||void 0===n||n.call(e,t,null!==(r=this.targetOrigin)&&void 0!==r?r:this.host))},e.prototype.go=function(t,e,n){this.sendMessage(new l(t,e,n))},e.prototype.msg=function(t){this.sendMessage(new v(t))},e.TdsMsgGo=l,e.ERROR_CODE=r,e.ServerEventReady="onReady",e.ServerEventMessage="onMessage",e.ServerEventError="onError",e.ServerEventRefreshTicket="onRefreshTicket",e.ServerEventSyncPath="onSyncPath",e.ServerEventAll="onAll",e}(u)}();
//# sourceMappingURL=TdsServer.iife.min.js.map

@@ -493,2 +493,9 @@ (function (global, factory) {

})(ERROR_CODE || (ERROR_CODE = {}));
var ACTION_TYPE;
(function (ACTION_TYPE) {
ACTION_TYPE["PUSH"] = "PUSH";
ACTION_TYPE["REPLACE"] = "REPLACE";
})(ACTION_TYPE || (ACTION_TYPE = {}));
/**

@@ -495,0 +502,0 @@ * Tds 消息类型

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

***************************************************************************** */
var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)};function n(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,i=e((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,i||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],c]:e._events[u].push(c):(e._events[u]=c,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}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 e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,i,s){var c=n?n+e:e;if(!this._events[c])return!1;var u,a,f=this._events[c],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,i),!0;case 6:return f.fn.call(f.context,t,r,o,i,s),!0}for(a=1,u=new Array(l-1);a<l;a++)u[a-1]=arguments[a];f.fn.apply(f.context,u)}else{var v,E=f.length;for(a=0;a<E;a++)switch(f[a].once&&this.removeListener(e,f[a].fn,void 0,!0),l){case 1:f[a].fn.call(f[a].context);break;case 2:f[a].fn.call(f[a].context,t);break;case 3:f[a].fn.call(f[a].context,t,r);break;case 4:f[a].fn.call(f[a].context,t,r,o);break;default:if(!u)for(v=1,u=new Array(l-1);v<l;v++)u[v-1]=arguments[v];f[a].fn.apply(f[a].context,u)}}return!0},c.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var c=this._events[i];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||s(this,i);else{for(var u=0,a=[],f=c.length;u<f;u++)(c[u].fn!==t||o&&!c[u].once||r&&c[u].context!==r)&&a.push(c[u]);a.length?this._events[i]=1===a.length?a[0]:a:s(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(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,e.exports=c})),s=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function c(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(r=e[n],o=t[n],!(r===o||s(r)&&s(o)))return!1;var r,o;return!0}!function(e){e[e.TICKET_EXPIRED=100]="TICKET_EXPIRED",e[e.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(e){e.TAP_MESSAGE_TYPE_READY="tdsMsg.ready",e.TAP_MESSAGE_TYPE_GO="tdsMsg.go",e.TAP_MESSAGE_TYPE_MESSAGE="tdsMsg.message",e.TAP_MESSAGE_TYPE_ERROR="tdsMsg.error",e.TAP_MESSAGE_TYPE_REFRESH_TICKET="tdsMsg.refreshTicket",e.TAP_MESSAGE_TYPE_SYNC_PATH="tdsMsg.syncPath"}(o||(o={}));var u=function(e){function t(t){var n=e.call(this)||this;return n.fn=t,n.debug=!1,window.addEventListener("message",(function(e){n.debug&&window.console.log("[TdsMsg]<"+e.origin+">:",e.data),n.fn(e)}),!1),n}return n(t,e),t.prototype.destroy=function(){window.removeEventListener("message",this.fn)},t}(i),a=function(){this.time=(new Date).getTime()};!function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=o.TAP_MESSAGE_TYPE_REFRESH_TICKET,t}n(t,e)}(a),function(e){function t(t){var n=e.call(this)||this;return n.payload=t,n.type=o.TAP_MESSAGE_TYPE_SYNC_PATH,n}n(t,e)}(a),function(e){function t(t){var n=e.call(this)||this;return n.origin=t,n.type=o.TAP_MESSAGE_TYPE_READY,n}n(t,e)}(a);var f=function(e){function t(t,n,r){var i=e.call(this)||this;return i.path=t,i.ticket=n,i.payload=r,i.type=o.TAP_MESSAGE_TYPE_GO,i}return n(t,e),t}(a),l=function(e){function t(t){var n=e.call(this)||this;return n.payload=t,n.type=o.TAP_MESSAGE_TYPE_MESSAGE,n}return n(t,e),t}(a);!function(e){function t(t,n){var r=e.call(this)||this;return r.code=t,r.payload=n,r.type=o.TAP_MESSAGE_TYPE_ERROR,r}n(t,e)}(a);var v=function(e,t){void 0===t&&(t=c);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&t(r,n.lastArgs))return n.lastResult;var i=e.apply(this,r);return n={lastResult:i,lastArgs:r,lastThis:this},i}return r.clear=function(){n=null},r}((function(e,t){return function(e){var t=e.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+t+"$")}(t).test(e)}));function E(e,t){return t.indexOf("*")>-1?v(e,t):e===t}return function(e){function t(n,r,i){var s=void 0===i?{}:i,c=s.onError,u=s.onReady,a=s.onMessage,f=s.onRefreshTicket,l=s.onSyncPath,v=e.call(this,(function(e){if(E(e.origin,n)){var r=e.data;switch(v.emit(t.ServerEventAll,r),r.type){case o.TAP_MESSAGE_TYPE_READY:return console.log("[TdsMsgServer]: TapMsgClient 准备就绪"),v.ready=!0,r.origin&&E(r.origin,n)&&(v.targetOrigin=r.origin),void v.emit(t.ServerEventReady,r);case o.TAP_MESSAGE_TYPE_MESSAGE:return void v.emit(t.ServerEventMessage,r);case o.TAP_MESSAGE_TYPE_GO:return void console.log("[TdsMsgServer]: 服务端理应不接收 Go");case o.TAP_MESSAGE_TYPE_ERROR:return void v.emit(t.ServerEventError,r);case o.TAP_MESSAGE_TYPE_REFRESH_TICKET:return void v.emit(t.ServerEventRefreshTicket,r);case o.TAP_MESSAGE_TYPE_SYNC_PATH:return void v.emit(t.ServerEventSyncPath,r)}}}))||this;return v.host=n,v.iframe=r,v.ready=!1,c&&"function"==typeof c&&v.on(t.ServerEventError,c),l&&"function"==typeof l&&v.on(t.ServerEventSyncPath,l),f&&"function"==typeof f&&v.on(t.ServerEventRefreshTicket,f),a&&"function"==typeof a&&v.on(t.ServerEventMessage,a),u&&"function"==typeof u&&v.on(t.ServerEventReady,u),v}return n(t,e),Object.defineProperty(t.prototype,"origin",{get:function(){return this.host+"/tap-dm/wait"},enumerable:!1,configurable:!0}),t.prototype.sendMessage=function(e){var t,n,r,o=this.iframe();o&&(null===(n=null===(t=o.contentWindow)||void 0===t?void 0:t.postMessage)||void 0===n||n.call(t,e,null!==(r=this.targetOrigin)&&void 0!==r?r:this.host))},t.prototype.go=function(e,t,n){this.sendMessage(new f(e,t,n))},t.prototype.msg=function(e){this.sendMessage(new l(e))},t.TdsMsgGo=f,t.ERROR_CODE=r,t.ServerEventReady="onReady",t.ServerEventMessage="onMessage",t.ServerEventError="onError",t.ServerEventRefreshTicket="onRefreshTicket",t.ServerEventSyncPath="onSyncPath",t.ServerEventAll="onAll",t}(u)}));
var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)};function n(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,i,s=e((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,i||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],c]:e._events[u].push(c):(e._events[u]=c,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}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 e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,i,s){var c=n?n+e:e;if(!this._events[c])return!1;var u,f,a=this._events[c],l=arguments.length;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,t),!0;case 3:return a.fn.call(a.context,t,r),!0;case 4:return a.fn.call(a.context,t,r,o),!0;case 5:return a.fn.call(a.context,t,r,o,i),!0;case 6:return a.fn.call(a.context,t,r,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];a.fn.apply(a.context,u)}else{var v,E=a.length;for(f=0;f<E;f++)switch(a[f].once&&this.removeListener(e,a[f].fn,void 0,!0),l){case 1:a[f].fn.call(a[f].context);break;case 2:a[f].fn.call(a[f].context,t);break;case 3:a[f].fn.call(a[f].context,t,r);break;case 4:a[f].fn.call(a[f].context,t,r,o);break;default:if(!u)for(v=1,u=new Array(l-1);v<l;v++)u[v-1]=arguments[v];a[f].fn.apply(a[f].context,u)}}return!0},c.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var c=this._events[i];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||s(this,i);else{for(var u=0,f=[],a=c.length;u<a;u++)(c[u].fn!==t||o&&!c[u].once||r&&c[u].context!==r)&&f.push(c[u]);f.length?this._events[i]=1===f.length?f[0]:f:s(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(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,e.exports=c})),c=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function u(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(r=e[n],o=t[n],!(r===o||c(r)&&c(o)))return!1;var r,o;return!0}!function(e){e[e.TICKET_EXPIRED=100]="TICKET_EXPIRED",e[e.PERMISSION_DENIED=101]="PERMISSION_DENIED"}(r||(r={})),function(e){e.PUSH="PUSH",e.REPLACE="REPLACE"}(o||(o={})),function(e){e.TAP_MESSAGE_TYPE_READY="tdsMsg.ready",e.TAP_MESSAGE_TYPE_GO="tdsMsg.go",e.TAP_MESSAGE_TYPE_MESSAGE="tdsMsg.message",e.TAP_MESSAGE_TYPE_ERROR="tdsMsg.error",e.TAP_MESSAGE_TYPE_REFRESH_TICKET="tdsMsg.refreshTicket",e.TAP_MESSAGE_TYPE_SYNC_PATH="tdsMsg.syncPath"}(i||(i={}));var f=function(e){function t(t){var n=e.call(this)||this;return n.fn=t,n.debug=!1,window.addEventListener("message",(function(e){n.debug&&window.console.log("[TdsMsg]<"+e.origin+">:",e.data),n.fn(e)}),!1),n}return n(t,e),t.prototype.destroy=function(){window.removeEventListener("message",this.fn)},t}(s),a=function(){this.time=(new Date).getTime()};!function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=i.TAP_MESSAGE_TYPE_REFRESH_TICKET,t}n(t,e)}(a),function(e){function t(t){var n=e.call(this)||this;return n.payload=t,n.type=i.TAP_MESSAGE_TYPE_SYNC_PATH,n}n(t,e)}(a),function(e){function t(t){var n=e.call(this)||this;return n.origin=t,n.type=i.TAP_MESSAGE_TYPE_READY,n}n(t,e)}(a);var l=function(e){function t(t,n,r){var o=e.call(this)||this;return o.path=t,o.ticket=n,o.payload=r,o.type=i.TAP_MESSAGE_TYPE_GO,o}return n(t,e),t}(a),v=function(e){function t(t){var n=e.call(this)||this;return n.payload=t,n.type=i.TAP_MESSAGE_TYPE_MESSAGE,n}return n(t,e),t}(a);!function(e){function t(t,n){var r=e.call(this)||this;return r.code=t,r.payload=n,r.type=i.TAP_MESSAGE_TYPE_ERROR,r}n(t,e)}(a);var E=function(e,t){void 0===t&&(t=u);var n=null;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(n&&n.lastThis===this&&t(r,n.lastArgs))return n.lastResult;var i=e.apply(this,r);return n={lastResult:i,lastArgs:r,lastThis:this},i}return r.clear=function(){n=null},r}((function(e,t){return function(e){var t=e.replace(/([.\-\[\]()?\\^$=:])/g,"\\$1").replace(/\*/g,".*?");return new RegExp("^"+t+"$")}(t).test(e)}));function p(e,t){return t.indexOf("*")>-1?E(e,t):e===t}return function(e){function t(n,r,o){var s=void 0===o?{}:o,c=s.onError,u=s.onReady,f=s.onMessage,a=s.onRefreshTicket,l=s.onSyncPath,v=e.call(this,(function(e){if(p(e.origin,n)){var r=e.data;switch(v.emit(t.ServerEventAll,r),r.type){case i.TAP_MESSAGE_TYPE_READY:return console.log("[TdsMsgServer]: TapMsgClient 准备就绪"),v.ready=!0,r.origin&&p(r.origin,n)&&(v.targetOrigin=r.origin),void v.emit(t.ServerEventReady,r);case i.TAP_MESSAGE_TYPE_MESSAGE:return void v.emit(t.ServerEventMessage,r);case i.TAP_MESSAGE_TYPE_GO:return void console.log("[TdsMsgServer]: 服务端理应不接收 Go");case i.TAP_MESSAGE_TYPE_ERROR:return void v.emit(t.ServerEventError,r);case i.TAP_MESSAGE_TYPE_REFRESH_TICKET:return void v.emit(t.ServerEventRefreshTicket,r);case i.TAP_MESSAGE_TYPE_SYNC_PATH:return void v.emit(t.ServerEventSyncPath,r)}}}))||this;return v.host=n,v.iframe=r,v.ready=!1,c&&"function"==typeof c&&v.on(t.ServerEventError,c),l&&"function"==typeof l&&v.on(t.ServerEventSyncPath,l),a&&"function"==typeof a&&v.on(t.ServerEventRefreshTicket,a),f&&"function"==typeof f&&v.on(t.ServerEventMessage,f),u&&"function"==typeof u&&v.on(t.ServerEventReady,u),v}return n(t,e),Object.defineProperty(t.prototype,"origin",{get:function(){return this.host+"/tap-dm/wait"},enumerable:!1,configurable:!0}),t.prototype.sendMessage=function(e){var t,n,r,o=this.iframe();o&&(null===(n=null===(t=o.contentWindow)||void 0===t?void 0:t.postMessage)||void 0===n||n.call(t,e,null!==(r=this.targetOrigin)&&void 0!==r?r:this.host))},t.prototype.go=function(e,t,n){this.sendMessage(new l(e,t,n))},t.prototype.msg=function(e){this.sendMessage(new v(e))},t.TdsMsgGo=l,t.ERROR_CODE=r,t.ServerEventReady="onReady",t.ServerEventMessage="onMessage",t.ServerEventError="onError",t.ServerEventRefreshTicket="onRefreshTicket",t.ServerEventSyncPath="onSyncPath",t.ServerEventAll="onAll",t}(f)}));
//# sourceMappingURL=TdsServer.umd.min.js.map

@@ -1,2 +0,2 @@

import { TdsCallback, TdsMsg, TdsMsgError, TdsMsgMessage, TdsMsgReady, TdsMsgSubject, TdsMsgRefreshTicket, TdsMsgSyncPath, ERROR_CODE } from './common';
import { TdsCallback, TdsMsg, TdsMsgError, TdsMsgMessage, TdsMsgReady, TdsMsgSubject, TdsMsgRefreshTicket, TdsMsgSyncPath, ERROR_CODE, SyncPathPayload } from './common';
declare class TdsMsgClient extends TdsMsgSubject {

@@ -47,4 +47,5 @@ private readonly tdsOrigin;

* @param path
* @param options
*/
syncPath(path: string): void;
syncPath(path: string, options?: SyncPathPayload['options']): void;
/**

@@ -51,0 +52,0 @@ * 用于主动要求服务端更新 ticket 使用

@@ -89,5 +89,6 @@ import { __extends } from "tslib";

* @param path
* @param options
*/
TdsMsgClient.prototype.syncPath = function (path) {
this.sendMessage(new TdsMsgClient.ClientSyncPath({ path: path }));
TdsMsgClient.prototype.syncPath = function (path, options) {
this.sendMessage(new TdsMsgClient.ClientSyncPath({ path: path, options: options }));
};

@@ -94,0 +95,0 @@ /**

@@ -29,2 +29,12 @@ import EventEmitter from 'eventemitter3';

}
export declare enum ACTION_TYPE {
PUSH = "PUSH",
REPLACE = "REPLACE"
}
export declare type SyncPathPayload = {
path: string;
options?: {
action: ACTION_TYPE;
};
};
export declare type TdsCallback = (tdsMsg: TdsMsg) => void;

@@ -71,12 +81,6 @@ /**

*/
export declare class TdsMsgSyncPath extends TdsMsgBase implements TdsMsg<{
path: string;
}> {
payload: {
path: any;
};
export declare class TdsMsgSyncPath extends TdsMsgBase implements TdsMsg<SyncPathPayload> {
payload: SyncPathPayload;
type: TDS_MESSAGE_TYPE;
constructor(payload: {
path: any;
});
constructor(payload: SyncPathPayload);
}

@@ -83,0 +87,0 @@ /**

@@ -9,2 +9,7 @@ import { __extends } from "tslib";

})(ERROR_CODE || (ERROR_CODE = {}));
export var ACTION_TYPE;
(function (ACTION_TYPE) {
ACTION_TYPE["PUSH"] = "PUSH";
ACTION_TYPE["REPLACE"] = "REPLACE";
})(ACTION_TYPE || (ACTION_TYPE = {}));
/**

@@ -11,0 +16,0 @@ * Tds 消息类型

{
"name": "@taptap/tds-msg",
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "module": "es/index.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

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

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