@dooboostore/simple-web-component 1.0.19 → 1.0.21

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 (146) hide show
  1. package/README.md +2028 -146
  2. package/dist/cjs/decorators/addEventListener.js +4 -4
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/appendChild.js +4 -4
  5. package/dist/cjs/decorators/appendChild.js.map +2 -2
  6. package/dist/cjs/decorators/attribute.js +141 -0
  7. package/dist/cjs/decorators/attribute.js.map +7 -0
  8. package/dist/cjs/decorators/changedAttribute.js +5 -5
  9. package/dist/cjs/decorators/changedAttribute.js.map +2 -2
  10. package/dist/cjs/decorators/classList.js +4 -4
  11. package/dist/cjs/decorators/classList.js.map +2 -2
  12. package/dist/cjs/decorators/elementDefine.js +36 -9
  13. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  14. package/dist/cjs/decorators/emitCustomEvent.js +4 -4
  15. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  16. package/dist/cjs/decorators/index.js +1 -0
  17. package/dist/cjs/decorators/index.js.map +2 -2
  18. package/dist/cjs/decorators/lifecycles.js +4 -4
  19. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  20. package/dist/cjs/decorators/onConnectedInnerHtml.js +4 -4
  21. package/dist/cjs/decorators/onConnectedInnerHtml.js.map +2 -2
  22. package/dist/cjs/decorators/query.js +4 -4
  23. package/dist/cjs/decorators/query.js.map +2 -2
  24. package/dist/cjs/decorators/queryAll.js +4 -4
  25. package/dist/cjs/decorators/queryAll.js.map +2 -2
  26. package/dist/cjs/decorators/replaceChildren.js +5 -5
  27. package/dist/cjs/decorators/replaceChildren.js.map +2 -2
  28. package/dist/cjs/decorators/setAttribute.js +46 -20
  29. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  30. package/dist/cjs/decorators/style.js +4 -4
  31. package/dist/cjs/decorators/style.js.map +2 -2
  32. package/dist/cjs/elements/SwcAppEngine.js +8 -8
  33. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  34. package/dist/cjs/elements/SwcAppMixin.js +28 -1
  35. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  36. package/dist/cjs/elements/SwcAsync.js +4 -4
  37. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  38. package/dist/cjs/elements/SwcChoose.js +4 -4
  39. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  40. package/dist/cjs/elements/SwcIf.js +4 -4
  41. package/dist/cjs/elements/SwcIf.js.map +2 -2
  42. package/dist/cjs/elements/SwcLoop.js +4 -4
  43. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  44. package/dist/cjs/elements/register.js +13 -13
  45. package/dist/cjs/elements/register.js.map +2 -2
  46. package/dist/cjs/index.js +1 -0
  47. package/dist/cjs/index.js.map +2 -2
  48. package/dist/cjs/router/ElementRouter.js +7 -7
  49. package/dist/cjs/router/ElementRouter.js.map +2 -2
  50. package/dist/cjs/types.js.map +1 -1
  51. package/dist/esm/decorators/addEventListener.js +1 -1
  52. package/dist/esm/decorators/addEventListener.js.map +1 -1
  53. package/dist/esm/decorators/appendChild.js +1 -1
  54. package/dist/esm/decorators/appendChild.js.map +1 -1
  55. package/dist/esm/decorators/attribute.js +122 -0
  56. package/dist/esm/decorators/attribute.js.map +7 -0
  57. package/dist/esm/decorators/changedAttribute.js +1 -1
  58. package/dist/esm/decorators/changedAttribute.js.map +1 -1
  59. package/dist/esm/decorators/classList.js +1 -1
  60. package/dist/esm/decorators/classList.js.map +1 -1
  61. package/dist/esm/decorators/elementDefine.js +31 -4
  62. package/dist/esm/decorators/elementDefine.js.map +2 -2
  63. package/dist/esm/decorators/emitCustomEvent.js +1 -1
  64. package/dist/esm/decorators/emitCustomEvent.js.map +1 -1
  65. package/dist/esm/decorators/index.js +1 -0
  66. package/dist/esm/decorators/index.js.map +2 -2
  67. package/dist/esm/decorators/lifecycles.js +1 -1
  68. package/dist/esm/decorators/lifecycles.js.map +1 -1
  69. package/dist/esm/decorators/onConnectedInnerHtml.js +1 -1
  70. package/dist/esm/decorators/onConnectedInnerHtml.js.map +1 -1
  71. package/dist/esm/decorators/query.js +1 -1
  72. package/dist/esm/decorators/query.js.map +1 -1
  73. package/dist/esm/decorators/queryAll.js +1 -1
  74. package/dist/esm/decorators/queryAll.js.map +1 -1
  75. package/dist/esm/decorators/replaceChildren.js +1 -1
  76. package/dist/esm/decorators/replaceChildren.js.map +1 -1
  77. package/dist/esm/decorators/setAttribute.js +42 -16
  78. package/dist/esm/decorators/setAttribute.js.map +2 -2
  79. package/dist/esm/decorators/style.js +1 -1
  80. package/dist/esm/decorators/style.js.map +1 -1
  81. package/dist/esm/elements/SwcAppEngine.js +4 -4
  82. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  83. package/dist/esm/elements/SwcAppMixin.js +28 -1
  84. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  85. package/dist/esm/elements/SwcAsync.js +1 -1
  86. package/dist/esm/elements/SwcAsync.js.map +1 -1
  87. package/dist/esm/elements/SwcChoose.js +1 -1
  88. package/dist/esm/elements/SwcChoose.js.map +1 -1
  89. package/dist/esm/elements/SwcIf.js +1 -1
  90. package/dist/esm/elements/SwcIf.js.map +1 -1
  91. package/dist/esm/elements/SwcLoop.js +1 -1
  92. package/dist/esm/elements/SwcLoop.js.map +1 -1
  93. package/dist/esm/elements/register.js +1 -1
  94. package/dist/esm/elements/register.js.map +1 -1
  95. package/dist/esm/index.js +1 -0
  96. package/dist/esm/index.js.map +2 -2
  97. package/dist/esm/router/ElementRouter.js +2 -2
  98. package/dist/esm/router/ElementRouter.js.map +1 -1
  99. package/dist/esm/types.js.map +1 -1
  100. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +5910 -3839
  101. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  102. package/dist/types/decorators/attribute.d.ts +23 -0
  103. package/dist/types/decorators/attribute.d.ts.map +1 -0
  104. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  105. package/dist/types/decorators/index.d.ts +1 -0
  106. package/dist/types/decorators/index.d.ts.map +1 -1
  107. package/dist/types/decorators/setAttribute.d.ts +3 -0
  108. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  109. package/dist/types/elements/SwcAppEngine.d.ts +5 -4
  110. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  111. package/dist/types/elements/SwcAppMixin.d.ts +1 -1
  112. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  113. package/dist/types/index.d.ts +1 -0
  114. package/dist/types/index.d.ts.map +1 -1
  115. package/dist/types/router/ElementRouter.d.ts +1 -1
  116. package/dist/types/router/ElementRouter.d.ts.map +1 -1
  117. package/dist/types/types.d.ts +2 -1
  118. package/dist/types/types.d.ts.map +1 -1
  119. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +5910 -3839
  120. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  121. package/package.json +10 -5
  122. package/src/decorators/addEventListener.ts +1 -1
  123. package/src/decorators/appendChild.ts +1 -1
  124. package/src/decorators/attribute.ts +158 -0
  125. package/src/decorators/changedAttribute.ts +1 -1
  126. package/src/decorators/classList.ts +1 -1
  127. package/src/decorators/elementDefine.ts +38 -5
  128. package/src/decorators/emitCustomEvent.ts +1 -1
  129. package/src/decorators/index.ts +1 -0
  130. package/src/decorators/lifecycles.ts +1 -1
  131. package/src/decorators/onConnectedInnerHtml.ts +1 -1
  132. package/src/decorators/query.ts +1 -1
  133. package/src/decorators/queryAll.ts +1 -1
  134. package/src/decorators/replaceChildren.ts +1 -1
  135. package/src/decorators/setAttribute.ts +49 -17
  136. package/src/decorators/style.ts +1 -1
  137. package/src/elements/SwcAppEngine.ts +9 -8
  138. package/src/elements/SwcAppMixin.ts +32 -1
  139. package/src/elements/SwcAsync.ts +1 -1
  140. package/src/elements/SwcChoose.ts +1 -1
  141. package/src/elements/SwcIf.ts +1 -1
  142. package/src/elements/SwcLoop.ts +1 -1
  143. package/src/elements/register.ts +1 -1
  144. package/src/index.ts +3 -2
  145. package/src/router/ElementRouter.ts +2 -2
  146. package/src/types.ts +2 -1
