@dooboostore/simple-web-component 1.0.48 → 1.0.50
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 +189 -19
- package/dist/cjs/config/config.js +1 -1
- package/dist/cjs/config/config.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +2373 -30
- package/dist/cjs/decorators/addEventListener.js.map +3 -3
- package/dist/cjs/decorators/applyAttribute.js +31 -0
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +55 -18
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +73 -1
- package/dist/cjs/decorators/applyNode.js.map +3 -3
- package/dist/cjs/decorators/applyProperty.js +107 -3
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +6 -5
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +42 -5
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +61 -13
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +254 -439
- 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/eventMedia.js +84 -0
- package/dist/cjs/decorators/eventMedia.js.map +7 -0
- package/dist/cjs/decorators/index.js +6 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +200 -0
- package/dist/cjs/decorators/intersectionObserver.js.map +7 -0
- package/dist/cjs/decorators/mutationObserver.js +186 -55
- package/dist/cjs/decorators/mutationObserver.js.map +3 -3
- package/dist/cjs/decorators/parameter.js +73 -0
- package/dist/cjs/decorators/parameter.js.map +7 -0
- package/dist/cjs/decorators/query.js +117 -102
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/requestAnimationFrame.js +124 -0
- package/dist/cjs/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/cjs/decorators/resizeObserver.js +133 -55
- package/dist/cjs/decorators/resizeObserver.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +114 -0
- package/dist/cjs/decorators/setInterval.js.map +7 -0
- package/dist/cjs/decorators/setTimeout.js +117 -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/elements/SwcAppMixin.js +19 -3
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/window.d.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 +2374 -30
- package/dist/esm/decorators/addEventListener.js.map +3 -3
- package/dist/esm/decorators/applyAttribute.js +31 -0
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +55 -18
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +73 -1
- package/dist/esm/decorators/applyNode.js.map +3 -3
- package/dist/esm/decorators/applyProperty.js +107 -3
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +6 -5
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +42 -5
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +62 -13
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +261 -446
- 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/eventMedia.js +66 -0
- package/dist/esm/decorators/eventMedia.js.map +7 -0
- package/dist/esm/decorators/index.js +6 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +182 -0
- package/dist/esm/decorators/intersectionObserver.js.map +7 -0
- package/dist/esm/decorators/mutationObserver.js +187 -55
- package/dist/esm/decorators/mutationObserver.js.map +3 -3
- package/dist/esm/decorators/parameter.js +54 -0
- package/dist/esm/decorators/parameter.js.map +7 -0
- package/dist/esm/decorators/query.js +117 -102
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/requestAnimationFrame.js +105 -0
- package/dist/esm/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/esm/decorators/resizeObserver.js +134 -55
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +95 -0
- package/dist/esm/decorators/setInterval.js.map +7 -0
- package/dist/esm/decorators/setTimeout.js +98 -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/elements/SwcAppMixin.js +20 -4
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4961 -1628
- 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 +1046 -33
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +24 -34
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +36 -34
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +32 -20
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +61 -34
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +27 -12
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts +12 -3
- 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/eventMedia.d.ts +25 -0
- package/dist/types/decorators/eventMedia.d.ts.map +1 -0
- package/dist/types/decorators/index.d.ts +6 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +58 -0
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -0
- package/dist/types/decorators/mutationObserver.d.ts +44 -25
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +35 -0
- package/dist/types/decorators/parameter.d.ts.map +1 -0
- package/dist/types/decorators/query.d.ts +57 -14
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/requestAnimationFrame.d.ts +47 -0
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -0
- package/dist/types/decorators/resizeObserver.d.ts +43 -23
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +41 -0
- package/dist/types/decorators/setInterval.d.ts.map +1 -0
- package/dist/types/decorators/setTimeout.d.ts +41 -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/elements/SwcAppMixin.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 +4961 -1628
- 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 +1446 -34
- package/src/decorators/applyAttribute.ts +60 -36
- package/src/decorators/applyClass.ts +86 -26
- package/src/decorators/applyNode.ts +124 -36
- package/src/decorators/applyProperty.ts +172 -40
- package/src/decorators/applySlot.ts +6 -5
- package/src/decorators/applyStyle.ts +74 -17
- package/src/decorators/changedAttribute.ts +76 -15
- package/src/decorators/elementDefine.ts +310 -582
- package/src/decorators/emitCustomEvent.ts +73 -5
- package/src/decorators/eventMedia.ts +78 -0
- package/src/decorators/index.ts +6 -1
- package/src/decorators/intersectionObserver.ts +275 -0
- package/src/decorators/mutationObserver.ts +282 -89
- package/src/decorators/parameter.ts +81 -0
- package/src/decorators/query.ts +168 -126
- package/src/decorators/requestAnimationFrame.ts +158 -0
- package/src/decorators/resizeObserver.ts +211 -89
- package/src/decorators/setInterval.ts +136 -0
- package/src/decorators/setTimeout.ts +139 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +17 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +19 -0
- package/src/elements/SwcAppMixin.ts +20 -5
- package/src/types/index.ts +141 -0
- package/src/types/window.d.ts +2 -18
- package/dist/cjs/decorators/queryAll.js +0 -181
- package/dist/cjs/decorators/queryAll.js.map +0 -7
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/decorators/queryAll.js +0 -162
- package/dist/esm/decorators/queryAll.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/decorators/queryAll.d.ts +0 -22
- package/dist/types/decorators/queryAll.d.ts.map +0 -1
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/decorators/queryAll.ts +0 -186
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/decorators/eventMedia.ts"],
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\nimport { SwcUtils } from '../utils/Utils';\n\nexport const EVENT_MEDIA_METADATA_KEY = Symbol.for('simple-web-component:event-media');\n\nexport interface EventMediaMetadata {\n propertyKey: string | symbol;\n query: string;\n eventType: string;\n}\n\n/**\n * CSS \uBBF8\uB514\uC5B4\uCFFC\uB9AC(`window.matchMedia`) \uC0C1\uD0DC \uBCC0\uD654\uB97C \uAC10\uC9C0\uD55C\uB2E4.\n * connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uAD6C\uB3C5\uD558\uACE0, disconnect \uC2DC \uC790\uB3D9\uC73C\uB85C \uD574\uC81C\uD55C\uB2E4.\n *\n * MediaQueryList\uB294 \uC2A4\uD399\uC0C1 'change' \uC774\uBCA4\uD2B8 \uD558\uB098\uB9CC \uC815\uC758\uB3FC\uC788\uB2E4 \u2014 eventType\uC740 \uADF8\uB798\uB3C4 \uBA85\uC2DC\uC801\uC73C\uB85C \uBC1B\uB294\uB2E4\n * (\uB2E4\uB978 @event* \uACC4\uC5F4\uCC98\uB7FC \uBCA0\uC774\uC2A4\uB294 \uBA85\uC2DC\uC801, \uD3B8\uC758 \uBCC4\uCE6D\uC774 \uAC12\uC744 \uACE0\uC815\uD558\uB294 \uCEE8\uBCA4\uC158\uC744 \uB530\uB984). 'change' \uACE0\uC815 \uBC84\uC804\uC740\n * eventMediaChange\uB97C \uC0AC\uC6A9\uD55C\uB2E4.\n */\nexport function eventMedia(query: string, eventType: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(EVENT_MEDIA_METADATA_KEY, constructor) as EventMediaMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(EVENT_MEDIA_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, query, eventType });\n };\n}\n\n/** eventMedia(query, 'change')\uC758 \uBCC4\uCE6D - MediaQueryList\uAC00 \uC2E4\uC81C\uB85C \uBC1C\uC0DD\uC2DC\uD0A4\uB294 \uC720\uC77C\uD55C \uC774\uBCA4\uD2B8. */\nexport function eventMediaChange(query: string): MethodDecorator {\n return eventMedia(query, 'change');\n}\n\nexport const findAllEventMediaMetadata = (target: any): EventMediaMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n return (ReflectUtils.findAllMetadata<EventMediaMetadata[]>(EVENT_MEDIA_METADATA_KEY, constructor) || []).flat();\n};\n\nexport class EventMediaLifeCycler implements ElementDefineLifeCycler {\n private readonly entriesMap = new WeakMap<any, Array<{ mql: MediaQueryList; eventType: string; handler: (e: Event) => void }>>();\n\n onConnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n const metaList = findAllEventMediaMetadata(inst);\n if (metaList.length === 0) return;\n\n const entries: Array<{ mql: MediaQueryList; eventType: string; handler: (e: Event) => void }> = [];\n for (const meta of metaList) {\n const mql = helperHostSet.$w.matchMedia(meta.query);\n const handler = (e: Event) => {\n try {\n inst[meta.propertyKey](e, helperHostSet);\n } catch (err) {\n console.error('[SWC] eventMedia handler error:', err);\n }\n };\n mql.addEventListener(meta.eventType, handler);\n entries.push({ mql, eventType: meta.eventType, handler });\n }\n this.entriesMap.set(inst, entries);\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const { mql, eventType, handler } of this.entriesMap.get(inst) ?? []) {\n try {\n mql.removeEventListener(eventType, handler);\n } catch (e) {\n console.error('[SWC] eventMedia cleanup error:', e);\n }\n }\n this.entriesMap.delete(inst);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAItB,MAAM,2BAA2B,OAAO,IAAI,kCAAkC;AAgB9E,SAAS,WAAW,OAAe,WAAoC;AAC5E,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,0BAA0B,WAAW;AAChF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,+BAAa,eAAe,0BAA0B,UAAU,WAAW;AAAA,IAC7E;AACA,aAAS,KAAK,EAAE,aAAa,OAAO,UAAU,CAAC;AAAA,EACjD;AACF;AAGO,SAAS,iBAAiB,OAAgC;AAC/D,SAAO,WAAW,OAAO,QAAQ;AACnC;AAEO,MAAM,4BAA4B,CAAC,WAAsC;AAC9E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,UAAQ,yBAAa,gBAAsC,0BAA0B,WAAW,KAAK,CAAC,GAAG,KAAK;AAChH;AAEO,MAAM,qBAAwD;AAAA,EAA9D;AACL,wBAAiB,cAAa,oBAAI,QAA6F;AAAA;AAAA,EAE/H,YAAY,eAAoC;AAC9C,UAAM,OAAO,cAAc;AAC3B,UAAM,WAAW,0BAA0B,IAAI;AAC/C,QAAI,SAAS,WAAW,EAAG;AAE3B,UAAM,UAA0F,CAAC;AACjG,eAAW,QAAQ,UAAU;AAC3B,YAAM,MAAM,cAAc,GAAG,WAAW,KAAK,KAAK;AAClD,YAAM,UAAU,CAAC,MAAa;AAC5B,YAAI;AACF,eAAK,KAAK,WAAW,EAAE,GAAG,aAAa;AAAA,QACzC,SAAS,KAAK;AACZ,kBAAQ,MAAM,mCAAmC,GAAG;AAAA,QACtD;AAAA,MACF;AACA,UAAI,iBAAiB,KAAK,WAAW,OAAO;AAC5C,cAAQ,KAAK,EAAE,KAAK,WAAW,KAAK,WAAW,QAAQ,CAAC;AAAA,IAC1D;AACA,SAAK,WAAW,IAAI,MAAM,OAAO;AAAA,EACnC;AAAA,EAEA,eAAe,eAAoC;AACjD,UAAM,OAAO,cAAc;AAC3B,eAAW,EAAE,KAAK,WAAW,QAAQ,KAAK,KAAK,WAAW,IAAI,IAAI,KAAK,CAAC,GAAG;AACzE,UAAI;AACF,YAAI,oBAAoB,WAAW,OAAO;AAAA,MAC5C,SAAS,GAAG;AACV,gBAAQ,MAAM,mCAAmC,CAAC;AAAA,MACpD;AAAA,IACF;AACA,SAAK,WAAW,OAAO,IAAI;AAAA,EAC7B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -17,6 +17,7 @@ module.exports = __toCommonJS(decorators_exports);
|
|
|
17
17
|
__reExport(decorators_exports, require("./addEventListener"), module.exports);
|
|
18
18
|
__reExport(decorators_exports, require("./mutationObserver"), module.exports);
|
|
19
19
|
__reExport(decorators_exports, require("./resizeObserver"), module.exports);
|
|
20
|
+
__reExport(decorators_exports, require("./intersectionObserver"), module.exports);
|
|
20
21
|
__reExport(decorators_exports, require("./applyAttribute"), module.exports);
|
|
21
22
|
__reExport(decorators_exports, require("./elementDefine"), module.exports);
|
|
22
23
|
__reExport(decorators_exports, require("./changedAttribute"), module.exports);
|
|
@@ -24,7 +25,6 @@ __reExport(decorators_exports, require("./emitCustomEvent"), module.exports);
|
|
|
24
25
|
__reExport(decorators_exports, require("./applyNode"), module.exports);
|
|
25
26
|
__reExport(decorators_exports, require("./lifecycles"), module.exports);
|
|
26
27
|
__reExport(decorators_exports, require("./query"), module.exports);
|
|
27
|
-
__reExport(decorators_exports, require("./queryAll"), module.exports);
|
|
28
28
|
__reExport(decorators_exports, require("./applyClass"), module.exports);
|
|
29
29
|
__reExport(decorators_exports, require("./applyStyle"), module.exports);
|
|
30
30
|
__reExport(decorators_exports, require("./applyAttribute"), module.exports);
|
|
@@ -34,4 +34,9 @@ __reExport(decorators_exports, require("./subscribeSwcAppMessageWhileConnected")
|
|
|
34
34
|
__reExport(decorators_exports, require("./publishSwcAppMessage"), module.exports);
|
|
35
35
|
__reExport(decorators_exports, require("./applySlot"), module.exports);
|
|
36
36
|
__reExport(decorators_exports, require("./state"), module.exports);
|
|
37
|
+
__reExport(decorators_exports, require("./setInterval"), module.exports);
|
|
38
|
+
__reExport(decorators_exports, require("./setTimeout"), module.exports);
|
|
39
|
+
__reExport(decorators_exports, require("./requestAnimationFrame"), module.exports);
|
|
40
|
+
__reExport(decorators_exports, require("./eventMedia"), module.exports);
|
|
41
|
+
__reExport(decorators_exports, require("./parameter"), module.exports);
|
|
37
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './addEventListener';\nexport * from './mutationObserver';\nexport * from './resizeObserver';\nexport * from './
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,+BAAd;AACA,+BAAc,+BADd;AAEA,+BAAc,6BAFd;AAGA,+BAAc,
|
|
4
|
+
"sourcesContent": ["export * from './addEventListener';\nexport * from './mutationObserver';\nexport * from './resizeObserver';\nexport * from './intersectionObserver';\nexport * from './applyAttribute';\nexport * from './elementDefine';\nexport * from './changedAttribute';\nexport * from './emitCustomEvent';\nexport * from './applyNode';\nexport * from './lifecycles';\nexport * from './query';\nexport * from './applyClass';\nexport * from './applyStyle';\nexport * from './applyAttribute';\nexport * from './applyProperty';\nexport * from './subscribeSwcAppRouteChangeWhileConnected';\nexport * from './subscribeSwcAppMessageWhileConnected';\nexport * from './publishSwcAppMessage';\nexport * from './applySlot';\nexport * from './state';\nexport * from './setInterval';\nexport * from './setTimeout';\nexport * from './requestAnimationFrame';\nexport * from './eventMedia';\nexport * from './parameter';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,+BAAd;AACA,+BAAc,+BADd;AAEA,+BAAc,6BAFd;AAGA,+BAAc,mCAHd;AAIA,+BAAc,6BAJd;AAKA,+BAAc,4BALd;AAMA,+BAAc,+BANd;AAOA,+BAAc,8BAPd;AAQA,+BAAc,wBARd;AASA,+BAAc,yBATd;AAUA,+BAAc,oBAVd;AAWA,+BAAc,yBAXd;AAYA,+BAAc,yBAZd;AAaA,+BAAc,6BAbd;AAcA,+BAAc,4BAdd;AAeA,+BAAc,uDAfd;AAgBA,+BAAc,mDAhBd;AAiBA,+BAAc,mCAjBd;AAkBA,+BAAc,wBAlBd;AAmBA,+BAAc,oBAnBd;AAoBA,+BAAc,0BApBd;AAqBA,+BAAc,yBArBd;AAsBA,+BAAc,oCAtBd;AAuBA,+BAAc,yBAvBd;AAwBA,+BAAc,wBAxBd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
|
+
var intersectionObserver_exports = {};
|
|
21
|
+
__export(intersectionObserver_exports, {
|
|
22
|
+
INTERSECTION_OBSERVER_METADATA_KEY: () => INTERSECTION_OBSERVER_METADATA_KEY,
|
|
23
|
+
IntersectionObserverLifeCycler: () => IntersectionObserverLifeCycler,
|
|
24
|
+
getIntersectionObserverMetadata: () => getIntersectionObserverMetadata,
|
|
25
|
+
intersectionObserver: () => intersectionObserver,
|
|
26
|
+
intersectionObserverAll: () => intersectionObserverAll,
|
|
27
|
+
intersectionObserverDelegate: () => intersectionObserverDelegate,
|
|
28
|
+
intersectionObserverDelegateAll: () => intersectionObserverDelegateAll,
|
|
29
|
+
intersectionObserverDelegateLight: () => intersectionObserverDelegateLight,
|
|
30
|
+
intersectionObserverDelegateShadow: () => intersectionObserverDelegateShadow,
|
|
31
|
+
intersectionObserverLight: () => intersectionObserverLight,
|
|
32
|
+
intersectionObserverShadow: () => intersectionObserverShadow,
|
|
33
|
+
intersectionObserverThis: () => intersectionObserverThis
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(intersectionObserver_exports);
|
|
36
|
+
var import_core = require("@dooboostore/core");
|
|
37
|
+
var import_Utils = require("../utils/Utils");
|
|
38
|
+
const INTERSECTION_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:intersection-observer");
|
|
39
|
+
const applyIntersectionObserver = (selector, options, targetObj, propertyKey) => {
|
|
40
|
+
const constructor = targetObj.constructor;
|
|
41
|
+
let observers = import_core.ReflectUtils.getMetadata(INTERSECTION_OBSERVER_METADATA_KEY, constructor);
|
|
42
|
+
if (!observers) {
|
|
43
|
+
observers = [];
|
|
44
|
+
import_core.ReflectUtils.defineMetadata(INTERSECTION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
45
|
+
}
|
|
46
|
+
observers.push({ propertyKey, selector, options });
|
|
47
|
+
};
|
|
48
|
+
const resolveIntersectionObserverArgs = (selectorOrOptions, maybeOptions, extra) => {
|
|
49
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
50
|
+
return { selector: selectorOrOptions, options: { ...maybeOptions ?? {}, ...extra } };
|
|
51
|
+
}
|
|
52
|
+
return { selector: "$this", options: { ...selectorOrOptions ?? {}, ...extra } };
|
|
53
|
+
};
|
|
54
|
+
const dispatchIntersectionObserver = (selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, extra) => {
|
|
55
|
+
if ((typeof maybeOptionsOrPropertyKey === "string" || typeof maybeOptionsOrPropertyKey === "symbol") && descriptor !== void 0) {
|
|
56
|
+
applyIntersectionObserver("$this", { ...extra }, selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const { selector, options } = resolveIntersectionObserverArgs(
|
|
60
|
+
selectorOrOptionsOrTarget,
|
|
61
|
+
maybeOptionsOrPropertyKey,
|
|
62
|
+
extra
|
|
63
|
+
);
|
|
64
|
+
return (targetObj, propertyKey) => {
|
|
65
|
+
applyIntersectionObserver(selector, options, targetObj, propertyKey);
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
function intersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
69
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});
|
|
70
|
+
}
|
|
71
|
+
function intersectionObserverThis(optionsOrTarget, propertyKey, descriptor) {
|
|
72
|
+
return dispatchIntersectionObserver(optionsOrTarget, propertyKey, descriptor, {});
|
|
73
|
+
}
|
|
74
|
+
function intersectionObserverDelegateLight(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
75
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "light", delegate: true });
|
|
76
|
+
}
|
|
77
|
+
function intersectionObserverDelegateShadow(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
78
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "shadow", delegate: true });
|
|
79
|
+
}
|
|
80
|
+
function intersectionObserverDelegateAll(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
81
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "all", delegate: true });
|
|
82
|
+
}
|
|
83
|
+
function intersectionObserverDelegate(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
84
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "auto", delegate: true });
|
|
85
|
+
}
|
|
86
|
+
function intersectionObserverLight(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
87
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "light" });
|
|
88
|
+
}
|
|
89
|
+
function intersectionObserverShadow(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
90
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "shadow" });
|
|
91
|
+
}
|
|
92
|
+
function intersectionObserverAll(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
93
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "all" });
|
|
94
|
+
}
|
|
95
|
+
function getIntersectionObserverMetadata(target) {
|
|
96
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
97
|
+
return import_core.ReflectUtils.getMetadata(INTERSECTION_OBSERVER_METADATA_KEY, constructor);
|
|
98
|
+
}
|
|
99
|
+
class IntersectionObserverLifeCycler {
|
|
100
|
+
constructor() {
|
|
101
|
+
__publicField(this, "removeObserverCallbacksMap", /* @__PURE__ */ new WeakMap());
|
|
102
|
+
}
|
|
103
|
+
onConnected(helperHostSet) {
|
|
104
|
+
const inst = helperHostSet.$this;
|
|
105
|
+
const currentWin = helperHostSet.$w;
|
|
106
|
+
const removeObserverCallbacks = [];
|
|
107
|
+
this.removeObserverCallbacksMap.set(inst, removeObserverCallbacks);
|
|
108
|
+
const allMeta = getIntersectionObserverMetadata(inst) ?? [];
|
|
109
|
+
if (allMeta.length === 0) return;
|
|
110
|
+
const root = inst.shadowRoot || inst;
|
|
111
|
+
for (const m of allMeta) {
|
|
112
|
+
if (m.options.removeObserver) removeObserverCallbacks.push({ fn: m.options.removeObserver, target: root, opts: m.options });
|
|
113
|
+
}
|
|
114
|
+
const buildCallback = (metas) => {
|
|
115
|
+
return (entries, obs) => {
|
|
116
|
+
for (const m of metas) {
|
|
117
|
+
let matchedEls;
|
|
118
|
+
if (m.options.delegate && typeof m.selector === "string") {
|
|
119
|
+
const isThis = m.selector === "$this" || m.selector === "";
|
|
120
|
+
matchedEls = entries.map((e) => e.target).filter((el) => {
|
|
121
|
+
if (!el || el.nodeType !== 1) return false;
|
|
122
|
+
if (isThis) return true;
|
|
123
|
+
return el.matches?.(m.selector) || !!el.closest?.(m.selector);
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
matchedEls = entries.map((e) => e.target).filter((t) => t && t.nodeType === 1);
|
|
127
|
+
}
|
|
128
|
+
if (matchedEls.length === 0) continue;
|
|
129
|
+
if (m.options.filter) {
|
|
130
|
+
if (!m.options.filter(matchedEls, { currentThis: inst, helper: helperHostSet })) continue;
|
|
131
|
+
}
|
|
132
|
+
const hostSet = import_Utils.SwcUtils.getHostSet(inst);
|
|
133
|
+
inst[m.propertyKey](matchedEls, entries, obs, { ...hostSet, $root: root });
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
const groups = /* @__PURE__ */ new Map();
|
|
138
|
+
for (const m of allMeta) {
|
|
139
|
+
const obsOptions = {
|
|
140
|
+
root: m.options.intersectionRoot ?? null,
|
|
141
|
+
rootMargin: m.options.rootMargin,
|
|
142
|
+
threshold: m.options.threshold
|
|
143
|
+
};
|
|
144
|
+
const key = JSON.stringify([obsOptions.root, obsOptions.rootMargin, obsOptions.threshold]);
|
|
145
|
+
if (!groups.has(key)) groups.set(key, { options: obsOptions, metas: [] });
|
|
146
|
+
groups.get(key).metas.push(m);
|
|
147
|
+
}
|
|
148
|
+
const intersectionObserverSet = [];
|
|
149
|
+
for (const [, group] of groups) {
|
|
150
|
+
const callback = buildCallback(group.metas);
|
|
151
|
+
const observeTargets = [];
|
|
152
|
+
for (const m of group.metas) {
|
|
153
|
+
if (m.options.delegate && typeof m.selector === "string") {
|
|
154
|
+
observeTargets.push({ target: m.selector, delegate: true, delegateRoot: m.options.root, callback });
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
let targets = [];
|
|
158
|
+
if (typeof m.selector === "function") {
|
|
159
|
+
const res = m.selector(inst, helperHostSet);
|
|
160
|
+
if (res instanceof currentWin.HTMLElement) targets = [res];
|
|
161
|
+
else if (res instanceof currentWin.NodeList) targets = Array.from(res).filter((e) => e instanceof currentWin.HTMLElement);
|
|
162
|
+
else if (Array.isArray(res)) targets = res.filter((e) => e instanceof currentWin.HTMLElement);
|
|
163
|
+
} else if (typeof m.selector === "string") {
|
|
164
|
+
if (m.selector === "$this" || m.selector === "") {
|
|
165
|
+
targets = [inst];
|
|
166
|
+
} else {
|
|
167
|
+
const r = m.options.root || "auto";
|
|
168
|
+
const scopes = [];
|
|
169
|
+
if (r === "auto") scopes.push(inst.shadowRoot || inst);
|
|
170
|
+
else if (r === "light") scopes.push(inst);
|
|
171
|
+
else if (r === "shadow" && inst.shadowRoot) scopes.push(inst.shadowRoot);
|
|
172
|
+
else if (r === "all") {
|
|
173
|
+
scopes.push(inst);
|
|
174
|
+
if (inst.shadowRoot) scopes.push(inst.shadowRoot);
|
|
175
|
+
}
|
|
176
|
+
for (const s of scopes) {
|
|
177
|
+
const found = s?.querySelectorAll?.(m.selector);
|
|
178
|
+
if (found?.length) targets.push(...Array.from(found));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const el of targets) observeTargets.push({ target: el, callback });
|
|
183
|
+
}
|
|
184
|
+
intersectionObserverSet.push({ options: group.options, observeTargets });
|
|
185
|
+
}
|
|
186
|
+
return { intersectionObserverSet };
|
|
187
|
+
}
|
|
188
|
+
onDisconnected(helperHostSet) {
|
|
189
|
+
const inst = helperHostSet.$this;
|
|
190
|
+
for (const cb of this.removeObserverCallbacksMap.get(inst) ?? []) {
|
|
191
|
+
try {
|
|
192
|
+
cb.fn(cb.target, cb.opts);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
console.error("[SWC] removeObserver error:", e);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
this.removeObserverCallbacksMap.delete(inst);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=intersectionObserver.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/decorators/intersectionObserver.ts"],
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, SwcFnSelector, SwcSelector, HelperHostSet } from '../types';\n\n// \uACF5\uD1B5 \uC635\uC158 \u2014 IntersectionObserverInit + filter/removeObserver. root\u00B7delegate \uC81C\uC678.\n// \uC8FC\uC758: \uB370\uCF54\uB808\uC774\uD130\uC758 root(light/shadow/all/auto) \uB294 \uC140\uB809\uD130 \uC2A4\uCF54\uD504 \uC120\uD0DD\uC6A9\uC774\uB2E4.\n// IntersectionObserver \uC758 \uC2A4\uD06C\uB864 \uCEE8\uD14C\uC774\uB108 root \uB294 intersectionRoot \uB85C \uC9C0\uC815\uD55C\uB2E4.\nexport interface IntersectionObserverBaseOptions extends Omit<IntersectionObserverInit, 'root'> {\n /** IntersectionObserver \uC758 \uC2A4\uD06C\uB864 \uCEE8\uD14C\uC774\uB108 (viewport \uB300\uC2E0). \uB370\uCF54\uB808\uC774\uD130 root \uC640 \uD63C\uB3D9 \uC8FC\uC758. */\n intersectionRoot?: Element | Document;\n filter?: (matchedEls: HTMLElement[], meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n removeObserver?: (target: Element, optionValue: IntersectionObserverQueryOptions) => void;\n}\n\n// \uBB38\uC790\uC5F4 \uC140\uB809\uD130 \uC804\uC6A9 \u2014 root\u00B7delegate \uD5C8\uC6A9\nexport type IntersectionObserverQueryOptions = IntersectionObserverBaseOptions & SwcQueryOptions & { delegate?: boolean };\n// \uD568\uC218 \uC140\uB809\uD130 \uC804\uC6A9 \u2014 root\u00B7delegate \uAE08\uC9C0\nexport type IntersectionObserverNonQueryOptions = IntersectionObserverBaseOptions;\n// \uB0B4\uBD80 \uC800\uC7A5/\uD574\uC11D\uC6A9\nexport type IntersectionObserverOptions = IntersectionObserverQueryOptions;\n\n// \uC140\uB809\uD130 \uC885\uB958\uC5D0 \uB530\uB77C \uC635\uC158 \uD0C0\uC785 \uBD84\uAE30\nexport type IntersectionObserverOptionsOf<S extends SwcSelector> = S extends string ? IntersectionObserverQueryOptions : IntersectionObserverNonQueryOptions;\n\nexport interface IntersectionObserverMetadata {\n propertyKey: string | symbol;\n selector: SwcSelector;\n options: IntersectionObserverOptions;\n}\n\nexport const INTERSECTION_OBSERVER_METADATA_KEY = Symbol.for('simple-web-component:intersection-observer');\n\nconst applyIntersectionObserver = (selector: SwcSelector, options: IntersectionObserverOptions, targetObj: Object, propertyKey: string | symbol): void => {\n const constructor = targetObj.constructor;\n let observers = ReflectUtils.getMetadata<IntersectionObserverMetadata[]>(INTERSECTION_OBSERVER_METADATA_KEY, constructor);\n if (!observers) {\n observers = [];\n ReflectUtils.defineMetadata(INTERSECTION_OBSERVER_METADATA_KEY, observers, constructor);\n }\n observers.push({ propertyKey, selector, options });\n};\n\nconst resolveIntersectionObserverArgs = (\n selectorOrOptions: SwcSelector | IntersectionObserverOptions | undefined,\n maybeOptions: IntersectionObserverOptions | undefined,\n extra: Partial<IntersectionObserverOptions>\n): { selector: SwcSelector; options: IntersectionObserverOptions } => {\n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return { selector: selectorOrOptions, options: { ...(maybeOptions ?? {}), ...extra } };\n }\n return { selector: '$this', options: { ...(selectorOrOptions ?? {}), ...extra } };\n};\n\n/**\n * bare(@decorator)\uC640 factory(@decorator()/@decorator(...)) \uD638\uCD9C\uC744 \uBAA8\uB450 \uCC98\uB9AC\uD558\uB294 \uACF5\uD1B5 \uB514\uC2A4\uD328\uCC98.\n * extra\uB294 Light/Shadow/All/Delegate \uBCC0\uD615\uC774 \uAC15\uC81C\uB85C \uB367\uC50C\uC6B0\uB294 \uC635\uC158(root, delegate \uB4F1)\uC774\uB2E4.\n */\nconst dispatchIntersectionObserver = (\n selectorOrOptionsOrTarget: SwcSelector | IntersectionObserverOptions | Object | undefined,\n maybeOptionsOrPropertyKey: IntersectionObserverOptions | string | symbol | undefined,\n descriptor: PropertyDescriptor | undefined,\n extra: Partial<IntersectionObserverOptions>\n): MethodDecorator | void => {\n if ((typeof maybeOptionsOrPropertyKey === 'string' || typeof maybeOptionsOrPropertyKey === 'symbol') && descriptor !== undefined) {\n // \uC635\uC158 \uC5C6\uC774: @decorator\n applyIntersectionObserver('$this', { ...extra }, selectorOrOptionsOrTarget as Object, maybeOptionsOrPropertyKey);\n return;\n }\n // \uC635\uC158\uACFC \uD568\uAED8: @decorator() / @decorator(selector, options) / @decorator(options)\n const { selector, options } = resolveIntersectionObserverArgs(\n selectorOrOptionsOrTarget as SwcSelector | IntersectionObserverOptions | undefined,\n maybeOptionsOrPropertyKey as IntersectionObserverOptions | undefined,\n extra\n );\n return (targetObj: Object, propertyKey: string | symbol) => {\n applyIntersectionObserver(selector, options, targetObj, propertyKey);\n };\n};\n\nexport function intersectionObserver(target: SpecialSelector, options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserver(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserver(selector: SwcFnSelector, options?: IntersectionObserverNonQueryOptions): MethodDecorator;\nexport function intersectionObserver(options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserver(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\n/**\n * @intersectionObserver decorator to observe element intersection changes.\n *\n * IntersectionObserver \uB294 \uC0DD\uC131 \uC2DC\uC810\uC5D0 \uC635\uC158(threshold/rootMargin/root)\uC774 \uACE0\uC815\uB418\uBBC0\uB85C,\n * \uC635\uC158\uBCC4\uB85C \uADF8\uB8F9\uC744 \uB9CC\uB4E4\uC5B4 observer \uB97C \uC0DD\uC131\uD55C\uB2E4. \uAC19\uC740 \uC635\uC158 \uADF8\uB8F9 \uC548\uC5D0\uC11C delegate \uB3D9\uC801 \uCD94\uC801\uC774 \uAC00\uB2A5\uD558\uB2E4.\n * \uC635\uC158 \uC5C6\uC774 `@intersectionObserver` \uADF8\uB300\uB85C \uBD99\uC5EC\uB3C4 \uB418\uACE0, `@intersectionObserver(...)`\uCC98\uB7FC \uC140\uB809\uD130/\uC635\uC158\uC744 \uC904 \uC218\uB3C4 \uC788\uB2E4.\n */\nexport function intersectionObserver(selectorOrOptionsOrTarget?: SwcSelector | IntersectionObserverOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});\n}\n\nexport function intersectionObserverThis(options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverThis(optionsOrTarget?: IntersectionObserverQueryOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(optionsOrTarget, propertyKey, descriptor, {});\n}\n\n// \u2500\u2500\u2500 root\uBCC4 delegate \uD5EC\uD37C (root \uC8FC\uC785 \u2192 \uBB38\uC790\uC5F4 \uC140\uB809\uD130 \uC804\uC6A9) \u2500\u2500\u2500\n\nexport function intersectionObserverDelegateLight(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegateLight(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegateLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverDelegateLight(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'light', delegate: true });\n}\n\nexport function intersectionObserverDelegateShadow(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegateShadow(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegateShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverDelegateShadow(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'shadow', delegate: true });\n}\n\nexport function intersectionObserverDelegateAll(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegateAll(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegateAll(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverDelegateAll(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'all', delegate: true });\n}\n\nexport function intersectionObserverDelegate(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegate(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;\nexport function intersectionObserverDelegate(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverDelegate(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'auto', delegate: true });\n}\n\n// \u2500\u2500\u2500 root\uBCC4 \uC77C\uBC18 \uD5EC\uD37C (delegate \uC5C6\uC774, \uC140\uB809\uD130 \uC0DD\uB7B5 \uC2DC $this) \u2500\u2500\u2500\n\nexport function intersectionObserverLight(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverLight(options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverLight(selectorOrOptionsOrTarget?: string | IntersectionObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'light' });\n}\n\nexport function intersectionObserverShadow(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverShadow(options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverShadow(selectorOrOptionsOrTarget?: string | IntersectionObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'shadow' });\n}\n\nexport function intersectionObserverAll(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverAll(options?: IntersectionObserverQueryOptions): MethodDecorator;\nexport function intersectionObserverAll(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function intersectionObserverAll(selectorOrOptionsOrTarget?: string | IntersectionObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'all' });\n}\n\nexport function getIntersectionObserverMetadata(target: any): IntersectionObserverMetadata[] | undefined {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INTERSECTION_OBSERVER_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// IntersectionObserverLifeCycler\n// observer \uB97C \uC9C1\uC811 \uC0DD\uC131\uD558\uC9C0 \uC54A\uACE0 \uC635\uC158 \uADF8\uB8F9 \uBC30\uC5F4(IntersectionObserverSet)\uC744 \uBC18\uD658\uD55C\uB2E4.\n// elementDefine \uC774 \uADF8\uB8F9\uBCC4\uB85C observer \uB97C \uC0DD\uC131\uD55C\uB2E4.\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, OnConnectedResult, IntersectionObserverSet, IntersectionObserverGroup, IntersectionObserverSetEntry } from '../types';\nimport { SwcUtils } from '../utils/Utils';\n\nexport class IntersectionObserverLifeCycler implements ElementDefineLifeCycler {\n private readonly removeObserverCallbacksMap = new WeakMap<Element, Array<{ fn: (target: Element, opts: unknown) => void; target: any; opts: unknown }>>();\n\n onConnected(helperHostSet: HelperHostSet): OnConnectedResult | void {\n const inst = helperHostSet.$this;\n const currentWin = helperHostSet.$w;\n\n const removeObserverCallbacks: Array<{ fn: (target: Element, opts: unknown) => void; target: any; opts: unknown }> = [];\n this.removeObserverCallbacksMap.set(inst, removeObserverCallbacks);\n\n const allMeta = getIntersectionObserverMetadata(inst) ?? [];\n if (allMeta.length === 0) return;\n\n const root: HTMLElement | ShadowRoot = inst.shadowRoot || inst;\n\n // removeObserver \uCF5C\uBC31 \uC218\uC9D1\n for (const m of allMeta) {\n if (m.options.removeObserver) removeObserverCallbacks.push({ fn: m.options.removeObserver, target: root, opts: m.options });\n }\n\n // \u2500\u2500 IntersectionObserver \uCF5C\uBC31 \u2500\u2500\n const buildCallback = (metas: IntersectionObserverMetadata[]): IntersectionObserverSetEntry['callback'] => {\n return (entries, obs) => {\n for (const m of metas) {\n let matchedEls: HTMLElement[];\n if (m.options.delegate && typeof m.selector === 'string') {\n const isThis = m.selector === '$this' || m.selector === '';\n matchedEls = entries.map(e => e.target as HTMLElement).filter(el => {\n if (!el || el.nodeType !== 1) return false;\n if (isThis) return true;\n return el.matches?.(m.selector as string) || !!el.closest?.(m.selector as string);\n });\n } else {\n matchedEls = entries.map(e => e.target as HTMLElement).filter(t => t && t.nodeType === 1);\n }\n if (matchedEls.length === 0) continue;\n if (m.options.filter) {\n if (!m.options.filter(matchedEls, { currentThis: inst, helper: helperHostSet })) continue;\n }\n const hostSet = SwcUtils.getHostSet(inst);\n inst[m.propertyKey](matchedEls, entries, obs, { ...hostSet, $root: root });\n }\n };\n };\n\n // \u2500\u2500 \uC635\uC158\uBCC4 \uADF8\uB8F9\uD551: \uAC19\uC740 observer \uC635\uC158(threshold/rootMargin/intersectionRoot)\uB07C\uB9AC \uBB36\uB294\uB2E4 \u2500\u2500\n // delegate:true \uD56D\uBAA9\uC740 \uB3D9\uC801 \uCD94\uC801\uC6A9 \uC140\uB809\uD130 \uBB38\uC790\uC5F4\uB85C \uC120\uC5B8\uB41C\uB2E4.\n const groups = new Map<string, { options: IntersectionObserverInit; metas: IntersectionObserverMetadata[] }>();\n for (const m of allMeta) {\n const obsOptions: IntersectionObserverInit = {\n root: m.options.intersectionRoot ?? null,\n rootMargin: m.options.rootMargin,\n threshold: m.options.threshold,\n };\n const key = JSON.stringify([obsOptions.root, obsOptions.rootMargin, obsOptions.threshold]);\n if (!groups.has(key)) groups.set(key, { options: obsOptions, metas: [] });\n groups.get(key)!.metas.push(m);\n }\n\n const intersectionObserverSet: IntersectionObserverSet = [];\n for (const [, group] of groups) {\n const callback = buildCallback(group.metas);\n const observeTargets: IntersectionObserverGroup['observeTargets'] = [];\n\n for (const m of group.metas) {\n if (m.options.delegate && typeof m.selector === 'string') {\n observeTargets.push({ target: m.selector, delegate: true, delegateRoot: m.options.root, callback });\n continue;\n }\n let targets: HTMLElement[] = [];\n\n if (typeof m.selector === 'function') {\n const res = (m.selector as any)(inst, helperHostSet);\n if (res instanceof currentWin.HTMLElement) targets = [res as HTMLElement];\n else if (res instanceof currentWin.NodeList) targets = Array.from(res as NodeList).filter((e: any) => e instanceof currentWin.HTMLElement) as HTMLElement[];\n else if (Array.isArray(res)) targets = res.filter((e: any) => e instanceof currentWin.HTMLElement) as HTMLElement[];\n } else if (typeof m.selector === 'string') {\n if (m.selector === '$this' || m.selector === '') {\n targets = [inst as HTMLElement];\n } else {\n const r: any = m.options.root || 'auto';\n const scopes: any[] = [];\n if (r === 'auto') scopes.push(inst.shadowRoot || inst);\n else if (r === 'light') scopes.push(inst);\n else if (r === 'shadow' && inst.shadowRoot) scopes.push(inst.shadowRoot);\n else if (r === 'all') { scopes.push(inst); if (inst.shadowRoot) scopes.push(inst.shadowRoot); }\n for (const s of scopes) {\n const found = s?.querySelectorAll?.(m.selector as string) as NodeListOf<HTMLElement> | undefined;\n if (found?.length) targets.push(...Array.from(found));\n }\n }\n }\n for (const el of targets) observeTargets.push({ target: el, callback });\n }\n\n intersectionObserverSet.push({ options: group.options, observeTargets });\n }\n\n return { intersectionObserverSet };\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const cb of this.removeObserverCallbacksMap.get(inst) ?? []) {\n try { cb.fn(cb.target, cb.opts); } catch (e) { console.error('[SWC] removeObserver error:', e); }\n }\n this.removeObserverCallbacksMap.delete(inst);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAoK7B,mBAAyB;AAvIlB,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAEzG,MAAM,4BAA4B,CAAC,UAAuB,SAAsC,WAAmB,gBAAuC;AACxJ,QAAM,cAAc,UAAU;AAC9B,MAAI,YAAY,yBAAa,YAA4C,oCAAoC,WAAW;AACxH,MAAI,CAAC,WAAW;AACd,gBAAY,CAAC;AACb,6BAAa,eAAe,oCAAoC,WAAW,WAAW;AAAA,EACxF;AACA,YAAU,KAAK,EAAE,aAAa,UAAU,QAAQ,CAAC;AACnD;AAEA,MAAM,kCAAkC,CACtC,mBACA,cACA,UACoE;AACpE,MAAI,OAAO,sBAAsB,YAAY,OAAO,sBAAsB,YAAY;AACpF,WAAO,EAAE,UAAU,mBAAmB,SAAS,EAAE,GAAI,gBAAgB,CAAC,GAAI,GAAG,MAAM,EAAE;AAAA,EACvF;AACA,SAAO,EAAE,UAAU,SAAS,SAAS,EAAE,GAAI,qBAAqB,CAAC,GAAI,GAAG,MAAM,EAAE;AAClF;AAMA,MAAM,+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AAM,OAAO,cAAc;AAC3B,eAAW,MAAM,KAAK,2BAA2B,IAAI,IAAI,KAAK,CAAC,GAAG;AAChE,UAAI;AAAE,WAAG,GAAG,GAAG,QAAQ,GAAG,IAAI;AAAA,MAAG,SAAS,GAAG;AAAE,gBAAQ,MAAM,+BAA+B,CAAC;AAAA,MAAG;AAAA,IAClG;AACA,SAAK,2BAA2B,OAAO,IAAI;AAAA,EAC7C;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,9 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
16
|
return to;
|
|
16
17
|
};
|
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
18
20
|
var mutationObserver_exports = {};
|
|
19
21
|
__export(mutationObserver_exports, {
|
|
20
22
|
MUTATION_OBSERVER_METADATA_KEY: () => MUTATION_OBSERVER_METADATA_KEY,
|
|
23
|
+
MutationObserverLifeCycler: () => MutationObserverLifeCycler,
|
|
21
24
|
getMutationObserverMetadata: () => getMutationObserverMetadata,
|
|
22
25
|
mutationObserver: () => mutationObserver,
|
|
23
26
|
mutationObserverAll: () => mutationObserverAll,
|
|
@@ -31,74 +34,202 @@ __export(mutationObserver_exports, {
|
|
|
31
34
|
});
|
|
32
35
|
module.exports = __toCommonJS(mutationObserver_exports);
|
|
33
36
|
var import_core = require("@dooboostore/core");
|
|
37
|
+
var import_Utils = require("../utils/Utils");
|
|
34
38
|
const MUTATION_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:mutation-observer");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
const applyMutationObserver = (selector, options, targetObj, propertyKey) => {
|
|
40
|
+
const constructor = targetObj.constructor;
|
|
41
|
+
let observers = import_core.ReflectUtils.getMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor);
|
|
42
|
+
if (!observers) {
|
|
43
|
+
observers = [];
|
|
44
|
+
import_core.ReflectUtils.defineMetadata(MUTATION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
45
|
+
}
|
|
46
|
+
observers.push({ propertyKey, selector, options });
|
|
47
|
+
};
|
|
48
|
+
const resolveMutationObserverArgs = (selectorOrOptions, maybeOptions, extra) => {
|
|
49
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
50
|
+
return { selector: selectorOrOptions, options: { ...maybeOptions ?? {}, ...extra } };
|
|
51
|
+
}
|
|
52
|
+
return { selector: "$this", options: { ...selectorOrOptions ?? {}, ...extra } };
|
|
53
|
+
};
|
|
54
|
+
const dispatchMutationObserver = (selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, extra) => {
|
|
55
|
+
if ((typeof maybeOptionsOrPropertyKey === "string" || typeof maybeOptionsOrPropertyKey === "symbol") && descriptor !== void 0) {
|
|
56
|
+
applyMutationObserver("$this", { ...extra }, selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const { selector, options } = resolveMutationObserverArgs(
|
|
60
|
+
selectorOrOptionsOrTarget,
|
|
61
|
+
maybeOptionsOrPropertyKey,
|
|
62
|
+
extra
|
|
63
|
+
);
|
|
64
|
+
return (targetObj, propertyKey) => {
|
|
65
|
+
applyMutationObserver(selector, options, targetObj, propertyKey);
|
|
53
66
|
};
|
|
67
|
+
};
|
|
68
|
+
function mutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
69
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});
|
|
54
70
|
}
|
|
55
|
-
function mutationObserverThis(
|
|
56
|
-
return
|
|
71
|
+
function mutationObserverThis(optionsOrTarget, propertyKey, descriptor) {
|
|
72
|
+
return dispatchMutationObserver(optionsOrTarget, propertyKey, descriptor, {});
|
|
57
73
|
}
|
|
58
|
-
function mutationObserverDelegateLight(
|
|
59
|
-
|
|
60
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "light", delegate: true });
|
|
61
|
-
}
|
|
62
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "light", delegate: true });
|
|
74
|
+
function mutationObserverDelegateLight(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
75
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "light", delegate: true });
|
|
63
76
|
}
|
|
64
|
-
function mutationObserverDelegateShadow(
|
|
65
|
-
|
|
66
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "shadow", delegate: true });
|
|
67
|
-
}
|
|
68
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "shadow", delegate: true });
|
|
77
|
+
function mutationObserverDelegateShadow(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
78
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "shadow", delegate: true });
|
|
69
79
|
}
|
|
70
|
-
function mutationObserverDelegateAll(
|
|
71
|
-
|
|
72
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "all", delegate: true });
|
|
73
|
-
}
|
|
74
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "all", delegate: true });
|
|
80
|
+
function mutationObserverDelegateAll(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
81
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "all", delegate: true });
|
|
75
82
|
}
|
|
76
|
-
function mutationObserverDelegate(
|
|
77
|
-
|
|
78
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "auto", delegate: true });
|
|
79
|
-
}
|
|
80
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "auto", delegate: true });
|
|
83
|
+
function mutationObserverDelegate(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
84
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "auto", delegate: true });
|
|
81
85
|
}
|
|
82
|
-
function mutationObserverLight(
|
|
83
|
-
|
|
84
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "light" });
|
|
85
|
-
}
|
|
86
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "light" });
|
|
86
|
+
function mutationObserverLight(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
87
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "light" });
|
|
87
88
|
}
|
|
88
|
-
function mutationObserverShadow(
|
|
89
|
-
|
|
90
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "shadow" });
|
|
91
|
-
}
|
|
92
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "shadow" });
|
|
89
|
+
function mutationObserverShadow(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
90
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "shadow" });
|
|
93
91
|
}
|
|
94
|
-
function mutationObserverAll(
|
|
95
|
-
|
|
96
|
-
return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "all" });
|
|
97
|
-
}
|
|
98
|
-
return mutationObserver({ ...selectorOrOptions ?? {}, root: "all" });
|
|
92
|
+
function mutationObserverAll(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
93
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "all" });
|
|
99
94
|
}
|
|
100
95
|
function getMutationObserverMetadata(target) {
|
|
101
96
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
102
97
|
return import_core.ReflectUtils.getMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor);
|
|
103
98
|
}
|
|
99
|
+
class MutationObserverLifeCycler {
|
|
100
|
+
constructor() {
|
|
101
|
+
__publicField(this, "removeObserverCallbacksMap", /* @__PURE__ */ new WeakMap());
|
|
102
|
+
}
|
|
103
|
+
onConnected(helperHostSet) {
|
|
104
|
+
const inst = helperHostSet.$this;
|
|
105
|
+
const currentWin = helperHostSet.$w;
|
|
106
|
+
const removeObserverCallbacks = [];
|
|
107
|
+
this.removeObserverCallbacksMap.set(inst, removeObserverCallbacks);
|
|
108
|
+
const allMeta = getMutationObserverMetadata(inst) ?? [];
|
|
109
|
+
if (allMeta.length === 0) return;
|
|
110
|
+
const shadowMetas = allMeta.filter((m) => {
|
|
111
|
+
const r = m.options.root || "auto";
|
|
112
|
+
return inst.shadowRoot && (r === "shadow" || r === "all" || r === "auto");
|
|
113
|
+
});
|
|
114
|
+
const lightMetas = allMeta.filter((m) => {
|
|
115
|
+
const r = m.options.root || "auto";
|
|
116
|
+
return r === "light" || r === "all" || !inst.shadowRoot && r === "auto";
|
|
117
|
+
});
|
|
118
|
+
const buildSet = (root, metas) => {
|
|
119
|
+
if (metas.length === 0) return null;
|
|
120
|
+
const initFrom = (o) => {
|
|
121
|
+
const init = {
|
|
122
|
+
childList: o.childList,
|
|
123
|
+
attributes: o.attributes,
|
|
124
|
+
characterData: o.characterData,
|
|
125
|
+
subtree: o.subtree,
|
|
126
|
+
attributeFilter: o.attributeFilter,
|
|
127
|
+
attributeOldValue: o.attributeOldValue,
|
|
128
|
+
characterDataOldValue: o.characterDataOldValue
|
|
129
|
+
};
|
|
130
|
+
if (!init.childList && !init.attributes && !init.characterData) init.childList = true;
|
|
131
|
+
return init;
|
|
132
|
+
};
|
|
133
|
+
const fnObservedSets = /* @__PURE__ */ new Map();
|
|
134
|
+
const callback = (mutations, obs) => {
|
|
135
|
+
for (const meta of metas) {
|
|
136
|
+
const { selector, options } = meta;
|
|
137
|
+
let matchedEls = [];
|
|
138
|
+
const typeMatches = (m) => {
|
|
139
|
+
const has = !!(options.childList || options.attributes || options.characterData);
|
|
140
|
+
if (m.type === "childList") return has ? !!options.childList : true;
|
|
141
|
+
if (m.type === "attributes") return !!options.attributes;
|
|
142
|
+
if (m.type === "characterData") return !!options.characterData;
|
|
143
|
+
return true;
|
|
144
|
+
};
|
|
145
|
+
const collect = (matchesSel) => mutations.flatMap((m) => {
|
|
146
|
+
if (!typeMatches(m)) return [];
|
|
147
|
+
const els = [];
|
|
148
|
+
if (matchesSel(m.target)) els.push(m.target);
|
|
149
|
+
Array.from(m.addedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
|
|
150
|
+
Array.from(m.removedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
|
|
151
|
+
return els;
|
|
152
|
+
});
|
|
153
|
+
if (options.delegate && typeof selector === "string") {
|
|
154
|
+
const isThis = selector === "$this" || selector === "";
|
|
155
|
+
matchedEls = collect((n) => {
|
|
156
|
+
if (!n || n.nodeType !== 1) return false;
|
|
157
|
+
if (isThis) return true;
|
|
158
|
+
const el = n;
|
|
159
|
+
return el.matches?.(selector) || !!el.closest?.(selector);
|
|
160
|
+
});
|
|
161
|
+
} else if (typeof selector === "string") {
|
|
162
|
+
const isThis = selector === "$this" || selector === "";
|
|
163
|
+
matchedEls = collect((n) => {
|
|
164
|
+
if (!n || n.nodeType !== 1) return false;
|
|
165
|
+
if (isThis) return true;
|
|
166
|
+
return n.matches?.(selector);
|
|
167
|
+
});
|
|
168
|
+
} else if (typeof selector === "function") {
|
|
169
|
+
const set = fnObservedSets.get(meta);
|
|
170
|
+
matchedEls = mutations.filter((m) => typeMatches(m)).map((m) => m.target).filter((t) => t && t.nodeType === 1 && (set ? set.has(t) : false));
|
|
171
|
+
} else {
|
|
172
|
+
matchedEls = mutations.filter((m) => typeMatches(m)).map((m) => m.target).filter((t) => t && t.nodeType === 1);
|
|
173
|
+
}
|
|
174
|
+
if (matchedEls.length === 0) continue;
|
|
175
|
+
if (options.filter) {
|
|
176
|
+
if (!options.filter(matchedEls, { currentThis: inst, helper: helperHostSet })) continue;
|
|
177
|
+
}
|
|
178
|
+
const hostSet = import_Utils.SwcUtils.getHostSet(inst);
|
|
179
|
+
inst[meta.propertyKey](matchedEls, mutations, obs, { ...hostSet, $root: root });
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const observeTargets = [];
|
|
183
|
+
if (metas.some((m) => m.options.delegate)) {
|
|
184
|
+
observeTargets.push({ target: root, options: { childList: true, subtree: true } });
|
|
185
|
+
}
|
|
186
|
+
for (const m of metas.filter((m2) => !m2.options.delegate)) {
|
|
187
|
+
const { selector, options } = m;
|
|
188
|
+
const mInit = initFrom(options);
|
|
189
|
+
if (typeof selector === "string") {
|
|
190
|
+
if (selector === "$this" || selector === "") {
|
|
191
|
+
observeTargets.push({ target: root, options: mInit });
|
|
192
|
+
} else {
|
|
193
|
+
root.querySelectorAll(selector).forEach((el) => observeTargets.push({ target: el, options: mInit }));
|
|
194
|
+
}
|
|
195
|
+
} else if (typeof selector === "function") {
|
|
196
|
+
const res = selector(inst, helperHostSet);
|
|
197
|
+
let targets = [];
|
|
198
|
+
if (res instanceof currentWin.HTMLElement) targets = [res];
|
|
199
|
+
else if (res instanceof currentWin.NodeList) targets = Array.from(res).filter((e) => e instanceof currentWin.HTMLElement);
|
|
200
|
+
else if (Array.isArray(res)) targets = res.filter((e) => e instanceof currentWin.HTMLElement);
|
|
201
|
+
const set = /* @__PURE__ */ new WeakSet();
|
|
202
|
+
for (const el of targets) {
|
|
203
|
+
set.add(el);
|
|
204
|
+
observeTargets.push({ target: el, options: mInit });
|
|
205
|
+
}
|
|
206
|
+
fnObservedSets.set(m, set);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (const m of metas) {
|
|
210
|
+
if (m.options.removeObserver) removeObserverCallbacks.push({ fn: m.options.removeObserver, target: root, opts: m.options });
|
|
211
|
+
}
|
|
212
|
+
return { callback, observeTargets };
|
|
213
|
+
};
|
|
214
|
+
const shadowSet = inst.shadowRoot ? buildSet(inst.shadowRoot, shadowMetas) : null;
|
|
215
|
+
const lightSet = buildSet(inst, lightMetas);
|
|
216
|
+
const mutationObserverSet = [
|
|
217
|
+
...(shadowSet?.observeTargets ?? []).map((t) => ({ ...t, callback: shadowSet.callback })),
|
|
218
|
+
...(lightSet?.observeTargets ?? []).map((t) => ({ ...t, callback: lightSet.callback }))
|
|
219
|
+
];
|
|
220
|
+
if (mutationObserverSet.length === 0) return;
|
|
221
|
+
return { mutationObserverSet };
|
|
222
|
+
}
|
|
223
|
+
onDisconnected(helperHostSet) {
|
|
224
|
+
const inst = helperHostSet.$this;
|
|
225
|
+
for (const cb of this.removeObserverCallbacksMap.get(inst) ?? []) {
|
|
226
|
+
try {
|
|
227
|
+
cb.fn(cb.target, cb.opts);
|
|
228
|
+
} catch (e) {
|
|
229
|
+
console.error("[SWC] removeObserver error:", e);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
this.removeObserverCallbacksMap.delete(inst);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
104
235
|
//# sourceMappingURL=mutationObserver.js.map
|