@oinone/kunlun-event 6.4.3 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/oinone-kunlun-event.esm.js +1 -15
- package/dist/types/index.d.ts +1 -1
- package/dist/types/src/bus/abstract/AbstractEventConsumer.d.ts +17 -17
- package/dist/types/src/bus/abstract/AbstractEventEngine.d.ts +21 -21
- package/dist/types/src/bus/abstract/AbstractEventProducer.d.ts +15 -15
- package/dist/types/src/bus/abstract/index.d.ts +2 -2
- package/dist/types/src/bus/bus/basic.d.ts +12 -12
- package/dist/types/src/bus/bus/html-event.d.ts +6 -6
- package/dist/types/src/bus/bus/html-keyboard-event.d.ts +6 -6
- package/dist/types/src/bus/bus/index.d.ts +18 -18
- package/dist/types/src/bus/hook/consumer.d.ts +1 -1
- package/dist/types/src/bus/hook/index.d.ts +2 -2
- package/dist/types/src/bus/hook/producer.d.ts +1 -1
- package/dist/types/src/bus/index.d.ts +5 -5
- package/dist/types/src/bus/operator/consumer.d.ts +11 -11
- package/dist/types/src/bus/operator/index.d.ts +2 -2
- package/dist/types/src/bus/operator/producer.d.ts +10 -10
- package/dist/types/src/bus/spi/consumer.d.ts +8 -8
- package/dist/types/src/bus/spi/index.d.ts +2 -2
- package/dist/types/src/bus/spi/producer.d.ts +8 -8
- package/dist/types/src/bus/typing/basic.d.ts +64 -64
- package/dist/types/src/bus/typing/category.d.ts +5 -5
- package/dist/types/src/bus/typing/index.d.ts +3 -3
- package/dist/types/src/bus/typing/keyboard.d.ts +16 -16
- package/dist/types/src/effects/effectbox.d.ts +3 -3
- package/dist/types/src/effects/fieldEffects.d.ts +61 -61
- package/dist/types/src/effects/index.d.ts +2 -2
- package/dist/types/src/effects/viewEffects.d.ts +69 -69
- package/dist/types/src/helper.d.ts +14 -14
- package/dist/types/src/html-event/basic/AbstractHTMLEventProducer.d.ts +7 -7
- package/dist/types/src/html-event/basic/HTMLEventConsumer.d.ts +4 -4
- package/dist/types/src/html-event/basic/HTMLEventProducer.d.ts +5 -5
- package/dist/types/src/html-event/basic/index.d.ts +3 -3
- package/dist/types/src/html-event/index.d.ts +2 -2
- package/dist/types/src/html-event/keyboard/HTMLKeyboardEventConsumer.d.ts +14 -14
- package/dist/types/src/html-event/keyboard/HTMLKeyboardEventProducer.d.ts +16 -16
- package/dist/types/src/html-event/keyboard/index.d.ts +2 -2
- package/dist/types/src/index.d.ts +6 -6
- package/dist/types/src/lifecycle/heart.d.ts +75 -75
- package/dist/types/src/lifecycle/index.d.ts +2 -2
- package/dist/types/src/lifecycle/lifecycle.d.ts +7 -7
- package/dist/types/src/typing/index.d.ts +1 -1
- package/dist/types/src/typing/lifecycle.d.ts +92 -92
- package/package.json +20 -9
- package/src/bus/abstract/AbstractEventConsumer.ts +1 -9
- package/src/bus/abstract/AbstractEventEngine.ts +1 -1
- package/src/bus/abstract/AbstractEventProducer.ts +1 -8
- package/src/bus/bus/basic.ts +1 -10
- package/src/bus/bus/html-event.ts +1 -9
- package/src/bus/bus/html-keyboard-event.ts +1 -9
- package/src/bus/operator/consumer.ts +1 -8
- package/src/bus/operator/producer.ts +1 -1
- package/src/bus/spi/consumer.ts +2 -2
- package/src/bus/spi/producer.ts +2 -2
- package/src/bus/typing/basic.ts +1 -1
- package/src/bus/typing/keyboard.ts +1 -1
- package/src/html-event/basic/AbstractHTMLEventProducer.ts +1 -1
- package/src/html-event/basic/HTMLEventConsumer.ts +1 -10
- package/src/html-event/basic/HTMLEventProducer.ts +1 -1
- package/src/html-event/keyboard/HTMLKeyboardEventConsumer.ts +1 -13
- package/src/html-event/keyboard/HTMLKeyboardEventProducer.ts +1 -10
- package/rollup.config.js +0 -4
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import{useCurrentInstance as e,useEnv as t}from"@oinone/kunlun-environment";import{instantiate as i,KeyboardEventHelper as r}from"@oinone/kunlun-shared";import{SPIOperator as s}from"@oinone/kunlun-spi";
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function n(e,t,i,r){return new(i||(i=Promise))(function(s,n){function o(e){try{a(r.next(e))}catch(e){n(e)}}function c(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,c)}a((r=r.apply(e,t||[])).next())})}const o=Symbol("__event_bus_consumer");function c(e,t){return s.register(o,e,t)}function a(e){return s.selector(o,e)}s.createStorage({key:o,matchKeys:["category","type"]});const u=Symbol("__event_bus_producer");function d(e,t){return s.register(u,e,t)}function l(e){return s.selector(u,e)}s.createStorage({key:u,matchKeys:["category","type"]});class _{static getConsumers(e){return _.consumers.get(_.generatorKeyByMessage(e))}static construct(t,r,s){var n;const o=a(t);if(!o)throw new Error(`Unsupported consumer. category: ${t.category}, type: ${t.type}`);const c=i(o,t.type,r,s);return c.el=null===(n=e().currentInstance)||void 0===n?void 0:n.vNode.el,c}static init(e){const t=_.generatorKeyByEngine(e);let i=_.consumers.get(t);i||(i=[],_.consumers.set(t,i)),i.push(e),e.start()}static dispose(e){const t=_.generatorKeyByEngine(e),i=e.key,r=_.consumers.get(t);if(!r)return!1;const s=r.findIndex(e=>e.key===i);if(-1===s)return!1;const n=r.splice(s,1);for(const e of n)e.dispose();return!0}static generatorKey(e,t){return`${e}#${t}`}static generatorKeyByEngine(e){return`${e.category}#${e.type}`}static generatorKeyByMessage(e){return`${e.category}#${e.type}`}}_.consumers=new Map;class E{static getProducer(e,t){return E.producers.get(E.generatorKey(e,t))}static construct(e,t){const r=l(e);if(!r)throw new Error(`Unsupported producer. category: ${e.category}, type: ${e.type}`);return i(r,e.type,t)}static init(e){const t=E.generatorKeyByEngine(e);E.dispose(t),E.producers.set(t,e),e.start()}static dispose(e){const t=E.producers.get(e);return t&&(E.producers.delete(e),t.isDisposed||t.dispose()),t}static generatorKey(e,t){return`${e}#${t}`}static generatorKeyByEngine(e){return`${e.category}#${e.type}`}}E.producers=new Map;class p{constructor(e,t){this._key=this.generatorKey(),this._category=e,this._type=t,this._isActivated=!1,this._isDisposed=!1}get key(){return this._key}get category(){return this._category}get type(){return this._type}get isActivated(){return this._isActivated}get isDisposed(){return this._isDisposed}start(){return!this.isActivated&&(this._isActivated=!0,this.$$start(),!0)}$$start(){}stop(){return!!this.isActivated&&(this._isActivated=!1,this.$$stop(),!0)}$$stop(){}dispose(){return!this.isDisposed&&(this.isActivated&&this.stop(),this._isDisposed=!0,this.$$dispose(),!0)}$$dispose(){}}let y=0;class h extends p{constructor(e,t,i){super(e,t),this._rawConvert=(null==i?void 0:i.convert)||this.$$convert,this._rawPublish=(null==i?void 0:i.publish)||this.$$publish}get rawConvert(){return this._rawConvert}get rawPublish(){return this._rawPublish}convert(e){return this.rawConvert(this,e)}publish(e){this.rawPublish(this,e)}$$publish(e,t){const i=this.convert(t);if(!i)return;const r=_.getConsumers(i);r&&r.length&&r.filter(e=>e.filter(t,i)).map(e=>n(this,void 0,void 0,function*(){return e.consumer(i)}))}generatorKey(){return"event_producer_"+y++}$$dispose(){E.dispose(E.generatorKeyByEngine(this))}}let f=0;class g extends p{constructor(e,t,i,r){super(e,t),this._config=(null==r?void 0:r.config)||{},this._rawFilter=(null==r?void 0:r.filter)||this.$$filter.bind(this),this._rawConsumer=i}get config(){return this._config}get rawFilter(){return this._rawFilter}get rawConsumer(){return this._rawConsumer}filter(e,t){return!!this.isActivated&&this.rawFilter(e,t)}$$filter(e,t){return!0}consumer(e){return this.rawConsumer(this,e)}generatorKey(){return"event_consumer_"+f++}$$dispose(){_.dispose(this)}}class I{static init(e,t){const{category:i,type:r}=e;let s=E.getProducer(i,r);return s||(s=E.construct({category:i,type:r},t),E.init(s)),s}static startProducer(e){const{category:t,type:i}=e,r=E.getProducer(t,i);return!!r&&r.start()}static stopProducer(e){const{category:t,type:i}=e,r=E.getProducer(t,i);return!!r&&r.stop()}static publish(e,t){const{category:i,type:r}=e,s=E.getProducer(i,r);if(!s)throw new Error("Invalid producer. please initialize the producer before publish.");s.publish(t)}static subscribe(e,t,i){const r=_.construct(e,t,i);return _.init(r),I.consumerMap.set(t,r),r}static unsubscribe(e){const t=I.consumerMap.get(e);return t&&(I.consumerMap.delete(e),_.dispose(t)),t}static startConsumer(e){const t=I.consumerMap.get(e);return!!t&&t.start()}static stopConsumer(e){const t=I.consumerMap.get(e);return!!t&&t.stop()}}var V,b;I.consumerMap=new Map,function(e){e.global="global",e.view="view",e.current="current"}(V||(V={})),function(e){e.html="html",e.keyboard="keyboard"}(b||(b={}));const w=["keypress","keyup","keydown"];class F{static init(e){return I.init({category:b.html,type:e})}static dispose(e){return E.dispose(`${b.html}#${e}`)}static subscribe(e,t,i,r=!0){return r&&F.init(e),I.subscribe({category:b.html,type:e},t,i)}}const O="global";class N{static init(){return I.init({category:b.keyboard,type:O})}static dispose(){return E.dispose(`${b.keyboard}#${O}`)}static subscribe(e,t,i,r=!0){return r&&N.init(),I.subscribe({category:b.keyboard,type:e},t,i)}}class D{}D.init=I.init,D.startProducer=I.startProducer,D.stopProducer=I.stopProducer,D.publish=I.publish,D.subscribe=I.subscribe,D.unsubscribe=I.unsubscribe,D.start=I.startConsumer,D.stop=I.stopConsumer,D.disposeProducer=E.dispose,D.disposeConsumer=_.dispose,D.subscribeHTMLEvent=F.subscribe,D.subscribeKeyboardEvent=N.subscribe;class m extends h{constructor(e,t,i){super(e,t,i)}$$convert(e,t){return{category:this.category,type:this.type,origin:t}}$$start(){document.addEventListener(this.type,this.publish.bind(this))}$$stop(){document.removeEventListener(this.type,this.publish.bind(this))}}class T extends g{constructor(e,t,i){super(b.html,e,t,i)}}c({category:b.html},T);class A extends m{constructor(e,t){super(b.html,e,t)}}d({category:b.html},A);class v extends g{constructor(e,t,i,r){super(e,t,i,r),this.initConfig()}initConfig(){const{config:e}=this;null==e.scope&&(e.scope=V.view),void 0===e.ctrl&&(e.ctrl=!1),void 0===e.shift&&(e.shift=!1),void 0===e.alt&&(e.alt=!1)}$$filter(e,i){const{scope:r,ctrl:s,alt:n,shift:o}=this.config;let c=!1;switch(r){case V.global:case V.current:c=!0;break;case V.view:{const{el:e}=this;if(!e)break;const{x:i,y:r}=e.getBoundingClientRect(),s=t().clickVisibleArea[0];if(s){const{el:t,x:n,y:o,ex:a,ey:u}=s;if(t)t.contains(e)&&(c=!0);else if(n<=i&&i<=a&&o<=r&&r<=u){c=!0;break}}break}}return!!c&&((null==s||s===i.ctrl)&&((null==o||o===i.shift)&&(null==n||n===i.alt)))}}class C extends v{constructor(e,t,i){super(b.html,e,t,i)}}class S extends v{constructor(e,t,i){super(b.keyboard,e,t,i)}}c({category:b.html,type:w},C),c({category:b.keyboard},S);class U extends m{$$convert(e,t){const i=r.newInstance(t);if(!i.isStateKey())return{category:this.category,type:this.type,origin:t,code:t.code,key:t.key,ctrl:i.isPressCtrl(),alt:i.isPressAlt(),shift:i.isPressShift()}}}class L extends U{constructor(e,t){super(b.html,e,t)}}class $ extends U{constructor(e,t){super(b.keyboard,e,t)}$$convert(e,t){const i=super.$$convert(e,t);return i&&(i.type=t.key),i}onKeydown(e){this.publish(e)}$$start(){document.addEventListener("keydown",this.onKeydown.bind(this))}$$stop(){document.removeEventListener("keydown",this.onKeydown.bind(this))}}var B,M,W,k;d({category:b.html,type:w},L),d({category:b.keyboard},$),function(e){e.FIELD="Field",e.VIEW="View",e.ACTION="Action"}(B||(B={})),function(e){e.ON_VIEW_BEFORE_CREATED="onViewBeforeCreated",e.ON_VIEW_CREATED="onViewCreated",e.ON_VIEW_BEFORE_MOUNT="onViewBeforeMount",e.ON_VIEW_MOUNTED="onViewMounted",e.ON_VIEW_BEFORE_UPDATE="onViewBeforeUpdate",e.ON_VIEW_UPDATED="onViewUpdated",e.ON_VIEW_ACTIVATED="onViewActivated",e.ON_VIEW_BEFORE_UNMOUNT="onViewBeforeUnmount",e.ON_VIEW_UNMOUNTED="onViewUnmounted",e.ON_VIEW_SUBMIT="onViewSubmit",e.ON_VIEW_SUBMIT_START="onViewSubmitStart",e.ON_VIEW_SUBMIT_END="onViewSubmitEnd",e.ON_VIEW_SUBMIT_SUCCESS="onViewSubmitSuccess",e.ON_VIEW_SUBMIT_FAILED="onViewSubmitFailed",e.ON_VIEW_VALIDATE_START="onViewValidateStart",e.ON_VIEW_VALIDATE_SUCCESS="onViewValidateSuccess",e.ON_VIEW_VALIDATE_FAILED="onViewValidateFailed",e.ON_VIEW_VALIDATE_END="onViewValidateEnd",e.ON_FIELD_BEFORE_CREATED="onFieldBeforeCreated",e.ON_FIELD_CREATED="onFieldCreated",e.ON_FIELD_BEFORE_MOUNT="onFieldBeforeMount",e.ON_FIELD_MOUNTED="onFieldMounted",e.ON_FIELD_BEFORE_UPDATE="onFieldBeforeUpdate",e.ON_FIELD_UPDATED="onFieldUpdated",e.ON_FIELD_ACTIVATED="onFieldActivated",e.ON_FIELD_BEFORE_UNMOUNT="onFieldBeforeUnmount",e.ON_FIELD_UNMOUNTED="onFieldUnmounted",e.ON_FIELD_FOCUS="onFieldFocus",e.ON_FIELD_CHANGE="onFieldChange",e.ON_FIELD_BLUR="onFieldBlur",e.ON_FIELD_VALIDATE_START="onFieldValidateStart",e.ON_FIELD_VALIDATE_SUCCESS="onFieldValidateSuccess",e.ON_FIELD_VALIDATE_FAILED="onFieldValidateFailed",e.ON_FIELD_VALIDATE_END="onFieldValidateEnd"}(M||(M={})),function(e){e.viewBeforeCreated="onViewBeforeCreated",e.viewCreated="onViewCreated",e.viewBeforeMount="onViewBeforeMount",e.viewMounted="onViewMounted",e.viewBeforeUpdate="onViewBeforeUpdate",e.viewUpdated="onViewUpdated",e.viewActivated="onViewActivated",e.viewBeforeUnmount="onViewBeforeUnmount",e.viewUnmounted="onViewUnmounted",e.viewSubmit="onViewSubmit",e.viewSubmitStart="onViewSubmitStart",e.viewSubmitEnd="onViewSubmitEnd",e.viewSubmitSuccess="onViewSubmitSuccess",e.viewSubmitFailed="onViewSubmitFailed",e.viewValidateStart="onViewValidateStart",e.viewValidateSuccess="onViewValidateSuccess",e.viewValidateFailed="onViewValidateFailed",e.viewValidateEnd="onViewValidateEnd"}(W||(W={})),function(e){e.beforeCreated="onFieldBeforeCreated",e.created="onFieldCreated",e.beforeMount="onFieldBeforeMount",e.mount="onFieldMounted",e.beforeUpdate="onFieldBeforeUpdate",e.updated="onViewUpdated",e.beforeUnmount="onFieldBeforeUnmount",e.unmounted="onFieldUnmounted",e.focus="onFieldFocus",e.change="onFieldChange",e.blur="onFieldBlur",e.validateStart="onFieldValidateStart",e.validateSuccess="onFieldValidateSuccess",e.validateFailed="onFieldValidateFailed",e.validateEnd="onFieldValidateEnd"}(k||(k={}));const R=e=>t=>P(t)===`[object ${e}]`,P=e=>Object.prototype.toString.call(e),x=e=>"function"==typeof e,K=Array.isArray,j=R("Object"),H=R("String"),z=R("Boolean"),G=R("Number"),q=e=>e&&e instanceof Map,J=e=>e&&e instanceof Set,Q=e=>e&&e instanceof WeakMap,X=e=>e&&e instanceof WeakSet,Y=e=>G(e)||/^\d+$/.test(e),Z=e=>"object"==typeof e,ee=R("RegExp");class te{constructor(e){if(!x(e))throw new Error("life cycle callback must be function");this.listener=this.buildListener(e)}buildListener(e){return t=>{x(e)&&e(t)}}notify(e){this.listener.call(e,e)}}class ie{static initialize(e){this.lifeCycles=e}static getLifeCycleIndex(e){return this.lifeCycles.findIndex(t=>t.type===e)}static getLifeCycle(){return this.lifeCycles}static getLifeCycleByType(e){const t=this.getLifeCycleIndex(e);return t>=0?this.lifeCycles[t]:null}static setType(e){this.heartType=e}static setLifeCycle(e,t,i){if(!(H(e)&&H(t)&&i instanceof te))return!1;if(!this.heartType)throw new Error('set fail, use "LifeCycleHeart.setType(type)" first, then call "setLifeCycle"');const r=this.getLifeCycleIndex(e);r>=0?t&&this.lifeCycles[r].pattern.push({identifier:t,lifes:[i]}):this.lifeCycles.push({type:e,registryType:this.heartType,pattern:[{identifier:t,lifes:[i]}]}),this.heartType=null}static publish(e,t,i){if(!e||!t||!i)return!1;const r=this.getLifeCycleIndex(e);if(r>=0&&t){const e=this.lifeCycles[r].pattern.find(e=>e.identifier===t);e&&e.lifes.forEach(e=>{e.notify(i)})}}static disposeLifeCycle(e){}static dispose(e){this.lifeCycles.forEach(t=>{const i=t.pattern.findIndex(t=>t.identifier===e);i>=0&&t.pattern.splice(i,1)})}}function re(e,t){return(i,r)=>{if(!H(i))throw new Error("arg[0] must be string, but now is "+typeof i);if(r){if(!x(r))throw new Error("arg[1] must be function");ie.setType(t),ie.setLifeCycle(e,i,new te(r))}}}function se(e){return re(e,B.FIELD)}ie.lifeCycles=[],ie.heartType=null;const ne=se(M.ON_FIELD_BEFORE_CREATED),oe=se(M.ON_FIELD_CREATED),ce=se(M.ON_FIELD_BEFORE_MOUNT),ae=se(M.ON_FIELD_MOUNTED),ue=se(M.ON_FIELD_BEFORE_UPDATE),de=se(M.ON_FIELD_UPDATED),le=se(M.ON_FIELD_BEFORE_UNMOUNT),_e=se(M.ON_FIELD_UNMOUNTED),Ee=se(M.ON_FIELD_VALIDATE_START),pe=se(M.ON_FIELD_VALIDATE_SUCCESS),ye=se(M.ON_FIELD_VALIDATE_FAILED),he=se(M.ON_FIELD_VALIDATE_END),fe=se(M.ON_FIELD_FOCUS),ge=se(M.ON_FIELD_CHANGE),Ie=se(M.ON_FIELD_BLUR);function Ve(e){return re(e,B.VIEW)}const be=Ve(M.ON_VIEW_BEFORE_CREATED),we=Ve(M.ON_VIEW_CREATED),Fe=Ve(M.ON_VIEW_BEFORE_MOUNT),Oe=Ve(M.ON_VIEW_MOUNTED),Ne=Ve(M.ON_VIEW_BEFORE_UPDATE),De=Ve(M.ON_VIEW_UPDATED),me=Ve(M.ON_VIEW_BEFORE_UNMOUNT),Te=Ve(M.ON_VIEW_UNMOUNTED),Ae=Ve(M.ON_VIEW_SUBMIT),ve=Ve(M.ON_VIEW_SUBMIT_START),Ce=Ve(M.ON_VIEW_SUBMIT_SUCCESS),Se=Ve(M.ON_VIEW_SUBMIT_FAILED),Ue=Ve(M.ON_VIEW_SUBMIT_END),Le=Ve(M.ON_VIEW_VALIDATE_START),$e=Ve(M.ON_VIEW_VALIDATE_SUCCESS),Be=Ve(M.ON_VIEW_VALIDATE_FAILED),Me=Ve(M.ON_VIEW_VALIDATE_END);export{g as AbstractEventConsumer,h as AbstractEventProducer,m as AbstractHTMLEventProducer,D as EventBus,b as EventCategory,V as EventConsumerScope,k as FieldEventNames,T as HTMLEventConsumer,A as HTMLEventProducer,C as HTMLKeyboardEventConsumer,L as HTMLKeyboardEventProducer,S as KeyboardEventConsumer,$ as KeyboardEventProducer,w as KeyboardTypes,te as LifeCycle,ie as LifeCycleHeart,M as LifeCycleTypes,B as RegistryType,W as ViewEventNames,K as isArr,z as isBool,x as isFn,q as isMap,G as isNum,Y as isNumberLike,Z as isObj,j as isPlainObj,ee as isRegExp,J as isSet,H as isStr,Q as isWeakMap,X as isWeakSet,ne as onFieldBeforeCreate,ce as onFieldBeforeMount,le as onFieldBeforeUnmount,ue as onFieldBeforeUpdate,Ie as onFieldBlur,oe as onFieldCreated,fe as onFieldFocus,ae as onFieldMounted,_e as onFieldUnmounted,de as onFieldUpdated,he as onFieldValidateEnd,ye as onFieldValidateFailed,Ee as onFieldValidateStart,pe as onFieldValidateSuccess,ge as onFieldValueChange,be as onViewBeforeCreated,Fe as onViewBeforeMount,me as onViewBeforeUnmount,Ne as onViewBeforeUpdate,we as onViewCreated,Oe as onViewMounted,Ae as onViewSubmit,Ue as onViewSubmitEnd,Se as onViewSubmitFailed,ve as onViewSubmitStart,Ce as onViewSubmitSuccess,Te as onViewUnmounted,De as onViewUpdated,Me as onViewValidateEnd,Be as onViewValidateFailed,Le as onViewValidateStart,$e as onViewValidateSuccess,c as registerEventConsumer,d as registerEventProducer,a as selectorEventConsumer,l as selectorEventProducer};
|
|
1
|
+
import{useCurrentInstance as e,useEnv as t}from"@oinone/kunlun-environment";import{instantiate as r,KeyboardEventHelper as s}from"@oinone/kunlun-shared";import{SPIOperator as n}from"@oinone/kunlun-spi";function o(e,t,r,s){return new(r||(r=Promise))(function(n,o){function i(e){try{a(s.next(e))}catch(e){o(e)}}function c(e){try{a(s.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,c)}a((s=s.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i=Symbol("__event_bus_consumer");function c(e,t){return n.register(i,e,t)}function a(e){return n.selector(i,e)}n.createStorage({key:i,matchKeys:["category","type"]});const u=Symbol("__event_bus_producer");function d(e,t){return n.register(u,e,t)}function E(e){return n.selector(u,e)}n.createStorage({key:u,matchKeys:["category","type"]});class ConsumerOperator{static getConsumers(e){return ConsumerOperator.consumers.get(ConsumerOperator.generatorKeyByMessage(e))}static construct(t,s,n){var o;const i=a(t);if(!i)throw new Error(`Unsupported consumer. category: ${t.category}, type: ${t.type}`);const c=r(i,t.type,s,n);return c.el=null===(o=e().currentInstance)||void 0===o?void 0:o.vNode.el,c}static init(e){const t=ConsumerOperator.generatorKeyByEngine(e);let r=ConsumerOperator.consumers.get(t);r||(r=[],ConsumerOperator.consumers.set(t,r)),r.push(e),e.start()}static dispose(e){const t=ConsumerOperator.generatorKeyByEngine(e),r=e.key,s=ConsumerOperator.consumers.get(t);if(!s)return!1;const n=s.findIndex(e=>e.key===r);if(-1===n)return!1;const o=s.splice(n,1);for(const e of o)e.dispose();return!0}static generatorKey(e,t){return`${e}#${t}`}static generatorKeyByEngine(e){return`${e.category}#${e.type}`}static generatorKeyByMessage(e){return`${e.category}#${e.type}`}}ConsumerOperator.consumers=new Map;class ProducerOperator{static getProducer(e,t){return ProducerOperator.producers.get(ProducerOperator.generatorKey(e,t))}static construct(e,t){const s=E(e);if(!s)throw new Error(`Unsupported producer. category: ${e.category}, type: ${e.type}`);return r(s,e.type,t)}static init(e){const t=ProducerOperator.generatorKeyByEngine(e);ProducerOperator.dispose(t),ProducerOperator.producers.set(t,e),e.start()}static dispose(e){const t=ProducerOperator.producers.get(e);return t&&(ProducerOperator.producers.delete(e),t.isDisposed||t.dispose()),t}static generatorKey(e,t){return`${e}#${t}`}static generatorKeyByEngine(e){return`${e.category}#${e.type}`}}ProducerOperator.producers=new Map;class AbstractEventEngine{constructor(e,t){this._key=this.generatorKey(),this._category=e,this._type=t,this._isActivated=!1,this._isDisposed=!1}get key(){return this._key}get category(){return this._category}get type(){return this._type}get isActivated(){return this._isActivated}get isDisposed(){return this._isDisposed}start(){return!this.isActivated&&(this._isActivated=!0,this.$$start(),!0)}$$start(){}stop(){return!!this.isActivated&&(this._isActivated=!1,this.$$stop(),!0)}$$stop(){}dispose(){return!this.isDisposed&&(this.isActivated&&this.stop(),this._isDisposed=!0,this.$$dispose(),!0)}$$dispose(){}}let l=0;class AbstractEventProducer extends AbstractEventEngine{constructor(e,t,r){super(e,t),this._rawConvert=(null==r?void 0:r.convert)||this.$$convert,this._rawPublish=(null==r?void 0:r.publish)||this.$$publish}get rawConvert(){return this._rawConvert}get rawPublish(){return this._rawPublish}convert(e){return this.rawConvert(this,e)}publish(e){this.rawPublish(this,e)}$$publish(e,t){const r=this.convert(t);if(!r)return;const s=ConsumerOperator.getConsumers(r);s&&s.length&&s.filter(e=>e.filter(t,r)).map(e=>o(this,void 0,void 0,function*(){return e.consumer(r)}))}generatorKey(){return"event_producer_"+l++}$$dispose(){ProducerOperator.dispose(ProducerOperator.generatorKeyByEngine(this))}}let p=0;class AbstractEventConsumer extends AbstractEventEngine{constructor(e,t,r,s){super(e,t),this._config=(null==s?void 0:s.config)||{},this._rawFilter=(null==s?void 0:s.filter)||this.$$filter.bind(this),this._rawConsumer=r}get config(){return this._config}get rawFilter(){return this._rawFilter}get rawConsumer(){return this._rawConsumer}filter(e,t){return!!this.isActivated&&this.rawFilter(e,t)}$$filter(e,t){return!0}consumer(e){return this.rawConsumer(this,e)}generatorKey(){return"event_consumer_"+p++}$$dispose(){ConsumerOperator.dispose(this)}}class Basic{static init(e,t){const{category:r,type:s}=e;let n=ProducerOperator.getProducer(r,s);return n||(n=ProducerOperator.construct({category:r,type:s},t),ProducerOperator.init(n)),n}static startProducer(e){const{category:t,type:r}=e,s=ProducerOperator.getProducer(t,r);return!!s&&s.start()}static stopProducer(e){const{category:t,type:r}=e,s=ProducerOperator.getProducer(t,r);return!!s&&s.stop()}static publish(e,t){const{category:r,type:s}=e,n=ProducerOperator.getProducer(r,s);if(!n)throw new Error("Invalid producer. please initialize the producer before publish.");n.publish(t)}static subscribe(e,t,r){const s=ConsumerOperator.construct(e,t,r);return ConsumerOperator.init(s),Basic.consumerMap.set(t,s),s}static unsubscribe(e){const t=Basic.consumerMap.get(e);return t&&(Basic.consumerMap.delete(e),ConsumerOperator.dispose(t)),t}static startConsumer(e){const t=Basic.consumerMap.get(e);return!!t&&t.start()}static stopConsumer(e){const t=Basic.consumerMap.get(e);return!!t&&t.stop()}}var _,y;Basic.consumerMap=new Map,function(e){e.global="global",e.view="view",e.current="current"}(_||(_={})),function(e){e.html="html",e.keyboard="keyboard"}(y||(y={}));const f=["keypress","keyup","keydown"];class HTMLEvent{static init(e){return Basic.init({category:y.html,type:e})}static dispose(e){return ProducerOperator.dispose(`${y.html}#${e}`)}static subscribe(e,t,r,s=!0){return s&&HTMLEvent.init(e),Basic.subscribe({category:y.html,type:e},t,r)}}const h="global";class HTMLKeyboardEvent{static init(){return Basic.init({category:y.keyboard,type:h})}static dispose(){return ProducerOperator.dispose(`${y.keyboard}#${h}`)}static subscribe(e,t,r,s=!0){return s&&HTMLKeyboardEvent.init(),Basic.subscribe({category:y.keyboard,type:e},t,r)}}class EventBus{}EventBus.init=Basic.init,EventBus.startProducer=Basic.startProducer,EventBus.stopProducer=Basic.stopProducer,EventBus.publish=Basic.publish,EventBus.subscribe=Basic.subscribe,EventBus.unsubscribe=Basic.unsubscribe,EventBus.start=Basic.startConsumer,EventBus.stop=Basic.stopConsumer,EventBus.disposeProducer=ProducerOperator.dispose,EventBus.disposeConsumer=ConsumerOperator.dispose,EventBus.subscribeHTMLEvent=HTMLEvent.subscribe,EventBus.subscribeKeyboardEvent=HTMLKeyboardEvent.subscribe;class AbstractHTMLEventProducer extends AbstractEventProducer{constructor(e,t,r){super(e,t,r)}$$convert(e,t){return{category:this.category,type:this.type,origin:t}}$$start(){document.addEventListener(this.type,this.publish.bind(this))}$$stop(){document.removeEventListener(this.type,this.publish.bind(this))}}class HTMLEventConsumer extends AbstractEventConsumer{constructor(e,t,r){super(y.html,e,t,r)}}c({category:y.html},HTMLEventConsumer);class HTMLEventProducer extends AbstractHTMLEventProducer{constructor(e,t){super(y.html,e,t)}}d({category:y.html},HTMLEventProducer);class AbstractKeyboardEventConsumer extends AbstractEventConsumer{constructor(e,t,r,s){super(e,t,r,s),this.initConfig()}initConfig(){const{config:e}=this;null==e.scope&&(e.scope=_.view),void 0===e.ctrl&&(e.ctrl=!1),void 0===e.shift&&(e.shift=!1),void 0===e.alt&&(e.alt=!1)}$$filter(e,r){const{scope:s,ctrl:n,alt:o,shift:i}=this.config;let c=!1;switch(s){case _.global:case _.current:c=!0;break;case _.view:{const{el:e}=this;if(!e)break;const{x:r,y:s}=e.getBoundingClientRect(),n=t().clickVisibleArea[0];if(n){const{el:t,x:o,y:i,ex:a,ey:u}=n;if(t)t.contains(e)&&(c=!0);else if(o<=r&&r<=a&&i<=s&&s<=u){c=!0;break}}break}}return!!c&&((null==n||n===r.ctrl)&&((null==i||i===r.shift)&&(null==o||o===r.alt)))}}class HTMLKeyboardEventConsumer extends AbstractKeyboardEventConsumer{constructor(e,t,r){super(y.html,e,t,r)}}class KeyboardEventConsumer extends AbstractKeyboardEventConsumer{constructor(e,t,r){super(y.keyboard,e,t,r)}}c({category:y.html,type:f},HTMLKeyboardEventConsumer),c({category:y.keyboard},KeyboardEventConsumer);class AbstractHTMLKeyboardEventProducer extends AbstractHTMLEventProducer{$$convert(e,t){const r=s.newInstance(t);if(!r.isStateKey())return{category:this.category,type:this.type,origin:t,code:t.code,key:t.key,ctrl:r.isPressCtrl(),alt:r.isPressAlt(),shift:r.isPressShift()}}}class HTMLKeyboardEventProducer extends AbstractHTMLKeyboardEventProducer{constructor(e,t){super(y.html,e,t)}}class KeyboardEventProducer extends AbstractHTMLKeyboardEventProducer{constructor(e,t){super(y.keyboard,e,t)}$$convert(e,t){const r=super.$$convert(e,t);return r&&(r.type=t.key),r}onKeydown(e){this.publish(e)}$$start(){document.addEventListener("keydown",this.onKeydown.bind(this))}$$stop(){document.removeEventListener("keydown",this.onKeydown.bind(this))}}var b,v,O,m;d({category:y.html,type:f},HTMLKeyboardEventProducer),d({category:y.keyboard},KeyboardEventProducer),function(e){e.FIELD="Field",e.VIEW="View",e.ACTION="Action"}(b||(b={})),function(e){e.ON_VIEW_BEFORE_CREATED="onViewBeforeCreated",e.ON_VIEW_CREATED="onViewCreated",e.ON_VIEW_BEFORE_MOUNT="onViewBeforeMount",e.ON_VIEW_MOUNTED="onViewMounted",e.ON_VIEW_BEFORE_UPDATE="onViewBeforeUpdate",e.ON_VIEW_UPDATED="onViewUpdated",e.ON_VIEW_ACTIVATED="onViewActivated",e.ON_VIEW_BEFORE_UNMOUNT="onViewBeforeUnmount",e.ON_VIEW_UNMOUNTED="onViewUnmounted",e.ON_VIEW_SUBMIT="onViewSubmit",e.ON_VIEW_SUBMIT_START="onViewSubmitStart",e.ON_VIEW_SUBMIT_END="onViewSubmitEnd",e.ON_VIEW_SUBMIT_SUCCESS="onViewSubmitSuccess",e.ON_VIEW_SUBMIT_FAILED="onViewSubmitFailed",e.ON_VIEW_VALIDATE_START="onViewValidateStart",e.ON_VIEW_VALIDATE_SUCCESS="onViewValidateSuccess",e.ON_VIEW_VALIDATE_FAILED="onViewValidateFailed",e.ON_VIEW_VALIDATE_END="onViewValidateEnd",e.ON_FIELD_BEFORE_CREATED="onFieldBeforeCreated",e.ON_FIELD_CREATED="onFieldCreated",e.ON_FIELD_BEFORE_MOUNT="onFieldBeforeMount",e.ON_FIELD_MOUNTED="onFieldMounted",e.ON_FIELD_BEFORE_UPDATE="onFieldBeforeUpdate",e.ON_FIELD_UPDATED="onFieldUpdated",e.ON_FIELD_ACTIVATED="onFieldActivated",e.ON_FIELD_BEFORE_UNMOUNT="onFieldBeforeUnmount",e.ON_FIELD_UNMOUNTED="onFieldUnmounted",e.ON_FIELD_FOCUS="onFieldFocus",e.ON_FIELD_CHANGE="onFieldChange",e.ON_FIELD_BLUR="onFieldBlur",e.ON_FIELD_VALIDATE_START="onFieldValidateStart",e.ON_FIELD_VALIDATE_SUCCESS="onFieldValidateSuccess",e.ON_FIELD_VALIDATE_FAILED="onFieldValidateFailed",e.ON_FIELD_VALIDATE_END="onFieldValidateEnd"}(v||(v={})),function(e){e.viewBeforeCreated="onViewBeforeCreated",e.viewCreated="onViewCreated",e.viewBeforeMount="onViewBeforeMount",e.viewMounted="onViewMounted",e.viewBeforeUpdate="onViewBeforeUpdate",e.viewUpdated="onViewUpdated",e.viewActivated="onViewActivated",e.viewBeforeUnmount="onViewBeforeUnmount",e.viewUnmounted="onViewUnmounted",e.viewSubmit="onViewSubmit",e.viewSubmitStart="onViewSubmitStart",e.viewSubmitEnd="onViewSubmitEnd",e.viewSubmitSuccess="onViewSubmitSuccess",e.viewSubmitFailed="onViewSubmitFailed",e.viewValidateStart="onViewValidateStart",e.viewValidateSuccess="onViewValidateSuccess",e.viewValidateFailed="onViewValidateFailed",e.viewValidateEnd="onViewValidateEnd"}(O||(O={})),function(e){e.beforeCreated="onFieldBeforeCreated",e.created="onFieldCreated",e.beforeMount="onFieldBeforeMount",e.mount="onFieldMounted",e.beforeUpdate="onFieldBeforeUpdate",e.updated="onViewUpdated",e.beforeUnmount="onFieldBeforeUnmount",e.unmounted="onFieldUnmounted",e.focus="onFieldFocus",e.change="onFieldChange",e.blur="onFieldBlur",e.validateStart="onFieldValidateStart",e.validateSuccess="onFieldValidateSuccess",e.validateFailed="onFieldValidateFailed",e.validateEnd="onFieldValidateEnd"}(m||(m={}));const C=e=>t=>g(t)===`[object ${e}]`,g=e=>Object.prototype.toString.call(e),I=e=>"function"==typeof e,V=Array.isArray,T=C("Object"),L=C("String"),w=C("Boolean"),A=C("Number"),F=e=>e&&e instanceof Map,N=e=>e&&e instanceof Set,D=e=>e&&e instanceof WeakMap,B=e=>e&&e instanceof WeakSet,S=e=>A(e)||/^\d+$/.test(e),M=e=>"object"==typeof e,U=C("RegExp");class LifeCycle{constructor(e){if(!I(e))throw new Error("life cycle callback must be function");this.listener=this.buildListener(e)}buildListener(e){return t=>{I(e)&&e(t)}}notify(e){this.listener.call(e,e)}}class LifeCycleHeart{static initialize(e){this.lifeCycles=e}static getLifeCycleIndex(e){return this.lifeCycles.findIndex(t=>t.type===e)}static getLifeCycle(){return this.lifeCycles}static getLifeCycleByType(e){const t=this.getLifeCycleIndex(e);return t>=0?this.lifeCycles[t]:null}static setType(e){this.heartType=e}static setLifeCycle(e,t,r){if(!(L(e)&&L(t)&&r instanceof LifeCycle))return!1;if(!this.heartType)throw new Error('set fail, use "LifeCycleHeart.setType(type)" first, then call "setLifeCycle"');const s=this.getLifeCycleIndex(e);s>=0?t&&this.lifeCycles[s].pattern.push({identifier:t,lifes:[r]}):this.lifeCycles.push({type:e,registryType:this.heartType,pattern:[{identifier:t,lifes:[r]}]}),this.heartType=null}static publish(e,t,r){if(!e||!t||!r)return!1;const s=this.getLifeCycleIndex(e);if(s>=0&&t){const e=this.lifeCycles[s].pattern.find(e=>e.identifier===t);e&&e.lifes.forEach(e=>{e.notify(r)})}}static disposeLifeCycle(e){}static dispose(e){this.lifeCycles.forEach(t=>{const r=t.pattern.findIndex(t=>t.identifier===e);r>=0&&t.pattern.splice(r,1)})}}function P(e,t){return(r,s)=>{if(!L(r))throw new Error("arg[0] must be string, but now is "+typeof r);if(s){if(!I(s))throw new Error("arg[1] must be function");LifeCycleHeart.setType(t),LifeCycleHeart.setLifeCycle(e,r,new LifeCycle(s))}}}function $(e){return P(e,b.FIELD)}LifeCycleHeart.lifeCycles=[],LifeCycleHeart.heartType=null;const K=$(v.ON_FIELD_BEFORE_CREATED),W=$(v.ON_FIELD_CREATED),k=$(v.ON_FIELD_BEFORE_MOUNT),H=$(v.ON_FIELD_MOUNTED),R=$(v.ON_FIELD_BEFORE_UPDATE),x=$(v.ON_FIELD_UPDATED),j=$(v.ON_FIELD_BEFORE_UNMOUNT),z=$(v.ON_FIELD_UNMOUNTED),G=$(v.ON_FIELD_VALIDATE_START),q=$(v.ON_FIELD_VALIDATE_SUCCESS),J=$(v.ON_FIELD_VALIDATE_FAILED),Q=$(v.ON_FIELD_VALIDATE_END),X=$(v.ON_FIELD_FOCUS),Y=$(v.ON_FIELD_CHANGE),Z=$(v.ON_FIELD_BLUR);function ee(e){return P(e,b.VIEW)}const te=ee(v.ON_VIEW_BEFORE_CREATED),re=ee(v.ON_VIEW_CREATED),se=ee(v.ON_VIEW_BEFORE_MOUNT),ne=ee(v.ON_VIEW_MOUNTED),oe=ee(v.ON_VIEW_BEFORE_UPDATE),ie=ee(v.ON_VIEW_UPDATED),ce=ee(v.ON_VIEW_BEFORE_UNMOUNT),ae=ee(v.ON_VIEW_UNMOUNTED),ue=ee(v.ON_VIEW_SUBMIT),de=ee(v.ON_VIEW_SUBMIT_START),Ee=ee(v.ON_VIEW_SUBMIT_SUCCESS),le=ee(v.ON_VIEW_SUBMIT_FAILED),pe=ee(v.ON_VIEW_SUBMIT_END),_e=ee(v.ON_VIEW_VALIDATE_START),ye=ee(v.ON_VIEW_VALIDATE_SUCCESS),fe=ee(v.ON_VIEW_VALIDATE_FAILED),he=ee(v.ON_VIEW_VALIDATE_END);export{AbstractEventConsumer,AbstractEventProducer,AbstractHTMLEventProducer,EventBus,y as EventCategory,_ as EventConsumerScope,m as FieldEventNames,HTMLEventConsumer,HTMLEventProducer,HTMLKeyboardEventConsumer,HTMLKeyboardEventProducer,KeyboardEventConsumer,KeyboardEventProducer,f as KeyboardTypes,LifeCycle,LifeCycleHeart,v as LifeCycleTypes,b as RegistryType,O as ViewEventNames,V as isArr,w as isBool,I as isFn,F as isMap,A as isNum,S as isNumberLike,M as isObj,T as isPlainObj,U as isRegExp,N as isSet,L as isStr,D as isWeakMap,B as isWeakSet,K as onFieldBeforeCreate,k as onFieldBeforeMount,j as onFieldBeforeUnmount,R as onFieldBeforeUpdate,Z as onFieldBlur,W as onFieldCreated,X as onFieldFocus,H as onFieldMounted,z as onFieldUnmounted,x as onFieldUpdated,Q as onFieldValidateEnd,J as onFieldValidateFailed,G as onFieldValidateStart,q as onFieldValidateSuccess,Y as onFieldValueChange,te as onViewBeforeCreated,se as onViewBeforeMount,ce as onViewBeforeUnmount,oe as onViewBeforeUpdate,re as onViewCreated,ne as onViewMounted,ue as onViewSubmit,pe as onViewSubmitEnd,le as onViewSubmitFailed,de as onViewSubmitStart,Ee as onViewSubmitSuccess,ae as onViewUnmounted,ie as onViewUpdated,he as onViewValidateEnd,fe as onViewValidateFailed,_e as onViewValidateStart,ye as onViewValidateSuccess,c as registerEventConsumer,d as registerEventProducer,a as selectorEventConsumer,E as selectorEventProducer};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './src';
|
|
1
|
+
export * from './src';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { EventCategoryType, EventConsumer, EventConsumerConfig, EventConsumerFilter, EventConsumerFunction, EventConsumerOptions, EventMessage } from '../typing';
|
|
2
|
-
import { AbstractEventEngine } from './AbstractEventEngine';
|
|
3
|
-
export declare abstract class AbstractEventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> extends AbstractEventEngine<K> implements EventConsumer<K, EV, V, M, C> {
|
|
4
|
-
el: HTMLElement | undefined;
|
|
5
|
-
private readonly _config;
|
|
6
|
-
private readonly _rawFilter;
|
|
7
|
-
private readonly _rawConsumer;
|
|
8
|
-
protected constructor(category: EventCategoryType, type: K, consumer: EventConsumerFunction<K, EV, V, M, C>, options?: EventConsumerOptions<EV, V, M, C>);
|
|
9
|
-
get config(): C;
|
|
10
|
-
protected get rawFilter(): EventConsumerFilter<EV, V, M>;
|
|
11
|
-
protected get rawConsumer(): EventConsumerFunction<K, EV, V, M, C>;
|
|
12
|
-
filter(ev: EV, message: M): boolean;
|
|
13
|
-
protected $$filter(ev: EV, message: M): boolean;
|
|
14
|
-
consumer(message: M): void;
|
|
15
|
-
protected generatorKey(): string;
|
|
16
|
-
protected $$dispose(): void;
|
|
17
|
-
}
|
|
1
|
+
import type { EventCategoryType, EventConsumer, EventConsumerConfig, EventConsumerFilter, EventConsumerFunction, EventConsumerOptions, EventMessage } from '../typing';
|
|
2
|
+
import { AbstractEventEngine } from './AbstractEventEngine';
|
|
3
|
+
export declare abstract class AbstractEventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> extends AbstractEventEngine<K> implements EventConsumer<K, EV, V, M, C> {
|
|
4
|
+
el: HTMLElement | undefined;
|
|
5
|
+
private readonly _config;
|
|
6
|
+
private readonly _rawFilter;
|
|
7
|
+
private readonly _rawConsumer;
|
|
8
|
+
protected constructor(category: EventCategoryType, type: K, consumer: EventConsumerFunction<K, EV, V, M, C>, options?: EventConsumerOptions<EV, V, M, C>);
|
|
9
|
+
get config(): C;
|
|
10
|
+
protected get rawFilter(): EventConsumerFilter<EV, V, M>;
|
|
11
|
+
protected get rawConsumer(): EventConsumerFunction<K, EV, V, M, C>;
|
|
12
|
+
filter(ev: EV, message: M): boolean;
|
|
13
|
+
protected $$filter(ev: EV, message: M): boolean;
|
|
14
|
+
consumer(message: M): void;
|
|
15
|
+
protected generatorKey(): string;
|
|
16
|
+
protected $$dispose(): void;
|
|
17
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { EventCategoryType, EventEngine } from '../typing';
|
|
2
|
-
export declare abstract class AbstractEventEngine<K = string> implements EventEngine<K> {
|
|
3
|
-
private readonly _key;
|
|
4
|
-
private readonly _category;
|
|
5
|
-
private readonly _type;
|
|
6
|
-
private _isActivated;
|
|
7
|
-
private _isDisposed;
|
|
8
|
-
protected constructor(category: EventCategoryType, type: K);
|
|
9
|
-
get key(): string;
|
|
10
|
-
get category(): EventCategoryType;
|
|
11
|
-
get type(): K;
|
|
12
|
-
get isActivated(): boolean;
|
|
13
|
-
get isDisposed(): boolean;
|
|
14
|
-
start(): boolean;
|
|
15
|
-
protected $$start(): void;
|
|
16
|
-
stop(): boolean;
|
|
17
|
-
protected $$stop(): void;
|
|
18
|
-
dispose(): boolean;
|
|
19
|
-
protected $$dispose(): void;
|
|
20
|
-
protected abstract generatorKey(): string;
|
|
21
|
-
}
|
|
1
|
+
import type { EventCategoryType, EventEngine } from '../typing';
|
|
2
|
+
export declare abstract class AbstractEventEngine<K = string> implements EventEngine<K> {
|
|
3
|
+
private readonly _key;
|
|
4
|
+
private readonly _category;
|
|
5
|
+
private readonly _type;
|
|
6
|
+
private _isActivated;
|
|
7
|
+
private _isDisposed;
|
|
8
|
+
protected constructor(category: EventCategoryType, type: K);
|
|
9
|
+
get key(): string;
|
|
10
|
+
get category(): EventCategoryType;
|
|
11
|
+
get type(): K;
|
|
12
|
+
get isActivated(): boolean;
|
|
13
|
+
get isDisposed(): boolean;
|
|
14
|
+
start(): boolean;
|
|
15
|
+
protected $$start(): void;
|
|
16
|
+
stop(): boolean;
|
|
17
|
+
protected $$stop(): void;
|
|
18
|
+
dispose(): boolean;
|
|
19
|
+
protected $$dispose(): void;
|
|
20
|
+
protected abstract generatorKey(): string;
|
|
21
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { EventCategoryType, EventConvertFunction, EventMessage, EventProducer, EventProducerOptions, EventPublishFunction } from '../typing';
|
|
2
|
-
import { AbstractEventEngine } from './AbstractEventEngine';
|
|
3
|
-
export declare abstract class AbstractEventProducer<K = string, EV = unknown, V = EV> extends AbstractEventEngine<K> implements EventProducer<K, EV, V> {
|
|
4
|
-
private readonly _rawConvert;
|
|
5
|
-
private readonly _rawPublish;
|
|
6
|
-
protected constructor(category: EventCategoryType, type: K, options?: EventProducerOptions<K, EV, V>);
|
|
7
|
-
get rawConvert(): EventConvertFunction<K, EV, V>;
|
|
8
|
-
get rawPublish(): EventPublishFunction<K, EV, V>;
|
|
9
|
-
convert(ev: EV): EventMessage<V> | undefined;
|
|
10
|
-
protected abstract $$convert(self: EventProducer<K, EV, V>, ev: EV): EventMessage<V> | undefined;
|
|
11
|
-
publish(ev: EV): void;
|
|
12
|
-
protected $$publish(self: EventProducer<K, EV, V>, ev: EV): void;
|
|
13
|
-
protected generatorKey(): string;
|
|
14
|
-
protected $$dispose(): void;
|
|
15
|
-
}
|
|
1
|
+
import type { EventCategoryType, EventConvertFunction, EventMessage, EventProducer, EventProducerOptions, EventPublishFunction } from '../typing';
|
|
2
|
+
import { AbstractEventEngine } from './AbstractEventEngine';
|
|
3
|
+
export declare abstract class AbstractEventProducer<K = string, EV = unknown, V = EV> extends AbstractEventEngine<K> implements EventProducer<K, EV, V> {
|
|
4
|
+
private readonly _rawConvert;
|
|
5
|
+
private readonly _rawPublish;
|
|
6
|
+
protected constructor(category: EventCategoryType, type: K, options?: EventProducerOptions<K, EV, V>);
|
|
7
|
+
get rawConvert(): EventConvertFunction<K, EV, V>;
|
|
8
|
+
get rawPublish(): EventPublishFunction<K, EV, V>;
|
|
9
|
+
convert(ev: EV): EventMessage<V> | undefined;
|
|
10
|
+
protected abstract $$convert(self: EventProducer<K, EV, V>, ev: EV): EventMessage<V> | undefined;
|
|
11
|
+
publish(ev: EV): void;
|
|
12
|
+
protected $$publish(self: EventProducer<K, EV, V>, ev: EV): void;
|
|
13
|
+
protected generatorKey(): string;
|
|
14
|
+
protected $$dispose(): void;
|
|
15
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './AbstractEventProducer';
|
|
2
|
-
export * from './AbstractEventConsumer';
|
|
1
|
+
export * from './AbstractEventProducer';
|
|
2
|
+
export * from './AbstractEventConsumer';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { EventConsumer, EventConsumerConfig, EventConsumerFunction, EventConsumerOptions, EventEngineOptions, EventMessage, EventProducer, EventProducerOptions } from '../typing';
|
|
2
|
-
export declare class Basic {
|
|
3
|
-
private static consumerMap;
|
|
4
|
-
static init<K = string, EV = unknown, V = EV>(options: EventEngineOptions, producerOptions?: EventProducerOptions<K, EV, V>): EventProducer<K, EV, V>;
|
|
5
|
-
static startProducer(options: EventEngineOptions): boolean;
|
|
6
|
-
static stopProducer(options: EventEngineOptions): boolean;
|
|
7
|
-
static publish<K = string, EV = unknown, V = EV>(options: EventEngineOptions, ev: EV): void;
|
|
8
|
-
static subscribe<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventEngineOptions, consumerFn: EventConsumerFunction<K, EV, V, M, C>, consumerOptions?: EventConsumerOptions<EV, V, M, C>): EventConsumer<K, EV, V, M, C>;
|
|
9
|
-
static unsubscribe<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(consumerFn: EventConsumerFunction<K, EV, V, M, C>): EventConsumer<K, EV, V> | undefined;
|
|
10
|
-
static startConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(consumerFn: EventConsumerFunction<K, EV, V, M, C>): boolean;
|
|
11
|
-
static stopConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(consumerFn: EventConsumerFunction<K, EV, V, M, C>): boolean;
|
|
12
|
-
}
|
|
1
|
+
import type { EventConsumer, EventConsumerConfig, EventConsumerFunction, EventConsumerOptions, EventEngineOptions, EventMessage, EventProducer, EventProducerOptions } from '../typing';
|
|
2
|
+
export declare class Basic {
|
|
3
|
+
private static consumerMap;
|
|
4
|
+
static init<K = string, EV = unknown, V = EV>(options: EventEngineOptions, producerOptions?: EventProducerOptions<K, EV, V>): EventProducer<K, EV, V>;
|
|
5
|
+
static startProducer(options: EventEngineOptions): boolean;
|
|
6
|
+
static stopProducer(options: EventEngineOptions): boolean;
|
|
7
|
+
static publish<K = string, EV = unknown, V = EV>(options: EventEngineOptions, ev: EV): void;
|
|
8
|
+
static subscribe<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventEngineOptions, consumerFn: EventConsumerFunction<K, EV, V, M, C>, consumerOptions?: EventConsumerOptions<EV, V, M, C>): EventConsumer<K, EV, V, M, C>;
|
|
9
|
+
static unsubscribe<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(consumerFn: EventConsumerFunction<K, EV, V, M, C>): EventConsumer<K, EV, V> | undefined;
|
|
10
|
+
static startConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(consumerFn: EventConsumerFunction<K, EV, V, M, C>): boolean;
|
|
11
|
+
static stopConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(consumerFn: EventConsumerFunction<K, EV, V, M, C>): boolean;
|
|
12
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventConsumer, EventConsumerConfig, EventConsumerFunction, EventConsumerOptions, EventMessage, EventProducer } from '../typing';
|
|
2
|
-
export declare class HTMLEvent {
|
|
3
|
-
static init<K extends keyof HTMLElementEventMap, EV = HTMLElementEventMap[K]>(type: K | '*'): EventProducer<K, EV>;
|
|
4
|
-
static dispose<K extends keyof HTMLElementEventMap>(type: K | '*'): EventProducer<K, HTMLElementEventMap[K]> | undefined;
|
|
5
|
-
static subscribe<K extends keyof HTMLElementEventMap, EV = HTMLElementEventMap[K], V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(type: K | '*', consumerFn: EventConsumerFunction<K, EV, V, M, C>, consumerOptions?: EventConsumerOptions<EV, V, M, C>, autoInitProducer?: boolean): EventConsumer<K, EV, V, M, C>;
|
|
6
|
-
}
|
|
1
|
+
import { type EventConsumer, type EventConsumerConfig, type EventConsumerFunction, type EventConsumerOptions, type EventMessage, type EventProducer } from '../typing';
|
|
2
|
+
export declare class HTMLEvent {
|
|
3
|
+
static init<K extends keyof HTMLElementEventMap, EV = HTMLElementEventMap[K]>(type: K | '*'): EventProducer<K, EV>;
|
|
4
|
+
static dispose<K extends keyof HTMLElementEventMap>(type: K | '*'): EventProducer<K, HTMLElementEventMap[K]> | undefined;
|
|
5
|
+
static subscribe<K extends keyof HTMLElementEventMap, EV = HTMLElementEventMap[K], V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(type: K | '*', consumerFn: EventConsumerFunction<K, EV, V, M, C>, consumerOptions?: EventConsumerOptions<EV, V, M, C>, autoInitProducer?: boolean): EventConsumer<K, EV, V, M, C>;
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventConsumer, EventConsumerFunction, EventConsumerOptions, EventProducer, HTMLKeyboardEventConsumerConfig, KeyboardEventMessage } from '../typing';
|
|
2
|
-
export declare class HTMLKeyboardEvent {
|
|
3
|
-
static init(): EventProducer;
|
|
4
|
-
static dispose(): EventProducer | undefined;
|
|
5
|
-
static subscribe(type: string | '*', consumerFn: EventConsumerFunction<string, KeyboardEvent, KeyboardEvent, KeyboardEventMessage, HTMLKeyboardEventConsumerConfig>, consumerOptions?: EventConsumerOptions<KeyboardEvent, KeyboardEvent, KeyboardEventMessage, HTMLKeyboardEventConsumerConfig>, autoInitProducer?: boolean): EventConsumer<string, KeyboardEvent, KeyboardEvent, KeyboardEventMessage, HTMLKeyboardEventConsumerConfig>;
|
|
6
|
-
}
|
|
1
|
+
import { type EventConsumer, type EventConsumerFunction, type EventConsumerOptions, type EventProducer, type HTMLKeyboardEventConsumerConfig, type KeyboardEventMessage } from '../typing';
|
|
2
|
+
export declare class HTMLKeyboardEvent {
|
|
3
|
+
static init(): EventProducer;
|
|
4
|
+
static dispose(): EventProducer | undefined;
|
|
5
|
+
static subscribe(type: string | '*', consumerFn: EventConsumerFunction<string, KeyboardEvent, KeyboardEvent, KeyboardEventMessage, HTMLKeyboardEventConsumerConfig>, consumerOptions?: EventConsumerOptions<KeyboardEvent, KeyboardEvent, KeyboardEventMessage, HTMLKeyboardEventConsumerConfig>, autoInitProducer?: boolean): EventConsumer<string, KeyboardEvent, KeyboardEvent, KeyboardEventMessage, HTMLKeyboardEventConsumerConfig>;
|
|
6
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ConsumerOperator, ProducerOperator } from '../operator';
|
|
2
|
-
import { Basic } from './basic';
|
|
3
|
-
import { HTMLEvent } from './html-event';
|
|
4
|
-
import { HTMLKeyboardEvent } from './html-keyboard-event';
|
|
5
|
-
export declare class EventBus {
|
|
6
|
-
static init: typeof Basic.init;
|
|
7
|
-
static startProducer: typeof Basic.startProducer;
|
|
8
|
-
static stopProducer: typeof Basic.stopProducer;
|
|
9
|
-
static publish: typeof Basic.publish;
|
|
10
|
-
static subscribe: typeof Basic.subscribe;
|
|
11
|
-
static unsubscribe: typeof Basic.unsubscribe;
|
|
12
|
-
static start: typeof Basic.startConsumer;
|
|
13
|
-
static stop: typeof Basic.stopConsumer;
|
|
14
|
-
static disposeProducer: typeof ProducerOperator.dispose;
|
|
15
|
-
static disposeConsumer: typeof ConsumerOperator.dispose;
|
|
16
|
-
static subscribeHTMLEvent: typeof HTMLEvent.subscribe;
|
|
17
|
-
static subscribeKeyboardEvent: typeof HTMLKeyboardEvent.subscribe;
|
|
18
|
-
}
|
|
1
|
+
import { ConsumerOperator, ProducerOperator } from '../operator';
|
|
2
|
+
import { Basic } from './basic';
|
|
3
|
+
import { HTMLEvent } from './html-event';
|
|
4
|
+
import { HTMLKeyboardEvent } from './html-keyboard-event';
|
|
5
|
+
export declare class EventBus {
|
|
6
|
+
static init: typeof Basic.init;
|
|
7
|
+
static startProducer: typeof Basic.startProducer;
|
|
8
|
+
static stopProducer: typeof Basic.stopProducer;
|
|
9
|
+
static publish: typeof Basic.publish;
|
|
10
|
+
static subscribe: typeof Basic.subscribe;
|
|
11
|
+
static unsubscribe: typeof Basic.unsubscribe;
|
|
12
|
+
static start: typeof Basic.startConsumer;
|
|
13
|
+
static stop: typeof Basic.stopConsumer;
|
|
14
|
+
static disposeProducer: typeof ProducerOperator.dispose;
|
|
15
|
+
static disposeConsumer: typeof ConsumerOperator.dispose;
|
|
16
|
+
static subscribeHTMLEvent: typeof HTMLEvent.subscribe;
|
|
17
|
+
static subscribeKeyboardEvent: typeof HTMLKeyboardEvent.subscribe;
|
|
18
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './consumer';
|
|
2
|
-
export * from './producer';
|
|
1
|
+
export * from './consumer';
|
|
2
|
+
export * from './producer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './abstract';
|
|
2
|
-
export * from './bus';
|
|
3
|
-
export * from './hook';
|
|
4
|
-
export * from './spi';
|
|
5
|
-
export * from './typing';
|
|
1
|
+
export * from './abstract';
|
|
2
|
+
export * from './bus';
|
|
3
|
+
export * from './hook';
|
|
4
|
+
export * from './spi';
|
|
5
|
+
export * from './typing';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { EventConsumer, EventConsumerConfig, EventConsumerFunction, EventConsumerOptions, EventEngineOptions, EventMessage } from '../typing';
|
|
2
|
-
export declare class ConsumerOperator {
|
|
3
|
-
private static consumers;
|
|
4
|
-
static getConsumers(message: EventMessage): EventConsumer<unknown, unknown, unknown, EventMessage<unknown>, EventConsumerConfig>[] | undefined;
|
|
5
|
-
static construct<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventEngineOptions, consumer: EventConsumerFunction<K, EV, V, M, C>, consumerOptions?: EventConsumerOptions<EV, V, M, C>): EventConsumer<K, EV, V, M, C>;
|
|
6
|
-
static init<K = string, EV = unknown, V = EV>(consumer: EventConsumer<K, EV, V>): void;
|
|
7
|
-
static dispose<K = string, EV = unknown, V = EV>(consumer: EventConsumer<K, EV, V>): boolean;
|
|
8
|
-
static generatorKey(category: string, type: string): string;
|
|
9
|
-
static generatorKeyByEngine<K = string, EV = unknown, V = EV>(consumer: EventConsumer<K, EV, V>): string;
|
|
10
|
-
static generatorKeyByMessage(message: EventMessage): string;
|
|
11
|
-
}
|
|
1
|
+
import type { EventConsumer, EventConsumerConfig, EventConsumerFunction, EventConsumerOptions, EventEngineOptions, EventMessage } from '../typing';
|
|
2
|
+
export declare class ConsumerOperator {
|
|
3
|
+
private static consumers;
|
|
4
|
+
static getConsumers(message: EventMessage): EventConsumer<unknown, unknown, unknown, EventMessage<unknown>, EventConsumerConfig>[] | undefined;
|
|
5
|
+
static construct<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventEngineOptions, consumer: EventConsumerFunction<K, EV, V, M, C>, consumerOptions?: EventConsumerOptions<EV, V, M, C>): EventConsumer<K, EV, V, M, C>;
|
|
6
|
+
static init<K = string, EV = unknown, V = EV>(consumer: EventConsumer<K, EV, V>): void;
|
|
7
|
+
static dispose<K = string, EV = unknown, V = EV>(consumer: EventConsumer<K, EV, V>): boolean;
|
|
8
|
+
static generatorKey(category: string, type: string): string;
|
|
9
|
+
static generatorKeyByEngine<K = string, EV = unknown, V = EV>(consumer: EventConsumer<K, EV, V>): string;
|
|
10
|
+
static generatorKeyByMessage(message: EventMessage): string;
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './consumer';
|
|
2
|
-
export * from './producer';
|
|
1
|
+
export * from './consumer';
|
|
2
|
+
export * from './producer';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EventCategoryType, EventEngineOptions, EventProducer, EventProducerOptions } from '../typing';
|
|
2
|
-
export declare class ProducerOperator {
|
|
3
|
-
private static producers;
|
|
4
|
-
static getProducer<K = string, EV = unknown, V = EV>(category: EventCategoryType, type: string): EventProducer<K, EV, V> | undefined;
|
|
5
|
-
static construct<K = string, EV = unknown, V = EV>(options: EventEngineOptions, producerOptions?: EventProducerOptions<K, EV, V>): EventProducer<K, EV, V>;
|
|
6
|
-
static init<K = string, EV = unknown, V = EV>(producer: EventProducer<K, EV, V>): void;
|
|
7
|
-
static dispose<K = string, EV = unknown, V = EV>(key: string): EventProducer<K, EV, V> | undefined;
|
|
8
|
-
static generatorKey(category: string, type: string): string;
|
|
9
|
-
static generatorKeyByEngine<K = string, EV = unknown, V = EV>(producer: EventProducer<K, EV, V>): string;
|
|
10
|
-
}
|
|
1
|
+
import type { EventCategoryType, EventEngineOptions, EventProducer, EventProducerOptions } from '../typing';
|
|
2
|
+
export declare class ProducerOperator {
|
|
3
|
+
private static producers;
|
|
4
|
+
static getProducer<K = string, EV = unknown, V = EV>(category: EventCategoryType, type: string): EventProducer<K, EV, V> | undefined;
|
|
5
|
+
static construct<K = string, EV = unknown, V = EV>(options: EventEngineOptions, producerOptions?: EventProducerOptions<K, EV, V>): EventProducer<K, EV, V>;
|
|
6
|
+
static init<K = string, EV = unknown, V = EV>(producer: EventProducer<K, EV, V>): void;
|
|
7
|
+
static dispose<K = string, EV = unknown, V = EV>(key: string): EventProducer<K, EV, V> | undefined;
|
|
8
|
+
static generatorKey(category: string, type: string): string;
|
|
9
|
+
static generatorKeyByEngine<K = string, EV = unknown, V = EV>(producer: EventProducer<K, EV, V>): string;
|
|
10
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SPIOptions } from '@oinone/kunlun-spi';
|
|
2
|
-
import { EventCategoryType, EventConsumerConfig, EventConsumerConstructor, EventMessage } from '../typing';
|
|
3
|
-
export interface EventBusConsumerOptions extends SPIOptions {
|
|
4
|
-
category: EventCategoryType | EventCategoryType[];
|
|
5
|
-
type?: string | string[];
|
|
6
|
-
}
|
|
7
|
-
export declare function registerEventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventBusConsumerOptions, constructor: EventConsumerConstructor<K, EV, V, M, C>): boolean;
|
|
8
|
-
export declare function selectorEventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventBusConsumerOptions): EventConsumerConstructor<K, EV, V, M, C> | undefined;
|
|
1
|
+
import { type SPIOptions } from '@oinone/kunlun-spi';
|
|
2
|
+
import type { EventCategoryType, EventConsumerConfig, EventConsumerConstructor, EventMessage } from '../typing';
|
|
3
|
+
export interface EventBusConsumerOptions extends SPIOptions {
|
|
4
|
+
category: EventCategoryType | EventCategoryType[];
|
|
5
|
+
type?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function registerEventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventBusConsumerOptions, constructor: EventConsumerConstructor<K, EV, V, M, C>): boolean;
|
|
8
|
+
export declare function selectorEventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig>(options: EventBusConsumerOptions): EventConsumerConstructor<K, EV, V, M, C> | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './consumer';
|
|
2
|
-
export * from './producer';
|
|
1
|
+
export * from './consumer';
|
|
2
|
+
export * from './producer';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SPIOptions } from '@oinone/kunlun-spi';
|
|
2
|
-
import { EventCategoryType, EventProducerConstructor } from '../typing';
|
|
3
|
-
export interface EventBusProducerOptions extends SPIOptions {
|
|
4
|
-
category: EventCategoryType | EventCategoryType[];
|
|
5
|
-
type?: string | string[];
|
|
6
|
-
}
|
|
7
|
-
export declare function registerEventProducer<K = string, EV = unknown, V = EV>(options: EventBusProducerOptions, constructor: EventProducerConstructor<K, EV, V>): boolean;
|
|
8
|
-
export declare function selectorEventProducer<K = string, EV = unknown, V = EV>(options: EventBusProducerOptions): EventProducerConstructor<K, EV, V> | undefined;
|
|
1
|
+
import { type SPIOptions } from '@oinone/kunlun-spi';
|
|
2
|
+
import type { EventCategoryType, EventProducerConstructor } from '../typing';
|
|
3
|
+
export interface EventBusProducerOptions extends SPIOptions {
|
|
4
|
+
category: EventCategoryType | EventCategoryType[];
|
|
5
|
+
type?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function registerEventProducer<K = string, EV = unknown, V = EV>(options: EventBusProducerOptions, constructor: EventProducerConstructor<K, EV, V>): boolean;
|
|
8
|
+
export declare function selectorEventProducer<K = string, EV = unknown, V = EV>(options: EventBusProducerOptions): EventProducerConstructor<K, EV, V> | undefined;
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { EventCategoryType } from './category';
|
|
2
|
-
export interface EventEngine<K = string> {
|
|
3
|
-
key: string;
|
|
4
|
-
category: EventCategoryType;
|
|
5
|
-
type: K;
|
|
6
|
-
isActivated: boolean;
|
|
7
|
-
isDisposed: boolean;
|
|
8
|
-
start(): boolean;
|
|
9
|
-
stop(): boolean;
|
|
10
|
-
dispose(): boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface EventProducer<K = string, EV = unknown, V = EV> extends EventEngine<K> {
|
|
13
|
-
convert(ev: EV): EventMessage<V> | undefined;
|
|
14
|
-
publish(ev: EV): void;
|
|
15
|
-
}
|
|
16
|
-
export
|
|
17
|
-
export interface EventProducerOptions<K = string, EV = unknown, V = EV> {
|
|
18
|
-
convert?: EventConvertFunction<K, EV, V>;
|
|
19
|
-
publish?: EventPublishFunction<K, EV, V>;
|
|
20
|
-
}
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export interface EventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> extends EventEngine<K> {
|
|
24
|
-
el?: HTMLElement;
|
|
25
|
-
config: C;
|
|
26
|
-
filter(ev: EV, message: M): boolean;
|
|
27
|
-
consumer(message: M): void;
|
|
28
|
-
}
|
|
29
|
-
export
|
|
30
|
-
export interface EventConsumerOptions<EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> {
|
|
31
|
-
config?: C;
|
|
32
|
-
filter?: EventConsumerFilter<EV, V, M>;
|
|
33
|
-
}
|
|
34
|
-
export interface EventConsumerConfig {
|
|
35
|
-
/**
|
|
36
|
-
* 作用范围
|
|
37
|
-
*/
|
|
38
|
-
scope?: EventConsumerScope;
|
|
39
|
-
/**
|
|
40
|
-
* 指针悬浮时启用
|
|
41
|
-
*/
|
|
42
|
-
pointerActivated?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* 隐藏时禁用
|
|
45
|
-
*/
|
|
46
|
-
invisibleDeactivated?: boolean;
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
}
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export interface EventMessage<V = unknown> {
|
|
52
|
-
category: EventCategoryType;
|
|
53
|
-
type: string;
|
|
54
|
-
origin: V;
|
|
55
|
-
}
|
|
56
|
-
export
|
|
57
|
-
category: EventCategoryType;
|
|
58
|
-
type: string | '*';
|
|
59
|
-
};
|
|
60
|
-
export declare enum EventConsumerScope {
|
|
61
|
-
global = "global",
|
|
62
|
-
view = "view",
|
|
63
|
-
current = "current"
|
|
64
|
-
}
|
|
1
|
+
import type { EventCategoryType } from './category';
|
|
2
|
+
export interface EventEngine<K = string> {
|
|
3
|
+
key: string;
|
|
4
|
+
category: EventCategoryType;
|
|
5
|
+
type: K;
|
|
6
|
+
isActivated: boolean;
|
|
7
|
+
isDisposed: boolean;
|
|
8
|
+
start(): boolean;
|
|
9
|
+
stop(): boolean;
|
|
10
|
+
dispose(): boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface EventProducer<K = string, EV = unknown, V = EV> extends EventEngine<K> {
|
|
13
|
+
convert(ev: EV): EventMessage<V> | undefined;
|
|
14
|
+
publish(ev: EV): void;
|
|
15
|
+
}
|
|
16
|
+
export type EventProducerConstructor<K = string, EV = unknown, V = EV> = (new (type: string, options?: EventProducerOptions<K, EV, V>) => EventProducer<K, EV, V>) | EventProducer<K, EV, V>;
|
|
17
|
+
export interface EventProducerOptions<K = string, EV = unknown, V = EV> {
|
|
18
|
+
convert?: EventConvertFunction<K, EV, V>;
|
|
19
|
+
publish?: EventPublishFunction<K, EV, V>;
|
|
20
|
+
}
|
|
21
|
+
export type EventConvertFunction<K = string, EV = unknown, V = EV> = (self: EventProducer<K, EV, V>, ev: EV) => EventMessage<V> | undefined;
|
|
22
|
+
export type EventPublishFunction<K = string, EV = unknown, V = EV> = (self: EventProducer<K, EV, V>, ev: EV) => void;
|
|
23
|
+
export interface EventConsumer<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> extends EventEngine<K> {
|
|
24
|
+
el?: HTMLElement;
|
|
25
|
+
config: C;
|
|
26
|
+
filter(ev: EV, message: M): boolean;
|
|
27
|
+
consumer(message: M): void;
|
|
28
|
+
}
|
|
29
|
+
export type EventConsumerConstructor<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> = new (type: string, consumer: EventConsumerFunction<K, EV, V, M, C>, options?: EventConsumerOptions<EV, V, M, C>) => EventConsumer<K, EV, V, M, C>;
|
|
30
|
+
export interface EventConsumerOptions<EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> {
|
|
31
|
+
config?: C;
|
|
32
|
+
filter?: EventConsumerFilter<EV, V, M>;
|
|
33
|
+
}
|
|
34
|
+
export interface EventConsumerConfig {
|
|
35
|
+
/**
|
|
36
|
+
* 作用范围
|
|
37
|
+
*/
|
|
38
|
+
scope?: EventConsumerScope;
|
|
39
|
+
/**
|
|
40
|
+
* 指针悬浮时启用
|
|
41
|
+
*/
|
|
42
|
+
pointerActivated?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 隐藏时禁用
|
|
45
|
+
*/
|
|
46
|
+
invisibleDeactivated?: boolean;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
export type EventConsumerFilter<EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>> = (ev: EV, message: M) => boolean;
|
|
50
|
+
export type EventConsumerFunction<K = string, EV = unknown, V = EV, M extends EventMessage<V> = EventMessage<V>, C extends EventConsumerConfig = EventConsumerConfig> = (self: EventConsumer, message: M) => void;
|
|
51
|
+
export interface EventMessage<V = unknown> {
|
|
52
|
+
category: EventCategoryType;
|
|
53
|
+
type: string;
|
|
54
|
+
origin: V;
|
|
55
|
+
}
|
|
56
|
+
export type EventEngineOptions = {
|
|
57
|
+
category: EventCategoryType;
|
|
58
|
+
type: string | '*';
|
|
59
|
+
};
|
|
60
|
+
export declare enum EventConsumerScope {
|
|
61
|
+
global = "global",
|
|
62
|
+
view = "view",
|
|
63
|
+
current = "current"
|
|
64
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare enum EventCategory {
|
|
2
|
-
html = "html",
|
|
3
|
-
keyboard = "keyboard"
|
|
4
|
-
}
|
|
5
|
-
export
|
|
1
|
+
export declare enum EventCategory {
|
|
2
|
+
html = "html",
|
|
3
|
+
keyboard = "keyboard"
|
|
4
|
+
}
|
|
5
|
+
export type EventCategoryType = keyof typeof EventCategory | string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './basic';
|
|
2
|
-
export * from './category';
|
|
3
|
-
export * from './keyboard';
|
|
1
|
+
export * from './basic';
|
|
2
|
+
export * from './category';
|
|
3
|
+
export * from './keyboard';
|