@dooboostore/simple-web-component 1.0.41 → 1.0.43

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 (95) hide show
  1. package/README.md +423 -68
  2. package/dist/cjs/decorators/addEventListener.js +10 -0
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +11 -2
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyClass.js +9 -2
  7. package/dist/cjs/decorators/applyClass.js.map +2 -2
  8. package/dist/cjs/decorators/applyNode.js +11 -2
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/applyProperty.js +10 -2
  11. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  12. package/dist/cjs/decorators/applySlot.js +11 -2
  13. package/dist/cjs/decorators/applySlot.js.map +2 -2
  14. package/dist/cjs/decorators/applyStyle.js +9 -2
  15. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  16. package/dist/cjs/decorators/elementDefine.js +9 -23
  17. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  18. package/dist/cjs/decorators/emitCustomEvent.js +2 -0
  19. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  20. package/dist/cjs/decorators/lifecycles.js +78 -21
  21. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  22. package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
  23. package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
  24. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +3 -1
  25. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  26. package/dist/cjs/elements/SwcAppMixin.js +4 -9
  27. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  28. package/dist/esm/decorators/addEventListener.js +10 -0
  29. package/dist/esm/decorators/addEventListener.js.map +2 -2
  30. package/dist/esm/decorators/applyAttribute.js +11 -2
  31. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  32. package/dist/esm/decorators/applyClass.js +9 -2
  33. package/dist/esm/decorators/applyClass.js.map +2 -2
  34. package/dist/esm/decorators/applyNode.js +11 -2
  35. package/dist/esm/decorators/applyNode.js.map +2 -2
  36. package/dist/esm/decorators/applyProperty.js +10 -2
  37. package/dist/esm/decorators/applyProperty.js.map +2 -2
  38. package/dist/esm/decorators/applySlot.js +11 -2
  39. package/dist/esm/decorators/applySlot.js.map +2 -2
  40. package/dist/esm/decorators/applyStyle.js +9 -2
  41. package/dist/esm/decorators/applyStyle.js.map +2 -2
  42. package/dist/esm/decorators/elementDefine.js +9 -23
  43. package/dist/esm/decorators/elementDefine.js.map +2 -2
  44. package/dist/esm/decorators/emitCustomEvent.js +2 -0
  45. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  46. package/dist/esm/decorators/lifecycles.js +78 -21
  47. package/dist/esm/decorators/lifecycles.js.map +2 -2
  48. package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
  49. package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
  50. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +3 -1
  51. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  52. package/dist/esm/elements/SwcAppMixin.js +4 -9
  53. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  54. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +216 -126
  55. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  56. package/dist/types/decorators/addEventListener.d.ts +5 -0
  57. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  58. package/dist/types/decorators/applyAttribute.d.ts +26 -0
  59. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  60. package/dist/types/decorators/applyClass.d.ts +6 -0
  61. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  62. package/dist/types/decorators/applyNode.d.ts +6 -0
  63. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  64. package/dist/types/decorators/applyProperty.d.ts +26 -0
  65. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  66. package/dist/types/decorators/applySlot.d.ts +6 -0
  67. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  68. package/dist/types/decorators/applyStyle.d.ts +6 -0
  69. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  70. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  71. package/dist/types/decorators/emitCustomEvent.d.ts +17 -0
  72. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  73. package/dist/types/decorators/lifecycles.d.ts +25 -11
  74. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  75. package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
  76. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  77. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +1 -1
  78. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  79. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  80. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +216 -126
  81. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  82. package/package.json +1 -3
  83. package/src/decorators/addEventListener.ts +7 -0
  84. package/src/decorators/applyAttribute.ts +58 -2
  85. package/src/decorators/applyClass.ts +24 -2
  86. package/src/decorators/applyNode.ts +26 -2
  87. package/src/decorators/applyProperty.ts +57 -2
  88. package/src/decorators/applySlot.ts +24 -10
  89. package/src/decorators/applyStyle.ts +24 -2
  90. package/src/decorators/elementDefine.ts +9 -23
  91. package/src/decorators/emitCustomEvent.ts +19 -0
  92. package/src/decorators/lifecycles.ts +120 -26
  93. package/src/decorators/publishSwcAppMessage.ts +71 -27
  94. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +6 -2
  95. package/src/elements/SwcAppMixin.ts +5 -11