@@ -22,21 +22,21 @@ __export(addEventListener_exports, {
22
22
  getAddEventListenerMetadata: () => getAddEventListenerMetadata
23
23
  });
24
24
  module.exports = __toCommonJS(addEventListener_exports);
25
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
25
+ var import_core = require("@dooboostore/core");
26
26
  const ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:add-event-listener");
27
27
  function addEventListener(selectorOrTarget, type, options = {}) {
28
28
  return (targetObj, propertyKey, descriptor) => {
29
29
  const constructor = targetObj.constructor;
30
- let listeners = import_ReflectUtils.ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
30
+ let listeners = import_core.ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
31
31
  if (!listeners) {
32
32
  listeners = [];
33
- import_ReflectUtils.ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);
33
+ import_core.ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);
34
34
  }
35
35
  listeners.push({ propertyKey, selector: selectorOrTarget, type, options });
36
36
  };
37
37
  }
38
38
  const getAddEventListenerMetadata = (target) => {
39
39
  const constructor = target instanceof Function ? target : target.constructor;
40
- return import_ReflectUtils.ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
40
+ return import_core.ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
41
41
  };
42
42
  //# sourceMappingURL=addEventListener.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/addEventListener.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAqBtB,MAAM,kCAAkC,OAAO,yCAAyC;AAOxF,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,iCAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,uCAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,kBAAkB,MAAM,QAAQ,CAAC;AAAA,EAC3E;AACF;AAEO,MAAM,8BAA8B,CAAC,WAAwD;AAClG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,iCAAa,YAAY,iCAAiC,WAAW;AAC9E;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAqBtB,MAAM,kCAAkC,OAAO,yCAAyC;AAOxF,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,yBAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,+BAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,kBAAkB,MAAM,QAAQ,CAAC;AAAA,EAC3E;AACF;AAEO,MAAM,8BAA8B,CAAC,WAAwD;AAClG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,iCAAiC,WAAW;AAC9E;",
