Repository navigation
Expand file tree
/
Copy pathpostmessage.min.js
More file actions
1 lines (1 loc) · 5.24 KB
/
Copy pathpostmessage.min.js
File metadata and controls
1 lines (1 loc) · 5.24 KB
1
!function(){function require(path,parent,orig){var resolved=require.resolve(path);if(null==resolved){orig=orig||path,parent=parent||"root";var err=new Error('Failed to require "'+orig+'" from "'+parent+'"');throw err.path=orig,err.parent=parent,err.require=!0,err}var module=require.modules[resolved];return module.exports||(module.exports={},module.client=module.component=!0,module.call(this,module.exports,require.relative(resolved),module)),module.exports}require.modules={},require.aliases={},require.resolve=function(path){"/"===path.charAt(0)&&(path=path.slice(1));for(var paths=[path,path+".js",path+".json",path+"/index.js",path+"/index.json"],i=0;i<paths.length;i++){var path=paths[i];if(require.modules.hasOwnProperty(path))return path;if(require.aliases.hasOwnProperty(path))return require.aliases[path]}},require.normalize=function(curr,path){var segs=[];if("."!=path.charAt(0))return path;curr=curr.split("/"),path=path.split("/");for(var i=0;i<path.length;++i)".."==path[i]?curr.pop():"."!=path[i]&&""!=path[i]&&segs.push(path[i]);return curr.concat(segs).join("/")},require.register=function(path,definition){require.modules[path]=definition},require.alias=function(from,to){if(!require.modules.hasOwnProperty(from))throw new Error('Failed to alias "'+from+'", it does not exist');require.aliases[to]=from},require.relative=function(parent){function lastIndexOf(arr,obj){for(var i=arr.length;i--;)if(arr[i]===obj)return i;return-1}function localRequire(path){var resolved=localRequire.resolve(path);return require(resolved,parent,path)}var p=require.normalize(parent,"..");return localRequire.resolve=function(path){var c=path.charAt(0);if("/"==c)return path.slice(1);if("."==c)return require.normalize(p,path);var segs=parent.split("/"),i=lastIndexOf(segs,"deps")+1;return i||(i=0),path=segs.slice(0,i+1).join("/")+"/deps/"+path},localRequire.exists=function(path){return require.modules.hasOwnProperty(localRequire.resolve(path))},localRequire},require.register("component-bind/index.js",function(exports,require,module){var slice=[].slice;module.exports=function(obj,fn){if("string"==typeof fn&&(fn=obj[fn]),"function"!=typeof fn)throw new Error("bind() requires a function");var args=[].slice.call(arguments,2);return function(){return fn.apply(obj,args.concat(slice.call(arguments)))}}}),require.register("postmessage/lib/pub.js",function(exports,require,module){function Publisher(target){return this instanceof Publisher?(this.defaults().target(target),void 0):new Publisher(target)}module.exports=Publisher,Publisher.prototype.defaults=function(){return this._origin="*",this._target=window.parent,this},Publisher.prototype.target=function target(target){return arguments.length?(this._target=target||this._target,this):this._target},Publisher.prototype.origin=function origin(origin){return arguments.length?(this._origin=origin||this._origin,this):this._origin},Publisher.prototype.send=Publisher.prototype.publish=function(data,target,origin){var pub=this;return data=JSON.stringify(data),this.target(target).origin(origin),setTimeout(function(){pub._target.postMessage(data,pub._origin)},0),this}}),require.register("postmessage/lib/sub.js",function(exports,require,module){function Subscriber(win){return this instanceof Subscriber?(this.defaults(win),this._bind(),void 0):new Subscriber(win)}var bind=require("bind");module.exports=Subscriber,Subscriber.prototype.defaults=function(win){return this.fns=[],this.origins=[],this.win=win||window,this},Subscriber.prototype._bind=function(){return this.onmessage=bind(this,"onmessage"),this.win.addEventListener("message",this.onmessage,!1),this},Subscriber.prototype._unbind=function(){return this.win.removeEventListener("message",this.onmessage,!1),this},Subscriber.prototype.onmessage=function(e){if(this.matches())for(var i=0,l=this.fns.length;l>i;++i)this.fns[i](JSON.parse(e.data),e);return this},Subscriber.prototype.origin=function origin(origin){return"string"==typeof origin&&this.origins.push(origin),this},Subscriber.prototype.matches=function(origin){var oRE=new RegExp("^("+this.origins.join("|")+")$");return 0===this.origins.length||oRE.test(origin)},Subscriber.prototype.bind=Subscriber.prototype.subscribe=function(fn){return"function"==typeof fn&&(fn.id=this.fns.length+1,this.fns.push(fn)),this},Subscriber.prototype.unbind=Subscriber.prototype.unsubscribe=function(fn){if(arguments.length){if("function"==typeof fn){var fns=this.fns;for(var i in fns)if(fns[i]==fn&&fn.id===fns[i].id){fns.splice(i,1);break}}}else this.fns=[];return this},Subscriber.prototype.destroy=function(){return this._unbind(),this.defaults(),this}}),require.register("postmessage/lib/index.js",function(exports,require,module){module.exports={pub:require("./pub"),sub:require("./sub")}}),require.register("postmessage/index.js",function(exports,require,module){function PostMessage(type){return pm[type]}var pm=require("./lib");module.exports=PostMessage,PostMessage.Pub=pm.pub,PostMessage.Sub=pm.sub}),require.alias("component-bind/index.js","postmessage/deps/bind/index.js"),require.alias("component-bind/index.js","bind/index.js"),require.alias("postmessage/index.js","postmessage/index.js"),"object"==typeof exports?module.exports=require("postmessage"):"function"==typeof define&&define.amd?define(function(){return require("postmessage")}):this.postmessage=require("postmessage")}();