@dooboostore/simple-web-component 1.0.47 → 1.0.48

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 (132) hide show
  1. package/README.md +109 -11
  2. package/dist/cjs/decorators/addEventListener.js +45 -7
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/elementDefine.js +225 -6
  5. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  6. package/dist/cjs/decorators/index.js +2 -0
  7. package/dist/cjs/decorators/index.js.map +2 -2
  8. package/dist/cjs/decorators/mutationObserver.js +104 -0
  9. package/dist/cjs/decorators/mutationObserver.js.map +7 -0
  10. package/dist/cjs/decorators/query.js +13 -1
  11. package/dist/cjs/decorators/query.js.map +2 -2
  12. package/dist/cjs/decorators/resizeObserver.js +104 -0
  13. package/dist/cjs/decorators/resizeObserver.js.map +7 -0
  14. package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
  15. package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
  16. package/dist/esm/decorators/addEventListener.js +45 -7
  17. package/dist/esm/decorators/addEventListener.js.map +2 -2
  18. package/dist/esm/decorators/elementDefine.js +225 -6
  19. package/dist/esm/decorators/elementDefine.js.map +3 -3
  20. package/dist/esm/decorators/index.js +2 -0
  21. package/dist/esm/decorators/index.js.map +2 -2
  22. package/dist/esm/decorators/mutationObserver.js +85 -0
  23. package/dist/esm/decorators/mutationObserver.js.map +7 -0
  24. package/dist/esm/decorators/query.js +13 -1
  25. package/dist/esm/decorators/query.js.map +2 -2
  26. package/dist/esm/decorators/resizeObserver.js +85 -0
  27. package/dist/esm/decorators/resizeObserver.js.map +7 -0
  28. package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
  29. package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
  30. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +446 -13
  31. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  32. package/dist/types/decorators/addEventListener.d.ts +24 -5
  33. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  34. package/dist/types/decorators/elementDefine.d.ts +14 -0
  35. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  36. package/dist/types/decorators/index.d.ts +2 -0
  37. package/dist/types/decorators/index.d.ts.map +1 -1
  38. package/dist/types/decorators/mutationObserver.d.ts +36 -0
  39. package/dist/types/decorators/mutationObserver.d.ts.map +1 -0
  40. package/dist/types/decorators/query.d.ts +12 -0
  41. package/dist/types/decorators/query.d.ts.map +1 -1
  42. package/dist/types/decorators/resizeObserver.d.ts +37 -0
  43. package/dist/types/decorators/resizeObserver.d.ts.map +1 -0
  44. package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
  45. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
  46. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +446 -13
  47. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  48. package/package.json +4 -4
  49. package/src/decorators/addEventListener.ts +52 -9
  50. package/src/decorators/elementDefine.ts +330 -47
  51. package/src/decorators/index.ts +2 -0
  52. package/src/decorators/mutationObserver.ts +128 -0
  53. package/src/decorators/query.ts +23 -0
  54. package/src/decorators/resizeObserver.ts +129 -0
  55. package/src/examples/RxJSOperatorsExample.ts +279 -0
  56. package/dist/cjs/elements/tt/SwcAppMixin.js +0 -1
  57. package/dist/cjs/elements/tt/SwcAppMixin.js.map +0 -7
  58. package/dist/cjs/elements/tt/SwcAsync.js +0 -1
  59. package/dist/cjs/elements/tt/SwcAsync.js.map +0 -7
  60. package/dist/cjs/elements/tt/SwcAsyncTemplate.js +0 -1
  61. package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +0 -7
  62. package/dist/cjs/elements/tt/SwcChoose.js +0 -1
  63. package/dist/cjs/elements/tt/SwcChoose.js.map +0 -7
  64. package/dist/cjs/elements/tt/SwcChooseTemplate.js +0 -1
  65. package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +0 -7
  66. package/dist/cjs/elements/tt/SwcIf.js +0 -1
  67. package/dist/cjs/elements/tt/SwcIf.js.map +0 -7
  68. package/dist/cjs/elements/tt/SwcIfTemplate.js +0 -1
  69. package/dist/cjs/elements/tt/SwcIfTemplate.js.map +0 -7
  70. package/dist/cjs/elements/tt/SwcLoop.js +0 -1
  71. package/dist/cjs/elements/tt/SwcLoop.js.map +0 -7
  72. package/dist/cjs/elements/tt/SwcLoopTemplate.js +0 -1
  73. package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +0 -7
  74. package/dist/cjs/elements/tt/SwcSubTemplates.js +0 -1
  75. package/dist/cjs/elements/tt/SwcSubTemplates.js.map +0 -7
  76. package/dist/cjs/elements/tt/register.js +0 -1
  77. package/dist/cjs/elements/tt/register.js.map +0 -7
  78. package/dist/esm/elements/tt/SwcAppMixin.js +0 -1
  79. package/dist/esm/elements/tt/SwcAppMixin.js.map +0 -7
  80. package/dist/esm/elements/tt/SwcAsync.js +0 -1
  81. package/dist/esm/elements/tt/SwcAsync.js.map +0 -7
  82. package/dist/esm/elements/tt/SwcAsyncTemplate.js +0 -1
  83. package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +0 -7
  84. package/dist/esm/elements/tt/SwcChoose.js +0 -1
  85. package/dist/esm/elements/tt/SwcChoose.js.map +0 -7
  86. package/dist/esm/elements/tt/SwcChooseTemplate.js +0 -1
  87. package/dist/esm/elements/tt/SwcChooseTemplate.js.map +0 -7
  88. package/dist/esm/elements/tt/SwcIf.js +0 -1
  89. package/dist/esm/elements/tt/SwcIf.js.map +0 -7
  90. package/dist/esm/elements/tt/SwcIfTemplate.js +0 -1
  91. package/dist/esm/elements/tt/SwcIfTemplate.js.map +0 -7
  92. package/dist/esm/elements/tt/SwcLoop.js +0 -1
  93. package/dist/esm/elements/tt/SwcLoop.js.map +0 -7
  94. package/dist/esm/elements/tt/SwcLoopTemplate.js +0 -1
  95. package/dist/esm/elements/tt/SwcLoopTemplate.js.map +0 -7
  96. package/dist/esm/elements/tt/SwcSubTemplates.js +0 -1
  97. package/dist/esm/elements/tt/SwcSubTemplates.js.map +0 -7
  98. package/dist/esm/elements/tt/register.js +0 -1
  99. package/dist/esm/elements/tt/register.js.map +0 -7
  100. package/dist/types/elements/tt/SwcAppMixin.d.ts +0 -1
  101. package/dist/types/elements/tt/SwcAppMixin.d.ts.map +0 -1
  102. package/dist/types/elements/tt/SwcAsync.d.ts +0 -1
  103. package/dist/types/elements/tt/SwcAsync.d.ts.map +0 -1
  104. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +0 -1
  105. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +0 -1
  106. package/dist/types/elements/tt/SwcChoose.d.ts +0 -1
  107. package/dist/types/elements/tt/SwcChoose.d.ts.map +0 -1
  108. package/dist/types/elements/tt/SwcChooseTemplate.d.ts +0 -1
  109. package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +0 -1
  110. package/dist/types/elements/tt/SwcIf.d.ts +0 -1
  111. package/dist/types/elements/tt/SwcIf.d.ts.map +0 -1
  112. package/dist/types/elements/tt/SwcIfTemplate.d.ts +0 -1
  113. package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +0 -1
  114. package/dist/types/elements/tt/SwcLoop.d.ts +0 -1
  115. package/dist/types/elements/tt/SwcLoop.d.ts.map +0 -1
  116. package/dist/types/elements/tt/SwcLoopTemplate.d.ts +0 -1
  117. package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +0 -1
  118. package/dist/types/elements/tt/SwcSubTemplates.d.ts +0 -1
  119. package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +0 -1
  120. package/dist/types/elements/tt/register.d.ts +0 -1
  121. package/dist/types/elements/tt/register.d.ts.map +0 -1
  122. package/src/elements/tt/SwcAppMixin.ts +0 -13
  123. package/src/elements/tt/SwcAsync.ts +0 -139
  124. package/src/elements/tt/SwcAsyncTemplate.ts +0 -126
  125. package/src/elements/tt/SwcChoose.ts +0 -182
  126. package/src/elements/tt/SwcChooseTemplate.ts +0 -229
  127. package/src/elements/tt/SwcIf.ts +0 -145
  128. package/src/elements/tt/SwcIfTemplate.ts +0 -158
  129. package/src/elements/tt/SwcLoop.ts +0 -222
  130. package/src/elements/tt/SwcLoopTemplate.ts +0 -255
  131. package/src/elements/tt/SwcSubTemplates.ts +0 -6
  132. package/src/elements/tt/register.ts +0 -720
