@dooboostore/simple-web-component 1.0.42 → 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 (69) 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/emitCustomEvent.js +2 -0
  17. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  18. package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
  19. package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
  20. package/dist/esm/decorators/addEventListener.js +10 -0
  21. package/dist/esm/decorators/addEventListener.js.map +2 -2
  22. package/dist/esm/decorators/applyAttribute.js +11 -2
  23. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  24. package/dist/esm/decorators/applyClass.js +9 -2
  25. package/dist/esm/decorators/applyClass.js.map +2 -2
  26. package/dist/esm/decorators/applyNode.js +11 -2
  27. package/dist/esm/decorators/applyNode.js.map +2 -2
  28. package/dist/esm/decorators/applyProperty.js +10 -2
  29. package/dist/esm/decorators/applyProperty.js.map +2 -2
  30. package/dist/esm/decorators/applySlot.js +11 -2
  31. package/dist/esm/decorators/applySlot.js.map +2 -2
  32. package/dist/esm/decorators/applyStyle.js +9 -2
  33. package/dist/esm/decorators/applyStyle.js.map +2 -2
  34. package/dist/esm/decorators/emitCustomEvent.js +2 -0
  35. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  36. package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
  37. package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
  38. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +146 -71
  39. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  40. package/dist/types/decorators/addEventListener.d.ts +5 -0
  41. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  42. package/dist/types/decorators/applyAttribute.d.ts +26 -0
  43. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  44. package/dist/types/decorators/applyClass.d.ts +6 -0
  45. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  46. package/dist/types/decorators/applyNode.d.ts +6 -0
  47. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  48. package/dist/types/decorators/applyProperty.d.ts +26 -0
  49. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  50. package/dist/types/decorators/applySlot.d.ts +6 -0
  51. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  52. package/dist/types/decorators/applyStyle.d.ts +6 -0
  53. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  54. package/dist/types/decorators/emitCustomEvent.d.ts +17 -0
  55. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  56. package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
  57. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  58. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +146 -71
  59. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  60. package/package.json +7 -9
  61. package/src/decorators/addEventListener.ts +7 -0
  62. package/src/decorators/applyAttribute.ts +58 -2
  63. package/src/decorators/applyClass.ts +24 -2
  64. package/src/decorators/applyNode.ts +26 -2
  65. package/src/decorators/applyProperty.ts +57 -2
  66. package/src/decorators/applySlot.ts +24 -10
  67. package/src/decorators/applyStyle.ts +24 -2
  68. package/src/decorators/emitCustomEvent.ts +19 -0
  69. package/src/decorators/publishSwcAppMessage.ts +71 -27
@@ -6320,6 +6320,11 @@ function addEventListenerDelegateAllDom(selector, type, options) {
6320
6320
  function addEventListenerDelegate(selector, type, options) {
6321
6321
  return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
6322
6322
  }
6323
+ var event = addEventListener;
6324
+ var eventDelegateLightDom = addEventListenerDelegateLightDom;
6325
+ var eventDelegateShadowDom = addEventListenerDelegateShadowDom;
6326
+ var eventDelegateAllDom = addEventListenerDelegateAllDom;
6327
+ var eventDelegate = addEventListenerDelegate;
6323
6328
  function addEventListenerThis(type, options) {
6324
6329
  return addEventListener("$this", type, options);
6325
6330
  }
@@ -7494,7 +7499,7 @@ var DocumentUtils;
7494
7499
  };
