@trutoo/event-bus
Version:
Typesafe cross-platform pubsub event bus ensuring reliable communication between fragments and micro frontends.
3 lines (2 loc) • 40.3 kB
JavaScript
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).EventBus={})}(this,(function(e){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},r(e,t)};function t(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var n=function(){return n=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},n.apply(this,arguments)};function a(e,r,t,n){return new(t||(t=Promise))((function(a,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var r;e.done?a(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,s)}u((n=n.apply(e,r||[])).next())}))}function i(e,r){var t,n,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(t=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=r.call(e,i)}catch(e){s=[6,e],n=0}finally{t=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}"function"==typeof SuppressedError&&SuppressedError;var o=Object.getOwnPropertyNames,s=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty;function c(e,r){return function(t,n,a){return e(t,n,a)&&r(t,n,a)}}function f(e){return function(r,t,n){if(!r||!t||"object"!=typeof r||"object"!=typeof t)return e(r,t,n);var a=n.cache,i=a.get(r),o=a.get(t);if(i&&o)return i===t&&o===r;a.set(r,t),a.set(t,r);var s=e(r,t,n);return a.delete(r),a.delete(t),s}}function l(e){return o(e).concat(s(e))}var m=Object.hasOwn||function(e,r){return u.call(e,r)};function h(e,r){return e===r||!e&&!r&&e!=e&&r!=r}var d="__v",p="__o",v="_owner",y=Object.getOwnPropertyDescriptor,g=Object.keys;function b(e,r,t){var n=e.length;if(r.length!==n)return!1;for(;n-- >0;)if(!t.equals(e[n],r[n],n,n,e,r,t))return!1;return!0}function F(e,r){return h(e.getTime(),r.getTime())}function A(e,r){return e.name===r.name&&e.message===r.message&&e.cause===r.cause&&e.stack===r.stack}function w(e,r){return e===r}function E(e,r,t){var n=e.size;if(n!==r.size)return!1;if(!n)return!0;for(var a,i,o=new Array(n),s=e.entries(),u=0;(a=s.next())&&!a.done;){for(var c=r.entries(),f=!1,l=0;(i=c.next())&&!i.done;)if(o[l])l++;else{var m=a.value,h=i.value;if(t.equals(m[0],h[0],u,l,e,r,t)&&t.equals(m[1],h[1],m[0],h[0],e,r,t)){f=o[l]=!0;break}l++}if(!f)return!1;u++}return!0}var x=h;function S(e,r,t){var n=g(e),a=n.length;if(g(r).length!==a)return!1;for(;a-- >0;)if(!P(e,r,t,n[a]))return!1;return!0}function z(e,r,t){var n,a,i,o=l(e),s=o.length;if(l(r).length!==s)return!1;for(;s-- >0;){if(!P(e,r,t,n=o[s]))return!1;if(a=y(e,n),i=y(r,n),(a||i)&&(!a||!i||a.configurable!==i.configurable||a.enumerable!==i.enumerable||a.writable!==i.writable))return!1}return!0}function Z(e,r){return h(e.valueOf(),r.valueOf())}function $(e,r){return e.source===r.source&&e.flags===r.flags}function O(e,r,t){var n=e.size;if(n!==r.size)return!1;if(!n)return!0;for(var a,i,o=new Array(n),s=e.values();(a=s.next())&&!a.done;){for(var u=r.values(),c=!1,f=0;(i=u.next())&&!i.done;){if(!o[f]&&t.equals(a.value,i.value,a.value,i.value,e,r,t)){c=o[f]=!0;break}f++}if(!c)return!1}return!0}function _(e,r){var t=e.length;if(r.length!==t)return!1;for(;t-- >0;)if(e[t]!==r[t])return!1;return!0}function j(e,r){return e.hostname===r.hostname&&e.pathname===r.pathname&&e.protocol===r.protocol&&e.port===r.port&&e.hash===r.hash&&e.username===r.username&&e.password===r.password}function P(e,r,t,n){return!(n!==v&&n!==p&&n!==d||!e.$$typeof&&!r.$$typeof)||m(r,n)&&t.equals(e[n],r[n],n,n,e,r,t)}var q="[object Arguments]",k="[object Boolean]",C="[object Date]",M="[object Error]",R="[object Map]",I="[object Number]",V="[object Object]",T="[object RegExp]",N="[object Set]",U="[object String]",D="[object URL]",L=Array.isArray,J="function"==typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView:null,B=Object.assign,G=Object.prototype.toString.call.bind(Object.prototype.toString);H();var W=H({strict:!0});function H(e){void 0===e&&(e={});var r,t=e.circular,n=void 0!==t&&t,a=e.createInternalComparator,i=e.createState,o=e.strict,s=void 0!==o&&o,u=function(e){var r=e.circular,t=e.createCustomConfig,n=e.strict,a={areArraysEqual:n?z:b,areDatesEqual:F,areErrorsEqual:A,areFunctionsEqual:w,areMapsEqual:n?c(E,z):E,areNumbersEqual:x,areObjectsEqual:n?z:S,arePrimitiveWrappersEqual:Z,areRegExpsEqual:$,areSetsEqual:n?c(O,z):O,areTypedArraysEqual:n?z:_,areUrlsEqual:j};if(t&&(a=B({},a,t(a))),r){var i=f(a.areArraysEqual),o=f(a.areMapsEqual),s=f(a.areObjectsEqual),u=f(a.areSetsEqual);a=B({},a,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:s,areSetsEqual:u})}return a}(e),l=function(e){var r=e.areArraysEqual,t=e.areDatesEqual,n=e.areErrorsEqual,a=e.areFunctionsEqual,i=e.areMapsEqual,o=e.areNumbersEqual,s=e.areObjectsEqual,u=e.arePrimitiveWrappersEqual,c=e.areRegExpsEqual,f=e.areSetsEqual,l=e.areTypedArraysEqual,m=e.areUrlsEqual;return function(e,h,d){if(e===h)return!0;if(null==e||null==h)return!1;var p=typeof e;if(p!==typeof h)return!1;if("object"!==p)return"number"===p?o(e,h,d):"function"===p&&a(e,h,d);var v=e.constructor;if(v!==h.constructor)return!1;if(v===Object)return s(e,h,d);if(L(e))return r(e,h,d);if(null!=J&&J(e))return l(e,h,d);if(v===Date)return t(e,h,d);if(v===RegExp)return c(e,h,d);if(v===Map)return i(e,h,d);if(v===Set)return f(e,h,d);var y=G(e);return y===C?t(e,h,d):y===T?c(e,h,d):y===R?i(e,h,d):y===N?f(e,h,d):y===V?"function"!=typeof e.then&&"function"!=typeof h.then&&s(e,h,d):y===D?m(e,h,d):y===M?n(e,h,d):y===q?s(e,h,d):(y===k||y===I||y===U)&&u(e,h,d)}}(u);return function(e){var r=e.circular,t=e.comparator,n=e.createState,a=e.equals,i=e.strict;if(n)return function(e,o){var s=n(),u=s.cache,c=void 0===u?r?new WeakMap:void 0:u,f=s.meta;return t(e,o,{cache:c,equals:a,meta:f,strict:i})};if(r)return function(e,r){return t(e,r,{cache:new WeakMap,equals:a,meta:void 0,strict:i})};var o={cache:void 0,equals:a,meta:void 0,strict:i};return function(e,r){return t(e,r,o)}}({circular:n,comparator:l,createState:i,equals:a?a(l):(r=l,function(e,t,n,a,i,o,s){return r(e,t,s)}),strict:s})}H({circular:!0}),H({circular:!0,strict:!0}),H({createInternalComparator:function(){return h}}),H({strict:!0,createInternalComparator:function(){return h}}),H({circular:!0,createInternalComparator:function(){return h}}),H({circular:!0,createInternalComparator:function(){return h},strict:!0});var X,Y,K,Q={},ee={};function re(){if(X)return ee;X=1;var e=ee.ValidationError=function(e,r,t,n,a,i){if(Array.isArray(n)?(this.path=n,this.property=n.reduce((function(e,r){return e+s(r)}),"instance")):void 0!==n&&(this.property=n),e&&(this.message=e),t){var o=t.$id||t.id;this.schema=o||t}void 0!==r&&(this.instance=r),this.name=a,this.argument=i,this.stack=this.toString()};e.prototype.toString=function(){return this.property+" "+this.message};var r=ee.ValidatorResult=function(e,r,t,n){this.instance=e,this.schema=r,this.options=t,this.path=n.path,this.propertyPath=n.propertyPath,this.errors=[],this.throwError=t&&t.throwError,this.throwFirst=t&&t.throwFirst,this.throwAll=t&&t.throwAll,this.disableFormat=t&&!0===t.disableFormat};function t(e,r){return r+": "+e.toString()+"\n"}function n(e){"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,n),this.instance=e.instance,this.schema=e.schema,this.options=e.options,this.errors=e.errors}r.prototype.addError=function(r){var t;if("string"==typeof r)t=new e(r,this.instance,this.schema,this.path);else{if(!r)throw new Error("Missing error detail");if(!r.message)throw new Error("Missing error message");if(!r.name)throw new Error("Missing validator type");t=new e(r.message,this.instance,this.schema,this.path,r.name,r.argument)}if(this.errors.push(t),this.throwFirst)throw new n(this);if(this.throwError)throw t;return t},r.prototype.importErrors=function(e){"string"==typeof e||e&&e.validatorType?this.addError(e):e&&e.errors&&(this.errors=this.errors.concat(e.errors))},r.prototype.toString=function(e){return this.errors.map(t).join("")},Object.defineProperty(r.prototype,"valid",{get:function(){return!this.errors.length}}),ee.ValidatorResultError=n,n.prototype=new Error,n.prototype.constructor=n,n.prototype.name="Validation Error";var a=ee.SchemaError=function e(r,t){this.message=r,this.schema=t,Error.call(this,r),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)};a.prototype=Object.create(Error.prototype,{constructor:{value:a,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var i=ee.SchemaContext=function(e,r,t,n,a){this.schema=e,this.options=r,Array.isArray(t)?(this.path=t,this.propertyPath=t.reduce((function(e,r){return e+s(r)}),"instance")):this.propertyPath=t,this.base=n,this.schemas=a};i.prototype.resolve=function(e){return(()=>h(this.base,e))()},i.prototype.makeChild=function(e,r){var t=void 0===r?this.path:this.path.concat([r]),n=e.$id||e.id;let a=(()=>h(this.base,n||""))();var o=new i(e,this.options,t,a,Object.create(this.schemas));return n&&!o.schemas[a]&&(o.schemas[a]=e),o};var o=ee.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,duration:/P(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S)|\d+(D|M(\d+D)?|Y(\d+M(\d+D)?)?)(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S))?|\d+W)/i,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)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((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+(:\d*)?|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/u,uuid:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,"uri-template":/(%[0-9a-f]{2}|[!#$&(-;=?@\[\]_a-z~]|\{[!#&+,./;=?@|]?(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?(,(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?)*\})*/iu,"json-pointer":/^(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*$/iu,"relative-json-pointer":/^\d+(#|(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*)$/iu,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"utc-millisec":function(e){return"string"==typeof e&&parseFloat(e)===parseInt(e,10)&&!isNaN(e)},regex:function(e){var r=!0;try{new RegExp(e)}catch(e){r=!1}return r},style:/[\r\n\t ]*[^\r\n\t ][^:]*:[\r\n\t ]*[^\r\n\t ;]*[\r\n\t ]*;?/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/};o.regexp=o.regex,o.pattern=o.regex,o.ipv4=o["ip-address"],ee.isFormat=function(e,r,t){if("string"==typeof e&&void 0!==o[r]){if(o[r]instanceof RegExp)return o[r].test(e);if("function"==typeof o[r])return o[r](e)}else if(t&&t.customFormats&&"function"==typeof t.customFormats[r])return t.customFormats[r](e);return!0};var s=ee.makeSuffix=function(e){return(e=e.toString()).match(/[.\s\[\]]/)||e.match(/^[\d]/)?e.match(/^\d+$/)?"["+e+"]":"["+JSON.stringify(e)+"]":"."+e};function u(e,r,t,n){"object"==typeof t?r[n]=l(e[n],t):-1===e.indexOf(t)&&r.push(t)}function c(e,r,t){r[t]=e[t]}function f(e,r,t,n){"object"==typeof r[n]&&r[n]&&e[n]?t[n]=l(e[n],r[n]):t[n]=r[n]}function l(e,r){var t=Array.isArray(r),n=t&&[]||{};return t?(e=e||[],n=n.concat(e),r.forEach(u.bind(null,e,n))):(e&&"object"==typeof e&&Object.keys(e).forEach(c.bind(null,e,n)),Object.keys(r).forEach(f.bind(null,e,r,n))),n}function m(e){return"/"+encodeURIComponent(e).replace(/~/g,"%7E")}ee.deepCompareStrict=function e(r,t){if(typeof r!=typeof t)return!1;if(Array.isArray(r))return!!Array.isArray(t)&&(r.length===t.length&&r.every((function(n,a){return e(r[a],t[a])})));if("object"==typeof r){if(!r||!t)return r===t;var n=Object.keys(r),a=Object.keys(t);return n.length===a.length&&n.every((function(n){return e(r[n],t[n])}))}return r===t},ee.deepMerge=l,ee.objectGetPath=function(e,r){for(var t,n=r.split("/").slice(1);"string"==typeof(t=n.shift());){var a=decodeURIComponent(t.replace(/~0/,"~").replace(/~1/g,"/"));if(!(a in e))return;e=e[a]}return e},ee.encodePath=function(e){return e.map(m).join("")},ee.getDecimalPlaces=function(e){var r=0;if(isNaN(e))return r;"number"!=typeof e&&(e=Number(e));var t=e.toString().split("e");if(2===t.length){if("-"!==t[1][0])return r;r=Number(t[1].slice(1))}var n=t[0].split(".");return 2===n.length&&(r+=n[1].length),r},ee.isSchema=function(e){return"object"==typeof e&&e||"boolean"==typeof e};var h=ee.resolveUrl=function(e,r){const t=new URL(r,new URL(e,"resolve://"));if("resolve:"===t.protocol){const{pathname:e,search:r,hash:n}=t;return e+r+n}return t.toString()};return ee}var te,ne,ae,ie,oe={};function se(){if(te)return oe;te=1;var e=re();function r(e,r){this.id=e,this.ref=r}return oe.SchemaScanResult=r,oe.scan=function(t,n){function a(r,t){if(!t||"object"!=typeof t)return;if(t.$ref){let n=e.resolveUrl(r,t.$ref);return void(u[n]=u[n]?u[n]+1:0)}var n=t.$id||t.id;let c=e.resolveUrl(r,n);var f=n?c:r;if(f){if(f.indexOf("#")<0&&(f+="#"),s[f]){if(!e.deepCompareStrict(s[f],t))throw new Error("Schema <"+f+"> already exists with different definition");return s[f]}s[f]=t,"#"==f[f.length-1]&&(s[f.substring(0,f.length-1)]=t)}i(f+"/items",Array.isArray(t.items)?t.items:[t.items]),i(f+"/extends",Array.isArray(t.extends)?t.extends:[t.extends]),a(f+"/additionalItems",t.additionalItems),o(f+"/properties",t.properties),a(f+"/additionalProperties",t.additionalProperties),o(f+"/definitions",t.definitions),o(f+"/patternProperties",t.patternProperties),o(f+"/dependencies",t.dependencies),i(f+"/disallow",t.disallow),i(f+"/allOf",t.allOf),i(f+"/anyOf",t.anyOf),i(f+"/oneOf",t.oneOf),a(f+"/not",t.not)}function i(e,r){if(Array.isArray(r))for(var t=0;t<r.length;t++)a(e+"/"+t,r[t])}function o(e,r){if(r&&"object"==typeof r)for(var t in r)a(e+"/"+t,r[t])}var s={},u={};return a(t,n),new r(s,u)},oe}function ue(){if(ae)return ne;ae=1;var e=function(){if(K)return Y;K=1;var e=re(),r=e.ValidatorResult,t=e.SchemaError,n={ignoreProperties:{id:!0,default:!0,description:!0,title:!0,additionalItems:!0,then:!0,else:!0,$schema:!0,$ref:!0,extends:!0}},a=n.validators={};function i(e,r,t,n,a){var i=r.throwError,o=r.throwAll;r.throwError=!1,r.throwAll=!1;var s=this.validateSchema(e,a,r,t);return r.throwError=i,r.throwAll=o,!s.valid&&n instanceof Function&&n(s),s.valid}function o(e,r){if(Object.hasOwnProperty.call(e,r))return e[r];if(r in e)for(;e=Object.getPrototypeOf(e);)if(Object.propertyIsEnumerable.call(e,r))return e[r]}function s(e,r,t,n,a,i){if(this.types.object(e)&&(!r.properties||void 0===r.properties[a]))if(!1===r.additionalProperties)i.addError({name:"additionalProperties",argument:a,message:"is not allowed to have the additional property "+JSON.stringify(a)});else{var o=r.additionalProperties||{};"function"==typeof t.preValidateProperty&&t.preValidateProperty(e,a,o,t,n);var s=this.validateSchema(e[a],o,t,n.makeChild(o,a));s.instance!==i.instance[a]&&(i.instance[a]=s.instance),i.importErrors(s)}}a.type=function(e,t,n,a){if(void 0===e)return null;var i=new r(e,t,n,a),o=Array.isArray(t.type)?t.type:[t.type];if(!o.some(this.testType.bind(this,e,t,n,a))){var s=o.map((function(e){if(e){var r=e.$id||e.id;return r?"<"+r+">":e+""}}));i.addError({name:"type",argument:s,message:"is not of a type(s) "+s})}return i},a.anyOf=function(e,n,a,o){if(void 0===e)return null;var s=new r(e,n,a,o),u=new r(e,n,a,o);if(!Array.isArray(n.anyOf))throw new t("anyOf must be an array");if(!n.anyOf.some(i.bind(this,e,a,o,(function(e){u.importErrors(e)})))){var c=n.anyOf.map((function(e,r){var t=e.$id||e.id;return t?"<"+t+">":e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+r+"]"}));a.nestedErrors&&s.importErrors(u),s.addError({name:"anyOf",argument:c,message:"is not any of "+c.join(",")})}return s},a.allOf=function(e,n,a,i){if(void 0===e)return null;if(!Array.isArray(n.allOf))throw new t("allOf must be an array");var o=new r(e,n,a,i),s=this;return n.allOf.forEach((function(r,t){var n=s.validateSchema(e,r,a,i);if(!n.valid){var u=r.$id||r.id||r.title&&JSON.stringify(r.title)||r.$ref&&"<"+r.$ref+">"||"[subschema "+t+"]";o.addError({name:"allOf",argument:{id:u,length:n.errors.length,valid:n},message:"does not match allOf schema "+u+" with "+n.errors.length+" error[s]:"}),o.importErrors(n)}})),o},a.oneOf=function(e,n,a,o){if(void 0===e)return null;if(!Array.isArray(n.oneOf))throw new t("oneOf must be an array");var s=new r(e,n,a,o),u=new r(e,n,a,o),c=n.oneOf.filter(i.bind(this,e,a,o,(function(e){u.importErrors(e)}))).length,f=n.oneOf.map((function(e,r){return e.$id||e.id||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+r+"]"}));return 1!==c&&(a.nestedErrors&&s.importErrors(u),s.addError({name:"oneOf",argument:f,message:"is not exactly one from "+f.join(",")})),s},a.if=function(t,n,a,o){if(void 0===t)return null;if(!e.isSchema(n.if))throw new Error('Expected "if" keyword to be a schema');var s,u=i.call(this,t,a,o,null,n.if),c=new r(t,n,a,o);if(u){if(void 0===n.then)return;if(!e.isSchema(n.then))throw new Error('Expected "then" keyword to be a schema');s=this.validateSchema(t,n.then,a,o.makeChild(n.then)),c.importErrors(s)}else{if(void 0===n.else)return;if(!e.isSchema(n.else))throw new Error('Expected "else" keyword to be a schema');s=this.validateSchema(t,n.else,a,o.makeChild(n.else)),c.importErrors(s)}return c},a.propertyNames=function(n,a,i,s){if(this.types.object(n)){var u=new r(n,a,i,s),c=void 0!==a.propertyNames?a.propertyNames:{};if(!e.isSchema(c))throw new t('Expected "propertyNames" to be a schema (object or boolean)');for(var f in n)if(void 0!==o(n,f)){var l=this.validateSchema(f,c,i,s.makeChild(c));u.importErrors(l)}return u}},a.properties=function(e,n,a,i){if(this.types.object(e)){var s=new r(e,n,a,i),u=n.properties||{};for(var c in u){var f=u[c];if(void 0!==f){if(null===f)throw new t('Unexpected null, expected schema in "properties"');"function"==typeof a.preValidateProperty&&a.preValidateProperty(e,c,f,a,i);var l=o(e,c),m=this.validateSchema(l,f,a,i.makeChild(f,c));m.instance!==s.instance[c]&&(s.instance[c]=m.instance),s.importErrors(m)}}return s}},a.patternProperties=function(e,n,a,i){if(this.types.object(e)){var o=new r(e,n,a,i),u=n.patternProperties||{};for(var c in e){var f=!0;for(var l in u){var m=u[l];if(void 0!==m){if(null===m)throw new t('Unexpected null, expected schema in "patternProperties"');try{var h=new RegExp(l,"u")}catch(e){h=new RegExp(l)}if(h.test(c)){f=!1,"function"==typeof a.preValidateProperty&&a.preValidateProperty(e,c,m,a,i);var d=this.validateSchema(e[c],m,a,i.makeChild(m,c));d.instance!==o.instance[c]&&(o.instance[c]=d.instance),o.importErrors(d)}}}f&&s.call(this,e,n,a,i,c,o)}return o}},a.additionalProperties=function(e,t,n,a){if(this.types.object(e)){if(t.patternProperties)return null;var i=new r(e,t,n,a);for(var o in e)s.call(this,e,t,n,a,o,i);return i}},a.minProperties=function(e,t,n,a){if(this.types.object(e)){var i=new r(e,t,n,a);return Object.keys(e).length>=t.minProperties||i.addError({name:"minProperties",argument:t.minProperties,message:"does not meet minimum property length of "+t.minProperties}),i}},a.maxProperties=function(e,t,n,a){if(this.types.object(e)){var i=new r(e,t,n,a);return Object.keys(e).length<=t.maxProperties||i.addError({name:"maxProperties",argument:t.maxProperties,message:"does not meet maximum property length of "+t.maxProperties}),i}},a.items=function(e,t,n,a){var i=this;if(this.types.array(e)&&void 0!==t.items){var o=new r(e,t,n,a);return e.every((function(e,r){if(Array.isArray(t.items))var s=void 0===t.items[r]?t.additionalItems:t.items[r];else s=t.items;if(void 0===s)return!0;if(!1===s)return o.addError({name:"items",message:"additionalItems not permitted"}),!1;var u=i.validateSchema(e,s,n,a.makeChild(s,r));return u.instance!==o.instance[r]&&(o.instance[r]=u.instance),o.importErrors(u),!0})),o}},a.contains=function(t,n,a,i){var o=this;if(this.types.array(t)&&void 0!==n.contains){if(!e.isSchema(n.contains))throw new Error('Expected "contains" keyword to be a schema');var s=new r(t,n,a,i);return!1===t.some((function(e,r){return 0===o.validateSchema(e,n.contains,a,i.makeChild(n.contains,r)).errors.length}))&&s.addError({name:"contains",argument:n.contains,message:"must contain an item matching given schema"}),s}},a.minimum=function(e,t,n,a){if(this.types.number(e)){var i=new r(e,t,n,a);return t.exclusiveMinimum&&!0===t.exclusiveMinimum?e>t.minimum||i.addError({name:"minimum",argument:t.minimum,message:"must be greater than "+t.minimum}):e>=t.minimum||i.addError({name:"minimum",argument:t.minimum,message:"must be greater than or equal to "+t.minimum}),i}},a.maximum=function(e,t,n,a){if(this.types.number(e)){var i=new r(e,t,n,a);return t.exclusiveMaximum&&!0===t.exclusiveMaximum?e<t.maximum||i.addError({name:"maximum",argument:t.maximum,message:"must be less than "+t.maximum}):e<=t.maximum||i.addError({name:"maximum",argument:t.maximum,message:"must be less than or equal to "+t.maximum}),i}},a.exclusiveMinimum=function(e,t,n,a){if("boolean"!=typeof t.exclusiveMinimum&&this.types.number(e)){var i=new r(e,t,n,a);return e>t.exclusiveMinimum||i.addError({name:"exclusiveMinimum",argument:t.exclusiveMinimum,message:"must be strictly greater than "+t.exclusiveMinimum}),i}},a.exclusiveMaximum=function(e,t,n,a){if("boolean"!=typeof t.exclusiveMaximum&&this.types.number(e)){var i=new r(e,t,n,a);return e<t.exclusiveMaximum||i.addError({name:"exclusiveMaximum",argument:t.exclusiveMaximum,message:"must be strictly less than "+t.exclusiveMaximum}),i}};var u=function(n,a,i,o,s,u){if(this.types.number(n)){var c=a[s];if(0==c)throw new t(s+" cannot be zero");var f=new r(n,a,i,o),l=e.getDecimalPlaces(n),m=e.getDecimalPlaces(c),h=Math.max(l,m),d=Math.pow(10,h);return Math.round(n*d)%Math.round(c*d)!=0&&f.addError({name:s,argument:c,message:u+JSON.stringify(c)}),f}};function c(r,t,n){var a,i=n.length;for(a=t+1;a<i;a++)if(e.deepCompareStrict(r,n[a]))return!1;return!0}return a.multipleOf=function(e,r,t,n){return u.call(this,e,r,t,n,"multipleOf","is not a multiple of (divisible by) ")},a.divisibleBy=function(e,r,t,n){return u.call(this,e,r,t,n,"divisibleBy","is not divisible by (multiple of) ")},a.required=function(e,t,n,a){var i=new r(e,t,n,a);return void 0===e&&!0===t.required?i.addError({name:"required",message:"is required"}):this.types.object(e)&&Array.isArray(t.required)&&t.required.forEach((function(r){void 0===o(e,r)&&i.addError({name:"required",argument:r,message:"requires property "+JSON.stringify(r)})})),i},a.pattern=function(e,t,n,a){if(this.types.string(e)){var i=new r(e,t,n,a),o=t.pattern;try{var s=new RegExp(o,"u")}catch(e){s=new RegExp(o)}return e.match(s)||i.addError({name:"pattern",argument:t.pattern,message:"does not match pattern "+JSON.stringify(t.pattern.toString())}),i}},a.format=function(t,n,a,i){if(void 0!==t){var o=new r(t,n,a,i);return o.disableFormat||e.isFormat(t,n.format,this)||o.addError({name:"format",argument:n.format,message:"does not conform to the "+JSON.stringify(n.format)+" format"}),o}},a.minLength=function(e,t,n,a){if(this.types.string(e)){var i=new r(e,t,n,a),o=e.match(/[\uDC00-\uDFFF]/g);return e.length-(o?o.length:0)>=t.minLength||i.addError({name:"minLength",argument:t.minLength,message:"does not meet minimum length of "+t.minLength}),i}},a.maxLength=function(e,t,n,a){if(this.types.string(e)){var i=new r(e,t,n,a),o=e.match(/[\uDC00-\uDFFF]/g);return e.length-(o?o.length:0)<=t.maxLength||i.addError({name:"maxLength",argument:t.maxLength,message:"does not meet maximum length of "+t.maxLength}),i}},a.minItems=function(e,t,n,a){if(this.types.array(e)){var i=new r(e,t,n,a);return e.length>=t.minItems||i.addError({name:"minItems",argument:t.minItems,message:"does not meet minimum length of "+t.minItems}),i}},a.maxItems=function(e,t,n,a){if(this.types.array(e)){var i=new r(e,t,n,a);return e.length<=t.maxItems||i.addError({name:"maxItems",argument:t.maxItems,message:"does not meet maximum length of "+t.maxItems}),i}},a.uniqueItems=function(e,t,n,a){if(!0===t.uniqueItems&&this.types.array(e)){var i=new r(e,t,n,a);return e.every(c)||i.addError({name:"uniqueItems",message:"contains duplicate item"}),i}},a.dependencies=function(e,t,n,a){if(this.types.object(e)){var i=new r(e,t,n,a);for(var o in t.dependencies)if(void 0!==e[o]){var s=t.dependencies[o],u=a.makeChild(s,o);if("string"==typeof s&&(s=[s]),Array.isArray(s))s.forEach((function(r){void 0===e[r]&&i.addError({name:"dependencies",argument:u.propertyPath,message:"property "+r+" not found, required by "+u.propertyPath})}));else{var c=this.validateSchema(e,s,n,u);i.instance!==c.instance&&(i.instance=c.instance),c&&c.errors.length&&(i.addError({name:"dependencies",argument:u.propertyPath,message:"does not meet dependency required by "+u.propertyPath}),i.importErrors(c))}}return i}},a.enum=function(n,a,i,o){if(void 0===n)return null;if(!Array.isArray(a.enum))throw new t("enum expects an array",a);var s=new r(n,a,i,o);return a.enum.some(e.deepCompareStrict.bind(null,n))||s.addError({name:"enum",argument:a.enum,message:"is not one of enum values: "+a.enum.map(String).join(",")}),s},a.const=function(t,n,a,i){if(void 0===t)return null;var o=new r(t,n,a,i);return e.deepCompareStrict(n.const,t)||o.addError({name:"const",argument:n.const,message:"does not exactly match expected constant: "+n.const}),o},a.not=a.disallow=function(e,t,n,a){var i=this;if(void 0===e)return null;var o=new r(e,t,n,a),s=t.not||t.disallow;return s?(Array.isArray(s)||(s=[s]),s.forEach((function(r){if(i.testType(e,t,n,a,r)){var s=r&&(r.$id||r.id)||r;o.addError({name:"not",argument:s,message:"is of prohibited type "+s})}})),o):null},Y=n}(),r=re(),t=se().scan,n=r.ValidatorResult,a=r.ValidatorResultError,i=r.SchemaError,o=r.SchemaContext,s=function r(){this.customFormats=Object.create(r.prototype.customFormats),this.schemas={},this.unresolvedRefs=[],this.types=Object.create(c),this.attributes=Object.create(e.validators)};function u(e){var r="string"==typeof e?e:e.$ref;return"string"==typeof r&&r}s.prototype.customFormats={},s.prototype.schemas=null,s.prototype.types=null,s.prototype.attributes=null,s.prototype.unresolvedRefs=null,s.prototype.addSchema=function(e,r){var n=this;if(!e)return null;var a=t(r||"/",e),i=r||e.$id||e.id;for(var o in a.id)this.schemas[o]=a.id[o];for(var o in a.ref)this.unresolvedRefs.push(o);return this.unresolvedRefs=this.unresolvedRefs.filter((function(e){return void 0===n.schemas[e]})),this.schemas[i]},s.prototype.addSubSchemaArray=function(e,r){if(Array.isArray(r))for(var t=0;t<r.length;t++)this.addSubSchema(e,r[t])},s.prototype.addSubSchemaObject=function(e,r){if(r&&"object"==typeof r)for(var t in r)this.addSubSchema(e,r[t])},s.prototype.setSchemas=function(e){this.schemas=e},s.prototype.getSchema=function(e){return this.schemas[e]},s.prototype.validate=function(e,s,u,c){if("boolean"!=typeof s&&"object"!=typeof s||null===s)throw new i("Expected `schema` to be an object or boolean");u||(u={});var f=s.$id||s.id;let l=r.resolveUrl(u.base,f||"");if(!c){(c=new o(s,u,[],l,Object.create(this.schemas))).schemas[l]||(c.schemas[l]=s);var m=t(l,s);for(var h in m.id){var d=m.id[h];c.schemas[h]=d}}var p;if(u.required&&void 0===e)return(p=new n(e,s,u,c)).addError("is required, but is undefined"),p;if(!(p=this.validateSchema(e,s,u,c)))throw new Error("Result undefined");if(u.throwAll&&p.errors.length)throw new a(p);return p},s.prototype.validateSchema=function(t,a,s,c){var f=new n(t,a,s,c);if("boolean"==typeof a)!0===a?a={}:!1===a&&(a={type:[]});else if(!a)throw new Error("schema is undefined");if(a.extends)if(Array.isArray(a.extends)){var l={schema:a,ctx:c};a.extends.forEach(this.schemaTraverser.bind(this,l)),a=l.schema,l.schema=null,l.ctx=null,l=null}else a=r.deepMerge(a,this.superResolve(a.extends,c));var m=u(a);if(m){var h=this.resolve(a,m,c),d=new o(h.subschema,s,c.path,h.switchSchema,c.schemas);return this.validateSchema(t,h.subschema,s,d)}var p=s&&s.skipAttributes||[];for(var v in a)if(!e.ignoreProperties[v]&&p.indexOf(v)<0){var y=null,g=this.attributes[v];if(g)y=g.call(this,t,a,s,c);else if(!1===s.allowUnknownAttributes)throw new i("Unsupported attribute: "+v,a);y&&f.importErrors(y)}if("function"==typeof s.rewrite){var b=s.rewrite.call(this,t,a,s,c);f.instance=b}return f},s.prototype.schemaTraverser=function(e,t){e.schema=r.deepMerge(e.schema,this.superResolve(t,e.ctx))},s.prototype.superResolve=function(e,r){var t=u(e);return t?this.resolve(e,t,r).subschema:e},s.prototype.resolve=function(e,t,n){if(t=n.resolve(t),n.schemas[t])return{subschema:n.schemas[t],switchSchema:t};let a=new URL(t,"thismessage::/").hash;var o=a&&a.length&&t.substr(0,t.length-a.length);if(!o||!n.schemas[o])throw new i("no such schema <"+t+">",e);var s=r.objectGetPath(n.schemas[o],a.substr(1));if(void 0===s)throw new i("no such schema "+a+" located in <"+o+">",e);return{subschema:s,switchSchema:t}},s.prototype.testType=function(e,r,t,n,a){if(void 0!==a){if(null===a)throw new i('Unexpected null in "type" keyword');if("function"==typeof this.types[a])return this.types[a].call(this,e);if(a&&"object"==typeof a){var o=this.validateSchema(e,a,t,n);return void 0===o||!(o&&o.errors.length)}return!0}};var c=s.prototype.types={};return c.string=function(e){return"string"==typeof e},c.number=function(e){return"number"==typeof e&&isFinite(e)},c.integer=function(e){return"number"==typeof e&&e%1==0},c.boolean=function(e){return"boolean"==typeof e},c.array=function(e){return Array.isArray(e)},c.null=function(e){return null===e},c.date=function(e){return e instanceof Date},c.any=function(e){return!0},c.object=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof Date)},ne=s}var ce=function(){if(ie)return Q;ie=1;var e=Q.Validator=ue();return Q.ValidatorResult=re().ValidatorResult,Q.ValidatorResultError=re().ValidatorResultError,Q.ValidationError=re().ValidationError,Q.SchemaError=re().SchemaError,Q.SchemaScanResult=se().SchemaScanResult,Q.scan=se().scan,Q.validate=function(r,t,n){return(new e).validate(r,t,n)},Q}(),fe=function(e){function r(t,n,a){var i=e.call(this,"Payload does not match the specified schema for channel [".concat(t,"]. Schema: ").concat(JSON.stringify(n),", Payload: ").concat(JSON.stringify(a)))||this;return i.channel=t,i.schema=n,i.payload=a,Error.captureStackTrace&&Error.captureStackTrace(i,r),i.name="PayloadMismatchError",i}return t(r,e),r}(Error),le=function(e){function r(t,n,a){var i=e.call(this,"Schema registration for [".concat(t,"] must match already registered schema."))||this;return i.channel=t,i.schema=n,i.newSchema=a,Error.captureStackTrace&&Error.captureStackTrace(i,r),i.name="SchemaMismatchError",i}return t(r,e),r}(Error),me=function(){function e(e){void 0===e&&(e={}),this._lastId=0,this._subscriptions=new Map,this._options=n({logLevel:"error"},e),this._validator=new ce.Validator}return e.prototype._getNextId=function(){return this._lastId++},e.prototype._log=function(e,r){void 0===r&&(r="info");var t={none:0,error:1,warn:2,info:3};t[this._options.logLevel]>=t[r]&&console[r]("[EventBus] ".concat(e))},e.prototype._asyncCallback=function(e,r){return a(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e(r)];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this._log("Error in callback execution: ".concat(t instanceof Error?t.message:String(t)),"error"),[3,3];case 3:return[2]}}))}))},e.prototype._getOrCreateChannel=function(e){var r=this._subscriptions.get(e);return r||(r={callbacks:{}},this._subscriptions.set(e,r)),r},e.prototype.register=function(e,r){this._log("Registering schema for channel [".concat(e,"]"));var t=this._getOrCreateChannel(e),n=!!t.schema;if(n&&!W(t.schema,r))throw new le(e,t.schema,r);return t.schema=r,n},e.prototype.unregister=function(e){var r=this._subscriptions.get(e);return!!(null==r?void 0:r.schema)&&(delete r.schema,this._log("Unregistered schema for channel [".concat(e,"]")),!0)},e.prototype.subscribe=function(e,r,t){return a(this,void 0,void 0,(function(){var n,a,o,s,u=this;return i(this,(function(i){switch(i.label){case 0:if(n=this._getNextId().toString(),a="boolean"==typeof r&&r,"function"!=typeof(o="function"==typeof r?r:t))throw new Error("Callback function must be supplied as either the second or third argument.");return s=this._getOrCreateChannel(e),a&&void 0!==s.replay?[4,this._asyncCallback(o,{channel:e,payload:s.replay})]:[3,2];case 1:i.sent(),i.label=2;case 2:return s.callbacks[n]=o,[2,{unsubscribe:function(){delete s.callbacks[n],u._log("Unsubscribed from channel [".concat(e,"]"))}}]}}))}))},e.prototype._publishToChannel=function(e,r,t){return a(this,void 0,void 0,(function(){var n,a,o=this;return i(this,(function(i){switch(i.label){case 0:return(n=this._subscriptions.get(e))?(a={channel:r,payload:t},[4,Promise.all(Object.values(n.callbacks).map((function(e){return o._asyncCallback(e,a)})))]):[2];case 1:return i.sent(),[2]}}))}))},e.prototype.publish=function(e,r){return a(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:if(t=this._getOrCreateChannel(e),void 0!==r&&t.schema&&!this._validator.validate(r,t.schema).valid)throw new fe(e,t.schema,r);return t.replay=r,[4,Promise.all([this._publishToChannel(e,e,r),this._publishToChannel("*",e,r)])];case 1:return n.sent(),[2]}}))}))},e.prototype.getLatest=function(e){var r;return null===(r=this._subscriptions.get(e))||void 0===r?void 0:r.replay},e.prototype.getSchema=function(e){var r;return null===(r=this._subscriptions.get(e))||void 0===r?void 0:r.schema},e.prototype.clearReplay=function(e){var r=this._subscriptions.get(e);return void 0!==(null==r?void 0:r.replay)&&(delete r.replay,this._log("Cleared replay event for channel [".concat(e,"]")),!0)},e}(),he=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")};he().eventBus=new me,e.EventBus=me,e.getGlobal=he}));
//# sourceMappingURL=index.umd.min.js.map