@@ -10661,15 +10661,27 @@ var src_default = {
10661
10661
 
10662
10662
  // src/decorators/addEventListener.ts
10663
10663
  var ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
10664
- function addEventListener(selectorOrTarget, type, options = {}) {
10664
+ function addEventListener(selectorOrType, typeOrOptions, maybeOptions) {
10665
10665
  return (targetObj, propertyKey, descriptor) => {
10666
+ let selector;
10667
+ let type;
10668
+ let opts = {};
10669
+ if (typeof typeOrOptions === "string") {
10670
+ selector = selectorOrType;
10671
+ type = typeOrOptions;
10672
+ opts = maybeOptions ?? {};
10673
+ } else {
10674
+ selector = "$this";
10675
+ type = selectorOrType;
10676
+ opts = typeOrOptions ?? {};
10677
+ }
10666
10678
  const constructor = targetObj.constructor;
10667
10679
  let listeners = ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
10668
10680
  if (!listeners) {
10669
10681
  listeners = [];
10670
10682
  ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);
10671
10683
  }
10672
- listeners.push({ propertyKey, selector: selectorOrTarget, type, options });
10684
+ listeners.push({ propertyKey, selector, type, options: opts });
10673
10685
  };
10674
10686
  }
10675
10687
  function addEventListenerDelegateLightDom(selector, type, options) {
@@ -10684,11 +10696,15 @@ function addEventListenerDelegateAllDom(selector, type, options) {
10684
10696
  function addEventListenerDelegate(selector, type, options) {
10685
10697
  return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
10686
10698
  }
10687
- var event = addEventListener;
10688
- var eventDelegateLightDom = addEventListenerDelegateLightDom;
10689
- var eventDelegateShadowDom = addEventListenerDelegateShadowDom;
10690
- var eventDelegateAllDom = addEventListenerDelegateAllDom;
10691
- var eventDelegate = addEventListenerDelegate;
10699
+ function addEventListenerLightDom(selector, type, options) {
10700
+ return addEventListener(selector, type, { ...options ?? {}, root: "light" });
10701
+ }
10702
+ function addEventListenerShadowDom(selector, type, options) {
10703
+ return addEventListener(selector, type, { ...options ?? {}, root: "shadow" });
10704
+ }
10705
+ function addEventListenerAllDom(selector, type, options) {
10706
+ return addEventListener(selector, type, { ...options ?? {}, root: "all" });
10707
+ }
10692
10708
  function addEventListenerThis(type, options) {
10693
10709
  return addEventListener("$this", type, options);
10694
10710
  }
@@ -10701,11 +10717,167 @@ function addEventListenerWindow(type, options) {
10701
10717
  function addEventListenerDocument(type, options) {
10702
10718
  return addEventListener("$document", type, options);
10703
10719
  }
10720
+ var event = addEventListener;
10721
+ var eventDelegateLightDom = addEventListenerDelegateLightDom;
10722
+ var eventDelegateShadowDom = addEventListenerDelegateShadowDom;
10723
+ var eventDelegateAllDom = addEventListenerDelegateAllDom;
10724
+ var eventDelegate = addEventListenerDelegate;
10725
+ var eventLightDom = addEventListenerLightDom;
10726
+ var eventShadowDom = addEventListenerShadowDom;
10727
+ var eventAllDom = addEventListenerAllDom;
10728
+ var eventAppHost = addEventListenerAppHost;
10729
+ var eventWindow = addEventListenerWindow;
10730
+ var eventDocument = addEventListenerDocument;
10731
+ var eventThis = addEventListenerThis;
10704
10732
  var getAddEventListenerMetadata = (target) => {
10705
10733
  const constructor = target instanceof Function ? target : target.constructor;
10706
10734
  return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
10707
10735
  };
10708
10736
 
10737
+ // src/decorators/mutationObserver.ts
10738
+ var MUTATION_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:mutation-observer");
10739
+ function mutationObserver(selectorOrOptions, maybeOptions) {
10740
+ return (targetObj, propertyKey, descriptor) => {
10741
+ let selector = "$this";
10742
+ let options = {};
10743
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10744
+ selector = selectorOrOptions;
10745
+ options = maybeOptions ?? {};
10746
+ } else {
10747
+ selector = "$this";
10748
+ options = selectorOrOptions ?? {};
10749
+ }
10750
+ const constructor = targetObj.constructor;
10751
+ let observers = ReflectUtils.getMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor);
10752
+ if (!observers) {
10753
+ observers = [];
10754
+ ReflectUtils.defineMetadata(MUTATION_OBSERVER_METADATA_KEY, observers, constructor);
10755
+ }
10756
+ observers.push({ propertyKey, selector, options });
10757
+ };
10758
+ }
10759
+ function mutationObserverThis(options) {
10760
+ return mutationObserver("$this", options);
10761
+ }
10762
+ function mutationObserverDelegateLight(selectorOrOptions, maybeOptions) {
10763
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10764
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "light", delegate: true });
10765
+ }
10766
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "light", delegate: true });
10767
+ }
10768
+ function mutationObserverDelegateShadow(selectorOrOptions, maybeOptions) {
10769
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10770
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "shadow", delegate: true });
10771
+ }
10772
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "shadow", delegate: true });
10773
+ }
10774
+ function mutationObserverDelegateAll(selectorOrOptions, maybeOptions) {
10775
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10776
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "all", delegate: true });
10777
+ }
10778
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "all", delegate: true });
10779
+ }
10780
+ function mutationObserverDelegate(selectorOrOptions, maybeOptions) {
10781
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10782
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "auto", delegate: true });
10783
+ }
10784
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "auto", delegate: true });
10785
+ }
10786
+ function mutationObserverLight(selectorOrOptions, maybeOptions) {
10787
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10788
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "light" });
10789
+ }
10790
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "light" });
10791
+ }
10792
+ function mutationObserverShadow(selectorOrOptions, maybeOptions) {
10793
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10794
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "shadow" });
10795
+ }
10796
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "shadow" });
10797
+ }
10798
+ function mutationObserverAll(selectorOrOptions, maybeOptions) {
10799
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10800
+ return mutationObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "all" });
10801
+ }
10802
+ return mutationObserver({ ...selectorOrOptions ?? {}, root: "all" });
10803
+ }
10804
+ function getMutationObserverMetadata(target) {
10805
+ const constructor = target instanceof Function ? target : target.constructor;
10806
+ return ReflectUtils.getMetadata(MUTATION_OBSERVER_METADATA_KEY, constructor);
10807
+ }
10808
+
10809
+ // src/decorators/resizeObserver.ts
10810
+ var RESIZE_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:resize-observer");
10811
+ function resizeObserver(selectorOrOptions, maybeOptions) {
10812
+ return (targetObj, propertyKey, descriptor) => {
10813
+ let selector = "$this";
10814
+ let options = {};
10815
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10816
+ selector = selectorOrOptions;
10817
+ options = maybeOptions ?? {};
10818
+ } else {
10819
+ selector = "$this";
10820
+ options = selectorOrOptions ?? {};
10821
+ }
10822
+ const constructor = targetObj.constructor;
10823
+ let observers = ReflectUtils.getMetadata(RESIZE_OBSERVER_METADATA_KEY, constructor);
10824
+ if (!observers) {
10825
+ observers = [];
10826
+ ReflectUtils.defineMetadata(RESIZE_OBSERVER_METADATA_KEY, observers, constructor);
10827
+ }
10828
+ observers.push({ propertyKey, selector, options });
10829
+ };
10830
+ }
10831
+ function resizeObserverThis(options) {
10832
+ return resizeObserver("$this", options);
10833
+ }
10834
+ function resizeObserverDelegateLight(selectorOrOptions, maybeOptions) {
10835
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10836
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "light", delegate: true });
10837
+ }
10838
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "light", delegate: true });
10839
+ }
10840
+ function resizeObserverDelegateShadow(selectorOrOptions, maybeOptions) {
10841
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10842
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "shadow", delegate: true });
10843
+ }
10844
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "shadow", delegate: true });
10845
+ }
10846
+ function resizeObserverDelegateAll(selectorOrOptions, maybeOptions) {
10847
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10848
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "all", delegate: true });
10849
+ }
10850
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "all", delegate: true });
10851
+ }
10852
+ function resizeObserverDelegate(selectorOrOptions, maybeOptions) {
10853
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10854
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "auto", delegate: true });
10855
+ }
10856
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "auto", delegate: true });
10857
+ }
10858
+ function resizeObserverLight(selectorOrOptions, maybeOptions) {
10859
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10860
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "light" });
10861
+ }
10862
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "light" });
10863
+ }
10864
+ function resizeObserverShadow(selectorOrOptions, maybeOptions) {
10865
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10866
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "shadow" });
10867
+ }
10868
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "shadow" });
10869
+ }
10870
+ function resizeObserverAll(selectorOrOptions, maybeOptions) {
10871
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10872
+ return resizeObserver(selectorOrOptions, { ...maybeOptions ?? {}, root: "all" });
10873
+ }
10874
+ return resizeObserver({ ...selectorOrOptions ?? {}, root: "all" });
10875
+ }
10876
+ function getResizeObserverMetadata(target) {
10877
+ const constructor = target instanceof Function ? target : target.constructor;
10878
+ return ReflectUtils.getMetadata(RESIZE_OBSERVER_METADATA_KEY, constructor);
10879
+ }
10880
+
10709
10881
  // ../core/dist/esm/message/operators/debounceTime.js
