UNPKG

2.25 kBJavaScriptView Raw
1!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@lumino/algorithm"),require("@lumino/collections")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm","@lumino/collections"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_messaging={},e.lumino_algorithm,e.lumino_collections)}(this,(function(e,n,t){"use strict";class l{constructor(e){this.type=e}get isConflatable(){return!1}conflate(e){return!1}}e.MessageLoop=void 0,function(e){let l=null;const o=(s=Promise.resolve(),e=>{let n=!1;return s.then((()=>!n&&e())),()=>{n=!0}});var s;function r(e,t){let l=u.get(e);if(!l||0===l.length)return void g(e,t);let o=n.every(n.retro(l),(n=>!n||function(e,n,t){let l=!0;try{l="function"==typeof e?e(n,t):e.messageHook(n,t)}catch(e){f(e)}return l}(n,e,t)));o&&g(e,t)}e.sendMessage=r,e.postMessage=function(e,t){if(!t.isConflatable)return void d(e,t);n.some(i,(n=>n.handler===e&&(!!n.msg&&(n.msg.type===t.type&&(!!n.msg.isConflatable&&n.msg.conflate(t))))))||d(e,t)},e.installMessageHook=function(e,n){let t=u.get(e);t&&-1!==t.indexOf(n)||(t?t.push(n):u.set(e,[n]))},e.removeMessageHook=function(e,n){let t=u.get(e);if(!t)return;let l=t.indexOf(n);-1!==l&&(t[l]=null,h(t))},e.clearData=function(e){let t=u.get(e);t&&t.length>0&&(n.ArrayExt.fill(t,null),h(t));for(const n of i)n.handler===e&&(n.handler=null,n.msg=null)},e.flush=function(){c||null===l||(l(),l=null,c=!0,m(),c=!1)},e.getExceptionHandler=function(){return f},e.setExceptionHandler=function(e){let n=f;return f=e,n};const i=new t.LinkedList,u=new WeakMap,a=new Set;let f=e=>{console.error(e)},c=!1;function g(e,n){try{e.processMessage(n)}catch(e){f(e)}}function d(e,n){i.addLast({handler:e,msg:n}),null===l&&(l=o(m))}function m(){if(l=null,i.isEmpty)return;let e={handler:null,msg:null};for(i.addLast(e);;){let n=i.removeFirst();if(n===e)return;n.handler&&n.msg&&r(n.handler,n.msg)}}function h(e){0===a.size&&o(p),a.add(e)}function p(){a.forEach(y),a.clear()}function y(e){n.ArrayExt.removeAllWhere(e,M)}function M(e){return null===e}}(e.MessageLoop||(e.MessageLoop={})),e.ConflatableMessage=class extends l{get isConflatable(){return!0}conflate(e){return!0}},e.Message=l}));
2//# sourceMappingURL=index.min.js.map
\No newline at end of file