@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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAE7B,uBAAsC;AAmKtC,mBAAyB;AAlIlB,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAEzG,MAAM,4BAA4B,CAAC,UAAuB,SAAsC,WAAmB,gBAAuC;AACxJ,QAAM,cAAc,UAAU;AAC9B,MAAI,YAAY,yBAAa,eAAe,oCAAoC,WAAW;AAC3F,MAAI,CAAC,WAAW;AACd,gBAAY,CAAC;AACb,6BAAa,eAAe,oCAAoC,WAAW,WAA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AAG;AAAE,gBAAQ,MAAM,+BAA+B,CAAC;AAAA,MAAG;AAAA,IAClG;AACA,SAAK,2BAA2B,OAAO,IAAI;AAAA,EAC7C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -65,7 +65,7 @@ const ATTRIBUTE_CHANGED_WILDCARD = "*";
|
|
|
65
65
|
function onConnectedBefore(arg1, arg2, arg3) {
|
|
66
66
|
const decorator2 = (options, target, propertyKey) => {
|
|
67
67
|
const constructor = target.constructor;
|
|
68
|
-
let list = import_core.ReflectUtils.
|
|
68
|
+
let list = import_core.ReflectUtils.getOwnMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);
|
|
69
69
|
if (!list) {
|
|
70
70
|
list = [];
|
|
71
71
|
import_core.ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);
|
|
@@ -82,7 +82,7 @@ function onConnectedBefore(arg1, arg2, arg3) {
|
|
|
82
82
|
function onConnectedAfter(arg1, arg2, arg3) {
|
|
83
83
|
const decorator2 = (options, target, propertyKey) => {
|
|
84
84
|
const constructor = target.constructor;
|
|
85
|
-
let list = import_core.ReflectUtils.
|
|
85
|
+
let list = import_core.ReflectUtils.getOwnMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor);
|
|
86
86
|
if (!list) {
|
|
87
87
|
list = [];
|
|
88
88
|
import_core.ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);
|
|
@@ -144,7 +144,7 @@ function onConnectedCompleted(optionOrTarget, propertyKey) {
|
|
|
144
144
|
}
|
|
145
145
|
const decorator = (options, target, propertyKey) => {
|
|
146
146
|
const constructor = target.constructor;
|
|
147
|
-
let list = import_core.ReflectUtils.
|
|
147
|
+
let list = import_core.ReflectUtils.getOwnMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor);
|
|
148
148
|
if (!list) {
|
|
149
149
|
list = [];
|
|
150
150
|
import_core.ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);
|
|
@@ -176,13 +176,13 @@ function onConnectedBody(optionOrTarget, propertyKey, arg3) {
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
const findAllLifecycleMetadata = (target, metadataKey) => {
|
|
179
|
-
const constructor = target
|
|
180
|
-
const results = import_core.ReflectUtils.
|
|
179
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
180
|
+
const results = import_core.ReflectUtils.findAllMetadata(metadataKey, constructor).flat();
|
|
181
181
|
return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
182
182
|
};
|
|
183
183
|
const findAllOnConnectedMetadata = (target) => {
|
|
184
|
-
const constructor = target
|
|
185
|
-
const results = import_core.ReflectUtils.
|
|
184
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
185
|
+
const results = import_core.ReflectUtils.findAllMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor).flat();
|
|
186
186
|
return [...results].sort((a, b) => {
|
|
187
187
|
const orderA = a.options?.order ?? 0;
|
|
188
188
|
const orderB = b.options?.order ?? 0;
|
|
@@ -190,13 +190,13 @@ const findAllOnConnectedMetadata = (target) => {
|
|
|
190
190
|
});
|
|
191
191
|
};
|
|
192
192
|
const findAllOnConnectedBeforeMetadata = (target) => {
|
|
193
|
-
const constructor = target
|
|
194
|
-
const results = import_core.ReflectUtils.
|
|
193
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
194
|
+
const results = import_core.ReflectUtils.findAllMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor).flat();
|
|
195
195
|
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
196
196
|
};
|
|
197
197
|
const findAllOnConnectedAfterMetadata = (target) => {
|
|
198
|
-
const constructor = target
|
|
199
|
-
const results = import_core.ReflectUtils.
|
|
198
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
199
|
+
const results = import_core.ReflectUtils.findAllMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor).flat();
|
|
200
200
|
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
201
201
|
};
|
|
202
202
|
//# sourceMappingURL=lifecycles.js.map
|
|
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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["decorator", "propertyKey"]
|
|
7
7
|
}
|
|
@@ -29,16 +29,17 @@ __export(mutationObserver_exports, {
|
|
|
29
29
|
mutationObserverDelegateLight: () => mutationObserverDelegateLight,
|
|
30
30
|
mutationObserverDelegateShadow: () => mutationObserverDelegateShadow,
|
|
31
31
|
mutationObserverLight: () => mutationObserverLight,
|
|
32
|
-
mutationObserverShadow: () => mutationObserverShadow
|
|
33
|
-
mutationObserverThis: () => mutationObserverThis
|
|
32
|
+
mutationObserverShadow: () => mutationObserverShadow
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(mutationObserver_exports);
|
|
36
35
|
var import_core = require("@dooboostore/core");
|
|
36
|
+
var import_parameter = require("./parameter");
|
|
37
|
+
var import_types2 = require("../types");
|
|
37
38
|
var import_Utils = require("../utils/Utils");
|
|
38
39
|
const MUTATION_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:mutation-observer");
|
|
39
40
|
const applyMutationObserver = (selector, options, targetObj, propertyKey) => {
|
|
40
41
|
const constructor = targetObj.constructor;
|
|
41
|
-
let observers = import_core.ReflectUtils.
|
|
42
|
+
let observers = import_core.ReflectUtils.getOwnMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor);
|
|
42
43
|
if (!observers) {
|
|
43
44
|
observers = [];
|
|
44
45
|
import_core.ReflectUtils.defineMetadata(MUTATION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
@@ -53,7 +54,7 @@ const resolveMutationObserverArgs = (selectorOrOptions, maybeOptions, extra) =>
|
|
|
53
54
|
};
|
|
54
55
|
const dispatchMutationObserver = (selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, extra) => {
|
|
55
56
|
if ((typeof maybeOptionsOrPropertyKey === "string" || typeof maybeOptionsOrPropertyKey === "symbol") && descriptor !== void 0) {
|
|
56
|
-
applyMutationObserver("$this", { ...extra }, selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey);
|
|
57
|
+
applyMutationObserver("$this", { subtree: true, ...extra }, selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey);
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
const { selector, options } = resolveMutationObserverArgs(
|
|
@@ -68,9 +69,6 @@ const dispatchMutationObserver = (selectorOrOptionsOrTarget, maybeOptionsOrPrope
|
|
|
68
69
|
function mutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
69
70
|
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});
|
|
70
71
|
}
|
|
71
|
-
function mutationObserverThis(optionsOrTarget, propertyKey, descriptor) {
|
|
72
|
-
return dispatchMutationObserver(optionsOrTarget, propertyKey, descriptor, {});
|
|
73
|
-
}
|
|
74
72
|
function mutationObserverDelegateLight(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor) {
|
|
75
73
|
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "light", delegate: true });
|
|
76
74
|
}
|
|
@@ -93,19 +91,19 @@ function mutationObserverAll(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKe
|
|
|
93
91
|
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, { root: "all" });
|
|
94
92
|
}
|
|
95
93
|
function getMutationObserverMetadata(target) {
|
|
96
|
-
const constructor = target
|
|
97
|
-
return import_core.ReflectUtils.
|
|
94
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
95
|
+
return import_core.ReflectUtils.findAllMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor).flat();
|
|
98
96
|
}
|
|
99
97
|
class MutationObserverLifeCycler {
|
|
100
98
|
constructor() {
|
|
101
99
|
__publicField(this, "removeObserverCallbacksMap", /* @__PURE__ */ new WeakMap());
|
|
102
100
|
}
|
|
103
|
-
onConnected(helperHostSet) {
|
|
101
|
+
onConnected(helperHostSet, _set, scope) {
|
|
104
102
|
const inst = helperHostSet.$this;
|
|
105
103
|
const currentWin = helperHostSet.$w;
|
|
106
|
-
const removeObserverCallbacks = [];
|
|
104
|
+
const removeObserverCallbacks = scope === "rest" && this.removeObserverCallbacksMap.get(inst) || [];
|
|
107
105
|
this.removeObserverCallbacksMap.set(inst, removeObserverCallbacks);
|
|
108
|
-
const allMeta = getMutationObserverMetadata(inst) ?? [];
|
|
106
|
+
const allMeta = (getMutationObserverMetadata(inst) ?? []).filter((m) => (0, import_types2.inObserverScope)(m, scope));
|
|
109
107
|
if (allMeta.length === 0) return;
|
|
110
108
|
const shadowMetas = allMeta.filter((m) => {
|
|
111
109
|
const r = m.options.root || "auto";
|
|
@@ -130,11 +128,13 @@ class MutationObserverLifeCycler {
|
|
|
130
128
|
if (!init.childList && !init.attributes && !init.characterData) init.childList = true;
|
|
131
129
|
return init;
|
|
132
130
|
};
|
|
133
|
-
const
|
|
131
|
+
const observedNodes = /* @__PURE__ */ new Map();
|
|
132
|
+
const owns = (meta, m) => (observedNodes.get(meta) ?? []).some((o) => o === m.target || !!meta.options.subtree && o.contains(m.target));
|
|
134
133
|
const callback = (mutations, obs) => {
|
|
135
134
|
for (const meta of metas) {
|
|
136
135
|
const { selector, options } = meta;
|
|
137
136
|
let matchedEls = [];
|
|
137
|
+
let records = mutations;
|
|
138
138
|
const typeMatches = (m) => {
|
|
139
139
|
const has = !!(options.childList || options.attributes || options.characterData);
|
|
140
140
|
if (m.type === "childList") return has ? !!options.childList : true;
|
|
@@ -142,7 +142,7 @@ class MutationObserverLifeCycler {
|
|
|
142
142
|
if (m.type === "characterData") return !!options.characterData;
|
|
143
143
|
return true;
|
|
144
144
|
};
|
|
145
|
-
const collect = (matchesSel) =>
|
|
145
|
+
const collect = (matchesSel, records2 = mutations) => records2.flatMap((m) => {
|
|
146
146
|
if (!typeMatches(m)) return [];
|
|
147
147
|
const els = [];
|
|
148
148
|
if (matchesSel(m.target)) els.push(m.target);
|
|
@@ -150,33 +150,55 @@ class MutationObserverLifeCycler {
|
|
|
150
150
|
Array.from(m.removedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
|
|
151
151
|
return els;
|
|
152
152
|
});
|
|
153
|
-
if (
|
|
154
|
-
|
|
153
|
+
if (typeof selector === "string" && (selector === "$this" || selector === "")) {
|
|
154
|
+
records = mutations.filter((m) => typeMatches(m) && owns(meta, m));
|
|
155
|
+
matchedEls = records.length ? [inst] : [];
|
|
156
|
+
} else if (options.delegate && typeof selector === "string") {
|
|
155
157
|
matchedEls = collect((n) => {
|
|
156
158
|
if (!n || n.nodeType !== 1) return false;
|
|
157
|
-
if (isThis) return true;
|
|
158
159
|
const el = n;
|
|
159
160
|
return el.matches?.(selector) || !!el.closest?.(selector);
|
|
160
161
|
});
|
|
161
162
|
} else if (typeof selector === "string") {
|
|
162
|
-
|
|
163
|
-
matchedEls = collect((n) => {
|
|
163
|
+
records = mutations.filter((m) => owns(meta, m));
|
|
164
|
+
matchedEls = records.length ? collect((n) => {
|
|
164
165
|
if (!n || n.nodeType !== 1) return false;
|
|
165
|
-
if (isThis) return true;
|
|
166
166
|
return n.matches?.(selector);
|
|
167
|
-
});
|
|
167
|
+
}, records) : [];
|
|
168
168
|
} else if (typeof selector === "function") {
|
|
169
|
-
|
|
170
|
-
matchedEls =
|
|
169
|
+
records = mutations.filter((m) => typeMatches(m) && owns(meta, m));
|
|
170
|
+
matchedEls = (observedNodes.get(meta) ?? []).filter((o) => records.some((m) => o === m.target || !!options.subtree && o.contains(m.target)));
|
|
171
171
|
} else {
|
|
172
172
|
matchedEls = mutations.filter((m) => typeMatches(m)).map((m) => m.target).filter((t) => t && t.nodeType === 1);
|
|
173
173
|
}
|
|
174
174
|
if (matchedEls.length === 0) continue;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
void (async () => {
|
|
176
|
+
const helper = import_Utils.SwcUtils.getHelperAndHostSet(inst);
|
|
177
|
+
if (options.filter && !await options.filter(matchedEls, { currentThis: inst, helper })) return;
|
|
178
|
+
const hostSet = import_Utils.SwcUtils.getHostSet(inst);
|
|
179
|
+
const helperSet = import_Utils.SwcUtils.getHelperSet(helperHostSet.$w);
|
|
180
|
+
const legacyArgs = [matchedEls, records, obs, { ...hostSet, $root: root }];
|
|
181
|
+
const buildArgs = (beforeReturn) => (0, import_parameter.buildSwcParameterArgs)(inst, meta.propertyKey, {
|
|
182
|
+
hostSet,
|
|
183
|
+
helperHostSet: helper,
|
|
184
|
+
helperSet,
|
|
185
|
+
mutationObserverBeforeReturn: beforeReturn
|
|
186
|
+
}, [...legacyArgs, beforeReturn]);
|
|
187
|
+
let args = buildArgs(void 0);
|
|
188
|
+
if (options.before) {
|
|
189
|
+
const br = await options.before(matchedEls, { currentThis: inst, helper });
|
|
190
|
+
args = buildArgs(br);
|
|
191
|
+
}
|
|
192
|
+
let result, error;
|
|
193
|
+
try {
|
|
194
|
+
result = await inst[meta.propertyKey](...args);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
error = e;
|
|
197
|
+
} finally {
|
|
198
|
+
if (options.finally) await options.finally(matchedEls, { currentThis: inst, helper }, { args, result, error });
|
|
199
|
+
}
|
|
200
|
+
if (error) throw error;
|
|
201
|
+
})().catch((e) => console.error("[SWC] mutationObserver handler error:", e));
|
|
180
202
|
}
|
|
181
203
|
};
|
|
182
204
|
const observeTargets = [];
|
|
@@ -187,23 +209,17 @@ class MutationObserverLifeCycler {
|
|
|
187
209
|
const { selector, options } = m;
|
|
188
210
|
const mInit = initFrom(options);
|
|
189
211
|
if (typeof selector === "string") {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
root.querySelectorAll(selector).forEach((el) => observeTargets.push({ target: el, options: mInit }));
|
|
194
|
-
}
|
|
212
|
+
const nodes = selector === "$this" || selector === "" ? [root] : Array.from(root.querySelectorAll(selector));
|
|
213
|
+
for (const n of nodes) observeTargets.push({ target: n, options: mInit });
|
|
214
|
+
observedNodes.set(m, nodes);
|
|
195
215
|
} else if (typeof selector === "function") {
|
|
196
216
|
const res = selector(inst, helperHostSet);
|
|
197
217
|
let targets = [];
|
|
198
218
|
if (res instanceof currentWin.HTMLElement) targets = [res];
|
|
199
219
|
else if (res instanceof currentWin.NodeList) targets = Array.from(res).filter((e) => e instanceof currentWin.HTMLElement);
|
|
200
220
|
else if (Array.isArray(res)) targets = res.filter((e) => e instanceof currentWin.HTMLElement);
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
set.add(el);
|
|
204
|
-
observeTargets.push({ target: el, options: mInit });
|
|
205
|
-
}
|
|
206
|
-
fnObservedSets.set(m, set);
|
|
221
|
+
for (const el of targets) observeTargets.push({ target: el, options: mInit });
|
|
222
|
+
observedNodes.set(m, targets);
|
|
207
223
|
}
|
|
208
224
|
}
|
|
209
225
|
for (const m of metas) {
|