@dooboostore/simple-web-component 1.0.39 → 1.0.41

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.
Files changed (98) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +235 -47
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +194 -111
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyNode.js +58 -43
  7. package/dist/cjs/decorators/applyNode.js.map +2 -2
  8. package/dist/cjs/decorators/applyProperty.js +213 -0
  9. package/dist/cjs/decorators/applyProperty.js.map +7 -0
  10. package/dist/cjs/decorators/applySlot.js +32 -26
  11. package/dist/cjs/decorators/applySlot.js.map +2 -2
  12. package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
  13. package/dist/cjs/decorators/elementDefine.js +17 -30
  14. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  15. package/dist/cjs/decorators/index.js +2 -2
  16. package/dist/cjs/decorators/index.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +4 -4
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -3
  20. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  21. package/dist/cjs/elements/SwcApp.js.map +2 -2
  22. package/dist/cjs/elements/SwcAppMixin.js +11 -4
  23. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  24. package/dist/cjs/types/index.js.map +1 -1
  25. package/dist/esm/SwcAppEngine.js.map +2 -2
  26. package/dist/esm/decorators/applyAttribute.js +196 -113
  27. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  28. package/dist/esm/decorators/applyNode.js +58 -43
  29. package/dist/esm/decorators/applyNode.js.map +2 -2
  30. package/dist/esm/decorators/applyProperty.js +194 -0
  31. package/dist/esm/decorators/applyProperty.js.map +7 -0
  32. package/dist/esm/decorators/applySlot.js +32 -26
  33. package/dist/esm/decorators/applySlot.js.map +2 -2
  34. package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
  35. package/dist/esm/decorators/elementDefine.js +17 -30
  36. package/dist/esm/decorators/elementDefine.js.map +2 -2
  37. package/dist/esm/decorators/index.js +2 -2
  38. package/dist/esm/decorators/index.js.map +1 -1
  39. package/dist/esm/decorators/lifecycles.js +4 -4
  40. package/dist/esm/decorators/lifecycles.js.map +2 -2
  41. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -3
  42. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  43. package/dist/esm/elements/SwcApp.js.map +2 -2
  44. package/dist/esm/elements/SwcAppMixin.js +11 -4
  45. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  46. package/dist/esm/types/index.js.map +1 -1
  47. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +441 -401
  48. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  49. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  50. package/dist/types/decorators/applyAttribute.d.ts +56 -15
  51. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  52. package/dist/types/decorators/applyNode.d.ts +28 -24
  53. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  54. package/dist/types/decorators/applyProperty.d.ts +61 -0
  55. package/dist/types/decorators/applyProperty.d.ts.map +1 -0
  56. package/dist/types/decorators/applySlot.d.ts +10 -10
  57. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  58. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  59. package/dist/types/decorators/index.d.ts +2 -2
  60. package/dist/types/decorators/index.d.ts.map +1 -1
  61. package/dist/types/decorators/lifecycles.d.ts +4 -4
  62. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  63. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
  64. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  65. package/dist/types/elements/SwcApp.d.ts.map +1 -1
  66. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  67. package/dist/types/types/index.d.ts +1 -6
  68. package/dist/types/types/index.d.ts.map +1 -1
  69. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +441 -401
  70. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  71. package/package.json +3 -3
  72. package/src/SwcAppEngine.ts +1 -0
  73. package/src/decorators/applyAttribute.ts +311 -126
  74. package/src/decorators/applyNode.ts +68 -57
  75. package/src/decorators/applyProperty.ts +302 -0
  76. package/src/decorators/applySlot.ts +25 -18
  77. package/src/decorators/changedAttributeThis.ts +1 -1
  78. package/src/decorators/elementDefine.ts +41 -30
  79. package/src/decorators/index.ts +2 -3
  80. package/src/decorators/lifecycles.ts +6 -6
  81. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +14 -4
  82. package/src/elements/SwcApp.ts +0 -1
  83. package/src/elements/SwcAppMixin.ts +16 -4
  84. package/src/types/index.ts +7 -7
  85. package/dist/cjs/decorators/attribute.js +0 -187
  86. package/dist/cjs/decorators/attribute.js.map +0 -7
  87. package/dist/cjs/decorators/setProperty.js +0 -109
  88. package/dist/cjs/decorators/setProperty.js.map +0 -7
  89. package/dist/esm/decorators/attribute.js +0 -168
  90. package/dist/esm/decorators/attribute.js.map +0 -7
  91. package/dist/esm/decorators/setProperty.js +0 -90
  92. package/dist/esm/decorators/setProperty.js.map +0 -7
  93. package/dist/types/decorators/attribute.d.ts +0 -31
  94. package/dist/types/decorators/attribute.d.ts.map +0 -1
  95. package/dist/types/decorators/setProperty.d.ts +0 -17
  96. package/dist/types/decorators/setProperty.d.ts.map +0 -1
  97. package/src/decorators/attribute.ts +0 -223
  98. package/src/decorators/setProperty.ts +0 -112
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type AttributeAction = 'set' | 'update' | 'remove';\n\nexport interface AttributeApplyOptions extends SwcQueryOptions {\n name?: string;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface AttributeApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: AttributeAction;\n options: AttributeApplyOptions;\n}\n\nexport const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for('simple-web-component:attribute-apply');\n\nfunction createAttributeDecorator(action: AttributeAction) {\n return (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor) as Map<string | symbol, AttributeApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AttributeApplyMetadata>();\n ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);\n }\n\n let attributeName = typeof nameOrOptions === 'string' ? nameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof nameOrOptions === 'object' && nameOrOptions !== null) {\n finalOptions = nameOrOptions as AttributeApplyOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n action, \n options: { ...finalOptions, name: attributeName } \n });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (action === 'set' || action === 'update') {\n if (attributeName) {\n // Case: @setAttribute(selector, 'name')\n if (resolvedRes === null || resolvedRes === undefined || resolvedRes === false) {\n targetEl.removeAttribute(attributeName);\n } else {\n targetEl.setAttribute(attributeName, resolvedRes === true ? '' : String(resolvedRes));\n }\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @applyAttribute(selector) with Object return\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined || finalVal === false) {\n targetEl.removeAttribute(attr);\n } else {\n targetEl.setAttribute(attr, finalVal === true ? '' : String(finalVal));\n }\n });\n }\n } else if (action === 'remove') {\n if (attributeName) {\n targetEl.removeAttribute(attributeName);\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) targetEl.removeAttribute(attr);\n });\n } else {\n const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n attrs.forEach(a => targetEl.removeAttribute(String(a)));\n }\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n return descriptor;\n };\n };\n}\n\nexport function applyAttribute(selector: string, action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)(selector, options);\n}\n\nexport const setAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(selector, nameOrOptions, options);\nexport const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);\nexport const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);\n\n// This versions\nexport function applyAttributeThis(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)('$this', options);\n}\nexport const setAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')('$this', nameOrOptions, options);\nexport const updateAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')('$this', nameOrOptions, options);\nexport const removeAttributeThis = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')('$this', nameOrOptions, options);\n\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {\n const result = new Map<string | symbol, AttributeApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AttributeApplyMetadata>>(ATTRIBUTE_APPLY_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAiBlB,MAAM,+BAA+B,OAAO,IAAI,sCAAsC;AAE7F,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,UAAkB,eAAgD,UAAiC,CAAC,MAAuB;AACjI,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,aAAa,eAAe,8BAA8B,WAAW;AACpF,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAA6C;AAC5D,qBAAa,eAAe,8BAA8B,UAAU,WAAW;AAAA,MACjF;AAEA,UAAI,gBAAgB,OAAO,kBAAkB,WAAW,gBAAgB;AACxE,UAAI,eAAe;AAEnB,UAAI,OAAO,kBAAkB,YAAY,kBAAkB,MAAM;AAC7D,uBAAe;AAAA,MACnB;AAEA,eAAS,IAAI,aAAa;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,EAAE,GAAG,cAAc,MAAM,cAAc;AAAA,MAClD,CAAC;AAED,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,YAAa,MAAa;AAC3C,mBAAW,IAAI;AACf,cAAM,MAAO,SAAiB,MAAM,MAAM,IAAI;AAE9C,cAAM,eAAe,CAAC,kBAAuB;AAC3C,cAAI,kBAAkB,QAAW;AAC/B,kBAAM,MAAO,KAAa,eAAe,eAAe;AACxD,kBAAM,OAAO;AACb,kBAAM,UAAU,EAAE,GAAG,SAAS,oBAAoB,KAAK,IAAI,GAAG,OA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AAA,QACzB;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAAS,eAAe,UAAkB,SAA0B,UAAU,UAAiC,CAAC,GAAoB;AACzI,SAAO,yBAAyB,MAAM,EAAE,UAAU,OAAO;AAC3D;AAEO,MAAM,eAAe,CAAC,UAAkB,eAAgD,UAAiC,CAAC,MAAM,yBAAyB,KAAK,EAAE,UAAU,eAAe,OAAO;AAChM,MAAM,kBAAkB,CAAC,UAAkB,eAAgD,UAAiC,CAAC,MAAM,yBAAyB,QAAQ,EAAE,UAAU,eAAe,OAAO;AACtM,MAAM,kBAAkB,CAAC,UAAkB,eAAgD,UAAiC,CAAC,MAAM,yBAAyB,QAAQ,EAAE,UAAU,eAAe,OAAO;AAGtM,SAAS,mBAAmB,SAA0B,UAAU,UAAiC,CAAC,GAAoB;AAC3H,SAAO,yBAAyB,MAAM,EAAE,SAAS,OAAO;AAC1D;AACO,MAAM,mBAAmB,CAAC,eAA+C,UAAiC,CAAC,MAAM,yBAAyB,KAAK,EAAE,SAAS,eAAe,OAAO;AAChL,MAAM,sBAAsB,CAAC,eAA+C,UAAiC,CAAC,MAAM,yBAAyB,QAAQ,EAAE,SAAS,eAAe,OAAO;AACtL,MAAM,sBAAsB,CAAC,eAAgD,UAAiC,CAAC,MAAM,yBAAyB,QAAQ,EAAE,SAAS,eAAe,OAAO;AAEvL,MAAM,gCAAgC,CAAC,WAA8D;AAC1G,QAAM,SAAS,oBAAI,IAA6C;AAChE,QAAM,OAAO,aAAa,gBAA8D,8BAA8B,MAAM;AAC5H,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
4
+ "sourcesContent": ["import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport {SwcQueryOptions, HelperHostSet} from '../types';\nimport {ConvertUtils} from '@dooboostore/core-web';\n\n// ============================================\n// Types & Interfaces\n// ============================================\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n type?: typeof Number | typeof Boolean | typeof String;\n filter?: (target: HTMLElement, value: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n targetAttributeName: string;\n options: AttributeOptions;\n type: 'property' | 'method';\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol.for('simple-web-component:attribute');\n\n// ============================================\n// Utilities\n// ============================================\n\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\nexport {convertValue};\n\nexport const getAttributeValue = (inst: any, attrName: string, options?: AttributeOptions & { selector?: string }): any => {\n const conf = getElementConfig(inst);\n const currentWin = inst._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // If selector is not provided, use inst itself\n const targets = options?.selector ? resolveAttributeTargets(inst, options.selector, options) : [inst];\n\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function' && (primaryTarget as any).hasAttribute(attrName)) {\n let domVal = (primaryTarget as any).getAttribute(attrName);\n\n // \uD45C\uD604\uC2DD \uCCB4\uD06C\n const ae = new ActionExpression(domVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n try {\n const result = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),\n context: inst,\n args: SwcUtils.getHelperAndHostSet(currentWin, inst)\n });\n return convertValue(result, options?.type);\n } catch (err) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, err);\n return convertValue(domVal, options?.type);\n }\n }\n\n return convertValue(domVal, options?.type);\n }\n\n // If no target found, return null\n return null;\n};\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.) and CSS selectors\n * Returns HTMLElement[] for attribute operations\n */\nexport const resolveAttributeTargets = (inst: any, selector: string, options: AttributeOptions): HTMLElement[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === '$this' || !selector) {\n applyRoot(inst);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyAttribute decorator - set/get element attributes\n *\n * Usage:\n * - @applyAttribute('selector', 'attrName') - Set attribute with explicit name\n * - @applyAttribute('selector') - Use property name as attribute name\n * - @applyAttribute('selector', { name: 'attrName' }) - Set attribute via options\n * - Return null to remove attribute\n */\nexport function applyAttribute(selector: string, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: string, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n\n const constructor = target.constructor;\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n\n // Parse arguments\n let finalOptions: AttributeOptions = {};\n let targetAttributeName: string;\n\n if (typeof targetAttributeNameOrOptions === 'string') {\n // applyAttribute('selector', 'attrName', options?)\n targetAttributeName = targetAttributeNameOrOptions;\n finalOptions = options || {};\n } else if (targetAttributeNameOrOptions) {\n // applyAttribute('selector', options)\n finalOptions = targetAttributeNameOrOptions;\n targetAttributeName = finalOptions.name || String(propertyKey);\n } else {\n // applyAttribute('selector')\n targetAttributeName = String(propertyKey);\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector,\n targetAttributeName,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: Apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const targetEls = resolveAttributeTargets(inst, selector, finalOptions);\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: inst, helper: hostSet})) {\n return;\n }\n\n if (resolvedValue === null) {\n // Remove attribute if value is null\n targetEl.removeAttribute(targetAttributeName);\n } else if (resolvedValue !== undefined) {\n // Set attribute\n targetEl.setAttribute(targetAttributeName, resolvedValue === true ? '' : String(resolvedValue));\n }\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to attributes\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n if (res instanceof Promise) {\n return res.then((v: any) => {\n applyValueToTargets(this, v);\n return v;\n });\n } else {\n applyValueToTargets(this, res);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element attributes\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n const mergedOptions = {...finalOptions, selector, type: finalOptions.type || designType};\n return getAttributeValue(this, targetAttributeName, mergedOptions);\n },\n set(this: any, value: any) {\n ensureInit(this);\n\n if (value instanceof Promise) {\n value.then((v: any) => applyValueToTargets(this, v)).catch(() => { /* swallow */\n });\n } else {\n applyValueToTargets(this, value);\n }\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @attribute - Alias for @applyAttribute\n */\nexport function attribute(selector: string, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attribute(selector: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attribute(selector: string, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {\n return applyAttribute(selector, targetAttributeNameOrOptions as any, options);\n}\n\n/**\n * @attributeThis - Apply attribute on $this element\n * Can be used as: @attributeThis or @attributeThis('attrName') or @attributeThis({ name: 'attrName' })\n */\nexport function attributeThis(target: Object, propertyKey: string | symbol): void;\nexport function attributeThis(targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attributeThis(options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function attributeThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @attributeThis\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) &&\n typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') {\n // Called as @attributeThis (target, propertyKey)\n return applyAttribute('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);\n }\n\n // Called with parameters\n if (typeof targetOrOptions === 'string') {\n // @attributeThis('attrName', options?)\n return applyAttribute('$this', targetOrOptions, propertyKeyOrOptions);\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // @attributeThis({ name: 'attrName' })\n return applyAttribute('$this', undefined as any, targetOrOptions);\n } else {\n // @attributeThis() or @attributeThis\n return applyAttribute('$this', undefined as any, {});\n }\n}\n\n/**\n * @setAttribute - Alias for @applyAttribute (method-decorator semantics)\n */\nexport function setAttribute(selector: string, targetAttributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(selector: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(selector: string, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator {\n return applyAttribute(selector, targetAttributeNameOrOptions as any, options) as MethodDecorator;\n}\n\n/**\n * @setAttributeThis - Set attribute on $this element\n * Can be used as: @setAttributeThis or @setAttributeThis('attrName') or @setAttributeThis({ name: 'attrName' })\n */\nexport function setAttributeThis(target: Object, propertyKey: string | symbol): void;\nexport function setAttributeThis(targetAttributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttributeThis(options?: AttributeOptions): MethodDecorator;\nexport function setAttributeThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @setAttributeThis\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) &&\n (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n // Called as @setAttributeThis (target, propertyKey)\n return applyAttribute('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);\n }\n\n // Called with parameters\n if (typeof targetOrOptions === 'string') {\n // @setAttributeThis('attrName', options?)\n return applyAttribute('$this', targetOrOptions, propertyKeyOrOptions) as MethodDecorator;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // @setAttributeThis({ name: 'attrName' })\n return applyAttribute('$this', undefined as any, targetOrOptions) as MethodDecorator;\n } else {\n // @setAttributeThis() or @setAttributeThis\n return applyAttribute('$this', undefined as any, {}) as MethodDecorator;\n }\n}\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeMetadata> => {\n const result = new Map<string | symbol, AttributeMetadata>();\n findAllAttributeMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyAttribute;\n"],
5
+ "mappings": "AAAA,SAAQ,cAAc,eAAe,wBAAuB;AAC5D,SAAQ,YAAY,wBAAuB;AAC3C,SAAQ,gBAAe;AAEvB,SAAQ,oBAAmB;AAoBpB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAMjF,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAIO,MAAM,oBAAoB,CAAC,MAAW,UAAkB,YAA4D;AACzH,QA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oBAAoB;AAAA,EACtE,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,WAAO,eAAe,SAAS,QAAkB,eAAe;AAAA,EAClE,OAAO;AAEL,WAAO,eAAe,SAAS,QAAkB,CAAC,CAAC;AAAA,EACrD;AACF;AAOO,SAAS,aAAa,UAAkB,8BAA0D,SAA6C;AACpJ,SAAO,eAAe,UAAU,8BAAqC,OAAO;AAC9E;AASO,SAAS,iBAAiB,iBAAuB,sBAA4B,YAAsC;AAExH,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,QAAQ,CAAC,MAAM,QAAQ,eAAe,MAClG,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,WAAW;AAExF,WAAO,eAAe,SAAS,QAAkB,CAAC,CAAC,EAAE,iBAAiB,sBAAsB,UAAU;AAAA,EACxG;AAGA,MAAI,OAAO,oBAAoB,UAAU;AAEvC,WAAO,eAAe,SAAS,iBAAiB,oBAAoB;AAAA,EACtE,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,WAAO,eAAe,SAAS,QAAkB,eAAe;AAAA,EAClE,OAAO;AAEL,WAAO,eAAe,SAAS,QAAkB,CAAC,CAAC;AAAA,EACrD;AACF;AAMO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,QAAM,eAAe,kBAAkB,WAAW,SAAS,OAAO;AAClE,SAAO,aAAa,gBAAqC,wBAAwB,YAAY,EAAE,KAAK;AACtG;AAGO,MAAM,gCAAgC,CAAC,WAAyD;AACrG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,2BAAyB,MAAM,EAAE,QAAQ,UAAQ;AAC/C,WAAO,IAAI,KAAK,aAAa,IAAI;AAAA,EACnC,CAAC;AACD,SAAO;AACT;AAGA,IAAO,yBAAQ;",
6
6
  "names": []
7
7
  }
@@ -76,7 +76,6 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
76
76
  const targetRoot = applyRoot(this);
77
77
  return targetRoot ? targetRoot.querySelector(selector) : null;
78
78
  };