7495
7500
  DocumentUtils2.eventObservable = (document2, type, options) => {
7496
7501
  return new Observable((subscriber) => {
7497
- const handler = (event) => subscriber.next(event);
7502
+ const handler = (event2) => subscriber.next(event2);
7498
7503
  window.addEventListener(type, handler, options);
7499
7504
  return () => {
7500
7505
  window.removeEventListener(type, handler, options);
@@ -7508,7 +7513,7 @@ var EventUtils;
7508
7513
  ((EventUtils2) => {
7509
7514
  EventUtils2.htmlElementEventObservable = (element, type, options) => {
7510
7515
  return new Observable((subscriber) => {
7511
- const handler = (event) => subscriber.next(event);
7516
+ const handler = (event2) => subscriber.next(event2);
7512
7517
  element.addEventListener(type, handler, options);
7513
7518
  return () => {
7514
7519
  element.removeEventListener(type, handler, options);
@@ -7522,7 +7527,7 @@ var WindowUtils;
7522
7527
  ((WindowUtils2) => {
7523
7528
  WindowUtils2.eventObservable = (window2, type, options) => {
7524
7529
  return new Observable((subscriber) => {
7525
- const handler = (event) => subscriber.next(event);
7530
+ const handler = (event2) => subscriber.next(event2);
7526
7531
  window2.addEventListener(type, handler, options);
7527
7532
  return () => {
7528
7533
  window2.removeEventListener(type, handler, options);
@@ -7899,7 +7904,7 @@ var Router = class {
7899
7904
  routeData = { ...this.getRouteData(), triggerPoint: "first-end" };
7900
7905
  this.behaviorSubject = new BehaviorSubject(routeData);
7901
7906
  }
7902
- this.config.window.addEventListener("popstate", (event) => {
7907
+ this.config.window.addEventListener("popstate", (event2) => {
7903
7908
  const routeData2 = { ...this.getRouteData(), triggerPoint: "end" };
7904
7909
  this.behaviorSubject.next(routeData2);
7905
7910
  });
@@ -8291,7 +8296,7 @@ var AnimationFrameUtils;
8291
8296
  divideSize
8292
8297
  }) => {
8293
8298
  return new Observable((subscriber) => {
8294
- const handler = (event) => subscriber.next(event);
8299
+ const handler = (event2) => subscriber.next(event2);
8295
8300
  let fps2 = 0;
8296
8301
  const getDrawFpsGap = () => {
8297
8302
  return Math.floor(fps2 / divideSize);
@@ -8812,7 +8817,7 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
8812
8817
  ensureInit(this);
8813
8818
  const res = original.apply(this, args);
8814
8819
  const handleResult = (detail) => {
8815
- const event = new CustomEvent(type, {
8820
+ const event2 = new CustomEvent(type, {
8816
8821
  detail,
8817
8822
  bubbles: fullOptions.bubbles,
8818
8823
  composed: fullOptions.composed,
@@ -8862,7 +8867,7 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
8862
8867
  if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
8863
8868
  return;
8864
8869
  }
8865
- t.dispatchEvent(event);
8870
+ t.dispatchEvent(event2);
8866
8871
  });
8867
8872
  return detail;
8868
8873
  };
@@ -8878,6 +8883,7 @@ var getEmitCustomEventMetadataList = (target) => {
8878
8883
  const constructor = target instanceof Function ? target : target.constructor;
8879
8884
  return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
8880
8885
  };
8886
+ var emit = emitCustomEvent;
8881
8887
  function emitCustomEventThis(type, optionsOrAttributeaName) {
8882
8888
  if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
8883
8889
  return emitCustomEventThis(type, { attributeName: optionsOrAttributeaName });
@@ -9506,13 +9512,21 @@ function applyProperty(selector, targetPropertyKeyOrOptions, options) {
9506
9512
  descriptor.value = function(...args) {
9507
9513
  ensureInit(this);
9508
9514
  const res = original.apply(this, args);
9515
+ const extractValue = (v) => {
9516
+ if (v && typeof v === "object" && PROPERTY_METADATA_KEY in v) {
9517
+ return v[PROPERTY_METADATA_KEY];
9518
+ }
9519
+ return v;
9520
+ };
9509
9521
  if (res instanceof Promise) {
9510
9522
  return res.then((v) => {
9511
- applyValueToTargets(this, v);
9523
+ const extracted = extractValue(v);
9524
+ applyValueToTargets(this, extracted);
9512
9525
  return v;
9513
9526
  });
9514
9527
  } else {
9515
- applyValueToTargets(this, res);
9528
+ const extracted = extractValue(res);
9529
+ applyValueToTargets(this, extracted);
9516
9530
  return res;
9517
9531
  }
9518
9532
  };
@@ -9638,10 +9652,10 @@ var ensureInit = (inst) => {
9638
9652
  }
9639
9653
  };
9640
9654
  var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
9641
- var handleGlobalSwcEvent = async (event) => {
9642
- if (event.__swc_handled) return;
9643
- const path = event.composedPath();
9644
- const type = event.type;
9655
+ var handleGlobalSwcEvent = async (event2) => {
9656
+ if (event2.__swc_handled) return;
9657
+ const path = event2.composedPath();
9658
+ const type = event2.type;
9645
9659
  const attrName = `swc-on-${type}`;
9646
9660
  for (const node of path) {
9647
9661
  if (!(node instanceof HTMLElement)) continue;
@@ -9649,8 +9663,8 @@ var handleGlobalSwcEvent = async (event) => {
9649
9663
  if (script && !getElementConfig(node)) {
9650
9664
  const host = SwcUtils.findNearestSwcHostIncludingSelf(node);
9651
9665
  if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === "function") {
9652
- await host.__swc_executeAttributeEvent(node, attrName, script, event);
9653
- event.__swc_handled = true;
9666
+ await host.__swc_executeAttributeEvent(node, attrName, script, event2);
9667
+ event2.__swc_handled = true;
9654
9668
  break;
9655
9669
  }
9656
9670
  }
@@ -9739,14 +9753,14 @@ var setupPrototype = (proto, win) => {
9739
9753
  }
9740
9754
  const oldHandler = handlers.get(attrName);
9741
9755
  if (oldHandler) el.removeEventListener(eventName, oldHandler);
9742
- const handler = async (event) => {
9756
+ const handler = async (event2) => {
9743
9757
  const hostSet = SwcUtils.getHostSet(el);
9744
9758
  const conf = getElementConfig(this);
9745
9759
  const currentWin = this._resolveWindow(conf);
9746
9760
  const helpers = SwcUtils.getHelperSet(currentWin);
9747
9761
  const args = {
9748
- event,
9749
- $data: event.detail,
9762
+ event: event2,
9763
+ $data: event2.detail,
9750
9764
  ...hostSet,
9751
9765
  ...helpers,
9752
9766
  $el: el,
@@ -9757,16 +9771,16 @@ var setupPrototype = (proto, win) => {
9757
9771
  el.addEventListener(eventName, handler);
9758
9772
  handlers.set(attrName, handler);
9759
9773
  };
9760
- proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
9774
+ proto.__swc_executeAttributeEvent = async function(el, attrName, script, event2) {
9761
9775
  ensureInit(this);
9762
9776
  const hostSet = SwcUtils.getHostSet(el);
9763
9777
  const conf = getElementConfig(this);
9764
9778
  const currentWin = this._resolveWindow(conf);
9765
9779
  const currentHelpers = SwcUtils.getHelperSet(currentWin);
9766
- const detail = event.detail;
9780
+ const detail = event2.detail;
9767
9781
  const args = {
9768
- event,
9769
- $event: event,
9782
+ event: event2,
9783
+ $event: event2,
9770
9784
  $data: detail,
9771
9785
  $detail: detail,
9772
9786
  ...hostSet,
@@ -9917,24 +9931,24 @@ var elementDefine = (name, config = {}) => (constructor) => {
9917
9931
  const bStop = b.options.stopPropagation ? 1 : 0;
9918
9932
  return bStop - aStop;
9919
9933
  });
9920
- const unifiedHandler = async (event) => {
9934
+ const unifiedHandler = async (event2) => {
9921
9935
  for (const meta of sortedMetaList) {
9922
9936
  const { selector, options } = meta;
9923
- const matchedEl = event.target.closest(selector);
9937
+ const matchedEl = event2.target.closest(selector);
9924
9938
  if (matchedEl && br.contains(matchedEl)) {
9925
9939
  if (options.filter) {
9926
9940
  const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
9927
- if (!options.filter(event, helper)) {
9941
+ if (!options.filter(event2, helper)) {
9928
9942
  continue;
9929
9943
  }
9930
9944
  }
9931
- if (options.stopPropagation) event.stopPropagation();
9932
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
9933
- if (options.preventDefault) event.preventDefault();
9945
+ if (options.stopPropagation) event2.stopPropagation();
9946
+ if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
9947
+ if (options.preventDefault) event2.preventDefault();
9934
9948
  const currentHostSet = SwcUtils.getHostSet(this);
9935
- const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
9936
- await this[meta.propertyKey](event, { ...currentHostSet, $matchedElement: matchedEl }, args);
9937
- if (event.cancelBubble) break;
9949
+ const args = { event: event2, ...currentHostSet, $el: matchedEl, $root: br };
9950
+ await this[meta.propertyKey](event2, { ...currentHostSet, $matchedElement: matchedEl }, args);
9951
+ if (event2.cancelBubble) break;
9938
9952
  }
9939
9953
  }
9940
9954
  };
@@ -9982,19 +9996,19 @@ var elementDefine = (name, config = {}) => (constructor) => {
9982
9996
  });
9983
9997
  }
9984
9998
  bindTargets.forEach((t) => {
9985
- const handler = async (event) => {
9999
+ const handler = async (event2) => {
9986
10000
  if (options.filter) {
9987
10001
  const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
9988
- if (!options.filter(event, { currentThis: this, helper })) {
10002
+ if (!options.filter(event2, { currentThis: this, helper })) {
9989
10003
  return;
9990
10004
  }
9991
10005
  }
9992
- if (options.stopPropagation) event.stopPropagation();
9993
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
9994
- if (options.preventDefault) event.preventDefault();
10006
+ if (options.stopPropagation) event2.stopPropagation();
10007
+ if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
10008
+ if (options.preventDefault) event2.preventDefault();
9995
10009
  const currentHostSet = SwcUtils.getHostSet(this);
9996
- const args = { event, ...currentHostSet, $el: t, $root: t };
9997
- await this[meta.propertyKey](event, { currentHostSet, $$matchedElement: event.currentTarget }, args);
10010
+ const args = { event: event2, ...currentHostSet, $el: t, $root: t };
10011
+ await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
9998
10012
  };
9999
10013
  t.addEventListener(type, handler, opts);
10000
10014
  this._boundListeners.push({ target: t, type, handler, options: opts });
@@ -10249,13 +10263,22 @@ function applyAttribute(selector, targetAttributeNameOrOptions, options) {
10249
10263
  descriptor.value = function(...args) {
10250
10264
  ensureInit(this);
10251
10265
  const res = original.apply(this, args);
10266
+ const extractValue = (v) => {
10267
+ const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;
10268
+ if (v && typeof v === "object" && keyToUse in v) {
10269
+ return v[keyToUse];
10270
+ }
10271
+ return v;
10272
+ };
10252
10273
  if (res instanceof Promise) {
10253
10274
  return res.then((v) => {
10254
- applyValueToTargets(this, v);
10275
+ const extracted = extractValue(v);
10276
+ applyValueToTargets(this, extracted);
10255
10277
  return v;
10256
10278
  });
10257
10279
  } else {
10258
- applyValueToTargets(this, res);
10280
+ const extracted = extractValue(res);
10281
+ applyValueToTargets(this, extracted);
10259
10282
  return res;
10260
10283
  }
10261
10284
  };
@@ -10399,6 +10422,13 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
10399
10422
  };
10400
10423
  const targetEl = getTarget();
10401
10424
  const res = original.apply(this, args);
10425
+ const extractValue = (v) => {
10426
+ const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;
10427
+ if (v && typeof v === "object" && keyToUse in v) {
10428
+ return v[keyToUse];
10429
+ }
10430
+ return v;
10431
+ };
10402
10432
  const runApply = (target, val) => {
10403
10433
  const pos = options.position || "beforeEnd";
10404
10434
  const processedVal = val;
@@ -10413,12 +10443,14 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
10413
10443
  }
10414
10444
  if (res instanceof Promise) {
10415
10445
  return res.then((finalRes) => {
10446
+ const extracted = extractValue(finalRes);
10416
10447
  fallbackNodes.forEach((it) => it.remove());
10417
- if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
10448
+ if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
10418
10449
  return finalRes;
10419
10450
  });
10420
10451
  } else {
10421
- if (res !== void 0 && targetEl) runApply(targetEl, res);
10452
+ const extracted = extractValue(res);
10453
+ if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
10422
10454
  return res;
10423
10455
  }
10424
10456
  };
@@ -10545,6 +10577,13 @@ function createClassDecorator(action) {
10545
10577
  descriptor.value = function(...args) {
10546
10578
  ensureInit(this);
10547
10579
  const res = original.apply(this, args);
10580
+ const extractValue = (v) => {
10581
+ const keyToUse = finalOptions.valueKey ?? CLASS_METADATA_KEY;
10582
+ if (v && typeof v === "object" && keyToUse in v) {
10583
+ return v[keyToUse];
10584
+ }
10585
+ return v;
10586
+ };
10548
10587
  const handleResult = (resolvedValue) => {
10549
10588
  if (resolvedValue !== void 0) {
10550
10589
  const win = this.ownerDocument?.defaultView || window;
@@ -10624,9 +10663,9 @@ function createClassDecorator(action) {
10624
10663
  return resolvedValue;
10625
10664
  };
10626
10665
  if (res instanceof Promise) {
10627
- return res.then(handleResult);
10666
+ return res.then((v) => handleResult(extractValue(v)));
10628
10667
  } else {
10629
- return handleResult(res);
10668
+ return handleResult(extractValue(res));
10630
10669
  }
10631
10670
  };
10632
10671
  return descriptor;
@@ -10676,6 +10715,13 @@ function createStyleDecorator(action) {
10676
10715
  descriptor.value = function(...args) {
10677
10716
  ensureInit(this);
10678
10717
  const res = original.apply(this, args);
10718
+ const extractValue = (v) => {
10719
+ const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;
10720
+ if (v && typeof v === "object" && keyToUse in v) {
10721
+ return v[keyToUse];
10722
+ }
10723
+ return v;
10724
+ };
10679
10725
  const handleResult = (resolvedValue) => {
10680
10726
  if (resolvedValue !== void 0) {
10681
10727
  const win = this.ownerDocument?.defaultView || window;
@@ -10741,9 +10787,9 @@ function createStyleDecorator(action) {
10741
10787
  return resolvedValue;
10742
10788
  };
10743
10789
  if (res instanceof Promise) {
10744
- return res.then(handleResult);
10790
+ return res.then((v) => handleResult(extractValue(v)));
10745
10791
  } else {
10746
- return handleResult(res);
10792
+ return handleResult(extractValue(res));
10747
10793
  }
10748
10794
  };
10749
10795
  return descriptor;
@@ -10856,7 +10902,7 @@ var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
10856
10902
 
10857
10903
  // src/decorators/publishSwcAppMessage.ts
10858
10904
  var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
10859
- function createPublishSwcAppMessage(messageType) {
10905
+ function createPublishSwcAppMessage(messageType, options) {
10860
10906
  return (target, propertyKey, descriptor) => {
10861
10907
  const constructor = target.constructor;
10862
10908
  let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
@@ -10871,45 +10917,58 @@ function createPublishSwcAppMessage(messageType) {
10871
10917
  const originalMethod = descriptor.value;
10872
10918
  descriptor.value = function(...args) {
10873
10919
  const result = originalMethod.apply(this, args);
10874
- if (result instanceof Promise) {
10875
- result.then((data) => {
10876
- const appHost = SwcUtils.getAppHost(this);
10877
- if (appHost) {
10878
- appHost.publishMessage({
10879
- publisher: this,
10880
- data,
10881
- type: messageType
10882
- });
10883
- }
10884
- }).catch((err) => {
10885
- console.warn("publishSwcAppMessage async error:", err);
10886
- });
10887
- } else {
10920
+ const extractValue = (v) => {
10921
+ const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;
10922
+ if (v && typeof v === "object" && keyToUse in v) {
10923
+ return v[keyToUse];
10924
+ }
10925
+ return v;
10926
+ };
10927
+ const publishMessage = (data) => {
10888
10928
  const appHost = SwcUtils.getAppHost(this);
10889
10929
  if (appHost) {
10890
10930
  appHost.publishMessage({
10891
10931
  publisher: this,
10892
- data: result,
10932
+ data,
10893
10933
  type: messageType
10894
10934
  });
10895
10935
  }
10936
+ };
10937
+ if (result instanceof Promise) {
10938
+ result.then((data) => {
10939
+ const extracted = extractValue(data);
10940
+ publishMessage(extracted);
10941
+ }).catch((err) => {
10942
+ console.warn("publishSwcAppMessage async error:", err);
10943
+ });
10944
+ } else {
10945
+ const extracted = extractValue(result);
10946
+ publishMessage(extracted);
10896
10947
  }
10897
10948
  return result;
10898
10949
  };
10899
10950
  return descriptor;
10900
10951
  };
10901
10952
  }
10902
- function publishSwcAppMessage(targetOrMessageType, propertyKey, descriptor) {
10903
- if (targetOrMessageType && typeof targetOrMessageType === "object" && propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol") && descriptor) {
10904
- const target = targetOrMessageType;
10905
- return createPublishSwcAppMessage()(target, propertyKey, descriptor);
10953
+ function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions, descriptor) {
10954
+ if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && propertyKeyOrOptions && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") && descriptor) {
10955
+ const target = targetOrMessageTypeOrOptions;
10956
+ return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);
10906
10957
  }
10907
10958
  let messageType;
10908
- if (typeof targetOrMessageType === "string") {
10909
- messageType = targetOrMessageType;
10959
+ let options;
10960
+ if (typeof targetOrMessageTypeOrOptions === "string") {
10961
+ messageType = targetOrMessageTypeOrOptions;
10962
+ if (typeof propertyKeyOrOptions === "object" && propertyKeyOrOptions !== null) {
10963
+ options = propertyKeyOrOptions;
10964
+ }
10965
+ } else if (typeof targetOrMessageTypeOrOptions === "object" && targetOrMessageTypeOrOptions !== null) {
10966
+ options = targetOrMessageTypeOrOptions;
10967
+ messageType = options.messageType;
10910
10968
  }
10911
- return createPublishSwcAppMessage(messageType);
10969
+ return createPublishSwcAppMessage(messageType, options);
10912
10970
  }
10971
+ var publish = publishSwcAppMessage;
10913
10972
  var getPublishSwcAppMessageMetadata = (target) => {
10914
10973
  const constructor = target instanceof Function ? target : target.constructor;
10915
10974
  return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
@@ -10969,15 +11028,24 @@ function applySlot(targetId, opt) {
10969
11028
  fallbackNodes.push(...nodes);
10970
11029
  applyToDom2(swcId, targetId, options.position, nodes);
10971
11030
  }
11031
+ const extractValue = (v) => {
11032
+ const keyToUse = options.valueKey ?? APPLY_SLOT_METADATA_KEY;
11033
+ if (v && typeof v === "object" && keyToUse in v) {
11034
+ return v[keyToUse];
11035
+ }
11036
+ return v;
11037
+ };
10972
11038
  let res = original.apply(this, args);
10973
11039
  if (res instanceof Promise) {
10974
11040
  return res.then((asyncRes) => {
10975
- const nodes = resToNodes(asyncRes);
11041
+ const extracted = extractValue(asyncRes);
11042
+ const nodes = resToNodes(extracted);
10976
11043
  fallbackNodes.forEach((it) => it.remove());
10977
11044
  applyToDom2(swcId, targetId, options.position, nodes);
10978
11045
  });
10979
11046
  } else {
10980
- const nodes = resToNodes(res);
11047
+ const extracted = extractValue(res);
11048
+ const nodes = resToNodes(extracted);
10981
11049
  applyToDom2(swcId, targetId, options.position, nodes);
10982
11050
  }
10983
11051
  };
@@ -13734,9 +13802,15 @@ export {
13734
13802
  defineSwcAppNav,
13735
13803
  defineSwcAppSection,
13736
13804
  elementDefine,
13805
+ emit,
13737
13806
  emitCustomEvent,
13738
13807
  emitCustomEventThis,
13739
13808
  ensureInit,
13809
+ event,
13810
+ eventDelegate,
13811
+ eventDelegateAllDom,
13812
+ eventDelegateLightDom,
13813
+ eventDelegateShadowDom,
13740
13814
  findAllApplyNodeMetadata,
13741
13815
  findAllApplySlotMetadata,
13742
13816
  findAllAttributeApplyMetadata,
@@ -13802,6 +13876,7 @@ export {
13802
13876
  prependTextSlot,
13803
13877
  property,
13804
13878
  propertyThis,
13879
+ publish,
13805
13880
  publishSwcAppMessage,
13806
13881
  query,
13807
13882
  queryAll,