@dooboostore/simple-web-component 1.0.32 → 1.0.34

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 (143) hide show
  1. package/README.md +280 -43
  2. package/dist/cjs/decorators/addEventListener.js.map +1 -1
  3. package/dist/cjs/decorators/applyAttribute.js +67 -57
  4. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  5. package/dist/cjs/decorators/applyClass.js +80 -70
  6. package/dist/cjs/decorators/applyClass.js.map +2 -2
  7. package/dist/cjs/decorators/applyNode.js +1 -8
  8. package/dist/cjs/decorators/applyNode.js.map +2 -2
  9. package/dist/cjs/decorators/applyStyle.js +66 -56
  10. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  11. package/dist/cjs/decorators/attribute.js +35 -29
  12. package/dist/cjs/decorators/attribute.js.map +2 -2
  13. package/dist/cjs/decorators/changedAttributeHost.js +32 -12
  14. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  15. package/dist/cjs/decorators/elementDefine.js +29 -16
  16. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  17. package/dist/cjs/decorators/emitCustomEvent.js +57 -44
  18. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  19. package/dist/cjs/decorators/index.js +3 -1
  20. package/dist/cjs/decorators/index.js.map +2 -2
  21. package/dist/cjs/decorators/publishSwcAppMessage.js +86 -0
  22. package/dist/cjs/decorators/publishSwcAppMessage.js.map +7 -0
  23. package/dist/cjs/decorators/setProperty.js +50 -39
  24. package/dist/cjs/decorators/setProperty.js.map +2 -2
  25. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +62 -0
  26. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
  27. package/dist/cjs/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +16 -16
  28. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
  29. package/dist/cjs/elements/SwcAppEngine.js +7 -7
  30. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  31. package/dist/cjs/elements/SwcAppMixin.js +90 -43
  32. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  33. package/dist/cjs/elements/SwcChoose.js +19 -15
  34. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  35. package/dist/cjs/elements/register.js +21 -16
  36. package/dist/cjs/elements/register.js.map +2 -2
  37. package/dist/cjs/types.js.map +1 -1
  38. package/dist/cjs/utils/Utils.js +7 -3
  39. package/dist/cjs/utils/Utils.js.map +2 -2
  40. package/dist/esm/decorators/addEventListener.js.map +1 -1
  41. package/dist/esm/decorators/applyAttribute.js +67 -57
  42. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  43. package/dist/esm/decorators/applyClass.js +80 -70
  44. package/dist/esm/decorators/applyClass.js.map +2 -2
  45. package/dist/esm/decorators/applyNode.js +1 -8
  46. package/dist/esm/decorators/applyNode.js.map +2 -2
  47. package/dist/esm/decorators/applyStyle.js +66 -56
  48. package/dist/esm/decorators/applyStyle.js.map +2 -2
  49. package/dist/esm/decorators/attribute.js +35 -29
  50. package/dist/esm/decorators/attribute.js.map +2 -2
  51. package/dist/esm/decorators/changedAttributeHost.js +32 -12
  52. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  53. package/dist/esm/decorators/elementDefine.js +30 -17
  54. package/dist/esm/decorators/elementDefine.js.map +2 -2
  55. package/dist/esm/decorators/emitCustomEvent.js +57 -44
  56. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  57. package/dist/esm/decorators/index.js +3 -1
  58. package/dist/esm/decorators/index.js.map +2 -2
  59. package/dist/esm/decorators/publishSwcAppMessage.js +67 -0
  60. package/dist/esm/decorators/publishSwcAppMessage.js.map +7 -0
  61. package/dist/esm/decorators/setProperty.js +50 -39
  62. package/dist/esm/decorators/setProperty.js.map +2 -2
  63. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +43 -0
  64. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
  65. package/dist/esm/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +13 -13
  66. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
  67. package/dist/esm/elements/SwcAppEngine.js +6 -6
  68. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  69. package/dist/esm/elements/SwcAppMixin.js +90 -43
  70. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  71. package/dist/esm/elements/SwcChoose.js +20 -16
  72. package/dist/esm/elements/SwcChoose.js.map +2 -2
  73. package/dist/esm/elements/register.js +22 -17
  74. package/dist/esm/elements/register.js.map +2 -2
  75. package/dist/esm/types.js.map +1 -1
  76. package/dist/esm/utils/Utils.js +7 -3
  77. package/dist/esm/utils/Utils.js.map +2 -2
  78. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +543 -348
  79. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  80. package/dist/types/decorators/addEventListener.d.ts +4 -1
  81. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  82. package/dist/types/decorators/applyAttribute.d.ts +5 -1
  83. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  84. package/dist/types/decorators/applyClass.d.ts +4 -0
  85. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  86. package/dist/types/decorators/applyNode.d.ts +4 -1
  87. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  88. package/dist/types/decorators/applyStyle.d.ts +5 -1
  89. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  90. package/dist/types/decorators/attribute.d.ts +5 -0
  91. package/dist/types/decorators/attribute.d.ts.map +1 -1
  92. package/dist/types/decorators/changedAttributeHost.d.ts +13 -3
  93. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  94. package/dist/types/decorators/elementDefine.d.ts +1 -0
  95. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  96. package/dist/types/decorators/emitCustomEvent.d.ts +5 -1
  97. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  98. package/dist/types/decorators/index.d.ts +3 -1
  99. package/dist/types/decorators/index.d.ts.map +1 -1
  100. package/dist/types/decorators/publishSwcAppMessage.d.ts +13 -0
  101. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -0
  102. package/dist/types/decorators/setProperty.d.ts +5 -1
  103. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  104. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +16 -0
  105. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -0
  106. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +18 -0
  107. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -0
  108. package/dist/types/elements/SwcAppEngine.d.ts +6 -3
  109. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  110. package/dist/types/elements/SwcAppMixin.d.ts +8 -3
  111. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  112. package/dist/types/elements/register.d.ts.map +1 -1
  113. package/dist/types/types.d.ts +6 -0
  114. package/dist/types/types.d.ts.map +1 -1
  115. package/dist/types/utils/Utils.d.ts.map +1 -1
  116. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +543 -348
  117. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  118. package/package.json +4 -4
  119. package/src/decorators/addEventListener.ts +1 -1
  120. package/src/decorators/applyAttribute.ts +74 -61
  121. package/src/decorators/applyClass.ts +91 -77
  122. package/src/decorators/applyNode.ts +3 -12
  123. package/src/decorators/applyStyle.ts +75 -61
  124. package/src/decorators/attribute.ts +55 -43
  125. package/src/decorators/changedAttributeHost.ts +47 -14
  126. package/src/decorators/elementDefine.ts +38 -19
  127. package/src/decorators/emitCustomEvent.ts +65 -49
  128. package/src/decorators/index.ts +3 -1
  129. package/src/decorators/publishSwcAppMessage.ts +100 -0
  130. package/src/decorators/setProperty.ts +58 -44
  131. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +73 -0
  132. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +71 -0
  133. package/src/elements/SwcAppEngine.ts +11 -12
  134. package/src/elements/SwcAppMixin.ts +115 -44
  135. package/src/elements/SwcChoose.ts +28 -7
  136. package/src/elements/register.ts +28 -7
  137. package/src/types.ts +8 -0
  138. package/src/utils/Utils.ts +15 -5
  139. package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +0 -7
  140. package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +0 -7
  141. package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +0 -18
  142. package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +0 -1
  143. package/src/decorators/subscribeSwcAppRouteChange.ts +0 -71