10710
10882
  function debounceTime(duration, config) {
10711
10883
  return (source) => {
@@ -13960,6 +14132,15 @@ var getQueryMetadata = (target) => {
13960
14132
  const constructor = target instanceof Function ? target : target.constructor;
13961
14133
  return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor) ?? [];
13962
14134
  };
14135
+ function queryShadow(selector, options) {
14136
+ return query(selector, { ...options ?? {}, root: "shadow" });
14137
+ }
14138
+ function queryLight(selector, options) {
14139
+ return query(selector, { ...options ?? {}, root: "light" });
14140
+ }
14141
+ function queryAllRoots(selector, options) {
14142
+ return query(selector, { ...options ?? {}, root: "all" });
14143
+ }
13963
14144
 
13964
14145
  // src/decorators/queryAll.ts
13965
14146
  var QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
@@ -14535,7 +14716,6 @@ var ensureInit = (inst) => {
14535
14716
  if (!inst.__swc_initialized) {
14536
14717
  inst._swcId = inst?.getAttribute?.("swc-use-ssr") ?? "s" + Math.random().toString(36).substring(2, 11).toLowerCase();
14537
14718
  inst._emitHandlers = /* @__PURE__ */ new Map();
14538
- inst._boundListeners = [];
14539
14719
  inst.__swc_initialized = true;
14540
14720
  const target = inst instanceof Function ? inst : inst.constructor;
14541
14721
  const attributeAllList = findAllAttributeMetadata(target).filter((it) => it.type === "property");
@@ -14737,6 +14917,8 @@ var elementDefine = (name, config = {}) => (constructor) => {
14737
14917
  const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
14738
14918
  const emitHostCustomEventList = emitCustomEventList.filter((meta) => meta.selector === "$this" || meta.selector === "");
14739
14919
  const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
14920
+ const mutationObserverList = getMutationObserverMetadata(constructor) || [];
14921
+ const resizeObserverList = getResizeObserverMetadata(constructor) || [];
14740
14922
  const attrChangeMap = findAllAttributeChangedMetadata(constructor);
14741
14923
  const attributeList = findAllAttributeMetadata(constructor);
14742
14924
  const applyAttributeMap = findAllAttributeApplyMetadata(constructor);
@@ -14749,9 +14931,18 @@ var elementDefine = (name, config = {}) => (constructor) => {
14749
14931
  const proto = constructor.prototype;
14750
14932
  setupPrototype(proto, win);
14751
14933
  let helperHostSet = null;
14934
+ let boundListeners = [];
14935
+ let shadowMutationObserver = null;
14936
+ let lightMutationObserver = null;
14937
+ let resizeObserver2 = null;
14938
+ let resizeObservers = [];
14939
+ let removeObserverCallbacks = [];
14752
14940
  const originalConnected = proto.connectedCallback;
14753
14941
  proto.connectedCallback = async function() {
14754
14942
  ensureInit(this);
14943
+ boundListeners = [];
14944
+ resizeObservers = [];
14945
+ removeObserverCallbacks = [];
14755
14946
  helperHostSet = SwcUtils.getHelperAndHostSet(win, this);
14756
14947
  const appHost = helperHostSet.$appHost;
14757
14948
  const useSsr = isSSR(this);
@@ -14880,7 +15071,13 @@ var elementDefine = (name, config = {}) => (constructor) => {
14880
15071
  }
14881
15072
  };
14882
15073
  br.addEventListener(type, unifiedHandler, opts);
14883
- this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
15074
+ const onRemoves = [];
15075
+ for (const m of sortedMetaList) {
15076
+ if (m.options.removeListener) {
15077
+ onRemoves.push({ fn: m.options.removeListener, opts: m.options });
15078
+ }
15079
+ }
15080
+ boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts, onRemoves });
14884
15081
  });
14885
15082
  });
