@dooboostore/simple-web-component 1.0.21 → 1.0.23

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 (174) hide show
  1. package/README.md +1113 -95
  2. package/dist/cjs/decorators/addEventListener.js +4 -0
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyNode.js +174 -0
  5. package/dist/cjs/decorators/applyNode.js.map +7 -0
  6. package/dist/cjs/decorators/attribute.js +30 -10
  7. package/dist/cjs/decorators/attribute.js.map +3 -3
  8. package/dist/cjs/decorators/{changedAttribute.js → changedAttributeHost.js} +6 -6
  9. package/dist/cjs/decorators/changedAttributeHost.js.map +7 -0
  10. package/dist/cjs/decorators/classList.js +45 -15
  11. package/dist/cjs/decorators/classList.js.map +2 -2
  12. package/dist/cjs/decorators/elementDefine.js +107 -57
  13. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  14. package/dist/cjs/decorators/emitCustomEvent.js +4 -3
  15. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  16. package/dist/cjs/decorators/index.js +2 -4
  17. package/dist/cjs/decorators/index.js.map +2 -2
  18. package/dist/cjs/decorators/lifecycles.js +29 -0
  19. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  20. package/dist/cjs/decorators/query.js +5 -1
  21. package/dist/cjs/decorators/query.js.map +2 -2
  22. package/dist/cjs/decorators/queryAll.js +5 -1
  23. package/dist/cjs/decorators/queryAll.js.map +2 -2
  24. package/dist/cjs/decorators/setAttribute.js +5 -1
  25. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  26. package/dist/cjs/decorators/style.js +39 -13
  27. package/dist/cjs/decorators/style.js.map +2 -2
  28. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  29. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  30. package/dist/cjs/elements/SwcAsync.js +2 -2
  31. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  32. package/dist/cjs/elements/SwcChoose.js +2 -2
  33. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  34. package/dist/cjs/elements/SwcIf.js +2 -2
  35. package/dist/cjs/elements/SwcIf.js.map +2 -2
  36. package/dist/cjs/elements/SwcLoop.js +2 -2
  37. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  38. package/dist/cjs/elements/register.js +6 -5
  39. package/dist/cjs/elements/register.js.map +2 -2
  40. package/dist/cjs/index.js +6 -18
  41. package/dist/cjs/index.js.map +2 -2
  42. package/dist/cjs/types.js.map +2 -2
  43. package/dist/cjs/utils/TemplateUtils.js +6 -0
  44. package/dist/cjs/utils/TemplateUtils.js.map +2 -2
  45. package/dist/esm/decorators/addEventListener.js +4 -0
  46. package/dist/esm/decorators/addEventListener.js.map +2 -2
  47. package/dist/esm/decorators/applyNode.js +155 -0
  48. package/dist/esm/decorators/applyNode.js.map +7 -0
  49. package/dist/esm/decorators/attribute.js +30 -10
  50. package/dist/esm/decorators/attribute.js.map +3 -3
  51. package/dist/esm/decorators/{changedAttribute.js → changedAttributeHost.js} +3 -3
  52. package/dist/esm/decorators/changedAttributeHost.js.map +7 -0
  53. package/dist/esm/decorators/classList.js +45 -15
  54. package/dist/esm/decorators/classList.js.map +2 -2
  55. package/dist/esm/decorators/elementDefine.js +106 -56
  56. package/dist/esm/decorators/elementDefine.js.map +2 -2
  57. package/dist/esm/decorators/emitCustomEvent.js +4 -3
  58. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  59. package/dist/esm/decorators/index.js +2 -4
  60. package/dist/esm/decorators/index.js.map +2 -2
  61. package/dist/esm/decorators/lifecycles.js +29 -0
  62. package/dist/esm/decorators/lifecycles.js.map +2 -2
  63. package/dist/esm/decorators/query.js +5 -1
  64. package/dist/esm/decorators/query.js.map +2 -2
  65. package/dist/esm/decorators/queryAll.js +5 -1
  66. package/dist/esm/decorators/queryAll.js.map +2 -2
  67. package/dist/esm/decorators/setAttribute.js +5 -1
  68. package/dist/esm/decorators/setAttribute.js.map +2 -2
  69. package/dist/esm/decorators/style.js +39 -13
  70. package/dist/esm/decorators/style.js.map +2 -2
  71. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  72. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  73. package/dist/esm/elements/SwcAsync.js +2 -2
  74. package/dist/esm/elements/SwcAsync.js.map +2 -2
  75. package/dist/esm/elements/SwcChoose.js +2 -2
  76. package/dist/esm/elements/SwcChoose.js.map +2 -2
  77. package/dist/esm/elements/SwcIf.js +2 -2
  78. package/dist/esm/elements/SwcIf.js.map +2 -2
  79. package/dist/esm/elements/SwcLoop.js +2 -2
  80. package/dist/esm/elements/SwcLoop.js.map +2 -2
  81. package/dist/esm/elements/register.js +6 -5
  82. package/dist/esm/elements/register.js.map +2 -2
  83. package/dist/esm/index.js +6 -18
  84. package/dist/esm/index.js.map +2 -2
  85. package/dist/esm/types.js.map +2 -2
  86. package/dist/esm/utils/TemplateUtils.js +6 -0
  87. package/dist/esm/utils/TemplateUtils.js.map +2 -2
  88. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +385 -206
  89. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  90. package/dist/types/decorators/addEventListener.d.ts +6 -0
  91. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  92. package/dist/types/decorators/applyNode.d.ts +121 -0
  93. package/dist/types/decorators/applyNode.d.ts.map +1 -0
  94. package/dist/types/decorators/attribute.d.ts +6 -0
  95. package/dist/types/decorators/attribute.d.ts.map +1 -1
  96. package/dist/types/decorators/{changedAttribute.d.ts → changedAttributeHost.d.ts} +6 -2
  97. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -0
  98. package/dist/types/decorators/classList.d.ts +32 -5
  99. package/dist/types/decorators/classList.d.ts.map +1 -1
  100. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  101. package/dist/types/decorators/emitCustomEvent.d.ts +14 -2
  102. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  103. package/dist/types/decorators/index.d.ts +2 -4
  104. package/dist/types/decorators/index.d.ts.map +1 -1
  105. package/dist/types/decorators/lifecycles.d.ts +16 -0
  106. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  107. package/dist/types/decorators/query.d.ts +6 -3
  108. package/dist/types/decorators/query.d.ts.map +1 -1
  109. package/dist/types/decorators/queryAll.d.ts +6 -0
  110. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  111. package/dist/types/decorators/setAttribute.d.ts +5 -0
  112. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  113. package/dist/types/decorators/style.d.ts +28 -3
  114. package/dist/types/decorators/style.d.ts.map +1 -1
  115. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  116. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  117. package/dist/types/elements/register.d.ts +1 -1
  118. package/dist/types/elements/register.d.ts.map +1 -1
  119. package/dist/types/index.d.ts +3 -15
  120. package/dist/types/index.d.ts.map +1 -1
  121. package/dist/types/types.d.ts +2 -1
  122. package/dist/types/types.d.ts.map +1 -1
  123. package/dist/types/utils/TemplateUtils.d.ts +5 -0
  124. package/dist/types/utils/TemplateUtils.d.ts.map +1 -1
  125. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +385 -206
  126. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  127. package/package.json +3 -3
  128. package/src/decorators/addEventListener.ts +9 -0
  129. package/src/decorators/applyNode.ts +290 -0
  130. package/src/decorators/attribute.ts +46 -12
  131. package/src/decorators/{changedAttribute.ts → changedAttributeHost.ts} +5 -1
  132. package/src/decorators/classList.ts +71 -16
  133. package/src/decorators/elementDefine.ts +130 -63
  134. package/src/decorators/emitCustomEvent.ts +13 -5
  135. package/src/decorators/index.ts +2 -4
  136. package/src/decorators/lifecycles.ts +43 -1
  137. package/src/decorators/query.ts +9 -2
  138. package/src/decorators/queryAll.ts +9 -0
  139. package/src/decorators/setAttribute.ts +8 -0
  140. package/src/decorators/style.ts +64 -13
  141. package/src/elements/SwcAppEngine.ts +1 -0
  142. package/src/elements/SwcAppMixin.ts +2 -1
  143. package/src/elements/SwcAsync.ts +2 -2
  144. package/src/elements/SwcChoose.ts +2 -2
  145. package/src/elements/SwcIf.ts +2 -2
  146. package/src/elements/SwcLoop.ts +2 -2
  147. package/src/elements/register.ts +7 -5
  148. package/src/index.ts +8 -17
  149. package/src/types.ts +2 -1
  150. package/src/utils/TemplateUtils.ts +9 -0
  151. package/dist/cjs/decorators/appendChild.js +0 -92
  152. package/dist/cjs/decorators/appendChild.js.map +0 -7
  153. package/dist/cjs/decorators/changedAttribute.js.map +0 -7
  154. package/dist/cjs/decorators/onConnectedInnerHtml.js +0 -48
  155. package/dist/cjs/decorators/onConnectedInnerHtml.js.map +0 -7
  156. package/dist/cjs/decorators/replaceChildren.js +0 -79
  157. package/dist/cjs/decorators/replaceChildren.js.map +0 -7
  158. package/dist/esm/decorators/appendChild.js +0 -73
  159. package/dist/esm/decorators/appendChild.js.map +0 -7
  160. package/dist/esm/decorators/changedAttribute.js.map +0 -7
  161. package/dist/esm/decorators/onConnectedInnerHtml.js +0 -29
  162. package/dist/esm/decorators/onConnectedInnerHtml.js.map +0 -7
  163. package/dist/esm/decorators/replaceChildren.js +0 -60
  164. package/dist/esm/decorators/replaceChildren.js.map +0 -7
  165. package/dist/types/decorators/appendChild.d.ts +0 -17
  166. package/dist/types/decorators/appendChild.d.ts.map +0 -1
  167. package/dist/types/decorators/changedAttribute.d.ts.map +0 -1
  168. package/dist/types/decorators/onConnectedInnerHtml.d.ts +0 -15
  169. package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +0 -1
  170. package/dist/types/decorators/replaceChildren.d.ts +0 -9
  171. package/dist/types/decorators/replaceChildren.d.ts.map +0 -1
  172. package/src/decorators/appendChild.ts +0 -86
  173. package/src/decorators/onConnectedInnerHtml.ts +0 -42
  174. package/src/decorators/replaceChildren.ts +0 -64
