emitter-master
Advanced tools
Comparing version 2.0.0-dev.2024030401 to 2.0.0-dev.2024030402
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Emitter=void 0;var e=require("../package.json");const g=require("./utils"),m={strict:!0,debug:!1,timeout:0,check_passphrase:(e,r)=>e===r};const r={},a={},t={},s={};function v(){}function y(e){return t[e]??(t[e]=[])}function w(e){return r[e]??(r[e]=[])}function x(e){return s[e]??(s[e]=[])}function k(e){return a[e]??(a[e]=[])}function n(e,a,t){let s=[];if("string"==typeof e)s.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);s=e}if(t?.passphrase)for(let e=0,r=s.length;e<r;e++){var n=s[e],p=w(n),o=k(n),l=o.filter(e=>m.check_passphrase(e.passphrase,t.passphrase));if(0===l.length){var i={data_type:"sender",start:(new Date).getTime(),passphrase:t.passphrase,data:a};t?.timeout&&(i.timeout=t.timeout),p.push(i)}else for(let e=0;e<l.length;e++){var h=l[e];"string"===h.event_name_type?h.handle(a,v):h.handle({event_name:n,data:a},v),"once"===h.event_type&&(0,g.remove_from_array)(o,h)}}else for(let e=0,r=s.length;e<r;e++){var f=s[e],c=y(f),d=x(f);if(0===d.length){var u={data_type:"sender",start:(new Date).getTime(),data:a};t?.timeout&&(u.timeout=t.timeout),c.push(u)}else for(let e=0;e<d.length;e++){var _=d[e];"string"===_.event_name_type?_.handle(a,v):_.handle({event_name:f,data:a},v),"once"===_.event_type&&(d.splice(e,1),e--)}}}function p(e,a=null,t={}){let s=[],n;if("string"==typeof e)n="string",s.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n="array",s=e}if(t?.passphrase){if("function"==typeof a){for(let e=0;e<s.length;e++){const l=s[e],i=w(l);var r=i.filter(e=>m.check_passphrase(t.passphrase,e.passphrase)),p=k(l);0!==r.length&&t?.once||p.push({event_type:t?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),passphrase:t.passphrase,handle:a}),r.forEach(e=>{var r="array"===n?{event_name:l,data:e.data}:e.data;a(r),(0,g.remove_from_array)(i,e)})}return()=>E(e,a,t)}for(let e=0,r=s.length;e<r;e++){const h=s[e];const f=w(h).filter(e=>m.check_passphrase(t.passphrase,e.passphrase));if(0!=f.length)return new Promise(e=>{e("array"===n?{event_name:h,data:f.pop().data}:f.pop().data)})}return new Promise(e=>e(void 0===a?null:a))}if("function"==typeof a){for(let e=0;e<s.length;e++){const c=s[e],d=y(c);var o=x(c);0!==d.length&&t?.once||o.push({event_type:t?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),handle:a}),d.forEach(e=>{var r="array"===n?{event_name:c,data:e.data}:e.data;"sender"===e.data_type?(a(r),(0,g.remove_from_array)(d,e)):a(e.data,()=>(0,g.remove_from_array)(d,e))})}return()=>E(e,a,t)}for(let e=0,r=s.length;e<r;e++){const u=s[e],_=y(u);if(0!=_.length)return new Promise(e=>{var r=_[_.length-1],a="array"===n?{event_name:u,data:r.data}:r.data;"sender"===r.data_type&&(0,g.remove_from_array)(_,r),e(a)})}return new Promise(e=>e(void 0===a?null:a))}function E(e,a=null,r={clear_data:!1}){let t=[];if("string"==typeof e)t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);t=e}if(null===a)if(r.passphrase)for(let e=0;e<t.length;e++){var s=t[e];if(r.clear_data){var n=w(s);for(let e=0;e<n.length;e++)m.check_passphrase(r.passphrase,n[e].passphrase)&&(n.splice(e,1),e--)}var p=k(s);for(let e=0;e<p.length;e++)m.check_passphrase(r.passphrase,p[e].passphrase)&&(p.splice(e,1),e--)}else t.forEach(e=>{r.clear_data&&(w(e).length=0),k(e).length=0});else if(r.passphrase)for(let e=0;e<t.length;e++){var o=t[e];if(r.clear_data){var l=w(o);for(let e=0;e<l.length;e++)m.check_passphrase(r.passphrase,l[e].passphrase)&&(l.splice(e,1),e--)}var i=k(o);for(let e=0;e<i.length;e++)m.check_passphrase(r.passphrase,i[e].passphrase)&&a===i[e].handle&&(i.splice(e,1),e--)}else t.forEach(e=>{var r=x(e);for(let e=0;e<r.length;e++)r[e].handle===a&&(r.splice(e,1),e--)})}globalThis.__emitter_master={passphrase_data:r,passphrase_handle:a,general_data:t,general_handle:s};var o=p,l=n,i=E,e=(console.log(`%cemitter-master:%c ${e.version} %c=> %curl:%c https://www.npmjs.com/package/emitter-master`,"color: #fff;background: purple;padding: 2px 5px;border-radius:4px;font-size: 14px;","color: purple;font-size:14px;","color: #333;font-size:14px;","background: purple;font-size:14px; padding: 2px 5px; border-radius: 4px; color: #fff;","font-size:14px;"),{sender:n,receiver:p,forwarder:function(e,a,t){let s=[];if("string"==typeof e)s.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);s=e}for(let e=0,r=s.length;e<r;e++){var n=s[e],p=x(n);const i={data_type:"forwarder",start:(new Date).getTime(),data:a},h=(t?.timeout&&(i.timeout=t.timeout),y(n));function o(){var e=h.indexOf(i);-1!==e&&h.splice(e,1)}if(h.push(i),p.length)for(let e=0;e<p.length;e++){var l=p[e];"string"===l.event_name_type?l.handle(a,o):l.handle({event_name:n,data:a},o),"once"===l.event_type&&(p.splice(e,1),e--)}}},listener:o,trigger:l,clear:E,remove:i,set_config:function(e){}});exports.Emitter=e}(); | ||
!function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Emitter=void 0;const e=require("../package.json"),t=require("./utils"),r={strict:!0,debug:!1,timeout:0,check_passphrase:(e,t)=>e===t};const a={},s={},n={},o={};function p(){}function l(e){return n[e]??(n[e]=[])}function i(e){return a[e]??(a[e]=[])}function c(e){return o[e]??(o[e]=[])}function h(e){return s[e]??(s[e]=[])}function f(e,a,s){let n=[];if("string"==typeof e)n.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n=e}if(s?.passphrase)for(let e=0,o=n.length;e<o;e++){const o=n[e],l=i(o),c=h(o),f=c.filter((e=>r.check_passphrase(e.passphrase,s.passphrase)));if(0===f.length){const e={data_type:"sender",start:(new Date).getTime(),passphrase:s.passphrase,data:a};s?.timeout&&(e.timeout=s.timeout),l.push(e)}else for(let e=0;e<f.length;e++){const r=f[e];"string"===r.event_name_type?r.handle(a,p):r.handle({event_name:o,data:a},p),"once"===r.event_type&&(0,t.remove_from_array)(c,r)}}else for(let e=0,t=n.length;e<t;e++){const t=n[e],r=l(t),o=c(t);if(0===o.length){const e={data_type:"sender",start:(new Date).getTime(),data:a};s?.timeout&&(e.timeout=s.timeout),r.push(e)}else for(let e=0;e<o.length;e++){const r=o[e];"string"===r.event_name_type?r.handle(a,p):r.handle({event_name:t,data:a},p),"once"===r.event_type&&(o.splice(e,1),e--)}}}function d(e,a=null,s={}){let n,o=[];if("string"==typeof e)n="string",o.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n="array",o=e}if(s?.passphrase){if("function"==typeof a){for(let e=0;e<o.length;e++){const p=o[e],l=i(p),c=l.filter((e=>r.check_passphrase(s.passphrase,e.passphrase))),f=h(p);0!==c.length&&s?.once||f.push({event_type:s?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),passphrase:s.passphrase,handle:a}),c.forEach((e=>{const r="array"===n?{event_name:p,data:e.data}:e.data;a(r),(0,t.remove_from_array)(l,e)}))}return()=>u(e,a,s)}for(let e=0,t=o.length;e<t;e++){const t=o[e],a=i(t).filter((e=>r.check_passphrase(s.passphrase,e.passphrase)));if(0!=a.length)return new Promise((e=>{e("array"===n?{event_name:t,data:a.pop().data}:a.pop().data)}))}return new Promise((e=>e(void 0===a?null:a)))}if("function"==typeof a){for(let e=0;e<o.length;e++){const r=o[e],p=l(r),i=c(r);0!==p.length&&s?.once||i.push({event_type:s?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),handle:a}),p.forEach((e=>{const s="array"===n?{event_name:r,data:e.data}:e.data;"sender"===e.data_type?(a(s),(0,t.remove_from_array)(p,e)):a(e.data,(()=>(0,t.remove_from_array)(p,e)))}))}return()=>u(e,a,s)}for(let e=0,r=o.length;e<r;e++){const r=o[e],a=l(r);if(0!=a.length)return new Promise((e=>{const s=a[a.length-1],o="array"===n?{event_name:r,data:s.data}:s.data;"sender"===s.data_type&&(0,t.remove_from_array)(a,s),e(o)}))}return new Promise((e=>e(void 0===a?null:a)))}function u(e,t=null,a={clear_data:!1}){let s=[];if("string"==typeof e)s.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);s=e}if(null===t)if(a.passphrase)for(let e=0;e<s.length;e++){const t=s[e];if(a.clear_data){const e=i(t);for(let t=0;t<e.length;t++)r.check_passphrase(a.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const n=h(t);for(let e=0;e<n.length;e++)r.check_passphrase(a.passphrase,n[e].passphrase)&&(n.splice(e,1),e--)}else s.forEach((e=>{a.clear_data&&(i(e).length=0),h(e).length=0}));else if(a.passphrase)for(let e=0;e<s.length;e++){const n=s[e];if(a.clear_data){const e=i(n);for(let t=0;t<e.length;t++)r.check_passphrase(a.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const o=h(n);for(let e=0;e<o.length;e++)r.check_passphrase(a.passphrase,o[e].passphrase)&&t===o[e].handle&&(o.splice(e,1),e--)}else s.forEach((e=>{const r=c(e);for(let e=0;e<r.length;e++)r[e].handle===t&&(r.splice(e,1),e--)}))}globalThis.__emitter_master={passphrase_data:a,passphrase_handle:s,general_data:n,general_handle:o};const _=d,g=f,m=u;console.log(`%cemitter-master:%c ${e.version} %c=> %curl:%c https://www.npmjs.com/package/emitter-master`,"color: #fff;background: purple;padding: 2px 5px;border-radius:4px;font-size: 14px;","color: purple;font-size:14px;","color: #333;font-size:14px;","background: purple;font-size:14px; padding: 2px 5px; border-radius: 4px; color: #fff;","font-size:14px;");const y={sender:f,receiver:d,forwarder:function(e,t,r){let a=[];if("string"==typeof e)a.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);a=e}for(let s=0,n=a.length;s<n;s++){const o=a[s],p=c(o),i={data_type:"forwarder",start:(new Date).getTime(),data:t};r?.timeout&&(i.timeout=r.timeout);const h=l(o);function f(){const e=h.indexOf(i);-1!==e&&h.splice(e,1)}if(h.push(i),p.length)for(let d=0;d<p.length;d++){const u=p[d];"string"===u.event_name_type?u.handle(t,f):u.handle({event_name:o,data:t},f),"once"===u.event_type&&(p.splice(d,1),d--)}}},listener:_,trigger:g,clear:u,remove:m,set_config:function(e){}};exports.Emitter=y}(); |
@@ -62,2 +62,2 @@ interface EmitterMasterEventMap { | ||
export { Emitter, EmitterMasterEventMap }; | ||
export { Emitter, type EmitterMasterEventMap }; |
{ | ||
"name": "emitter-master", | ||
"version": "2.0.0-dev.2024030401", | ||
"version": "2.0.0-dev.2024030402", | ||
"description": "Support for offline event emitters, event, listener", | ||
@@ -56,25 +56,24 @@ "main": "./cjs/index.cjs", | ||
"devDependencies": { | ||
"@babel/core": "^7.17.10", | ||
"@babel/preset-env": "^7.17.10", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^22.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.2.1", | ||
"@rollup/plugin-typescript": "^11.0.0", | ||
"@babel/core": "^7.24.0", | ||
"@babel/preset-env": "^7.24.0", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-json": "^6.1.0", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"cross-env": "^7.0.3", | ||
"glob": "^8.0.1", | ||
"glob": "^8.1.0", | ||
"npm-run-all": "^4.1.5", | ||
"rollup": "^2.70.2", | ||
"rollup-plugin-dts": "^5.3.0", | ||
"rollup": "^4.12.0", | ||
"rollup-plugin-dts": "^6.1.0", | ||
"rollup-plugin-livereload": "^2.0.5", | ||
"rollup-plugin-serve": "^1.1.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"tslib": "^2.5.0", | ||
"typescript": "^5.1.6", | ||
"rollup-plugin-serve": "^1.1.1", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.3.1" | ||
}, | ||
"dependencies": { | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"typescript-treasure": "^0.0.10" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17
23916
2
118
+ Added@rollup/plugin-typescript@11.1.6(transitive)
+ Added@rollup/pluginutils@5.1.4(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Addedestree-walker@2.0.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-core-module@2.16.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpicomatch@4.0.2(transitive)
+ Addedresolve@1.22.10(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtypescript@5.7.3(transitive)