14886
15083
  nonDelegateListeners.forEach((meta) => {
@@ -14980,9 +15177,181 @@ var elementDefine = (name, config = {}) => (constructor) => {
14980
15177
  eventSubject.next(event2);
14981
15178
  };
14982
15179
  t.addEventListener(type, wrappedHandler, opts);
14983
- this._boundListeners.push({ target: t, type, handler: wrappedHandler, options: opts, subscription });
15180
+ const onRemoves = options.removeListener ? [{ fn: options.removeListener, opts }] : [];
15181
+ boundListeners.push({ target: t, type, handler: wrappedHandler, options: opts, subscription, onRemoves });
14984
15182
  });
14985
15183
  });
15184
+ shadowMutationObserver = null;
15185
+ lightMutationObserver = null;
15186
+ resizeObserver2 = null;
15187
+ if (resizeObserverList.length > 0) {
15188
+ const root2 = this.shadowRoot || this;
15189
+ resizeObserver2 = new ResizeObserver((entries, obs) => {
15190
+ for (const m of resizeObserverList) {
15191
+ let matchedEls = [];
15192
+ if (m.options.delegate && typeof m.selector === "string") {
15193
+ const isThis = m.selector === "$this" || m.selector === "";
15194
+ const matchesSel = (node) => {
15195
+ if (!node || node.nodeType !== 1) return false;
15196
+ if (isThis) return true;
15197
+ const el = node;
15198
+ return el.matches?.(m.selector) || !!el.closest?.(m.selector);
15199
+ };
15200
+ matchedEls = entries.map((e) => e.target).filter(matchesSel);
15201
+ } else {
15202
+ matchedEls = entries.map((e) => e.target).filter((t) => t && t.nodeType === 1);
15203
+ }
15204
+ if (matchedEls.length === 0) continue;
15205
+ if (m.options.filter) {
15206
+ const helper = SwcUtils.getHelperAndHostSet(currentWin, this);
15207
+ if (!m.options.filter(matchedEls, { currentThis: this, helper })) continue;
15208
+ }
15209
+ const hostSet = SwcUtils.getHostSet(this);
15210
+ this[m.propertyKey](matchedEls, entries, obs, { ...hostSet, $root: root2 });
15211
+ }
15212
+ });
15213
+ resizeObservers.push(resizeObserver2);
15214
+ for (const m of resizeObserverList) {
15215
+ if (m.options.removeObserver) {
15216
+ removeObserverCallbacks.push({ fn: m.options.removeObserver, target: root2, opts: m.options });
15217
+ }
15218
+ }
15219
+ }
15220
+ const shadowMetas = mutationObserverList.filter((m) => {
15221
+ const r = m.options.root || "auto";
15222
+ return this.shadowRoot && (r === "shadow" || r === "all" || r === "auto");
15223
+ });
15224
+ const lightMetas = mutationObserverList.filter((m) => {
15225
+ const r = m.options.root || "auto";
15226
+ return r === "light" || r === "all" || !this.shadowRoot && r === "auto";
15227
+ });
15228
+ const setupMutationObserver = (root2, metas, resizeDelegates = []) => {
15229
+ if (metas.length === 0) return null;
15230
+ const initFrom = (o) => {
15231
+ const init = {
15232
+ childList: o.childList,
15233
+ attributes: o.attributes,
15234
+ characterData: o.characterData,
15235
+ subtree: o.subtree,
15236
+ attributeFilter: o.attributeFilter,
15237
+ attributeOldValue: o.attributeOldValue,
15238
+ characterDataOldValue: o.characterDataOldValue
15239
+ };
15240
+ if (!init.childList && !init.attributes && !init.characterData) init.childList = true;
15241
+ return init;
15242
+ };
15243
+ const observer = new MutationObserver((mutations, obs) => {
15244
+ for (const meta of metas) {
15245
+ const { selector, options } = meta;
15246
+ let matchedEls = [];
15247
+ if (options.delegate && typeof selector === "string") {
15248
+ const isThis = selector === "$this" || selector === "";
15249
+ const matchesSel = (node) => {
15250
+ if (!node || node.nodeType !== 1) return false;
15251
+ if (isThis) return true;
15252
+ const el = node;
15253
+ return el.matches?.(selector) || !!el.closest?.(selector);
15254
+ };
15255
+ matchedEls = mutations.flatMap((m) => {
15256
+ const els = [];
15257
+ if (matchesSel(m.target)) els.push(m.target);
15258
+ Array.from(m.addedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
15259
+ Array.from(m.removedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
15260
+ return els;
15261
+ });
15262
+ } else if (typeof selector === "string") {
15263
+ const isThis = selector === "$this" || selector === "";
15264
+ const matchesSel = (node) => {
15265
+ if (!node || node.nodeType !== 1) return false;
15266
+ if (isThis) return true;
15267
+ return node.matches?.(selector);
15268
+ };
15269
+ matchedEls = mutations.flatMap((m) => {
15270
+ const els = [];
15271
+ if (matchesSel(m.target)) els.push(m.target);
15272
+ Array.from(m.addedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
15273
+ Array.from(m.removedNodes || []).filter(matchesSel).forEach((n) => els.push(n));
15274
+ return els;
15275
+ });
15276
+ } else {
15277
+ matchedEls = mutations.map((m) => m.target).filter((t) => t && t.nodeType === 1);
15278
+ }
15279
+ if (matchedEls.length === 0) continue;
15280
+ if (options.filter) {
15281
+ const helper = SwcUtils.getHelperAndHostSet(currentWin, this);
15282
+ if (!options.filter(matchedEls, { currentThis: this, helper })) continue;
15283
+ }
15284
+ const hostSet = SwcUtils.getHostSet(this);
15285
+ this[meta.propertyKey](matchedEls, mutations, obs, { ...hostSet, $root: root2 });
15286
+ }
15287
+ if (resizeDelegates.length > 0 && resizeObserver2) {
15288
+ const handle = (n, observe) => {
15289
+ if (n.nodeType !== 1) return;
15290
+ const el = n;
15291
+ for (const m of resizeDelegates) {
15292
+ if (typeof m.selector !== "string") continue;
15293
+ const isThis = m.selector === "$this" || m.selector === "";
15294
+ const matchesSel = (node) => {
15295
+ if (!node || node.nodeType !== 1) return false;
15296
+ if (isThis) return true;
15297
+ const e = node;
15298
+ return e.matches?.(m.selector) || !!e.closest?.(m.selector);
15299
+ };
15300
+ if (matchesSel(el)) {
15301
+ if (observe) resizeObserver2.observe(el, m.options.box ? { box: m.options.box } : void 0);
15302
+ else resizeObserver2.unobserve(el);
15303
+ } else if (!isThis) {
15304
+ el.querySelectorAll(m.selector).forEach((sub) => {
15305
+ if (observe) resizeObserver2.observe(sub, m.options.box ? { box: m.options.box } : void 0);
15306
+ else resizeObserver2.unobserve(sub);
15307
+ });
15308
+ }
15309
+ }
15310
+ };
15311
+ for (const m of mutations) {
15312
+ Array.from(m.addedNodes || []).forEach((n) => handle(n, true));
15313
+ Array.from(m.removedNodes || []).forEach((n) => handle(n, false));
15314
+ }
15315
+ }
15316
+ });
15317
+ const hasDelegate = metas.some((m) => m.options.delegate) || resizeDelegates.some((m) => m.options.delegate);
15318
+ if (hasDelegate) {
15319
+ observer.observe(root2, { childList: true, subtree: true });
15320
+ }
15321
+ const nonDelegateMetas = metas.filter((m) => !m.options.delegate);
15322
+ for (const m of nonDelegateMetas) {
15323
+ const { selector, options } = m;
15324
+ const mInit = initFrom(options);
15325
+ if (typeof selector === "string") {
15326
+ if (selector === "$this" || selector === "") {
15327
+ observer.observe(root2, mInit);
15328
+ } else {
15329
+ root2.querySelectorAll(selector).forEach((el) => observer.observe(el, mInit));
15330
+ }
15331
+ } else if (typeof selector === "function") {
15332
+ observer.observe(root2, mInit);
15333
+ }
15334
+ }
15335
+ return observer;
15336
+ };
15337
+ const shadowResizeDelegateMetas = resizeObserverList.filter((m) => {
15338
+ if (!m.options.delegate) return false;
15339
+ const r = m.options.root || "auto";
15340
+ return this.shadowRoot && (r === "shadow" || r === "all" || r === "auto");
15341
+ });
15342
+ const lightResizeDelegateMetas = resizeObserverList.filter((m) => {
15343
+ if (!m.options.delegate) return false;
15344
+ const r = m.options.root || "auto";
15345
+ return r === "light" || r === "all" || !this.shadowRoot && r === "auto";
15346
+ });
15347
+ if (this.shadowRoot) shadowMutationObserver = setupMutationObserver(this.shadowRoot, shadowMetas, shadowResizeDelegateMetas);
15348
+ lightMutationObserver = setupMutationObserver(this, lightMetas, lightResizeDelegateMetas);
15349
+ for (const m of mutationObserverList) {
15350
+ if (m.options.removeObserver) {
15351
+ const rootForM = this.shadowRoot && (m.options.root === "shadow" || m.options.root === "all" || m.options.root === "auto" && this.shadowRoot) ? this.shadowRoot : this;
15352
+ removeObserverCallbacks.push({ fn: m.options.removeObserver, target: rootForM, opts: m.options });
15353
+ }
15354
+ }
14986
15355
  if (originalConnected) await originalConnected.apply(this);
14987
15356
  const aMethods = findAllOnConnectedAfterMetadata(this);
14988
15357
  for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
@@ -15017,15 +15386,44 @@ var elementDefine = (name, config = {}) => (constructor) => {
15017
15386
  this._executeSwcScript("swc-on-before-disconnected", helperHostSet);
15018
15387
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
15019
15388
  for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
15020
- if (this._boundListeners) {
15021
- this._boundListeners.forEach((l) => {
15389
+ if (boundListeners.length > 0) {
15390
+ boundListeners.forEach((l) => {
15022
15391
  l.target.removeEventListener(l.type, l.handler, l.options);
15023
15392
  if (l.subscription && typeof l.subscription.unsubscribe === "function") {
15024
15393
  l.subscription.unsubscribe();
15025
15394
  }
15395
+ if (Array.isArray(l.onRemoves)) {
15396
+ for (const r of l.onRemoves) {
15397
+ try {
15398
+ r.fn(l.target, r.opts);
15399
+ } catch (e) {
15400
+ console.error("[SWC] removeListener error:", e);
15401
+ }
15402
+ }
15403
+ }
15026
15404
  });
15027
- this._boundListeners = [];
15405
+ boundListeners = [];
15406
+ }
15407
+ const _obs = [shadowMutationObserver, lightMutationObserver, resizeObserver2, ...resizeObservers];
15408
+ for (const o of _obs) {
15409
+ try {
15410
+ o?.disconnect?.();
15411
+ } catch (e) {
15412
+ console.error("[SWC] observer disconnect error:", e);
15413
+ }
15414
+ }
15415
+ shadowMutationObserver = null;
15416
+ lightMutationObserver = null;
15417
+ resizeObserver2 = null;
15418
+ resizeObservers = [];
15419
+ for (const cb of removeObserverCallbacks) {
15420
+ try {
15421
+ cb.fn(cb.target, cb.opts);
15422
+ } catch (e) {
15423
+ console.error("[SWC] removeObserver error:", e);
15424
+ }
15028
15425
  }
15426
+ removeObserverCallbacks = [];
15029
15427
  new ElementApply(this, { id: this._swcId }).removeAllEventListener();
15030
15428
  if (originalDisconnected) originalDisconnected.apply(this);
15031
15429
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
@@ -19518,6 +19916,7 @@ export {
19518
19916
  EMIT_CUSTOM_EVENT_METADATA_KEY,
19519
19917
  HTML_TAG_ENTRIES,
19520
19918
  InjectSituationType2 as InjectSituationType,
19919
+ MUTATION_OBSERVER_METADATA_KEY,
19521
19920
  ON_ADD_EVENT_LISTENER_METADATA_KEY,
19522
19921
  ON_AFTER_ADOPTED_METADATA_KEY,
19523
19922
  ON_AFTER_CONNECTED_METADATA_KEY,
@@ -19534,6 +19933,7 @@ export {
19534
19933
  PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
19535
19934
  QUERY_ALL_METADATA_KEY,
19536
19935
  QUERY_METADATA_KEY,
19936
+ RESIZE_OBSERVER_METADATA_KEY,
19537
19937
  STATE_METADATA_KEY,
19538
19938
  STYLE_METADATA_KEY,
19539
19939
  SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
@@ -19555,12 +19955,15 @@ export {
19555
19955
  SwcUtils,
19556
19956
  addClass,
19557
19957
  addEventListener,
19958
+ addEventListenerAllDom,
19558
19959
  addEventListenerAppHost,
19559
19960
  addEventListenerDelegate,
19560
19961
  addEventListenerDelegateAllDom,
19561
19962
  addEventListenerDelegateLightDom,
19562
19963
  addEventListenerDelegateShadowDom,
19563
19964
  addEventListenerDocument,
19965
+ addEventListenerLightDom,
19966
+ addEventListenerShadowDom,
19564
19967
  addEventListenerThis,
19565
19968
  addEventListenerWindow,
19566
19969
  appendHtmlSlot,
@@ -19599,10 +20002,17 @@ export {
19599
20002
  emitCustomEvent,
19600
20003
  ensureInit,
19601
20004
  event,
20005
+ eventAllDom,
20006
+ eventAppHost,
19602
20007
  eventDelegate,
19603
20008
  eventDelegateAllDom,
19604
20009
  eventDelegateLightDom,
19605
20010
  eventDelegateShadowDom,
20011
+ eventDocument,
20012
+ eventLightDom,
20013
+ eventShadowDom,
20014
+ eventThis,
20015
+ eventWindow,
19606
20016
  findAllApplyNodeMetadata,
19607
20017
  findAllApplySlotMetadata,
19608
20018
  findAllAttributeApplyMetadata,
@@ -19622,9 +20032,11 @@ export {
19622
20032
  getChangedAttributeMetadata,
19623
20033
  getElementConfig,
19624
20034
  getEmitCustomEventMetadataList,
20035
+ getMutationObserverMetadata,
19625
20036
  getPublishSwcAppMessageMetadata,
19626
20037
  getQueryAllMetadata,
19627
20038
  getQueryMetadata,
20039
+ getResizeObserverMetadata,
19628
20040
  getSubscribeSwcAppMessageWhileConnectedMetadata,
19629
20041
  getSubscribeSwcAppRouteChangeWhileConnectedMetadata,
19630
20042
  html,
@@ -19651,6 +20063,15 @@ export {
19651
20063
  insertBeforeEndLight,
19652
20064
  insertBeforeEndShadow,
19653
20065
  isSSR,
20066
+ mutationObserver,
20067
+ mutationObserverAll,
20068
+ mutationObserverDelegate,
20069
+ mutationObserverDelegateAll,
20070
+ mutationObserverDelegateLight,
20071
+ mutationObserverDelegateShadow,
20072
+ mutationObserverLight,
20073
+ mutationObserverShadow,
20074
+ mutationObserverThis,
19654
20075
  onAdopted,
19655
20076
  onAdoptedAfter,
19656
20077
  onAdoptedBefore,
@@ -19673,6 +20094,9 @@ export {
19673
20094
  publishSwcAppMessage,
19674
20095
  query,
19675
20096
  queryAll,
20097
+ queryAllRoots,
20098
+ queryLight,
20099
+ queryShadow,
19676
20100
  receiveMessage,
19677
20101
  removeClass,
19678
20102
  removeSSRAttribute,
@@ -19682,6 +20106,15 @@ export {
19682
20106
  replaceChildrenLight,
19683
20107
  replaceChildrenSlot,
19684
20108
  replaceChildrenTextSlot,
20109
+ resizeObserver,
20110
+ resizeObserverAll,
20111
+ resizeObserverDelegate,
20112
+ resizeObserverDelegateAll,
20113
+ resizeObserverDelegateLight,
20114
+ resizeObserverDelegateShadow,
20115
+ resizeObserverLight,
20116
+ resizeObserverShadow,
20117
+ resizeObserverThis,
19685
20118
  resolveAttributeTargets,
19686
20119
  resolvePropertyTargets,
19687
20120
  setAttribute,