@@ -1215,9 +1215,15 @@ var dooboostoreSimpleWebComponent = (() => {
1215
1215
  defineSwcAppNav: () => defineSwcAppNav,
1216
1216
  defineSwcAppSection: () => defineSwcAppSection,
1217
1217
  elementDefine: () => elementDefine,
1218
+ emit: () => emit,
1218
1219
  emitCustomEvent: () => emitCustomEvent,
1219
1220
  emitCustomEventThis: () => emitCustomEventThis,
1220
1221
  ensureInit: () => ensureInit,
1222
+ event: () => event,
1223
+ eventDelegate: () => eventDelegate,
1224
+ eventDelegateAllDom: () => eventDelegateAllDom,
1225
+ eventDelegateLightDom: () => eventDelegateLightDom,
1226
+ eventDelegateShadowDom: () => eventDelegateShadowDom,
1221
1227
  findAllApplyNodeMetadata: () => findAllApplyNodeMetadata,
1222
1228
  findAllApplySlotMetadata: () => findAllApplySlotMetadata,
1223
1229
  findAllAttributeApplyMetadata: () => findAllAttributeApplyMetadata,
@@ -1264,7 +1270,6 @@ var dooboostoreSimpleWebComponent = (() => {
1264
1270
  innerTextNodeThis: () => innerTextNodeThis,
1265
1271
  innerTextShadowNode: () => innerTextShadowNode,
1266
1272
  isSSR: () => isSSR,
1267
- onAddEventListener: () => onAddEventListener,
1268
1273
  onAdopted: () => onAdopted,
1269
1274
  onAdoptedAfter: () => onAdoptedAfter,
1270
1275
  onAdoptedBefore: () => onAdoptedBefore,
@@ -1284,6 +1289,7 @@ var dooboostoreSimpleWebComponent = (() => {
1284
1289
  prependTextSlot: () => prependTextSlot,
1285
1290
  property: () => property,
1286
1291
  propertyThis: () => propertyThis,
1292
+ publish: () => publish,
1287
1293
  publishSwcAppMessage: () => publishSwcAppMessage,
1288
1294
  query: () => query,
1289
1295
  queryAll: () => queryAll,
@@ -6545,6 +6551,11 @@ var dooboostoreSimpleWebComponent = (() => {
6545
6551
  function addEventListenerDelegate(selector, type, options) {
6546
6552
  return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
6547
6553
  }
6554
+ var event = addEventListener;
6555
+ var eventDelegateLightDom = addEventListenerDelegateLightDom;
6556
+ var eventDelegateShadowDom = addEventListenerDelegateShadowDom;
6557
+ var eventDelegateAllDom = addEventListenerDelegateAllDom;
6558
+ var eventDelegate = addEventListenerDelegate;
6548
6559
  function addEventListenerThis(type, options) {
6549
6560
  return addEventListener("$this", type, options);
6550
6561
  }
@@ -6609,27 +6620,52 @@ var dooboostoreSimpleWebComponent = (() => {
6609
6620
  decorator2(arg1 || {}, target, propertyKey);
6610
6621
  };
6611
6622
  }
6612
- function createLifecycleDecorator(metadataKey) {
6613
- return (target, propertyKey) => {
6614
- const constructor = target.constructor;
6615
- let list = ReflectUtils.getOwnMetadata(metadataKey, constructor);
6616
- if (!list) {
6617
- list = [];
6618
- ReflectUtils.defineMetadata(metadataKey, list, constructor);
6623
+ function createLifecycleDecoratorWithOptions(metadataKey) {
6624
+ return function(optionOrTarget, propertyKey) {
6625
+ if (propertyKey) {
6626
+ const constructor = optionOrTarget.constructor;
6627
+ let list = ReflectUtils.getOwnMetadata(metadataKey, constructor);
6628
+ if (!list) {
6629
+ list = [];
6630
+ ReflectUtils.defineMetadata(metadataKey, list, constructor);
6631
+ }
6632
+ list.push({ propertyKey, order: 0 });
6633
+ return;
6619
6634
  }
6620
- list.push(propertyKey);
6635
+ return (target, propertyKey2) => {
6636
+ const constructor = target.constructor;
6637
+ let list = ReflectUtils.getOwnMetadata(metadataKey, constructor);
6638
+ if (!list) {
6639
+ list = [];
6640
+ ReflectUtils.defineMetadata(metadataKey, list, constructor);
6641
+ }
6642
+ list.push({ propertyKey: propertyKey2, order: optionOrTarget?.order ?? 0 });
6643
+ };
6621
6644
  };
6622
6645
  }
6623
- var onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);
6624
- var onDisconnectedBefore = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);
6625
- var onDisconnectedAfter = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);
6646
+ function onInitialize(optionOrTarget, propertyKey) {
6647
+ return createLifecycleDecoratorWithOptions(ON_INITIALIZE_METADATA_KEY)(optionOrTarget, propertyKey);
6648
+ }
6649
+ function onDisconnectedBefore(optionOrTarget, propertyKey) {
6650
+ return createLifecycleDecoratorWithOptions(ON_BEFORE_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);
6651
+ }
6652
+ function onDisconnectedAfter(optionOrTarget, propertyKey) {
6653
+ return createLifecycleDecoratorWithOptions(ON_AFTER_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);
6654
+ }
6626
6655
  var onDisconnected = onDisconnectedAfter;
6627
- var onAdoptedBefore = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);
6628
- var onAdoptedAfter = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
6656
+ function onAdoptedBefore(optionOrTarget, propertyKey) {
6657
+ return createLifecycleDecoratorWithOptions(ON_BEFORE_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);
6658
+ }
6659
+ function onAdoptedAfter(optionOrTarget, propertyKey) {
6660
+ return createLifecycleDecoratorWithOptions(ON_AFTER_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);
6661
+ }
6629
6662
  var onAdopted = onAdoptedAfter;
6630
- var onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
6631
- var onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
6632
- var onConnectedCompleted = createLifecycleDecorator(ON_CONNECTED_COMPLETED_METADATA_KEY);
6663
+ function onConnectedSwcApp(optionOrTarget, propertyKey) {
6664
+ return createLifecycleDecoratorWithOptions(ON_CONNECTED_SWC_APP_METADATA_KEY)(optionOrTarget, propertyKey);
6665
+ }
6666
+ function onConnectedCompleted(optionOrTarget, propertyKey) {
6667
+ return createLifecycleDecoratorWithOptions(ON_CONNECTED_COMPLETED_METADATA_KEY)(optionOrTarget, propertyKey);
6668
+ }
6633
6669
  var decorator = (options, target, propertyKey) => {
6634
6670
  const constructor = target.constructor;
6635
6671
  let list = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor);
@@ -6664,20 +6700,28 @@ var dooboostoreSimpleWebComponent = (() => {
6664
6700
  };
6665
6701
  }
6666
6702
  var findAllLifecycleMetadata = (target, metadataKey) => {
6667
- const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target) ?? [];
6668
- return results;
6703
+ const constructor = target instanceof Function ? target : target.constructor;
6704
+ const results = ReflectUtils.getOwnMetadata(metadataKey, constructor) ?? [];
6705
+ return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
6669
6706
  };
6670
6707
  var findAllOnConnectedMetadata = (target) => {
6671
6708
  const constructor = target instanceof Function ? target : target.constructor;
6672
- return ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
6709
+ const results = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
6710
+ return [...results].sort((a, b) => {
6711
+ const orderA = a.options?.order ?? 0;
6712
+ const orderB = b.options?.order ?? 0;
6713
+ return orderA - orderB;
6714
+ });
6673
6715
  };
6674
6716
  var findAllOnConnectedBeforeMetadata = (target) => {
6675
6717
  const constructor = target instanceof Function ? target : target.constructor;
6676
- return ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
6718
+ const results = ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
6719
+ return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
6677
6720
  };
6678
6721
  var findAllOnConnectedAfterMetadata = (target) => {
6679
6722
  const constructor = target instanceof Function ? target : target.constructor;
6680
- return ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
6723
+ const results = ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
6724
+ return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
6681
6725
  };
6682
6726
 
6683
6727
  // ../core-web/dist/esm/element/CanvasUtils.js
@@ -7686,7 +7730,7 @@ var dooboostoreSimpleWebComponent = (() => {
7686
7730
  };
7687
7731
  DocumentUtils2.eventObservable = (document2, type, options) => {
7688
7732
  return new Observable((subscriber) => {
7689
- const handler = (event) => subscriber.next(event);
7733
+ const handler = (event2) => subscriber.next(event2);
7690
7734
  window.addEventListener(type, handler, options);
7691
7735
  return () => {
7692
7736
  window.removeEventListener(type, handler, options);
@@ -7700,7 +7744,7 @@ var dooboostoreSimpleWebComponent = (() => {
7700
7744
  ((EventUtils2) => {
7701
7745
  EventUtils2.htmlElementEventObservable = (element, type, options) => {
7702
7746
  return new Observable((subscriber) => {
7703
- const handler = (event) => subscriber.next(event);
7747
+ const handler = (event2) => subscriber.next(event2);
7704
7748
  element.addEventListener(type, handler, options);
7705
7749
  return () => {
7706
7750
  element.removeEventListener(type, handler, options);
@@ -7714,7 +7758,7 @@ var dooboostoreSimpleWebComponent = (() => {
7714
7758
  ((WindowUtils2) => {
7715
7759
  WindowUtils2.eventObservable = (window2, type, options) => {
7716
7760
  return new Observable((subscriber) => {
7717
- const handler = (event) => subscriber.next(event);
7761
+ const handler = (event2) => subscriber.next(event2);
7718
7762
  window2.addEventListener(type, handler, options);
7719
7763
  return () => {
7720
7764
  window2.removeEventListener(type, handler, options);
@@ -8091,7 +8135,7 @@ var dooboostoreSimpleWebComponent = (() => {
8091
8135
  routeData = { ...this.getRouteData(), triggerPoint: "first-end" };
8092
8136
  this.behaviorSubject = new BehaviorSubject(routeData);
8093
8137
  }
8094
- this.config.window.addEventListener("popstate", (event) => {
8138
+ this.config.window.addEventListener("popstate", (event2) => {
8095
8139
  const routeData2 = { ...this.getRouteData(), triggerPoint: "end" };
8096
8140
  this.behaviorSubject.next(routeData2);
8097
8141
  });
@@ -8483,7 +8527,7 @@ var dooboostoreSimpleWebComponent = (() => {
8483
8527
  divideSize
8484
8528
  }) => {
8485
8529
  return new Observable((subscriber) => {
8486
- const handler = (event) => subscriber.next(event);
8530
+ const handler = (event2) => subscriber.next(event2);
8487
8531
  let fps2 = 0;
8488
8532
  const getDrawFpsGap = () => {
8489
8533
  return Math.floor(fps2 / divideSize);
@@ -9004,7 +9048,7 @@ var dooboostoreSimpleWebComponent = (() => {
9004
9048
  ensureInit(this);
9005
9049
  const res = original.apply(this, args);
9006
9050
  const handleResult = (detail) => {
9007
- const event = new CustomEvent(type, {
9051
+ const event2 = new CustomEvent(type, {
9008
9052
  detail,
9009
9053
  bubbles: fullOptions.bubbles,
9010
9054
  composed: fullOptions.composed,
@@ -9054,7 +9098,7 @@ var dooboostoreSimpleWebComponent = (() => {
9054
9098
  if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
9055
9099
  return;
9056
9100
  }
9057
- t.dispatchEvent(event);
9101
+ t.dispatchEvent(event2);
9058
9102
  });
9059
9103
  return detail;
9060
9104
  };
@@ -9070,6 +9114,7 @@ var dooboostoreSimpleWebComponent = (() => {
9070
9114
  const constructor = target instanceof Function ? target : target.constructor;
9071
9115
  return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
9072
9116
  };
9117
+ var emit = emitCustomEvent;
9073
9118
  function emitCustomEventThis(type, optionsOrAttributeaName) {
9074
9119
  if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
9075
9120
  return emitCustomEventThis(type, { attributeName: optionsOrAttributeaName });
@@ -9698,13 +9743,21 @@ var dooboostoreSimpleWebComponent = (() => {
9698
9743
  descriptor.value = function(...args) {
9699
9744
  ensureInit(this);
9700
9745
  const res = original.apply(this, args);
9746
+ const extractValue = (v) => {
9747
+ if (v && typeof v === "object" && PROPERTY_METADATA_KEY in v) {
9748
+ return v[PROPERTY_METADATA_KEY];
9749
+ }
9750
+ return v;
9751
+ };
9701
9752
  if (res instanceof Promise) {
9702
9753
  return res.then((v) => {
9703
- applyValueToTargets(this, v);
9754
+ const extracted = extractValue(v);
9755
+ applyValueToTargets(this, extracted);
9704
9756
  return v;
9705
9757
  });
9706
9758
  } else {
9707
- applyValueToTargets(this, res);
9759
+ const extracted = extractValue(res);
9760
+ applyValueToTargets(this, extracted);
9708
9761
  return res;
9709
9762
  }
9710
9763
  };
@@ -9826,16 +9879,14 @@ var dooboostoreSimpleWebComponent = (() => {
9826
9879
  const appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(inst);
9827
9880
  inst._executeSwcScript?.("swc-on-constructor", hostSet);
9828
9881
  const cMethods = findAllLifecycleMetadata(inst, ON_INITIALIZE_METADATA_KEY);
9829
- if (cMethods) {
9830
- for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
9831
- }
9882
+ for (const m of cMethods) inst._invokeLifecycleMethod(m.propertyKey, hostSet);
9832
9883
  }
9833
9884
  };
9834
9885
  var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
9835
- var handleGlobalSwcEvent = async (event) => {
9836
- if (event.__swc_handled) return;
9837
- const path = event.composedPath();
9838
- const type = event.type;
9886
+ var handleGlobalSwcEvent = async (event2) => {
9887
+ if (event2.__swc_handled) return;
9888
+ const path = event2.composedPath();
9889
+ const type = event2.type;
9839
9890
  const attrName = `swc-on-${type}`;
9840
9891
  for (const node of path) {
9841
9892
  if (!(node instanceof HTMLElement)) continue;
@@ -9843,8 +9894,8 @@ var dooboostoreSimpleWebComponent = (() => {
9843
9894
  if (script && !getElementConfig(node)) {
9844
9895
  const host = SwcUtils.findNearestSwcHostIncludingSelf(node);
9845
9896
  if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === "function") {
9846
- await host.__swc_executeAttributeEvent(node, attrName, script, event);
9847
- event.__swc_handled = true;
9897
+ await host.__swc_executeAttributeEvent(node, attrName, script, event2);
9898
+ event2.__swc_handled = true;
9848
9899
  break;
9849
9900
  }
9850
9901
  }
@@ -9933,14 +9984,14 @@ var dooboostoreSimpleWebComponent = (() => {
9933
9984
  }
9934
9985
  const oldHandler = handlers.get(attrName);
9935
9986
  if (oldHandler) el.removeEventListener(eventName, oldHandler);
9936
- const handler = async (event) => {
9987
+ const handler = async (event2) => {
9937
9988
  const hostSet = SwcUtils.getHostSet(el);
9938
9989
  const conf = getElementConfig(this);
9939
9990
  const currentWin = this._resolveWindow(conf);
9940
9991
  const helpers = SwcUtils.getHelperSet(currentWin);
9941
9992
  const args = {
9942
- event,
9943
- $data: event.detail,
9993
+ event: event2,
9994
+ $data: event2.detail,
9944
9995
  ...hostSet,
9945
9996
  ...helpers,
9946
9997
  $el: el,
@@ -9951,16 +10002,16 @@ var dooboostoreSimpleWebComponent = (() => {
9951
10002
  el.addEventListener(eventName, handler);
9952
10003
  handlers.set(attrName, handler);
9953
10004
  };
9954
- proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
10005
+ proto.__swc_executeAttributeEvent = async function(el, attrName, script, event2) {
9955
10006
  ensureInit(this);
9956
10007
  const hostSet = SwcUtils.getHostSet(el);
9957
10008
  const conf = getElementConfig(this);
9958
10009
  const currentWin = this._resolveWindow(conf);
9959
10010
  const currentHelpers = SwcUtils.getHelperSet(currentWin);
9960
- const detail = event.detail;
10011
+ const detail = event2.detail;
9961
10012
  const args = {
9962
- event,
9963
- $event: event,
10013
+ event: event2,
10014
+ $event: event2,
9964
10015
  $data: detail,
9965
10016
  $detail: detail,
9966
10017
  ...hostSet,
@@ -10019,9 +10070,7 @@ var dooboostoreSimpleWebComponent = (() => {
10019
10070
  const conf = getElementConfig(this);
10020
10071
  const currentWin = this._resolveWindow(conf);
10021
10072
  const bMethods = findAllOnConnectedBeforeMetadata(this).filter((it) => useSsr ? !it.options.ssrFirst : true);
10022
- if (bMethods) {
10023
- for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10024
- }
10073
+ for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10025
10074
  this._executeSwcScript("swc-on-before-connected", helperHostSet);
10026
10075
  const targetConnectedList = findAllOnConnectedMetadata(constructor).filter((it) => useSsr ? !it.options.ssrFirst : true);
10027
10076
  const shadowMode = conf?.useShadow || targetConnectedList.find((it) => it.options.useShadow)?.options.useShadow;
@@ -10113,24 +10162,24 @@ var dooboostoreSimpleWebComponent = (() => {
10113
10162
  const bStop = b.options.stopPropagation ? 1 : 0;
10114
10163
  return bStop - aStop;
10115
10164
  });
10116
- const unifiedHandler = async (event) => {
10165
+ const unifiedHandler = async (event2) => {
10117
10166
  for (const meta of sortedMetaList) {
10118
10167
  const { selector, options } = meta;
10119
- const matchedEl = event.target.closest(selector);
10168
+ const matchedEl = event2.target.closest(selector);
10120
10169
  if (matchedEl && br.contains(matchedEl)) {
10121
10170
  if (options.filter) {
10122
10171
  const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
10123
- if (!options.filter(event, helper)) {
10172
+ if (!options.filter(event2, helper)) {
10124
10173
  continue;
10125
10174
  }
10126
10175
  }
10127
- if (options.stopPropagation) event.stopPropagation();
10128
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
10129
- if (options.preventDefault) event.preventDefault();
10176
+ if (options.stopPropagation) event2.stopPropagation();
10177
+ if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
10178
+ if (options.preventDefault) event2.preventDefault();
10130
10179
  const currentHostSet = SwcUtils.getHostSet(this);
10131
- const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
10132
- await this[meta.propertyKey](event, { ...currentHostSet, $matchedElement: matchedEl }, args);
10133
- if (event.cancelBubble) break;
10180
+ const args = { event: event2, ...currentHostSet, $el: matchedEl, $root: br };
10181
+ await this[meta.propertyKey](event2, { ...currentHostSet, $matchedElement: matchedEl }, args);
10182
+ if (event2.cancelBubble) break;
10134
10183
  }
10135
10184
  }
10136
10185
  };
@@ -10178,19 +10227,19 @@ var dooboostoreSimpleWebComponent = (() => {
10178
10227
  });
10179
10228
  }
10180
10229
  bindTargets.forEach((t) => {
10181
- const handler = async (event) => {
10230
+ const handler = async (event2) => {
10182
10231
  if (options.filter) {
10183
10232
  const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
10184
- if (!options.filter(event, { currentThis: this, helper })) {
10233
+ if (!options.filter(event2, { currentThis: this, helper })) {
10185
10234
  return;
10186
10235
  }
10187
10236
  }
10188
- if (options.stopPropagation) event.stopPropagation();
10189
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
10190
- if (options.preventDefault) event.preventDefault();
10237
+ if (options.stopPropagation) event2.stopPropagation();
10238
+ if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
10239
+ if (options.preventDefault) event2.preventDefault();
10191
10240
  const currentHostSet = SwcUtils.getHostSet(this);
10192
- const args = { event, ...currentHostSet, $el: t, $root: t };
10193
- await this[meta.propertyKey](event, { currentHostSet, $$matchedElement: event.currentTarget }, args);
10241
+ const args = { event: event2, ...currentHostSet, $el: t, $root: t };
10242
+ await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
10194
10243
  };
10195
10244
  t.addEventListener(type, handler, opts);
10196
10245
  this._boundListeners.push({ target: t, type, handler, options: opts });
@@ -10200,9 +10249,7 @@ var dooboostoreSimpleWebComponent = (() => {
10200
10249
  const aMethods = findAllOnConnectedAfterMetadata(this).filter((it) => {
10201
10250
  return useSsr ? !it.options.ssrFirst : true;
10202
10251
  });
10203
- if (aMethods) {
10204
- for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10205
- }
10252
+ for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10206
10253
  this._executeSwcScript("swc-on-connected", helperHostSet);
10207
10254
  this._executeSwcScript("swc-on-after-connected", helperHostSet);
10208
10255
  this.__swc_connected = true;
@@ -10217,8 +10264,8 @@ var dooboostoreSimpleWebComponent = (() => {
10217
10264
  }
10218
10265
  }
10219
10266
  } finally {
10220
- for (let mPropertyKey of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {
10221
- await this._invokeLifecycleMethod(mPropertyKey, helperHostSet);
10267
+ for (let m of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {
10268
+ await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10222
10269
  }
10223
10270
  if (appHost && typeof appHost._connectedDone === "function") {
10224
10271
  await appHost._connectedDone(this);
@@ -10233,9 +10280,7 @@ var dooboostoreSimpleWebComponent = (() => {
10233
10280
  }
10234
10281
  this._executeSwcScript("swc-on-before-disconnected", helperHostSet);
10235
10282
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
10236
- if (bMethods) {
10237
- for (const m of bMethods) this._invokeLifecycleMethod(m, helperHostSet);
10238
- }
10283
+ for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10239
10284
  if (this._boundListeners) {
10240
10285
  this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
10241
10286
  this._boundListeners = [];
@@ -10243,9 +10288,7 @@ var dooboostoreSimpleWebComponent = (() => {
10243
10288
  new ElementApply(this, { id: this._swcId }).removeAllEventListener();
10244
10289
  if (originalDisconnected) originalDisconnected.apply(this);
10245
10290
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
10246
- if (aMethods) {
10247
- for (const m of aMethods) this._invokeLifecycleMethod(m, helperHostSet);
10248
- }
10291
+ for (const m of aMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10249
10292
  this._executeSwcScript("swc-on-disconnected", helperHostSet);
10250
10293
  this._executeSwcScript("swc-on-after-disconnected", helperHostSet);
10251
10294
  this.__swc_connected = false;
@@ -10255,14 +10298,10 @@ var dooboostoreSimpleWebComponent = (() => {
10255
10298
  const hostSet = SwcUtils.getHostSet(this);
10256
10299
  this._executeSwcScript("swc-on-before-adopted", hostSet);
10257
10300
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);
10258
- if (bMethods) {
10259
- for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
10260
- }
10301
+ for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, hostSet);
10261
10302
  if (originalAdopted) originalAdopted.apply(this);
10262
10303
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);
10263
- if (aMethods) {
10264
- for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
10265
- }
10304
+ for (const m of aMethods) this._invokeLifecycleMethod(m.propertyKey, hostSet);
10266
10305
  this._executeSwcScript("swc-on-adopted", hostSet);
10267
10306
  this._executeSwcScript("swc-on-after-adopted", hostSet);
10268
10307
  };
@@ -10455,13 +10494,22 @@ var dooboostoreSimpleWebComponent = (() => {
10455
10494
  descriptor.value = function(...args) {
10456
10495
  ensureInit(this);
10457
10496
  const res = original.apply(this, args);
10497
+ const extractValue = (v) => {
10498
+ const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;
10499
+ if (v && typeof v === "object" && keyToUse in v) {
10500
+ return v[keyToUse];
10501
+ }
10502
+ return v;
10503
+ };
10458
10504
  if (res instanceof Promise) {
10459
10505
  return res.then((v) => {
10460
- applyValueToTargets(this, v);
10506
+ const extracted = extractValue(v);
10507
+ applyValueToTargets(this, extracted);
10461
10508
  return v;
10462
10509
  });
10463
10510
  } else {
10464
- applyValueToTargets(this, res);
10511
+ const extracted = extractValue(res);
10512
+ applyValueToTargets(this, extracted);
10465
10513
  return res;
10466
10514
  }
10467
10515
  };
@@ -10605,6 +10653,13 @@ var dooboostoreSimpleWebComponent = (() => {
10605
10653
  };
10606
10654
  const targetEl = getTarget();
10607
10655
  const res = original.apply(this, args);
10656
+ const extractValue = (v) => {
10657
+ const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;
10658
+ if (v && typeof v === "object" && keyToUse in v) {
10659
+ return v[keyToUse];
10660
+ }
10661
+ return v;
10662
+ };
10608
10663
  const runApply = (target, val) => {
10609
10664
  const pos = options.position || "beforeEnd";
10610
10665
  const processedVal = val;
@@ -10619,12 +10674,14 @@ var dooboostoreSimpleWebComponent = (() => {
10619
10674
  }
10620
10675
  if (res instanceof Promise) {
10621
10676
  return res.then((finalRes) => {
10677
+ const extracted = extractValue(finalRes);
10622
10678
  fallbackNodes.forEach((it) => it.remove());
10623
- if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
10679
+ if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
10624
10680
  return finalRes;
10625
10681
  });
10626
10682
  } else {
10627
- if (res !== void 0 && targetEl) runApply(targetEl, res);
10683
+ const extracted = extractValue(res);
10684
+ if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
10628
10685
  return res;
10629
10686
  }
10630
10687
  };
@@ -10751,6 +10808,13 @@ var dooboostoreSimpleWebComponent = (() => {
10751
10808
  descriptor.value = function(...args) {
10752
10809
  ensureInit(this);
10753
10810
  const res = original.apply(this, args);
10811
+ const extractValue = (v) => {
10812
+ const keyToUse = finalOptions.valueKey ?? CLASS_METADATA_KEY;
10813
+ if (v && typeof v === "object" && keyToUse in v) {
10814
+ return v[keyToUse];
10815
+ }
10816
+ return v;
10817
+ };
10754
10818
  const handleResult = (resolvedValue) => {
10755
10819
  if (resolvedValue !== void 0) {
10756
10820
  const win = this.ownerDocument?.defaultView || window;
@@ -10830,9 +10894,9 @@ var dooboostoreSimpleWebComponent = (() => {
10830
10894
  return resolvedValue;
10831
10895
  };
10832
10896
  if (res instanceof Promise) {
10833
- return res.then(handleResult);
10897
+ return res.then((v) => handleResult(extractValue(v)));
10834
10898
  } else {
10835
- return handleResult(res);
10899
+ return handleResult(extractValue(res));
10836
10900
  }
10837
10901
  };
10838
10902
  return descriptor;
@@ -10882,6 +10946,13 @@ var dooboostoreSimpleWebComponent = (() => {
10882
10946
  descriptor.value = function(...args) {
10883
10947
  ensureInit(this);
10884
10948
  const res = original.apply(this, args);
10949
+ const extractValue = (v) => {
10950
+ const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;
10951
+ if (v && typeof v === "object" && keyToUse in v) {
10952
+ return v[keyToUse];
10953
+ }
10954
+ return v;
10955
+ };
10885
10956
  const handleResult = (resolvedValue) => {
10886
10957
  if (resolvedValue !== void 0) {
10887
10958
  const win = this.ownerDocument?.defaultView || window;
@@ -10947,9 +11018,9 @@ var dooboostoreSimpleWebComponent = (() => {
10947
11018
  return resolvedValue;
10948
11019
  };
10949
11020
  if (res instanceof Promise) {
10950
- return res.then(handleResult);
11021
+ return res.then((v) => handleResult(extractValue(v)));
10951
11022
  } else {
10952
- return handleResult(res);
11023
+ return handleResult(extractValue(res));
10953
11024
  }
10954
11025
  };
10955
11026
  return descriptor;
@@ -11017,7 +11088,9 @@ var dooboostoreSimpleWebComponent = (() => {
11017
11088
  }
11018
11089
  var getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
11019
11090
  const constructor = target instanceof Function ? target : target.constructor;
11020
- return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
11091
+ const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
11092
+ if (!results) return [];
11093
+ return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
11021
11094
  };
11022
11095
 
11023
11096
  // src/decorators/subscribeSwcAppMessageWhileConnected.ts
@@ -11060,7 +11133,7 @@ var dooboostoreSimpleWebComponent = (() => {
11060
11133
 
11061
11134
  // src/decorators/publishSwcAppMessage.ts
11062
11135
  var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
11063
- function createPublishSwcAppMessage(messageType) {
11136
+ function createPublishSwcAppMessage(messageType, options) {
11064
11137
  return (target, propertyKey, descriptor) => {
11065
11138
  const constructor = target.constructor;
11066
11139
  let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
@@ -11075,45 +11148,58 @@ var dooboostoreSimpleWebComponent = (() => {
11075
11148
  const originalMethod = descriptor.value;
11076
11149
  descriptor.value = function(...args) {
11077
11150
  const result = originalMethod.apply(this, args);
11078
- if (result instanceof Promise) {
11079
- result.then((data) => {
11080
- const appHost = SwcUtils.getAppHost(this);
11081
- if (appHost) {
11082
- appHost.publishMessage({
11083
- publisher: this,
11084
- data,
11085
- type: messageType
11086
- });
11087
- }
11088
- }).catch((err) => {
11089
- console.warn("publishSwcAppMessage async error:", err);
11090
- });
11091
- } else {
11151
+ const extractValue = (v) => {
11152
+ const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;
11153
+ if (v && typeof v === "object" && keyToUse in v) {
11154
+ return v[keyToUse];
11155
+ }
11156
+ return v;
11157
+ };
11158
+ const publishMessage = (data) => {
11092
11159
  const appHost = SwcUtils.getAppHost(this);
11093
11160
  if (appHost) {
11094
11161
  appHost.publishMessage({
11095
11162
  publisher: this,
11096
- data: result,
11163
+ data,
11097
11164
  type: messageType
11098
11165
  });
11099
11166
  }
11167
+ };
11168
+ if (result instanceof Promise) {
11169
+ result.then((data) => {
11170
+ const extracted = extractValue(data);
11171
+ publishMessage(extracted);
11172
+ }).catch((err) => {
11173
+ console.warn("publishSwcAppMessage async error:", err);
11174
+ });
11175
+ } else {
11176
+ const extracted = extractValue(result);
11177
+ publishMessage(extracted);
11100
11178
  }
11101
11179
  return result;
11102
11180
  };
11103
11181
  return descriptor;
11104
11182
  };
11105
11183
  }
11106
- function publishSwcAppMessage(targetOrMessageType, propertyKey, descriptor) {
11107
- if (targetOrMessageType && typeof targetOrMessageType === "object" && propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol") && descriptor) {
11108
- const target = targetOrMessageType;
11109
- return createPublishSwcAppMessage()(target, propertyKey, descriptor);
11184
+ function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions, descriptor) {
11185
+ if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && propertyKeyOrOptions && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") && descriptor) {
11186
+ const target = targetOrMessageTypeOrOptions;
11187
+ return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);
11110
11188
  }
11111
11189
  let messageType;
11112
- if (typeof targetOrMessageType === "string") {
11113
- messageType = targetOrMessageType;
11190
+ let options;
11191
+ if (typeof targetOrMessageTypeOrOptions === "string") {
11192
+ messageType = targetOrMessageTypeOrOptions;
11193
+ if (typeof propertyKeyOrOptions === "object" && propertyKeyOrOptions !== null) {
11194
+ options = propertyKeyOrOptions;
11195
+ }
11196
+ } else if (typeof targetOrMessageTypeOrOptions === "object" && targetOrMessageTypeOrOptions !== null) {
11197
+ options = targetOrMessageTypeOrOptions;
11198
+ messageType = options.messageType;
11114
11199
  }
11115
- return createPublishSwcAppMessage(messageType);
11200
+ return createPublishSwcAppMessage(messageType, options);
11116
11201
  }
11202
+ var publish = publishSwcAppMessage;
11117
11203
  var getPublishSwcAppMessageMetadata = (target) => {
11118
11204
  const constructor = target instanceof Function ? target : target.constructor;
11119
11205
  return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
@@ -11173,15 +11259,24 @@ var dooboostoreSimpleWebComponent = (() => {
11173
11259
  fallbackNodes.push(...nodes);
11174
11260
  applyToDom2(swcId, targetId, options.position, nodes);
11175
11261
  }
11262
+ const extractValue = (v) => {
11263
+ const keyToUse = options.valueKey ?? APPLY_SLOT_METADATA_KEY;
11264
+ if (v && typeof v === "object" && keyToUse in v) {
11265
+ return v[keyToUse];
11266
+ }
11267
+ return v;
11268
+ };
11176
11269
  let res = original.apply(this, args);
11177
11270
  if (res instanceof Promise) {
11178
11271
  return res.then((asyncRes) => {
11179
- const nodes = resToNodes(asyncRes);
11272
+ const extracted = extractValue(asyncRes);
11273
+ const nodes = resToNodes(extracted);
11180
11274
  fallbackNodes.forEach((it) => it.remove());
11181
11275
  applyToDom2(swcId, targetId, options.position, nodes);
11182
11276
  });
11183
11277
  } else {
11184
- const nodes = resToNodes(res);
11278
+ const extracted = extractValue(res);
11279
+ const nodes = resToNodes(extracted);
11185
11280
  applyToDom2(swcId, targetId, options.position, nodes);
11186
11281
  }
11187
11282
  };
@@ -13463,14 +13558,9 @@ var dooboostoreSimpleWebComponent = (() => {
13463
13558
  );
13464
13559
  try {
13465
13560
  const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
13466
- if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
13561
+ if (routeChangeSubscribers.length > 0) {
13467
13562
  console.log("[SWC-MIXIN] Route change subscribers found");
13468
- const sortedSubscribers = [...routeChangeSubscribers].sort((a, b) => {
13469
- const orderA = a.options?.order ?? 0;
13470
- const orderB = b.options?.order ?? 0;
13471
- return orderA - orderB;
13472
- });
13473
- for (const metadata of sortedSubscribers) {
13563
+ for (const metadata of routeChangeSubscribers) {
13474
13564
  const methodName = metadata.propertyKey;
13475
13565
  let pathPattern = metadata.options?.path;
13476
13566
  const filter = metadata.options?.filter;
@@ -13525,9 +13615,9 @@ var dooboostoreSimpleWebComponent = (() => {
13525
13615
  this._connectedInvocations++;
13526
13616
  }
13527
13617
  this._swc_connected_instance.add(instance);
13528
- const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY) ?? [];
13618
+ const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
13529
13619
  for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {
13530
- await instance?._invokeLifecycleMethod?.(connectedSwcAppCallBack);
13620
+ await instance?._invokeLifecycleMethod?.(connectedSwcAppCallBack.propertyKey);
13531
13621
  }
13532
13622
  if (this._childrenConnectedDoneInterval) {
13533
13623
  this.config.window.clearInterval(this._childrenConnectedDoneInterval);