@ecopages/radiant 0.1.1 → 0.1.2
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.
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { type EventEmitterConfig } from '../tools/event-emitter';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Decorator that attaches an EventEmitter to the class field property.
|
|
4
4
|
* The EventEmitter can be used to dispatch custom events from the target element.
|
|
5
|
-
*
|
|
6
|
-
* @param {EventEmitterConfig} eventConfig - The configuration for the EventEmitter.
|
|
7
|
-
* This includes the event type, and optionally, whether the event should bubble and whether it should be composed.
|
|
8
|
-
*
|
|
9
|
-
* @returns {EventEmitter} - An EventEmitter instance that can be used to dispatch events from the target element.
|
|
10
|
-
* The returned EventEmitter is read-only and cannot be reconfigured after it's created.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // Use the `event` decorator to create an EventEmitter for a custom event
|
|
14
|
-
* @event({ type: 'my-event', bubbles: true, composed: true })
|
|
15
|
-
* myEventEmitter!: EventEmitter;
|
|
16
|
-
*
|
|
17
|
-
* // Later, you can use the EventEmitter to dispatch the custom event
|
|
18
|
-
* this.myEventEmitter.emit({ detail: { message: 'Hello, world!' } });
|
|
19
|
-
*
|
|
5
|
+
* @param eventConfig Configuration for the event emitter.
|
|
20
6
|
* @see {@link EventEmitter} for more details about how the EventEmitter works.
|
|
21
7
|
*/
|
|
22
8
|
export declare function event(eventConfig: EventEmitterConfig): (target: any, propertyKey: string) => void;
|
package/dist/decorators/event.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as
|
|
2
|
-
export{
|
|
1
|
+
import{z as F} from"../tools/event-emitter.js";function I(j){return(G,A)=>{if(!A)throw new Error("The propertyKey is missing for the event decorator.");if(!j||!j.name)throw new Error("Invalid eventConfig provided.");const z=Symbol(j.name);Object.defineProperty(G,A,{get(){const x=B.get(this)||new Map;if(!x.has(z))x.set(z,new F(this,j)),B.set(this,x);return x.get(z)}})}}var B=new WeakMap;export{I as event};
|
|
2
|
+
export{I as q};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=E335B76426A3F14F64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/decorators/event.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { EventEmitter, type EventEmitterConfig } from '@/tools/event-emitter';\n\n/**\n *
|
|
5
|
+
"import { EventEmitter, type EventEmitterConfig } from '@/tools/event-emitter';\n\nconst eventEmitters = new WeakMap();\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n return (target: any, propertyKey: string) => {\n if (!propertyKey) {\n throw new Error('The propertyKey is missing for the event decorator.');\n }\n\n if (!eventConfig || !eventConfig.name) {\n throw new Error('Invalid eventConfig provided.');\n }\n\n const uniqueKey = Symbol(eventConfig.name);\n\n Object.defineProperty(target, propertyKey, {\n get() {\n const emittersMap: Map<symbol, EventEmitter> = eventEmitters.get(this) || new Map();\n if (!emittersMap.has(uniqueKey)) {\n emittersMap.set(uniqueKey, new EventEmitter(this, eventConfig));\n eventEmitters.set(this, emittersMap);\n }\n\n return emittersMap.get(uniqueKey);\n },\n });\n };\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "+
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "+CAUO,SAAS,CAAK,CAAC,EAAiC,CACrD,MAAO,CAAC,EAAa,IAAwB,CAC3C,IAAK,EACH,MAAM,IAAI,MAAM,qDAAqD,EAGvE,IAAK,IAAgB,EAAY,KAC/B,MAAM,IAAI,MAAM,+BAA+B,EAGjD,MAAM,EAAY,OAAO,EAAY,IAAI,EAEzC,OAAO,eAAe,EAAQ,EAAa,CACzC,GAAG,EAAG,CACJ,MAAM,EAAyC,EAAc,IAAI,IAAI,GAAK,IAAI,IAC9E,IAAK,EAAY,IAAI,CAAS,EAC5B,EAAY,IAAI,EAAW,IAAI,EAAa,KAAM,CAAW,CAAC,EAC9D,EAAc,IAAI,KAAM,CAAW,EAGrC,OAAO,EAAY,IAAI,CAAS,EAEpC,CAAC,GA9BL,IAAM,EAAgB,IAAI",
|
|
8
|
+
"debugId": "E335B76426A3F14F64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|