@dooboostore/simple-web-component 1.0.50 → 1.0.51
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 +735 -354
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +64 -146
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +36 -48
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +9 -12
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +14 -22
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +12 -42
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +3 -3
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +9 -12
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/around.js +124 -0
- package/dist/cjs/decorators/around.js.map +7 -0
- package/dist/cjs/decorators/changedAttribute.js +40 -12
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +224 -195
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +14 -12
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/eventMedia.js +36 -8
- package/dist/cjs/decorators/eventMedia.js.map +2 -2
- package/dist/cjs/decorators/fetch.js +278 -0
- package/dist/cjs/decorators/fetch.js.map +7 -0
- package/dist/cjs/decorators/index.js +5 -2
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +33 -13
- package/dist/cjs/decorators/intersectionObserver.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +11 -11
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/mutationObserver.js +55 -39
- package/dist/cjs/decorators/mutationObserver.js.map +3 -3
- package/dist/cjs/decorators/parameter.js +92 -9
- package/dist/cjs/decorators/parameter.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/cjs/decorators/query.js +11 -5
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/requestAnimationFrame.js +7 -16
- package/dist/cjs/decorators/requestAnimationFrame.js.map +2 -2
- package/dist/cjs/decorators/resizeObserver.js +41 -17
- package/dist/cjs/decorators/resizeObserver.js.map +3 -3
- package/dist/cjs/decorators/setInterval.js +36 -25
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +36 -25
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/decorators/state.js +13 -10
- package/dist/cjs/decorators/state.js.map +2 -2
- package/dist/cjs/decorators/{subscribeSwcAppMessageWhileConnected.js → subscribeSwcAppMessage.js} +20 -21
- package/dist/cjs/decorators/subscribeSwcAppMessage.js.map +7 -0
- package/dist/cjs/decorators/{subscribeSwcAppRouteChangeWhileConnected.js → subscribeSwcAppRouteChange.js} +23 -19
- package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +7 -0
- package/dist/cjs/decorators/swcAppRoute.js +149 -0
- package/dist/cjs/decorators/swcAppRoute.js.map +7 -0
- package/dist/cjs/elements/SwcApp.js +70 -0
- package/dist/cjs/elements/SwcApp.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +256 -83
- package/dist/cjs/elements/SwcAppMixin.js.map +3 -3
- package/dist/cjs/types/index.js +5 -1
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/utils/Utils.js +36 -15
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +64 -146
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +36 -48
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +9 -12
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +15 -23
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +12 -42
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +3 -3
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +9 -12
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/around.js +105 -0
- package/dist/esm/decorators/around.js.map +7 -0
- package/dist/esm/decorators/changedAttribute.js +40 -12
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +222 -193
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +15 -13
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/eventMedia.js +36 -8
- package/dist/esm/decorators/eventMedia.js.map +2 -2
- package/dist/esm/decorators/fetch.js +259 -0
- package/dist/esm/decorators/fetch.js.map +7 -0
- package/dist/esm/decorators/index.js +5 -2
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +33 -13
- package/dist/esm/decorators/intersectionObserver.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +11 -11
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/mutationObserver.js +55 -39
- package/dist/esm/decorators/mutationObserver.js.map +3 -3
- package/dist/esm/decorators/parameter.js +92 -9
- package/dist/esm/decorators/parameter.js.map +2 -2
- package/dist/esm/decorators/publishSwcAppMessage.js +2 -2
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/query.js +11 -5
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/requestAnimationFrame.js +8 -17
- package/dist/esm/decorators/requestAnimationFrame.js.map +2 -2
- package/dist/esm/decorators/resizeObserver.js +41 -17
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +37 -26
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +37 -26
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/decorators/state.js +13 -10
- package/dist/esm/decorators/state.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessage.js +53 -0
- package/dist/esm/decorators/subscribeSwcAppMessage.js.map +7 -0
- package/dist/esm/decorators/{subscribeSwcAppRouteChangeWhileConnected.js → subscribeSwcAppRouteChange.js} +20 -16
- package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +7 -0
- package/dist/esm/decorators/swcAppRoute.js +130 -0
- package/dist/esm/decorators/swcAppRoute.js.map +7 -0
- package/dist/esm/elements/SwcApp.js +70 -0
- package/dist/esm/elements/SwcApp.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +258 -85
- package/dist/esm/elements/SwcAppMixin.js.map +3 -3
- package/dist/esm/types/index.js +5 -1
- package/dist/esm/types/index.js.map +2 -2
- package/dist/esm/utils/Utils.js +36 -15
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1886 -999
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts +1 -0
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +923 -960
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +26 -38
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +1 -3
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +15 -17
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +25 -45
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +1 -3
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/around.d.ts +87 -0
- package/dist/types/decorators/around.d.ts.map +1 -0
- package/dist/types/decorators/changedAttribute.d.ts +21 -1
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +0 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/eventMedia.d.ts +24 -1
- package/dist/types/decorators/eventMedia.d.ts.map +1 -1
- package/dist/types/decorators/fetch.d.ts +139 -0
- package/dist/types/decorators/fetch.d.ts.map +1 -0
- package/dist/types/decorators/index.d.ts +5 -2
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +24 -11
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +8 -7
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/mutationObserver.d.ts +26 -13
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +84 -6
- package/dist/types/decorators/parameter.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +0 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +7 -7
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/requestAnimationFrame.d.ts +1 -1
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -1
- package/dist/types/decorators/resizeObserver.d.ts +26 -13
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +10 -0
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +10 -0
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/decorators/state.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts +44 -0
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +60 -0
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +1 -0
- package/dist/types/decorators/swcAppRoute.d.ts +94 -0
- package/dist/types/decorators/swcAppRoute.d.ts.map +1 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +423 -388
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +43 -4
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +15 -5
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1886 -999
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +8 -6
- package/src/SwcAppEngine.ts +1 -0
- package/src/decorators/addEventListener.ts +102 -96
- package/src/decorators/applyAttribute.ts +76 -138
- package/src/decorators/applyClass.ts +8 -14
- package/src/decorators/applyNode.ts +33 -41
- package/src/decorators/applyProperty.ts +51 -99
- package/src/decorators/applySlot.ts +3 -3
- package/src/decorators/applyStyle.ts +8 -14
- package/src/decorators/around.ts +196 -0
- package/src/decorators/changedAttribute.ts +39 -15
- package/src/decorators/elementDefine.ts +270 -219
- package/src/decorators/emitCustomEvent.ts +17 -13
- package/src/decorators/eventMedia.ts +50 -9
- package/src/decorators/fetch.ts +454 -0
- package/src/decorators/index.ts +5 -2
- package/src/decorators/intersectionObserver.ts +38 -24
- package/src/decorators/lifecycles.ts +24 -22
- package/src/decorators/mutationObserver.ts +71 -52
- package/src/decorators/parameter.ts +145 -14
- package/src/decorators/publishSwcAppMessage.ts +3 -4
- package/src/decorators/query.ts +22 -14
- package/src/decorators/requestAnimationFrame.ts +10 -19
- package/src/decorators/resizeObserver.ts +50 -29
- package/src/decorators/setInterval.ts +37 -26
- package/src/decorators/setTimeout.ts +37 -26
- package/src/decorators/state.ts +19 -13
- package/src/decorators/subscribeSwcAppMessage.ts +106 -0
- package/src/decorators/subscribeSwcAppRouteChange.ts +131 -0
- package/src/decorators/swcAppRoute.ts +231 -0
- package/src/elements/SwcApp.ts +40 -10
- package/src/elements/SwcAppMixin.ts +330 -101
- package/src/types/index.ts +38 -5
- package/src/utils/Utils.ts +50 -18
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +0 -7
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +0 -7
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +0 -54
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +0 -7
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +0 -7
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +0 -23
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +0 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +0 -31
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +0 -1
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +0 -91
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +0 -107
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, SwcFnSelector, SwcSelector, HelperHostSet } from '../types';\nimport { buildSwcParameterArgs } from './parameter';\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 /** \uB9E4\uCE6D \uC2DC \uD578\uB4E4\uB7EC \uC2E4\uD589 \uC5EC\uBD80 \uAC8C\uC774\uD2B8. Promise<boolean>\uB3C4 \uB418\uC5B4 async \uD310\uC815 \uAC00\uB2A5. false\uBA74 \uC2A4\uD0B5. */\n filter?: (matchedEls: HTMLElement[], meta: { currentThis: any, helper: HelperHostSet }) => boolean | Promise<boolean>;\n /** filter \uD1B5\uACFC \uD6C4 \uD578\uB4E4\uB7EC \uC9C1\uC804 \uD6C5. await\uB418\uACE0, \uB9AC\uD134\uAC12\uC740 @intersectionObserverBeforeReturn \uC73C\uB85C \uD578\uB4E4\uB7EC\uC5D0 \uC8FC\uC785\uB41C\uB2E4. */\n before?: (matchedEls: HTMLElement[], meta: { currentThis: any, helper: HelperHostSet }) => any | Promise<any>;\n /** \uD578\uB4E4\uB7EC\uAC00 \uC131\uACF5/\uC2E4\uD328\uD574\uB3C4 \uD56D\uC0C1 \uC2E4\uD589\uB418\uB294 \uC815\uB9AC \uD6C5. ctx\uB85C \uC778\uC790/\uACB0\uACFC/\uC5D0\uB7EC\uB97C \uBC1B\uB294\uB2E4. \uC5D0\uB7EC\uB294 \uB85C\uAE45\uB428. */\n finally?: (matchedEls: HTMLElement[], meta: { currentThis: any, helper: HelperHostSet }, ctx: { args: any[]; result?: any; error?: any }) => any | Promise<any>;\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.getOwnMetadata(INTERSECTION_OBSERVER_METADATA_KEY, constructor) as IntersectionObserverMetadata[] | undefined;\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(...), \uBE48 \uAD04\uD638\uB294 \uD0C0\uC785\uC5D0\uC11C \uB9C9\uC74C) \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(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\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 = typeof target === 'function' ? target : target.constructor;\n return ReflectUtils.findAllMetadata<any[]>(INTERSECTION_OBSERVER_METADATA_KEY, constructor).flat();\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 const opts = m.options;\n void (async () => {\n const helper = SwcUtils.getHelperAndHostSet(inst);\n if (opts.filter && !(await opts.filter(matchedEls, { currentThis: inst, helper }))) return;\n const hostSet = SwcUtils.getHostSet(inst);\n const helperSet = SwcUtils.getHelperSet(helperHostSet.$w);\n const legacyArgs = [matchedEls, entries, obs, { ...hostSet, $root: root }];\n const buildArgs = (beforeReturn: any) => buildSwcParameterArgs(inst, m.propertyKey, {\n hostSet, helperHostSet: helper, helperSet, intersectionObserverBeforeReturn: beforeReturn\n }, [...legacyArgs, beforeReturn]);\n let args = buildArgs(undefined);\n if (opts.before) { const br = await opts.before(matchedEls, { currentThis: inst, helper }); args = buildArgs(br); }\n let result: any, error: any;\n try { result = await inst[m.propertyKey](...args); }\n catch (e) { error = e; }\n finally { if (opts.finally) await opts.finally(matchedEls, { currentThis: inst, helper }, { args, result, error }); }\n if (error) throw error;\n })().catch(e => console.error('[SWC] intersectionObserver handler error:', e));\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,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AAiC/B,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAEzG,MAAM,4BAA4B,CAAC,UAAuB,SAAsC,WAAmB,gBAAuC;AACxJ,QAAM,cAAc,UAAU;AAC9B,MAAI,YAAY,aAAa,eAAe,oCAAoC,WAAW;AAC3F,MAAI,CAAC,WAAW;AACd,gBAAY,CAAC;AACb,iBAAa,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,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ILDCARD = "*";
|
|
|
14
14
|
function onConnectedBefore(arg1, arg2, arg3) {
|
|
15
15
|
const decorator2 = (options, target, propertyKey) => {
|
|
16
16
|
const constructor = target.constructor;
|
|
17
|
-
let list = ReflectUtils.
|
|
17
|
+
let list = ReflectUtils.getOwnMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);
|
|
18
18
|
if (!list) {
|
|
19
19
|
list = [];
|
|
20
20
|
ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);
|
|
@@ -31,7 +31,7 @@ function onConnectedBefore(arg1, arg2, arg3) {
|
|
|
31
31
|
function onConnectedAfter(arg1, arg2, arg3) {
|
|
32
32
|
const decorator2 = (options, target, propertyKey) => {
|
|
33
33
|
const constructor = target.constructor;
|
|
34
|
-
let list = ReflectUtils.
|
|
34
|
+
let list = ReflectUtils.getOwnMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor);
|
|
35
35
|
if (!list) {
|
|
36
36
|
list = [];
|
|
37
37
|
ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);
|
|
@@ -93,7 +93,7 @@ function onConnectedCompleted(optionOrTarget, propertyKey) {
|
|
|
93
93
|
}
|
|
94
94
|
const decorator = (options, target, propertyKey) => {
|
|
95
95
|
const constructor = target.constructor;
|
|
96
|
-
let list = ReflectUtils.
|
|
96
|
+
let list = ReflectUtils.getOwnMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor);
|
|
97
97
|
if (!list) {
|
|
98
98
|
list = [];
|
|
99
99
|
ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);
|
|
@@ -125,13 +125,13 @@ function onConnectedBody(optionOrTarget, propertyKey, arg3) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
const findAllLifecycleMetadata = (target, metadataKey) => {
|
|
128
|
-
const constructor = target
|
|
129
|
-
const results = ReflectUtils.
|
|
128
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
129
|
+
const results = ReflectUtils.findAllMetadata(metadataKey, constructor).flat();
|
|
130
130
|
return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
131
131
|
};
|
|
132
132
|
const findAllOnConnectedMetadata = (target) => {
|
|
133
|
-
const constructor = target
|
|
134
|
-
const results = ReflectUtils.
|
|
133
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
134
|
+
const results = ReflectUtils.findAllMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor).flat();
|
|
135
135
|
return [...results].sort((a, b) => {
|
|
136
136
|
const orderA = a.options?.order ?? 0;
|
|
137
137
|
const orderB = b.options?.order ?? 0;
|
|
@@ -139,13 +139,13 @@ const findAllOnConnectedMetadata = (target) => {
|
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
141
|
const findAllOnConnectedBeforeMetadata = (target) => {
|
|
142
|
-
const constructor = target
|
|
143
|
-
const results = ReflectUtils.
|
|
142
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
143
|
+
const results = ReflectUtils.findAllMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor).flat();
|
|
144
144
|
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
145
145
|
};
|
|
146
146
|
const findAllOnConnectedAfterMetadata = (target) => {
|
|
147
|
-
const constructor = target
|
|
148
|
-
const results = ReflectUtils.
|
|
147
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
148
|
+
const results = ReflectUtils.findAllMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor).flat();
|
|
149
149
|
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
150
150
|
};
|
|
151
151
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/lifecycles.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_INITIALIZE_METADATA_KEY = Symbol.for('simple-web-component:on-constructor');\nexport const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-connected');\nexport const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-connected');\nexport const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-disconnected');\nexport const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-disconnected');\nexport const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');\nexport const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');\nexport const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');\nexport const ON_CONNECTED_BODY_METADATA_KEY = Symbol.for('simple-web-component:on-connected-body');\nexport const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');\nexport const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface OnConnectedAppendChildOptions {\n // ssrFirst?: boolean;\n // replaceWrap?:{ start: string, end:string},\n useShadow?: boolean;\n order?: number;\n}\nexport interface OnConnectedAppendChildOptionsMetadata {\n propertyKey: string | symbol;\n options: OnConnectedAppendChildOptions;\n}\n\nexport interface OnConnectedOptions {\n // ssrFirst?: boolean;\n order?: number;\n}\nexport interface OnConnectedMetadata {\n propertyKey: string | symbol;\n options: OnConnectedOptions;\n}\n\nexport interface LifecycleOptions {\n order?: number;\n}\nexport interface LifecycleMetadata {\n propertyKey: string | symbol;\n order?: number;\n}\n\n\nexport function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBefore(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\nexport function onConnectedAfter(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\n\n// function createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {\n// const decorator = (options?: LifecycleOptions): MethodDecorator => {\n// return (target: Object, propertyKey: string | symbol) => {\n// const constructor = target.constructor;\n// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n// if (!list) {\n// list = [];\n// ReflectUtils.defineMetadata(metadataKey, list, constructor);\n// }\n// list.push({ propertyKey, order: options?.order ?? 0 });\n// };\n// };\n//\n// // Support both @decorator and @decorator() syntax\n// return Object.assign(\n// (target: Object, propertyKey: string | symbol) => {\n// const constructor = target.constructor;\n// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n// if (!list) {\n// list = [];\n// ReflectUtils.defineMetadata(metadataKey, list, constructor);\n// }\n// list.push({ propertyKey, order: 0 });\n// },\n// { __isDecorator: true, __decorator: decorator }\n// ) as any;\n// }\n\n// Helper to handle both @decorator and @decorator() syntax\nfunction createLifecycleDecoratorWithOptions(metadataKey: symbol) {\n return function(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n if (propertyKey) {\n // Direct decorator usage: @decorator\n const constructor = (optionOrTarget as Object).constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: 0 });\n return;\n }\n\n // Decorator with options: @decorator({ order: 1 })\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: (optionOrTarget as LifecycleOptions)?.order ?? 0 });\n };\n };\n}\n\nexport function onInitialize(options?: LifecycleOptions): MethodDecorator;\nexport function onInitialize(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onInitialize(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_INITIALIZE_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedBefore(options?: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedAfter(options?: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onDisconnected = onDisconnectedAfter;\n\nexport function onAdoptedBefore(options?: LifecycleOptions): MethodDecorator;\nexport function onAdoptedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onAdoptedAfter(options?: LifecycleOptions): MethodDecorator;\nexport function onAdoptedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onAdopted = onAdoptedAfter;\n\nexport function onConnectedSwcApp(options?: LifecycleOptions): MethodDecorator;\nexport function onConnectedSwcApp(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedSwcApp(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_SWC_APP_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onConnectedCompleted(options?: LifecycleOptions): MethodDecorator;\nexport function onConnectedCompleted(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedCompleted(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_COMPLETED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\n\n\n\n\nconst decorator = (options: OnConnectedAppendChildOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n};\n\nexport function onConnectedBodyShadow(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedBodyShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedBodyShadow(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: true}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: true}, target, propertyKey);\n };\n}\n\nexport function onConnectedBodyLight(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedBodyLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedBodyLight(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: false}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: false}, target, propertyKey);\n };\n}\nexport function onConnectedBody(options: OnConnectedAppendChildOptions): MethodDecorator;\nexport function onConnectedBody(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBody(optionOrTarget: OnConnectedAppendChildOptions | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator((optionOrTarget as OnConnectedAppendChildOptions) || {}, target, propertyKey);\n };\n}\n\n/**\n * \uD504\uB85C\uD1A0\uD0C0\uC785 \uCCB4\uC778\uC744 \uC21C\uD68C\uD558\uBA70 \uBAA8\uB4E0 \uB77C\uC774\uD504\uC0AC\uC774\uD074 \uBA54\uC11C\uB4DC\uB97C \uC218\uC9D1\uD569\uB2C8\uB2E4.\n */\nexport const findAllLifecycleMetadata = (target: any, metadataKey: symbol): LifecycleMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[] ?? [];\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n};\n\nexport const findAllOnConnectedMetadata = (target: any): OnConnectedAppendChildOptionsMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor) ?? [];\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => {\n const orderA = a.options?.order ?? 0;\n const orderB = b.options?.order ?? 0;\n return orderA - orderB;\n });\n};\n\nexport const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n\nexport const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,6BAA6B,OAAO,IAAI,qCAAqC;AACnF,MAAM,mCAAmC,OAAO,IAAI,0CAA0C;AAC9F,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAC5F,MAAM,sCAAsC,OAAO,IAAI,6CAA6C;AACpG,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,gCAAgC,OAAO,IAAI,uCAAuC;AACxF,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAChG,MAAM,sCAAsC,OAAO,IAAI,mCAAmC;AAE1F,MAAM,6BAA6B;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_INITIALIZE_METADATA_KEY = Symbol.for('simple-web-component:on-constructor');\nexport const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-connected');\nexport const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-connected');\nexport const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-disconnected');\nexport const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-disconnected');\nexport const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');\nexport const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');\nexport const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');\nexport const ON_CONNECTED_BODY_METADATA_KEY = Symbol.for('simple-web-component:on-connected-body');\nexport const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');\nexport const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface OnConnectedAppendChildOptions {\n // ssrFirst?: boolean;\n // replaceWrap?:{ start: string, end:string},\n useShadow?: boolean;\n order?: number;\n // \uBE44\uB3D9\uAE30 \uB80C\uB354\uAC00 \uB05D\uB098\uAE30 \uC804\uAE4C\uC9C0 \uBA3C\uC800 \uBCF4\uC5EC\uC904 \uB0B4\uC6A9. resolve\uB418\uBA74 \uC81C\uAC70\uB418\uACE0 \uC2E4\uC81C \uACB0\uACFC\uAC00 \uB4E4\uC5B4\uAC10.\n fallback?: string | ((helper: any) => string | Node | Node[] | DocumentFragment);\n}\nexport interface OnConnectedAppendChildOptionsMetadata {\n propertyKey: string | symbol;\n options: OnConnectedAppendChildOptions;\n}\n\nexport interface OnConnectedOptions {\n // ssrFirst?: boolean;\n order?: number;\n}\nexport interface OnConnectedMetadata {\n propertyKey: string | symbol;\n options: OnConnectedOptions;\n}\n\nexport interface LifecycleOptions {\n order?: number;\n}\nexport interface LifecycleMetadata {\n propertyKey: string | symbol;\n order?: number;\n}\n\n\nexport function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBefore(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) as OnConnectedMetadata[] | undefined;\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\nexport function onConnectedAfter(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) as OnConnectedMetadata[] | undefined;\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\n\n// function createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {\n// const decorator = (options?: LifecycleOptions): MethodDecorator => {\n// return (target: Object, propertyKey: string | symbol) => {\n// const constructor = target.constructor;\n// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n// if (!list) {\n// list = [];\n// ReflectUtils.defineMetadata(metadataKey, list, constructor);\n// }\n// list.push({ propertyKey, order: options?.order ?? 0 });\n// };\n// };\n//\n// // Support both @decorator and @decorator() syntax\n// return Object.assign(\n// (target: Object, propertyKey: string | symbol) => {\n// const constructor = target.constructor;\n// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n// if (!list) {\n// list = [];\n// ReflectUtils.defineMetadata(metadataKey, list, constructor);\n// }\n// list.push({ propertyKey, order: 0 });\n// },\n// { __isDecorator: true, __decorator: decorator }\n// ) as any;\n// }\n\n// Helper: bare @decorator \uC640 \uC635\uC158 @decorator({...}) (\uBE48 \uAD04\uD638 @decorator() \uB294 \uD0C0\uC785\uC5D0\uC11C \uB9C9\uC74C)\nfunction createLifecycleDecoratorWithOptions(metadataKey: symbol) {\n return function(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n if (propertyKey) {\n // Direct decorator usage: @decorator\n const constructor = (optionOrTarget as Object).constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: 0 });\n return;\n }\n\n // Decorator with options: @decorator({ order: 1 })\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: (optionOrTarget as LifecycleOptions)?.order ?? 0 });\n };\n };\n}\n\nexport function onInitialize(options: LifecycleOptions): MethodDecorator;\nexport function onInitialize(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onInitialize(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_INITIALIZE_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedBefore(options: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedAfter(options: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onDisconnected = onDisconnectedAfter;\n\nexport function onAdoptedBefore(options: LifecycleOptions): MethodDecorator;\nexport function onAdoptedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onAdoptedAfter(options: LifecycleOptions): MethodDecorator;\nexport function onAdoptedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onAdopted = onAdoptedAfter;\n\nexport function onConnectedSwcApp(options: LifecycleOptions): MethodDecorator;\nexport function onConnectedSwcApp(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedSwcApp(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_SWC_APP_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onConnectedCompleted(options: LifecycleOptions): MethodDecorator;\nexport function onConnectedCompleted(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedCompleted(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_COMPLETED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\n\n\n\n\nconst decorator = (options: OnConnectedAppendChildOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor) as OnConnectedAppendChildOptionsMetadata[] | undefined;\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n};\n\nexport function onConnectedBodyShadow(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedBodyShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedBodyShadow(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: true}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator({...})\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: true}, target, propertyKey);\n };\n}\n\nexport function onConnectedBodyLight(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedBodyLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedBodyLight(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: false}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator({...})\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: false}, target, propertyKey);\n };\n}\nexport function onConnectedBody(options: OnConnectedAppendChildOptions): MethodDecorator;\nexport function onConnectedBody(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBody(optionOrTarget: OnConnectedAppendChildOptions | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator({...})\n return (target: Object, propertyKey: string | symbol) => {\n decorator((optionOrTarget as OnConnectedAppendChildOptions) || {}, target, propertyKey);\n };\n}\n\n/**\n * \uD504\uB85C\uD1A0\uD0C0\uC785 \uCCB4\uC778\uC744 \uC21C\uD68C\uD558\uBA70 \uBAA8\uB4E0 \uB77C\uC774\uD504\uC0AC\uC774\uD074 \uBA54\uC11C\uB4DC\uB97C \uC218\uC9D1\uD569\uB2C8\uB2E4.\n */\nexport const findAllLifecycleMetadata = (target: any, metadataKey: symbol): LifecycleMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n const results = ReflectUtils.findAllMetadata<LifecycleMetadata[]>(metadataKey, constructor).flat();\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n};\n\nexport const findAllOnConnectedMetadata = (target: any): OnConnectedAppendChildOptionsMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n const results = ReflectUtils.findAllMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor).flat();\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => {\n const orderA = a.options?.order ?? 0;\n const orderB = b.options?.order ?? 0;\n return orderA - orderB;\n });\n};\n\nexport const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n const results = ReflectUtils.findAllMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor).flat();\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n\nexport const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n const results = ReflectUtils.findAllMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor).flat();\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,6BAA6B,OAAO,IAAI,qCAAqC;AACnF,MAAM,mCAAmC,OAAO,IAAI,0CAA0C;AAC9F,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAC5F,MAAM,sCAAsC,OAAO,IAAI,6CAA6C;AACpG,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,gCAAgC,OAAO,IAAI,uCAAuC;AACxF,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAChG,MAAM,sCAAsC,OAAO,IAAI,mCAAmC;AAE1F,MAAM,6BAA6B;AAmCnC,SAAS,kBAAkB,MAAoC,MAAwB,MAAmD;AAC/I,QAAMA,aAAY,CAAC,SAA6B,QAAgB,gBAAiC;AAC/F,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa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,cAAc,OAAO,WAAW,aAAa,SAAS,OAAO;AACnE,QAAM,UAAU,aAAa,gBAAuC,kCAAkC,WAAW,EAAE,KAAK;AAExH,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;AAEO,MAAM,kCAAkC,CAAC,WAAuC;AACrF,QAAM,cAAc,OAAO,WAAW,aAAa,SAAS,OAAO;AACnE,QAAM,UAAU,aAAa,gBAAuC,iCAAiC,WAAW,EAAE,KAAK;AAEvH,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;",
|
|
6
6
|
"names": ["decorator", "propertyKey"]
|
|
7
7
|
}
|
|
@@ -2,10 +2,11 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { ReflectUtils } from "@dooboostore/core";
|
|
5
|
+
import { buildSwcParameterArgs } from "./parameter.js";
|
|
5
6
|
const MUTATION_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:mutation-observer");
|
|
6
7
|
const applyMutationObserver = (selector, options, targetObj, propertyKey) => {
|
|
7
8
|
const constructor = targetObj.constructor;
|
|
8
|
-
let observers = ReflectUtils.
|
|
9
|
+
let observers = ReflectUtils.getOwnMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor);
|
|
9
10
|
if (!observers) {
|
|
10
11
|
observers = [];
|
|
11
12
|
ReflectUtils.defineMetadata(MUTATION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
@@ -20,7 +21,7 @@ const resolveMutationObserverArgs = (selectorOrOptions, maybeOptions, extra) =>
|
|
|
20
21
|
};
|
|
21
22
|
const dispatchMutationObserver = (selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, extra) => {
|
|
22
23
|
if ((typeof maybeOptionsOrPropertyKey === "string" || typeof maybeOptionsOrPropertyKey === "symbol") && descriptor !== void 0) {
|
|
23
|
-
applyMutationObserver("$this", { ...extra }, selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey);
|
|
24
|
+
applyMutationObserver("$this", { subtree: true, ...extra }, selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
const { selector, options } = resolveMutationObserverArgs(
|
|
@@ -35,9 +36,6 @@ const dispatchMutationObserver = (selectorOrOptionsOrTarget, maybeOptionsOrPrope
|
|
|
35
36
|
function mutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
36
37
|
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});
|
|
37
38
|
}
|
|
38
|
-
function mutationObserverThis(optionsOrTarget, propertyKey, descriptor) {
|
|
39
|
-
return dispatchMutationObserver(optionsOrTarget, propertyKey, descriptor, {});
|
|
40
|
-
}
|
|
41
39
|
function mutationObserverDelegateLight(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
42
40
|
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "light", delegate: true });
|
|
43
41
|
}
|
|
@@ -60,20 +58,21 @@ function mutationObserverAll(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKe
|
|
|
60
58
|
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "all" });
|
|
61
59
|
}
|
|
62
60
|
function getMutationObserverMetadata(target) {
|
|
63
|
-
const constructor = target
|
|
64
|
-
return ReflectUtils.
|
|
61
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
62
|
+
return ReflectUtils.findAllMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor).flat();
|
|
65
63
|
}
|
|
64
|
+
import { inObserverScope } from "../types/index.js";
|
|
66
65
|
import { SwcUtils } from "../utils/Utils.js";
|
|
67
66
|
class MutationObserverLifeCycler {
|
|
68
67
|
constructor() {
|
|
69
68
|
__publicField(this, "removeObserverCallbacksMap", /* @__PURE__ */ new WeakMap());
|
|
70
69
|
}
|
|
71
|
-
onConnected(helperHostSet) {
|
|
70
|
+
onConnected(helperHostSet, _set, scope) {
|
|
72
71
|
const inst = helperHostSet.$this;
|
|
73
72
|
const currentWin = helperHostSet.$w;
|
|
74
|
-
const removeObserverCallbacks = [];
|
|
73
|
+
const removeObserverCallbacks = scope === "rest" && this.removeObserverCallbacksMap.get(inst) || [];
|
|
75
74
|
this.removeObserverCallbacksMap.set(inst, removeObserverCallbacks);
|
|
76
|
-
const allMeta = getMutationObserverMetadata(inst) ?? [];
|
|
75
|
+
const allMeta = (getMutationObserverMetadata(inst) ?? []).filter((m) => inObserverScope(m, scope));
|
|
77
76
|
if (allMeta.length === 0) return;
|
|
78
77
|
const shadowMetas = allMeta.filter((m) => {
|
|
79
78
|
const r = m.options.root || "auto";
|
|
@@ -98,11 +97,13 @@ class MutationObserverLifeCycler {
|
|
|
98
97
|
if (!init.childList && !init.attributes && !init.characterData) init.childList = true;
|
|
99
98
|
return init;
|
|
100
99
|
};
|
|
101
|
-
const
|
|
100
|
+
const observedNodes = /* @__PURE__ */ new Map();
|
|
101
|
+
const owns = (meta, m) => (observedNodes.get(meta) ?? []).some((o) => o === m.target || !!meta.options.subtree && o.contains(m.target));
|
|
102
102
|
const callback = (mutations, obs) => {
|
|
103
103
|
for (const meta of metas) {
|
|
104
104
|
const { selector, options } = meta;
|
|
105
105
|
let matchedEls = [];
|
|
106
|
+
let records = mutations;
|
|
106
107
|
const typeMatches = (m) => {
|
|
107
108
|
const has = !!(options.childList || options.attributes || options.characterData);
|
|
108
109
|
if (m.type === "childList") return has ? !!options.childList : true;
|
|
@@ -110,7 +111,7 @@ class MutationObserverLifeCycler {
|
|
|
110
111
|
if (m.type === "characterData") return !!options.characterData;
|
|
111
112
|
return true;
|
|
112
113
|
};
|
|
113
|
-
const collect = (matchesSel) =>
|
|
114
|
+
const collect = (matchesSel, records2 = mutations) => records2.flatMap((m) => {
|
|
114
115
|
if (!typeMatches(m)) return [];
|
|
115
116
|
const els = [];
|
|
116
117
|
if (matchesSel(m.target)) els.push(m.target);
|
|
@@ -118,33 +119,55 @@ class MutationObserverLifeCycler {
|
|
|
118
119
|
Array.from(m.removedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
|
|
119
120
|
return els;
|
|
120
121
|
});
|
|
121
|
-
if (
|
|
122
|
-
|
|
122
|
+
if (typeof selector === "string" && (selector === "$this" || selector === "")) {
|
|
123
|
+
records = mutations.filter((m) => typeMatches(m) && owns(meta, m));
|
|
124
|
+
matchedEls = records.length ? [inst] : [];
|
|
125
|
+
} else if (options.delegate && typeof selector === "string") {
|
|
123
126
|
matchedEls = collect((n) => {
|
|
124
127
|
if (!n || n.nodeType !== 1) return false;
|
|
125
|
-
if (isThis) return true;
|
|
126
128
|
const el = n;
|
|
127
129
|
return el.matches?.(selector) || !!el.closest?.(selector);
|
|
128
130
|
});
|
|
129
131
|
} else if (typeof selector === "string") {
|
|
130
|
-
|
|
131
|
-
matchedEls = collect((n) => {
|
|
132
|
+
records = mutations.filter((m) => owns(meta, m));
|
|
133
|
+
matchedEls = records.length ? collect((n) => {
|
|
132
134
|
if (!n || n.nodeType !== 1) return false;
|
|
133
|
-
if (isThis) return true;
|
|
134
135
|
return n.matches?.(selector);
|
|
135
|
-
});
|
|
136
|
+
}, records) : [];
|
|
136
137
|
} else if (typeof selector === "function") {
|
|
137
|
-
|
|
138
|
-
matchedEls =
|
|
138
|
+
records = mutations.filter((m) => typeMatches(m) && owns(meta, m));
|
|
139
|
+
matchedEls = (observedNodes.get(meta) ?? []).filter((o) => records.some((m) => o === m.target || !!options.subtree && o.contains(m.target)));
|
|
139
140
|
} else {
|
|
140
141
|
matchedEls = mutations.filter((m) => typeMatches(m)).map((m) => m.target).filter((t) => t && t.nodeType === 1);
|
|
141
142
|
}
|
|
142
143
|
if (matchedEls.length === 0) continue;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
void (async () => {
|
|
145
|
+
const helper = SwcUtils.getHelperAndHostSet(inst);
|
|
146
|
+
if (options.filter && !await options.filter(matchedEls, { currentThis: inst, helper })) return;
|
|
147
|
+
const hostSet = SwcUtils.getHostSet(inst);
|
|
148
|
+
const helperSet = SwcUtils.getHelperSet(helperHostSet.$w);
|
|
149
|
+
const legacyArgs = [matchedEls, records, obs, { ...hostSet, $root: root }];
|
|
150
|
+
const buildArgs = (beforeReturn) => buildSwcParameterArgs(inst, meta.propertyKey, {
|
|
151
|
+
hostSet,
|
|
152
|
+
helperHostSet: helper,
|
|
153
|
+
helperSet,
|
|
154
|
+
mutationObserverBeforeReturn: beforeReturn
|
|
155
|
+
}, [...legacyArgs, beforeReturn]);
|
|
156
|
+
let args = buildArgs(void 0);
|
|
157
|
+
if (options.before) {
|
|
158
|
+
const br = await options.before(matchedEls, { currentThis: inst, helper });
|
|
159
|
+
args = buildArgs(br);
|
|
160
|
+
}
|
|
161
|
+
let result, error;
|
|
162
|
+
try {
|
|
163
|
+
result = await inst[meta.propertyKey](...args);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
error = e;
|
|
166
|
+
} finally {
|
|
167
|
+
if (options.finally) await options.finally(matchedEls, { currentThis: inst, helper }, { args, result, error });
|
|
168
|
+
}
|
|
169
|
+
if (error) throw error;
|
|
170
|
+
})().catch((e) => console.error("[SWC] mutationObserver handler error:", e));
|
|
148
171
|
}
|
|
149
172
|
};
|
|
150
173
|
const observeTargets = [];
|
|
@@ -155,23 +178,17 @@ class MutationObserverLifeCycler {
|
|
|
155
178
|
const { selector, options } = m;
|
|
156
179
|
const mInit = initFrom(options);
|
|
157
180
|
if (typeof selector === "string") {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
root.querySelectorAll(selector).forEach((el) => observeTargets.push({ target: el, options: mInit }));
|
|
162
|
-
}
|
|
181
|
+
const nodes = selector === "$this" || selector === "" ? [root] : Array.from(root.querySelectorAll(selector));
|
|
182
|
+
for (const n of nodes) observeTargets.push({ target: n, options: mInit });
|
|
183
|
+
observedNodes.set(m, nodes);
|
|
163
184
|
} else if (typeof selector === "function") {
|
|
164
185
|
const res = selector(inst, helperHostSet);
|
|
165
186
|
let targets = [];
|
|
166
187
|
if (res instanceof currentWin.HTMLElement) targets = [res];
|
|
167
188
|
else if (res instanceof currentWin.NodeList) targets = Array.from(res).filter((e) => e instanceof currentWin.HTMLElement);
|
|
168
189
|
else if (Array.isArray(res)) targets = res.filter((e) => e instanceof currentWin.HTMLElement);
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
set.add(el);
|
|
172
|
-
observeTargets.push({ target: el, options: mInit });
|
|
173
|
-
}
|
|
174
|
-
fnObservedSets.set(m, set);
|
|
190
|
+
for (const el of targets) observeTargets.push({ target: el, options: mInit });
|
|
191
|
+
observedNodes.set(m, targets);
|
|
175
192
|
}
|
|
176
193
|
}
|
|
177
194
|
for (const m of metas) {
|
|
@@ -211,7 +228,6 @@ export {
|
|
|
211
228
|
mutationObserverDelegateLight,
|
|
212
229
|
mutationObserverDelegateShadow,
|
|
213
230
|
mutationObserverLight,
|
|
214
|
-
mutationObserverShadow
|
|
215
|
-
mutationObserverThis
|
|
231
|
+
mutationObserverShadow
|
|
216
232
|
};
|
|
217
233
|
//# sourceMappingURL=mutationObserver.js.map
|