@dooboostore/simple-web-component 1.0.52 → 1.0.53
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 +7 -8
- package/dist/cjs/decorators/addEventListener.js +8 -3
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/requestAnimationFrame.js +10 -2
- package/dist/cjs/decorators/requestAnimationFrame.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +4 -2
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +4 -2
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessage.js +14 -1
- package/dist/cjs/decorators/subscribeSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +8 -3
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/requestAnimationFrame.js +10 -2
- package/dist/esm/decorators/requestAnimationFrame.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +4 -2
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +4 -2
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessage.js +14 -1
- package/dist/esm/decorators/subscribeSwcAppMessage.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +36 -6
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/requestAnimationFrame.d.ts +7 -4
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +6 -4
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +6 -4
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts +12 -0
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +36 -6
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +1 -1
- package/src/decorators/addEventListener.ts +10 -3
- package/src/decorators/requestAnimationFrame.ts +17 -5
- package/src/decorators/setInterval.ts +9 -5
- package/src/decorators/setTimeout.ts +9 -5
- package/src/decorators/subscribeSwcAppMessage.ts +27 -0
|
@@ -25,7 +25,7 @@ const startFrameLoop = (win, entries, frameFn) => {
|
|
|
25
25
|
};
|
|
26
26
|
const applyRequestAnimationFrame = (options, target, propertyKey, descriptor) => {
|
|
27
27
|
const constructor = target.constructor;
|
|
28
|
-
const normalizedOptions = { ...options, type: options.type ?? "
|
|
28
|
+
const normalizedOptions = { ...options, type: options.type ?? "onConnected" };
|
|
29
29
|
let metaList = ReflectUtils.getOwnMetadata(REQUEST_ANIMATION_FRAME_METADATA_KEY, constructor);
|
|
30
30
|
if (!metaList) {
|
|
31
31
|
metaList = [];
|
|
@@ -87,10 +87,18 @@ class RequestAnimationFrameLifeCycler {
|
|
|
87
87
|
inst.__swc_requestAnimationFrameIds = [];
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
function requestAnimationFrameReturnValue(optionsOrTarget, propertyKey, descriptor) {
|
|
91
|
+
if (propertyKey !== void 0) {
|
|
92
|
+
applyRequestAnimationFrame({ type: "returnValue" }, optionsOrTarget, propertyKey, descriptor);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
return (target, propertyKey2, descriptor2) => applyRequestAnimationFrame({ ...optionsOrTarget ?? {}, type: "returnValue" }, target, propertyKey2, descriptor2);
|
|
96
|
+
}
|
|
90
97
|
export {
|
|
91
98
|
REQUEST_ANIMATION_FRAME_METADATA_KEY,
|
|
92
99
|
RequestAnimationFrameLifeCycler,
|
|
93
100
|
findAllRequestAnimationFrameMetadata,
|
|
94
|
-
requestAnimationFrame
|
|
101
|
+
requestAnimationFrame,
|
|
102
|
+
requestAnimationFrameReturnValue
|
|
95
103
|
};
|
|
96
104
|
//# sourceMappingURL=requestAnimationFrame.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/requestAnimationFrame.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\n\nexport const REQUEST_ANIMATION_FRAME_METADATA_KEY = Symbol.for('simple-web-component:request-animation-frame');\n\nexport type RequestAnimationFrameType = 'onConnected' | 'returnValue';\n\nexport interface RequestAnimationFrameOptions {\n /**\n * 'onConnected' - connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uB8E8\uD504 \uC2DC\uC791 (\uB9E4 \uD504\uB808\uC784 \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C), disconnect \uC2DC \uC790\uB3D9 \uC815\uB9AC.\n * 'returnValue'(\uAE30\uBCF8\uAC12) - \uC790\uB3D9 \uC2DC\uC791 \uC5C6\uC74C. \uAC1C\uBC1C\uC790\uAC00 \uC774 \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC2DC\uC791\uB418\uACE0,\n * \uADF8 \uD638\uCD9C\uC758 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uC2E4\uC81C\uB85C \uB9E4 \uD504\uB808\uC784 \uD638\uCD9C\uB420 \uD568\uC218\uAC00 \uB41C\uB2E4.\n */\n type?: RequestAnimationFrameType;\n /** \uB8E8\uD504 \uC2DC\uC791 \uC9C1\uD6C4 1\uD68C \uD638\uCD9C (\uB514\uBC84\uAE45/\uB85C\uAE45\uC6A9). id\uB294 \uCCAB requestAnimationFrame \uBC18\uD658\uAC12 - cleanup\uC740 \uC790\uB3D9\uC73C\uB85C \uCC98\uB9AC\uB418\uBBC0\uB85C \uC9C1\uC811 \uCDE8\uC18C\uD560 \uD544\uC694 \uC5C6\uC74C. */\n created?: (set: HelperHostSet, id: number) => void;\n /**\n * type:'returnValue' \uC804\uC6A9 - \uB9AC\uD134\uAC12\uC774 \uD568\uC218\uBA74 \uADF8 \uC790\uCCB4\uB97C, \uAC1D\uCCB4\uBA74 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC77C \uB54C \uADF8 \uAC12\uC744\n * \"\uB9E4 \uD504\uB808\uC784 \uD638\uCD9C\uB420 \uD568\uC218\"\uB85C \uC0AC\uC6A9\uD55C\uB2E4. \uC548 \uC8FC\uBA74 REQUEST_ANIMATION_FRAME_METADATA_KEY\uB85C \uD3F4\uBC31\uD55C\uB2E4 -\n * applyAttribute.ts/applyNode.ts\uC758 valueKey\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158.\n */\n valueKey?: symbol | string;\n}\n\nexport interface RequestAnimationFrameMetadata {\n propertyKey: string | symbol;\n options: RequestAnimationFrameOptions;\n}\n\n/**\n * \uD504\uB808\uC784 \uCF5C\uBC31 \uC2DC\uADF8\uB2C8\uCC98.\n * - timestamp: \uC774\uBC88 \uD504\uB808\uC784\uC758 \uC2DC\uAC01 (requestAnimationFrame\uC774 \uB118\uACA8\uC8FC\uB294 \uAC12)\n * - prevValue: \uC9C1\uC804 \uD638\uCD9C\uC774 \uB9AC\uD134\uD55C \uAC12 (\uCCAB \uD638\uCD9C\uC5D0\uC11C\uB294 undefined)\n * \uB9AC\uD134\uAC12\uC774 undefined/null\uC774\uBA74 \uB2E4\uC74C \uD504\uB808\uC784\uC744 \uC608\uC57D\uD558\uC9C0 \uC54A\uACE0 \uB8E8\uD504\uAC00 \uBA48\uCD98\uB2E4 (\uAC1C\uBC1C\uC790\uAC00 \uC885\uB8CC\uB97C \uC81C\uC5B4).\n * undefined/null\uC774 \uC544\uB2CC \uAC12\uC744 \uB9AC\uD134\uD558\uBA74 \uADF8 \uAC12 \uADF8\uB300\uB85C \uB2E4\uC74C \uD638\uCD9C\uC758 prevValue\uB85C \uC804\uB2EC\uB41C\uB2E4.\n */\nexport type FrameCallback = (timestamp: number, prevValue?: any) => any;\n\nconst getActiveEntries = (inst: any): number[] => (inst.__swc_requestAnimationFrameIds ??= []);\n\nconst startFrameLoop = (win: Window, entries: number[], frameFn: FrameCallback): number => {\n let currentId = 0;\n const step = (timestamp: number, prevValue?: any) => {\n const idx = entries.indexOf(currentId);\n if (idx >= 0) entries.splice(idx, 1);\n let result: any;\n try {\n result = frameFn(timestamp, prevValue);\n } catch (e) {\n console.error('[SWC] requestAnimationFrame callback error:', e);\n return;\n }\n if (result === undefined || result === null) return; // \uAC1C\uBC1C\uC790\uAC00 \uC885\uB8CC\uB97C \uC2E0\uD638\uD568 - \uB2E4\uC74C \uD504\uB808\uC784 \uC608\uC57D \uC548 \uD568\n currentId = win.requestAnimationFrame(ts => step(ts, result));\n entries.push(currentId);\n };\n currentId = win.requestAnimationFrame(ts => step(ts, undefined));\n entries.push(currentId);\n return currentId;\n};\n\nconst applyRequestAnimationFrame = (options: RequestAnimationFrameOptions, target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void => {\n const constructor = target.constructor;\n const normalizedOptions: RequestAnimationFrameOptions = { ...options, type: options.type ?? 'returnValue' };\n\n let metaList = ReflectUtils.getOwnMetadata(REQUEST_ANIMATION_FRAME_METADATA_KEY, constructor) as RequestAnimationFrameMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(REQUEST_ANIMATION_FRAME_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, options: normalizedOptions });\n\n if (normalizedOptions.type === 'onConnected' || !descriptor) {\n return; // LifeCycler\uAC00 connect/disconnect\uB97C \uC804\uB2F4 - wrapping \uBD88\uD544\uC694\n }\n\n const original = descriptor.value;\n descriptor.value = function (this: any, ...args: any[]) {\n const res = original.apply(this, args);\n // valueKey\uB97C \uC548 \uC8FC\uBA74 \uC774 \uB370\uCF54\uB808\uC774\uD130 \uC804\uC6A9 METADATA_KEY\uB85C \uD3F4\uBC31 (applyAttribute.ts/applyNode.ts\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158)\n const vk = normalizedOptions.valueKey ?? REQUEST_ANIMATION_FRAME_METADATA_KEY;\n const frameFn: FrameCallback | undefined =\n typeof res === 'function' ? res : res && typeof res === 'object' && typeof res[vk] === 'function' ? res[vk] : undefined;\n\n if (frameFn) {\n ensureInit(this);\n const win = SwcUtils.resolveWindow(this);\n const id = startFrameLoop(win, getActiveEntries(this), frameFn);\n normalizedOptions.created?.(SwcUtils.getHelperAndHostSet(this), id);\n }\n return res;\n };\n return descriptor;\n};\n\n/**\n * type:'onConnected' - connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uB9E4 \uD504\uB808\uC784 \uB8E8\uD504\uB97C \uC2DC\uC791\uD558\uACE0, disconnect \uC2DC \uC790\uB3D9\uC73C\uB85C cancelAnimationFrame \uD55C\uB2E4.\n * type:'returnValue'(\uAE30\uBCF8\uAC12) - \uBA54\uC11C\uB4DC\uB97C \uAC10\uC2F8\uC9C0 \uC54A\uB294 \uB300\uC2E0, \uD638\uCD9C\uB420 \uB54C\uB9C8\uB2E4(\uAC1C\uBC1C\uC790\uAC00 \uC9C1\uC811 \uD638\uCD9C) \uC6D0\uBCF8 \uB85C\uC9C1\uC744\n * \uADF8\uB300\uB85C \uC2E4\uD589\uD558\uACE0 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uD568\uC218\uBA74 \uADF8 \uD568\uC218\uB97C \uB9E4 \uD504\uB808\uC784 \uD638\uCD9C\uB418\uB294 \uB8E8\uD504\uB85C \uB4F1\uB85D\uD55C\uB2E4.\n * \uC6D0\uBCF8 \uB9AC\uD134\uAC12\uC740 \uADF8\uB300\uB85C \uD1B5\uACFC\uC2DC\uD0A4\uBBC0\uB85C \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uAC19\uC740 \uBA54\uC11C\uB4DC\uC5D0 \uC2A4\uD0DD\uD574\uB3C4 \uC21C\uC11C\uC5D0 \uC0C1\uAD00\uC5C6\uC774 \uC548\uC804\uD558\uB2E4.\n *\n * \uC635\uC158 \uC5C6\uC774 `@requestAnimationFrame` \uADF8\uB300\uB85C \uBD99\uC5EC\uB3C4 \uB418\uACE0, `@requestAnimationFrame({...})`\uCC98\uB7FC \uC635\uC158\uC744 \uC904 \uC218\uB3C4 \uC788\uB2E4.\n */\nexport function requestAnimationFrame(options: RequestAnimationFrameOptions): MethodDecorator;\nexport function requestAnimationFrame(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function requestAnimationFrame(optionsOrTarget?: RequestAnimationFrameOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey !== undefined) {\n // \uC635\uC158 \uC5C6\uC774: @requestAnimationFrame\n applyRequestAnimationFrame({}, optionsOrTarget as Object, propertyKey, descriptor);\n return;\n }\n // \uC635\uC158\uACFC \uD568\uAED8: @requestAnimationFrame({...})\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n return applyRequestAnimationFrame((optionsOrTarget as RequestAnimationFrameOptions) ?? {}, target, propertyKey, descriptor);\n };\n}\n\nexport const findAllRequestAnimationFrameMetadata = (target: any): RequestAnimationFrameMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return (ReflectUtils.findAllMetadata<RequestAnimationFrameMetadata[]>(REQUEST_ANIMATION_FRAME_METADATA_KEY, constructor) || []).flat();\n};\n\nexport class RequestAnimationFrameLifeCycler implements ElementDefineLifeCycler {\n onConnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n inst.__swc_requestAnimationFrameIds = []; // \uC7AC\uC5F0\uACB0 \uB300\uBE44 \uB9AC\uC14B\n const entries = getActiveEntries(inst);\n for (const meta of findAllRequestAnimationFrameMetadata(inst)) {\n if (meta.options.type !== 'onConnected') continue; // returnValue \uD0C0\uC785\uC740 \uC218\uB3D9 \uD638\uCD9C\uC744 \uAE30\uB2E4\uB9BC\n const frameFn: FrameCallback = (timestamp, prevValue) => inst[meta.propertyKey](timestamp, prevValue);\n const id = startFrameLoop(helperHostSet.$w, entries, frameFn);\n meta.options.created?.(helperHostSet, id);\n }\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const id of inst.__swc_requestAnimationFrameIds ?? []) {\n try {\n helperHostSet.$w.cancelAnimationFrame(id);\n } catch (e) {\n console.error('[SWC] cancelAnimationFrame error:', e);\n }\n }\n inst.__swc_requestAnimationFrameIds = [];\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAGlB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;AAmC7G,MAAM,mBAAmB,CAAC,SAAyB,KAAK,mCAAL,KAAK,iCAAmC,CAAC;AAE5F,MAAM,iBAAiB,CAAC,KAAa,SAAmB,YAAmC;AACzF,MAAI,YAAY;AAChB,QAAM,OAAO,CAAC,WAAmB,cAAoB;AACnD,UAAM,MAAM,QAAQ,QAAQ,SAAS;AACrC,QAAI,OAAO,EAAG,SAAQ,OAAO,KAAK,CAAC;AACnC,QAAI;AACJ,QAAI;AACF,eAAS,QAAQ,WAAW,SAAS;AAAA,IACvC,SAAS,GAAG;AACV,cAAQ,MAAM,+CAA+C,CAAC;AAC9D;AAAA,IACF;AACA,QAAI,WAAW,UAAa,WAAW,KAAM;AAC7C,gBAAY,IAAI,sBAAsB,QAAM,KAAK,IAAI,MAAM,CAAC;AAC5D,YAAQ,KAAK,SAAS;AAAA,EACxB;AACA,cAAY,IAAI,sBAAsB,QAAM,KAAK,IAAI,MAA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AAM,cAAc,OAAO,WAAW,aAAa,SAAS,OAAO;AACnE,UAAQ,aAAa,gBAAiD,sCAAsC,WAAW,KAAK,CAAC,GAAG,KAAK;AACvI;AAEO,MAAM,gCAAmE;AAAA,EAC9E,YAAY,eAAoC;AAC9C,UAAM,OAAO,cAAc;AAC3B,SAAK,iCAAiC,CAAC;AACvC,UAAM,UAAU,iBAAiB,IAAI;AACrC,eAAW,QAAQ,qCAAqC,IAAI,GAAG;AAC7D,UAAI,KAAK,QAAQ,SAAS,cAAe;AACzC,YAAM,UAAyB,CAAC,WAAW,cAAc,KAAK,KAAK,WAAW,EAAE,WAAW,SAAS;AACpG,YAAM,KAAK,eAAe,cAAc,IAAI,SAAS,OAAO;AAC5D,WAAK,QAAQ,UAAU,eAAe,EAAE;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,eAAe,eAAoC;AACjD,UAAM,OAAO,cAAc;AAC3B,eAAW,MAAM,KAAK,kCAAkC,CAAC,GAAG;AAC1D,UAAI;AACF,sBAAc,GAAG,qBAAqB,EAAE;AAAA,MAC1C,SAAS,GAAG;AACV,gBAAQ,MAAM,qCAAqC,CAAC;AAAA,MACtD;AAAA,IACF;AACA,SAAK,iCAAiC,CAAC;AAAA,EACzC;AACF;",
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\n\nexport const REQUEST_ANIMATION_FRAME_METADATA_KEY = Symbol.for('simple-web-component:request-animation-frame');\n\nexport type RequestAnimationFrameType = 'onConnected' | 'returnValue';\n\nexport interface RequestAnimationFrameOptions {\n /**\n * 'onConnected'(\uAE30\uBCF8\uAC12) - connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uB8E8\uD504 \uC2DC\uC791 (\uB9E4 \uD504\uB808\uC784 \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C), disconnect \uC2DC \uC790\uB3D9 \uC815\uB9AC.\n * 'returnValue' - \uC790\uB3D9 \uC2DC\uC791 \uC5C6\uC74C. \uAC1C\uBC1C\uC790\uAC00 \uC774 \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC2DC\uC791\uB418\uACE0,\n * \uADF8 \uD638\uCD9C\uC758 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uC2E4\uC81C\uB85C \uB9E4 \uD504\uB808\uC784 \uD638\uCD9C\uB420 \uD568\uC218\uAC00 \uB41C\uB2E4.\n */\n type?: RequestAnimationFrameType;\n /** \uB8E8\uD504 \uC2DC\uC791 \uC9C1\uD6C4 1\uD68C \uD638\uCD9C (\uB514\uBC84\uAE45/\uB85C\uAE45\uC6A9). id\uB294 \uCCAB requestAnimationFrame \uBC18\uD658\uAC12 - cleanup\uC740 \uC790\uB3D9\uC73C\uB85C \uCC98\uB9AC\uB418\uBBC0\uB85C \uC9C1\uC811 \uCDE8\uC18C\uD560 \uD544\uC694 \uC5C6\uC74C. */\n created?: (set: HelperHostSet, id: number) => void;\n /**\n * type:'returnValue' \uC804\uC6A9 - \uB9AC\uD134\uAC12\uC774 \uD568\uC218\uBA74 \uADF8 \uC790\uCCB4\uB97C, \uAC1D\uCCB4\uBA74 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC77C \uB54C \uADF8 \uAC12\uC744\n * \"\uB9E4 \uD504\uB808\uC784 \uD638\uCD9C\uB420 \uD568\uC218\"\uB85C \uC0AC\uC6A9\uD55C\uB2E4. \uC548 \uC8FC\uBA74 REQUEST_ANIMATION_FRAME_METADATA_KEY\uB85C \uD3F4\uBC31\uD55C\uB2E4 -\n * applyAttribute.ts/applyNode.ts\uC758 valueKey\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158.\n */\n valueKey?: symbol | string;\n}\n\nexport interface RequestAnimationFrameMetadata {\n propertyKey: string | symbol;\n options: RequestAnimationFrameOptions;\n}\n\n/**\n * \uD504\uB808\uC784 \uCF5C\uBC31 \uC2DC\uADF8\uB2C8\uCC98.\n * - timestamp: \uC774\uBC88 \uD504\uB808\uC784\uC758 \uC2DC\uAC01 (requestAnimationFrame\uC774 \uB118\uACA8\uC8FC\uB294 \uAC12)\n * - prevValue: \uC9C1\uC804 \uD638\uCD9C\uC774 \uB9AC\uD134\uD55C \uAC12 (\uCCAB \uD638\uCD9C\uC5D0\uC11C\uB294 undefined)\n * \uB9AC\uD134\uAC12\uC774 undefined/null\uC774\uBA74 \uB2E4\uC74C \uD504\uB808\uC784\uC744 \uC608\uC57D\uD558\uC9C0 \uC54A\uACE0 \uB8E8\uD504\uAC00 \uBA48\uCD98\uB2E4 (\uAC1C\uBC1C\uC790\uAC00 \uC885\uB8CC\uB97C \uC81C\uC5B4).\n * undefined/null\uC774 \uC544\uB2CC \uAC12\uC744 \uB9AC\uD134\uD558\uBA74 \uADF8 \uAC12 \uADF8\uB300\uB85C \uB2E4\uC74C \uD638\uCD9C\uC758 prevValue\uB85C \uC804\uB2EC\uB41C\uB2E4.\n */\nexport type FrameCallback = (timestamp: number, prevValue?: any) => any;\n\nconst getActiveEntries = (inst: any): number[] => (inst.__swc_requestAnimationFrameIds ??= []);\n\nconst startFrameLoop = (win: Window, entries: number[], frameFn: FrameCallback): number => {\n let currentId = 0;\n const step = (timestamp: number, prevValue?: any) => {\n const idx = entries.indexOf(currentId);\n if (idx >= 0) entries.splice(idx, 1);\n let result: any;\n try {\n result = frameFn(timestamp, prevValue);\n } catch (e) {\n console.error('[SWC] requestAnimationFrame callback error:', e);\n return;\n }\n if (result === undefined || result === null) return; // \uAC1C\uBC1C\uC790\uAC00 \uC885\uB8CC\uB97C \uC2E0\uD638\uD568 - \uB2E4\uC74C \uD504\uB808\uC784 \uC608\uC57D \uC548 \uD568\n currentId = win.requestAnimationFrame(ts => step(ts, result));\n entries.push(currentId);\n };\n currentId = win.requestAnimationFrame(ts => step(ts, undefined));\n entries.push(currentId);\n return currentId;\n};\n\nconst applyRequestAnimationFrame = (options: RequestAnimationFrameOptions, target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void => {\n const constructor = target.constructor;\n const normalizedOptions: RequestAnimationFrameOptions = { ...options, type: options.type ?? 'onConnected' };\n\n let metaList = ReflectUtils.getOwnMetadata(REQUEST_ANIMATION_FRAME_METADATA_KEY, constructor) as RequestAnimationFrameMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(REQUEST_ANIMATION_FRAME_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, options: normalizedOptions });\n\n if (normalizedOptions.type === 'onConnected' || !descriptor) {\n return; // LifeCycler\uAC00 connect/disconnect\uB97C \uC804\uB2F4 - wrapping \uBD88\uD544\uC694\n }\n\n const original = descriptor.value;\n descriptor.value = function (this: any, ...args: any[]) {\n const res = original.apply(this, args);\n // valueKey\uB97C \uC548 \uC8FC\uBA74 \uC774 \uB370\uCF54\uB808\uC774\uD130 \uC804\uC6A9 METADATA_KEY\uB85C \uD3F4\uBC31 (applyAttribute.ts/applyNode.ts\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158)\n const vk = normalizedOptions.valueKey ?? REQUEST_ANIMATION_FRAME_METADATA_KEY;\n const frameFn: FrameCallback | undefined =\n typeof res === 'function' ? res : res && typeof res === 'object' && typeof res[vk] === 'function' ? res[vk] : undefined;\n\n if (frameFn) {\n ensureInit(this);\n const win = SwcUtils.resolveWindow(this);\n const id = startFrameLoop(win, getActiveEntries(this), frameFn);\n normalizedOptions.created?.(SwcUtils.getHelperAndHostSet(this), id);\n }\n return res;\n };\n return descriptor;\n};\n\n/**\n * type:'onConnected'(\uAE30\uBCF8\uAC12) - connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uB9E4 \uD504\uB808\uC784 \uB8E8\uD504\uB97C \uC2DC\uC791\uD558\uACE0, disconnect \uC2DC \uC790\uB3D9\uC73C\uB85C cancelAnimationFrame \uD55C\uB2E4.\n * type:'returnValue' (@requestAnimationFrameReturnValue) - \uBA54\uC11C\uB4DC\uB97C \uAC10\uC2F8\uC9C0 \uC54A\uB294 \uB300\uC2E0, \uD638\uCD9C\uB420 \uB54C\uB9C8\uB2E4(\uAC1C\uBC1C\uC790\uAC00 \uC9C1\uC811 \uD638\uCD9C) \uC6D0\uBCF8 \uB85C\uC9C1\uC744\n * \uADF8\uB300\uB85C \uC2E4\uD589\uD558\uACE0 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uD568\uC218\uBA74 \uADF8 \uD568\uC218\uB97C \uB9E4 \uD504\uB808\uC784 \uD638\uCD9C\uB418\uB294 \uB8E8\uD504\uB85C \uB4F1\uB85D\uD55C\uB2E4.\n * \uC6D0\uBCF8 \uB9AC\uD134\uAC12\uC740 \uADF8\uB300\uB85C \uD1B5\uACFC\uC2DC\uD0A4\uBBC0\uB85C \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uAC19\uC740 \uBA54\uC11C\uB4DC\uC5D0 \uC2A4\uD0DD\uD574\uB3C4 \uC21C\uC11C\uC5D0 \uC0C1\uAD00\uC5C6\uC774 \uC548\uC804\uD558\uB2E4.\n *\n * \uC635\uC158 \uC5C6\uC774 `@requestAnimationFrame` \uADF8\uB300\uB85C \uBD99\uC5EC\uB3C4 \uB418\uACE0, `@requestAnimationFrame({...})`\uCC98\uB7FC \uC635\uC158\uC744 \uC904 \uC218\uB3C4 \uC788\uB2E4.\n */\nexport function requestAnimationFrame(options: RequestAnimationFrameOptions): MethodDecorator;\nexport function requestAnimationFrame(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function requestAnimationFrame(optionsOrTarget?: RequestAnimationFrameOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey !== undefined) {\n // \uC635\uC158 \uC5C6\uC774: @requestAnimationFrame\n applyRequestAnimationFrame({}, optionsOrTarget as Object, propertyKey, descriptor);\n return;\n }\n // \uC635\uC158\uACFC \uD568\uAED8: @requestAnimationFrame({...})\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n return applyRequestAnimationFrame((optionsOrTarget as RequestAnimationFrameOptions) ?? {}, target, propertyKey, descriptor);\n };\n}\n\nexport const findAllRequestAnimationFrameMetadata = (target: any): RequestAnimationFrameMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return (ReflectUtils.findAllMetadata<RequestAnimationFrameMetadata[]>(REQUEST_ANIMATION_FRAME_METADATA_KEY, constructor) || []).flat();\n};\n\nexport class RequestAnimationFrameLifeCycler implements ElementDefineLifeCycler {\n onConnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n inst.__swc_requestAnimationFrameIds = []; // \uC7AC\uC5F0\uACB0 \uB300\uBE44 \uB9AC\uC14B\n const entries = getActiveEntries(inst);\n for (const meta of findAllRequestAnimationFrameMetadata(inst)) {\n if (meta.options.type !== 'onConnected') continue; // returnValue \uD0C0\uC785\uC740 \uC218\uB3D9 \uD638\uCD9C\uC744 \uAE30\uB2E4\uB9BC\n const frameFn: FrameCallback = (timestamp, prevValue) => inst[meta.propertyKey](timestamp, prevValue);\n const id = startFrameLoop(helperHostSet.$w, entries, frameFn);\n meta.options.created?.(helperHostSet, id);\n }\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const id of inst.__swc_requestAnimationFrameIds ?? []) {\n try {\n helperHostSet.$w.cancelAnimationFrame(id);\n } catch (e) {\n console.error('[SWC] cancelAnimationFrame error:', e);\n }\n }\n inst.__swc_requestAnimationFrameIds = [];\n }\n}\n\n/** \uC218\uB3D9 \uC2DC\uC791: \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC2DC\uC791\uB418\uACE0, \uADF8 \uB9AC\uD134 \uD568\uC218\uAC00 \uB9E4 \uD504\uB808\uC784 \uB3C8\uB2E4. = @requestAnimationFrame({ type: 'returnValue' }) */\nexport function requestAnimationFrameReturnValue(options: Omit<RequestAnimationFrameOptions, 'type'>): MethodDecorator;\nexport function requestAnimationFrameReturnValue(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function requestAnimationFrameReturnValue(optionsOrTarget?: Omit<RequestAnimationFrameOptions, 'type'> | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey !== undefined) {\n applyRequestAnimationFrame({ type: 'returnValue' }, optionsOrTarget as Object, propertyKey, descriptor);\n return;\n }\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) =>\n applyRequestAnimationFrame({ ...((optionsOrTarget as RequestAnimationFrameOptions) ?? {}), type: 'returnValue' }, target, propertyKey, descriptor);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAGlB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;AAmC7G,MAAM,mBAAmB,CAAC,SAAyB,KAAK,mCAAL,KAAK,iCAAmC,CAAC;AAE5F,MAAM,iBAAiB,CAAC,KAAa,SAAmB,YAAmC;AACzF,MAAI,YAAY;AAChB,QAAM,OAAO,CAAC,WAAmB,cAAoB;AACnD,UAAM,MAAM,QAAQ,QAAQ,SAAS;AACrC,QAAI,OAAO,EAAG,SAAQ,OAAO,KAAK,CAAC;AACnC,QAAI;AACJ,QAAI;AACF,eAAS,QAAQ,WAAW,SAAS;AAAA,IACvC,SAAS,GAAG;AACV,cAAQ,MAAM,+CAA+C,CAAC;AAC9D;AAAA,IACF;AACA,QAAI,WAAW,UAAa,WAAW,KAAM;AAC7C,gBAAY,IAAI,sBAAsB,QAAM,KAAK,IAAI,MAAM,CAAC;AAC5D,YAAQ,KAAK,SAAS;AAA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|
7
7
|
function setInterval(interval, options = {}) {
|
|
8
8
|
return (target, propertyKey, descriptor) => {
|
|
9
9
|
const constructor = target.constructor;
|
|
10
|
-
const normalizedOptions = { ...options, type: options.type ?? "
|
|
10
|
+
const normalizedOptions = { ...options, type: options.type ?? "onConnected" };
|
|
11
11
|
let metaList = ReflectUtils.getOwnMetadata(SET_INTERVAL_METADATA_KEY, constructor);
|
|
12
12
|
if (!metaList) {
|
|
13
13
|
metaList = [];
|
|
@@ -97,10 +97,12 @@ class SetIntervalLifeCycler {
|
|
|
97
97
|
inst.__swc_intervalIds = [];
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
+
const setIntervalReturnValue = (interval, options = {}) => setInterval(interval, { ...options, type: "returnValue" });
|
|
100
101
|
export {
|
|
101
102
|
SET_INTERVAL_METADATA_KEY,
|
|
102
103
|
SetIntervalLifeCycler,
|
|
103
104
|
findAllSetIntervalMetadata,
|
|
104
|
-
setInterval
|
|
105
|
+
setInterval,
|
|
106
|
+
setIntervalReturnValue
|
|
105
107
|
};
|
|
106
108
|
//# sourceMappingURL=setInterval.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/setInterval.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { buildSwcParameterArgs } from './parameter';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\n\nexport const SET_INTERVAL_METADATA_KEY = Symbol.for('simple-web-component:set-interval');\n\nexport type SetIntervalType = 'onConnected' | 'returnValue';\n\nexport interface SetIntervalOptions {\n /**\n * 'onConnected' (connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uC2DC\uC791, disconnect \uC2DC \uC790\uB3D9 \uC815\uB9AC) |\n * 'returnValue' (\
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SA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AAA,UACV,UAAE;AACA,gBAAI,KAAK,QAAQ,QAAS,OAAM,KAAK,QAAQ,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM,CAAC;AAAA,UACtF;AACA,cAAI,MAAO,SAAQ,MAAM,iCAAiC,KAAK;AAAA,QACjE,GAAG,EAAE,MAAM,OAAK,QAAQ,MAAM,iCAAiC,CAAC,CAAC;AAAA,MACnE,GAAG,KAAK,QAAQ;AAChB,WAAK,QAAQ,UAAU,eAAe,EAAE;AACxC,uBAAiB,IAAI,EAAE,KAAK,EAAE;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,eAAe,eAAoC;AACjD,UAAM,OAAO,cAAc;AAC3B,eAAW,MAAM,KAAK,qBAAqB,CAAC,GAAG;AAC7C,UAAI;AACF,sBAAc,GAAG,cAAc,EAAE;AAAA,MACnC,SAAS,GAAG;AACV,gBAAQ,MAAM,8BAA8B,CAAC;AAAA,MAC/C;AAAA,IACF;AACA,SAAK,oBAAoB,CAAC;AAAA,EAC5B;AACF;",
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { buildSwcParameterArgs } from './parameter';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\n\nexport const SET_INTERVAL_METADATA_KEY = Symbol.for('simple-web-component:set-interval');\n\nexport type SetIntervalType = 'onConnected' | 'returnValue';\n\nexport interface SetIntervalOptions {\n /**\n * 'onConnected' (\uAE30\uBCF8\uAC12 - connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uC2DC\uC791, disconnect \uC2DC \uC790\uB3D9 \uC815\uB9AC) |\n * 'returnValue' (\uC790\uB3D9 \uC2DC\uC791 \uC5C6\uC74C. \uAC1C\uBC1C\uC790\uAC00 \uC774 \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC2DC\uC791\uB418\uACE0,\n * \uADF8 \uD638\uCD9C\uC758 \uB9AC\uD134\uAC12\uC774 \uC2E4\uC81C\uB85C \uBC18\uBCF5 \uC2E4\uD589\uB420 \uD568\uC218\uAC00 \uB41C\uB2E4 - \uC544\uB798 \uC124\uBA85 \uCC38\uACE0).\n */\n type?: SetIntervalType;\n /** \uB9E4 tick\uB9C8\uB2E4 \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uC5D0 \uB118\uAE38 \uC778\uC790\uB97C \uACC4\uC0B0. type:'onConnected'\uC5D0\uC11C\uB9CC \uC758\uBBF8\uAC00 \uC788\uC74C (\uC5C6\uC73C\uBA74 \uC778\uC790 \uC5C6\uC774 \uD638\uCD9C). */\n parameter?: (set: HelperHostSet) => any[];\n /** \uD0C0\uC774\uBA38 \uB4F1\uB85D \uC9C1\uD6C4 1\uD68C \uD638\uCD9C (\uB514\uBC84\uAE45/\uB85C\uAE45\uC6A9). id\uB294 \uC2E4\uC81C setInterval \uBC18\uD658\uAC12 - cleanup\uC740 \uC790\uB3D9\uC73C\uB85C \uCC98\uB9AC\uB418\uBBC0\uB85C \uC9C1\uC811 clear\uD560 \uD544\uC694 \uC5C6\uC74C. */\n created?: (set: HelperHostSet, id: number) => void;\n /** [type:'onConnected' \uC804\uC6A9] \uB9E4 tick \uC2E4\uD589 \uC5EC\uBD80 \uAC8C\uC774\uD2B8. Promise<boolean>\uB3C4 \uAC00\uB2A5. false\uBA74 \uC774 tick \uC2A4\uD0B5. */\n filter?: (set: HelperHostSet) => boolean | Promise<boolean>;\n /** [type:'onConnected' \uC804\uC6A9] tick \uD578\uB4E4\uB7EC \uC9C1\uC804 \uD6C5. await\uB418\uACE0, \uB9AC\uD134\uAC12\uC740 @setIntervalBeforeReturn \uC73C\uB85C \uC8FC\uC785\uB41C\uB2E4. */\n before?: (set: HelperHostSet) => any | Promise<any>;\n /** [type:'onConnected' \uC804\uC6A9] tick \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. */\n finally?: (set: HelperHostSet, ctx: { args: any[]; result?: any; error?: any }) => any | Promise<any>;\n /**\n * type:'onConnected' - \uB9E4 tick\uB9C8\uB2E4 \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uC758 \uB9AC\uD134\uAC12\uC774 \uAC1D\uCCB4\uC774\uACE0 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC774\uBA74 (id: number)\uB85C \uD638\uCD9C\uD55C\uB2E4.\n * type:'returnValue' - \uB9AC\uD134\uAC12\uC774 \uD568\uC218\uBA74 \uADF8 \uC790\uCCB4\uB97C, \uAC1D\uCCB4\uBA74 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC77C \uB54C \uADF8 \uAC12\uC744 \"\uC2E4\uC81C\uB85C \uBC18\uBCF5 \uC2E4\uD589\uB420 \uD568\uC218\"\uB85C \uC0AC\uC6A9\uD55C\uB2E4.\n * \uC548 \uC8FC\uBA74 SET_INTERVAL_METADATA_KEY\uB85C \uD3F4\uBC31\uD55C\uB2E4 - applyAttribute.ts/applyNode.ts\uC758 valueKey\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158\n * (\uB9AC\uD134 \uAC1D\uCCB4\uC5D0\uC11C \uC774 \uB370\uCF54\uB808\uC774\uD130 \uBAAB\uB9CC \uBF51\uC544 \uC4F0\uACE0, \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uC2A4\uD0DD\uD560 \uB54C\uB9CC \uCEE4\uC2A4\uD140 \uD0A4\uB85C \uAD6C\uBD84\uD558\uBA74 \uB41C\uB2E4).\n */\n valueKey?: symbol | string;\n}\n\nexport interface SetIntervalMetadata {\n propertyKey: string | symbol;\n interval: number;\n options: SetIntervalOptions;\n}\n\nconst getActiveEntries = (inst: any): number[] => (inst.__swc_intervalIds ??= []);\n\n/**\n * type:'onConnected'(\uAE30\uBCF8\uAC12) - connect \uC2DC \uC790\uB3D9\uC73C\uB85C setInterval\uC744 \uAC78\uACE0, disconnect \uC2DC \uC790\uB3D9\uC73C\uB85C clearInterval \uD55C\uB2E4.\n * type:'returnValue' (@setIntervalReturnValue) - \uBA54\uC11C\uB4DC\uB97C \uAC10\uC2F8\uC9C0 \uC54A\uB294 \uB300\uC2E0, \uD638\uCD9C\uB420 \uB54C\uB9C8\uB2E4(\uAC1C\uBC1C\uC790\uAC00 \uC9C1\uC811 \uD638\uCD9C) \uC6D0\uBCF8 \uB85C\uC9C1\uC744\n * \uADF8\uB300\uB85C \uC2E4\uD589\uD558\uACE0 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uD568\uC218\uBA74 \uADF8 \uD568\uC218\uB97C \uC0C8 setInterval\uC758 \uBC18\uBCF5 \uCF5C\uBC31\uC73C\uB85C \uB4F1\uB85D\uD55C\uB2E4.\n * \uD638\uCD9C\uD560 \uB54C\uB9C8\uB2E4 \uBCC4\uB3C4\uC758 \uC0C8 \uD0C0\uC774\uBA38\uAC00 \uC0DD\uAE30\uBA70, disconnect \uC2DC \uC804\uBD80 \uC815\uB9AC\uB41C\uB2E4. \uC6D0\uBCF8 \uB9AC\uD134\uAC12\uC740 \uADF8\uB300\uB85C \uD1B5\uACFC\uC2DC\uD0A4\uBBC0\uB85C\n * \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uAC19\uC740 \uBA54\uC11C\uB4DC\uC5D0 \uC2A4\uD0DD\uD574\uB3C4 \uC21C\uC11C\uC5D0 \uC0C1\uAD00\uC5C6\uC774 \uC548\uC804\uD558\uB2E4.\n */\nexport function setInterval(interval: number, options: SetIntervalOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n const normalizedOptions: SetIntervalOptions = { ...options, type: options.type ?? 'onConnected' };\n\n let metaList = ReflectUtils.getOwnMetadata(SET_INTERVAL_METADATA_KEY, constructor) as SetIntervalMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(SET_INTERVAL_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, interval, options: normalizedOptions });\n\n if (normalizedOptions.type === 'onConnected' || !descriptor) {\n return; // LifeCycler\uAC00 connect/disconnect\uB97C \uC804\uB2F4 - wrapping \uBD88\uD544\uC694\n }\n\n const original = descriptor.value;\n descriptor.value = function (this: any, ...args: any[]) {\n const res = original.apply(this, args);\n // valueKey\uB97C \uC548 \uC8FC\uBA74 \uC774 \uB370\uCF54\uB808\uC774\uD130 \uC804\uC6A9 METADATA_KEY\uB85C \uD3F4\uBC31 (applyAttribute.ts/applyNode.ts\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158)\n const vk = normalizedOptions.valueKey ?? SET_INTERVAL_METADATA_KEY;\n const tickFn: ((id: number) => void) | undefined =\n typeof res === 'function' ? res : res && typeof res === 'object' && typeof res[vk] === 'function' ? res[vk] : undefined;\n\n if (tickFn) {\n ensureInit(this);\n const win = SwcUtils.resolveWindow(this);\n const id = win.setInterval(() => {\n try {\n tickFn(id);\n } catch (e) {\n console.error('[SWC] setInterval tick error:', e);\n }\n }, interval);\n normalizedOptions.created?.(SwcUtils.getHelperAndHostSet(this), id);\n getActiveEntries(this).push(id);\n }\n return res;\n };\n return descriptor;\n };\n}\n\nexport const findAllSetIntervalMetadata = (target: any): SetIntervalMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return (ReflectUtils.findAllMetadata<SetIntervalMetadata[]>(SET_INTERVAL_METADATA_KEY, constructor) || []).flat();\n};\n\nexport class SetIntervalLifeCycler implements ElementDefineLifeCycler {\n onConnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n inst.__swc_intervalIds = []; // \uC7AC\uC5F0\uACB0 \uB300\uBE44 \uB9AC\uC14B\n for (const meta of findAllSetIntervalMetadata(inst)) {\n if (meta.options.type !== 'onConnected') continue; // returnValue \uD0C0\uC785\uC740 \uC218\uB3D9 \uD638\uCD9C\uC744 \uAE30\uB2E4\uB9BC\n const id = helperHostSet.$w.setInterval(() => {\n void (async () => {\n const helper = SwcUtils.getHelperAndHostSet(inst);\n if (meta.options.filter && !(await meta.options.filter(helper))) return;\n const paramArgs = meta.options.parameter?.(helperHostSet) ?? [];\n const hostSet = SwcUtils.getHostSet(inst);\n const helperSet = SwcUtils.getHelperSet(helperHostSet.$w);\n const buildArgs = (beforeReturn: any) => buildSwcParameterArgs(inst, meta.propertyKey, {\n hostSet, helperHostSet: helper, helperSet, setIntervalBeforeReturn: beforeReturn\n }, [...paramArgs, beforeReturn]);\n let args = buildArgs(undefined);\n if (meta.options.before) { const br = await meta.options.before(helper); args = buildArgs(br); }\n let result: any, error: any;\n try {\n result = await inst[meta.propertyKey](...args);\n const vk = meta.options.valueKey ?? SET_INTERVAL_METADATA_KEY;\n if (result && typeof result === 'object' && typeof result[vk] === 'function') result[vk](id);\n } catch (e) {\n error = e;\n } finally {\n if (meta.options.finally) await meta.options.finally(helper, { args, result, error });\n }\n if (error) console.error('[SWC] setInterval tick error:', error);\n })().catch(e => console.error('[SWC] setInterval tick error:', e));\n }, meta.interval);\n meta.options.created?.(helperHostSet, id);\n getActiveEntries(inst).push(id);\n }\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const id of inst.__swc_intervalIds ?? []) {\n try {\n helperHostSet.$w.clearInterval(id);\n } catch (e) {\n console.error('[SWC] clearInterval error:', e);\n }\n }\n inst.__swc_intervalIds = [];\n }\n}\n\n/** \uC218\uB3D9 \uC2DC\uC791: \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC2DC\uC791\uB41C\uB2E4. = @setInterval(interval, { type: 'returnValue' }) */\nexport const setIntervalReturnValue =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Y;AACpC,gBAAI,UAAU,OAAO,WAAW,YAAY,OAAO,OAAO,EAAE,MAAM,WAAY,QAAO,EAAE,EAAE,EAAE;AAAA,UAC7F,SAAS,GAAG;AACV,oBAAQ;AAAA,UACV,UAAE;AACA,gBAAI,KAAK,QAAQ,QAAS,OAAM,KAAK,QAAQ,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM,CAAC;AAAA,UACtF;AACA,cAAI,MAAO,SAAQ,MAAM,iCAAiC,KAAK;AAAA,QACjE,GAAG,EAAE,MAAM,OAAK,QAAQ,MAAM,iCAAiC,CAAC,CAAC;AAAA,MACnE,GAAG,KAAK,QAAQ;AAChB,WAAK,QAAQ,UAAU,eAAe,EAAE;AACxC,uBAAiB,IAAI,EAAE,KAAK,EAAE;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,eAAe,eAAoC;AACjD,UAAM,OAAO,cAAc;AAC3B,eAAW,MAAM,KAAK,qBAAqB,CAAC,GAAG;AAC7C,UAAI;AACF,sBAAc,GAAG,cAAc,EAAE;AAAA,MACnC,SAAS,GAAG;AACV,gBAAQ,MAAM,8BAA8B,CAAC;AAAA,MAC/C;AAAA,IACF;AACA,SAAK,oBAAoB,CAAC;AAAA,EAC5B;AACF;AAGO,MAAM,yBAAyB,CAAC,UAAkB,UAA4C,CAAC,MACpG,YAAY,UAAU,EAAE,GAAG,SAAS,MAAM,cAAc,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ const getActiveEntries = (inst) => inst.__swc_timeoutIds ?? (inst.__swc_timeoutI
|
|
|
7
7
|
function setTimeout(delay, options = {}) {
|
|
8
8
|
return (target, propertyKey, descriptor) => {
|
|
9
9
|
const constructor = target.constructor;
|
|
10
|
-
const normalizedOptions = { ...options, type: options.type ?? "
|
|
10
|
+
const normalizedOptions = { ...options, type: options.type ?? "onConnected" };
|
|
11
11
|
let metaList = ReflectUtils.getOwnMetadata(SET_TIMEOUT_METADATA_KEY, constructor);
|
|
12
12
|
if (!metaList) {
|
|
13
13
|
metaList = [];
|
|
@@ -100,10 +100,12 @@ class SetTimeoutLifeCycler {
|
|
|
100
100
|
inst.__swc_timeoutIds = [];
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
const setTimeoutReturnValue = (delay, options = {}) => setTimeout(delay, { ...options, type: "returnValue" });
|
|
103
104
|
export {
|
|
104
105
|
SET_TIMEOUT_METADATA_KEY,
|
|
105
106
|
SetTimeoutLifeCycler,
|
|
106
107
|
findAllSetTimeoutMetadata,
|
|
107
|
-
setTimeout
|
|
108
|
+
setTimeout,
|
|
109
|
+
setTimeoutReturnValue
|
|
108
110
|
};
|
|
109
111
|
//# sourceMappingURL=setTimeout.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/setTimeout.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { buildSwcParameterArgs } from './parameter';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\n\nexport const SET_TIMEOUT_METADATA_KEY = Symbol.for('simple-web-component:set-timeout');\n\nexport type SetTimeoutType = 'onConnected' | 'returnValue';\n\nexport interface SetTimeoutOptions {\n /**\n * 'onConnected' (connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uC608\uC57D, disconnect \uC2DC \uC790\uB3D9 \uC815\uB9AC) |\n * 'returnValue' (\uAE30\uBCF8\uAC12 - \uC790\uB3D9 \uC608\uC57D \uC5C6\uC74C. \uAC1C\uBC1C\uC790\uAC00 \uC774 \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC608\uC57D\uB418\uACE0,\n * \uADF8 \uD638\uCD9C\uC758 \uB9AC\uD134\uAC12\uC774 \uC2E4\uC81C\uB85C \uC2E4\uD589\uB420 \uD568\uC218\uAC00 \uB41C\uB2E4 - \uC544\uB798 \uC124\uBA85 \uCC38\uACE0).\n */\n type?: SetTimeoutType;\n /** \uC2E4\uD589 \uC2DC \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uC5D0 \uB118\uAE38 \uC778\uC790\uB97C \uACC4\uC0B0. type:'onConnected'\uC5D0\uC11C\uB9CC \uC758\uBBF8\uAC00 \uC788\uC74C (\uC5C6\uC73C\uBA74 \uC778\uC790 \uC5C6\uC774 \uD638\uCD9C). */\n parameter?: (set: HelperHostSet) => any[];\n /** \uD0C0\uC774\uBA38 \uB4F1\uB85D \uC9C1\uD6C4 1\uD68C \uD638\uCD9C (\uB514\uBC84\uAE45/\uB85C\uAE45\uC6A9). id\uB294 \uC2E4\uC81C setTimeout \uBC18\uD658\uAC12 - cleanup\uC740 \uC790\uB3D9\uC73C\uB85C \uCC98\uB9AC\uB418\uBBC0\uB85C \uC9C1\uC811 clear\uD560 \uD544\uC694 \uC5C6\uC74C. */\n created?: (set: HelperHostSet, id: number) => void;\n /** [type:'onConnected' \uC804\uC6A9] \uBC1C\uD654 \uC5EC\uBD80 \uAC8C\uC774\uD2B8. Promise<boolean>\uB3C4 \uAC00\uB2A5. false\uBA74 \uC2A4\uD0B5. */\n filter?: (set: HelperHostSet) => boolean | Promise<boolean>;\n /** [type:'onConnected' \uC804\uC6A9] \uD578\uB4E4\uB7EC \uC9C1\uC804 \uD6C5. await\uB418\uACE0, \uB9AC\uD134\uAC12\uC740 @setTimeoutBeforeReturn \uC73C\uB85C \uC8FC\uC785\uB41C\uB2E4. */\n before?: (set: HelperHostSet) => any | Promise<any>;\n /** [type:'onConnected' \uC804\uC6A9] \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. */\n finally?: (set: HelperHostSet, ctx: { args: any[]; result?: any; error?: any }) => any | Promise<any>;\n /**\n * type:'onConnected' - fire \uC2DC \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uC758 \uB9AC\uD134\uAC12\uC774 \uAC1D\uCCB4\uC774\uACE0 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC774\uBA74 (id: number)\uB85C \uD638\uCD9C\uD55C\uB2E4.\n * type:'returnValue' - \uB9AC\uD134\uAC12\uC774 \uD568\uC218\uBA74 \uADF8 \uC790\uCCB4\uB97C, \uAC1D\uCCB4\uBA74 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC77C \uB54C \uADF8 \uAC12\uC744 \"\uC2E4\uC81C\uB85C \uC2E4\uD589\uB420 \uD568\uC218\"\uB85C \uC0AC\uC6A9\uD55C\uB2E4.\n * \uC548 \uC8FC\uBA74 SET_TIMEOUT_METADATA_KEY\uB85C \uD3F4\uBC31\uD55C\uB2E4 - applyAttribute.ts/applyNode.ts\uC758 valueKey\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158\n * (\uB9AC\uD134 \uAC1D\uCCB4\uC5D0\uC11C \uC774 \uB370\uCF54\uB808\uC774\uD130 \uBAAB\uB9CC \uBF51\uC544 \uC4F0\uACE0, \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uC2A4\uD0DD\uD560 \uB54C\uB9CC \uCEE4\uC2A4\uD140 \uD0A4\uB85C \uAD6C\uBD84\uD558\uBA74 \uB41C\uB2E4).\n */\n valueKey?: symbol | string;\n}\n\nexport interface SetTimeoutMetadata {\n propertyKey: string | symbol;\n delay: number;\n options: SetTimeoutOptions;\n}\n\nconst getActiveEntries = (inst: any): number[] => (inst.__swc_timeoutIds ??= []);\n\n/**\n * type:'onConnected' - connect \uC2DC \uC790\uB3D9\uC73C\uB85C setTimeout\uC744 \uAC78\uACE0, disconnect \uC2DC (\uC544\uC9C1 \uC2E4\uD589 \uC804\uC774\uB77C\uBA74) \uC790\uB3D9\uC73C\uB85C clearTimeout \uD55C\uB2E4.\n * type:'returnValue'(\uAE30\uBCF8\uAC12) - \uBA54\uC11C\uB4DC\uB97C \uAC10\uC2F8\uC9C0 \uC54A\uB294 \uB300\uC2E0, \uD638\uCD9C\uB420 \uB54C\uB9C8\uB2E4(\uAC1C\uBC1C\uC790\uAC00 \uC9C1\uC811 \uD638\uCD9C) \uC6D0\uBCF8 \uB85C\uC9C1\uC744\n * \uADF8\uB300\uB85C \uC2E4\uD589\uD558\uACE0 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uD568\uC218\uBA74 \uADF8 \uD568\uC218\uB97C \uC0C8 setTimeout\uC73C\uB85C \uC608\uC57D\uD55C\uB2E4.\n * \uD638\uCD9C\uD560 \uB54C\uB9C8\uB2E4 \uBCC4\uB3C4\uC758 \uC0C8 \uD0C0\uC774\uBA38\uAC00 \uC0DD\uAE30\uBA70, disconnect \uC2DC (\uC544\uC9C1 \uC2E4\uD589 \uC804\uC778 \uAC83\uB4E4\uC740) \uC804\uBD80 \uC815\uB9AC\uB41C\uB2E4.\n * \uC6D0\uBCF8 \uB9AC\uD134\uAC12\uC740 \uADF8\uB300\uB85C \uD1B5\uACFC\uC2DC\uD0A4\uBBC0\uB85C \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uAC19\uC740 \uBA54\uC11C\uB4DC\uC5D0 \uC2A4\uD0DD\uD574\uB3C4 \uC21C\uC11C\uC5D0 \uC0C1\uAD00\uC5C6\uC774 \uC548\uC804\uD558\uB2E4.\n */\nexport function setTimeout(delay: number, options: SetTimeoutOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n const normalizedOptions: SetTimeoutOptions = { ...options, type: options.type ?? 'returnValue' };\n\n let metaList = ReflectUtils.getOwnMetadata(SET_TIMEOUT_METADATA_KEY, constructor) as SetTimeoutMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(SET_TIMEOUT_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, delay, options: normalizedOptions });\n\n if (normalizedOptions.type === 'onConnected' || !descriptor) {\n return; // LifeCycler\uAC00 connect/disconnect\uB97C \uC804\uB2F4 - wrapping \uBD88\uD544\uC694\n }\n\n const original = descriptor.value;\n descriptor.value = function (this: any, ...args: any[]) {\n const res = original.apply(this, args);\n // valueKey\uB97C \uC548 \uC8FC\uBA74 \uC774 \uB370\uCF54\uB808\uC774\uD130 \uC804\uC6A9 METADATA_KEY\uB85C \uD3F4\uBC31 (applyAttribute.ts/applyNode.ts\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158)\n const vk = normalizedOptions.valueKey ?? SET_TIMEOUT_METADATA_KEY;\n const tickFn: ((id: number) => void) | undefined =\n typeof res === 'function' ? res : res && typeof res === 'object' && typeof res[vk] === 'function' ? res[vk] : undefined;\n\n if (tickFn) {\n ensureInit(this);\n const win = SwcUtils.resolveWindow(this);\n const id = win.setTimeout(() => {\n const entries = getActiveEntries(this);\n const idx = entries.indexOf(id);\n if (idx >= 0) entries.splice(idx, 1);\n try {\n tickFn(id);\n } catch (e) {\n console.error('[SWC] setTimeout fire error:', e);\n }\n }, delay);\n normalizedOptions.created?.(SwcUtils.getHelperAndHostSet(this), id);\n getActiveEntries(this).push(id);\n }\n return res;\n };\n return descriptor;\n };\n}\n\nexport const findAllSetTimeoutMetadata = (target: any): SetTimeoutMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return (ReflectUtils.findAllMetadata<SetTimeoutMetadata[]>(SET_TIMEOUT_METADATA_KEY, constructor) || []).flat();\n};\n\nexport class SetTimeoutLifeCycler implements ElementDefineLifeCycler {\n onConnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n inst.__swc_timeoutIds = []; // \uC7AC\uC5F0\uACB0 \uB300\uBE44 \uB9AC\uC14B\n for (const meta of findAllSetTimeoutMetadata(inst)) {\n if (meta.options.type !== 'onConnected') continue; // returnValue \uD0C0\uC785\uC740 \uC218\uB3D9 \uD638\uCD9C\uC744 \uAE30\uB2E4\uB9BC\n const id = helperHostSet.$w.setTimeout(() => {\n void (async () => {\n const helper = SwcUtils.getHelperAndHostSet(inst);\n if (meta.options.filter && !(await meta.options.filter(helper))) return;\n const paramArgs = meta.options.parameter?.(helperHostSet) ?? [];\n const hostSet = SwcUtils.getHostSet(inst);\n const helperSet = SwcUtils.getHelperSet(helperHostSet.$w);\n const buildArgs = (beforeReturn: any) => buildSwcParameterArgs(inst, meta.propertyKey, {\n hostSet, helperHostSet: helper, helperSet, setTimeoutBeforeReturn: beforeReturn\n }, [...paramArgs, beforeReturn]);\n let args = buildArgs(undefined);\n if (meta.options.before) { const br = await meta.options.before(helper); args = buildArgs(br); }\n let result: any, error: any;\n try {\n result = await inst[meta.propertyKey](...args);\n const vk = meta.options.valueKey ?? SET_TIMEOUT_METADATA_KEY;\n if (result && typeof result === 'object' && typeof result[vk] === 'function') result[vk](id);\n } catch (e) {\n error = e;\n } finally {\n if (meta.options.finally) await meta.options.finally(helper, { args, result, error });\n }\n if (error) console.error('[SWC] setTimeout fire error:', error);\n })().catch(e => console.error('[SWC] setTimeout fire error:', e));\n }, meta.delay);\n meta.options.created?.(helperHostSet, id);\n getActiveEntries(inst).push(id);\n }\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const id of inst.__swc_timeoutIds ?? []) {\n try {\n helperHostSet.$w.clearTimeout(id);\n } catch (e) {\n console.error('[SWC] clearTimeout error:', e);\n }\n }\n inst.__swc_timeoutIds = [];\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AAG/B,MAAM,2BAA2B,OAAO,IAAI,kCAAkC;AAoCrF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AG;AACV,oBAAQ;AAAA,UACV,UAAE;AACA,gBAAI,KAAK,QAAQ,QAAS,OAAM,KAAK,QAAQ,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM,CAAC;AAAA,UACtF;AACA,cAAI,MAAO,SAAQ,MAAM,gCAAgC,KAAK;AAAA,QAChE,GAAG,EAAE,MAAM,OAAK,QAAQ,MAAM,gCAAgC,CAAC,CAAC;AAAA,MAClE,GAAG,KAAK,KAAK;AACb,WAAK,QAAQ,UAAU,eAAe,EAAE;AACxC,uBAAiB,IAAI,EAAE,KAAK,EAAE;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,eAAe,eAAoC;AACjD,UAAM,OAAO,cAAc;AAC3B,eAAW,MAAM,KAAK,oBAAoB,CAAC,GAAG;AAC5C,UAAI;AACF,sBAAc,GAAG,aAAa,EAAE;AAAA,MAClC,SAAS,GAAG;AACV,gBAAQ,MAAM,6BAA6B,CAAC;AAAA,MAC9C;AAAA,IACF;AACA,SAAK,mBAAmB,CAAC;AAAA,EAC3B;AACF;",
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { buildSwcParameterArgs } from './parameter';\nimport { ElementDefineLifeCycler, HelperHostSet } from '../types';\n\nexport const SET_TIMEOUT_METADATA_KEY = Symbol.for('simple-web-component:set-timeout');\n\nexport type SetTimeoutType = 'onConnected' | 'returnValue';\n\nexport interface SetTimeoutOptions {\n /**\n * 'onConnected' (\uAE30\uBCF8\uAC12 - connect \uC2DC \uC790\uB3D9\uC73C\uB85C \uC608\uC57D, disconnect \uC2DC \uC790\uB3D9 \uC815\uB9AC) |\n * 'returnValue' (\uC790\uB3D9 \uC608\uC57D \uC5C6\uC74C. \uAC1C\uBC1C\uC790\uAC00 \uC774 \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC608\uC57D\uB418\uACE0,\n * \uADF8 \uD638\uCD9C\uC758 \uB9AC\uD134\uAC12\uC774 \uC2E4\uC81C\uB85C \uC2E4\uD589\uB420 \uD568\uC218\uAC00 \uB41C\uB2E4 - \uC544\uB798 \uC124\uBA85 \uCC38\uACE0).\n */\n type?: SetTimeoutType;\n /** \uC2E4\uD589 \uC2DC \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uC5D0 \uB118\uAE38 \uC778\uC790\uB97C \uACC4\uC0B0. type:'onConnected'\uC5D0\uC11C\uB9CC \uC758\uBBF8\uAC00 \uC788\uC74C (\uC5C6\uC73C\uBA74 \uC778\uC790 \uC5C6\uC774 \uD638\uCD9C). */\n parameter?: (set: HelperHostSet) => any[];\n /** \uD0C0\uC774\uBA38 \uB4F1\uB85D \uC9C1\uD6C4 1\uD68C \uD638\uCD9C (\uB514\uBC84\uAE45/\uB85C\uAE45\uC6A9). id\uB294 \uC2E4\uC81C setTimeout \uBC18\uD658\uAC12 - cleanup\uC740 \uC790\uB3D9\uC73C\uB85C \uCC98\uB9AC\uB418\uBBC0\uB85C \uC9C1\uC811 clear\uD560 \uD544\uC694 \uC5C6\uC74C. */\n created?: (set: HelperHostSet, id: number) => void;\n /** [type:'onConnected' \uC804\uC6A9] \uBC1C\uD654 \uC5EC\uBD80 \uAC8C\uC774\uD2B8. Promise<boolean>\uB3C4 \uAC00\uB2A5. false\uBA74 \uC2A4\uD0B5. */\n filter?: (set: HelperHostSet) => boolean | Promise<boolean>;\n /** [type:'onConnected' \uC804\uC6A9] \uD578\uB4E4\uB7EC \uC9C1\uC804 \uD6C5. await\uB418\uACE0, \uB9AC\uD134\uAC12\uC740 @setTimeoutBeforeReturn \uC73C\uB85C \uC8FC\uC785\uB41C\uB2E4. */\n before?: (set: HelperHostSet) => any | Promise<any>;\n /** [type:'onConnected' \uC804\uC6A9] \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. */\n finally?: (set: HelperHostSet, ctx: { args: any[]; result?: any; error?: any }) => any | Promise<any>;\n /**\n * type:'onConnected' - fire \uC2DC \uB370\uCF54\uB808\uC774\uD2B8\uB41C \uBA54\uC11C\uB4DC\uC758 \uB9AC\uD134\uAC12\uC774 \uAC1D\uCCB4\uC774\uACE0 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC774\uBA74 (id: number)\uB85C \uD638\uCD9C\uD55C\uB2E4.\n * type:'returnValue' - \uB9AC\uD134\uAC12\uC774 \uD568\uC218\uBA74 \uADF8 \uC790\uCCB4\uB97C, \uAC1D\uCCB4\uBA74 \uC774 \uD0A4\uC758 \uAC12\uC774 \uD568\uC218\uC77C \uB54C \uADF8 \uAC12\uC744 \"\uC2E4\uC81C\uB85C \uC2E4\uD589\uB420 \uD568\uC218\"\uB85C \uC0AC\uC6A9\uD55C\uB2E4.\n * \uC548 \uC8FC\uBA74 SET_TIMEOUT_METADATA_KEY\uB85C \uD3F4\uBC31\uD55C\uB2E4 - applyAttribute.ts/applyNode.ts\uC758 valueKey\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158\n * (\uB9AC\uD134 \uAC1D\uCCB4\uC5D0\uC11C \uC774 \uB370\uCF54\uB808\uC774\uD130 \uBAAB\uB9CC \uBF51\uC544 \uC4F0\uACE0, \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uC2A4\uD0DD\uD560 \uB54C\uB9CC \uCEE4\uC2A4\uD140 \uD0A4\uB85C \uAD6C\uBD84\uD558\uBA74 \uB41C\uB2E4).\n */\n valueKey?: symbol | string;\n}\n\nexport interface SetTimeoutMetadata {\n propertyKey: string | symbol;\n delay: number;\n options: SetTimeoutOptions;\n}\n\nconst getActiveEntries = (inst: any): number[] => (inst.__swc_timeoutIds ??= []);\n\n/**\n * type:'onConnected'(\uAE30\uBCF8\uAC12) - connect \uC2DC \uC790\uB3D9\uC73C\uB85C setTimeout\uC744 \uAC78\uACE0, disconnect \uC2DC (\uC544\uC9C1 \uC2E4\uD589 \uC804\uC774\uB77C\uBA74) \uC790\uB3D9\uC73C\uB85C clearTimeout \uD55C\uB2E4.\n * type:'returnValue' (@setTimeoutReturnValue) - \uBA54\uC11C\uB4DC\uB97C \uAC10\uC2F8\uC9C0 \uC54A\uB294 \uB300\uC2E0, \uD638\uCD9C\uB420 \uB54C\uB9C8\uB2E4(\uAC1C\uBC1C\uC790\uAC00 \uC9C1\uC811 \uD638\uCD9C) \uC6D0\uBCF8 \uB85C\uC9C1\uC744\n * \uADF8\uB300\uB85C \uC2E4\uD589\uD558\uACE0 \uB9AC\uD134\uAC12(\uB610\uB294 valueKey\uB85C \uBF51\uC740 \uAC12)\uC774 \uD568\uC218\uBA74 \uADF8 \uD568\uC218\uB97C \uC0C8 setTimeout\uC73C\uB85C \uC608\uC57D\uD55C\uB2E4.\n * \uD638\uCD9C\uD560 \uB54C\uB9C8\uB2E4 \uBCC4\uB3C4\uC758 \uC0C8 \uD0C0\uC774\uBA38\uAC00 \uC0DD\uAE30\uBA70, disconnect \uC2DC (\uC544\uC9C1 \uC2E4\uD589 \uC804\uC778 \uAC83\uB4E4\uC740) \uC804\uBD80 \uC815\uB9AC\uB41C\uB2E4.\n * \uC6D0\uBCF8 \uB9AC\uD134\uAC12\uC740 \uADF8\uB300\uB85C \uD1B5\uACFC\uC2DC\uD0A4\uBBC0\uB85C \uB2E4\uB978 \uB370\uCF54\uB808\uC774\uD130\uC640 \uAC19\uC740 \uBA54\uC11C\uB4DC\uC5D0 \uC2A4\uD0DD\uD574\uB3C4 \uC21C\uC11C\uC5D0 \uC0C1\uAD00\uC5C6\uC774 \uC548\uC804\uD558\uB2E4.\n */\nexport function setTimeout(delay: number, options: SetTimeoutOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n const normalizedOptions: SetTimeoutOptions = { ...options, type: options.type ?? 'onConnected' };\n\n let metaList = ReflectUtils.getOwnMetadata(SET_TIMEOUT_METADATA_KEY, constructor) as SetTimeoutMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(SET_TIMEOUT_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, delay, options: normalizedOptions });\n\n if (normalizedOptions.type === 'onConnected' || !descriptor) {\n return; // LifeCycler\uAC00 connect/disconnect\uB97C \uC804\uB2F4 - wrapping \uBD88\uD544\uC694\n }\n\n const original = descriptor.value;\n descriptor.value = function (this: any, ...args: any[]) {\n const res = original.apply(this, args);\n // valueKey\uB97C \uC548 \uC8FC\uBA74 \uC774 \uB370\uCF54\uB808\uC774\uD130 \uC804\uC6A9 METADATA_KEY\uB85C \uD3F4\uBC31 (applyAttribute.ts/applyNode.ts\uC640 \uB3D9\uC77C\uD55C \uCEE8\uBCA4\uC158)\n const vk = normalizedOptions.valueKey ?? SET_TIMEOUT_METADATA_KEY;\n const tickFn: ((id: number) => void) | undefined =\n typeof res === 'function' ? res : res && typeof res === 'object' && typeof res[vk] === 'function' ? res[vk] : undefined;\n\n if (tickFn) {\n ensureInit(this);\n const win = SwcUtils.resolveWindow(this);\n const id = win.setTimeout(() => {\n const entries = getActiveEntries(this);\n const idx = entries.indexOf(id);\n if (idx >= 0) entries.splice(idx, 1);\n try {\n tickFn(id);\n } catch (e) {\n console.error('[SWC] setTimeout fire error:', e);\n }\n }, delay);\n normalizedOptions.created?.(SwcUtils.getHelperAndHostSet(this), id);\n getActiveEntries(this).push(id);\n }\n return res;\n };\n return descriptor;\n };\n}\n\nexport const findAllSetTimeoutMetadata = (target: any): SetTimeoutMetadata[] => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return (ReflectUtils.findAllMetadata<SetTimeoutMetadata[]>(SET_TIMEOUT_METADATA_KEY, constructor) || []).flat();\n};\n\nexport class SetTimeoutLifeCycler implements ElementDefineLifeCycler {\n onConnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n inst.__swc_timeoutIds = []; // \uC7AC\uC5F0\uACB0 \uB300\uBE44 \uB9AC\uC14B\n for (const meta of findAllSetTimeoutMetadata(inst)) {\n if (meta.options.type !== 'onConnected') continue; // returnValue \uD0C0\uC785\uC740 \uC218\uB3D9 \uD638\uCD9C\uC744 \uAE30\uB2E4\uB9BC\n const id = helperHostSet.$w.setTimeout(() => {\n void (async () => {\n const helper = SwcUtils.getHelperAndHostSet(inst);\n if (meta.options.filter && !(await meta.options.filter(helper))) return;\n const paramArgs = meta.options.parameter?.(helperHostSet) ?? [];\n const hostSet = SwcUtils.getHostSet(inst);\n const helperSet = SwcUtils.getHelperSet(helperHostSet.$w);\n const buildArgs = (beforeReturn: any) => buildSwcParameterArgs(inst, meta.propertyKey, {\n hostSet, helperHostSet: helper, helperSet, setTimeoutBeforeReturn: beforeReturn\n }, [...paramArgs, beforeReturn]);\n let args = buildArgs(undefined);\n if (meta.options.before) { const br = await meta.options.before(helper); args = buildArgs(br); }\n let result: any, error: any;\n try {\n result = await inst[meta.propertyKey](...args);\n const vk = meta.options.valueKey ?? SET_TIMEOUT_METADATA_KEY;\n if (result && typeof result === 'object' && typeof result[vk] === 'function') result[vk](id);\n } catch (e) {\n error = e;\n } finally {\n if (meta.options.finally) await meta.options.finally(helper, { args, result, error });\n }\n if (error) console.error('[SWC] setTimeout fire error:', error);\n })().catch(e => console.error('[SWC] setTimeout fire error:', e));\n }, meta.delay);\n meta.options.created?.(helperHostSet, id);\n getActiveEntries(inst).push(id);\n }\n }\n\n onDisconnected(helperHostSet: HelperHostSet): void {\n const inst = helperHostSet.$this;\n for (const id of inst.__swc_timeoutIds ?? []) {\n try {\n helperHostSet.$w.clearTimeout(id);\n } catch (e) {\n console.error('[SWC] clearTimeout error:', e);\n }\n }\n inst.__swc_timeoutIds = [];\n }\n}\n\n/** \uC218\uB3D9 \uC608\uC57D: \uBA54\uC11C\uB4DC\uB97C \uC9C1\uC811 \uD638\uCD9C\uD574\uC57C \uC608\uC57D\uB41C\uB2E4. = @setTimeout(delay, { type: 'returnValue' }) */\nexport const setTimeoutReturnValue = (delay: number, options: Omit<SetTimeoutOptions, 'type'> = {}): MethodDecorator =>\n setTimeout(delay, { ...options, type: 'returnValue' });\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AAG/B,MAAM,2BAA2B,OAAO,IAAI,kCAAkC;AAoCrF,MAAM,mBAAmB,CAAC,SAAyB,KAAK,qBAAL,KAAK,mBAAqB,CAAC;AASvE,SAAS,WAAW,OAAe,UAA6B,CAAC,GAAoB;AAC1F,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,UAAM,oBAAuC,EAAE,GAAG,SAAS,MAAM,QAAQ,QAAQ,cAAc;AAE/F,QAAI,WAAW,aAAa,eAAe,0BAA0B,WAAW;AAChF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,mBAAa,eAAe,0BAA0B,UAAU,WAAW;AAAA,IAC7E;AACA,aAAS,KAAK,EAAE,aAAa,OAAO,SAAS,kBAAkB,CAAC;AAEhE,QAAI,kBAAkB,SAAS,iBAAiB,CAAC,YAAY;AAC3D;AAAA,IACF;AAEA,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,YAAwB,MAAa;AACtD,YAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAErC,YAAM,KAAK,kBAAkB,YAAY;AACzC,YAAM,SACJ,OAAO,QAAQ,aAAa,MAAM,OAAO,OAAO,QAAQ,YAAY,OAAO,IAAI,EAAE,MAAM,aAAa,IAAI,EAAE,IAAI;AAEhH,UAAI,QAAQ;AACV,mBAAW,IAAI;AACf,cAAM,MAAM,SAAS,cAAc,IAAI;AACvC,cAAM,KAAK,IAAI,WAAW,MAAM;AAC9B,gBAA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return createSubscribeSwcAppMessage(options, messageType);
|
|
32
32
|
}
|
|
33
33
|
const receiveMessage = subscribeSwcAppMessage;
|
|
34
|
+
const withSubject = (subject, a, b, descriptor) => {
|
|
35
|
+
if (descriptor) return createSubscribeSwcAppMessage({ subject })(a, b, descriptor);
|
|
36
|
+
if (typeof a === "string") return createSubscribeSwcAppMessage({ ...b ?? {}, subject }, a);
|
|
37
|
+
return createSubscribeSwcAppMessage({ ...a ?? {}, subject });
|
|
38
|
+
};
|
|
39
|
+
function subscribeSwcAppMessageBehavior(a, b, descriptor) {
|
|
40
|
+
return withSubject("behavior", a, b, descriptor);
|
|
41
|
+
}
|
|
42
|
+
function subscribeSwcAppMessageReplay(a, b, descriptor) {
|
|
43
|
+
return withSubject("replay", a, b, descriptor);
|
|
44
|
+
}
|
|
34
45
|
const getSubscribeSwcAppMessageMetadata = (target) => {
|
|
35
46
|
const constructor = typeof target === "function" ? target : target.constructor;
|
|
36
47
|
return ReflectUtils.findAllMetadata(SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY, constructor).flat();
|
|
@@ -48,6 +59,8 @@ export {
|
|
|
48
59
|
SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY,
|
|
49
60
|
getSubscribeSwcAppMessageMetadata,
|
|
50
61
|
receiveMessage,
|
|
51
|
-
subscribeSwcAppMessage
|
|
62
|
+
subscribeSwcAppMessage,
|
|
63
|
+
subscribeSwcAppMessageBehavior,
|
|
64
|
+
subscribeSwcAppMessageReplay
|
|
52
65
|
};
|
|
53
66
|
//# sourceMappingURL=subscribeSwcAppMessage.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/subscribeSwcAppMessage.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage, SwcAppMessageSubject, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message');\n\nexport interface SwcAppMessageOptions<Data = any, BeforeReturn = any, Result = any> {\n /** \uBA54\uC2DC\uC9C0 \uC218\uC2E0 \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?: (message: SwcAppMessage<Data>, currentThis: any) => boolean | Promise<boolean>;\n /** filter \uD1B5\uACFC \uD6C4 \uD578\uB4E4\uB7EC \uC9C1\uC804 \uD6C5. await\uB418\uACE0, \uB9AC\uD134\uAC12\uC740 @appMessageBeforeReturn \uC73C\uB85C \uD578\uB4E4\uB7EC\uC5D0 \uC8FC\uC785\uB41C\uB2E4. */\n before?: (message: SwcAppMessage<Data>, currentThis: any) => BeforeReturn | Promise<BeforeReturn>;\n /** \uD578\uB4E4\uB7EC\uAC00 \uC131\uACF5/\uC2E4\uD328\uD574\uB3C4 \uD56D\uC0C1 \uC2E4\uD589\uB418\uB294 \uC815\uB9AC \uD6C5. ctx\uB85C \uD578\uB4E4\uB7EC \uC778\uC790/\uACB0\uACFC/\uC5D0\uB7EC\uB97C \uBC1B\uB294\uB2E4. \uC5D0\uB7EC\uB294 \uC0BC\uD0A4\uC9C0 \uC54A\uACE0 \uC804\uD30C. */\n finally?: (message: SwcAppMessage<Data>, currentThis: any, ctx: { args: any[]; result?: Result; error?: any }) => any | Promise<any>;\n /**\n * \uB2A6\uAC8C \uC5F0\uACB0\uB41C \uACBD\uC6B0 \uACFC\uAC70 \uBA54\uC2DC\uC9C0 \uC7AC\uC0DD \uBC29\uC2DD. \uC774\uBBF8 \uC5F0\uACB0\uB41C \uAD6C\uB3C5\uC790\uC5D0\uAC8C\uB294 \uD56D\uC0C1 live\uB85C \uC3E8.\n * - \uBBF8\uC9C0\uC815/'subject': live\uB9CC. \uC9C0\uB098\uAC04 \uAC74 \uBABB \uBC1B\uC74C (\uAE30\uBCF8\uAC12, \uAE30\uC874 \uB3D9\uC791)\n * - 'behavior': \uB9C8\uC9C0\uB9C9 1\uAC1C \uC7AC\uC0DD\n * - 'replay': \uBC84\uD37C \uC804\uCCB4 \uC2DC\uAC04\uC21C \uC7AC\uC0DD\n */\n subject?: SwcAppMessageSubject;\n /**\n * \uC7AC\uC0DD \uC2DC\uC810. \uAE30\uBCF8 'connected' (\uC5F0\uACB0 \uC989\uC2DC).\n * - 'connectedDone': \uC5D8\uB9AC\uBA3C\uD2B8 render \uC644\uB8CC \uD6C4 (_connectedDone). @innerHtml \uB4F1\n * DOM \uD0C0\uAC9F\uC774 \uD544\uC694\uD55C \uD578\uB4E4\uB7EC\uB294 \uC774\uAC78\uB85C (replay\uAC00 render\uBCF4\uB2E4 \uBA3C\uC800 \uC640\uC11C \uC99D\uBC1C\uD558\uB294 \uB808\uC774\uC2A4 \uBC29\uC9C0).\n */\n trigger?: 'connected' | 'connectedDone';\n}\n\nexport interface SwcAppMessageSubscriberMetadata extends SwcAppMessageOptions {\n propertyKey: string | symbol;\n messageType?: string;\n}\n\nfunction createSubscribeSwcAppMessage(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter: options?.filter, before: options?.before, finally: options?.finally, subject: options?.subject, trigger: options?.trigger });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessage(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessage(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessage<Data = any, BeforeReturn = any, Result = any>(options: SwcAppMessageOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessage<Data = any, BeforeReturn = any, Result = any>(messageType: string, options: SwcAppMessageOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\n\nexport function subscribeSwcAppMessage(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessage\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessage({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessage('messageType') \uB610\uB294 @subscribeSwcAppMessage('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessage({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessage(options, messageType);\n}\n\nexport const receiveMessage = subscribeSwcAppMessage;\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return ReflectUtils.findAllMetadata<any[]>(SUBSCRIBE_SWC_APP_MESSAGE_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// MessageSubscribeLifeCycler\n// NOTE: \uC2E4\uC81C \uAD6C\uB3C5 \uB85C\uC9C1\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\uB41C\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 } from '../types';\n\nexport class MessageSubscribeLifeCycler implements ElementDefineLifeCycler {\n onConnected(_helperHostSet: HelperHostSet): void {\n // \uC2E4\uC81C \uAD6C\uB3C5\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\n }\n\n /** SwcAppMixin \uC774 \uAD6C\uB3C5 \uB300\uC0C1 \uBA54\uD0C0\uB97C \uAEBC\uB0BC \uB54C \uC0AC\uC6A9 */\n getMetadata(helperHostSet: HelperHostSet): SwcAppMessageSubscriberMetadata[] | undefined {\n return getSubscribeSwcAppMessageMetadata(helperHostSet.$this);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,yCAAyC,OAAO,IAAI,gDAAgD;AA6BjH,SAAS,6BAA6B,SAAgC,aAAuC;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,wCAAwC,WAAW;AAC1F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,wCAAwC,MAAM,WAAW;AAAA,IACvF;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,QAAQ,SAAS,QAAQ,QAAQ,SAAS,QAAQ,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,QAAQ,CAAC;AAEzK,WAAO;AAAA,EACT;AACF;AAWO,SAAS,uBAAuB,8BAAoC,sBAA4B,YAAsC;AAE3I,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,6BAA6B,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACzE;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,6BAA6B,SAAS,WAAW;AAC1D;AAEO,MAAM,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage, SwcAppMessageSubject, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message');\n\nexport interface SwcAppMessageOptions<Data = any, BeforeReturn = any, Result = any> {\n /** \uBA54\uC2DC\uC9C0 \uC218\uC2E0 \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?: (message: SwcAppMessage<Data>, currentThis: any) => boolean | Promise<boolean>;\n /** filter \uD1B5\uACFC \uD6C4 \uD578\uB4E4\uB7EC \uC9C1\uC804 \uD6C5. await\uB418\uACE0, \uB9AC\uD134\uAC12\uC740 @appMessageBeforeReturn \uC73C\uB85C \uD578\uB4E4\uB7EC\uC5D0 \uC8FC\uC785\uB41C\uB2E4. */\n before?: (message: SwcAppMessage<Data>, currentThis: any) => BeforeReturn | Promise<BeforeReturn>;\n /** \uD578\uB4E4\uB7EC\uAC00 \uC131\uACF5/\uC2E4\uD328\uD574\uB3C4 \uD56D\uC0C1 \uC2E4\uD589\uB418\uB294 \uC815\uB9AC \uD6C5. ctx\uB85C \uD578\uB4E4\uB7EC \uC778\uC790/\uACB0\uACFC/\uC5D0\uB7EC\uB97C \uBC1B\uB294\uB2E4. \uC5D0\uB7EC\uB294 \uC0BC\uD0A4\uC9C0 \uC54A\uACE0 \uC804\uD30C. */\n finally?: (message: SwcAppMessage<Data>, currentThis: any, ctx: { args: any[]; result?: Result; error?: any }) => any | Promise<any>;\n /**\n * \uB2A6\uAC8C \uC5F0\uACB0\uB41C \uACBD\uC6B0 \uACFC\uAC70 \uBA54\uC2DC\uC9C0 \uC7AC\uC0DD \uBC29\uC2DD. \uC774\uBBF8 \uC5F0\uACB0\uB41C \uAD6C\uB3C5\uC790\uC5D0\uAC8C\uB294 \uD56D\uC0C1 live\uB85C \uC3E8.\n * - \uBBF8\uC9C0\uC815/'subject': live\uB9CC. \uC9C0\uB098\uAC04 \uAC74 \uBABB \uBC1B\uC74C (\uAE30\uBCF8\uAC12, \uAE30\uC874 \uB3D9\uC791)\n * - 'behavior': \uB9C8\uC9C0\uB9C9 1\uAC1C \uC7AC\uC0DD\n * - 'replay': \uBC84\uD37C \uC804\uCCB4 \uC2DC\uAC04\uC21C \uC7AC\uC0DD\n */\n subject?: SwcAppMessageSubject;\n /**\n * \uC7AC\uC0DD \uC2DC\uC810. \uAE30\uBCF8 'connected' (\uC5F0\uACB0 \uC989\uC2DC).\n * - 'connectedDone': \uC5D8\uB9AC\uBA3C\uD2B8 render \uC644\uB8CC \uD6C4 (_connectedDone). @innerHtml \uB4F1\n * DOM \uD0C0\uAC9F\uC774 \uD544\uC694\uD55C \uD578\uB4E4\uB7EC\uB294 \uC774\uAC78\uB85C (replay\uAC00 render\uBCF4\uB2E4 \uBA3C\uC800 \uC640\uC11C \uC99D\uBC1C\uD558\uB294 \uB808\uC774\uC2A4 \uBC29\uC9C0).\n */\n trigger?: 'connected' | 'connectedDone';\n}\n\nexport interface SwcAppMessageSubscriberMetadata extends SwcAppMessageOptions {\n propertyKey: string | symbol;\n messageType?: string;\n}\n\nfunction createSubscribeSwcAppMessage(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter: options?.filter, before: options?.before, finally: options?.finally, subject: options?.subject, trigger: options?.trigger });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessage(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessage(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessage<Data = any, BeforeReturn = any, Result = any>(options: SwcAppMessageOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessage<Data = any, BeforeReturn = any, Result = any>(messageType: string, options: SwcAppMessageOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\n\nexport function subscribeSwcAppMessage(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessage\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessage({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessage('messageType') \uB610\uB294 @subscribeSwcAppMessage('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessage({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessage(options, messageType);\n}\n\nexport const receiveMessage = subscribeSwcAppMessage;\n\n// \u2500\u2500 subject \uB97C \uC774\uB984\uC5D0 \uBC15\uC740 \uBCC4\uCE6D: @subscribeSwcAppMessageBehavior('auth') = @subscribeSwcAppMessage('auth', { subject: 'behavior' }) \u2500\u2500\ntype SubjectlessOptions<Data, BeforeReturn, Result> = Omit<SwcAppMessageOptions<Data, BeforeReturn, Result>, 'subject'>;\n\nconst withSubject = (subject: SwcAppMessageSubject, a?: any, b?: any, descriptor?: PropertyDescriptor): any => {\n if (descriptor) return createSubscribeSwcAppMessage({ subject })(a, b, descriptor); // \uAD04\uD638 \uC5C6\uC774\n if (typeof a === 'string') return createSubscribeSwcAppMessage({ ...(b ?? {}), subject }, a);\n return createSubscribeSwcAppMessage({ ...(a ?? {}), subject });\n};\n\n/** \uB2A6\uAC8C \uBD99\uC5B4\uB3C4 \uB9C8\uC9C0\uB9C9 \uBA54\uC2DC\uC9C0 1\uAC1C\uB97C \uBC1B\uB294\uB2E4 (subject: 'behavior') */\nexport function subscribeSwcAppMessageBehavior(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function subscribeSwcAppMessageBehavior(messageType: string): MethodDecorator;\nexport function subscribeSwcAppMessageBehavior<Data = any, BeforeReturn = any, Result = any>(options: SubjectlessOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\nexport function subscribeSwcAppMessageBehavior<Data = any, BeforeReturn = any, Result = any>(messageType: string, options: SubjectlessOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\nexport function subscribeSwcAppMessageBehavior(a?: any, b?: any, descriptor?: PropertyDescriptor): any {\n return withSubject('behavior', a, b, descriptor);\n}\n\n/** \uB2A6\uAC8C \uBD99\uC5B4\uB3C4 \uC9C0\uB098\uAC04 \uBA54\uC2DC\uC9C0\uB97C \uC804\uBD80 \uC2DC\uAC04\uC21C\uC73C\uB85C \uBC1B\uB294\uB2E4 (subject: 'replay') */\nexport function subscribeSwcAppMessageReplay(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function subscribeSwcAppMessageReplay(messageType: string): MethodDecorator;\nexport function subscribeSwcAppMessageReplay<Data = any, BeforeReturn = any, Result = any>(options: SubjectlessOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\nexport function subscribeSwcAppMessageReplay<Data = any, BeforeReturn = any, Result = any>(messageType: string, options: SubjectlessOptions<NoInfer<Data>, NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;\nexport function subscribeSwcAppMessageReplay(a?: any, b?: any, descriptor?: PropertyDescriptor): any {\n return withSubject('replay', a, b, descriptor);\n}\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = typeof target === 'function' ? target : target.constructor;\n return ReflectUtils.findAllMetadata<any[]>(SUBSCRIBE_SWC_APP_MESSAGE_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// MessageSubscribeLifeCycler\n// NOTE: \uC2E4\uC81C \uAD6C\uB3C5 \uB85C\uC9C1\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\uB41C\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 } from '../types';\n\nexport class MessageSubscribeLifeCycler implements ElementDefineLifeCycler {\n onConnected(_helperHostSet: HelperHostSet): void {\n // \uC2E4\uC81C \uAD6C\uB3C5\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\n }\n\n /** SwcAppMixin \uC774 \uAD6C\uB3C5 \uB300\uC0C1 \uBA54\uD0C0\uB97C \uAEBC\uB0BC \uB54C \uC0AC\uC6A9 */\n getMetadata(helperHostSet: HelperHostSet): SwcAppMessageSubscriberMetadata[] | undefined {\n return getSubscribeSwcAppMessageMetadata(helperHostSet.$this);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,yCAAyC,OAAO,IAAI,gDAAgD;AA6BjH,SAAS,6BAA6B,SAAgC,aAAuC;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,wCAAwC,WAAW;AAC1F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,wCAAwC,MAAM,WAAW;AAAA,IACvF;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,QAAQ,SAAS,QAAQ,QAAQ,SAAS,QAAQ,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,QAAQ,CAAC;AAEzK,WAAO;AAAA,EACT;AACF;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ACvF,WAAO,kCAAkC,cAAc,KAAK;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14816,7 +14816,9 @@ var EventListenerLifeCycler = class {
|
|
|
14816
14816
|
const currentWin = helperHostSet2.$w;
|
|
14817
14817
|
const { type, options } = meta;
|
|
14818
14818
|
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
14819
|
+
const matchedTargets = /* @__PURE__ */ new WeakMap();
|
|
14819
14820
|
const handler = async (event2) => {
|
|
14821
|
+
const matchedElement2 = matchedTargets.get(event2) ?? event2.currentTarget;
|
|
14820
14822
|
const helper = options.filter || options.before || options.finally ? SwcUtils.getHelperAndHostSet(target, currentWin) : void 0;
|
|
14821
14823
|
if (options.filter) {
|
|
14822
14824
|
if (!await options.filter(event2, { currentThis: inst, helper })) return;
|
|
@@ -14825,12 +14827,12 @@ var EventListenerLifeCycler = class {
|
|
|
14825
14827
|
if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
14826
14828
|
if (options.preventDefault) event2.preventDefault();
|
|
14827
14829
|
const currentHostSet = SwcUtils.getHostSet(inst);
|
|
14828
|
-
const legacyArgs = [event2, { currentHostSet, $matchedElement:
|
|
14830
|
+
const legacyArgs = [event2, { currentHostSet, $matchedElement: matchedElement2 }, { event: event2, ...currentHostSet, $el: target, $root: target }];
|
|
14829
14831
|
const currentHelperSet = SwcUtils.getHelperSet(currentWin);
|
|
14830
14832
|
const currentHelperHostSet = { ...currentHelperSet, ...currentHostSet, $this: inst };
|
|
14831
14833
|
const buildArgs = (beforeReturn) => buildSwcParameterArgs(inst, meta.propertyKey, {
|
|
14832
14834
|
eventObject: event2,
|
|
14833
|
-
matchedElement:
|
|
14835
|
+
matchedElement: matchedElement2,
|
|
14834
14836
|
hostSet: currentHostSet,
|
|
14835
14837
|
helperHostSet: currentHelperHostSet,
|
|
14836
14838
|
helperSet: currentHelperSet,
|
|
@@ -14864,7 +14866,10 @@ var EventListenerLifeCycler = class {
|
|
|
14864
14866
|
next: (e) => handler(e).catch((err) => console.error("Event handler error:", err)),
|
|
14865
14867
|
error: (err) => console.error("Event stream error:", err)
|
|
14866
14868
|
});
|
|
14867
|
-
const wrappedHandler = (event2) =>
|
|
14869
|
+
const wrappedHandler = (event2) => {
|
|
14870
|
+
matchedTargets.set(event2, event2.currentTarget);
|
|
14871
|
+
eventSubject.next(event2);
|
|
14872
|
+
};
|
|
14868
14873
|
target.addEventListener(type, wrappedHandler, opts);
|
|
14869
14874
|
const onRemoves = options.removeListener ? [{ fn: options.removeListener, opts: options }] : [];
|
|
14870
14875
|
this.getBoundListeners(inst).push({ target, type, handler: wrappedHandler, options: opts, subscription, onRemoves, meta });
|
|
@@ -16936,6 +16941,17 @@ function subscribeSwcAppMessage(targetOrMessageTypeOrOptions, optionsOrPropertyK
|
|
|
16936
16941
|
return createSubscribeSwcAppMessage(options, messageType);
|
|
16937
16942
|
}
|
|
16938
16943
|
var receiveMessage = subscribeSwcAppMessage;
|
|
16944
|
+
var withSubject = (subject, a, b, descriptor) => {
|
|
16945
|
+
if (descriptor) return createSubscribeSwcAppMessage({ subject })(a, b, descriptor);
|
|
16946
|
+
if (typeof a === "string") return createSubscribeSwcAppMessage({ ...b ?? {}, subject }, a);
|
|
16947
|
+
return createSubscribeSwcAppMessage({ ...a ?? {}, subject });
|
|
16948
|
+
};
|
|
16949
|
+
function subscribeSwcAppMessageBehavior(a, b, descriptor) {
|
|
16950
|
+
return withSubject("behavior", a, b, descriptor);
|
|
16951
|
+
}
|
|
16952
|
+
function subscribeSwcAppMessageReplay(a, b, descriptor) {
|
|
16953
|
+
return withSubject("replay", a, b, descriptor);
|
|
16954
|
+
}
|
|
16939
16955
|
var getSubscribeSwcAppMessageMetadata = (target) => {
|
|
16940
16956
|
const constructor = typeof target === "function" ? target : target.constructor;
|
|
16941
16957
|
return ReflectUtils.findAllMetadata(SUBSCRIBE_SWC_APP_MESSAGE_METADATA_KEY, constructor).flat();
|
|
@@ -17010,7 +17026,7 @@ var getActiveEntries = (inst) => inst.__swc_intervalIds ?? (inst.__swc_intervalI
|
|
|
17010
17026
|
function setInterval2(interval2, options = {}) {
|
|
17011
17027
|
return (target, propertyKey, descriptor) => {
|
|
17012
17028
|
const constructor = target.constructor;
|
|
17013
|
-
const normalizedOptions = { ...options, type: options.type ?? "
|
|
17029
|
+
const normalizedOptions = { ...options, type: options.type ?? "onConnected" };
|
|
17014
17030
|
let metaList = ReflectUtils.getOwnMetadata(SET_INTERVAL_METADATA_KEY, constructor);
|
|
17015
17031
|
if (!metaList) {
|
|
17016
17032
|
metaList = [];
|
|
@@ -17100,6 +17116,7 @@ var SetIntervalLifeCycler = class {
|
|
|
17100
17116
|
inst.__swc_intervalIds = [];
|
|
17101
17117
|
}
|
|
17102
17118
|
};
|
|
17119
|
+
var setIntervalReturnValue = (interval2, options = {}) => setInterval2(interval2, { ...options, type: "returnValue" });
|
|
17103
17120
|
|
|
17104
17121
|
// src/decorators/setTimeout.ts
|
|
17105
17122
|
var SET_TIMEOUT_METADATA_KEY = Symbol.for("simple-web-component:set-timeout");
|
|
@@ -17107,7 +17124,7 @@ var getActiveEntries2 = (inst) => inst.__swc_timeoutIds ?? (inst.__swc_timeoutId
|
|
|
17107
17124
|
function setTimeout2(delay, options = {}) {
|
|
17108
17125
|
return (target, propertyKey, descriptor) => {
|
|
17109
17126
|
const constructor = target.constructor;
|
|
17110
|
-
const normalizedOptions = { ...options, type: options.type ?? "
|
|
17127
|
+
const normalizedOptions = { ...options, type: options.type ?? "onConnected" };
|
|
17111
17128
|
let metaList = ReflectUtils.getOwnMetadata(SET_TIMEOUT_METADATA_KEY, constructor);
|
|
17112
17129
|
if (!metaList) {
|
|
17113
17130
|
metaList = [];
|
|
@@ -17200,6 +17217,7 @@ var SetTimeoutLifeCycler = class {
|
|
|
17200
17217
|
inst.__swc_timeoutIds = [];
|
|
17201
17218
|
}
|
|
17202
17219
|
};
|
|
17220
|
+
var setTimeoutReturnValue = (delay, options = {}) => setTimeout2(delay, { ...options, type: "returnValue" });
|
|
17203
17221
|
|
|
17204
17222
|
// src/decorators/requestAnimationFrame.ts
|
|
17205
17223
|
var REQUEST_ANIMATION_FRAME_METADATA_KEY = Symbol.for("simple-web-component:request-animation-frame");
|
|
@@ -17226,7 +17244,7 @@ var startFrameLoop = (win, entries, frameFn) => {
|
|
|
17226
17244
|
};
|
|
17227
17245
|
var applyRequestAnimationFrame = (options, target, propertyKey, descriptor) => {
|
|
17228
17246
|
const constructor = target.constructor;
|
|
17229
|
-
const normalizedOptions = { ...options, type: options.type ?? "
|
|
17247
|
+
const normalizedOptions = { ...options, type: options.type ?? "onConnected" };
|
|
17230
17248
|
let metaList = ReflectUtils.getOwnMetadata(REQUEST_ANIMATION_FRAME_METADATA_KEY, constructor);
|
|
17231
17249
|
if (!metaList) {
|
|
17232
17250
|
metaList = [];
|
|
@@ -17288,6 +17306,13 @@ var RequestAnimationFrameLifeCycler = class {
|
|
|
17288
17306
|
inst.__swc_requestAnimationFrameIds = [];
|
|
17289
17307
|
}
|
|
17290
17308
|
};
|
|
17309
|
+
function requestAnimationFrameReturnValue(optionsOrTarget, propertyKey, descriptor) {
|
|
17310
|
+
if (propertyKey !== void 0) {
|
|
17311
|
+
applyRequestAnimationFrame({ type: "returnValue" }, optionsOrTarget, propertyKey, descriptor);
|
|
17312
|
+
return;
|
|
17313
|
+
}
|
|
17314
|
+
return (target, propertyKey2, descriptor2) => applyRequestAnimationFrame({ ...optionsOrTarget ?? {}, type: "returnValue" }, target, propertyKey2, descriptor2);
|
|
17315
|
+
}
|
|
17291
17316
|
|
|
17292
17317
|
// src/decorators/eventMedia.ts
|
|
17293
17318
|
var EVENT_MEDIA_METADATA_KEY = Symbol.for("simple-web-component:event-media");
|
|
@@ -24289,6 +24314,7 @@ export {
|
|
|
24289
24314
|
replaceChildrenSlot,
|
|
24290
24315
|
replaceChildrenTextSlot,
|
|
24291
24316
|
requestAnimationFrame,
|
|
24317
|
+
requestAnimationFrameReturnValue,
|
|
24292
24318
|
resizeObserver,
|
|
24293
24319
|
resizeObserverAll,
|
|
24294
24320
|
resizeObserverBeforeReturn,
|
|
@@ -24305,10 +24331,12 @@ export {
|
|
|
24305
24331
|
setClass,
|
|
24306
24332
|
setInterval2 as setInterval,
|
|
24307
24333
|
setIntervalBeforeReturn,
|
|
24334
|
+
setIntervalReturnValue,
|
|
24308
24335
|
setSSRAttribute,
|
|
24309
24336
|
setStyle,
|
|
24310
24337
|
setTimeout2 as setTimeout,
|
|
24311
24338
|
setTimeoutBeforeReturn,
|
|
24339
|
+
setTimeoutReturnValue,
|
|
24312
24340
|
skipIfEmpty,
|
|
24313
24341
|
skipIfExists,
|
|
24314
24342
|
skipIfSameTagPresent,
|
|
@@ -24319,6 +24347,8 @@ export {
|
|
|
24319
24347
|
styleLight,
|
|
24320
24348
|
styleShadow,
|
|
24321
24349
|
subscribeSwcAppMessage,
|
|
24350
|
+
subscribeSwcAppMessageBehavior,
|
|
24351
|
+
subscribeSwcAppMessageReplay,
|
|
24322
24352
|
subscribeSwcAppRouteChange,
|
|
24323
24353
|
subscribeSwcAppRouteChangeConnectedDone,
|
|
24324
24354
|
swcAppArticleTagName,
|