@@ -1142,10 +1142,12 @@ var dooboostoreSimpleWebComponent = (() => {
1142
1142
  ON_CONNECTED_SWC_APP_METADATA_KEY: () => ON_CONNECTED_SWC_APP_METADATA_KEY,
1143
1143
  ON_INITIALIZE_METADATA_KEY: () => ON_INITIALIZE_METADATA_KEY,
1144
1144
  PROPERTY_SET_METADATA_KEY: () => PROPERTY_SET_METADATA_KEY,
1145
+ PUBLISH_SWC_APP_MESSAGE_METADATA_KEY: () => PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
1145
1146
  QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
1146
1147
  QUERY_METADATA_KEY: () => QUERY_METADATA_KEY,
1147
1148
  STYLE_METADATA_KEY: () => STYLE_METADATA_KEY,
1148
- SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY: () => SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY,
1149
+ SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY: () => SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
1150
+ SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY: () => SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY,
1149
1151
  SWC_NOT_FOUND: () => SWC_NOT_FOUND,
1150
1152
  SwcUtils: () => SwcUtils,
1151
1153
  addClass: () => addClass,
@@ -1177,6 +1179,8 @@ var dooboostoreSimpleWebComponent = (() => {
1177
1179
  attributeHost: () => attributeHost,
1178
1180
  changedAttributeHost: () => changedAttributeHost,
1179
1181
  commentNode: () => commentNode,
1182
+ convertAttributeValue: () => convertAttributeValue,
1183
+ convertValue: () => convertValue2,
1180
1184
  createElement: () => createElement,
1181
1185
  elementDefine: () => elementDefine,
1182
1186
  emitCustomEvent: () => emitCustomEvent,
@@ -1192,13 +1196,16 @@ var dooboostoreSimpleWebComponent = (() => {
1192
1196
  firstAppHost: () => firstAppHost,
1193
1197
  firstHost: () => firstHost,
1194
1198
  getAddEventListenerMetadata: () => getAddEventListenerMetadata,
1199
+ getAttributeValue: () => getAttributeValue,
1195
1200
  getChangedAttributeMetadata: () => getChangedAttributeMetadata,
1196
1201
  getElementConfig: () => getElementConfig,
1197
1202
  getEmitCustomEventMetadataList: () => getEmitCustomEventMetadataList,
1198
1203
  getOnConnectedInnerHtmlMetadata: () => getOnConnectedInnerHtmlMetadata,
1204
+ getPublishSwcAppMessageMetadata: () => getPublishSwcAppMessageMetadata,
1199
1205
  getQueryAllMetadata: () => getQueryAllMetadata,
1200
1206
  getQueryMetadata: () => getQueryMetadata,
1201
- getSubscribeSwcAppRouteChangeMetadata: () => getSubscribeSwcAppRouteChangeMetadata,
1207
+ getSubscribeSwcAppMessageWhileConnectedMetadata: () => getSubscribeSwcAppMessageWhileConnectedMetadata,
1208
+ getSubscribeSwcAppRouteChangeWhileConnectedMetadata: () => getSubscribeSwcAppRouteChangeWhileConnectedMetadata,
1202
1209
  host: () => host,
1203
1210
  htmlAElement: () => htmlAElement,
1204
1211
  htmlArticleElement: () => htmlArticleElement,
@@ -1227,6 +1234,7 @@ var dooboostoreSimpleWebComponent = (() => {
1227
1234
  onDisconnected: () => onDisconnected,
1228
1235
  onInitialize: () => onInitialize,
1229
1236
  parentHost: () => parentHost,
1237
+ publishSwcAppMessage: () => publishSwcAppMessage,
1230
1238
  query: () => query,
1231
1239
  queryAll: () => queryAll,
1232
1240
  queryAllHost: () => queryAllHost,
@@ -1246,7 +1254,8 @@ var dooboostoreSimpleWebComponent = (() => {
1246
1254
  setPropertyHost: () => setPropertyHost,
1247
1255
  setStyle: () => setStyle,
1248
1256
  setStyleHost: () => setStyleHost,
1249
- subscribeSwcAppRouteChange: () => subscribeSwcAppRouteChange,
1257
+ subscribeSwcAppMessageWhileConnected: () => subscribeSwcAppMessageWhileConnected,
1258
+ subscribeSwcAppRouteChangeWhileConnected: () => subscribeSwcAppRouteChangeWhileConnected,
1250
1259
  textNode: () => textNode,
1251
1260
  toggleClass: () => toggleClass,
1252
1261
  toggleClassHost: () => toggleClassHost,
@@ -6334,8 +6343,8 @@ var dooboostoreSimpleWebComponent = (() => {
6334
6343
  return (0, SwcUtils2.findNearestSwcHost)(el);
6335
6344
  };
6336
6345
  SwcUtils2.getAppHosts = (el) => {
6337
- const hosts = (0, SwcUtils2.getHosts)(el);
6338
- return hosts.filter((host2) => host2.tagName.toLowerCase() === "swc-app" || host2.getAttribute("is")?.startsWith("swc-app-"));
6346
+ const hosts = SwcUtils2.findAllParentAppHostsDirect(el);
6347
+ return hosts;
6339
6348
  };
6340
6349
  SwcUtils2.getAppHost = (el) => {
6341
6350
  const appHosts = (0, SwcUtils2.getAppHosts)(el);
@@ -6348,6 +6357,10 @@ var dooboostoreSimpleWebComponent = (() => {
6348
6357
  };
6349
6358
  SwcUtils2.findAllParentAppHostsDirect = (el) => {
6350
6359
  const appHosts = [];
6360
+ const w = el.ownerDocument?.defaultView || (typeof window !== "undefined" ? window : void 0);
6361
+ if (!w) {
6362
+ return appHosts;
6363
+ }
6351
6364
  let current = el;
6352
6365
  while (current) {
6353
6366
  const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
@@ -6358,7 +6371,7 @@ var dooboostoreSimpleWebComponent = (() => {
6358
6371
  current = current.parentElement;
6359
6372
  } else {
6360
6373
  const root = current.getRootNode();
6361
- if (root instanceof ShadowRoot) {
6374
+ if (w.ShadowRoot && root instanceof w.ShadowRoot) {
6362
6375
  current = root.host;
6363
6376
  } else {
6364
6377
  break;
@@ -6433,54 +6446,67 @@ var dooboostoreSimpleWebComponent = (() => {
6433
6446
  }
6434
6447
  list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
6435
6448
  const original = descriptor.value;
6436
- descriptor.value = async function(...args) {
6449
+ descriptor.value = function(...args) {
6437
6450
  ensureInit(this);
6438
- const detail = await original.apply(this, args);
6439
- const event = new CustomEvent(type, {
6440
- detail,
6441
- bubbles: fullOptions.bubbles,
6442
- composed: fullOptions.composed,
6443
- cancelable: fullOptions.cancelable
6444
- });
6445
- const hostSet = SwcUtils.getHostSet(this);
6446
- const conf = getElementConfig(this);
6447
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
6448
- const eventTargets = [];
6449
- if (selectorOrTarget === ":window") eventTargets.push(currentWin);
6450
- else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
6451
- else if (selectorOrTarget === ":parentHost") {
6452
- if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
6453
- } else if (selectorOrTarget === ":appHost") {
6454
- if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
6455
- } else if (selectorOrTarget === ":firstHost") {
6456
- if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
6457
- } else if (selectorOrTarget === ":lastHost") {
6458
- if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
6459
- } else if (selectorOrTarget === ":firstAppHost") {
6460
- if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
6461
- } else if (selectorOrTarget === ":lastAppHost") {
6462
- if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
6463
- } else if (selectorOrTarget === ":hosts") {
6464
- hostSet.$hosts.forEach((h) => eventTargets.push(h));
6465
- } else if (selectorOrTarget === ":appHosts") {
6466
- hostSet.$appHosts.forEach((h) => eventTargets.push(h));
6467
- } else if (selectorOrTarget === ":host" || !selectorOrTarget) eventTargets.push(this);
6468
- else {
6469
- const r = fullOptions.root || "auto";
6470
- const searchRoots = [];
6471
- if (r === "auto") searchRoots.push(this.shadowRoot || this);
6472
- else if (r === "light") searchRoots.push(this);
6473
- else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
6474
- else if (r === "all") {
6475
- searchRoots.push(this);
6476
- if (this.shadowRoot) searchRoots.push(this.shadowRoot);
6451
+ const res = original.apply(this, args);
6452
+ const handleResult = (detail) => {
6453
+ const event = new CustomEvent(type, {
6454
+ detail,
6455
+ bubbles: fullOptions.bubbles,
6456
+ composed: fullOptions.composed,
6457
+ cancelable: fullOptions.cancelable
6458
+ });
6459
+ const hostSet = SwcUtils.getHostSet(this);
6460
+ const conf = getElementConfig(this);
6461
+ const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
6462
+ const eventTargets = [];
6463
+ if (selectorOrTarget === ":window") eventTargets.push(currentWin);
6464
+ else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
6465
+ else if (selectorOrTarget === ":parentHost") {
6466
+ if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
6467
+ } else if (selectorOrTarget === ":appHost") {
6468
+ if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
6469
+ } else if (selectorOrTarget === ":firstHost") {
6470
+ if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
6471
+ } else if (selectorOrTarget === ":lastHost") {
6472
+ if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
6473
+ } else if (selectorOrTarget === ":firstAppHost") {
6474
+ if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
6475
+ } else if (selectorOrTarget === ":lastAppHost") {
6476
+ if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
6477
+ } else if (selectorOrTarget === ":hosts") {
6478
+ hostSet.$hosts.forEach((h) => eventTargets.push(h));
6479
+ } else if (selectorOrTarget === ":appHosts") {
6480
+ hostSet.$appHosts.forEach((h) => eventTargets.push(h));
6481
+ } else if (selectorOrTarget === ":host" || !selectorOrTarget) {
6482
+ eventTargets.push(this);
6483
+ } else {
6484
+ const r = fullOptions.root || "auto";
6485
+ const searchRoots = [];
6486
+ if (r === "auto") searchRoots.push(this.shadowRoot || this);
6487
+ else if (r === "light") searchRoots.push(this);
6488
+ else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
6489
+ else if (r === "all") {
6490
+ searchRoots.push(this);
6491
+ if (this.shadowRoot) searchRoots.push(this.shadowRoot);
6492
+ }
6493
+ searchRoots.forEach((sr) => {
6494
+ sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
6495
+ });
6477
6496
  }
6478
- searchRoots.forEach((sr) => {
6479
- sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
6497
+ eventTargets.forEach((t) => {
6498
+ if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
6499
+ return;
6500
+ }
6501
+ t.dispatchEvent(event);
6480
6502
  });
6503
+ return detail;
6504
+ };
6505
+ if (res instanceof Promise) {
6506
+ return res.then(handleResult);
6507
+ } else {
6508
+ return handleResult(res);
6481
6509
  }
6482
- eventTargets.forEach((t) => t.dispatchEvent(event));
6483
- return detail;
6484
6510
  };
6485
6511
  };
6486
6512
  }
@@ -6497,21 +6523,26 @@ var dooboostoreSimpleWebComponent = (() => {
6497
6523
 
6498
6524
  // src/decorators/changedAttributeHost.ts
6499
6525
  var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
6500
- function changedAttributeHost(attributeName) {
6526
+ var convertValue = (val, type) => {
6527
+ if (val === null || val === void 0) return val;
6528
+ if (type === Number) return Number(val);
6529
+ if (type === Boolean) return val === "false" || val === "0" ? false : true;
6530
+ return val;
6531
+ };
6532
+ function changedAttributeHost(attributeName, options = {}) {
6501
6533
  return (target, propertyKey) => {
6502
6534
  const constructor = target.constructor;
6503
- let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
6504
- if (!meta) {
6505
- meta = /* @__PURE__ */ new Map();
6506
- ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
6535
+ let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
6536
+ if (!metaList) {
6537
+ metaList = [];
6538
+ ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
6507
6539
  }
6508
6540
  const name = attributeName || String(propertyKey);
6509
- let methods = meta.get(name);
6510
- if (!methods) {
6511
- methods = [];
6512
- meta.set(name, methods);
6513
- }
6514
- if (!methods.includes(propertyKey)) methods.push(propertyKey);
6541
+ metaList.push({
6542
+ attributeName: name,
6543
+ propertyKey,
6544
+ options
6545
+ });
6515
6546
  };
6516
6547
  }
6517
6548
  var getChangedAttributeMetadata = (target) => {
@@ -6519,7 +6550,21 @@ var dooboostoreSimpleWebComponent = (() => {
6519
6550
  return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
6520
6551
  };
6521
6552
  var findAllAttributeChangedMetadata = (target) => {
6522
- return ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
6553
+ const constructor = target instanceof Function ? target : target.constructor;
6554
+ const metaList = ReflectUtils.findAllMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
6555
+ const result = /* @__PURE__ */ new Map();
6556
+ metaList.forEach((meta) => {
6557
+ meta.forEach((item) => {
6558
+ if (!result.has(item.attributeName)) {
6559
+ result.set(item.attributeName, []);
6560
+ }
6561
+ result.get(item.attributeName).push(item);
6562
+ });
6563
+ });
6564
+ return result;
6565
+ };
6566
+ var convertAttributeValue = (val, type) => {
6567
+ return convertValue(val, type);
6523
6568
  };
6524
6569
 
6525
6570
  // src/decorators/applyAttribute.ts
@@ -6545,70 +6590,80 @@ var dooboostoreSimpleWebComponent = (() => {
6545
6590
  options: { ...finalOptions, name: attributeName }
6546
6591
  });
6547
6592
  const original = descriptor.value;
6548
- descriptor.value = async function(...args) {
6593
+ descriptor.value = function(...args) {
6549
6594
  ensureInit(this);
6550
- const res = await original.apply(this, args);
6551
- if (res !== void 0) {
6552
- const win = this.ownerDocument?.defaultView || window;
6553
- const host2 = this;
6554
- const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
6555
- const r = finalOptions.root || "auto";
6556
- const targetEls = [];
6557
- const applyRoot = (t) => {
6558
- if (!t || !(t instanceof win.HTMLElement)) return;
6559
- targetEls.push(t);
6560
- };
6561
- if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
6562
- else if (selector === ":appHost") applyRoot(hostSet.$appHost);
6563
- else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
6564
- else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
6565
- else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
6566
- else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
6567
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
6568
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
6569
- else if (selector === ":host" || !selector) applyRoot(host2);
6570
- else {
6571
- const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
6572
- if (targetRoot) {
6573
- const found = targetRoot.querySelectorAll(selector);
6574
- if (found) targetEls.push(...Array.from(found));
6595
+ const res = original.apply(this, args);
6596
+ const handleResult = (resolvedValue) => {
6597
+ if (resolvedValue !== void 0) {
6598
+ const win = this.ownerDocument?.defaultView || window;
6599
+ const host2 = this;
6600
+ const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
6601
+ const r = finalOptions.root || "auto";
6602
+ const targetEls = [];
6603
+ const applyRoot = (t) => {
6604
+ if (!t || !(t instanceof win.HTMLElement)) return;
6605
+ targetEls.push(t);
6606
+ };
6607
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
6608
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
6609
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
6610
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
6611
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
6612
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
6613
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
6614
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
6615
+ else if (selector === ":host" || !selector) applyRoot(host2);
6616
+ else {
6617
+ const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
6618
+ if (targetRoot) {
6619
+ const found = targetRoot.querySelectorAll(selector);
6620
+ if (found) targetEls.push(...Array.from(found));
6621
+ }
6575
6622
  }
6576
- }
6577
- targetEls.forEach((targetEl) => {
6578
- const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
6579
- if (action === "set" || action === "update") {
6580
- if (attributeName) {
6581
- if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
6623
+ targetEls.forEach((targetEl) => {
6624
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
6625
+ return;
6626
+ }
6627
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
6628
+ if (action === "set" || action === "update") {
6629
+ if (attributeName) {
6630
+ if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
6631
+ targetEl.removeAttribute(attributeName);
6632
+ } else {
6633
+ targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
6634
+ }
6635
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
6636
+ Object.entries(resolvedRes).forEach(([attr, val]) => {
6637
+ const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
6638
+ if (finalVal === null || finalVal === void 0 || finalVal === false) {
6639
+ targetEl.removeAttribute(attr);
6640
+ } else {
6641
+ targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
6642
+ }
6643
+ });
6644
+ }
6645
+ } else if (action === "remove") {
6646
+ if (attributeName) {
6582
6647
  targetEl.removeAttribute(attributeName);
6648
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
6649
+ Object.entries(resolvedRes).forEach(([attr, val]) => {
6650
+ const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
6651
+ if (shouldRemove) targetEl.removeAttribute(attr);
6652
+ });
6583
6653
  } else {
6584
- targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
6654
+ const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
6655
+ attrs.forEach((a) => targetEl.removeAttribute(String(a)));
6585
6656
  }
6586
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
6587
- Object.entries(resolvedRes).forEach(([attr, val]) => {
6588
- const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
6589
- if (finalVal === null || finalVal === void 0 || finalVal === false) {
6590
- targetEl.removeAttribute(attr);
6591
- } else {
6592
- targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
6593
- }
6594
- });
6595
- }
6596
- } else if (action === "remove") {
6597
- if (attributeName) {
6598
- targetEl.removeAttribute(attributeName);
6599
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
6600
- Object.entries(resolvedRes).forEach(([attr, val]) => {
6601
- const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
6602
- if (shouldRemove) targetEl.removeAttribute(attr);
6603
- });
6604
- } else {
6605
- const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
6606
- attrs.forEach((a) => targetEl.removeAttribute(String(a)));
6607
6657
  }
6608
- }
6609
- });
6658
+ });
6659
+ }
6660
+ return resolvedValue;
6661
+ };
6662
+ if (res instanceof Promise) {
6663
+ return res.then(handleResult);
6664
+ } else {
6665
+ return handleResult(res);
6610
6666
  }
6611
- return res;
6612
6667
  };
6613
6668
  return descriptor;
6614
6669
  };
@@ -7906,7 +7961,7 @@ var dooboostoreSimpleWebComponent = (() => {
7906
7961
  }
7907
7962
  };
7908
7963
  function buildEnv(configWindow) {
7909
- const win = configWindow || (typeof window !== "undefined" ? window : void 0);
7964
+ const win = configWindow;
7910
7965
  const doc = win?.document;
7911
7966
  const builtInTagMap = /* @__PURE__ */ new Map();
7912
7967
  for (const [cls, tag] of HTML_TAG_ENTRIES) {
@@ -7945,7 +8000,7 @@ var dooboostoreSimpleWebComponent = (() => {
7945
8000
  const aConf = getElementConfig(ancestors[i]);
7946
8001
  if (aConf?.window) return aConf.window;
7947
8002
  }
7948
- return typeof window !== "undefined" ? window : void 0;
8003
+ return getElementConfig(this).window ?? (typeof window !== "undefined" ? window : void 0);
7949
8004
  };
7950
8005
  proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
7951
8006
  ensureInit(this);
@@ -8047,8 +8102,11 @@ var dooboostoreSimpleWebComponent = (() => {
8047
8102
  const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
8048
8103
  const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
8049
8104
  const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
8105
+ const proto = constructor.prototype;
8106
+ const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
8050
8107
  const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
8051
8108
  ...metadata.observedAttributes ?? [],
8109
+ ...originalStaticObservedAttributes,
8052
8110
  ...attrChangeMap.keys(),
8053
8111
  ...attributeApplyNames,
8054
8112
  ...hostAttributes,
@@ -8057,7 +8115,6 @@ var dooboostoreSimpleWebComponent = (() => {
8057
8115
  ...swcOnEvents
8058
8116
  ])];
8059
8117
  const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
8060
- const proto = constructor.prototype;
8061
8118
  setupPrototype(proto);
8062
8119
  const originalConnected = proto.connectedCallback;
8063
8120
  proto.connectedCallback = function() {
@@ -8066,8 +8123,10 @@ var dooboostoreSimpleWebComponent = (() => {
8066
8123
  const appHost2 = hostSet.$appHost;
8067
8124
  const conf = getElementConfig(this);
8068
8125
  const currentWin = this._resolveWindow(conf);
8069
- if (connectedInnerHtmlList.some((it) => it.options.useShadow === true) && !this.shadowRoot) {
8070
- this.attachShadow({ mode: "open" });
8126
+ const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
8127
+ if (shadowMode && !this.shadowRoot) {
8128
+ const mode = shadowMode === true ? "open" : shadowMode;
8129
+ this.attachShadow({ mode });
8071
8130
  }
8072
8131
  this._executeSwcScript("swc-on-before-connected", hostSet);
8073
8132
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
@@ -8079,12 +8138,16 @@ var dooboostoreSimpleWebComponent = (() => {
8079
8138
  for (const meta of connectedInnerHtmlList) {
8080
8139
  const res = this._invokeLifecycleMethod(meta.propertyKey, hostSet);
8081
8140
  if (res !== void 0) {
8082
- if (meta.options.useShadow) sContent += res;
8141
+ if (meta.options.useShadow || conf?.useShadow) sContent += res;
8083
8142
  else lContent += res;
8084
8143
  }
8085
8144
  }
8086
- if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
8087
- if (lContent) this.innerHTML = lContent;
8145
+ try {
8146
+ if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
8147
+ if (lContent) this.innerHTML = lContent;
8148
+ } catch (e) {
8149
+ console.error("[ElementDefine] innerHTML setting error:", e);
8150
+ }
8088
8151
  }
8089
8152
  const root = this.getRootNode();
8090
8153
  if (!globalDelegatedRoots.has(root)) {
@@ -8196,7 +8259,7 @@ var dooboostoreSimpleWebComponent = (() => {
8196
8259
  const handler = async (event) => {
8197
8260
  if (options.filter) {
8198
8261
  const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
8199
- if (!options.filter(event, helper)) {
8262
+ if (!options.filter(event, { currentThis: this, helper })) {
8200
8263
  return;
8201
8264
  }
8202
8265
  }
@@ -8280,15 +8343,17 @@ var dooboostoreSimpleWebComponent = (() => {
8280
8343
  const expr = ae.getFirstExpression("call-return");
8281
8344
  if (expr) {
8282
8345
  const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
8346
+ const helperAndHostSet = SwcUtils.getHelperAndHostSet(win2, this);
8283
8347
  try {
8348
+ const script = ConvertUtils2.decodeHtmlEntity(expr.script, win2.document);
8284
8349
  const result = FunctionUtils.executeReturn({
8285
- script: ConvertUtils2.decodeHtmlEntity(expr.script, win2.document),
8350
+ script,
8286
8351
  context: this,
8287
- args: SwcUtils.getHelperAndHostSet(win2, this)
8352
+ args: helperAndHostSet
8288
8353
  });
8289
- processedVal = String(result);
8354
+ processedVal = result;
8290
8355
  } catch (e) {
8291
- console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}:`, e);
8356
+ console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}: ${helperAndHostSet}`, e);
8292
8357
  processedVal = newVal;
8293
8358
  }
8294
8359
  }
@@ -8303,9 +8368,12 @@ var dooboostoreSimpleWebComponent = (() => {
8303
8368
  if (hostCustomEventMeta && newVal !== null) {
8304
8369
  this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
8305
8370
  }
8306
- const mKeys = attrChangeMap.get(name2);
8307
- if (mKeys && Array.isArray(mKeys)) {
8308
- for (const key of mKeys) this[key](processedVal, old, name2, hSet);
8371
+ const metaList = attrChangeMap.get(name2);
8372
+ if (metaList && Array.isArray(metaList)) {
8373
+ for (const meta of metaList) {
8374
+ const convertedVal = convertAttributeValue(processedVal, meta.options.type);
8375
+ this[meta.propertyKey](convertedVal, old, name2, hSet);
8376
+ }
8309
8377
  }
8310
8378
  };
8311
8379
  Object.defineProperty(constructor, "observedAttributes", {
@@ -8322,12 +8390,38 @@ var dooboostoreSimpleWebComponent = (() => {
8322
8390
 
8323
8391
  // src/decorators/attribute.ts
8324
8392
  var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
8325
- var convertValue = (val, type) => {
8393
+ var convertValue2 = (val, type) => {
8326
8394
  if (val === null || val === void 0) return val;
8327
8395
  if (type === Number) return Number(val);
8328
8396
  if (type === Boolean) return val === "false" || val === "0" ? false : true;
8329
8397
  return val;
8330
8398
  };
8399
+ var getAttributeValue = (inst, attrName, options) => {
8400
+ const conf = getElementConfig(inst);
8401
+ const currentWin = inst._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
8402
+ const targets = options?.selector ? resolveTargetEls(inst, options.selector, options, currentWin) : [inst];
8403
+ const primaryTarget = targets[0];
8404
+ if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
8405
+ let domVal = primaryTarget.getAttribute(attrName);
8406
+ const ae = new ActionExpression(domVal);
8407
+ const expr = ae.getFirstExpression("call-return");
8408
+ if (expr) {
8409
+ try {
8410
+ const result = FunctionUtils.executeReturn({
8411
+ script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
8412
+ context: inst,
8413
+ args: SwcUtils.getHelperAndHostSet(currentWin, inst)
8414
+ });
8415
+ return convertValue2(result, options?.type);
8416
+ } catch (e) {
8417
+ console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
8418
+ return convertValue2(domVal, options?.type);
8419
+ }
8420
+ }
8421
+ return convertValue2(domVal, options?.type);
8422
+ }
8423
+ return null;
8424
+ };
8331
8425
  var resolveTargetEls = (inst, selector, options, currentWin) => {
8332
8426
  const r = options.root || "auto";
8333
8427
  const results = [];
@@ -8402,35 +8496,13 @@ var dooboostoreSimpleWebComponent = (() => {
8402
8496
  Object.defineProperty(target, propertyKey, {
8403
8497
  get() {
8404
8498
  const attrName = options.name || String(propertyKey);
8405
- const conf = getElementConfig(this);
8406
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
8407
- const targetType = options.type || designType;
8408
- const targets = resolveTargetEls(this, selector, options, currentWin);
8409
- const primaryTarget = targets[0];
8410
- if (primaryTarget && typeof primaryTarget.hasAttribute === "function") {
8411
- if (primaryTarget.hasAttribute(attrName)) {
8412
- let domVal = primaryTarget.getAttribute(attrName);
8413
- const ae = new ActionExpression(domVal);
8414
- const expr = ae.getFirstExpression("call-return");
8415
- if (expr) {
8416
- try {
8417
- const result = FunctionUtils.executeReturn({
8418
- script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
8419
- context: this,
8420
- args: SwcUtils.getHelperAndHostSet(currentWin, this)
8421
- });
8422
- return convertValue(result, targetType);
8423
- } catch (e) {
8424
- console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
8425
- return convertValue(domVal, targetType);
8426
- }
8427
- }
8428
- return convertValue(domVal, targetType);
8429
- }
8430
- return null;
8431
- }
8432
- const data = convertValue(this[privateKey], targetType);
8433
- return data;
8499
+ const mergedOptions = {
8500
+ ...options,
8501
+ selector,
8502
+ type: options.type || designType
8503
+ };
8504
+ const result = getAttributeValue(this, attrName, mergedOptions);
8505
+ return result !== null ? result : this[privateKey];
8434
8506
  },
8435
8507
  set(nv) {
8436
8508
  const attrName = options.name || String(propertyKey);
@@ -8543,14 +8615,7 @@ var dooboostoreSimpleWebComponent = (() => {
8543
8615
  const res = original.apply(this, args);
8544
8616
  const runApply = (target, val) => {
8545
8617
  const pos = options.position || "beforeEnd";
8546
- const defaultFilter = (t, v) => {
8547
- if (v instanceof Node) return !t.contains(v);
8548
- if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
8549
- if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
8550
- return true;
8551
- };
8552
- const activeFilter = options.filter || defaultFilter;
8553
- if (activeFilter(target, val, hostSet)) {
8618
+ if (!options.filter || options.filter(target, val, { currentThis: this, helper: hostSet })) {
8554
8619
  applyToDom(target, val, pos, currentDoc);
8555
8620
  }
8556
8621
  };
@@ -8622,81 +8687,91 @@ var dooboostoreSimpleWebComponent = (() => {
8622
8687
  }
8623
8688
  metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
8624
8689
  const original = descriptor.value;
8625
- descriptor.value = async function(...args) {
8690
+ descriptor.value = function(...args) {
8626
8691
  ensureInit(this);
8627
- const res = await original.apply(this, args);
8628
- if (res !== void 0) {
8629
- const win = this.ownerDocument?.defaultView || window;
8630
- const host2 = this;
8631
- const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
8632
- const r = finalOptions.root || "auto";
8633
- const targetEls = [];
8634
- const applyRoot = (t) => {
8635
- if (!t || !(t instanceof win.HTMLElement)) return;
8636
- targetEls.push(t);
8637
- };
8638
- if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
8639
- else if (selector === ":appHost") applyRoot(hostSet.$appHost);
8640
- else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
8641
- else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
8642
- else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
8643
- else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
8644
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
8645
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
8646
- else if (selector === ":host" || !selector) applyRoot(host2);
8647
- else {
8648
- const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
8649
- if (targetRoot) {
8650
- const found = targetRoot.querySelectorAll(selector);
8651
- if (found) targetEls.push(...Array.from(found));
8652
- }
8653
- }
8654
- targetEls.forEach((targetEl) => {
8655
- const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
8656
- if (action === "set") {
8657
- let classes = "";
8658
- if (classMap && typeof classMap === "string") {
8659
- classes = resolvedRes ? classMap : "";
8660
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8661
- classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
8662
- } else {
8663
- classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
8692
+ const res = original.apply(this, args);
8693
+ const handleResult = (resolvedValue) => {
8694
+ if (resolvedValue !== void 0) {
8695
+ const win = this.ownerDocument?.defaultView || window;
8696
+ const host2 = this;
8697
+ const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
8698
+ const r = finalOptions.root || "auto";
8699
+ const targetEls = [];
8700
+ const applyRoot = (t) => {
8701
+ if (!t || !(t instanceof win.HTMLElement)) return;
8702
+ targetEls.push(t);
8703
+ };
8704
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
8705
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
8706
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
8707
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
8708
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
8709
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
8710
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
8711
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
8712
+ else if (selector === ":host" || !selector) applyRoot(host2);
8713
+ else {
8714
+ const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
8715
+ if (targetRoot) {
8716
+ const found = targetRoot.querySelectorAll(selector);
8717
+ if (found) targetEls.push(...Array.from(found));
8664
8718
  }
8665
- targetEl.className = classes;
8666
- } else if (action === "update" || action === "toggle") {
8667
- if (classMap && typeof classMap === "string") {
8668
- targetEl.classList.toggle(classMap, !!resolvedRes);
8669
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8670
- Object.entries(resolvedRes).forEach(([cls, force]) => {
8671
- const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
8672
- targetEl.classList.toggle(cls, isActive);
8673
- });
8674
- } else {
8675
- const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
8676
- if (action === "update") targetEl.classList.add(...classes);
8677
- else classes.forEach((c) => targetEl.classList.toggle(c));
8719
+ }
8720
+ targetEls.forEach((targetEl) => {
8721
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
8722
+ return;
8678
8723
  }
8679
- } else if (action === "add" || action === "remove") {
8680
- if (classMap && typeof classMap === "string" && !!resolvedRes) {
8681
- if (action === "add") targetEl.classList.add(classMap);
8682
- else targetEl.classList.remove(classMap);
8683
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8684
- Object.entries(resolvedRes).forEach(([cls, force]) => {
8685
- const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
8686
- if (shouldExecute) {
8687
- if (action === "add") targetEl.classList.add(cls);
8688
- else targetEl.classList.remove(cls);
8689
- }
8690
- });
8691
- } else {
8692
- const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
8693
- if (action === "add") targetEl.classList.add(...classes);
8694
- else targetEl.classList.remove(...classes);
8724
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
8725
+ if (action === "set") {
8726
+ let classes = "";
8727
+ if (classMap && typeof classMap === "string") {
8728
+ classes = resolvedRes ? classMap : "";
8729
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8730
+ classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
8731
+ } else {
8732
+ classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
8733
+ }
8734
+ targetEl.className = classes;
8735
+ } else if (action === "update" || action === "toggle") {
8736
+ if (classMap && typeof classMap === "string") {
8737
+ targetEl.classList.toggle(classMap, !!resolvedRes);
8738
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8739
+ Object.entries(resolvedRes).forEach(([cls, force]) => {
8740
+ const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
8741
+ targetEl.classList.toggle(cls, isActive);
8742
+ });
8743
+ } else {
8744
+ const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
8745
+ if (action === "update") targetEl.classList.add(...classes);
8746
+ else classes.forEach((c) => targetEl.classList.toggle(c));
8747
+ }
8748
+ } else if (action === "add" || action === "remove") {
8749
+ if (classMap && typeof classMap === "string" && !!resolvedRes) {
8750
+ if (action === "add") targetEl.classList.add(classMap);
8751
+ else targetEl.classList.remove(classMap);
8752
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8753
+ Object.entries(resolvedRes).forEach(([cls, force]) => {
8754
+ const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
8755
+ if (shouldExecute) {
8756
+ if (action === "add") targetEl.classList.add(cls);
8757
+ else targetEl.classList.remove(cls);
8758
+ }
8759
+ });
8760
+ } else {
8761
+ const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
8762
+ if (action === "add") targetEl.classList.add(...classes);
8763
+ else targetEl.classList.remove(...classes);
8764
+ }
8695
8765
  }
8696
- }
8697
- });
8766
+ });
8767
+ }
8768
+ return resolvedValue;
8769
+ };
8770
+ if (res instanceof Promise) {
8771
+ return res.then(handleResult);
8772
+ } else {
8773
+ return handleResult(res);
8698
8774
  }
8699
- return res;
8700
8775
  };
8701
8776
  return descriptor;
8702
8777
  };
@@ -8742,67 +8817,77 @@ var dooboostoreSimpleWebComponent = (() => {
8742
8817
  }
8743
8818
  metaList.set(propertyKey, { propertyKey, selector, action, options });
8744
8819
  const original = descriptor.value;
8745
- descriptor.value = async function(...args) {
8820
+ descriptor.value = function(...args) {
8746
8821
  ensureInit(this);
8747
- const res = await original.apply(this, args);
8748
- if (res !== void 0) {
8749
- const win = this.ownerDocument?.defaultView || window;
8750
- const host2 = this;
8751
- const hostSet = SwcUtils.getHelperAndHostSet(win, host2);
8752
- const r = options.root || "auto";
8753
- const targetEls = [];
8754
- const applyRoot = (t) => {
8755
- if (!t || !(t instanceof win.HTMLElement)) return;
8756
- targetEls.push(t);
8757
- };
8758
- if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
8759
- else if (selector === ":appHost") applyRoot(hostSet.$appHost);
8760
- else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
8761
- else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
8762
- else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
8763
- else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
8764
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
8765
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
8766
- else if (selector === ":host" || !selector) applyRoot(host2);
8767
- else {
8768
- const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
8769
- if (targetRoot) {
8770
- const found = targetRoot.querySelectorAll(selector);
8771
- if (found) targetEls.push(...Array.from(found));
8822
+ const res = original.apply(this, args);
8823
+ const handleResult = (resolvedValue) => {
8824
+ if (resolvedValue !== void 0) {
8825
+ const win = this.ownerDocument?.defaultView || window;
8826
+ const host2 = this;
8827
+ const hostSet = SwcUtils.getHelperAndHostSet(win, host2);
8828
+ const r = options.root || "auto";
8829
+ const targetEls = [];
8830
+ const applyRoot = (t) => {
8831
+ if (!t || !(t instanceof win.HTMLElement)) return;
8832
+ targetEls.push(t);
8833
+ };
8834
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
8835
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
8836
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
8837
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
8838
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
8839
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
8840
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
8841
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
8842
+ else if (selector === ":host" || !selector) applyRoot(host2);
8843
+ else {
8844
+ const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
8845
+ if (targetRoot) {
8846
+ const found = targetRoot.querySelectorAll(selector);
8847
+ if (found) targetEls.push(...Array.from(found));
8848
+ }
8772
8849
  }
8773
- }
8774
- targetEls.forEach((targetEl) => {
8775
- const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
8776
- if (action === "set" || action === "update") {
8777
- if (action === "set") targetEl.style.cssText = "";
8778
- if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8779
- Object.entries(resolvedRes).forEach(([prop, val]) => {
8780
- const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
8781
- if (finalVal === null || finalVal === void 0) {
8782
- targetEl.style.removeProperty(prop);
8783
- } else {
8784
- targetEl.style[prop] = String(finalVal);
8785
- }
8786
- });
8787
- } else if (typeof resolvedRes === "string") {
8788
- targetEl.style.cssText = resolvedRes;
8850
+ targetEls.forEach((targetEl) => {
8851
+ if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
8852
+ return;
8789
8853
  }
8790
- } else if (action === "remove") {
8791
- if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8792
- Object.entries(resolvedRes).forEach(([prop, val]) => {
8793
- const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
8794
- if (shouldRemove) {
8795
- targetEl.style.removeProperty(prop);
8796
- }
8797
- });
8798
- } else {
8799
- const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
8800
- props.forEach((p) => targetEl.style.removeProperty(String(p)));
8854
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
8855
+ if (action === "set" || action === "update") {
8856
+ if (action === "set") targetEl.style.cssText = "";
8857
+ if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8858
+ Object.entries(resolvedRes).forEach(([prop, val]) => {
8859
+ const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
8860
+ if (finalVal === null || finalVal === void 0) {
8861
+ targetEl.style.removeProperty(prop);
8862
+ } else {
8863
+ targetEl.style[prop] = String(finalVal);
8864
+ }
8865
+ });
8866
+ } else if (typeof resolvedRes === "string") {
8867
+ targetEl.style.cssText = resolvedRes;
8868
+ }
8869
+ } else if (action === "remove") {
8870
+ if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8871
+ Object.entries(resolvedRes).forEach(([prop, val]) => {
8872
+ const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
8873
+ if (shouldRemove) {
8874
+ targetEl.style.removeProperty(prop);
8875
+ }
8876
+ });
8877
+ } else {
8878
+ const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
8879
+ props.forEach((p) => targetEl.style.removeProperty(String(p)));
8880
+ }
8801
8881
  }
8802
- }
8803
- });
8882
+ });
8883
+ }
8884
+ return resolvedValue;
8885
+ };
8886
+ if (res instanceof Promise) {
8887
+ return res.then(handleResult);
8888
+ } else {
8889
+ return handleResult(res);
8804
8890
  }
8805
- return res;
8806
8891
  };
8807
8892
  return descriptor;
8808
8893
  };
@@ -8852,48 +8937,59 @@ var dooboostoreSimpleWebComponent = (() => {
8852
8937
  options: { ...finalOptions, name: propertyName }
8853
8938
  });
8854
8939
  const original = descriptor.value;
8855
- descriptor.value = async function(...args) {
8940
+ descriptor.value = function(...args) {
8856
8941
  ensureInit(this);
8857
- const res = await original.apply(this, args);
8858
- if (res !== void 0) {
8859
- const win = this.ownerDocument?.defaultView || window;
8860
- const host2 = this;
8861
- const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
8862
- const r = finalOptions.root || "auto";
8863
- const targetEls = [];
8864
- const applyRoot = (t) => {
8865
- if (!t || !(t instanceof win.HTMLElement)) return;
8866
- targetEls.push(t);
8867
- };
8868
- if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
8869
- else if (selector === ":appHost") applyRoot(hostSet.$appHost);
8870
- else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
8871
- else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
8872
- else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
8873
- else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
8874
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
8875
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
8876
- else if (selector === ":host" || !selector) applyRoot(host2);
8877
- else {
8878
- const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
8879
- if (targetRoot) {
8880
- const found = targetRoot.querySelectorAll(selector);
8881
- if (found) targetEls.push(...Array.from(found));
8942
+ const res = original.apply(this, args);
8943
+ const handleResult = (resolvedValue) => {
8944
+ if (resolvedValue !== void 0) {
8945
+ const win = this.ownerDocument?.defaultView || window;
8946
+ const host2 = this;
8947
+ const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
8948
+ const r = finalOptions.root || "auto";
8949
+ const targetEls = [];
8950
+ const applyRoot = (t) => {
8951
+ if (!t || !(t instanceof win.HTMLElement)) return;
8952
+ targetEls.push(t);
8953
+ };
8954
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
8955
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
8956
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
8957
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
8958
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
8959
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
8960
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
8961
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
8962
+ else if (selector === ":host" || !selector) applyRoot(host2);
8963
+ else {
8964
+ const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
8965
+ if (targetRoot) {
8966
+ const found = targetRoot.querySelectorAll(selector);
8967
+ if (found) targetEls.push(...Array.from(found));
8968
+ }
8882
8969
  }
8970
+ targetEls.forEach((targetEl) => {
8971
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
8972
+ return;
8973
+ }
8974
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
8975
+ if (propertyName) {
8976
+ targetEl[propertyName] = resolvedRes;
8977
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8978
+ Object.entries(resolvedRes).forEach(([prop, val]) => {
8979
+ const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
8980
+ targetEl[prop] = finalVal;
8981
+ });
8982
+ } else {
8983
+ targetEl.value = resolvedRes;
8984
+ }
8985
+ });
8883
8986
  }
8884
- targetEls.forEach((targetEl) => {
8885
- const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
8886
- if (propertyName) {
8887
- targetEl[propertyName] = resolvedRes;
8888
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
8889
- Object.entries(resolvedRes).forEach(([prop, val]) => {
8890
- const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
8891
- targetEl[prop] = finalVal;
8892
- });
8893
- } else {
8894
- targetEl.value = resolvedRes;
8895
- }
8896
- });
8987
+ return resolvedValue;
8988
+ };
8989
+ if (res instanceof Promise) {
8990
+ return res.then(handleResult);
8991
+ } else {
8992
+ return handleResult(res);
8897
8993
  }
8898
8994
  };
8899
8995
  };
@@ -8902,25 +8998,25 @@ var dooboostoreSimpleWebComponent = (() => {
8902
8998
  return setProperty(":host", propertyNameOrOptions, options);
8903
8999
  };
8904
9000
 
8905
- // src/decorators/subscribeSwcAppRouteChange.ts
8906
- var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change");
8907
- function createSwcAppRouteChangeSubscriber(options) {
9001
+ // src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts
9002
+ var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change-while-connected");
9003
+ function createSubscribeSwcAppRouteChangeWhileConnected(options) {
8908
9004
  return (target, propertyKey, descriptor) => {
8909
9005
  const pathPattern = options?.path;
8910
9006
  const filter = options?.filter;
8911
9007
  const constructor = target.constructor;
8912
- let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
9008
+ let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
8913
9009
  if (!list) {
8914
9010
  list = [];
8915
- ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
9011
+ ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
8916
9012
  }
8917
9013
  list.push({ propertyKey, pathPattern, filter });
8918
9014
  return descriptor;
8919
9015
  };
8920
9016
  }
8921
- function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
9017
+ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKey, descriptor) {
8922
9018
  if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
8923
- return createSwcAppRouteChangeSubscriber({})(targetOrOptions, propertyKey, descriptor);
9019
+ return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);
8924
9020
  }
8925
9021
  let options = {};
8926
9022
  if (Array.isArray(targetOrOptions)) {
@@ -8930,11 +9026,110 @@ var dooboostoreSimpleWebComponent = (() => {
8930
9026
  } else if (targetOrOptions && typeof targetOrOptions === "object") {
8931
9027
  options = targetOrOptions;
8932
9028
  }
8933
- return createSwcAppRouteChangeSubscriber(options);
9029
+ return createSubscribeSwcAppRouteChangeWhileConnected(options);
9030
+ }
9031
+ var getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
9032
+ const constructor = target instanceof Function ? target : target.constructor;
9033
+ return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
9034
+ };
9035
+
9036
+ // src/decorators/subscribeSwcAppMessageWhileConnected.ts
9037
+ var SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-message-while-connected");
9038
+ function createSubscribeSwcAppMessageWhileConnected(options, messageType) {
9039
+ return (target, propertyKey, descriptor) => {
9040
+ const filter = options?.filter;
9041
+ const constructor = target.constructor;
9042
+ let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
9043
+ if (!list) {
9044
+ list = [];
9045
+ ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
9046
+ }
9047
+ list.push({ propertyKey, messageType, filter });
9048
+ return descriptor;
9049
+ };
9050
+ }
9051
+ function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, optionsOrPropertyKey, descriptor) {
9052
+ if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && optionsOrPropertyKey && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol") && descriptor) {
9053
+ const target = targetOrMessageTypeOrOptions;
9054
+ const propertyKey = optionsOrPropertyKey;
9055
+ return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);
9056
+ }
9057
+ let messageType;
9058
+ let options = {};
9059
+ if (typeof targetOrMessageTypeOrOptions === "string") {
9060
+ messageType = targetOrMessageTypeOrOptions;
9061
+ if (optionsOrPropertyKey && typeof optionsOrPropertyKey === "object") {
9062
+ options = optionsOrPropertyKey;
9063
+ }
9064
+ } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object") {
9065
+ options = targetOrMessageTypeOrOptions;
9066
+ }
9067
+ return createSubscribeSwcAppMessageWhileConnected(options, messageType);
9068
+ }
9069
+ var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
9070
+ const constructor = target instanceof Function ? target : target.constructor;
9071
+ return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
9072
+ };
9073
+
9074
+ // src/decorators/publishSwcAppMessage.ts
9075
+ var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
9076
+ function createPublishSwcAppMessage(messageType) {
9077
+ return (target, propertyKey, descriptor) => {
9078
+ const constructor = target.constructor;
9079
+ let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
9080
+ if (!list) {
9081
+ list = [];
9082
+ ReflectUtils.defineMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);
9083
+ }
9084
+ list.push({ propertyKey, messageType });
9085
+ if (!descriptor) {
9086
+ return descriptor;
9087
+ }
9088
+ const originalMethod = descriptor.value;
9089
+ descriptor.value = function(...args) {
9090
+ const result = originalMethod.apply(this, args);
9091
+ if (result instanceof Promise) {
9092
+ result.then((data) => {
9093
+ const appHost2 = SwcUtils.getAppHost(this);
9094
+ if (appHost2) {
9095
+ appHost2.publishMessage({
9096
+ publisher: this,
9097
+ data,
9098
+ type: messageType
9099
+ });
9100
+ }
9101
+ }).catch((err) => {
9102
+ console.warn("publishSwcAppMessage async error:", err);
9103
+ });
9104
+ } else {
9105
+ const appHost2 = SwcUtils.getAppHost(this);
9106
+ if (appHost2) {
9107
+ appHost2.publishMessage({
9108
+ publisher: this,
9109
+ data: result,
9110
+ type: messageType
9111
+ });
9112
+ }
9113
+ }
9114
+ return result;
9115
+ };
9116
+ return descriptor;
9117
+ };
9118
+ }
9119
+ function publishSwcAppMessage(targetOrMessageType, propertyKey, descriptor) {
9120
+ if (targetOrMessageType && typeof targetOrMessageType === "object" && propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol") && descriptor) {
9121
+ const target = targetOrMessageType;
9122
+ return createPublishSwcAppMessage()(target, propertyKey, descriptor);
9123
+ }
9124
+ let messageType;
9125
+ if (typeof targetOrMessageType === "string") {
9126
+ messageType = targetOrMessageType;
9127
+ }
9128
+ return createPublishSwcAppMessage(messageType);
8934
9129
  }
8935
- var getSubscribeSwcAppRouteChangeMetadata = (target) => {
9130
+ var getPublishSwcAppMessageMetadata = (target) => {
8936
9131
  const constructor = target instanceof Function ? target : target.constructor;
8937
- return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
9132
+ return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
8938
9133
  };
8939
9134
 
8940
9135
  // ../simple-boot/dist/esm/decorators/SimDecorator.js