@@ -5715,30 +5715,6 @@ var Expression;
5715
5715
  })(Path = Expression2.Path || (Expression2.Path = {}));
5716
5716
  })(Expression || (Expression = {}));
5717
5717
 
5718
- // src/decorators/onConnectedInnerHtml.ts
5719
- var INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
5720
- function onConnectedInnerHtml(arg1, arg2, arg3) {
5721
- const decorator = (options, target, propertyKey) => {
5722
- const constructor = target.constructor;
5723
- let list = ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
5724
- if (!list) {
5725
- list = [];
5726
- ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
5727
- }
5728
- list.push({ propertyKey, options });
5729
- };
5730
- if (arg2) {
5731
- return decorator({}, arg1, arg2);
5732
- }
5733
- return (target, propertyKey) => {
5734
- decorator(arg1 || {}, target, propertyKey);
5735
- };
5736
- }
5737
- var getOnConnectedInnerHtmlMetadata = (target) => {
5738
- const constructor = target instanceof Function ? target : target.constructor;
5739
- return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
5740
- };
5741
-
5742
5718
  // src/decorators/addEventListener.ts
5743
5719
  var ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:add-event-listener");
5744
5720
  function addEventListener(selectorOrTarget, type, options = {}) {
@@ -5756,8 +5732,12 @@ var getAddEventListenerMetadata = (target) => {
5756
5732
  const constructor = target instanceof Function ? target : target.constructor;
5757
5733
  return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
5758
5734
  };
5735
+ function addEventListenerHost(type, options) {
5736
+ return addEventListener(":host", type, options);
5737
+ }
5759
5738
 
5760
5739
  // src/decorators/lifecycles.ts
5740
+ var ON_CONSTRUCTOR_METADATA_KEY = Symbol("simple-web-component:on-constructor");
5761
5741
  var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-connected");
5762
5742
  var ON_AFTER_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-connected");
5763
5743
  var ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-disconnected");
@@ -5765,6 +5745,7 @@ var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-d
5765
5745
  var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-before-adopted");
5766
5746
  var ON_AFTER_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-after-adopted");
5767
5747
  var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:on-add-event-listener");
5748
+ var INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
5768
5749
  var ATTRIBUTE_CHANGED_WILDCARD = "*";
5769
5750
  function createLifecycleDecorator(metadataKey) {
5770
5751
  return (target, propertyKey) => {
@@ -5777,6 +5758,7 @@ function createLifecycleDecorator(metadataKey) {
5777
5758
  list.push(propertyKey);
5778
5759
  };
5779
5760
  }
5761
+ var onConstructor = createLifecycleDecorator(ON_CONSTRUCTOR_METADATA_KEY);
5780
5762
  var onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
5781
5763
  var onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
5782
5764
  var onConnected = onAfterConnected;
@@ -5787,10 +5769,31 @@ var onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);
5787
5769
  var onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
5788
5770
  var onAdopted = onAfterAdopted;
5789
5771
  var onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
5772
+ function onConnectedInnerHtml(arg1, arg2, arg3) {
5773
+ const decorator = (options, target, propertyKey) => {
5774
+ const constructor = target.constructor;
5775
+ let list = ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
5776
+ if (!list) {
5777
+ list = [];
5778
+ ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
5779
+ }
5780
+ list.push({ propertyKey, options });
5781
+ };
5782
+ if (arg2) {
5783
+ return decorator({}, arg1, arg2);
5784
+ }
5785
+ return (target, propertyKey) => {
5786
+ decorator(arg1 || {}, target, propertyKey);
5787
+ };
5788
+ }
5790
5789
  var findAllLifecycleMetadata = (target, metadataKey) => {
5791
5790
  const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target);
5792
5791
  return results.length > 0 ? results : void 0;
5793
5792
  };
