@dooboostore/simple-web-component 1.0.48 → 1.0.49
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/README.md +117 -19
- package/dist/cjs/config/config.js +1 -1
- package/dist/cjs/config/config.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +387 -29
- package/dist/cjs/decorators/addEventListener.js.map +3 -3
- package/dist/cjs/decorators/applyAttribute.js +25 -0
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +49 -18
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +67 -1
- package/dist/cjs/decorators/applyNode.js.map +3 -3
- package/dist/cjs/decorators/applyProperty.js +101 -3
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +36 -5
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +39 -0
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +237 -437
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +55 -0
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +3 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +209 -0
- package/dist/cjs/decorators/intersectionObserver.js.map +7 -0
- package/dist/cjs/decorators/mutationObserver.js +140 -0
- package/dist/cjs/decorators/mutationObserver.js.map +3 -3
- package/dist/cjs/decorators/query.js +117 -102
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/resizeObserver.js +87 -0
- package/dist/cjs/decorators/resizeObserver.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +82 -0
- package/dist/cjs/decorators/setInterval.js.map +7 -0
- package/dist/cjs/decorators/setTimeout.js +82 -0
- package/dist/cjs/decorators/setTimeout.js.map +7 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/config/config.js +1 -1
- package/dist/esm/config/config.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +388 -29
- package/dist/esm/decorators/addEventListener.js.map +3 -3
- package/dist/esm/decorators/applyAttribute.js +25 -0
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +49 -18
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +67 -1
- package/dist/esm/decorators/applyNode.js.map +3 -3
- package/dist/esm/decorators/applyProperty.js +101 -3
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +36 -5
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +40 -0
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +244 -444
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +55 -0
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +3 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +191 -0
- package/dist/esm/decorators/intersectionObserver.js.map +7 -0
- package/dist/esm/decorators/mutationObserver.js +141 -0
- package/dist/esm/decorators/mutationObserver.js.map +3 -3
- package/dist/esm/decorators/query.js +117 -102
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/resizeObserver.js +88 -0
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +64 -0
- package/dist/esm/decorators/setInterval.js.map +7 -0
- package/dist/esm/decorators/setTimeout.js +64 -0
- package/dist/esm/decorators/setTimeout.js.map +7 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2565 -1474
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/config/config.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +84 -33
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +22 -34
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +34 -34
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +30 -20
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +57 -34
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +25 -12
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts +11 -0
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts +0 -14
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +28 -4
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +3 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +49 -0
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -0
- package/dist/types/decorators/mutationObserver.d.ts +35 -25
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +57 -14
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/resizeObserver.d.ts +34 -23
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +29 -0
- package/dist/types/decorators/setInterval.d.ts.map +1 -0
- package/dist/types/decorators/setTimeout.d.ts +29 -0
- package/dist/types/decorators/setTimeout.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +7 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +6 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +104 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2565 -1474
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +7 -5
- package/src/config/config.ts +1 -1
- package/src/decorators/addEventListener.ts +394 -34
- package/src/decorators/applyAttribute.ts +50 -36
- package/src/decorators/applyClass.ts +76 -26
- package/src/decorators/applyNode.ts +114 -36
- package/src/decorators/applyProperty.ts +152 -40
- package/src/decorators/applyStyle.ts +64 -17
- package/src/decorators/changedAttribute.ts +46 -0
- package/src/decorators/elementDefine.ts +281 -580
- package/src/decorators/emitCustomEvent.ts +73 -5
- package/src/decorators/index.ts +3 -1
- package/src/decorators/intersectionObserver.ts +259 -0
- package/src/decorators/mutationObserver.ts +215 -39
- package/src/decorators/query.ts +168 -126
- package/src/decorators/resizeObserver.ts +152 -46
- package/src/decorators/setInterval.ts +80 -0
- package/src/decorators/setTimeout.ts +80 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +17 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +19 -0
- package/src/types/index.ts +141 -0
- package/dist/cjs/decorators/queryAll.js +0 -181
- package/dist/cjs/decorators/queryAll.js.map +0 -7
- package/dist/esm/decorators/queryAll.js +0 -162
- package/dist/esm/decorators/queryAll.js.map +0 -7
- package/dist/types/decorators/queryAll.d.ts +0 -22
- package/dist/types/decorators/queryAll.d.ts.map +0 -1
- package/src/decorators/queryAll.ts +0 -186
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import { ReflectUtils } from "@dooboostore/core";
|
|
2
5
|
const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
|
|
3
6
|
function addEventListener(selectorOrType, typeOrOptions, maybeOptions) {
|
|
4
7
|
return (targetObj, propertyKey, descriptor) => {
|
|
5
8
|
let selector;
|
|
6
|
-
let
|
|
9
|
+
let types;
|
|
7
10
|
let opts = {};
|
|
8
|
-
if (typeof typeOrOptions === "string") {
|
|
11
|
+
if (typeof typeOrOptions === "string" || Array.isArray(typeOrOptions)) {
|
|
9
12
|
selector = selectorOrType;
|
|
10
|
-
|
|
13
|
+
types = Array.isArray(typeOrOptions) ? typeOrOptions : [typeOrOptions];
|
|
11
14
|
opts = maybeOptions ?? {};
|
|
12
15
|
} else {
|
|
13
16
|
selector = "$this";
|
|
14
|
-
|
|
17
|
+
if (Array.isArray(selectorOrType)) types = selectorOrType;
|
|
18
|
+
else types = [selectorOrType];
|
|
15
19
|
opts = typeOrOptions ?? {};
|
|
16
20
|
}
|
|
17
21
|
const constructor = targetObj.constructor;
|
|
@@ -20,28 +24,40 @@ function addEventListener(selectorOrType, typeOrOptions, maybeOptions) {
|
|
|
20
24
|
listeners = [];
|
|
21
25
|
ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);
|
|
22
26
|
}
|
|
23
|
-
listeners.push({ propertyKey, selector, type, options: opts });
|
|
27
|
+
for (const type of types) listeners.push({ propertyKey, selector, type, options: opts });
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
|
-
function
|
|
30
|
+
function addEventListenerDelegateLight(selector, type, options) {
|
|
27
31
|
return addEventListener(selector, type, { ...options ?? {}, root: "light", delegate: true });
|
|
28
32
|
}
|
|
29
|
-
function
|
|
33
|
+
function addEventListenerDelegateShadow(selector, type, options) {
|
|
30
34
|
return addEventListener(selector, type, { ...options ?? {}, root: "shadow", delegate: true });
|
|
31
35
|
}
|
|
32
|
-
function
|
|
36
|
+
function addEventListenerDelegateAll(selector, type, options) {
|
|
33
37
|
return addEventListener(selector, type, { ...options ?? {}, root: "all", delegate: true });
|
|
34
38
|
}
|
|
35
39
|
function addEventListenerDelegate(selector, type, options) {
|
|
36
40
|
return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
|
|
37
41
|
}
|
|
38
|
-
function
|
|
42
|
+
function addEventListenerMutationLight(selector, type, options) {
|
|
43
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "light", delegate: "mutation" });
|
|
44
|
+
}
|
|
45
|
+
function addEventListenerMutationShadow(selector, type, options) {
|
|
46
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "shadow", delegate: "mutation" });
|
|
47
|
+
}
|
|
48
|
+
function addEventListenerMutationAll(selector, type, options) {
|
|
49
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "all", delegate: "mutation" });
|
|
50
|
+
}
|
|
51
|
+
function addEventListenerMutation(selector, type, options) {
|
|
52
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: "mutation" });
|
|
53
|
+
}
|
|
54
|
+
function addEventListenerLight(selector, type, options) {
|
|
39
55
|
return addEventListener(selector, type, { ...options ?? {}, root: "light" });
|
|
40
56
|
}
|
|
41
|
-
function
|
|
57
|
+
function addEventListenerShadow(selector, type, options) {
|
|
42
58
|
return addEventListener(selector, type, { ...options ?? {}, root: "shadow" });
|
|
43
59
|
}
|
|
44
|
-
function
|
|
60
|
+
function addEventListenerAll(selector, type, options) {
|
|
45
61
|
return addEventListener(selector, type, { ...options ?? {}, root: "all" });
|
|
46
62
|
}
|
|
47
63
|
function addEventListenerThis(type, options) {
|
|
@@ -57,13 +73,17 @@ function addEventListenerDocument(type, options) {
|
|
|
57
73
|
return addEventListener("$document", type, options);
|
|
58
74
|
}
|
|
59
75
|
const event = addEventListener;
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
76
|
+
const eventDelegateLight = addEventListenerDelegateLight;
|
|
77
|
+
const eventDelegateShadow = addEventListenerDelegateShadow;
|
|
78
|
+
const eventDelegateAll = addEventListenerDelegateAll;
|
|
63
79
|
const eventDelegate = addEventListenerDelegate;
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
80
|
+
const eventMutationLight = addEventListenerMutationLight;
|
|
81
|
+
const eventMutationShadow = addEventListenerMutationShadow;
|
|
82
|
+
const eventMutationAll = addEventListenerMutationAll;
|
|
83
|
+
const eventMutation = addEventListenerMutation;
|
|
84
|
+
const eventLight = addEventListenerLight;
|
|
85
|
+
const eventShadow = addEventListenerShadow;
|
|
86
|
+
const eventAll = addEventListenerAll;
|
|
67
87
|
const eventAppHost = addEventListenerAppHost;
|
|
68
88
|
const eventWindow = addEventListenerWindow;
|
|
69
89
|
const eventDocument = addEventListenerDocument;
|
|
@@ -72,30 +92,369 @@ const getAddEventListenerMetadata = (target) => {
|
|
|
72
92
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
73
93
|
return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
|
|
74
94
|
};
|
|
95
|
+
import { Subject } from "@dooboostore/core";
|
|
96
|
+
import { debounceTime, distinctUntilChanged, throttleTime } from "@dooboostore/core/message/operators";
|
|
97
|
+
import { SwcUtils } from "../utils/Utils.js";
|
|
98
|
+
class EventListenerLifeCycler {
|
|
99
|
+
constructor() {
|
|
100
|
+
/** 인스턴스별 boundListeners 상태 (시클러는 elementDefine 시 1회 생성되어 공유되므로) */
|
|
101
|
+
__publicField(this, "boundListenersMap", /* @__PURE__ */ new WeakMap());
|
|
102
|
+
/** 인스턴스별 delegate:'mutation' 바인딩 추적 WeakSet — MutationObserverLifeCycler 에서 참조 */
|
|
103
|
+
__publicField(this, "eventBoundSetsMap", /* @__PURE__ */ new WeakMap());
|
|
104
|
+
}
|
|
105
|
+
// ── 외부(MutationObserverLifeCycler)에서 직접 사용하는 공개 헬퍼 ──
|
|
106
|
+
/** 인스턴스별 boundListeners 를 반환한다 (없으면 생성). */
|
|
107
|
+
getBoundListeners(inst) {
|
|
108
|
+
let list = this.boundListenersMap.get(inst);
|
|
109
|
+
if (!list) {
|
|
110
|
+
list = [];
|
|
111
|
+
this.boundListenersMap.set(inst, list);
|
|
112
|
+
}
|
|
113
|
+
return list;
|
|
114
|
+
}
|
|
115
|
+
/** 인스턴스별 eventBoundSets 를 반환한다 (없으면 생성). */
|
|
116
|
+
getEventBoundSets(inst) {
|
|
117
|
+
let map = this.eventBoundSetsMap.get(inst);
|
|
118
|
+
if (!map) {
|
|
119
|
+
map = /* @__PURE__ */ new Map();
|
|
120
|
+
this.eventBoundSetsMap.set(inst, map);
|
|
121
|
+
}
|
|
122
|
+
return map;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* target 에 meta 이벤트를 직접 바인딩한다.
|
|
126
|
+
* delegate:'mutation' 초기/동적 바인딩에서 호출된다.
|
|
127
|
+
*/
|
|
128
|
+
bindDirect(helperHostSet, target, meta) {
|
|
129
|
+
const inst = helperHostSet.$this;
|
|
130
|
+
const currentWin = helperHostSet.$w;
|
|
131
|
+
const { type, options } = meta;
|
|
132
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
133
|
+
const handler = async (event2) => {
|
|
134
|
+
if (options.filter) {
|
|
135
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, target);
|
|
136
|
+
if (!options.filter(event2, { currentThis: inst, helper })) return;
|
|
137
|
+
}
|
|
138
|
+
if (options.stopPropagation) event2.stopPropagation();
|
|
139
|
+
if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
140
|
+
if (options.preventDefault) event2.preventDefault();
|
|
141
|
+
const currentHostSet = SwcUtils.getHostSet(inst);
|
|
142
|
+
await inst[meta.propertyKey](event2, { currentHostSet, $matchedElement: event2.currentTarget }, { event: event2, ...currentHostSet, $el: target, $root: target });
|
|
143
|
+
};
|
|
144
|
+
const eventSubject = new Subject();
|
|
145
|
+
let eventStream = eventSubject;
|
|
146
|
+
if (options.debounceTime && options.debounceTime > 0)
|
|
147
|
+
eventStream = eventStream.pipe(debounceTime(options.debounceTime));
|
|
148
|
+
if (options.throttleTime && options.throttleTime > 0)
|
|
149
|
+
eventStream = eventStream.pipe(throttleTime(options.throttleTime));
|
|
150
|
+
if (options.distinctUntilChanged !== void 0 && options.distinctUntilChanged !== false) {
|
|
151
|
+
eventStream = typeof options.distinctUntilChanged === "function" ? eventStream.pipe(distinctUntilChanged(options.distinctUntilChanged)) : eventStream.pipe(distinctUntilChanged());
|
|
152
|
+
}
|
|
153
|
+
const subscription = eventStream.subscribe({
|
|
154
|
+
next: (e) => handler(e).catch((err) => console.error("Event handler error:", err)),
|
|
155
|
+
error: (err) => console.error("Event stream error:", err)
|
|
156
|
+
});
|
|
157
|
+
const wrappedHandler = (event2) => eventSubject.next(event2);
|
|
158
|
+
target.addEventListener(type, wrappedHandler, opts);
|
|
159
|
+
const onRemoves = options.removeListener ? [{ fn: options.removeListener, opts: options }] : [];
|
|
160
|
+
this.getBoundListeners(inst).push({ target, type, handler: wrappedHandler, options: opts, subscription, onRemoves, meta });
|
|
161
|
+
}
|
|
162
|
+
/** target + meta 조합 리스너를 제거한다. MutationObserver 추적 요소 제거 시 호출. */
|
|
163
|
+
unbindDirect(helperHostSet, target, meta) {
|
|
164
|
+
const inst = helperHostSet.$this;
|
|
165
|
+
const list = this.getBoundListeners(inst);
|
|
166
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
167
|
+
const l = list[i];
|
|
168
|
+
if (l.target === target && l.type === meta.type && l.meta === meta) {
|
|
169
|
+
try {
|
|
170
|
+
l.target.removeEventListener(l.type, l.handler, l.options);
|
|
171
|
+
l.subscription?.unsubscribe?.();
|
|
172
|
+
} catch (e) {
|
|
173
|
+
console.error("[SWC] unbindDirect error:", e);
|
|
174
|
+
}
|
|
175
|
+
for (const r of l.onRemoves ?? []) {
|
|
176
|
+
try {
|
|
177
|
+
r.fn(l.target, r.opts);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
console.error("[SWC] unbindDirect removeListener error:", e);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
list.splice(i, 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 메타데이터 목록을 delegate / mutationDelegate / nonDelegate 로 분류한다.
|
|
188
|
+
* MutationObserverLifeCycler 에서 mutationDelegate 목록을 꺼낼 때 사용한다.
|
|
189
|
+
*/
|
|
190
|
+
classifyListeners(metaList) {
|
|
191
|
+
const isSpecial = (sel) => [
|
|
192
|
+
"$window",
|
|
193
|
+
"$document",
|
|
194
|
+
"$host",
|
|
195
|
+
"$appHost",
|
|
196
|
+
"$firstHost",
|
|
197
|
+
"$lastHost",
|
|
198
|
+
"$firstAppHost",
|
|
199
|
+
"$lastAppHost",
|
|
200
|
+
"$hosts",
|
|
201
|
+
"$appHosts",
|
|
202
|
+
"$this",
|
|
203
|
+
""
|
|
204
|
+
].includes(sel);
|
|
205
|
+
const delegateListeners = [];
|
|
206
|
+
const mutationDelegateListeners = [];
|
|
207
|
+
const nonDelegateListeners = [];
|
|
208
|
+
for (const meta of metaList) {
|
|
209
|
+
const isStr = typeof meta.selector === "string";
|
|
210
|
+
const mode = meta.options.delegate;
|
|
211
|
+
if (mode && isStr && !isSpecial(meta.selector)) {
|
|
212
|
+
mode === "mutation" ? mutationDelegateListeners.push(meta) : delegateListeners.push(meta);
|
|
213
|
+
} else {
|
|
214
|
+
nonDelegateListeners.push(meta);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return { delegateListeners, mutationDelegateListeners, nonDelegateListeners };
|
|
218
|
+
}
|
|
219
|
+
// ── ElementDefineLifeCycler 구현 ──
|
|
220
|
+
onConnected(helperHostSet) {
|
|
221
|
+
const inst = helperHostSet.$this;
|
|
222
|
+
const currentWin = helperHostSet.$w;
|
|
223
|
+
this.boundListenersMap.delete(inst);
|
|
224
|
+
this.eventBoundSetsMap.delete(inst);
|
|
225
|
+
const allMeta = getAddEventListenerMetadata(inst) ?? [];
|
|
226
|
+
const { delegateListeners, nonDelegateListeners, mutationDelegateListeners } = this.classifyListeners(allMeta);
|
|
227
|
+
const groups = /* @__PURE__ */ new Map();
|
|
228
|
+
for (const meta of delegateListeners) {
|
|
229
|
+
const key = `${meta.type}:${meta.options.root || "auto"}`;
|
|
230
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
231
|
+
groups.get(key).push(meta);
|
|
232
|
+
}
|
|
233
|
+
groups.forEach((metaList, key) => {
|
|
234
|
+
const ci = key.indexOf(":");
|
|
235
|
+
const type = key.slice(0, ci);
|
|
236
|
+
const r = key.slice(ci + 1);
|
|
237
|
+
const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
|
|
238
|
+
const roots = [];
|
|
239
|
+
if (r === "auto") roots.push(inst.shadowRoot || inst);
|
|
240
|
+
else if (r === "light") roots.push(inst);
|
|
241
|
+
else if (r === "shadow" && inst.shadowRoot) roots.push(inst.shadowRoot);
|
|
242
|
+
else if (r === "all") {
|
|
243
|
+
roots.push(inst);
|
|
244
|
+
if (inst.shadowRoot) roots.push(inst.shadowRoot);
|
|
245
|
+
}
|
|
246
|
+
for (const br of roots) {
|
|
247
|
+
const sorted = [...metaList].sort((a, b) => (b.options.stopPropagation ? 1 : 0) - (a.options.stopPropagation ? 1 : 0));
|
|
248
|
+
const handler = async (event2) => {
|
|
249
|
+
for (const m of sorted) {
|
|
250
|
+
const matchedEl = event2.target?.closest(m.selector);
|
|
251
|
+
console.log("[DBG][delegate] type=", event2.type, "| evtTarget=", event2.target?.tagName, "| sel=", m.selector, "| matchedEl=", matchedEl?.className || matchedEl?.tagName, "| brContains=", br.contains?.(matchedEl), "| brTag=", br.tagName || br.constructor?.name);
|
|
252
|
+
if (matchedEl && br.contains(matchedEl)) {
|
|
253
|
+
if (m.options.filter) {
|
|
254
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
255
|
+
if (!m.options.filter(event2, { currentThis: inst, helper })) continue;
|
|
256
|
+
}
|
|
257
|
+
if (m.options.stopPropagation) event2.stopPropagation();
|
|
258
|
+
if (m.options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
259
|
+
if (m.options.preventDefault) event2.preventDefault();
|
|
260
|
+
const hs = SwcUtils.getHostSet(inst);
|
|
261
|
+
await inst[m.propertyKey](event2, { ...hs, $matchedElement: matchedEl }, { event: event2, ...hs, $el: matchedEl, $root: br });
|
|
262
|
+
if (event2.cancelBubble) break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
br.addEventListener(type, handler, opts);
|
|
267
|
+
if (type === "click") {
|
|
268
|
+
console.log("[DBG][eventCycler] bound click on br=", br.tagName || br.constructor?.name, "| inst=", inst.tagName || inst.constructor?.name, "| isSame=", br === inst);
|
|
269
|
+
}
|
|
270
|
+
const onRemoves = sorted.filter((m) => m.options.removeListener).map((m) => ({ fn: m.options.removeListener, opts: m.options }));
|
|
271
|
+
this.getBoundListeners(inst).push({ target: br, type, handler, options: opts, onRemoves });
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
for (const meta of nonDelegateListeners) {
|
|
275
|
+
const { selector, options } = meta;
|
|
276
|
+
const r = options.root || "auto";
|
|
277
|
+
const bindTargets = [];
|
|
278
|
+
let resolvedSel = null;
|
|
279
|
+
if (typeof selector === "function") {
|
|
280
|
+
const result = selector(inst, helperHostSet);
|
|
281
|
+
if (typeof result === "string") resolvedSel = result;
|
|
282
|
+
else if (result instanceof currentWin.Element) bindTargets.push(result);
|
|
283
|
+
else if (result instanceof currentWin.NodeList) bindTargets.push(...Array.from(result));
|
|
284
|
+
else if (Array.isArray(result)) bindTargets.push(...result);
|
|
285
|
+
} else {
|
|
286
|
+
resolvedSel = selector;
|
|
287
|
+
}
|
|
288
|
+
const applyRoot = (t) => {
|
|
289
|
+
if (!t) return;
|
|
290
|
+
if (r === "auto") bindTargets.push(t.shadowRoot || t);
|
|
291
|
+
else {
|
|
292
|
+
if (r === "light" || r === "all") bindTargets.push(t);
|
|
293
|
+
if ((r === "shadow" || r === "all") && t.shadowRoot) bindTargets.push(t.shadowRoot);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
if (resolvedSel) {
|
|
297
|
+
if (resolvedSel === "$window") bindTargets.push(currentWin);
|
|
298
|
+
else if (resolvedSel === "$document") bindTargets.push(currentWin.document);
|
|
299
|
+
else if (resolvedSel === "$host") applyRoot(helperHostSet.$host);
|
|
300
|
+
else if (resolvedSel === "$parentHost") applyRoot(helperHostSet.$parentHost);
|
|
301
|
+
else if (resolvedSel === "$appHost") applyRoot(helperHostSet.$appHost);
|
|
302
|
+
else if (resolvedSel === "$firstHost") applyRoot(helperHostSet.$firstHost);
|
|
303
|
+
else if (resolvedSel === "$lastHost") applyRoot(helperHostSet.$lastHost);
|
|
304
|
+
else if (resolvedSel === "$firstAppHost") applyRoot(helperHostSet.$firstAppHost);
|
|
305
|
+
else if (resolvedSel === "$lastAppHost") applyRoot(helperHostSet.$lastAppHost);
|
|
306
|
+
else if (resolvedSel === "$hosts") helperHostSet.$hosts.forEach(applyRoot);
|
|
307
|
+
else if (resolvedSel === "$appHosts") helperHostSet.$appHosts.forEach(applyRoot);
|
|
308
|
+
else if (resolvedSel === "$this" || !resolvedSel) applyRoot(inst);
|
|
309
|
+
else {
|
|
310
|
+
const searchRoots = [];
|
|
311
|
+
if (r === "auto") searchRoots.push(inst.shadowRoot || inst);
|
|
312
|
+
else if (r === "light") searchRoots.push(inst);
|
|
313
|
+
else if (r === "shadow" && inst.shadowRoot) searchRoots.push(inst.shadowRoot);
|
|
314
|
+
else if (r === "all") {
|
|
315
|
+
searchRoots.push(inst);
|
|
316
|
+
if (inst.shadowRoot) searchRoots.push(inst.shadowRoot);
|
|
317
|
+
}
|
|
318
|
+
for (const sr of searchRoots) sr.querySelectorAll(resolvedSel).forEach((el) => bindTargets.push(el));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
for (const t of bindTargets) this.bindDirect(helperHostSet, t, meta);
|
|
322
|
+
}
|
|
323
|
+
if (mutationDelegateListeners.length > 0) {
|
|
324
|
+
const shadowEventDelegates = mutationDelegateListeners.filter((m) => {
|
|
325
|
+
const r = m.options.root || "auto";
|
|
326
|
+
return inst.shadowRoot && (r === "shadow" || r === "all" || r === "auto");
|
|
327
|
+
});
|
|
328
|
+
const lightEventDelegates = mutationDelegateListeners.filter((m) => {
|
|
329
|
+
const r = m.options.root || "auto";
|
|
330
|
+
return r === "light" || r === "all" || !inst.shadowRoot && r === "auto";
|
|
331
|
+
});
|
|
332
|
+
const buildMutationEntry = (root, eventDelegates) => {
|
|
333
|
+
if (eventDelegates.length === 0) return null;
|
|
334
|
+
const boundSets = this.getEventBoundSets(inst);
|
|
335
|
+
const callback = (mutations, obs) => {
|
|
336
|
+
for (const m of eventDelegates) {
|
|
337
|
+
let boundSet = boundSets.get(m);
|
|
338
|
+
if (!boundSet) {
|
|
339
|
+
boundSet = /* @__PURE__ */ new WeakSet();
|
|
340
|
+
boundSets.set(m, boundSet);
|
|
341
|
+
}
|
|
342
|
+
const isThis = m.selector === "$this" || m.selector === "";
|
|
343
|
+
const matchesSel = (n) => {
|
|
344
|
+
if (!n || n.nodeType !== 1) return false;
|
|
345
|
+
if (isThis) return true;
|
|
346
|
+
return typeof m.selector === "string" && n.matches?.(m.selector);
|
|
347
|
+
};
|
|
348
|
+
const bindEl = (el) => {
|
|
349
|
+
if (!boundSet.has(el)) {
|
|
350
|
+
this.bindDirect(helperHostSet, el, m);
|
|
351
|
+
boundSet.add(el);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const unbindEl = (el) => {
|
|
355
|
+
if (boundSet.has(el)) {
|
|
356
|
+
this.unbindDirect(helperHostSet, el, m);
|
|
357
|
+
boundSet.delete(el);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
for (const mut of mutations) {
|
|
361
|
+
Array.from(mut.addedNodes || []).forEach((n) => {
|
|
362
|
+
if (n.nodeType !== 1) return;
|
|
363
|
+
if (matchesSel(n)) bindEl(n);
|
|
364
|
+
else if (!isThis && typeof m.selector === "string") n.querySelectorAll?.(m.selector).forEach(bindEl);
|
|
365
|
+
});
|
|
366
|
+
Array.from(mut.removedNodes || []).forEach((n) => {
|
|
367
|
+
if (n.nodeType !== 1) return;
|
|
368
|
+
const el = n;
|
|
369
|
+
if (matchesSel(el)) unbindEl(el);
|
|
370
|
+
else if (!isThis && typeof m.selector === "string") el.querySelectorAll?.(m.selector).forEach(unbindEl);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
for (const m of eventDelegates) {
|
|
376
|
+
let boundSet = boundSets.get(m);
|
|
377
|
+
if (!boundSet) {
|
|
378
|
+
boundSet = /* @__PURE__ */ new WeakSet();
|
|
379
|
+
boundSets.set(m, boundSet);
|
|
380
|
+
}
|
|
381
|
+
if (typeof m.selector !== "string") continue;
|
|
382
|
+
if (m.selector === "$this" || m.selector === "") {
|
|
383
|
+
this.bindDirect(helperHostSet, root, m);
|
|
384
|
+
boundSet.add(root);
|
|
385
|
+
} else {
|
|
386
|
+
root.querySelectorAll(m.selector).forEach((el) => {
|
|
387
|
+
if (!boundSet.has(el)) {
|
|
388
|
+
this.bindDirect(helperHostSet, el, m);
|
|
389
|
+
boundSet.add(el);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return { target: root, options: { childList: true, subtree: true }, callback };
|
|
395
|
+
};
|
|
396
|
+
const shadowEntry = inst.shadowRoot ? buildMutationEntry(inst.shadowRoot, shadowEventDelegates) : null;
|
|
397
|
+
const lightEntry = buildMutationEntry(inst, lightEventDelegates);
|
|
398
|
+
const mutationObserverSet = [shadowEntry, lightEntry].filter(Boolean);
|
|
399
|
+
if (mutationObserverSet.length > 0) return { mutationObserverSet };
|
|
400
|
+
}
|
|
401
|
+
return void 0;
|
|
402
|
+
}
|
|
403
|
+
onDisconnected(helperHostSet) {
|
|
404
|
+
const inst = helperHostSet.$this;
|
|
405
|
+
const list = this.boundListenersMap.get(inst) ?? [];
|
|
406
|
+
for (const l of list) {
|
|
407
|
+
try {
|
|
408
|
+
l.target.removeEventListener(l.type, l.handler, l.options);
|
|
409
|
+
l.subscription?.unsubscribe?.();
|
|
410
|
+
} catch (e) {
|
|
411
|
+
console.error("[SWC] EventListenerLifeCycler cleanup error:", e);
|
|
412
|
+
}
|
|
413
|
+
for (const r of l.onRemoves ?? []) {
|
|
414
|
+
try {
|
|
415
|
+
r.fn(l.target, r.opts);
|
|
416
|
+
} catch (e) {
|
|
417
|
+
console.error("[SWC] removeListener error:", e);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
this.boundListenersMap.delete(inst);
|
|
422
|
+
this.eventBoundSetsMap.delete(inst);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
75
425
|
export {
|
|
76
426
|
ADD_EVENT_LISTENER_METADATA_KEY,
|
|
427
|
+
EventListenerLifeCycler,
|
|
77
428
|
addEventListener,
|
|
78
|
-
|
|
429
|
+
addEventListenerAll,
|
|
79
430
|
addEventListenerAppHost,
|
|
80
431
|
addEventListenerDelegate,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
432
|
+
addEventListenerDelegateAll,
|
|
433
|
+
addEventListenerDelegateLight,
|
|
434
|
+
addEventListenerDelegateShadow,
|
|
84
435
|
addEventListenerDocument,
|
|
85
|
-
|
|
86
|
-
|
|
436
|
+
addEventListenerLight,
|
|
437
|
+
addEventListenerMutation,
|
|
438
|
+
addEventListenerMutationAll,
|
|
439
|
+
addEventListenerMutationLight,
|
|
440
|
+
addEventListenerMutationShadow,
|
|
441
|
+
addEventListenerShadow,
|
|
87
442
|
addEventListenerThis,
|
|
88
443
|
addEventListenerWindow,
|
|
89
444
|
event,
|
|
90
|
-
|
|
445
|
+
eventAll,
|
|
91
446
|
eventAppHost,
|
|
92
447
|
eventDelegate,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
448
|
+
eventDelegateAll,
|
|
449
|
+
eventDelegateLight,
|
|
450
|
+
eventDelegateShadow,
|
|
96
451
|
eventDocument,
|
|
97
|
-
|
|
98
|
-
|
|
452
|
+
eventLight,
|
|
453
|
+
eventMutation,
|
|
454
|
+
eventMutationAll,
|
|
455
|
+
eventMutationLight,
|
|
456
|
+
eventMutationShadow,
|
|
457
|
+
eventShadow,
|
|
99
458
|
eventThis,
|
|
100
459
|
eventWindow,
|
|
101
460
|
getAddEventListenerMetadata
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/addEventListener.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface AddEventListenerBaseOptions<TEvent extends Event = Event> extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n // removeOnDisconnected?: boolean;\n delegate?: boolean;\n filter?: (target: Event | CustomEvent, meta:{currentThis: any, helper: HelperHostSet}) => boolean;\n // \uB9AC\uC2A4\uB108 \uC81C\uAC70(disconnected \uB610\uB294 unmount) \uC2DC \uD638\uCD9C\uB418\uB294 \uCF5C\uBC31. \uCCAB \uBC88\uC9F8 \uC778\uC790\uB294 \uBC14\uC778\uB529\uB41C \uD0C0\uAC9F element, \uB450 \uBC88\uC9F8\uB294 \uC774 \uC635\uC158\uC774 \uC18D\uD55C \uC804\uCCB4 \uC635\uC158 \uAC1D\uCCB4(Base + SwcQuery + delegate).\n removeListener?: (target: Element, optionValue: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean }) => void;\n // RxJS operator options\n debounceTime?: number;\n throttleTime?: number;\n distinctUntilChanged?: boolean | ((prev: TEvent, curr: TEvent) => boolean);\n}\n\nexport type EventListenerSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface AddEventListenerMetadata<TEvent extends Event = Event> {\n propertyKey: string | symbol;\n selector: EventListenerSelector;\n type: string;\n options: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:add-event-listener');\n\nexport function addEventListener<TEvent extends Event = Event>(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions<TEvent>): MethodDecorator;\nexport function addEventListener<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener(type, options?) \u2014 \uC140\uB809\uD130 \uC0DD\uB7B5 \uC2DC $this(\uCEF4\uD3EC\uB10C\uD2B8 \uC790\uC2E0)\uB85C \uBC14\uC778\uB529\n */\nexport function addEventListener<TEvent extends Event = Event>(type: string, options?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener<TEvent extends Event = Event>(selectorOrType: EventListenerSelector | string, typeOrOptions?: string | (AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean }), maybeOptions?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean }): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n let selector: EventListenerSelector;\n let type: string;\n let opts: any = {};\n\n if (typeof typeOrOptions === 'string') {\n // (selector, type[, options]) form \u2014 \uAE30\uC874 \uD638\uD658\n selector = selectorOrType as EventListenerSelector;\n type = typeOrOptions;\n opts = maybeOptions ?? {};\n } else {\n // (type[, options]) form \u2014 selector \uAE30\uBCF8\uAC12 $this\n selector = '$this';\n type = selectorOrType as string;\n opts = typeOrOptions ?? {};\n }\n\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata<TEvent>[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector, type, options: opts });\n };\n}\n\n\nexport function addEventListenerDelegateLightDom<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: Omit<AddEventListenerBaseOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'light', delegate: true});\n}\n\nexport function addEventListenerDelegateShadowDom<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: Omit<AddEventListenerBaseOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'shadow', delegate: true});\n}\nexport function addEventListenerDelegateAllDom<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: Omit<AddEventListenerBaseOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'all', delegate: true});\n}\nexport function addEventListenerDelegate<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: Omit<AddEventListenerBaseOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'auto', delegate: true});\n}\n\n// \u2500\u2500\u2500 root\uBCC4 \uC77C\uBC18 \uD5EC\uD37C (delegate \uC5C6\uC74C) \u2500\u2500\u2500\n\nexport function addEventListenerLightDom<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: AddEventListenerBaseOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'light'});\n}\n\nexport function addEventListenerShadowDom<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: AddEventListenerBaseOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'shadow'});\n}\n\nexport function addEventListenerAllDom<TEvent extends Event = Event>(selector: EventListenerSelector, type: string, options?: AddEventListenerBaseOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'all'});\n}\n\n/**\n * @addEventListenerThis decorator - simplified version of @addEventListener for $this selector\n */\nexport function addEventListenerThis<TEvent extends Event = Event>(type: string, options?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions): MethodDecorator {\n return addEventListener<TEvent>('$this', type, options);\n}\n\n/**\n * @addEventListenerAppHost decorator - simplified version of @addEventListener for $appHost selector\n */\nexport function addEventListenerAppHost<TEvent extends Event = Event>(type: string, options?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions): MethodDecorator {\n return addEventListener<TEvent>('$appHost', type, options);\n}\n\nexport function addEventListenerWindow<TEvent extends Event = Event>(type: string, options?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions): MethodDecorator {\n return addEventListener<TEvent>('$window', type, options);\n}\nexport function addEventListenerDocument<TEvent extends Event = Event>(type: string, options?: AddEventListenerBaseOptions<TEvent> & SwcQueryOptions): MethodDecorator {\n return addEventListener<TEvent>('$document', type, options);\n}\n\n// --- Aliases: event... ---\nexport const event = addEventListener;\nexport const eventDelegateLightDom = addEventListenerDelegateLightDom;\nexport const eventDelegateShadowDom = addEventListenerDelegateShadowDom;\nexport const eventDelegateAllDom = addEventListenerDelegateAllDom;\nexport const eventDelegate = addEventListenerDelegate;\nexport const eventLightDom = addEventListenerLightDom;\nexport const eventShadowDom = addEventListenerShadowDom;\nexport const eventAllDom = addEventListenerAllDom;\nexport const eventAppHost = addEventListenerAppHost;\nexport const eventWindow = addEventListenerWindow;\nexport const eventDocument = addEventListenerDocument;\nexport const eventThis = addEventListenerThis;\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata<Event>[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AA8BtB,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAW5F,SAAS,iBAA+C,gBAAgD,eAA2G,cAAgH;AACxU,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,QAAI;AACJ,QAAI;AACJ,QAAI,OAAY,CAAC;AAEjB,QAAI,OAAO,kBAAkB,UAAU;AAErC,iBAAW;AACX,aAAO;AACP,aAAO,gBAAgB,CAAC;AAAA,IAC1B,OAAO;AAEL,iBAAW;AACX,aAAO;AACP,aAAO,iBAAiB,CAAC;AAAA,IAC3B;AAEA,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,aAAa,YAAgD,iCAAiC,WAAW;AACzH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,mBAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,MAAM,SAAS,KAAK,CAAC;AAAA,EAC/D;AACF;AAGO,SAAS,iCAA+D,UAAiC,MAAc,SAAkF;AAC9M,SAAO,iBAAyB,UAAU,MA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AC9B,MAAM,yBAAyB;AAC/B,MAAM,sBAAsB;AAC5B,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,gBAAgB;AACtB,MAAM,YAAY;AAElB,MAAM,8BAA8B,CAAC,WAA+D;AACzG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,iCAAiC,WAAW;AAC9E;",
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet, SwcFnSelector, SwcSelector } from '../types';\n\nexport interface AddEventListenerBaseOptions<TEvent extends Event = Event> extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n // removeOnDisconnected?: boolean;\n // delegate\uB294 \uBB38\uC790\uC5F4 \uC140\uB809\uD130 \uC804\uC6A9 \u2192 AddEventListenerQueryOptions\uC5D0\uB9CC \uC874\uC7AC\n filter?: (target: Event | CustomEvent, meta:{currentThis: any, helper: HelperHostSet}) => boolean;\n // \uB9AC\uC2A4\uB108 \uC81C\uAC70(disconnected \uB610\uB294 unmount) \uC2DC \uD638\uCD9C\uB418\uB294 \uCF5C\uBC31. \uCCAB \uBC88\uC9F8 \uC778\uC790\uB294 \uBC14\uC778\uB529\uB41C \uD0C0\uAC9F element, \uB450 \uBC88\uC9F8\uB294 \uC774 \uC635\uC158\uC774 \uC18D\uD55C \uC804\uCCB4 \uC635\uC158 \uAC1D\uCCB4(Base + SwcQuery + delegate).\n removeListener?: (target: Element, optionValue: AddEventListenerQueryOptions<TEvent>) => void;\n // RxJS operator options\n debounceTime?: number;\n throttleTime?: number;\n distinctUntilChanged?: boolean | ((prev: TEvent, curr: TEvent) => boolean);\n}\n\nexport type EventListenerFnSelector = SwcFnSelector;\nexport type EventListenerSelector = SwcSelector;\n\nexport interface AddEventListenerMetadata<TEvent extends Event = Event> {\n propertyKey: string | symbol;\n selector: EventListenerSelector;\n type: string;\n options: AddEventListenerQueryOptions<TEvent>;\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:add-event-listener');\n\n// root + delegate \uD5C8\uC6A9 \u2014 \uBB38\uC790\uC5F4 \uC140\uB809\uD130\uB294 \uCEF4\uD3EC\uB10C\uD2B8 DOM \uD2B8\uB9AC \uC548\uC5D0\uC11C \uD0D0\uC0C9/\uB378\uB9AC\uAC8C\uC774\uC158\uD558\uBBC0\uB85C \uC758\uBBF8 \uC788\uC74C\nexport type AddEventListenerQueryOptions<TEvent extends Event = Event> = AddEventListenerBaseOptions<TEvent> & SwcQueryOptions & { delegate?: boolean | 'this' | 'mutation' };\n// root\u00B7delegate \uBE44\uD5C8\uC6A9 \u2014 \uD568\uC218 \uC140\uB809\uD130\uB294 \uC774\uBBF8 \uC694\uC18C\uB97C \uC9C1\uC811 \uBC18\uD658\uD558\uBBC0\uB85C root\u00B7delegate\uAC00 \uBB34\uC758\uBBF8\uD568\nexport type AddEventListenerNonQueryOptions<TEvent extends Event = Event> = AddEventListenerBaseOptions<TEvent>;\n\n// \uC140\uB809\uD130 \uC885\uB958\uC5D0 \uB530\uB77C \uC635\uC158 \uD0C0\uC785\uC744 \uBD84\uAE30\nexport type AddEventListenerOptionsOf<S extends EventListenerSelector, TEvent extends Event = Event> =\n S extends string ? AddEventListenerQueryOptions<TEvent> : AddEventListenerNonQueryOptions<TEvent>;\n\nexport function addEventListener<TEvent extends Event = Event>(target: SpecialSelector, type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator;\nexport function addEventListener<TEvent extends Event = Event>(selector: string, type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator;\nexport function addEventListener<TEvent extends Event = Event>(selector: string, type: string[], options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator;\nexport function addEventListener<TEvent extends Event = Event>(selector: EventListenerFnSelector, type: string, options?: AddEventListenerNonQueryOptions<TEvent>): MethodDecorator;\n/**\n * @addEventListener(type, options?) \u2014 \uC140\uB809\uD130 \uC0DD\uB7B5 \uC2DC $this(\uCEF4\uD3EC\uB10C\uD2B8 \uC790\uC2E0)\uB85C \uBC14\uC778\uB529\n */\nexport function addEventListener<TEvent extends Event = Event>(type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator;\nexport function addEventListener<TEvent extends Event = Event>(type: string[], options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener<TEvent extends Event = Event>(selectorOrType: EventListenerSelector | string | string[], typeOrOptions?: string | string[] | AddEventListenerQueryOptions<TEvent>, maybeOptions?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n let selector: EventListenerSelector;\n let types: string[];\n let opts: any = {};\n\n if (typeof typeOrOptions === 'string' || Array.isArray(typeOrOptions)) {\n // (selector, type|[types][, options]) form \u2014 \uAE30\uC874 \uD638\uD658\n selector = selectorOrType as EventListenerSelector;\n types = Array.isArray(typeOrOptions) ? typeOrOptions : [typeOrOptions];\n opts = maybeOptions ?? {};\n } else {\n // (type|[types][, options]) form \u2014 selector \uAE30\uBCF8\uAC12 $this\n selector = '$this';\n if (Array.isArray(selectorOrType)) types = selectorOrType;\n else types = [selectorOrType as string];\n opts = typeOrOptions ?? {};\n }\n\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata<TEvent>[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n for (const type of types) listeners.push({ propertyKey, selector, type, options: opts });\n };\n}\n\n\nexport function addEventListenerDelegateLight<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'light', delegate: true});\n}\n\nexport function addEventListenerDelegateShadow<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'shadow', delegate: true});\n}\nexport function addEventListenerDelegateAll<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'all', delegate: true});\n}\nexport function addEventListenerDelegate<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'auto', delegate: true});\n}\n\nexport function addEventListenerMutationLight<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'light', delegate: 'mutation'});\n}\n\nexport function addEventListenerMutationShadow<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'shadow', delegate: 'mutation'});\n}\n\nexport function addEventListenerMutationAll<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'all', delegate: 'mutation'});\n}\n\nexport function addEventListenerMutation<TEvent extends Event = Event>(selector: string, type: string, options?: Omit<AddEventListenerQueryOptions<TEvent>, 'delegate'>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'auto', delegate: 'mutation'});\n}\n\n// \u2500\u2500\u2500 root\uBCC4 \uC77C\uBC18 \uD5EC\uD37C (delegate \uC5C6\uC74C, \uBB38\uC790\uC5F4 \uC140\uB809\uD130 \uC804\uC6A9) \u2500\u2500\u2500\n\nexport function addEventListenerLight<TEvent extends Event = Event>(selector: string, type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'light'});\n}\n\nexport function addEventListenerShadow<TEvent extends Event = Event>(selector: string, type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'shadow'});\n}\n\nexport function addEventListenerAll<TEvent extends Event = Event>(selector: string, type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>(selector, type, {...options??{}, root:'all'});\n}\n\n/**\n * @addEventListenerThis decorator - simplified version of @addEventListener for $this selector\n */\nexport function addEventListenerThis<TEvent extends Event = Event>(type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>('$this', type, options);\n}\n\n/**\n * @addEventListenerAppHost decorator - simplified version of @addEventListener for $appHost selector\n */\nexport function addEventListenerAppHost<TEvent extends Event = Event>(type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>('$appHost', type, options);\n}\n\nexport function addEventListenerWindow<TEvent extends Event = Event>(type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>('$window', type, options);\n}\nexport function addEventListenerDocument<TEvent extends Event = Event>(type: string, options?: AddEventListenerQueryOptions<TEvent>): MethodDecorator {\n return addEventListener<TEvent>('$document', type, options);\n}\n\n// --- Aliases: event... ---\nexport const event = addEventListener;\nexport const eventDelegateLight = addEventListenerDelegateLight;\nexport const eventDelegateShadow = addEventListenerDelegateShadow;\nexport const eventDelegateAll = addEventListenerDelegateAll;\nexport const eventDelegate = addEventListenerDelegate;\nexport const eventMutationLight = addEventListenerMutationLight;\nexport const eventMutationShadow = addEventListenerMutationShadow;\nexport const eventMutationAll = addEventListenerMutationAll;\nexport const eventMutation = addEventListenerMutation;\nexport const eventLight = addEventListenerLight;\nexport const eventShadow = addEventListenerShadow;\nexport const eventAll = addEventListenerAll;\nexport const eventAppHost = addEventListenerAppHost;\nexport const eventWindow = addEventListenerWindow;\nexport const eventDocument = addEventListenerDocument;\nexport const eventThis = addEventListenerThis;\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata<Event>[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// EventListenerLifeCycler\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nimport { ElementDefineLifeCycler, MutationObserverSetEntry, OnConnectedResult } from '../types';\nimport { Subject } from '@dooboostore/core';\nimport { debounceTime, distinctUntilChanged, throttleTime } from '@dooboostore/core/message/operators';\nimport { SwcUtils } from '../utils/Utils';\n\nexport interface BoundListenerEntry {\n target: EventTarget;\n type: string;\n handler: EventListener;\n options: AddEventListenerOptions;\n onRemoves?: Array<{ fn: (target: EventTarget, optionValue: unknown) => void; opts: unknown }>;\n subscription?: { unsubscribe: () => void };\n meta?: AddEventListenerMetadata<Event>;\n}\n\nexport class EventListenerLifeCycler implements ElementDefineLifeCycler {\n /** \uC778\uC2A4\uD134\uC2A4\uBCC4 boundListeners \uC0C1\uD0DC (\uC2DC\uD074\uB7EC\uB294 elementDefine \uC2DC 1\uD68C \uC0DD\uC131\uB418\uC5B4 \uACF5\uC720\uB418\uBBC0\uB85C) */\n private readonly boundListenersMap = new WeakMap<Element, BoundListenerEntry[]>();\n /** \uC778\uC2A4\uD134\uC2A4\uBCC4 delegate:'mutation' \uBC14\uC778\uB529 \uCD94\uC801 WeakSet \u2014 MutationObserverLifeCycler \uC5D0\uC11C \uCC38\uC870 */\n private readonly eventBoundSetsMap = new WeakMap<Element, Map<AddEventListenerMetadata, WeakSet<Element>>>();\n\n // \u2500\u2500 \uC678\uBD80(MutationObserverLifeCycler)\uC5D0\uC11C \uC9C1\uC811 \uC0AC\uC6A9\uD558\uB294 \uACF5\uAC1C \uD5EC\uD37C \u2500\u2500\n\n /** \uC778\uC2A4\uD134\uC2A4\uBCC4 boundListeners \uB97C \uBC18\uD658\uD55C\uB2E4 (\uC5C6\uC73C\uBA74 \uC0DD\uC131). */\n getBoundListeners(inst: Element): BoundListenerEntry[] {\n let list = this.boundListenersMap.get(inst);\n if (!list) { list = []; this.boundListenersMap.set(inst, list); }\n return list;\n }\n\n /** \uC778\uC2A4\uD134\uC2A4\uBCC4 eventBoundSets \uB97C \uBC18\uD658\uD55C\uB2E4 (\uC5C6\uC73C\uBA74 \uC0DD\uC131). */\n getEventBoundSets(inst: Element): Map<AddEventListenerMetadata, WeakSet<Element>> {\n let map = this.eventBoundSetsMap.get(inst);\n if (!map) { map = new Map(); this.eventBoundSetsMap.set(inst, map); }\n return map;\n }\n\n /**\n * target \uC5D0 meta \uC774\uBCA4\uD2B8\uB97C \uC9C1\uC811 \uBC14\uC778\uB529\uD55C\uB2E4.\n * delegate:'mutation' \uCD08\uAE30/\uB3D9\uC801 \uBC14\uC778\uB529\uC5D0\uC11C \uD638\uCD9C\uB41C\uB2E4.\n */\n bindDirect(helperHostSet: HelperHostSet, target: EventTarget, meta: AddEventListenerMetadata): void {\n const inst = helperHostSet.$this;\n const currentWin = helperHostSet.$w;\n const { type, options } = meta;\n const opts = { capture: options.capture, once: options.once, passive: options.passive };\n\n const handler = async (event: Event) => {\n if (options.filter) {\n const helper = SwcUtils.getHelperAndHostSet(currentWin, target as HTMLElement);\n if (!options.filter(event, { currentThis: inst, helper })) return;\n }\n if (options.stopPropagation) event.stopPropagation();\n if (options.stopImmediatePropagation) event.stopImmediatePropagation();\n if (options.preventDefault) event.preventDefault();\n const currentHostSet = SwcUtils.getHostSet(inst);\n await inst[meta.propertyKey](event, { currentHostSet, $matchedElement: event.currentTarget }, { event, ...currentHostSet, $el: target, $root: target });\n };\n\n const eventSubject = new Subject<Event>();\n let eventStream: any = eventSubject;\n if (options.debounceTime && options.debounceTime > 0)\n eventStream = eventStream.pipe(debounceTime(options.debounceTime));\n if (options.throttleTime && options.throttleTime > 0)\n eventStream = eventStream.pipe(throttleTime(options.throttleTime));\n if (options.distinctUntilChanged !== undefined && options.distinctUntilChanged !== false) {\n eventStream = typeof options.distinctUntilChanged === 'function'\n ? eventStream.pipe(distinctUntilChanged(options.distinctUntilChanged))\n : eventStream.pipe(distinctUntilChanged());\n }\n\n const subscription = eventStream.subscribe({\n next: (e: Event) => handler(e).catch((err: any) => console.error('Event handler error:', err)),\n error: (err: any) => console.error('Event stream error:', err),\n });\n\n const wrappedHandler = (event: Event) => eventSubject.next(event);\n target.addEventListener(type, wrappedHandler, opts);\n\n const onRemoves: Array<{ fn: any; opts: any }> =\n options.removeListener ? [{ fn: options.removeListener, opts: options }] : [];\n this.getBoundListeners(inst).push({ target, type, handler: wrappedHandler, options: opts, subscription, onRemoves, meta });\n }\n\n /** target + meta \uC870\uD569 \uB9AC\uC2A4\uB108\uB97C \uC81C\uAC70\uD55C\uB2E4. MutationObserver \uCD94\uC801 \uC694\uC18C \uC81C\uAC70 \uC2DC \uD638\uCD9C. */\n unbindDirect(helperHostSet: HelperHostSet, target: EventTarget, meta: AddEventListenerMetadata): void {\n const inst = helperHostSet.$this;\n const list = this.getBoundListeners(inst);\n for (let i = list.length - 1; i >= 0; i--) {\n const l = list[i];\n if (l.target === target && l.type === meta.type && l.meta === meta) {\n try { l.target.removeEventListener(l.type, l.handler, l.options); l.subscription?.unsubscribe?.(); }\n catch (e) { console.error('[SWC] unbindDirect error:', e); }\n for (const r of l.onRemoves ?? []) {\n try { r.fn(l.target, r.opts); } catch (e) { console.error('[SWC] unbindDirect removeListener error:', e); }\n }\n list.splice(i, 1);\n }\n }\n }\n\n /**\n * \uBA54\uD0C0\uB370\uC774\uD130 \uBAA9\uB85D\uC744 delegate / mutationDelegate / nonDelegate \uB85C \uBD84\uB958\uD55C\uB2E4.\n * MutationObserverLifeCycler \uC5D0\uC11C mutationDelegate \uBAA9\uB85D\uC744 \uAEBC\uB0BC \uB54C \uC0AC\uC6A9\uD55C\uB2E4.\n */\n classifyListeners(metaList: AddEventListenerMetadata[]): {\n delegateListeners: AddEventListenerMetadata[];\n mutationDelegateListeners: AddEventListenerMetadata[];\n nonDelegateListeners: AddEventListenerMetadata[];\n } {\n const isSpecial = (sel: any) =>\n ['$window', '$document', '$host', '$appHost', '$firstHost', '$lastHost',\n '$firstAppHost', '$lastAppHost', '$hosts', '$appHosts', '$this', ''].includes(sel);\n\n const delegateListeners: AddEventListenerMetadata[] = [];\n const mutationDelegateListeners: AddEventListenerMetadata[] = [];\n const nonDelegateListeners: AddEventListenerMetadata[] = [];\n\n for (const meta of metaList) {\n const isStr = typeof meta.selector === 'string';\n const mode = meta.options.delegate;\n if (mode && isStr && !isSpecial(meta.selector)) {\n mode === 'mutation' ? mutationDelegateListeners.push(meta) : delegateListeners.push(meta);\n } else {\n nonDelegateListeners.push(meta);\n }\n }\n return { delegateListeners, mutationDelegateListeners, nonDelegateListeners };\n }\n\n // \u2500\u2500 ElementDefineLifeCycler \uAD6C\uD604 \u2500\u2500\n\n onConnected(helperHostSet: HelperHostSet): OnConnectedResult | void {\n const inst = helperHostSet.$this;\n const currentWin = helperHostSet.$w;\n\n this.boundListenersMap.delete(inst);\n this.eventBoundSetsMap.delete(inst);\n\n const allMeta = getAddEventListenerMetadata(inst) ?? [];\n const { delegateListeners, nonDelegateListeners, mutationDelegateListeners } = this.classifyListeners(allMeta);\n\n // \u2500\u2500 delegate \uB9AC\uC2A4\uB108: type+root \uD0A4\uB85C \uADF8\uB8F9\uD551 \u2192 unified handler \u2500\u2500\n const groups = new Map<string, AddEventListenerMetadata[]>();\n for (const meta of delegateListeners) {\n const key = `${meta.type}:${meta.options.root || 'auto'}`;\n if (!groups.has(key)) groups.set(key, []);\n groups.get(key)!.push(meta);\n }\n\n groups.forEach((metaList, key) => {\n const ci = key.indexOf(':');\n const type = key.slice(0, ci);\n const r = key.slice(ci + 1);\n const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };\n\n const roots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') roots.push(inst.shadowRoot || inst);\n else if (r === 'light') roots.push(inst);\n else if (r === 'shadow' && inst.shadowRoot) roots.push(inst.shadowRoot);\n else if (r === 'all') { roots.push(inst); if (inst.shadowRoot) roots.push(inst.shadowRoot); }\n\n for (const br of roots) {\n const sorted = [...metaList].sort((a, b) => (b.options.stopPropagation ? 1 : 0) - (a.options.stopPropagation ? 1 : 0));\n const handler = async (event: Event) => {\n for (const m of sorted) {\n const matchedEl = (event.target as HTMLElement)?.closest(m.selector as string);\n console.log('[DBG][delegate] type=', event.type, '| evtTarget=', (event.target as any)?.tagName, '| sel=', m.selector, '| matchedEl=', matchedEl?.className || matchedEl?.tagName, '| brContains=', (br as any).contains?.(matchedEl), '| brTag=', (br as any).tagName || (br as any).constructor?.name);\n if (matchedEl && (br as any).contains(matchedEl)) {\n if (m.options.filter) {\n const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl as HTMLElement);\n if (!m.options.filter(event, { currentThis: inst, helper })) continue;\n }\n if (m.options.stopPropagation) event.stopPropagation();\n if (m.options.stopImmediatePropagation) event.stopImmediatePropagation();\n if (m.options.preventDefault) event.preventDefault();\n const hs = SwcUtils.getHostSet(inst);\n await inst[m.propertyKey](event, { ...hs, $matchedElement: matchedEl }, { event, ...hs, $el: matchedEl, $root: br });\n if ((event as any).cancelBubble) break;\n }\n }\n };\n br.addEventListener(type, handler, opts);\n if (type === 'click') {\n console.log('[DBG][eventCycler] bound click on br=', (br as any).tagName || (br as any).constructor?.name, '| inst=', (inst as any).tagName || (inst as any).constructor?.name, '| isSame=', br === inst);\n }\n const onRemoves: Array<{ fn: any; opts: any }> = sorted.filter(m => m.options.removeListener).map(m => ({ fn: m.options.removeListener, opts: m.options }));\n this.getBoundListeners(inst).push({ target: br, type, handler, options: opts, onRemoves });\n }\n });\n\n // \u2500\u2500 non-delegate \uB9AC\uC2A4\uB108: \uB300\uC0C1 \uC694\uC18C \uC9C1\uC811 \uD0D0\uC0C9 \u2192 bindDirect \u2500\u2500\n for (const meta of nonDelegateListeners) {\n const { selector, options } = meta;\n const r = options.root || 'auto';\n const bindTargets: EventTarget[] = [];\n\n let resolvedSel: string | null = null;\n if (typeof selector === 'function') {\n const result = selector(inst, helperHostSet);\n if (typeof result === 'string') resolvedSel = result;\n else if (result instanceof currentWin.Element) bindTargets.push(result as EventTarget);\n else if (result instanceof currentWin.NodeList) bindTargets.push(...(Array.from(result) as EventTarget[]));\n else if (Array.isArray(result)) bindTargets.push(...(result as EventTarget[]));\n } else {\n resolvedSel = selector;\n }\n\n const applyRoot = (t: any) => {\n if (!t) return;\n if (r === 'auto') bindTargets.push(t.shadowRoot || t);\n else { if (r === 'light' || r === 'all') bindTargets.push(t); if ((r === 'shadow' || r === 'all') && t.shadowRoot) bindTargets.push(t.shadowRoot); }\n };\n\n if (resolvedSel) {\n if (resolvedSel === '$window') bindTargets.push(currentWin);\n else if (resolvedSel === '$document') bindTargets.push(currentWin.document);\n else if (resolvedSel === '$host') applyRoot(helperHostSet.$host);\n else if (resolvedSel === '$parentHost') applyRoot(helperHostSet.$parentHost);\n else if (resolvedSel === '$appHost') applyRoot(helperHostSet.$appHost);\n else if (resolvedSel === '$firstHost') applyRoot(helperHostSet.$firstHost);\n else if (resolvedSel === '$lastHost') applyRoot(helperHostSet.$lastHost);\n else if (resolvedSel === '$firstAppHost') applyRoot(helperHostSet.$firstAppHost);\n else if (resolvedSel === '$lastAppHost') applyRoot(helperHostSet.$lastAppHost);\n else if (resolvedSel === '$hosts') helperHostSet.$hosts.forEach(applyRoot);\n else if (resolvedSel === '$appHosts') helperHostSet.$appHosts.forEach(applyRoot);\n else if (resolvedSel === '$this' || !resolvedSel) applyRoot(inst);\n else {\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(inst.shadowRoot || inst);\n else if (r === 'light') searchRoots.push(inst);\n else if (r === 'shadow' && inst.shadowRoot) searchRoots.push(inst.shadowRoot);\n else if (r === 'all') { searchRoots.push(inst); if (inst.shadowRoot) searchRoots.push(inst.shadowRoot); }\n for (const sr of searchRoots) sr.querySelectorAll(resolvedSel).forEach(el => bindTargets.push(el));\n }\n }\n\n for (const t of bindTargets) this.bindDirect(helperHostSet, t, meta);\n }\n\n // \u2500\u2500 delegate:'mutation' \uB9AC\uC2A4\uB108: MutationObserver \uB85C \uCD94\uAC00/\uC81C\uAC70\uB41C \uC694\uC18C\uB97C \uCD94\uC801\uD574 \uC9C1\uC811 \uBC14\uC778\uB529/\uD574\uC81C \u2500\u2500\n // \uC774\uBCA4\uD2B8 \uB9AC\uC2A4\uB108\uC758 \uCC45\uC784\uC774\uBBC0\uB85C EventListenerLifeCycler \uAC00 \uC9C1\uC811 \uCC98\uB9AC\uD558\uACE0,\n // mutationObserverSet \uC744 \uBC18\uD658\uD574 elementDefine \uC774 \uD558\uB098\uC758 MutationObserver \uB85C \uC0DD\uC131\uD558\uAC8C \uD55C\uB2E4.\n if (mutationDelegateListeners.length > 0) {\n const shadowEventDelegates = mutationDelegateListeners.filter(m => {\n const r = m.options.root || 'auto';\n return inst.shadowRoot && (r === 'shadow' || r === 'all' || r === 'auto');\n });\n const lightEventDelegates = mutationDelegateListeners.filter(m => {\n const r = m.options.root || 'auto';\n return r === 'light' || r === 'all' || (!inst.shadowRoot && r === 'auto');\n });\n\n const buildMutationEntry = (\n root: HTMLElement | ShadowRoot,\n eventDelegates: AddEventListenerMetadata[],\n ): MutationObserverSetEntry | null => {\n if (eventDelegates.length === 0) return null;\n const boundSets = this.getEventBoundSets(inst);\n\n const callback = (mutations: MutationRecord[], obs: MutationObserver) => {\n for (const m of eventDelegates) {\n let boundSet = boundSets.get(m);\n if (!boundSet) { boundSet = new WeakSet<Element>(); boundSets.set(m, boundSet); }\n\n const isThis = m.selector === '$this' || m.selector === '';\n const matchesSel = (n: any) => {\n if (!n || n.nodeType !== 1) return false;\n if (isThis) return true;\n return typeof m.selector === 'string' && (n as HTMLElement).matches?.(m.selector);\n };\n const bindEl = (el: Element) => { if (!boundSet!.has(el)) { this.bindDirect(helperHostSet, el, m); boundSet!.add(el); } };\n const unbindEl = (el: Element) => { if (boundSet!.has(el)) { this.unbindDirect(helperHostSet, el, m); boundSet!.delete(el); } };\n\n for (const mut of mutations) {\n Array.from(mut.addedNodes || []).forEach(n => { if (n.nodeType !== 1) return; if (matchesSel(n)) bindEl(n as Element); else if (!isThis && typeof m.selector === 'string') (n as Element).querySelectorAll?.(m.selector).forEach(bindEl); });\n Array.from(mut.removedNodes || []).forEach(n => { if (n.nodeType !== 1) return; const el = n as Element; if (matchesSel(el)) unbindEl(el); else if (!isThis && typeof m.selector === 'string') el.querySelectorAll?.(m.selector).forEach(unbindEl); });\n }\n }\n };\n\n // delegate:'mutation' \uCD08\uAE30 \uBC14\uC778\uB529 (connected \uC2DC \uC774\uBBF8 \uC874\uC7AC\uD558\uB294 \uC694\uC18C)\n for (const m of eventDelegates) {\n let boundSet = boundSets.get(m);\n if (!boundSet) { boundSet = new WeakSet<Element>(); boundSets.set(m, boundSet); }\n if (typeof m.selector !== 'string') continue;\n if (m.selector === '$this' || m.selector === '') {\n this.bindDirect(helperHostSet, root as EventTarget, m);\n boundSet.add(root as Element);\n } else {\n root.querySelectorAll(m.selector).forEach(el => {\n if (!boundSet!.has(el)) { this.bindDirect(helperHostSet, el, m); boundSet!.add(el); }\n });\n }\n }\n\n return { target: root, options: { childList: true, subtree: true }, callback };\n };\n\n const shadowEntry = inst.shadowRoot ? buildMutationEntry(inst.shadowRoot, shadowEventDelegates) : null;\n const lightEntry = buildMutationEntry(inst as any, lightEventDelegates);\n const mutationObserverSet: MutationObserverSetEntry[] = [shadowEntry, lightEntry].filter(Boolean) as MutationObserverSetEntry[];\n if (mutationObserverSet.length > 0) return { mutationObserverSet };\n }\n\n return undefined;\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n const list = this.boundListenersMap.get(inst) ?? [];\n for (const l of list) {\n try { l.target.removeEventListener(l.type, l.handler, l.options); l.subscription?.unsubscribe?.(); }\n catch (e) { console.error('[SWC] EventListenerLifeCycler cleanup error:', e); }\n for (const r of l.onRemoves ?? []) {\n try { r.fn(l.target, r.opts); } catch (e) { console.error('[SWC] removeListener error:', e); }\n }\n }\n this.boundListenersMap.delete(inst);\n this.eventBoundSetsMap.delete(inst);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,SAAS,oBAAoB;AA+BtB,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAuB5F,SAAS,iBAA+C,gBAA2D,eAA0E,cAAsE;AACxQ,SAAO,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AAEA,YAAM,cAAc,KAAK,aAAa,mBAAmB,KAAK,YAAY,oBAAoB,IAAI;AAClG,YAAM,aAAa,mBAAmB,MAAa,mBAAmB;AACtE,YAAM,sBAAkD,CAAC,aAAa,UAAU,EAAE,OAAO,OAAO;AAChG,UAAI,oBAAoB,SAAS,EAAG,QAAO,EAAE,oBAAoB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,eAAe,eAAoC;AACjD,UAAM,OAAO,cAAc;AAC3B,UAAM,OAAO,KAAK,kBAAkB,IAAI,IAAI,KAAK,CAAC;AAClD,eAAW,KAAK,MAAM;AACpB,UAAI;AAAE,UAAE,OAAO,oBAAoB,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO;AAAG,UAAE,cAAc,cAAc;AAAA,MAAG,SAC5F,GAAG;AAAE,gBAAQ,MAAM,gDAAgD,CAAC;AAAA,MAAG;AAC9E,iBAAW,KAAK,EAAE,aAAa,CAAC,GAAG;AACjC,YAAI;AAAE,YAAE,GAAG,EAAE,QAAQ,EAAE,IAAI;AAAA,QAAG,SAAS,GAAG;AAAE,kBAAQ,MAAM,+BAA+B,CAAC;AAAA,QAAG;AAAA,MAC/F;AAAA,IACF;AACA,SAAK,kBAAkB,OAAO,IAAI;AAClC,SAAK,kBAAkB,OAAO,IAAI;AAAA,EACpC;AACF;",
|
|
6
|
+
"names": ["event"]
|
|
7
7
|
}
|
|
@@ -217,6 +217,9 @@ function attribute(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsO
|
|
|
217
217
|
return applyAttribute("$this", void 0, selectorOrAttributeOrTarget);
|
|
218
218
|
}
|
|
219
219
|
function setAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions, optionsOrUndefined) {
|
|
220
|
+
if (typeof selectorOrAttributeOrOptions === "function") {
|
|
221
|
+
return applyAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions, optionsOrUndefined);
|
|
222
|
+
}
|
|
220
223
|
if (typeof selectorOrAttributeOrOptions === "string") {
|
|
221
224
|
const isSelector = isCssSelector(selectorOrAttributeOrOptions);
|
|
222
225
|
if (isSelector) {
|
|
@@ -239,10 +242,32 @@ const findAllAttributeApplyMetadata = (target) => {
|
|
|
239
242
|
});
|
|
240
243
|
return result;
|
|
241
244
|
};
|
|
245
|
+
const attr = applyAttribute;
|
|
246
|
+
function attrThis(targetAttributeName, options) {
|
|
247
|
+
return applyAttribute("$this", targetAttributeName, options);
|
|
248
|
+
}
|
|
249
|
+
function attrAppHost(targetAttributeName, options) {
|
|
250
|
+
return applyAttribute("$appHost", targetAttributeName, options);
|
|
251
|
+
}
|
|
252
|
+
function attrLight(selector, targetAttributeName, options) {
|
|
253
|
+
return applyAttribute(selector, targetAttributeName, { ...options ?? {}, root: "light" });
|
|
254
|
+
}
|
|
255
|
+
function attrShadow(selector, targetAttributeName, options) {
|
|
256
|
+
return applyAttribute(selector, targetAttributeName, { ...options ?? {}, root: "shadow" });
|
|
257
|
+
}
|
|
258
|
+
function attrAll(selector, targetAttributeName, options) {
|
|
259
|
+
return applyAttribute(selector, targetAttributeName, { ...options ?? {}, root: "all" });
|
|
260
|
+
}
|
|
242
261
|
var applyAttribute_default = applyAttribute;
|
|
243
262
|
export {
|
|
244
263
|
ATTRIBUTE_METADATA_KEY,
|
|
245
264
|
applyAttribute,
|
|
265
|
+
attr,
|
|
266
|
+
attrAll,
|
|
267
|
+
attrAppHost,
|
|
268
|
+
attrLight,
|
|
269
|
+
attrShadow,
|
|
270
|
+
attrThis,
|
|
246
271
|
attribute,
|
|
247
272
|
convertValue,
|
|
248
273
|
applyAttribute_default as default,
|