79
- console.log("fffffffffff");
80
79
  const targetEl = getTarget();
81
80
  const res = original.apply(this, args);
82
81
  const runApply = (target, val) => {
@@ -104,108 +103,124 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
104
103
  };
105
104
  };
106
105
  }
107
- const findAllApplyNodeMetadata = (target) => {
108
- const result = /* @__PURE__ */ new Map();
109
- const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
110
- maps.forEach((map) => {
111
- if (map instanceof Map) {
112
- map.forEach((v, k) => result.set(k, v));
113
- }
114
- });
115
- return result;
116
- };
117
106
  function applyNodeThis(targetOrOptions, propertyKey, descriptor) {
118
107
  const option = { position: "replaceChildren" };
119
108
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
120
109
  const opt = targetOrOptions || {};
121
110
  return applyNode("$this", { ...option, ...opt });
122
111
  }
123
- function applyNodeThisReplaceChildren(targetOrOptions, propertyKey, descriptor) {
112
+ function replaceChildrenNodeThis(targetOrOptions, propertyKey, descriptor) {
124
113
  const option = { position: "replaceChildren" };
125
114
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
126
115
  const opt = targetOrOptions || {};
127
116
  return applyNode("$this", { ...opt, ...option });
128
117
  }
129
- function applyNodeThisReplaceChildrenLightDom(targetOrOptions, propertyKey, descriptor) {
130
- const options = { position: "replaceChildren", root: "light" };
131
- if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
132
- const opt = targetOrOptions || {};
133
- return applyNode("$this", { ...opt, ...options });
134
- }
135
- function applyNodeThisBeforeEnd(targetOrOptions, propertyKey, descriptor) {
118
+ function beforeEndNodeThis(targetOrOptions, propertyKey, descriptor) {
136
119
  const options = { position: "beforeEnd" };
137
120
  if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
138
121
  const opt = targetOrOptions || {};
139
122
  return applyNode("$this", { ...opt, ...options });
140
123
  }
141
- function applyNodeThisBeforeEndLightDom(targetOrOptions, propertyKey, descriptor) {
124
+ function beforeEndLightNodeThis(targetOrOptions, propertyKey, descriptor) {
142
125
  const option = { position: "beforeEnd", root: "light" };
143
126
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
144
127
  const opt = targetOrOptions || {};
145
128
  return applyNode("$this", { ...opt, ...option });
146
129
  }
147
- function applyNodeThisBeforeEndShadow(targetOrOptions, propertyKey, descriptor) {
130
+ function beforeEndShadowNodeThis(targetOrOptions, propertyKey, descriptor) {
148
131
  const option = { position: "beforeEnd", root: "shadow" };
149
132
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
150
133
  const opt = targetOrOptions || {};
151
134
  return applyNode("$this", { ...opt, ...option });
152
135
  }
153
- function applyNodeThisAfterBegin(targetOrOptions, propertyKey, descriptor) {
136
+ function afterBeginNodeThis(targetOrOptions, propertyKey, descriptor) {
154
137
  const option = { position: "afterBegin" };
155
138
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
156
139
  const opt = targetOrOptions || {};
157
140
  return applyNode("$this", { ...opt, ...option });
158
141
  }
159
- function applyNodeThisAfterBeginLightDom(targetOrOptions, propertyKey, descriptor) {
142
+ function afterBeginLightNodeThis(targetOrOptions, propertyKey, descriptor) {
160
143
  const option = { position: "afterBegin", root: "light" };
161
144
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
162
145
  const opt = targetOrOptions || {};
163
146
  return applyNode("$this", { ...opt, ...option });
164
147
  }
165
- function applyNodeThisInnerHtml(targetOrOptions, propertyKey, descriptor) {
148
+ function innerHtmlNodeThis(targetOrOptions, propertyKey, descriptor) {
166
149
  const option = { position: "innerHtml" };
167
150
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
168
151
  const opt = targetOrOptions || {};
169
152
  return applyNode("$this", { ...opt, ...option });
170
153
  }
171
- function applyThisInnerHtmlNodeLightDom(targetOrOptions, propertyKey, descriptor) {
154
+ function innerTextNodeThis(targetOrOptions, propertyKey, descriptor) {
155
+ const option = { position: "innerText" };
156
+ if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
157
+ const opt = targetOrOptions || {};
158
+ return applyNode("$this", { ...opt, ...option });
159
+ }
160
+ function innerHtmlLightNodeThis(targetOrOptions, propertyKey, descriptor) {
172
161
  const option = { position: "innerHtml", root: "light" };
173
162
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
174
163
  const opt = targetOrOptions || {};
175
164
  return applyNode("$this", { ...opt, ...option });
176
165
  }
177
- function applyThisReplaceChildrenNodeLightDom(targetOrOptions, propertyKey, descriptor) {
166
+ function replaceChildrenLightNodeThis(targetOrOptions, propertyKey, descriptor) {
178
167
  const option = { position: "replaceChildren", root: "light" };
179
168
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
180
169
  const opt = targetOrOptions || {};
181
170
  return applyNode("$this", { ...opt, ...option });
182
171
  }
183
- function applyNodeReplaceChildren(selector, options = {}) {
172
+ function replaceChildrenNode(selector, options = {}) {
184
173
  return applyNode(selector, { ...options, position: "replaceChildren" });
185
174
  }
186
- function applyNodeInnerHtml(selector, options = {}) {
175
+ function innerHtmlNode(selector, options = {}) {
187
176
  return applyNode(selector, { ...options, position: "innerHtml" });
188
177
  }
189
- function applyNodeInnerText(selector, options = {}) {
178
+ function innerHtmlLightNode(selector, options = {}) {
179
+ return applyNode(selector, { ...options, position: "innerHtml", root: "light" });
180
+ }
181
+ function innerHtmlShadowNode(selector, options = {}) {
182
+ return applyNode(selector, { ...options, position: "innerHtml", root: "shadow" });
183
+ }
184
+ function innerTextNode(selector, options = {}) {
190
185
  return applyNode(selector, { ...options, position: "innerText" });
191
186
  }
187
+ function innerTextLightNode(selector, options = {}) {
188
+ return applyNode(selector, { ...options, position: "innerText", root: "light" });
189
+ }
190
+ function innerTextShadowNode(selector, options = {}) {
191
+ return applyNode(selector, { ...options, position: "innerText", root: "shadow" });
192
+ }
193
+ const findAllApplyNodeMetadata = (target) => {
194
+ const result = /* @__PURE__ */ new Map();
195
+ const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
196
+ maps.forEach((map) => {
197
+ if (map instanceof Map) {
198
+ map.forEach((v, k) => result.set(k, v));
199
+ }
200
+ });
201
+ return result;
202
+ };
192
203
  export {
193
204
  APPLY_NODE_METADATA_KEY,
205
+ afterBeginLightNodeThis,
206
+ afterBeginNodeThis,
194
207
  applyNode,
195
- applyNodeInnerHtml,
196
- applyNodeInnerText,
197
- applyNodeReplaceChildren,
198
208
  applyNodeThis,
199
- applyNodeThisAfterBegin,
200
- applyNodeThisAfterBeginLightDom,
201
- applyNodeThisBeforeEnd,
202
- applyNodeThisBeforeEndLightDom,
203
- applyNodeThisBeforeEndShadow,
204
- applyNodeThisInnerHtml,
205
- applyNodeThisReplaceChildren,
206
- applyNodeThisReplaceChildrenLightDom,
207
- applyThisInnerHtmlNodeLightDom,
208
- applyThisReplaceChildrenNodeLightDom,
209
- findAllApplyNodeMetadata
209
+ beforeEndLightNodeThis,
210
+ beforeEndNodeThis,
211
+ beforeEndShadowNodeThis,
212
+ findAllApplyNodeMetadata,
213
+ innerHtmlLightNode,
214
+ innerHtmlLightNodeThis,
215
+ innerHtmlNode,
216
+ innerHtmlNodeThis,
217
+ innerHtmlShadowNode,
218
+ innerTextLightNode,
219
+ innerTextNode,
220
+ innerTextNodeThis,
221
+ innerTextShadowNode,
222
+ replaceChildrenLightNodeThis,
223
+ replaceChildrenNode,
224
+ replaceChildrenNodeThis
210
225
  };
211
226
  //# sourceMappingURL=applyNode.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyNode.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport {SpecialSelector, SwcQueryOptions, HelperHostSet, SwcRootType} from '../types';\nimport { SwcUtils} from \"../utils/Utils\";\nimport {findAllStateMetadata} from \"./state\";\nimport {ElementApply} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n fallback?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\nconst applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string, pos: ApplyNodePosition, win: Window, host?: any) => {\n if (!targetEl) return;\n const doc = win.document;\n const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);\n const id = currentThis._swcId;\n\n\n const nodes: Node[] = [];\n\n if (typeof res === 'string' && pos === 'innerHtml') {\n const t = win.document.createElement('template');\n t.innerHTML = res;\n nodes.push(...Array.from(t.content.childNodes));\n } else if (typeof res === 'string' && pos === 'innerText') {\n nodes.push(win.document.createTextNode(res));\n }\n\n SwcUtils.projectProcessHtml(id, nodes, doc);\n\n\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n // const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'innerHtml') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerText') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') {\n targetEl.append(...nodes)\n }\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n\n const stateContext: any = {...hostSet};\n findAllStateMetadata(currentThis).forEach(it => {\n stateContext[it.name] = currentThis[it.propertyKey]\n })\n new ElementApply(targetEl, {id: id}).apply({target: 'noInitialized', context: stateContext, bind: currentThis});\n return nodes;\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = {position: 'replaceChildren'}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, {propertyKey, selector, options});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n\n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n\n console.log('fffffffffff')\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n // Delegate HTML/node processing to applyToDom which centralizes\n // processing. runApply should not call processHtml itself to avoid\n // duplicate processing.\n const processedVal = val;\n\n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, processedVal, {currentThis: this, helper: hostSet})) {\n applyToDom(this, target, processedVal, pos, currentWin);\n }\n };\n\n\n const fallbackNodes: Node[] = [];\n if (targetEl && options.fallback) {\n const loadingRes = options.fallback.call(this, hostSet);\n // applyToDom expects a Window as the 4th argument\n fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || 'beforeEnd', currentWin));\n }\n\n if (res instanceof Promise) {\n return res.then(finalRes => {\n fallbackNodes.forEach((it: any)=>it.remove());\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\nexport function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...option, ...opt});\n}\n\nexport function applyNodeThisReplaceChildren(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisReplaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisReplaceChildren(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisReplaceChildrenLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisReplaceChildrenLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisReplaceChildrenLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const options: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...options});\n}\n\nexport function applyNodeThisBeforeEnd(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisBeforeEnd(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisBeforeEnd(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const options: ApplyNodeOptions = {position: 'beforeEnd'};\n if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...options});\n}\n\nexport function applyNodeThisBeforeEndLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisBeforeEndLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisBeforeEndLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\nexport function applyNodeThisBeforeEndShadow(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisBeforeEndShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisBeforeEndShadow(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'shadow'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisAfterBegin(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisAfterBegin(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisAfterBegin(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisAfterBeginLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisAfterBeginLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisAfterBeginLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisInnerHtml(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisInnerHtml(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyThisInnerHtmlNodeLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyThisInnerHtmlNodeLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyThisInnerHtmlNodeLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyThisReplaceChildrenNodeLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyThisReplaceChildrenNodeLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyThisReplaceChildrenNodeLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeReplaceChildren(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'replaceChildren'});\n}\n\nexport function applyNodeInnerHtml(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml'});\n}\n\n// export function applyNodeInnerHtmlLightDom(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n// return applyNode(selector, {...options, position: 'innerHtml', root: 'light'});\n// }\n\nexport function applyNodeInnerText(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText'});\n}\n\n// export function applyNodeInnerTextLightDom(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n// return applyNode(selector, {...options, position: 'innerText', root: 'light'});\n// }\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAe;AACxB,SAAQ,4BAA2B;AACnC,SAAQ,oBAAmB;AAgCpB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAUnF,MAAM,aAAa,CAAC,aAAkB,UAAuB,KAAoB,KAAwB,KAAa,SAAe;AACnI,MAAI,CAAC,SAAU;AACf,QAAM,MAAM,IAAI;AAChB,QAAM,UAAU,SAAS,oBAAoB,KAAK,WAAW;AAC7D,QAAM,KAAK,YAAY;AAGvB,QAAM,QAAgB,CAAC;AAEvB,M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G,OAAM,CAAC;AAC/C;AAIO,SAAS,qCAAqC,iBAAuB,aAA+B,YAAsC;AAC/I,QAAM,SAA2B,EAAC,UAAU,mBAAmB,MAAM,QAAO;AAC5E,MAAI,gBAAgB,OAAW,QAAO,UAAU,SAAS,MAAM,EAAE,iBAAiB,aAAa,UAAU;AACzG,QAAM,MAAM,mBAAmB,CAAC;AAChC,SAAO,UAAU,SAAS,EAAC,GAAG,KAAK,GAAG,OAAM,CAAC;AAC/C;AAEO,SAAS,yBAAyB,UAAkB,UAA8C,CAAC,GAAoB;AAC5H,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,kBAAiB,CAAC;AACtE;AAEO,SAAS,mBAAmB,UAAkB,UAA8C,CAAC,GAAoB;AACtH,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,YAAW,CAAC;AAChE;AAMO,SAAS,mBAAmB,UAAkB,UAA8C,CAAC,GAAoB;AACtH,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,YAAW,CAAC;AAChE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport {SpecialSelector, SwcQueryOptions, HelperHostSet, SwcRootType} from '../types';\nimport { SwcUtils} from \"../utils/Utils\";\nimport {findAllStateMetadata} from \"./state\";\nimport {ElementApply} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n fallback?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\nconst applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string, pos: ApplyNodePosition, win: Window, host?: any) => {\n if (!targetEl) return;\n const doc = win.document;\n const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);\n const id = currentThis._swcId;\n\n\n const nodes: Node[] = [];\n\n if (typeof res === 'string' && pos === 'innerHtml') {\n const t = win.document.createElement('template');\n t.innerHTML = res;\n nodes.push(...Array.from(t.content.childNodes));\n } else if (typeof res === 'string' && pos === 'innerText') {\n nodes.push(win.document.createTextNode(res));\n }\n\n SwcUtils.projectProcessHtml(id, nodes, doc);\n\n\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n // const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'innerHtml') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerText') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') {\n targetEl.append(...nodes)\n }\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n\n const stateContext: any = {...hostSet};\n findAllStateMetadata(currentThis).forEach(it => {\n stateContext[it.name] = currentThis[it.propertyKey]\n })\n new ElementApply(targetEl, {id: id}).apply({target: 'noInitialized', context: stateContext, bind: currentThis});\n return nodes;\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = {position: 'replaceChildren'}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, {propertyKey, selector, options});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n\n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n // Delegate HTML/node processing to applyToDom which centralizes\n // processing. runApply should not call processHtml itself to avoid\n // duplicate processing.\n const processedVal = val;\n\n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, processedVal, {currentThis: this, helper: hostSet})) {\n applyToDom(this, target, processedVal, pos, currentWin);\n }\n };\n\n\n const fallbackNodes: Node[] = [];\n if (targetEl && options.fallback) {\n const loadingRes = options.fallback.call(this, hostSet);\n // applyToDom expects a Window as the 4th argument\n fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || 'beforeEnd', currentWin));\n }\n\n if (res instanceof Promise) {\n return res.then(finalRes => {\n fallbackNodes.forEach((it: any)=>it.remove());\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\n };\n };\n}\n\nexport function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...option, ...opt});\n}\n\nexport function replaceChildrenNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function replaceChildrenNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function replaceChildrenNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\n\n\nexport function beforeEndNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function beforeEndNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function beforeEndNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const options: ApplyNodeOptions = {position: 'beforeEnd'};\n if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...options});\n}\n\nexport function beforeEndLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function beforeEndLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function beforeEndLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function beforeEndShadowNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function beforeEndShadowNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function beforeEndShadowNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'shadow'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function afterBeginNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function afterBeginNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function afterBeginNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function afterBeginLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function afterBeginLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function afterBeginLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function innerHtmlNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerHtmlNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function innerHtmlNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function innerTextNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerTextNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function innerTextNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerText'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function innerHtmlLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function innerHtmlLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function replaceChildrenLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function replaceChildrenLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function replaceChildrenLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function replaceChildrenNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'replaceChildren'});\n}\n\nexport function innerHtmlNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml'});\n}\n\nexport function innerHtmlLightNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml', root: 'light'});\n}\n\nexport function innerHtmlShadowNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml', root: 'shadow'});\n}\n\nexport function innerTextNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText'});\n}\n\nexport function innerTextLightNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText', root: 'light'});\n}\n\nexport function innerTextShadowNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText', root: 'shadow'});\n}\n\n\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAe;AACxB,SAAQ,4BAA2B;AACnC,SAAQ,oBAAmB;AAgCpB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAUnF,MAAM,aAAa,CAAC,aAAkB,UAAuB,KAAoB,KAAwB,KAAa,SAAe;AACnI,MAAI,CAAC,SAAU;AACf,QAAM,MAAM,IAAI;AAChB,QAAM,UAAU,SAAS,oBAAoB,KAAK,WAAW;AAC7D,QAAM,KAAK,YAAY;AAGvB,QAAM,QAAgB,CAAC;AAEvB,MAAI,OAAO,QAAQ,YAAY,QAAQ,aAAa;AAClD,UAAM,IAAI,IAAI,SAAS,cAAc,UAAU;AAC/C,MAAE,YAAY;AACd,UAAM,KAAK,GAAG,MAAM,KAAK,EAAE,QAAQ,UAAU,CAAC;AAAA,EAChD,WAAW,OAAO,QAAQ,YAAY,QAAQ,aAAa;AACzD,UAAM,KAAK,IAAI,SAAS,eAAe,GAAG,CAAC;AAAA,EAC7C;AAEA,WAAS,mBAAmB,IAAI,OAAO,GAAG;AAI1C,QAAM,eAAe,oBAAoB,IAAI;AAE7C,MAAI,QAAQ,WAAW;AACrB,QAAI,CAAC,aAAc,UAAS,YAAY,GAAG,KAAK;AAAA,EAClD,WAAW,QAAQ,aAAa;AAC9B,aAAS,gBAAgB,GAAG,KAAK;AAAA,EACnC,W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C,CAAC,GAAoB;AACjH,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,YAAW,CAAC;AAChE;AAEO,SAAS,mBAAmB,UAAkB,UAAuD,CAAC,GAAoB;AAC/H,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,aAAa,MAAM,QAAO,CAAC;AAC/E;AAEO,SAAS,oBAAoB,UAAkB,UAAuD,CAAC,GAAoB;AAChI,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,aAAa,MAAM,SAAQ,CAAC;AAChF;AAIO,MAAM,2BAA2B,CAAC,WAAyD;AAChG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,QAAM,OAAO,aAAa,gBAAyD,yBAAyB,MAAM;AAClH,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,194 @@
1
+ import { ReflectUtils } from "@dooboostore/core";
2
+ import { ensureInit, getElementConfig } from "./elementDefine.js";
3
+ import { SwcUtils } from "../utils/Utils.js";
4
+ const PROPERTY_METADATA_KEY = Symbol.for("simple-web-component:property");
5
+ const resolvePropertyTargets = (inst, selector, options) => {
6
+ const conf = getElementConfig(inst);
7
+ const currentWin = conf.window;
8
+ const r = options.root || "auto";
9
+ const results = [];
10
+ const applyRoot = (target) => {
11
+ if (!target) return;
12
+ if (r === "auto") {
13
+ results.push(target);
14
+ } else {
15
+ if (r === "light" || r === "all") results.push(target);
16
+ if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
17
+ }
18
+ };
19
+ if (selector === "$this" || !selector) {
20
+ applyRoot(inst);
21
+ } else if (selector === "$window") {
22
+ results.push(currentWin);
23
+ } else if (selector === "$document") {
24
+ results.push(currentWin.document);
25
+ } else {
26
+ const hostSet = SwcUtils.getHostSet(inst);
27
+ if (selector === "$host") applyRoot(hostSet.$host);
28
+ else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
29
+ else if (selector === "$appHost") applyRoot(hostSet.$appHost);
30
+ else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
31
+ else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
32
+ else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
33
+ else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
34
+ else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
35
+ else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
36
+ else {
37
+ if (r === "shadow") {
38
+ const found = inst.shadowRoot?.querySelectorAll(selector);
39
+ if (found) results.push(...found);
40
+ } else if (r === "light") {
41
+ const found = inst.querySelectorAll(selector);
42
+ if (found) results.push(...found);
43
+ } else if (r === "all") {
44
+ const sMatch = inst.shadowRoot?.querySelectorAll(selector);
45
+ const lMatch = inst.querySelectorAll(selector);
46
+ if (sMatch) results.push(...sMatch);
47
+ if (lMatch) results.push(...lMatch);
48
+ } else {
49
+ const found = (inst.shadowRoot || inst).querySelectorAll(selector);
50
+ if (found) results.push(...found);
51
+ }
52
+ }
53
+ }
54
+ return results;
55
+ };
56
+ function applyProperty(selector, targetPropertyKeyOrOptions, options) {
57
+ return (target, propertyKey, descriptor) => {
58
+ const constructor = target.constructor;
59
+ const metaType = descriptor && typeof descriptor.value === "function" ? "method" : "property";
60
+ let finalOptions = {};
61
+ let targetPropertyKey;
62
+ if (typeof targetPropertyKeyOrOptions === "string" || typeof targetPropertyKeyOrOptions === "symbol") {
63
+ targetPropertyKey = targetPropertyKeyOrOptions;
64
+ finalOptions = options || {};
65
+ } else if (targetPropertyKeyOrOptions) {
66
+ finalOptions = targetPropertyKeyOrOptions;
67
+ targetPropertyKey = finalOptions.name || propertyKey;
68
+ } else {
69
+ targetPropertyKey = propertyKey;
70
+ }
71
+ let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor);
72
+ if (!metaList) {
73
+ metaList = [];
74
+ ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);
75
+ }
76
+ metaList.push({
77
+ propertyKey,
78
+ selector,
79
+ targetPropertyKey,
80
+ options: finalOptions,
81
+ type: metaType
82
+ });
83
+ const applyValueToTargets = (inst, resolvedValue) => {
84
+ if (resolvedValue === void 0) return resolvedValue;
85
+ const targetEls = resolvePropertyTargets(inst, selector, finalOptions);
86
+ const conf = getElementConfig(inst);
87
+ const currentWin = conf.window;
88
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
89
+ targetEls.forEach((targetEl) => {
90
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {
91
+ return;
92
+ }
93
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
94
+ targetEl[targetPropertyKey] = resolvedRes;
95
+ });
96
+ return resolvedValue;
97
+ };
98
+ if (descriptor && typeof descriptor.value === "function") {
99
+ const original = descriptor.value;
100
+ descriptor.value = function(...args) {
101
+ ensureInit(this);
102
+ const res = original.apply(this, args);
103
+ if (res instanceof Promise) {
104
+ return res.then((v) => {
105
+ applyValueToTargets(this, v);
106
+ return v;
107
+ });
108
+ } else {
109
+ applyValueToTargets(this, res);
110
+ return res;
111
+ }
112
+ };
113
+ return;
114
+ }
115
+ Object.defineProperty(target, propertyKey, {
116
+ configurable: true,
117
+ enumerable: true,
118
+ get() {
119
+ ensureInit(this);
120
+ const targetEls = resolvePropertyTargets(this, selector, finalOptions);
121
+ const conf = getElementConfig(this);
122
+ const currentWin = conf.window;
123
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
124
+ const filtered = targetEls.filter((el) => {
125
+ if (finalOptions.filter && !finalOptions.filter(el, el[targetPropertyKey], { currentThis: this, helper: hostSet })) {
126
+ return false;
127
+ }
128
+ return true;
129
+ });
130
+ const values = filtered.map((el) => el[targetPropertyKey]);
131
+ return values.length === 1 ? values[0] : values;
132
+ },
133
+ set(value) {
134
+ ensureInit(this);
135
+ applyValueToTargets(this, value);
136
+ }
137
+ });
138
+ };
139
+ }
140
+ function property(selector, targetPropertyKeyOrOptions, options) {
141
+ return applyProperty(selector, targetPropertyKeyOrOptions, options);
142
+ }
143
+ function propertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
144
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
145
+ return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
146
+ }
147
+ if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
148
+ return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
149
+ } else if (targetOrOptions && typeof targetOrOptions === "object") {
150
+ return applyProperty("$this", void 0, targetOrOptions);
151
+ } else {
152
+ return applyProperty("$this", void 0, {});
153
+ }
154
+ }
155
+ function setProperty(selector, targetPropertyKeyOrOptions, options) {
156
+ return applyProperty(selector, targetPropertyKeyOrOptions, options);
157
+ }
158
+ function setPropertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
159
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
160
+ return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
161
+ }
162
+ if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
163
+ return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
164
+ } else if (targetOrOptions && typeof targetOrOptions === "object") {
165
+ return applyProperty("$this", void 0, targetOrOptions);
166
+ } else {
167
+ return applyProperty("$this", void 0, {});
168
+ }
169
+ }
170
+ const findAllPropertyMetadata = (target) => {
171
+ const actualTarget = target instanceof Function ? target : target.constructor;
172
+ return ReflectUtils.findAllMetadata(PROPERTY_METADATA_KEY, actualTarget).flat();
173
+ };
174
+ const findAllPropertyApplyMetadata = (target) => {
175
+ const result = /* @__PURE__ */ new Map();
176
+ findAllPropertyMetadata(target).forEach((meta) => {
177
+ result.set(meta.propertyKey, meta);
178
+ });
179
+ return result;
180
+ };
181
+ var applyProperty_default = applyProperty;
182
+ export {
183
+ PROPERTY_METADATA_KEY,
184
+ applyProperty,
185
+ applyProperty_default as default,
186
+ findAllPropertyApplyMetadata,
187
+ findAllPropertyMetadata,
188
+ property,
189
+ propertyThis,
190
+ resolvePropertyTargets,
191
+ setProperty,
192
+ setPropertyThis
193
+ };
194
+ //# sourceMappingURL=applyProperty.js.map