6
6
  "names": []
7
7
  }
@@ -22,7 +22,7 @@ __export(appendChild_exports, {
22
22
  findAllAppendChildMetadata: () => findAllAppendChildMetadata
23
23
  });
24
24
  module.exports = __toCommonJS(appendChild_exports);
25
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
25
+ var import_core = require("@dooboostore/core");
26
26
  var import_elementDefine = require("./elementDefine");
27
27
  const APPEND_CHILD_METADATA_KEY = Symbol("simple-web-component:append-child");
28
28
  const normalizeNodes = (res, doc) => {
@@ -36,10 +36,10 @@ const normalizeNodes = (res, doc) => {
36
36
  function appendChild(selector, options = { position: "beforeEnd" }) {
37
37
  return (target, propertyKey, descriptor) => {
38
38
  const constructor = target.constructor;
39
- let metaList = import_ReflectUtils.ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor);
39
+ let metaList = import_core.ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor);
40
40
  if (!metaList) {
41
41
  metaList = /* @__PURE__ */ new Map();
42
- import_ReflectUtils.ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
42
+ import_core.ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
43
43
  }
44
44
  metaList.set(propertyKey, { propertyKey, selector, options });
45
45
  const original = descriptor.value;
@@ -81,7 +81,7 @@ function appendChild(selector, options = { position: "beforeEnd" }) {
81
81
  }
82
82
  const findAllAppendChildMetadata = (target) => {
83
83
  const result = /* @__PURE__ */ new Map();
84
- const maps = import_ReflectUtils.ReflectUtils.findAllMetadata(APPEND_CHILD_METADATA_KEY, target);
84
+ const maps = import_core.ReflectUtils.findAllMetadata(APPEND_CHILD_METADATA_KEY, target);
85
85
  maps.forEach((map) => {
86
86
  if (map instanceof Map) {
87
87
  map.forEach((v, k) => result.set(k, v));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/appendChild.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\n\nconst 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\n/**\n * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\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\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.for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AO,QAAQ,UAAU;AAC3B,qBAAS,mBAAmB,KAAuB,GAAG;UACxD,WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,iCAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\n\nconst 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\n/**\n * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\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\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_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": ";;;;;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WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,yBAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,141 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var attribute_exports = {};
19
+ __export(attribute_exports, {
20
+ ATTRIBUTE_METADATA_KEY: () => ATTRIBUTE_METADATA_KEY,
21
+ attribute: () => attribute,
22
+ findAllAttributeMetadata: () => findAllAttributeMetadata,
23
+ resolveTargetEls: () => resolveTargetEls
24
+ });
25
+ module.exports = __toCommonJS(attribute_exports);
26
+ var import_core = require("@dooboostore/core");
27
+ var import_elementDefine = require("./elementDefine");
28
+ var import_Utils = require("../utils/Utils");
29
+ const ATTRIBUTE_METADATA_KEY = Symbol("simple-web-component:attribute");
30
+ const convertValue = (val, type) => {
31
+ if (val === null || val === void 0) return val;
32
+ if (type === Number) return Number(val);
33
+ if (type === Boolean) return val === "false" || val === "0" ? false : true;
34
+ return val;
35
+ };
36
+ const resolveTargetEls = (inst, selector, options, currentWin) => {
37
+ const r = options.root || "auto";
38
+ const results = [];
39
+ const applyRoot = (target) => {
40
+ if (!target) return;
41
+ if (r === "auto") {
42
+ results.push(target);
43
+ } else {
44
+ if (r === "light" || r === "all") results.push(target);
45
+ if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
46
+ }
47
+ };
48
+ if (selector === ":host" || !selector) {
49
+ applyRoot(inst);
50
+ } else if (selector === ":window") {
51
+ results.push(currentWin);
52
+ } else if (selector === ":document") {
53
+ results.push(currentWin.document);
54
+ } else {
55
+ const hostSet = import_Utils.SwcUtils.getHostSet(inst);
56
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
57
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
58
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
59
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
60
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
61
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
62
+ else {
63
+ if (r === "shadow") {
64
+ const found = inst.shadowRoot?.querySelectorAll(selector);
65
+ if (found) results.push(...found);
66
+ } else if (r === "light") {
67
+ const found = inst.querySelectorAll(selector);
68
+ if (found) results.push(...found);
69
+ } else if (r === "all") {
70
+ const sMatch = inst.shadowRoot?.querySelectorAll(selector);
71
+ const lMatch = inst.querySelectorAll(selector);
72
+ if (sMatch) results.push(...sMatch);
73
+ if (lMatch) results.push(...lMatch);
74
+ } else {
75
+ const found = (inst.shadowRoot || inst).querySelectorAll(selector);
76
+ if (found) results.push(...found);
77
+ }
78
+ }
79
+ }
80
+ return results;
81
+ };
82
+ function attribute(selector, options = {}) {
83
+ return (target, propertyKey) => {
84
+ const constructor = target.constructor;
85
+ const privateKey = Symbol(String(propertyKey));
86
+ const designType = Reflect.getMetadata("design:type", target, propertyKey);
87
+ let metaList = import_core.ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor);
88
+ if (!metaList) {
89
+ metaList = [];
90
+ import_core.ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);
91
+ }
92
+ metaList.push({ propertyKey, selector, options, privateKey });
93
+ Object.defineProperty(target, propertyKey, {
94
+ get() {
95
+ const attrName = options.name || String(propertyKey);
96
+ const conf = (0, import_elementDefine.getElementConfig)(this);
97
+ const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
98
+ const targetType = options.type || designType;
99
+ console.log("type-->", propertyKey, targetType);
100
+ if (this.__swc_syncing_init || options.connectedInitialize && !this.__swc_connected) {
101
+ return convertValue(this[privateKey], targetType);
102
+ }
103
+ const targets = resolveTargetEls(this, selector, options, currentWin);
104
+ const primaryTarget = targets[0];
105
+ if (primaryTarget && typeof primaryTarget.hasAttribute === "function") {
106
+ if (primaryTarget.hasAttribute(attrName)) {
107
+ const domVal = primaryTarget.getAttribute(attrName);
108
+ return convertValue(domVal, targetType);
109
+ }
110
+ return null;
111
+ }
112
+ return convertValue(this[privateKey], targetType);
113
+ },
114
+ set(nv) {
115
+ const targetType = options.type || designType;
116
+ const attrName = options.name || String(propertyKey);
117
+ const conf = (0, import_elementDefine.getElementConfig)(this);
118
+ const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
119
+ const targets = resolveTargetEls(this, selector, options, currentWin);
120
+ targets.forEach((it) => {
121
+ console.log("----->", it);
122
+ if (it && typeof it.setAttribute === "function") {
123
+ if (nv === null) {
124
+ it.removeAttribute(attrName);
125
+ } else {
126
+ it.setAttribute(attrName, String(nv));
127
+ }
128
+ } else {
129
+ this[privateKey] = nv;
130
+ }
131
+ });
132
+ },
133
+ enumerable: true,
134
+ configurable: true
135
+ });
136
+ };
137
+ }
138
+ const findAllAttributeMetadata = (target) => {
139
+ return import_core.ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
140
+ };
141
+ //# sourceMappingURL=attribute.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/attribute.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeOptions;\n privateKey: symbol; // Added to bypass getter during initialization\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:attribute');\n\n/**\n * Helper to perform type conversion from string to target type\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\n/**\n * Helper to resolve target elements based on selector and root options\n */\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeOptions, currentWin: any): HTMLElement[] => {\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 // Attributes belong to the ELEMENT, not the ShadowRoot.\n // So for :host and direct attribute sync, we mostly want the element itself.\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 === ':host' || !selector) {\n applyRoot(inst);\n } else if (selector === ':window') {\n results.push(currentWin);\n } else if (selector === ':document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n 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 {\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 * @attribute decorator to sync a field value with an element's attribute.\n */\nexport function attribute(selector: string, options: AttributeOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const privateKey = Symbol(String(propertyKey));\n\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n\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({ propertyKey, selector, options, privateKey });\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targetType = options.type || designType;\n\n console.log('type-->', propertyKey, targetType);\n // During early init phase, if syncing memory to DOM, return memory.\n if (this.__swc_syncing_init || (options.connectedInitialize && !this.__swc_connected)) {\n return convertValue(this[privateKey], targetType);\n }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function') {\n if ((primaryTarget as any).hasAttribute(attrName)) {\n const domVal = (primaryTarget as any).getAttribute(attrName);\n return convertValue(domVal, targetType);\n }\n return null;\n }\n\n return convertValue(this[privateKey], targetType);\n },\n set(this: any, nv: any) {\n const targetType = options.type || designType;\n // const convertedValue = convertValue(nv, targetType);\n // console.log('---set', propertyKey, targetType, nv, convertedValue);\n\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targets = resolveTargetEls(this, selector, options, currentWin);\n targets.forEach(it => {\n console.log('----->', it)\n if (it && typeof (it as any).setAttribute === 'function') {\n if (nv === null) {\n (it as any).removeAttribute(attrName);\n } else {\n (it as any).setAttribute(attrName, String(nv));\n }\n } else {\n this[privateKey] = nv;\n }\n })\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, target).flat();\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA6C;AAC7C,mBAAyB;AAgBlB,MAAM,yBAAyB,OAAO,gCAAgC;AAK7E,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAA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,cAAM,gBAAgB,QAAQ,CAAC;AAE/B,YAAI,iBAAiB,OAAQ,cAAsB,iBAAiB,YAAY;AAC9E,cAAK,cAAsB,aAAa,QAAQ,GAAG;AACjD,kBAAM,SAAU,cAAsB,aAAa,QAAQ;AAC3D,mBAAO,aAAa,QAAQ,UAAU;AAAA,UACxC;AACA,iBAAO;AAAA,QACT;AAEA,eAAO,aAAa,KAAK,UAAU,GAAG,UAAU;AAAA,MAClD;AAAA,MACA,IAAe,IAAS;AACtB,cAAM,aAAa,QAAQ,QAAQ;AAInC,cAAM,WAAW,QAAQ,QAAQ,OAAO,WAAW;AACnD,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAa,KAAK,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AAC7F,cAAM,UAAU,iBAAiB,MAAM,UAAU,SAAS,UAAU;AACpE,gBAAQ,QAAQ,QAAM;AACpB,kBAAQ,IAAI,UAAU,EAAE;AACxB,cAAI,MAAM,OAAQ,GAAW,iBAAiB,YAAY;AACxD,gBAAI,OAAO,MAAM;AACf,cAAC,GAAW,gBAAgB,QAAQ;AAAA,YACtC,OAAO;AACL,cAAC,GAAW,aAAa,UAAU,OAAO,EAAE,CAAC;AAAA,YAC/C;AAAA,UACF,OAAO;AACL,iBAAK,UAAU,IAAI;AAAA,UACrB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,SAAO,yBAAa,gBAAqC,wBAAwB,MAAM,EAAE,KAAK;AAChG;",
6
+ "names": []
7
+ }
@@ -23,15 +23,15 @@ __export(changedAttribute_exports, {
23
23
  getChangedAttributeMetadata: () => getChangedAttributeMetadata
24
24
  });
25
25
  module.exports = __toCommonJS(changedAttribute_exports);
26
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
26
+ var import_core = require("@dooboostore/core");
27
27
  const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol("simple-web-component:on-attribute-changed");
28
28
  function changedAttribute(attributeName) {
29
29
  return (target, propertyKey) => {
30
30
  const constructor = target.constructor;
31
- let meta = import_ReflectUtils.ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
31
+ let meta = import_core.ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
32
32
  if (!meta) {
33
33
  meta = /* @__PURE__ */ new Map();
34
- import_ReflectUtils.ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
34
+ import_core.ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
35
35
  }
36
36
  const name = attributeName || String(propertyKey);
37
37
  let methods = meta.get(name);
@@ -44,9 +44,9 @@ function changedAttribute(attributeName) {
44
44
  }
45
45
  const getChangedAttributeMetadata = (target) => {
46
46
  const constructor = target instanceof Function ? target : target.constructor;
47
- return import_ReflectUtils.ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
47
+ return import_core.ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
48
48
  };
49
49
  const findAllAttributeChangedMetadata = (target) => {
50
- return import_ReflectUtils.ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
50
+ return import_core.ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
51
51
  };
52
52
  //# sourceMappingURL=changedAttribute.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/changedAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,iCAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,uCAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,iCAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,iCAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,+BAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,yBAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
6
6
  "names": []
7
7
  }
@@ -26,7 +26,7 @@ __export(classList_exports, {
26
26
  updateClassList: () => updateClassList
27
27
  });
28
28
  module.exports = __toCommonJS(classList_exports);
29
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
29
+ var import_core = require("@dooboostore/core");
30
30
  var import_elementDefine = require("./elementDefine");
31
31
  var import_Utils = require("../utils/Utils");
32
32
  const CLASS_LIST_METADATA_KEY = Symbol("simple-web-component:class-list");
@@ -34,10 +34,10 @@ function createClassListDecorator(action) {
34
34
  return (selector) => {
35
35
  return (target, propertyKey, descriptor) => {
36
36
  const constructor = target.constructor;
37
- let metaList = import_ReflectUtils.ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor);
37
+ let metaList = import_core.ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor);
38
38
  if (!metaList) {
39
39
  metaList = /* @__PURE__ */ new Map();
40
- import_ReflectUtils.ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);
40
+ import_core.ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);
41
41
  }
42
42
  metaList.set(propertyKey, { propertyKey, selector, action });
43
43
  const original = descriptor.value;
@@ -93,7 +93,7 @@ const removeClassList = createClassListDecorator("remove");
93
93
  const toggleClassList = createClassListDecorator("toggle");
94
94
  const findAllClassListMetadata = (target) => {
95
95
  const result = /* @__PURE__ */ new Map();
96
- const maps = import_ReflectUtils.ReflectUtils.findAllMetadata(CLASS_LIST_METADATA_KEY, target);
96
+ const maps = import_core.ReflectUtils.findAllMetadata(CLASS_LIST_METADATA_KEY, target);
97
97
  maps.forEach((map) => {
98
98
  if (map instanceof Map) {
99
99
  map.forEach((v, k) => result.set(k, v));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/classList.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport const CLASS_LIST_METADATA_KEY = Symbol('simple-web-component:class-list');\n\nexport type ClassListAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';\n\nexport interface ClassListMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: ClassListAction;\n}\n\nfunction createClassListDecorator(action: ClassListAction) {\n return (selector: string): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor) as Map<string | symbol, ClassListMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ClassListMetadata>();\n ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const hostSet = SwcUtils.getHostSet(this as any);\n\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) targetEl = this as any;\n else if (selector === ':parentHost') targetEl = hostSet.$parentHost;\n else if (selector === ':appHost') targetEl = hostSet.$appHost;\n else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n\n if (targetEl) {\n if (action === 'set') {\n let classes = '';\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n classes = Object.entries(res)\n .filter(([_, force]) => !!force)\n .map(([cls]) => cls)\n .join(' ');\n } else {\n classes = Array.isArray(res) ? res.join(' ') : String(res);\n }\n targetEl.className = classes;\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n Object.entries(res).forEach(([cls, force]) => {\n targetEl!.classList.toggle(cls, !!force);\n });\n } else if (res !== undefined && res !== null) {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n }\n } else if (action === 'add') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n } else if (action === 'remove') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.remove(...classes);\n } else if (action === 'toggle') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n classes.forEach(c => targetEl!.classList.toggle(c));\n }\n }\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setClassList decorator to surgically replace all classes on a target element.\n * Returns: string | string[]\n */\nexport const setClassList = createClassListDecorator('set');\n\n/**\n * @updateClassList decorator to surgically update specific classes.\n * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)\n */\nexport const updateClassList = createClassListDecorator('update');\n\n/**\n * @addClassList decorator to surgically add classes to a target element.\n * Returns: string | string[]\n */\nexport const addClassList = createClassListDecorator('add');\n\n/**\n * @removeClassList decorator to surgically remove classes from a target element.\n * Returns: string | string[]\n */\nexport const removeClassList = createClassListDecorator('remove');\n\n/**\n * @toggleClassList decorator to surgically toggle classes on a target element.\n * Returns: string | string[]\n */\nexport const toggleClassList = createClassListDecorator('toggle');\n\nexport const findAllClassListMetadata = (target: any): Map<string | symbol, ClassListMetadata> => {\n const result = new Map<string | symbol, ClassListMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassListMetadata>>(CLASS_LIST_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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAElB,MAAM,0BAA0B,OAAO,iCAAiC;AAU/E,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,aAAsC;AAC5C,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,iCAAa,eAAe,yBAAyB,WAAW;AAC/E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAwC;AACvD,yCAAa,eAAe,yBAAyB,UAAU,WAAW;AAAA,MAC5E;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,OAAO,CAAC;AAE3D,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,6CAAW,IAAI;AACf,cAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,YAAI,QAAQ,QAAW;AACrB,gBAAM,UAAU,sBAAS,WAAW,IAAW;AAE/C,cAAI,WAA+B;AACnC,cAAI,aAAa,WAAW,CAAC,SAAU,YAAW;AAAA,mBACzC,aAAa,cAAe,YAAW,QAAQ;AAAA,mBAC/C,aAAa,WAAY,YAAW,QAAQ;AAAA,cAChD,aAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAEzE,cAAI,UAAU;AACZ,gBAAI,WAAW,OAAO;AACpB,kBAAI,UAAU;AACd,kBAAI,OAAO,QAAQ,YA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,SAAU,UAAU,OAAO,CAAC,CAAC;AAAA,YACpD;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAMO,MAAM,eAAe,yBAAyB,KAAK;AAMnD,MAAM,kBAAkB,yBAAyB,QAAQ;AAMzD,MAAM,eAAe,yBAAyB,KAAK;AAMnD,MAAM,kBAAkB,yBAAyB,QAAQ;AAMzD,MAAM,kBAAkB,yBAAyB,QAAQ;AAEzD,MAAM,2BAA2B,CAAC,WAAyD;AAChG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,QAAM,OAAO,iCAAa,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;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport const CLASS_LIST_METADATA_KEY = Symbol('simple-web-component:class-list');\n\nexport type ClassListAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';\n\nexport interface ClassListMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: ClassListAction;\n}\n\nfunction createClassListDecorator(action: ClassListAction) {\n return (selector: string): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor) as Map<string | symbol, ClassListMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ClassListMetadata>();\n ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const hostSet = SwcUtils.getHostSet(this as any);\n\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) targetEl = this as any;\n else if (selector === ':parentHost') targetEl = hostSet.$parentHost;\n else if (selector === ':appHost') targetEl = hostSet.$appHost;\n else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n\n if (targetEl) {\n if (action === 'set') {\n let classes = '';\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n classes = Object.entries(res)\n .filter(([_, force]) => !!force)\n .map(([cls]) => cls)\n .join(' ');\n } else {\n classes = Array.isArray(res) ? res.join(' ') : String(res);\n }\n targetEl.className = classes;\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n Object.entries(res).forEach(([cls, force]) => {\n targetEl!.classList.toggle(cls, !!force);\n });\n } else if (res !== undefined && res !== null) {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n }\n } else if (action === 'add') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n } else if (action === 'remove') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.remove(...classes);\n } else if (action === 'toggle') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n classes.forEach(c => targetEl!.classList.toggle(c));\n }\n }\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setClassList decorator to surgically replace all classes on a target element.\n * Returns: string | string[]\n */\nexport const setClassList = createClassListDecorator('set');\n\n/**\n * @updateClassList decorator to surgically update specific classes.\n * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)\n */\nexport const updateClassList = createClassListDecorator('update');\n\n/**\n * @addClassList decorator to surgically add classes to a target element.\n * Returns: string | string[]\n */\nexport const addClassList = createClassListDecorator('add');\n\n/**\n * @removeClassList decorator to surgically remove classes from a target element.\n * Returns: string | string[]\n */\nexport const removeClassList = createClassListDecorator('remove');\n\n/**\n * @toggleClassList decorator to surgically toggle classes on a target element.\n * Returns: string | string[]\n */\nexport const toggleClassList = createClassListDecorator('toggle');\n\nexport const findAllClassListMetadata = (target: any): Map<string | symbol, ClassListMetadata> => {\n const result = new Map<string | symbol, ClassListMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassListMetadata>>(CLASS_LIST_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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAElB,MAAM,0BAA0B,OAAO,iCAAiC;AAU/E,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,aAAsC;AAC5C,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,yBAAa,eAAe,yBAAyB,WAAW;AAC/E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAwC;AACvD,iCAAa,eAAe,yBAAyB,UAAU,WAAW;AAAA,MAC5E;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,OAAO,CAAC;AAE3D,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,6CAAW,IAAI;AACf,cAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,YAAI,QAAQ,QAAW;AACrB,gBAAM,UAAU,sBAAS,WAAW,IAAW;AAE/C,cAAI,WAA+B;AACnC,cAAI,aAAa,WAAW,CAAC,SAAU,YAAW;AAAA,mBACzC,aAAa,cAAe,YAAW,QAAQ;AAAA,mBAC/C,aAAa,WAAY,YAAW,QAAQ;AAAA,cAChD,aAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAEzE,cAAI,UAAU;AACZ,gBAAI,WAAW,OAAO;AACpB,kBAAI,UAAU;AAC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ACnE,sBAAQ,QAAQ,OAAK,SAAU,UAAU,OAAO,CAAC,CAAC;AAAA,YACpD;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAMO,MAAM,eAAe,yBAAyB,KAAK;AAMnD,MAAM,kBAAkB,yBAAyB,QAAQ;AAMzD,MAAM,eAAe,yBAAyB,KAAK;AAMnD,MAAM,kBAAkB,yBAAyB,QAAQ;AAMzD,MAAM,kBAAkB,yBAAyB,QAAQ;AAEzD,MAAM,2BAA2B,CAAC,WAAyD;AAChG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,QAAM,OAAO,yBAAa,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
  }
@@ -23,14 +23,15 @@ __export(elementDefine_exports, {
23
23
  getElementConfig: () => getElementConfig
24
24
  });
25
25
  module.exports = __toCommonJS(elementDefine_exports);
26
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
27
- var import_FunctionUtils = require("@dooboostore/core/function/FunctionUtils");
26
+ var import_core = require("@dooboostore/core");
27
+ var import_core2 = require("@dooboostore/core");
28
28
  var import_onConnectedInnerHtml = require("./onConnectedInnerHtml");
29
29
  var import_addEventListener = require("./addEventListener");
30
30
  var import_lifecycles = require("./lifecycles");
31
31
  var import_emitCustomEvent = require("./emitCustomEvent");
32
32
  var import_changedAttribute = require("./changedAttribute");
33
33
  var import_setAttribute = require("./setAttribute");
34
+ var import_attribute = require("./attribute");
34
35
  var import_Utils = require("../utils/Utils");
35
36
  var import_config = require("../config/config");
36
37
  var import_Inject = require("@dooboostore/simple-boot/decorators/inject/Inject");
@@ -38,7 +39,7 @@ var import_types = require("../types");
38
39
  const ELEMENT_CONFIG_KEY = Symbol("simple-web-component:element-config");
39
40
  const getElementConfig = (target) => {
40
41
  const constructor = target instanceof Function ? target : target.constructor;
41
- return import_ReflectUtils.ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
42
+ return import_core.ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
42
43
  };
43
44
  const ensureInit = (inst) => {
44
45
  if (!inst.__swc_initialized) {
@@ -95,7 +96,7 @@ const setupPrototype = (proto) => {
95
96
  const currentWin = this._resolveWindow(conf);
96
97
  const helpers = import_Utils.SwcUtils.getHelperSet(currentWin);
97
98
  const args = { ...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode() };
98
- import_FunctionUtils.FunctionUtils.execute({ script, context: this, args });
99
+ import_core2.FunctionUtils.execute({ script, context: this, args });
99
100
  } catch (e) {
100
101
  console.error(`[SWC] Failed to execute ${attrName}:`, e);
101
102
  }
@@ -158,7 +159,7 @@ const setupPrototype = (proto) => {
158
159
  $el: el,
159
160
  $root: this.getRootNode()
160
161
  };
161
- await import_FunctionUtils.FunctionUtils.execute({ script, context: el, args });
162
+ await import_core2.FunctionUtils.execute({ script, context: el, args });
162
163
  };
163
164
  el.addEventListener(eventName, handler);
164
165
  handlers.set(attrName, handler);
@@ -177,7 +178,7 @@ const setupPrototype = (proto) => {
177
178
  $el: el,
178
179
  $root: this.getRootNode()
179
180
  };
180
- await import_FunctionUtils.FunctionUtils.execute({ script, context: el, args });
181
+ await import_core2.FunctionUtils.execute({ script, context: el, args });
181
182
  };
182
183
  };
183
184
  const elementDefine = (name, config = {}) => (constructor) => {
@@ -200,9 +201,10 @@ const elementDefine = (name, config = {}) => (constructor) => {
200
201
  const emitCustomEventList = (0, import_emitCustomEvent.getEmitCustomEventMetadataList)(constructor) || [];
201
202
  const addEventListenerList = (0, import_addEventListener.getAddEventListenerMetadata)(constructor) || [];
202
203
  const attrChangeMap = (0, import_changedAttribute.findAllAttributeChangedMetadata)(constructor);
204
+ const attributeList = (0, import_attribute.findAllAttributeMetadata)(constructor);
203
205
  const swcLifecycleAttributes = ["swc-on-constructor", "swc-on-connected", "swc-on-disconnected", "swc-on-before-connected", "swc-on-after-connected", "swc-on-before-disconnected", "swc-on-after-disconnected", "swc-on-before-adopted", "swc-on-after-adopted", "swc-on-attribute-changed"];
204
206
  const swcOnEvents = import_config.DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
205
- const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...attrChangeMap.keys(), ...Array.from((0, import_setAttribute.findAllSetAttributeMetadata)(constructor).values()).map((it) => it.name), ...emitCustomEventList.map((it) => it.options.attributeName), ...swcLifecycleAttributes, ...swcOnEvents])];
207
+ const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...attrChangeMap.keys(), ...Array.from((0, import_setAttribute.findAllSetAttributeMetadata)(constructor).values()).map((it) => it.name), ...attributeList.map((it) => it.options.name || String(it.propertyKey)), ...emitCustomEventList.map((it) => it.options.attributeName), ...swcLifecycleAttributes, ...swcOnEvents])];
206
208
  const connectedInnerHtmlList = (0, import_onConnectedInnerHtml.getOnConnectedInnerHtmlMetadata)(constructor) || [];