5793
+ var getOnConnectedInnerHtmlMetadata = (target) => {
5794
+ const constructor = target instanceof Function ? target : target.constructor;
5795
+ return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
5796
+ };
5794
5797
 
5795
5798
  // src/decorators/attribute.ts
5796
5799
  var ATTRIBUTE_METADATA_KEY = Symbol("simple-web-component:attribute");
@@ -5857,6 +5860,20 @@ function attribute(selector, options = {}) {
5857
5860
  ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);
5858
5861
  }
5859
5862
  metaList.push({ propertyKey, selector, options, privateKey });
5863
+ const applySetAttribute = (inst, targets, attrName, nv) => {
5864
+ targets.forEach((it) => {
5865
+ console.log("----->", it);
5866
+ if (it && typeof it.setAttribute === "function") {
5867
+ if (nv === null) {
5868
+ it.removeAttribute(attrName);
5869
+ } else {
5870
+ it.setAttribute(attrName, String(nv));
5871
+ }
5872
+ } else {
5873
+ inst[privateKey] = nv;
5874
+ }
5875
+ });
5876
+ };
5860
5877
  Object.defineProperty(target, propertyKey, {
5861
5878
  get() {
5862
5879
  const attrName = options.name || String(propertyKey);
@@ -5883,19 +5900,21 @@ function attribute(selector, options = {}) {
5883
5900
  const attrName = options.name || String(propertyKey);
5884
5901
  const conf = getElementConfig(this);
5885
5902
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
5886
- const targets = resolveTargetEls(this, selector, options, currentWin);
5887
- targets.forEach((it) => {
5888
- console.log("----->", it);
5889
- if (it && typeof it.setAttribute === "function") {
5890
- if (nv === null) {
5891
- it.removeAttribute(attrName);
5892
- } else {
5893
- it.setAttribute(attrName, String(nv));
5894
- }
5903
+ if (this.__swc_syncing_init) {
5904
+ if (options.connectedInitialize === true) {
5905
+ const targets2 = resolveTargetEls(this, selector, options, currentWin);
5906
+ applySetAttribute(this, targets2, attrName, nv);
5895
5907
  } else {
5896
5908
  this[privateKey] = nv;
5897
5909
  }
5898
- });
5910
+ return;
5911
+ }
5912
+ if (!this.__swc_connected) {
5913
+ this[privateKey] = nv;
5914
+ return;
5915
+ }
5916
+ const targets = resolveTargetEls(this, selector, options, currentWin);
5917
+ applySetAttribute(this, targets, attrName, nv);
5899
5918
  },
5900
5919
  enumerable: true,
5901
5920
  configurable: true
@@ -5905,10 +5924,13 @@ function attribute(selector, options = {}) {
5905
5924
  var findAllAttributeMetadata = (target) => {
5906
5925
  return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
5907
5926
  };
5927
+ function attributeHost(attrName, options = {}) {
5928
+ return attribute(":host", { ...options, name: attrName });
5929
+ }
5908
5930
 
5909
- // src/decorators/changedAttribute.ts
5931
+ // src/decorators/changedAttributeHost.ts
5910
5932
  var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol("simple-web-component:on-attribute-changed");
5911
- function changedAttribute(attributeName) {
5933
+ function changedAttributeHost(attributeName) {
5912
5934
  return (target, propertyKey) => {
5913
5935
  const constructor = target.constructor;
5914
5936
  let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
@@ -6012,62 +6034,12 @@ var findAllSetAttributeMetadata = (target) => {
6012
6034
  });
6013
6035
  return result;
6014
6036
  };
6015
-
6016
- // src/decorators/replaceChildren.ts
6017
- var REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
6018
- function replaceChildren(selector) {
6019
- return (target, propertyKey, descriptor) => {
6020
- const constructor = target.constructor;
6021
- let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
6022
- if (!meta) {
6023
- meta = /* @__PURE__ */ new Map();
6024
- ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
6025
- }
6026
- meta.set(propertyKey, selector);
6027
- const original = descriptor.value;
6028
- descriptor.value = async function(...args) {
6029
- ensureInit2(this);
6030
- const res = await original.apply(this, args);
6031
- if (res !== void 0) {
6032
- const conf = getElementConfig(this);
6033
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
6034
- const currentDoc = currentWin.document;
6035
- let targetEl = null;
6036
- if (selector === ":host" || !selector) {
6037
- targetEl = this;
6038
- } else {
6039
- targetEl = (this.shadowRoot || this).querySelector(selector);
6040
- }
6041
- if (targetEl) {
6042
- if (typeof res === "string") {
6043
- targetEl.textContent = res;
6044
- } else {
6045
- const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
6046
- targetEl.replaceChildren(...nodes);
6047
- }
6048
- }
6049
- }
6050
- return res;
6051
- };
6052
- };
6037
+ function setAttributeHost(name, options) {
6038
+ return setAttribute(":host", name, options);
6053
6039
  }
6054
- var getReplaceChildrenMetadata = (target) => {
6055
- const constructor = target instanceof Function ? target : target.constructor;
6056
- return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
6057
- };
6058
- var findAllReplaceChildrenMetadata = (target) => {
6059
- const result = /* @__PURE__ */ new Map();
6060
- const maps = ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
6061
- maps.forEach((map) => {
6062
- if (map instanceof Map) {
6063
- map.forEach((v, k) => result.set(k, v));
6064
- }
6065
- });
6066
- return result;
6067
- };
6068
6040
 
6069
- // src/decorators/appendChild.ts
6070
- var APPEND_CHILD_METADATA_KEY = Symbol("simple-web-component:append-child");
6041
+ // src/decorators/applyNode.ts
6042
+ var APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
6071
6043
  var normalizeNodes = (res, doc) => {
6072
6044
  const items = Array.isArray(res) ? res : [res];
6073
6045
  return items.map((it) => {
@@ -6076,13 +6048,13 @@ var normalizeNodes = (res, doc) => {
6076
6048
  return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
6077
6049
  });
6078
6050
  };
6079
- function appendChild(selector, options = { position: "beforeEnd" }) {
6051
+ function applyNode(selector, options = { position: "beforeEnd" }) {
6080
6052
  return (target, propertyKey, descriptor) => {
6081
6053
  const constructor = target.constructor;
6082
- let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor);
6054
+ let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
6083
6055
  if (!metaList) {
6084
6056
  metaList = /* @__PURE__ */ new Map();
6085
- ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
6057
+ ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);
6086
6058
  }
6087
6059
  metaList.set(propertyKey, { propertyKey, selector, options });
6088
6060
  const original = descriptor.value;
@@ -6093,28 +6065,70 @@ function appendChild(selector, options = { position: "beforeEnd" }) {
6093
6065
  const conf = getElementConfig(this);
6094
6066
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
6095
6067
  const currentDoc = currentWin.document;
6096
- let targetEl = null;
6097
- if (selector === ":host" || !selector) {
6098
- targetEl = this;
6068
+ const pos = options.position || "beforeEnd";
6069
+ const r = options.root || "auto";
6070
+ const getTargetRoot = () => {
6071
+ if (r === "shadow")
6072
+ return this.shadowRoot;
6073
+ if (r === "light")
6074
+ return this;
6075
+ if (r === "all")
6076
+ return this.shadowRoot || this;
6077
+ return this.shadowRoot || this;
6078
+ };
6079
+ if (pos === "remove") {
6080
+ if (res) {
6081
+ if (selector === ":host" || !selector) {
6082
+ if (r === "shadow" && this.shadowRoot) {
6083
+ this.shadowRoot.replaceChildren();
6084
+ } else {
6085
+ this.remove();
6086
+ }
6087
+ } else {
6088
+ const targetRoot = getTargetRoot();
6089
+ if (targetRoot) {
6090
+ const targets = targetRoot.querySelectorAll(selector);
6091
+ targets.forEach((el) => el.remove());
6092
+ }
6093
+ }
6094
+ }
6099
6095
  } else {
6100
- targetEl = (this.shadowRoot || this).querySelector(selector);
6101
- }
6102
- if (targetEl) {
6103
- const nodes = normalizeNodes(res, currentDoc);
6104
- const pos = options.position || "beforeEnd";
6105
- if (typeof res === "string") {
6106
- targetEl.insertAdjacentText(pos, res);
6107
- } else if (Array.isArray(res) && res.every((n) => typeof n === "string")) {
6108
- targetEl.insertAdjacentText(pos, res.join(""));
6096
+ let targetEl = null;
6097
+ if (selector === ":host" || !selector) {
6098
+ if (r === "shadow") {
6099
+ targetEl = this.shadowRoot;
6100
+ } else {
6101
+ targetEl = this;
6102
+ }
6109
6103
  } else {
6110
- if (pos === "beforeEnd")
6111
- targetEl.append(...nodes);
6112
- else if (pos === "afterBegin")
6113
- targetEl.prepend(...nodes);
6114
- else if (pos === "beforeBegin")
6115
- targetEl.before(...nodes);
6116
- else if (pos === "afterEnd")
6117
- targetEl.after(...nodes);
6104
+ const targetRoot = getTargetRoot();
6105
+ targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
6106
+ }
6107
+ if (targetEl) {
6108
+ const isShadowRoot = targetEl instanceof ShadowRoot;
6109
+ const nodes = normalizeNodes(res, currentDoc);
6110
+ if (pos === "replace") {
6111
+ if (!isShadowRoot) {
6112
+ targetEl.replaceWith(...nodes);
6113
+ }
6114
+ } else if (pos === "replaceChildren") {
6115
+ targetEl.replaceChildren(...nodes);
6116
+ } else if (pos === "innerHtml") {
6117
+ targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
6118
+ } else if (pos === "innerText") {
6119
+ if (targetEl.innerText !== void 0) {
6120
+ targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
6121
+ }
6122
+ } else {
6123
+ if (pos === "beforeEnd")
6124
+ targetEl.append(...nodes);
6125
+ else if (pos === "afterBegin")
6126
+ targetEl.prepend(...nodes);
6127
+ else if (pos === "beforeBegin" && !isShadowRoot)
6128
+ targetEl.before(...nodes);
6129
+ else if (pos === "afterEnd" && !isShadowRoot)
6130
+ targetEl.after(...nodes);
6131
+ }
6118
6132
  }
6119
6133
  }
6120
6134
  }
@@ -6122,9 +6136,9 @@ function appendChild(selector, options = { position: "beforeEnd" }) {
6122
6136
  };
6123
6137
  };
6124
6138
  }
6125
- var findAllAppendChildMetadata = (target) => {
6139
+ var findAllApplyNodeMetadata = (target) => {
6126
6140
  const result = /* @__PURE__ */ new Map();
6127
- const maps = ReflectUtils.findAllMetadata(APPEND_CHILD_METADATA_KEY, target);
6141
+ const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
6128
6142
  maps.forEach((map) => {
6129
6143
  if (map instanceof Map) {
6130
6144
  map.forEach((v, k) => result.set(k, v));
@@ -6132,6 +6146,27 @@ var findAllAppendChildMetadata = (target) => {
6132
6146
  });
6133
6147
  return result;
6134
6148
  };
6149
+ function applyNodeHost(options = { position: "beforeEnd" }) {
6150
+ return applyNode(":host", options);
6151
+ }
6152
+ var applyBeforeBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeBegin" });
6153
+ var applyAfterBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterBegin" });
6154
+ var applyBeforeEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeEnd" });
6155
+ var applyAfterEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterEnd" });
6156
+ var applyReplaceNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replace" });
6157
+ var applyReplaceChildrenNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replaceChildren" });
6158
+ var applyInnerHtmlNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerHtml" });
6159
+ var applyInnerTextNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerText" });
6160
+ var applyRemoveNode = (selector, options = {}) => applyNode(selector, { ...options, position: "remove" });
6161
+ var applyBeforeBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeBegin" });
6162
+ var applyAfterBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterBegin" });
6163
+ var applyBeforeEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeEnd" });
6164
+ var applyAfterEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterEnd" });
6165
+ var applyReplaceNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replace" });
6166
+ var applyReplaceChildrenNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replaceChildren" });
6167
+ var applyInnerHtmlNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerHtml" });
6168
+ var applyInnerTextNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerText" });
6169
+ var applyRemoveNodeHost = (options = {}) => applyNode(":host", { ...options, position: "remove" });
6135
6170
 
6136
6171
  // src/decorators/query.ts
6137
6172
  var QUERY_METADATA_KEY = Symbol("simple-web-component:query");
@@ -6232,6 +6267,9 @@ var getQueryMetadata = (target) => {
6232
6267
  const constructor = target instanceof Function ? target : target.constructor;
6233
6268
  return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
6234
6269
  };
6270
+ function queryHost(options) {
6271
+ return query(":host", options);
6272
+ }
6235
6273
 
6236
6274
  // src/decorators/queryAll.ts
6237
6275
  var QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
@@ -6329,11 +6367,14 @@ var getQueryAllMetadata = (target) => {
6329
6367
  const constructor = target instanceof Function ? target : target.constructor;
6330
6368
  return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
6331
6369
  };
6370
+ function queryAllHost(options) {
6371
+ return queryAll(":host", options);
6372
+ }
6332
6373
 
6333
6374
  // src/decorators/classList.ts
6334
6375
  var CLASS_LIST_METADATA_KEY = Symbol("simple-web-component:class-list");
6335
6376
  function createClassListDecorator(action) {
6336
- return (selector) => {
6377
+ return (selector, options = {}) => {
6337
6378
  return (target, propertyKey, descriptor) => {
6338
6379
  const constructor = target.constructor;
6339
6380
  let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor);
@@ -6341,19 +6382,39 @@ function createClassListDecorator(action) {
6341
6382
  metaList = /* @__PURE__ */ new Map();
6342
6383
  ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);
6343
6384
  }
6344
- metaList.set(propertyKey, { propertyKey, selector, action });
6385
+ metaList.set(propertyKey, { propertyKey, selector, action, options });
6345
6386
  const original = descriptor.value;
6346
6387
  descriptor.value = async function(...args) {
6347
6388
  ensureInit2(this);
6348
6389
  const res = await original.apply(this, args);
6349
6390
  if (res !== void 0) {
6391
+ const r = options.root || "auto";
6350
6392
  const hostSet = SwcUtils.getHostSet(this);
6351
- let targetEl = null;
6352
- if (selector === ":host" || !selector) targetEl = this;
6353
- else if (selector === ":parentHost") targetEl = hostSet.$parentHost;
6354
- else if (selector === ":appHost") targetEl = hostSet.$appHost;
6355
- else targetEl = (this.shadowRoot || this).querySelector(selector);
6356
- if (targetEl) {
6393
+ const targetEls = [];
6394
+ if (selector === ":host" || !selector) {
6395
+ targetEls.push(this);
6396
+ } else if (selector === ":parentHost") {
6397
+ if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);
6398
+ } else if (selector === ":appHost") {
6399
+ if (hostSet.$appHost) targetEls.push(hostSet.$appHost);
6400
+ } else {
6401
+ if (r === "shadow") {
6402
+ const found = this.shadowRoot?.querySelectorAll(selector);
6403
+ if (found) targetEls.push(...found);
6404
+ } else if (r === "light") {
6405
+ const found = this.querySelectorAll(selector);
6406
+ if (found) targetEls.push(...found);
6407
+ } else if (r === "all") {
6408
+ const sFound = this.shadowRoot?.querySelectorAll(selector);
6409
+ const lFound = this.querySelectorAll(selector);
6410
+ if (sFound) targetEls.push(...sFound);
6411
+ if (lFound) targetEls.push(...lFound);
6412
+ } else {
6413
+ const found = (this.shadowRoot || this).querySelectorAll(selector);
6414
+ if (found) targetEls.push(...found);
6415
+ }
6416
+ }
6417
+ targetEls.forEach((targetEl) => {
6357
6418
  if (action === "set") {
6358
6419
  let classes = "";
6359
6420
  if (typeof res === "object" && res !== null && !Array.isArray(res)) {
@@ -6381,18 +6442,23 @@ function createClassListDecorator(action) {
6381
6442
  const classes = Array.isArray(res) ? res.map(String) : [String(res)];
6382
6443
  classes.forEach((c) => targetEl.classList.toggle(c));
6383
6444
  }
6384
- }
6445
+ });
6385
6446
  }
6386
6447
  return res;
6387
6448
  };
6388
6449
  };
6389
6450
  };
6390
6451
  }
6391
- var setClassList = createClassListDecorator("set");
6392
- var updateClassList = createClassListDecorator("update");
6393
- var addClassList = createClassListDecorator("add");
6394
- var removeClassList = createClassListDecorator("remove");
6395
- var toggleClassList = createClassListDecorator("toggle");
6452
+ var setClassList = (selector, options = {}) => createClassListDecorator("set")(selector, options);
6453
+ var updateClassList = (selector, options = {}) => createClassListDecorator("update")(selector, options);
6454
+ var addClassList = (selector, options = {}) => createClassListDecorator("add")(selector, options);
6455
+ var removeClassList = (selector, options = {}) => createClassListDecorator("remove")(selector, options);
6456
+ var toggleClassList = (selector, options = {}) => createClassListDecorator("toggle")(selector, options);
6457
+ var setClassListHost = (options = {}) => createClassListDecorator("set")(":host", options);
6458
+ var updateClassListHost = (options = {}) => createClassListDecorator("update")(":host", options);
6459
+ var addClassListHost = (options = {}) => createClassListDecorator("add")(":host", options);
6460
+ var removeClassListHost = (options = {}) => createClassListDecorator("remove")(":host", options);
6461
+ var toggleClassListHost = (options = {}) => createClassListDecorator("toggle")(":host", options);
6396
6462
  var findAllClassListMetadata = (target) => {
6397
6463
  const result = /* @__PURE__ */ new Map();
6398
6464
  const maps = ReflectUtils.findAllMetadata(CLASS_LIST_METADATA_KEY, target);
@@ -6407,7 +6473,7 @@ var findAllClassListMetadata = (target) => {
6407
6473
  // src/decorators/style.ts
6408
6474
  var STYLE_METADATA_KEY = Symbol("simple-web-component:style");
6409
6475
  function createStyleDecorator(action) {
6410
- return (selector) => {
6476
+ return (selector, options = {}) => {
6411
6477
  return (target, propertyKey, descriptor) => {
6412
6478
  const constructor = target.constructor;
6413
6479
  let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor);
@@ -6415,19 +6481,39 @@ function createStyleDecorator(action) {
6415
6481
  metaList = /* @__PURE__ */ new Map();
6416
6482
  ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
6417
6483
  }
6418
- metaList.set(propertyKey, { propertyKey, selector, action });
6484
+ metaList.set(propertyKey, { propertyKey, selector, action, options });
6419
6485
  const original = descriptor.value;
6420
6486
  descriptor.value = async function(...args) {
6421
6487
  ensureInit2(this);
6422
6488
  const res = await original.apply(this, args);
6423
6489
  if (res !== void 0) {
6490
+ const r = options.root || "auto";
6424
6491
  const hostSet = SwcUtils.getHostSet(this);
6425
- let targetEl = null;
6426
- if (selector === ":host" || !selector) targetEl = this;
6427
- else if (selector === ":parentHost") targetEl = hostSet.$parentHost;
6428
- else if (selector === ":appHost") targetEl = hostSet.$appHost;
6429
- else targetEl = (this.shadowRoot || this).querySelector(selector);
6430
- if (targetEl) {
6492
+ const targetEls = [];
6493
+ if (selector === ":host" || !selector) {
6494
+ targetEls.push(this);
6495
+ } else if (selector === ":parentHost") {
6496
+ if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);
6497
+ } else if (selector === ":appHost") {
6498
+ if (hostSet.$appHost) targetEls.push(hostSet.$appHost);
6499
+ } else {
6500
+ if (r === "shadow") {
6501
+ const found = this.shadowRoot?.querySelectorAll(selector);
6502
+ if (found) targetEls.push(...found);
6503
+ } else if (r === "light") {
6504
+ const found = this.querySelectorAll(selector);
6505
+ if (found) targetEls.push(...found);
6506
+ } else if (r === "all") {
6507
+ const sFound = this.shadowRoot?.querySelectorAll(selector);
6508
+ const lFound = this.querySelectorAll(selector);
6509
+ if (sFound) targetEls.push(...sFound);
6510
+ if (lFound) targetEls.push(...lFound);
6511
+ } else {
6512
+ const found = (this.shadowRoot || this).querySelectorAll(selector);
6513
+ if (found) targetEls.push(...found);
6514
+ }
6515
+ }
6516
+ targetEls.forEach((targetEl) => {
6431
6517
  if (action === "set") {
6432
6518
  targetEl.style.cssText = "";
6433
6519
  if (typeof res === "object" && res !== null) {
@@ -6443,16 +6529,19 @@ function createStyleDecorator(action) {
6443
6529
  const props = Array.isArray(res) ? res : [res];
6444
6530
  props.forEach((p) => targetEl.style.removeProperty(String(p)));
6445
6531
  }
6446
- }
6532
+ });
6447
6533
  }
6448
6534
  return res;
6449
6535
  };
6450
6536
  };
6451
6537
  };
6452
6538
  }
6453
- var setStyle = createStyleDecorator("set");
6454
- var updateStyle = createStyleDecorator("update");
6455
- var removeStyle = createStyleDecorator("remove");
6539
+ var setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
6540
+ var setStyleHost = (options = {}) => createStyleDecorator("set")(":host", options);
6541
+ var updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
6542
+ var updateStyleHost = (options = {}) => createStyleDecorator("update")(":host", options);
6543
+ var removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
6544
+ var removeStyleHost = (options = {}) => createStyleDecorator("remove")(":host", options);
6456
6545
  var findAllStyleMetadata = (target) => {
6457
6546
  const result = /* @__PURE__ */ new Map();
6458
6547
  const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
@@ -6582,9 +6671,6 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
6582
6671
  return (targetObj, propertyKey, descriptor) => {
6583
6672
  const constructor = targetObj.constructor;
6584
6673
  const fullOptions = { ...options, type };
6585
- if (!fullOptions.attributeName) {
6586
- fullOptions.attributeName = `swc-on-${type}`;
6587
- }
6588
6674
  if (fullOptions.bubbles === void 0) fullOptions.bubbles = true;
6589
6675
  if (fullOptions.composed === void 0) fullOptions.composed = true;
6590
6676
  let list = ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
@@ -6649,6 +6735,9 @@ var getEmitCustomEventMetadataList = (target) => {
6649
6735
  const constructor = target instanceof Function ? target : target.constructor;
6650
6736
  return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
6651
6737
  };
6738
+ function emitCustomEventHost(type, options) {
6739
+ return emitCustomEvent(":host", type, options);
6740
+ }
6652
6741
 
6653
6742
  // src/config/config.ts
6654
6743
  var HTML_TAG_ENTRIES = [
@@ -6769,6 +6858,10 @@ var ensureInit2 = (inst) => {
6769
6858
  inst.__swc_initialized = true;
6770
6859
  const hostSet = SwcUtils.getHostSet(inst);
6771
6860
  inst._executeSwcScript?.("swc-on-constructor", hostSet);
6861
+ const cMethods = findAllLifecycleMetadata(inst, ON_CONSTRUCTOR_METADATA_KEY);
6862
+ if (cMethods) {
6863
+ for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
6864
+ }
6772
6865
  }
6773
6866
  };
6774
6867
  var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
@@ -6867,7 +6960,9 @@ var setupPrototype = (proto) => {
6867
6960
  const oldHandler = handlers.get(attrName);
6868
6961
  if (oldHandler) el.removeEventListener(eventName, oldHandler);
6869
6962
  const handler = async (event) => {
6870
- const hostSet = SwcUtils.getHostSet(el);
6963
+ console.log("execute handler", event);
6964
+ const parent = SwcUtils.findNearestSwcHost(el);
6965
+ const hostSet = SwcUtils.getHostSet(parent || el);
6871
6966
  const conf = getElementConfig(this);
6872
6967
  const currentWin = this._resolveWindow(conf);
6873
6968
  const helpers = SwcUtils.getHelperSet(currentWin);
@@ -6886,13 +6981,18 @@ var setupPrototype = (proto) => {
6886
6981
  };
6887
6982
  proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
6888
6983
  ensureInit2(this);
6889
- const hostSet = SwcUtils.getHostSet(el);
6984
+ console.log("execute handler2", event);
6985
+ const parent = SwcUtils.findNearestSwcHost(el);
6986
+ const hostSet = SwcUtils.getHostSet(parent || el);
6890
6987
  const conf = getElementConfig(this);
6891
6988
  const currentWin = this._resolveWindow(conf);
6892
6989
  const currentHelpers = SwcUtils.getHelperSet(currentWin);
6990
+ const detail = event.detail;
6893
6991
  const args = {
6894
6992
  event,
6895
- $data: event.detail,
6993
+ $event: event,
6994
+ $data: detail,
6995
+ $detail: detail,
6896
6996
  ...hostSet,
6897
6997
  ...currentHelpers,
6898
6998
  $el: el,
@@ -6919,12 +7019,14 @@ var elementDefine = (name, config = {}) => (constructor) => {
6919
7019
  metadata.extends = extendsTagName;
6920
7020
  }
6921
7021
  const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
7022
+ const emitHostCustomEventList = emitCustomEventList.filter((meta) => meta.selector === ":host" || meta.selector === "");
6922
7023
  const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
7024
+ const addHostEventListenerList = addEventListenerList.filter((meta) => meta.selector === ":host" || meta.selector === "");
6923
7025
  const attrChangeMap = findAllAttributeChangedMetadata(constructor);
6924
7026
  const attributeList = findAllAttributeMetadata(constructor);
6925
7027
  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"];
6926
7028
  const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
6927
- const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...attrChangeMap.keys(), ...Array.from(findAllSetAttributeMetadata(constructor).values()).map((it) => it.name), ...attributeList.map((it) => it.options.name || String(it.propertyKey)), ...emitCustomEventList.map((it) => it.options.attributeName), ...swcLifecycleAttributes, ...swcOnEvents])];
7029
+ const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...attrChangeMap.keys(), ...Array.from(findAllSetAttributeMetadata(constructor).values()).map((it) => it.name), ...attributeList.map((it) => it.options.name || String(it.propertyKey)), ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
6928
7030
  const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
6929
7031
  const proto = constructor.prototype;
6930
7032
  setupPrototype(proto);
@@ -6944,25 +7046,15 @@ var elementDefine = (name, config = {}) => (constructor) => {
6944
7046
  }
6945
7047
  attributeList.forEach((meta) => {
6946
7048
  const attrName = meta.options.name || String(meta.propertyKey);
6947
- if (meta.options.connectedInitialize) {
6948
- const memoryVal = this[meta.privateKey];
6949
- if (memoryVal !== void 0) {
6950
- this.__swc_syncing_init = true;
6951
- try {
7049
+ if (meta.options.connectedInitialize === true) {
7050
+ this.__swc_syncing_init = true;
7051
+ try {
7052
+ const memoryVal = this[meta.privateKey];
7053
+ if (memoryVal !== void 0) {
6952
7054
  this[meta.propertyKey] = memoryVal;
6953
- } finally {
6954
- this.__swc_syncing_init = false;
6955
- }
6956
- }
6957
- } else if (meta.selector === ":host" || !meta.selector) {
6958
- const domVal = this.getAttribute(attrName);
6959
- if (domVal !== null) {
6960
- this.__swc_syncing_init = true;
6961
- try {
6962
- this[meta.propertyKey] = domVal;
6963
- } finally {
6964
- this.__swc_syncing_init = false;
6965
7055
  }
7056
+ } finally {
7057
+ this.__swc_syncing_init = false;
6966
7058
  }
6967
7059
  }
6968
7060
  });
@@ -6985,7 +7077,62 @@ var elementDefine = (name, config = {}) => (constructor) => {
6985
7077
  });
6986
7078
  globalDelegatedRoots.add(root);
6987
7079
  }
7080
+ const delegateListeners = [];
7081
+ const nonDelegateListeners = [];
6988
7082
  addEventListenerList.forEach((meta) => {
7083
+ if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
7084
+ delegateListeners.push(meta);
7085
+ } else {
7086
+ nonDelegateListeners.push(meta);
7087
+ }
7088
+ });
7089
+ const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
7090
+ delegateListeners.forEach((meta) => {
7091
+ const r = meta.options.root || "auto";
7092
+ const rootKey = `${meta.type}:${r}`;
7093
+ if (!delegatesByTypeAndRoot.has(rootKey)) {
7094
+ delegatesByTypeAndRoot.set(rootKey, []);
7095
+ }
7096
+ delegatesByTypeAndRoot.get(rootKey).push(meta);
7097
+ });
7098
+ delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
7099
+ const [type, rStr] = typeRootKey.split(":");
7100
+ const r = rStr === "auto" ? "auto" : rStr;
7101
+ const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
7102
+ const bindRoots = [];
7103
+ if (r === "auto") bindRoots.push(this.shadowRoot || this);
7104
+ else if (r === "light") bindRoots.push(this);
7105
+ else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
7106
+ else if (r === "all") {
7107
+ bindRoots.push(this);
7108
+ if (this.shadowRoot) bindRoots.push(this.shadowRoot);
7109
+ }
7110
+ bindRoots.forEach((br) => {
7111
+ const sortedMetaList = [...metaList].sort((a, b) => {
7112
+ const aStop = a.options.stopPropagation ? 1 : 0;
7113
+ const bStop = b.options.stopPropagation ? 1 : 0;
7114
+ return bStop - aStop;
7115
+ });
7116
+ const unifiedHandler = async (event) => {
7117
+ for (const meta of sortedMetaList) {
7118
+ const { selector, options } = meta;
7119
+ const matchedEl = event.target.closest(selector);
7120
+ if (matchedEl && br.contains(matchedEl)) {
7121
+ if (options.stopPropagation) event.stopPropagation();
7122
+ if (options.stopImmediatePropagation) event.stopImmediatePropagation();
7123
+ if (options.preventDefault) event.preventDefault();
7124
+ const currentHostSet = SwcUtils.getHostSet(this);
7125
+ const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
7126
+ await this[meta.propertyKey](event, currentHostSet, matchedEl, args);
7127
+ if (event.cancelBubble) break;
7128
+ }
7129
+ }
7130
+ };
7131
+ br.addEventListener(type, unifiedHandler, opts);
7132
+ this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
7133
+ });
7134
+ });
7135
+ nonDelegateListeners.forEach((meta) => {
6989
7136
  const { selector, type, options } = meta;
6990
7137
  const opts = { capture: options.capture, once: options.once, passive: options.passive };
6991
7138
  const bindTargets = [];
@@ -7010,33 +7157,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
7010
7157
  else if (selector === ":hosts") hostSet.$hosts.forEach(applyRootOption);
7011
7158
  else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRootOption);
7012
7159
  else if (selector === ":host" || !selector) applyRootOption(this);
7013
- else if (options.delegate) {
7014
- const bindRoots = [];
7015
- if (r === "auto") bindRoots.push(this.shadowRoot || this);
7016
- else if (r === "light") bindRoots.push(this);
7017
- else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
7018
- else if (r === "all") {
7019
- bindRoots.push(this);
7020
- if (this.shadowRoot) bindRoots.push(this.shadowRoot);
7021
- }
7022
- bindRoots.forEach((br) => {
7023
- const handler = async (event) => {
7024
- const matchedEl = event.target.closest(selector);
7025
- if (matchedEl && br.contains(matchedEl)) {
7026
- if (options.stopPropagation) event.stopPropagation();
7027
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
7028
- if (options.preventDefault) event.preventDefault();
7029
- const currentHostSet = SwcUtils.getHostSet(this);
7030
- const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
7031
- await this._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, matchedEl, args]);
7032
- }
7033
- };
7034
- br.addEventListener(type, handler, opts);
7035
- if (options.removeOnDisconnected === true || br !== this && br !== this.shadowRoot) {
7036
- this._boundListeners.push({ target: br, type, handler, options: opts });
7037
- }
7038
- });
7039
- } else {
7160
+ else {
7040
7161
  const searchRoots = [];
7041
7162
  if (r === "auto") searchRoots.push(this.shadowRoot || this);
7042
7163
  else if (r === "light") searchRoots.push(this);
@@ -7056,7 +7177,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
7056
7177
  if (options.preventDefault) event.preventDefault();
7057
7178
  const currentHostSet = SwcUtils.getHostSet(this);
7058
7179
  const args = { event, ...currentHostSet, $el: t, $root: t };
7059
- await this._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, args]);
7180
+ await this[meta.propertyKey](event, currentHostSet, args);
7060
7181
  };
7061
7182
  t.addEventListener(type, handler, opts);
7062
7183
  if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
@@ -7064,6 +7185,22 @@ var elementDefine = (name, config = {}) => (constructor) => {
7064
7185
  }
7065
7186
  });
7066
7187
  });
7188
+ addHostEventListenerList.forEach((meta) => {
7189
+ const { type, options } = meta;
7190
+ const opts = { capture: options.capture, once: options.once, passive: options.passive };
7191
+ const handler = async (event) => {
7192
+ if (options.stopPropagation) event.stopPropagation();
7193
+ if (options.stopImmediatePropagation) event.stopImmediatePropagation();
7194
+ if (options.preventDefault) event.preventDefault();
7195
+ const currentHostSet = SwcUtils.getHostSet(this);
7196
+ const args = { event, ...currentHostSet, $el: this, $root: this.getRootNode() };
7197
+ await this[meta.propertyKey](event, currentHostSet, args);
7198
+ };
7199
+ this.addEventListener(type, handler, opts);
7200
+ if (options.removeOnDisconnected === true) {
7201
+ this._boundListeners.push({ target: this, type, handler, options: opts });
7202
+ }
7203
+ });
7067
7204
  if (originalConnected) originalConnected.apply(this);
7068
7205
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
7069
7206
  if (aMethods) {
@@ -7113,17 +7250,20 @@ var elementDefine = (name, config = {}) => (constructor) => {
7113
7250
  const originalAttributeChanged = proto.attributeChangedCallback;
7114
7251
  proto.attributeChangedCallback = function(name2, old, newVal) {
7115
7252
  if (originalAttributeChanged) originalAttributeChanged.apply(this, [name2, old, newVal]);
7253
+ const hSet = SwcUtils.getHostSet(this);
7116
7254
  if (name2.startsWith("swc-on-") && !swcLifecycleAttributes.includes(name2)) {
7117
7255
  if (newVal !== null) {
7118
- const customEventMeta = emitCustomEventList.find((it) => it.options.attributeName === name2);
7119
- const eventName = customEventMeta ? customEventMeta.type : name2.substring(7);
7256
+ const eventName = name2.substring(7);
7120
7257
  this._bindAttributeEvent(this, name2, newVal, eventName);
7121
7258
  }
7122
7259
  }
7260
+ const hostCustomEventMeta = emitHostCustomEventList.find((it) => it.options.attributeName === name2);
7261
+ if (hostCustomEventMeta && newVal !== null) {
7262
+ this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
7263
+ }
7123
7264
  const mKeys = attrChangeMap.get(name2);
7124
7265
  if (mKeys && Array.isArray(mKeys)) {
7125
- const hSet = SwcUtils.getHostSet(this);
7126
- for (const key of mKeys) this._invokeLifecycleMethod(key, hSet, [newVal, old, name2]);
7266
+ for (const key of mKeys) this[key](newVal, old, name2, hSet);
7127
7267
  }
7128
7268
  };
7129
7269
  Object.defineProperty(constructor, "observedAttributes", {
@@ -7948,6 +8088,10 @@ var TemplateUtils;
7948
8088
  const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
7949
8089
  return document.createTextNode(raw);
7950
8090
  };
8091
+ TemplateUtils2.commentNode = (strings, ...values) => {
8092
+ const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
8093
+ return document.createComment(raw);
8094
+ };
7951
8095
  TemplateUtils2.createElement = (info, attrs = {}) => {
7952
8096
  const el = document.createElement(info.tagName);
7953
8097
  if (info.innerHtml !== void 0) el.innerHTML = info.innerHtml;
@@ -7980,6 +8124,7 @@ var TemplateUtils;
7980
8124
  })(TemplateUtils || (TemplateUtils = {}));
7981
8125
  var htmlFragment = TemplateUtils.htmlFragment;
7982
8126
  var textNode = TemplateUtils.textNode;
8127
+ var commentNode = TemplateUtils.commentNode;
7983
8128
  var createElement = TemplateUtils.createElement;
7984
8129
  var htmlDivElement = TemplateUtils.htmlDivElement;
7985
8130
  var htmlSpanElement = TemplateUtils.htmlSpanElement;
@@ -7999,7 +8144,7 @@ var htmlSectionElement = TemplateUtils.htmlSectionElement;
7999
8144
  var htmlArticleElement = TemplateUtils.htmlArticleElement;
8000
8145
  export {
8001
8146
  ADD_EVENT_LISTENER_METADATA_KEY,
8002
- APPEND_CHILD_METADATA_KEY,
8147
+ APPLY_NODE_METADATA_KEY,
8003
8148
  ATTRIBUTE_CHANGED_WILDCARD,
8004
8149
  ATTRIBUTE_METADATA_KEY,
8005
8150
  BROWSER_GLOBALS,
@@ -8008,6 +8153,7 @@ export {
8008
8153
  ELEMENT_CONFIG_KEY,
8009
8154
  EMIT_CUSTOM_EVENT_METADATA_KEY,
8010
8155
  HTML_TAG_ENTRIES,
8156
+ INNER_HTML_METADATA_KEY,
8011
8157
  InjectSituationType,
8012
8158
  ON_ADD_EVENT_LISTENER_METADATA_KEY,
8013
8159
  ON_AFTER_ADOPTED_METADATA_KEY,
@@ -8017,38 +8163,61 @@ export {
8017
8163
  ON_BEFORE_ADOPTED_METADATA_KEY,
8018
8164
  ON_BEFORE_CONNECTED_METADATA_KEY,
8019
8165
  ON_BEFORE_DISCONNECTED_METADATA_KEY,
8166
+ ON_CONSTRUCTOR_METADATA_KEY,
8020
8167
  QUERY_ALL_METADATA_KEY,
8021
8168
  QUERY_METADATA_KEY,
8022
- REPLACE_CHILDREN_METADATA_KEY,
8023
8169
  SET_ATTRIBUTE_METADATA_KEY,
8024
8170
  STYLE_METADATA_KEY,
8025
8171
  SWC_NOT_FOUND,
8026
8172
  SwcUtils,
8027
8173
  TemplateUtils,
8028
8174
  addClassList,
8175
+ addClassListHost,
8029
8176
  addEventListener,
8030
- appendChild,
8177
+ addEventListenerHost,
8178
+ applyAfterBeginNode,
8179
+ applyAfterBeginNodeHost,
8180
+ applyAfterEndNode,
8181
+ applyAfterEndNodeHost,
8182
+ applyBeforeBeginNode,
8183
+ applyBeforeBeginNodeHost,
8184
+ applyBeforeEndNode,
8185
+ applyBeforeEndNodeHost,
8186
+ applyInnerHtmlNode,
8187
+ applyInnerHtmlNodeHost,
8188
+ applyInnerTextNode,
8189
+ applyInnerTextNodeHost,
8190
+ applyNode,
8191
+ applyNodeHost,
8192
+ applyRemoveNode,
8193
+ applyRemoveNodeHost,
8194
+ applyReplaceChildrenNode,
8195
+ applyReplaceChildrenNodeHost,
8196
+ applyReplaceNode,
8197
+ applyReplaceNodeHost,
8031
8198
  attribute,
8032
- changedAttribute,
8199
+ attributeHost,
8200
+ changedAttributeHost,
8201
+ commentNode,
8033
8202
  createElement,
8034
8203
  elementDefine,
8035
8204
  emitCustomEvent,
8205
+ emitCustomEventHost,
8036
8206
  ensureInit2 as ensureInit,
8037
- findAllAppendChildMetadata,
8207
+ findAllApplyNodeMetadata,
8038
8208
  findAllAttributeChangedMetadata,
8039
8209
  findAllAttributeMetadata,
8040
8210
  findAllClassListMetadata,
8041
8211
  findAllLifecycleMetadata,
8042
- findAllReplaceChildrenMetadata,
8043
8212
  findAllSetAttributeMetadata,
8044
8213
  findAllStyleMetadata,
8045
8214
  getAddEventListenerMetadata,
8046
8215
  getChangedAttributeMetadata,
8047
8216
  getElementConfig,
8048
8217
  getEmitCustomEventMetadataList,
8218
+ getOnConnectedInnerHtmlMetadata,
8049
8219
  getQueryAllMetadata,
8050
8220
  getQueryMetadata,
8051
- getReplaceChildrenMetadata,
8052
8221
  getSetAttributeMetadata,
8053
8222
  htmlAElement,
8054
8223
  htmlArticleElement,
@@ -8077,20 +8246,30 @@ export {
8077
8246
  onBeforeDisconnected,
8078
8247
  onConnected,
8079
8248
  onConnectedInnerHtml,
8249
+ onConstructor,
8080
8250
  onDisconnected,
8081
8251
  query,
8082
8252
  queryAll,
8253
+ queryAllHost,
8254
+ queryHost,
8083
8255
  removeClassList,
8256
+ removeClassListHost,
8084
8257
  removeStyle,
8085
- replaceChildren,
8258
+ removeStyleHost,
8086
8259
  resolveTargetEls,
8087
8260
  setAttribute,
8261
+ setAttributeHost,
8088
8262
  setClassList,
8263
+ setClassListHost,
8089
8264
  setStyle,
8265
+ setStyleHost,
8090
8266
  textNode,
8091
8267
  toggleClassList,
8268
+ toggleClassListHost,
8092
8269
  updateClassList,
8093
- updateStyle
8270
+ updateClassListHost,
8271
+ updateStyle,
8272
+ updateStyleHost
8094
8273
  };
8095
8274
  /*! Bundled license information:
8096
8275