207
209
  const proto = constructor.prototype;
208
210
  setupPrototype(proto);
@@ -220,7 +222,30 @@ const elementDefine = (name, config = {}) => (constructor) => {
220
222
  if (bMethods) {
221
223
  for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
222
224
  }
223
- if (typeof this.initCore === "function") this.initCore();
225
+ attributeList.forEach((meta) => {
226
+ const attrName = meta.options.name || String(meta.propertyKey);
227
+ if (meta.options.connectedInitialize) {
228
+ const memoryVal = this[meta.privateKey];
229
+ if (memoryVal !== void 0) {
230
+ this.__swc_syncing_init = true;
231
+ try {
232
+ this[meta.propertyKey] = memoryVal;
233
+ } finally {
234
+ this.__swc_syncing_init = false;
235
+ }
236
+ }
237
+ } else if (meta.selector === ":host" || !meta.selector) {
238
+ const domVal = this.getAttribute(attrName);
239
+ if (domVal !== null) {
240
+ this.__swc_syncing_init = true;
241
+ try {
242
+ this[meta.propertyKey] = domVal;
243
+ } finally {
244
+ this.__swc_syncing_init = false;
245
+ }
246
+ }
247
+ }
248
+ });
224
249
  if (connectedInnerHtmlList.length > 0) {
225
250
  let sContent = "", lContent = "";
226
251
  for (const meta of connectedInnerHtmlList) {
@@ -326,6 +351,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
326
351
  }
327
352
  this._executeSwcScript("swc-on-connected", hostSet);
328
353
  this._executeSwcScript("swc-on-after-connected", hostSet);
354
+ this.__swc_connected = true;
329
355
  };
330
356
  const originalDisconnected = proto.disconnectedCallback;
331
357
  proto.disconnectedCallback = function() {
@@ -346,6 +372,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
346
372
  }
347
373
  this._executeSwcScript("swc-on-disconnected", hostSet);
348
374
  this._executeSwcScript("swc-on-after-disconnected", hostSet);
375
+ this.__swc_connected = false;
349
376
  };
350
377
  const originalAdopted = proto.adoptedCallback;
351
378
  proto.adoptedCallback = function() {
@@ -383,7 +410,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
383
410
  get: () => mergedObservedAttributes,
384
411
  configurable: true
385
412
  });
386
- import_ReflectUtils.ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);
413
+ import_core.ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);
387
414
  const registry = metadata.customElementRegistry || win?.customElements;
388
415
  if (registry && !registry.get(metadata.name)) {
389
416
  registry.define(metadata.name, constructor, metadata.extends ? { extends: metadata.extends } : void 0);