@dooboostore/simple-web-component 1.0.43 → 1.0.45

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 (146) hide show
  1. package/README.md +312 -63
  2. package/dist/cjs/SwcAppEngine.js +3 -1
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  5. package/dist/cjs/decorators/applyAttribute.js +66 -43
  6. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  7. package/dist/cjs/decorators/applyClass.js +110 -43
  8. package/dist/cjs/decorators/applyClass.js.map +3 -3
  9. package/dist/cjs/decorators/applyNode.js +200 -112
  10. package/dist/cjs/decorators/applyNode.js.map +2 -2
  11. package/dist/cjs/decorators/applyProperty.js +49 -45
  12. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  13. package/dist/cjs/decorators/applyStyle.js +92 -37
  14. package/dist/cjs/decorators/applyStyle.js.map +3 -3
  15. package/dist/cjs/decorators/{changedAttributeThis.js → changedAttribute.js} +6 -6
  16. package/dist/cjs/decorators/changedAttribute.js.map +7 -0
  17. package/dist/cjs/decorators/elementDefine.js +81 -31
  18. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  19. package/dist/cjs/decorators/emitCustomEvent.js +80 -52
  20. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  21. package/dist/cjs/decorators/index.js +1 -1
  22. package/dist/cjs/decorators/index.js.map +2 -2
  23. package/dist/cjs/decorators/publishSwcAppMessage.js +5 -5
  24. package/dist/cjs/decorators/publishSwcAppMessage.js.map +3 -3
  25. package/dist/cjs/decorators/query.js +133 -147
  26. package/dist/cjs/decorators/query.js.map +3 -3
  27. package/dist/cjs/decorators/queryAll.js +143 -132
  28. package/dist/cjs/decorators/queryAll.js.map +3 -3
  29. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
  30. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  31. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
  32. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  33. package/dist/cjs/elements/SwcAppMixin.js +17 -2
  34. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  35. package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
  36. package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
  37. package/dist/cjs/index.js +1 -0
  38. package/dist/cjs/index.js.map +2 -2
  39. package/dist/cjs/router/ElementRouter.js +4 -0
  40. package/dist/cjs/router/ElementRouter.js.map +2 -2
  41. package/dist/cjs/types/window.d.js.map +1 -1
  42. package/dist/esm/SwcAppEngine.js +3 -1
  43. package/dist/esm/SwcAppEngine.js.map +2 -2
  44. package/dist/esm/decorators/addEventListener.js.map +2 -2
  45. package/dist/esm/decorators/applyAttribute.js +66 -43
  46. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  47. package/dist/esm/decorators/applyClass.js +110 -43
  48. package/dist/esm/decorators/applyClass.js.map +3 -3
  49. package/dist/esm/decorators/applyNode.js +200 -112
  50. package/dist/esm/decorators/applyNode.js.map +2 -2
  51. package/dist/esm/decorators/applyProperty.js +49 -45
  52. package/dist/esm/decorators/applyProperty.js.map +2 -2
  53. package/dist/esm/decorators/applyStyle.js +92 -37
  54. package/dist/esm/decorators/applyStyle.js.map +3 -3
  55. package/dist/esm/decorators/{changedAttributeThis.js → changedAttribute.js} +3 -3
  56. package/dist/esm/decorators/changedAttribute.js.map +7 -0
  57. package/dist/esm/decorators/elementDefine.js +79 -29
  58. package/dist/esm/decorators/elementDefine.js.map +2 -2
  59. package/dist/esm/decorators/emitCustomEvent.js +80 -52
  60. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  61. package/dist/esm/decorators/index.js +1 -1
  62. package/dist/esm/decorators/index.js.map +1 -1
  63. package/dist/esm/decorators/publishSwcAppMessage.js +5 -5
  64. package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
  65. package/dist/esm/decorators/query.js +133 -147
  66. package/dist/esm/decorators/query.js.map +3 -3
  67. package/dist/esm/decorators/queryAll.js +143 -132
  68. package/dist/esm/decorators/queryAll.js.map +3 -3
  69. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
  70. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  71. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
  72. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  73. package/dist/esm/elements/SwcAppMixin.js +18 -3
  74. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  75. package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
  76. package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
  77. package/dist/esm/index.js +1 -0
  78. package/dist/esm/index.js.map +2 -2
  79. package/dist/esm/router/ElementRouter.js +4 -0
  80. package/dist/esm/router/ElementRouter.js.map +2 -2
  81. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1118 -633
  82. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  83. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  84. package/dist/types/decorators/addEventListener.d.ts +19 -15
  85. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  86. package/dist/types/decorators/applyAttribute.d.ts +45 -26
  87. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  88. package/dist/types/decorators/applyClass.d.ts +19 -38
  89. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  90. package/dist/types/decorators/applyNode.d.ts +175 -32
  91. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  92. package/dist/types/decorators/applyProperty.d.ts +38 -25
  93. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  94. package/dist/types/decorators/applyStyle.d.ts +10 -9
  95. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  96. package/dist/types/decorators/{changedAttributeThis.d.ts → changedAttribute.d.ts} +2 -2
  97. package/dist/types/decorators/changedAttribute.d.ts.map +1 -0
  98. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  99. package/dist/types/decorators/emitCustomEvent.d.ts +6 -12
  100. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  101. package/dist/types/decorators/index.d.ts +1 -1
  102. package/dist/types/decorators/index.d.ts.map +1 -1
  103. package/dist/types/decorators/publishSwcAppMessage.d.ts +1 -1
  104. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  105. package/dist/types/decorators/query.d.ts +16 -29
  106. package/dist/types/decorators/query.d.ts.map +1 -1
  107. package/dist/types/decorators/queryAll.d.ts +16 -23
  108. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  109. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +1 -0
  110. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  111. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
  112. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  113. package/dist/types/elements/SwcAppMixin.d.ts +4 -4
  114. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  115. package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
  116. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
  117. package/dist/types/index.d.ts +1 -0
  118. package/dist/types/index.d.ts.map +1 -1
  119. package/dist/types/router/ElementRouter.d.ts.map +1 -1
  120. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1118 -633
  121. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  122. package/package.json +1 -1
  123. package/src/SwcAppEngine.ts +3 -1
  124. package/src/decorators/addEventListener.ts +31 -25
  125. package/src/decorators/applyAttribute.ts +164 -86
  126. package/src/decorators/applyClass.ts +161 -41
  127. package/src/decorators/applyNode.ts +408 -108
  128. package/src/decorators/applyProperty.ts +100 -89
  129. package/src/decorators/applyStyle.ts +131 -37
  130. package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
  131. package/src/decorators/elementDefine.ts +96 -30
  132. package/src/decorators/emitCustomEvent.ts +92 -60
  133. package/src/decorators/index.ts +1 -1
  134. package/src/decorators/publishSwcAppMessage.ts +1 -1
  135. package/src/decorators/query.ts +155 -162
  136. package/src/decorators/queryAll.ts +157 -139
  137. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -0
  138. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +3 -1
  139. package/src/elements/SwcAppMixin.ts +43 -24
  140. package/src/examples/RxJSOperatorsExample.ts +279 -0
  141. package/src/index.ts +2 -0
  142. package/src/router/ElementRouter.ts +4 -0
  143. package/src/types/window.d.ts +3 -0
  144. package/dist/cjs/decorators/changedAttributeThis.js.map +0 -7
  145. package/dist/esm/decorators/changedAttributeThis.js.map +0 -7
  146. package/dist/types/decorators/changedAttributeThis.d.ts.map +0 -1
@@ -6342,6 +6342,155 @@ var getAddEventListenerMetadata = (target) => {
6342
6342
  return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
6343
6343
  };
6344
6344
 
6345
+ // ../core/dist/esm/message/operators/debounceTime.js
6346
+ function debounceTime(duration, config) {
6347
+ return (source) => {
6348
+ return new Observable((subscriber) => {
6349
+ const setTimeoutFn = config?.setTimeout || setTimeout;
6350
+ const clearTimeoutFn = config?.clearTimeout || clearTimeout;
6351
+ let timeoutId = null;
6352
+ let lastValue;
6353
+ let hasValue = false;
6354
+ const subscription = source.subscribe({
6355
+ next: (value) => {
6356
+ clearTimeoutFn(timeoutId);
6357
+ lastValue = value;
6358
+ hasValue = true;
6359
+ timeoutId = setTimeoutFn(() => {
6360
+ if (hasValue) {
6361
+ subscriber.next(lastValue);
6362
+ hasValue = false;
6363
+ }
6364
+ }, duration);
6365
+ },
6366
+ error: (err) => {
6367
+ clearTimeoutFn(timeoutId);
6368
+ subscriber.error(err);
6369
+ },
6370
+ complete: () => {
6371
+ clearTimeoutFn(timeoutId);
6372
+ if (hasValue) {
6373
+ subscriber.next(lastValue);
6374
+ }
6375
+ subscriber.complete();
6376
+ }
6377
+ });
6378
+ return subscription;
6379
+ });
6380
+ };
6381
+ }
6382
+
6383
+ // ../core/dist/esm/message/operators/distinctUntilChanged.js
6384
+ function distinctUntilChanged(comparator) {
6385
+ return (source) => {
6386
+ return new Observable((subscriber) => {
6387
+ let hasValue = false;
6388
+ let previousValue;
6389
+ const subscription = source.subscribe({
6390
+ next: (value) => {
6391
+ const areEqual = hasValue ? comparator ? comparator(previousValue, value) : previousValue === value : false;
6392
+ if (!areEqual) {
6393
+ hasValue = true;
6394
+ previousValue = value;
6395
+ subscriber.next(value);
6396
+ }
6397
+ },
6398
+ error: (err) => {
6399
+ subscriber.error(err);
6400
+ },
6401
+ complete: () => {
6402
+ subscriber.complete();
6403
+ }
6404
+ });
6405
+ return subscription;
6406
+ });
6407
+ };
6408
+ }
6409
+
6410
+ // ../core/dist/esm/message/operators/throttleTime.js
6411
+ function throttleTime(duration, config) {
6412
+ const leading = config?.leading ?? true;
6413
+ const trailing = config?.trailing ?? false;
6414
+ const setTimeoutFn = config?.setTimeout || setTimeout;
6415
+ const clearTimeoutFn = config?.clearTimeout || clearTimeout;
6416
+ return (source) => {
6417
+ return new Observable((subscriber) => {
6418
+ let throttled = false;
6419
+ let trailingValue;
6420
+ let hasTrailingValue = false;
6421
+ let timeoutId = null;
6422
+ const endThrottle = () => {
6423
+ if (timeoutId !== null) {
6424
+ clearTimeoutFn(timeoutId);
6425
+ timeoutId = null;
6426
+ }
6427
+ throttled = false;
6428
+ if (trailing && hasTrailingValue) {
6429
+ const valueToEmit = trailingValue;
6430
+ hasTrailingValue = false;
6431
+ trailingValue = void 0;
6432
+ Promise.resolve().then(() => {
6433
+ if (!subscriber.closed) {
6434
+ subscriber.next(valueToEmit);
6435
+ startThrottle();
6436
+ }
6437
+ });
6438
+ }
6439
+ };
6440
+ const startThrottle = () => {
6441
+ if (throttled) {
6442
+ return;
6443
+ }
6444
+ throttled = true;
6445
+ timeoutId = setTimeoutFn(() => {
6446
+ endThrottle();
6447
+ }, duration);
6448
+ };
6449
+ const subscription = source.subscribe({
6450
+ next: (value) => {
6451
+ if (!throttled) {
6452
+ if (leading) {
6453
+ subscriber.next(value);
6454
+ } else if (trailing) {
6455
+ trailingValue = value;
6456
+ hasTrailingValue = true;
6457
+ }
6458
+ startThrottle();
6459
+ } else if (trailing) {
6460
+ trailingValue = value;
6461
+ hasTrailingValue = true;
6462
+ }
6463
+ },
6464
+ error: (err) => {
6465
+ if (timeoutId !== null) {
6466
+ clearTimeoutFn(timeoutId);
6467
+ timeoutId = null;
6468
+ }
6469
+ throttled = false;
6470
+ subscriber.error(err);
6471
+ },
6472
+ complete: () => {
6473
+ if (timeoutId !== null) {
6474
+ clearTimeoutFn(timeoutId);
6475
+ timeoutId = null;
6476
+ }
6477
+ if (trailing && hasTrailingValue) {
6478
+ subscriber.next(trailingValue);
6479
+ }
6480
+ subscriber.complete();
6481
+ }
6482
+ });
6483
+ return () => {
6484
+ subscription.unsubscribe();
6485
+ if (timeoutId !== null) {
6486
+ clearTimeoutFn(timeoutId);
6487
+ timeoutId = null;
6488
+ }
6489
+ };
6490
+ });
6491
+ };
6492
+ }
6493
+
6345
6494
  // src/decorators/lifecycles.ts
6346
6495
  var ON_INITIALIZE_METADATA_KEY = Symbol.for("simple-web-component:on-constructor");
6347
6496
  var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-connected");
@@ -6846,7 +6995,7 @@ var ElementApply = class _ElementApply {
6846
6995
  if (!config?.targetVariableName || config?.targetVariableName && tit.variables.find((v) => v === config?.targetVariableName)) {
6847
6996
  const data = new Function("ctx", `
6848
6997
  with(ctx) {
6849
- return function(){
6998
+ return function(event){
6850
6999
  return (${this.stripWrap(tit.script)});
6851
7000
  }
6852
7001
  }
@@ -8800,18 +8949,32 @@ var SwcUtils;
8800
8949
 
8801
8950
  // src/decorators/emitCustomEvent.ts
8802
8951
  var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for("simple-web-component:emit-custom-event");
8803
- function emitCustomEvent(selectorOrTarget, type, options = {}) {
8952
+ function emitCustomEvent(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor) {
8953
+ if (typeof selectorOrTarget === "object" && typeof typeOrPropertyKey === "string" && typeof optionsOrDescriptor === "object" && "value" in optionsOrDescriptor) {
8954
+ throw new Error(`@emitCustomEvent decorator cannot be used on properties. (Property: ${String(typeOrPropertyKey)})`);
8955
+ }
8956
+ if ((typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") && typeof typeOrPropertyKey === "string") {
8957
+ return createEmitDecorator(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor);
8958
+ }
8959
+ if (typeof selectorOrTarget === "string" && typeOrPropertyKey !== "string") {
8960
+ return createEmitDecorator("$this", selectorOrTarget, typeOrPropertyKey);
8961
+ }
8962
+ throw new Error("Invalid @emitCustomEvent usage");
8963
+ }
8964
+ function createEmitDecorator(selector, type, options) {
8804
8965
  return (targetObj, propertyKey, descriptor) => {
8805
8966
  const constructor = targetObj.constructor;
8806
- const fullOptions = { ...options, type };
8807
- if (fullOptions.bubbles === void 0) fullOptions.bubbles = true;
8808
- if (fullOptions.composed === void 0) fullOptions.composed = true;
8967
+ const fullOptions = { ...options || {}, type };
8968
+ if (fullOptions.bubbles === void 0)
8969
+ fullOptions.bubbles = true;
8970
+ if (fullOptions.composed === void 0)
8971
+ fullOptions.composed = true;
8809
8972
  let list = ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
8810
8973
  if (!list) {
8811
8974
  list = [];
8812
8975
  ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
8813
8976
  }
8814
- list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
8977
+ list.push({ propertyKey, selector, type, options: fullOptions });
8815
8978
  const original = descriptor.value;
8816
8979
  descriptor.value = function(...args) {
8817
8980
  ensureInit(this);
@@ -8823,45 +8986,72 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
8823
8986
  composed: fullOptions.composed,
8824
8987
  cancelable: fullOptions.cancelable
8825
8988
  });
8826
- const hostSet = SwcUtils.getHostSet(this);
8827
8989
  const conf = getElementConfig(this);
8828
8990
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
8991
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
8829
8992
  const eventTargets = [];
8830
- if (selectorOrTarget === "$window") eventTargets.push(currentWin);
8831
- else if (selectorOrTarget === "$document") eventTargets.push(currentWin.document);
8832
- else if (selectorOrTarget === "$host") {
8833
- if (hostSet.$host) eventTargets.push(hostSet.$host);
8834
- } else if (selectorOrTarget === "$parentHost") {
8835
- if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
8836
- } else if (selectorOrTarget === "$appHost") {
8837
- if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
8838
- } else if (selectorOrTarget === "$firstHost") {
8839
- if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
8840
- } else if (selectorOrTarget === "$lastHost") {
8841
- if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
8842
- } else if (selectorOrTarget === "$firstAppHost") {
8843
- if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
8844
- } else if (selectorOrTarget === "$lastAppHost") {
8845
- if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
8846
- } else if (selectorOrTarget === "$hosts") {
8847
- hostSet.$hosts.forEach((h) => eventTargets.push(h));
8848
- } else if (selectorOrTarget === "$appHosts") {
8849
- hostSet.$appHosts.forEach((h) => eventTargets.push(h));
8850
- } else if (selectorOrTarget === "$this" || !selectorOrTarget) {
8851
- eventTargets.push(this);
8993
+ let resolvedSelector = selector;
8994
+ if (typeof selector === "function") {
8995
+ resolvedSelector = selector(this, hostSet);
8996
+ }
8997
+ if (resolvedSelector instanceof currentWin.Element) {
8998
+ eventTargets.push(resolvedSelector);
8999
+ } else if (resolvedSelector instanceof currentWin.NodeList) {
9000
+ eventTargets.push(...Array.from(resolvedSelector));
9001
+ } else if (Array.isArray(resolvedSelector)) {
9002
+ eventTargets.push(...resolvedSelector);
9003
+ } else if (resolvedSelector === null) {
8852
9004
  } else {
8853
- const r = fullOptions.root || "auto";
8854
- const searchRoots = [];
8855
- if (r === "auto") searchRoots.push(this.shadowRoot || this);
8856
- else if (r === "light") searchRoots.push(this);
8857
- else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
8858
- else if (r === "all") {
8859
- searchRoots.push(this);
8860
- if (this.shadowRoot) searchRoots.push(this.shadowRoot);
9005
+ const stringSelector = resolvedSelector;
9006
+ if (stringSelector === "$window")
9007
+ eventTargets.push(currentWin);
9008
+ else if (stringSelector === "$document")
9009
+ eventTargets.push(currentWin.document);
9010
+ else if (stringSelector === "$host") {
9011
+ if (hostSet.$host)
9012
+ eventTargets.push(hostSet.$host);
9013
+ } else if (stringSelector === "$parentHost") {
9014
+ if (hostSet.$parentHost)
9015
+ eventTargets.push(hostSet.$parentHost);
9016
+ } else if (stringSelector === "$appHost") {
9017
+ if (hostSet.$appHost)
9018
+ eventTargets.push(hostSet.$appHost);
9019
+ } else if (stringSelector === "$firstHost") {
9020
+ if (hostSet.$firstHost)
9021
+ eventTargets.push(hostSet.$firstHost);
9022
+ } else if (stringSelector === "$lastHost") {
9023
+ if (hostSet.$lastHost)
9024
+ eventTargets.push(hostSet.$lastHost);
9025
+ } else if (stringSelector === "$firstAppHost") {
9026
+ if (hostSet.$firstAppHost)
9027
+ eventTargets.push(hostSet.$firstAppHost);
9028
+ } else if (stringSelector === "$lastAppHost") {
9029
+ if (hostSet.$lastAppHost)
9030
+ eventTargets.push(hostSet.$lastAppHost);
9031
+ } else if (stringSelector === "$hosts") {
9032
+ hostSet.$hosts.forEach((h) => eventTargets.push(h));
9033
+ } else if (stringSelector === "$appHosts") {
9034
+ hostSet.$appHosts.forEach((h) => eventTargets.push(h));
9035
+ } else if (stringSelector === "$this" || !stringSelector) {
9036
+ eventTargets.push(this);
9037
+ } else {
9038
+ const r = fullOptions.root || "auto";
9039
+ const searchRoots = [];
9040
+ if (r === "auto")
9041
+ searchRoots.push(this.shadowRoot || this);
9042
+ else if (r === "light")
9043
+ searchRoots.push(this);
9044
+ else if (r === "shadow" && this.shadowRoot)
9045
+ searchRoots.push(this.shadowRoot);
9046
+ else if (r === "all") {
9047
+ searchRoots.push(this);
9048
+ if (this.shadowRoot)
9049
+ searchRoots.push(this.shadowRoot);
9050
+ }
9051
+ searchRoots.forEach((sr) => {
9052
+ sr.querySelectorAll(stringSelector).forEach((el) => eventTargets.push(el));
9053
+ });
8861
9054
  }
8862
- searchRoots.forEach((sr) => {
8863
- sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
8864
- });
8865
9055
  }
8866
9056
  eventTargets.forEach((t) => {
8867
9057
  if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
@@ -8884,20 +9074,8 @@ var getEmitCustomEventMetadataList = (target) => {
8884
9074
  return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
8885
9075
  };
8886
9076
  var emit = emitCustomEvent;
8887
- function emitCustomEventThis(type, optionsOrAttributeaName) {
8888
- if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
8889
- return emitCustomEventThis(type, { attributeName: optionsOrAttributeaName });
8890
- } else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "object") {
8891
- if (!optionsOrAttributeaName.attributeName) {
8892
- optionsOrAttributeaName.attributeName = `on-emit-${type}`;
8893
- }
8894
- return emitCustomEvent("$this", type, optionsOrAttributeaName);
8895
- } else {
8896
- return emitCustomEvent("$this", type, { attributeName: `on-emit-${type}` });
8897
- }
8898
- }
8899
9077
 
8900
- // src/decorators/changedAttributeThis.ts
9078
+ // src/decorators/changedAttribute.ts
8901
9079
  var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
8902
9080
  var convertValue = (val, type) => {
8903
9081
  if (val === null || val === void 0) return val;
@@ -8905,7 +9083,7 @@ var convertValue = (val, type) => {
8905
9083
  if (type === Boolean) return val === "false" || val === "0" ? false : true;
8906
9084
  return val;
8907
9085
  };
8908
- function changedAttributeThis(attributeName, options = {}) {
9086
+ function changedAttribute(attributeName, options = {}) {
8909
9087
  return (target, propertyKey) => {
8910
9088
  const constructor = target.constructor;
8911
9089
  let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
@@ -8945,150 +9123,141 @@ var convertAttributeValue = (val, type) => {
8945
9123
 
8946
9124
  // src/decorators/query.ts
8947
9125
  var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
8948
- function query(selectorOrTarget, options = {}) {
8949
- return (targetObj, propertyKey, descriptor) => {
8950
- if (descriptor !== void 0) {
8951
- throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
8952
- }
8953
- const constructor = targetObj.constructor;
8954
- let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
8955
- if (!queries) {
8956
- queries = [];
8957
- ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
8958
- }
8959
- queries.push({ propertyKey, selector: selectorOrTarget, options });
8960
- Object.defineProperty(targetObj, propertyKey, {
8961
- get() {
8962
- ensureInit(this);
8963
- const selector = selectorOrTarget;
8964
- const r = options.root || "auto";
8965
- const applyRoot = (t) => {
8966
- if (!t || !(t instanceof HTMLElement))
8967
- return t;
8968
- if (r === "auto")
8969
- return t.shadowRoot || t;
8970
- if (r === "shadow")
8971
- return t.shadowRoot;
8972
- if (r === "light")
8973
- return t;
8974
- if (r === "all")
8975
- return t.shadowRoot || t;
8976
- return t;
8977
- };
8978
- const hostSet = SwcUtils.getHostSet(this);
8979
- if (selector === "$this")
8980
- return applyRoot(this);
8981
- if (selector === "$host")
8982
- return applyRoot(hostSet.$host);
8983
- if (selector === "$parentHost")
8984
- return applyRoot(hostSet.$parentHost);
8985
- if (selector === "$appHost")
8986
- return applyRoot(hostSet.$appHost);
8987
- if (selector === "$firstHost")
8988
- return applyRoot(hostSet.$firstHost);
8989
- if (selector === "$lastHost")
8990
- return applyRoot(hostSet.$lastHost);
8991
- if (selector === "$firstAppHost")
8992
- return applyRoot(hostSet.$firstAppHost);
8993
- if (selector === "$lastAppHost")
8994
- return applyRoot(hostSet.$lastAppHost);
8995
- const config = getElementConfig(this);
8996
- const win = config?.window || window;
8997
- if (selector === "$window")
8998
- return win;
8999
- if (selector === "$document")
9000
- return win.document;
9001
- if (r === "shadow")
9002
- return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
9003
- if (r === "light")
9004
- return this.querySelector(selector);
9005
- if (r === "all") {
9006
- const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
9007
- return shadowMatch || this.querySelector(selector);
9008
- }
9009
- return (this.shadowRoot || this).querySelector(selector);
9010
- },
9011
- set(nv) {
9012
- ensureInit(this);
9013
- if (nv === null || nv === void 0) {
9014
- const selector = selectorOrTarget;
9015
- if (selector.startsWith("$") && selector !== "$this")
9016
- return;
9017
- const r = options.root || "auto";
9018
- const targets = [];
9019
- if (r === "shadow") {
9020
- if (this.shadowRoot?.querySelector(selector))
9021
- targets.push(this.shadowRoot.querySelector(selector));
9022
- } else if (r === "light") {
9023
- if (this.querySelector(selector))
9024
- targets.push(this.querySelector(selector));
9025
- } else if (r === "all") {
9026
- if (this.shadowRoot?.querySelector(selector))
9027
- targets.push(this.shadowRoot.querySelector(selector));
9028
- if (this.querySelector(selector))
9029
- targets.push(this.querySelector(selector));
9126
+ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
9127
+ if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
9128
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
9129
+ }
9130
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
9131
+ return (targetObj, propertyKey, descriptor2) => {
9132
+ if (descriptor2 !== void 0) {
9133
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
9134
+ }
9135
+ const constructor = targetObj.constructor;
9136
+ let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
9137
+ if (!queries) {
9138
+ queries = [];
9139
+ ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
9140
+ }
9141
+ queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
9142
+ Object.defineProperty(targetObj, propertyKey, {
9143
+ get() {
9144
+ ensureInit(this);
9145
+ const config = getElementConfig(this);
9146
+ const win = config?.window || window;
9147
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9148
+ let resolvedSelector;
9149
+ let resolvedElement = null;
9150
+ if (typeof selectorOrTarget === "function") {
9151
+ const result = selectorOrTarget(this, hostSet);
9152
+ if (result instanceof win.Node || result instanceof win.Element) {
9153
+ resolvedElement = result instanceof win.HTMLElement ? result : null;
9154
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
9155
+ resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? result[0] : null;
9156
+ }
9030
9157
  } else {
9031
- const el = (this.shadowRoot || this).querySelector(selector);
9032
- if (el)
9033
- targets.push(el);
9158
+ resolvedSelector = selectorOrTarget;
9159
+ const r = optionsOrPropertyKey?.root || "auto";
9160
+ const applyRoot = (t) => {
9161
+ if (!t || !(t instanceof HTMLElement))
9162
+ return t;
9163
+ if (r === "auto")
9164
+ return t.shadowRoot || t;
9165
+ if (r === "shadow")
9166
+ return t.shadowRoot;
9167
+ if (r === "light")
9168
+ return t;
9169
+ if (r === "all")
9170
+ return t.shadowRoot || t;
9171
+ return t;
9172
+ };
9173
+ if (resolvedSelector === "$this")
9174
+ resolvedElement = applyRoot(this);
9175
+ else if (resolvedSelector === "$host")
9176
+ resolvedElement = applyRoot(hostSet.$host);
9177
+ else if (resolvedSelector === "$parentHost")
9178
+ resolvedElement = applyRoot(hostSet.$parentHost);
9179
+ else if (resolvedSelector === "$appHost")
9180
+ resolvedElement = applyRoot(hostSet.$appHost);
9181
+ else if (resolvedSelector === "$firstHost")
9182
+ resolvedElement = applyRoot(hostSet.$firstHost);
9183
+ else if (resolvedSelector === "$lastHost")
9184
+ resolvedElement = applyRoot(hostSet.$lastHost);
9185
+ else if (resolvedSelector === "$firstAppHost")
9186
+ resolvedElement = applyRoot(hostSet.$firstAppHost);
9187
+ else if (resolvedSelector === "$lastAppHost")
9188
+ resolvedElement = applyRoot(hostSet.$lastAppHost);
9189
+ else if (resolvedSelector === "$window")
9190
+ return win;
9191
+ else if (resolvedSelector === "$document")
9192
+ return win.document;
9193
+ else {
9194
+ if (r === "shadow")
9195
+ resolvedElement = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
9196
+ else if (r === "light")
9197
+ resolvedElement = this.querySelector(resolvedSelector);
9198
+ else if (r === "all") {
9199
+ const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
9200
+ resolvedElement = shadowMatch || this.querySelector(resolvedSelector);
9201
+ } else
9202
+ resolvedElement = (this.shadowRoot || this).querySelector(resolvedSelector);
9203
+ }
9034
9204
  }
9035
- targets.forEach((t) => t.remove());
9036
- }
9037
- },
9038
- enumerable: true,
9039
- configurable: true
9040
- });
9041
- };
9042
- }
9043
- function queryThis(targetOrOptions, propertyKey) {
9044
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9045
- return query("$this", {})(targetOrOptions, propertyKey);
9046
- }
9047
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9048
- return query("$this", targetOrOptions);
9049
- } else {
9050
- return query("$this", {});
9051
- }
9052
- }
9053
- function queryWindow(targetOrOptions, propertyKey) {
9054
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9055
- return query("$window", {})(targetOrOptions, propertyKey);
9056
- }
9057
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9058
- return query("$window", targetOrOptions);
9059
- } else {
9060
- return query("$window", {});
9061
- }
9062
- }
9063
- function queryDocument(targetOrOptions, propertyKey) {
9064
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9065
- return query("$document", {})(targetOrOptions, propertyKey);
9066
- }
9067
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9068
- return query("$document", targetOrOptions);
9069
- } else {
9070
- return query("$document", {});
9071
- }
9072
- }
9073
- function queryHost(targetOrOptions, propertyKey) {
9074
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9075
- return query("$host", {})(targetOrOptions, propertyKey);
9076
- }
9077
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9078
- return query("$host", targetOrOptions);
9079
- } else {
9080
- return query("$host", {});
9081
- }
9082
- }
9083
- function queryAppHost(targetOrOptions, propertyKey) {
9084
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9085
- return query("$appHost", {})(targetOrOptions, propertyKey);
9086
- }
9087
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9088
- return query("$appHost", targetOrOptions);
9089
- } else {
9090
- return query("$appHost", {});
9205
+ if (resolvedElement instanceof win.HTMLElement && optionsOrPropertyKey?.filter) {
9206
+ const shouldInclude = optionsOrPropertyKey.filter(resolvedElement, { currentThis: this, helper: hostSet });
9207
+ if (!shouldInclude) {
9208
+ return null;
9209
+ }
9210
+ }
9211
+ return resolvedElement;
9212
+ },
9213
+ set(nv) {
9214
+ ensureInit(this);
9215
+ if (nv === null || nv === void 0) {
9216
+ const config = getElementConfig(this);
9217
+ const win = config?.window || window;
9218
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9219
+ if (typeof selectorOrTarget === "function") {
9220
+ const result = selectorOrTarget(this, hostSet);
9221
+ if (result instanceof win.Element) {
9222
+ result.remove();
9223
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
9224
+ const el = result.length > 0 ? result[0] : null;
9225
+ if (el instanceof win.Element) {
9226
+ el.remove();
9227
+ }
9228
+ }
9229
+ return;
9230
+ }
9231
+ const resolvedSelector = selectorOrTarget;
9232
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
9233
+ return;
9234
+ const r = optionsOrPropertyKey?.root || "auto";
9235
+ const targets = [];
9236
+ if (r === "shadow") {
9237
+ if (this.shadowRoot?.querySelector(resolvedSelector))
9238
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
9239
+ } else if (r === "light") {
9240
+ if (this.querySelector(resolvedSelector))
9241
+ targets.push(this.querySelector(resolvedSelector));
9242
+ } else if (r === "all") {
9243
+ if (this.shadowRoot?.querySelector(resolvedSelector))
9244
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
9245
+ if (this.querySelector(resolvedSelector))
9246
+ targets.push(this.querySelector(resolvedSelector));
9247
+ } else {
9248
+ const el = (this.shadowRoot || this).querySelector(resolvedSelector);
9249
+ if (el)
9250
+ targets.push(el);
9251
+ }
9252
+ targets.forEach((t) => t.remove());
9253
+ }
9254
+ },
9255
+ enumerable: true,
9256
+ configurable: true
9257
+ });
9258
+ };
9091
9259
  }
9260
+ return query("$this", selectorOrTarget);
9092
9261
  }
9093
9262
  var getQueryMetadata = (target) => {
9094
9263
  const constructor = target instanceof Function ? target : target.constructor;
@@ -9097,139 +9266,153 @@ var getQueryMetadata = (target) => {
9097
9266
 
9098
9267
  // src/decorators/queryAll.ts
9099
9268
  var QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
9100
- function queryAll(selectorOrTarget, options = {}) {
9101
- return (targetObj, propertyKey, descriptor) => {
9102
- if (descriptor !== void 0) {
9103
- throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
9104
- }
9105
- const constructor = targetObj.constructor;
9106
- let queries = ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
9107
- if (!queries) {
9108
- queries = [];
9109
- ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
9110
- }
9111
- queries.push({ propertyKey, selector: selectorOrTarget, options });
9112
- Object.defineProperty(targetObj, propertyKey, {
9113
- get() {
9114
- ensureInit(this);
9115
- const selector = selectorOrTarget;
9116
- const r = options.root || "auto";
9117
- const applyRoot = (t) => {
9118
- if (!t)
9119
- return [];
9120
- const items = Array.isArray(t) ? t : [t];
9121
- const results = [];
9122
- items.forEach((it) => {
9123
- if (!(it instanceof HTMLElement)) {
9124
- results.push(it);
9125
- return;
9269
+ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
9270
+ if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
9271
+ throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
9272
+ }
9273
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
9274
+ return (targetObj, propertyKey, descriptor2) => {
9275
+ if (descriptor2 !== void 0) {
9276
+ throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
9277
+ }
9278
+ const constructor = targetObj.constructor;
9279
+ let queries = ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
9280
+ if (!queries) {
9281
+ queries = [];
9282
+ ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
9283
+ }
9284
+ queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
9285
+ Object.defineProperty(targetObj, propertyKey, {
9286
+ get() {
9287
+ ensureInit(this);
9288
+ const config = getElementConfig(this);
9289
+ const win = config?.window || window;
9290
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9291
+ let resolvedSelector;
9292
+ let resolvedElements = [];
9293
+ if (typeof selectorOrTarget === "function") {
9294
+ const result = selectorOrTarget(this, hostSet);
9295
+ if (result instanceof win.NodeList) {
9296
+ resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
9297
+ } else if (Array.isArray(result)) {
9298
+ resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
9126
9299
  }
9127
- if (r === "auto")
9128
- results.push(it.shadowRoot || it);
9300
+ } else {
9301
+ resolvedSelector = selectorOrTarget;
9302
+ const r = optionsOrPropertyKey?.root || "auto";
9303
+ const applyRoot = (t) => {
9304
+ if (!t)
9305
+ return [];
9306
+ const items = Array.isArray(t) ? t : [t];
9307
+ const results = [];
9308
+ items.forEach((it) => {
9309
+ if (!(it instanceof HTMLElement)) {
9310
+ results.push(it);
9311
+ return;
9312
+ }
9313
+ if (r === "auto")
9314
+ results.push(it.shadowRoot || it);
9315
+ else {
9316
+ if (r === "light" || r === "all")
9317
+ results.push(it);
9318
+ if ((r === "shadow" || r === "all") && it.shadowRoot)
9319
+ results.push(it.shadowRoot);
9320
+ }
9321
+ });
9322
+ return results;
9323
+ };
9324
+ if (resolvedSelector === "$hosts")
9325
+ resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
9326
+ else if (resolvedSelector === "$appHosts")
9327
+ resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
9328
+ else if (resolvedSelector === "$host")
9329
+ resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
9330
+ else if (resolvedSelector === "$parentHost")
9331
+ resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
9332
+ else if (resolvedSelector === "$appHost")
9333
+ resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
9334
+ else if (resolvedSelector === "$firstHost")
9335
+ resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
9336
+ else if (resolvedSelector === "$lastHost")
9337
+ resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
9338
+ else if (resolvedSelector === "$firstAppHost")
9339
+ resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
9340
+ else if (resolvedSelector === "$lastAppHost")
9341
+ resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
9342
+ else if (resolvedSelector === "$window")
9343
+ return [win];
9344
+ else if (resolvedSelector === "$document")
9345
+ return [win.document];
9346
+ else if (resolvedSelector === "$this")
9347
+ resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
9129
9348
  else {
9130
- if (r === "light" || r === "all")
9131
- results.push(it);
9132
- if ((r === "shadow" || r === "all") && it.shadowRoot)
9133
- results.push(it.shadowRoot);
9349
+ if (r === "shadow")
9350
+ resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9351
+ else if (r === "light")
9352
+ resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
9353
+ else if (r === "all") {
9354
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9355
+ const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
9356
+ resolvedElements = [...sNodes, ...lNodes];
9357
+ } else
9358
+ resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
9134
9359
  }
9135
- });
9136
- return results;
9137
- };
9138
- const hostSet = SwcUtils.getHostSet(this);
9139
- if (selector === "$hosts")
9140
- return applyRoot(hostSet.$hosts);
9141
- if (selector === "$appHosts")
9142
- return applyRoot(hostSet.$appHosts);
9143
- if (selector === "$host")
9144
- return applyRoot(hostSet.$host);
9145
- if (selector === "$parentHost")
9146
- return applyRoot(hostSet.$parentHost);
9147
- if (selector === "$appHost")
9148
- return applyRoot(hostSet.$appHost);
9149
- if (selector === "$firstHost")
9150
- return applyRoot(hostSet.$firstHost);
9151
- if (selector === "$lastHost")
9152
- return applyRoot(hostSet.$lastHost);
9153
- if (selector === "$firstAppHost")
9154
- return applyRoot(hostSet.$firstAppHost);
9155
- if (selector === "$lastAppHost")
9156
- return applyRoot(hostSet.$lastAppHost);
9157
- const config = getElementConfig(this);
9158
- const win = config?.window || window;
9159
- if (selector === "$window")
9160
- return [win];
9161
- if (selector === "$document")
9162
- return [win.document];
9163
- if (selector === "$this")
9164
- return applyRoot(this);
9165
- if (r === "shadow")
9166
- return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9167
- if (r === "light")
9168
- return Array.from(this.querySelectorAll(selector));
9169
- if (r === "all") {
9170
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9171
- const lNodes = Array.from(this.querySelectorAll(selector));
9172
- return [...sNodes, ...lNodes];
9173
- }
9174
- const root = this.shadowRoot || this;
9175
- return Array.from(root.querySelectorAll(selector));
9176
- },
9177
- set(nv) {
9178
- ensureInit(this);
9179
- if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
9180
- const selector = selectorOrTarget;
9181
- if (selector.startsWith("$") && selector !== "$this")
9182
- return;
9183
- const r = options.root || "auto";
9184
- let targets = [];
9185
- if (r === "shadow")
9186
- targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9187
- else if (r === "light")
9188
- targets = Array.from(this.querySelectorAll(selector));
9189
- else if (r === "all") {
9190
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9191
- const lNodes = Array.from(this.querySelectorAll(selector));
9192
- targets = [...sNodes, ...lNodes];
9193
- } else {
9194
- targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
9195
9360
  }
9196
- targets.forEach((t) => t.remove());
9197
- }
9198
- },
9199
- enumerable: true,
9200
- configurable: true
9201
- });
9202
- };
9203
- }
9204
- function queryAllThis(targetOrOptions, propertyKey) {
9205
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9206
- return queryAll("$this", {})(targetOrOptions, propertyKey);
9207
- }
9208
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9209
- return queryAll("$this", targetOrOptions);
9210
- } else {
9211
- return queryAll("$this", {});
9212
- }
9213
- }
9214
- function allParentHost(targetOrOptions, propertyKey) {
9215
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9216
- return queryAll("$host", {})(targetOrOptions, propertyKey);
9217
- }
9218
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9219
- return queryAll("$host", targetOrOptions);
9220
- } else {
9221
- return queryAll("$host", {});
9222
- }
9223
- }
9224
- function allAppHost(targetOrOptions, propertyKey) {
9225
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
9226
- return queryAll("$appHost", {})(targetOrOptions, propertyKey);
9227
- }
9228
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
9229
- return queryAll("$appHost", targetOrOptions);
9230
- } else {
9231
- return queryAll("$appHost", {});
9361
+ if (optionsOrPropertyKey?.filter) {
9362
+ resolvedElements = resolvedElements.filter((el) => {
9363
+ if (!(el instanceof win.HTMLElement))
9364
+ return true;
9365
+ return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
9366
+ });
9367
+ }
9368
+ return resolvedElements;
9369
+ },
9370
+ set(nv) {
9371
+ ensureInit(this);
9372
+ if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
9373
+ const config = getElementConfig(this);
9374
+ const win = config?.window || window;
9375
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9376
+ if (typeof selectorOrTarget === "function") {
9377
+ const result = selectorOrTarget(this, hostSet);
9378
+ if (result instanceof win.NodeList) {
9379
+ Array.from(result).forEach((el) => {
9380
+ if (el instanceof win.Element)
9381
+ el.remove();
9382
+ });
9383
+ } else if (Array.isArray(result)) {
9384
+ result.forEach((el) => {
9385
+ if (el instanceof win.Element)
9386
+ el.remove();
9387
+ });
9388
+ }
9389
+ return;
9390
+ }
9391
+ const resolvedSelector = selectorOrTarget;
9392
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
9393
+ return;
9394
+ const r = optionsOrPropertyKey?.root || "auto";
9395
+ let targets = [];
9396
+ if (r === "shadow")
9397
+ targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9398
+ else if (r === "light")
9399
+ targets = Array.from(this.querySelectorAll(resolvedSelector));
9400
+ else if (r === "all") {
9401
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9402
+ const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
9403
+ targets = [...sNodes, ...lNodes];
9404
+ } else {
9405
+ targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
9406
+ }
9407
+ targets.forEach((t) => t.remove());
9408
+ }
9409
+ },
9410
+ enumerable: true,
9411
+ configurable: true
9412
+ });
9413
+ };
9232
9414
  }
9415
+ return queryAll("$this", selectorOrTarget);
9233
9416
  }
9234
9417
  var getQueryAllMetadata = (target) => {
9235
9418
  const constructor = target instanceof Function ? target : target.constructor;
@@ -9419,6 +9602,27 @@ var resolvePropertyTargets = (inst, selector, options) => {
9419
9602
  const currentWin = conf.window;
9420
9603
  const r = options.root || "auto";
9421
9604
  const results = [];
9605
+ let resolvedSelector = selector;
9606
+ if (typeof selector === "function") {
9607
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
9608
+ resolvedSelector = selector(inst, hostSet);
9609
+ }
9610
+ if (resolvedSelector instanceof currentWin.Element) {
9611
+ results.push(resolvedSelector);
9612
+ return results;
9613
+ }
9614
+ if (resolvedSelector instanceof currentWin.NodeList) {
9615
+ results.push(...Array.from(resolvedSelector));
9616
+ return results;
9617
+ }
9618
+ if (Array.isArray(resolvedSelector)) {
9619
+ results.push(...resolvedSelector);
9620
+ return results;
9621
+ }
9622
+ if (resolvedSelector === null) {
9623
+ return results;
9624
+ }
9625
+ const stringSelector = resolvedSelector;
9422
9626
  const applyRoot = (target) => {
9423
9627
  if (!target) return;
9424
9628
  if (r === "auto") {
@@ -9428,37 +9632,37 @@ var resolvePropertyTargets = (inst, selector, options) => {
9428
9632
  if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
9429
9633
  }
9430
9634
  };
9431
- if (selector === "$this" || !selector) {
9635
+ if (stringSelector === "$this" || !stringSelector) {
9432
9636
  applyRoot(inst);
9433
- } else if (selector === "$window") {
9637
+ } else if (stringSelector === "$window") {
9434
9638
  results.push(currentWin);
9435
- } else if (selector === "$document") {
9639
+ } else if (stringSelector === "$document") {
9436
9640
  results.push(currentWin.document);
9437
9641
  } else {
9438
9642
  const hostSet = SwcUtils.getHostSet(inst);
9439
- if (selector === "$host") applyRoot(hostSet.$host);
9440
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
9441
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
9442
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
9443
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
9444
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
9445
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
9446
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
9447
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
9643
+ if (stringSelector === "$host") applyRoot(hostSet.$host);
9644
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
9645
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
9646
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
9647
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
9648
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
9649
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
9650
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
9651
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
9448
9652
  else {
9449
9653
  if (r === "shadow") {
9450
- const found = inst.shadowRoot?.querySelectorAll(selector);
9654
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
9451
9655
  if (found) results.push(...found);
9452
9656
  } else if (r === "light") {
9453
- const found = inst.querySelectorAll(selector);
9657
+ const found = inst.querySelectorAll(stringSelector);
9454
9658
  if (found) results.push(...found);
9455
9659
  } else if (r === "all") {
9456
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
9457
- const lMatch = inst.querySelectorAll(selector);
9660
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
9661
+ const lMatch = inst.querySelectorAll(stringSelector);
9458
9662
  if (sMatch) results.push(...sMatch);
9459
9663
  if (lMatch) results.push(...lMatch);
9460
9664
  } else {
9461
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
9665
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
9462
9666
  if (found) results.push(...found);
9463
9667
  }
9464
9668
  }
@@ -9557,35 +9761,20 @@ function applyProperty(selector, targetPropertyKeyOrOptions, options) {
9557
9761
  });
9558
9762
  };
9559
9763
  }
9560
- function property(selector, targetPropertyKeyOrOptions, options) {
9561
- return applyProperty(selector, targetPropertyKeyOrOptions, options);
9562
- }
9563
- function propertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
9564
- if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
9565
- return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
9764
+ function property(selectorOrTarget, targetPropertyKeyOrOptions, optionsOrDescriptor) {
9765
+ if (optionsOrDescriptor !== void 0 && (typeof targetPropertyKeyOrOptions === "string" || typeof targetPropertyKeyOrOptions === "symbol")) {
9766
+ return applyProperty("$this", void 0, {})(selectorOrTarget, targetPropertyKeyOrOptions, optionsOrDescriptor);
9566
9767
  }
9567
- if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
9568
- return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
9569
- } else if (targetOrOptions && typeof targetOrOptions === "object") {
9570
- return applyProperty("$this", void 0, targetOrOptions);
9571
- } else {
9572
- return applyProperty("$this", void 0, {});
9768
+ if (typeof selectorOrTarget === "string") {
9769
+ return applyProperty(selectorOrTarget, targetPropertyKeyOrOptions, optionsOrDescriptor);
9573
9770
  }
9771
+ return applyProperty("$this", void 0, selectorOrTarget);
9574
9772
  }
9575
- function setProperty(selector, targetPropertyKeyOrOptions, options) {
9576
- return applyProperty(selector, targetPropertyKeyOrOptions, options);
9577
- }
9578
- function setPropertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
9579
- if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
9580
- return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
9581
- }
9582
- if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
9583
- return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
9584
- } else if (targetOrOptions && typeof targetOrOptions === "object") {
9585
- return applyProperty("$this", void 0, targetOrOptions);
9586
- } else {
9587
- return applyProperty("$this", void 0, {});
9773
+ function setProperty(selectorOrOptions, targetPropertyKeyOrOptions, optionsOrUndefined) {
9774
+ if (typeof selectorOrOptions === "string") {
9775
+ return applyProperty(selectorOrOptions, targetPropertyKeyOrOptions, optionsOrUndefined);
9588
9776
  }
9777
+ return applyProperty("$this", void 0, selectorOrOptions);
9589
9778
  }
9590
9779
  var findAllPropertyMetadata = (target) => {
9591
9780
  const actualTarget = target instanceof Function ? target : target.constructor;
@@ -9898,7 +10087,8 @@ var elementDefine = (name, config = {}) => (constructor) => {
9898
10087
  const delegateListeners = [];
9899
10088
  const nonDelegateListeners = [];
9900
10089
  addEventListenerList.forEach((meta) => {
9901
- if (meta.options.delegate && meta.selector !== "$window" && meta.selector !== "$document" && meta.selector !== "$host" && meta.selector !== "$appHost" && meta.selector !== "$firstHost" && meta.selector !== "$lastHost" && meta.selector !== "$firstAppHost" && meta.selector !== "$lastAppHost" && meta.selector !== "$hosts" && meta.selector !== "$appHosts" && meta.selector !== "$this" && meta.selector !== "") {
10090
+ const isStringSelector = typeof meta.selector === "string";
10091
+ if (meta.options.delegate && isStringSelector && meta.selector !== "$window" && meta.selector !== "$document" && meta.selector !== "$host" && meta.selector !== "$appHost" && meta.selector !== "$firstHost" && meta.selector !== "$lastHost" && meta.selector !== "$firstAppHost" && meta.selector !== "$lastAppHost" && meta.selector !== "$hosts" && meta.selector !== "$appHosts" && meta.selector !== "$this" && meta.selector !== "") {
9902
10092
  delegateListeners.push(meta);
9903
10093
  } else {
9904
10094
  nonDelegateListeners.push(meta);
@@ -9961,6 +10151,22 @@ var elementDefine = (name, config = {}) => (constructor) => {
9961
10151
  const opts = { capture: options.capture, once: options.once, passive: options.passive };
9962
10152
  const bindTargets = [];
9963
10153
  const r = options.root || "auto";
10154
+ let resolvedSelector = null;
10155
+ if (typeof selector === "function") {
10156
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
10157
+ const result = selector(this, hostSet);
10158
+ if (typeof result === "string") {
10159
+ resolvedSelector = result;
10160
+ } else if (result instanceof currentWin.Element) {
10161
+ bindTargets.push(result);
10162
+ } else if (result instanceof currentWin.NodeList) {
10163
+ bindTargets.push(...Array.from(result));
10164
+ } else if (Array.isArray(result)) {
10165
+ bindTargets.push(...result);
10166
+ }
10167
+ } else {
10168
+ resolvedSelector = selector;
10169
+ }
9964
10170
  const applyRootOption = (target) => {
9965
10171
  if (!target) return;
9966
10172
  if (r === "auto") {
@@ -9970,30 +10176,32 @@ var elementDefine = (name, config = {}) => (constructor) => {
9970
10176
  if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
9971
10177
  }
9972
10178
  };
9973
- if (selector === "$window") bindTargets.push(currentWin);
9974
- else if (selector === "$document") bindTargets.push(currentWin.document);
9975
- else if (selector === "$host") applyRootOption(helperHostSet.$host);
9976
- else if (selector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
9977
- else if (selector === "$appHost") applyRootOption(helperHostSet.$appHost);
9978
- else if (selector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
9979
- else if (selector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
9980
- else if (selector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
9981
- else if (selector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
9982
- else if (selector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
9983
- else if (selector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
9984
- else if (selector === "$this" || !selector) applyRootOption(this);
9985
- else {
9986
- const searchRoots = [];
9987
- if (r === "auto") searchRoots.push(this.shadowRoot || this);
9988
- else if (r === "light") searchRoots.push(this);
9989
- else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
9990
- else if (r === "all") {
9991
- searchRoots.push(this);
9992
- if (this.shadowRoot) searchRoots.push(this.shadowRoot);
10179
+ if (resolvedSelector) {
10180
+ if (resolvedSelector === "$window") bindTargets.push(currentWin);
10181
+ else if (resolvedSelector === "$document") bindTargets.push(currentWin.document);
10182
+ else if (resolvedSelector === "$host") applyRootOption(helperHostSet.$host);
10183
+ else if (resolvedSelector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
10184
+ else if (resolvedSelector === "$appHost") applyRootOption(helperHostSet.$appHost);
10185
+ else if (resolvedSelector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
10186
+ else if (resolvedSelector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
10187
+ else if (resolvedSelector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
10188
+ else if (resolvedSelector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
10189
+ else if (resolvedSelector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
10190
+ else if (resolvedSelector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
10191
+ else if (resolvedSelector === "$this" || !resolvedSelector) applyRootOption(this);
10192
+ else {
10193
+ const searchRoots = [];
10194
+ if (r === "auto") searchRoots.push(this.shadowRoot || this);
10195
+ else if (r === "light") searchRoots.push(this);
10196
+ else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
10197
+ else if (r === "all") {
10198
+ searchRoots.push(this);
10199
+ if (this.shadowRoot) searchRoots.push(this.shadowRoot);
10200
+ }
10201
+ searchRoots.forEach((sr) => {
10202
+ sr.querySelectorAll(resolvedSelector).forEach((el) => bindTargets.push(el));
10203
+ });
9993
10204
  }
9994
- searchRoots.forEach((sr) => {
9995
- sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
9996
- });
9997
10205
  }
9998
10206
  bindTargets.forEach((t) => {
9999
10207
  const handler = async (event2) => {
@@ -10008,10 +10216,34 @@ var elementDefine = (name, config = {}) => (constructor) => {
10008
10216
  if (options.preventDefault) event2.preventDefault();
10009
10217
  const currentHostSet = SwcUtils.getHostSet(this);
10010
10218
  const args = { event: event2, ...currentHostSet, $el: t, $root: t };
10011
- await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
10219
+ await this[meta.propertyKey](event2, { currentHostSet, $matchedElement: event2.currentTarget }, args);
10220
+ };
10221
+ const eventSubject = new Subject();
10222
+ let eventStream = eventSubject;
10223
+ if (options.debounceTime !== void 0 && options.debounceTime > 0) {
10224
+ eventStream = eventStream.pipe(debounceTime(options.debounceTime));
10225
+ }
10226
+ if (options.throttleTime !== void 0 && options.throttleTime > 0) {
10227
+ eventStream = eventStream.pipe(throttleTime(options.throttleTime));
10228
+ }
10229
+ if (options.distinctUntilChanged !== void 0 && options.distinctUntilChanged !== false) {
10230
+ if (typeof options.distinctUntilChanged === "function") {
10231
+ eventStream = eventStream.pipe(distinctUntilChanged(options.distinctUntilChanged));
10232
+ } else {
10233
+ eventStream = eventStream.pipe(distinctUntilChanged());
10234
+ }
10235
+ }
10236
+ const subscription = eventStream.subscribe({
10237
+ next: (event2) => {
10238
+ handler(event2).catch((err) => console.error("Event handler error:", err));
10239
+ },
10240
+ error: (err) => console.error("Event stream error:", err)
10241
+ });
10242
+ const wrappedHandler = (event2) => {
10243
+ eventSubject.next(event2);
10012
10244
  };
10013
- t.addEventListener(type, handler, opts);
10014
- this._boundListeners.push({ target: t, type, handler, options: opts });
10245
+ t.addEventListener(type, wrappedHandler, opts);
10246
+ this._boundListeners.push({ target: t, type, handler: wrappedHandler, options: opts, subscription });
10015
10247
  });
10016
10248
  });
10017
10249
  if (originalConnected) await originalConnected.apply(this);
@@ -10051,7 +10283,12 @@ var elementDefine = (name, config = {}) => (constructor) => {
10051
10283
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
10052
10284
  for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10053
10285
  if (this._boundListeners) {
10054
- this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
10286
+ this._boundListeners.forEach((l) => {
10287
+ l.target.removeEventListener(l.type, l.handler, l.options);
10288
+ if (l.subscription && typeof l.subscription.unsubscribe === "function") {
10289
+ l.subscription.unsubscribe();
10290
+ }
10291
+ });
10055
10292
  this._boundListeners = [];
10056
10293
  }
10057
10294
  new ElementApply(this, { id: this._swcId }).removeAllEventListener();
@@ -10134,6 +10371,13 @@ var elementDefine = (name, config = {}) => (constructor) => {
10134
10371
 
10135
10372
  // src/decorators/applyAttribute.ts
10136
10373
  var ATTRIBUTE_METADATA_KEY = Symbol.for("simple-web-component:attribute");
10374
+ var isCssSelector = (str) => {
10375
+ if (!str) return false;
10376
+ if (str.startsWith("$")) return true;
10377
+ if (/^[#.\[\:>+~]/.test(str)) return true;
10378
+ if (/[>+~:\[\]]/.test(str)) return true;
10379
+ return false;
10380
+ };
10137
10381
  var convertValue2 = (val, type) => {
10138
10382
  if (val === null || val === void 0) return val;
10139
10383
  if (type === Number) return Number(val);
@@ -10171,6 +10415,27 @@ var resolveAttributeTargets = (inst, selector, options) => {
10171
10415
  const currentWin = conf.window;
10172
10416
  const r = options.root || "auto";
10173
10417
  const results = [];
10418
+ let resolvedSelector = selector;
10419
+ if (typeof selector === "function") {
10420
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
10421
+ resolvedSelector = selector(inst, hostSet);
10422
+ }
10423
+ if (resolvedSelector instanceof currentWin.Element) {
10424
+ results.push(resolvedSelector);
10425
+ return results;
10426
+ }
10427
+ if (resolvedSelector instanceof currentWin.NodeList) {
10428
+ results.push(...Array.from(resolvedSelector));
10429
+ return results;
10430
+ }
10431
+ if (Array.isArray(resolvedSelector)) {
10432
+ results.push(...resolvedSelector);
10433
+ return results;
10434
+ }
10435
+ if (resolvedSelector === null) {
10436
+ return results;
10437
+ }
10438
+ const stringSelector = resolvedSelector;
10174
10439
  const applyRoot = (target) => {
10175
10440
  if (!target) return;
10176
10441
  if (r === "auto") {
@@ -10180,33 +10445,33 @@ var resolveAttributeTargets = (inst, selector, options) => {
10180
10445
  if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
10181
10446
  }
10182
10447
  };
10183
- if (selector === "$this" || !selector) {
10448
+ if (stringSelector === "$this" || !stringSelector) {
10184
10449
  applyRoot(inst);
10185
10450
  } else {
10186
10451
  const hostSet = SwcUtils.getHostSet(inst);
10187
- if (selector === "$host") applyRoot(hostSet.$host);
10188
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
10189
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
10190
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
10191
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
10192
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10193
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10194
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10195
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10452
+ if (stringSelector === "$host") applyRoot(hostSet.$host);
10453
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
10454
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
10455
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
10456
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
10457
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10458
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10459
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10460
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10196
10461
  else {
10197
10462
  if (r === "shadow") {
10198
- const found = inst.shadowRoot?.querySelectorAll(selector);
10463
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
10199
10464
  if (found) results.push(...found);
10200
10465
  } else if (r === "light") {
10201
- const found = inst.querySelectorAll(selector);
10466
+ const found = inst.querySelectorAll(stringSelector);
10202
10467
  if (found) results.push(...found);
10203
10468
  } else if (r === "all") {
10204
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
10205
- const lMatch = inst.querySelectorAll(selector);
10469
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
10470
+ const lMatch = inst.querySelectorAll(stringSelector);
10206
10471
  if (sMatch) results.push(...sMatch);
10207
10472
  if (lMatch) results.push(...lMatch);
10208
10473
  } else {
10209
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
10474
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
10210
10475
  if (found) results.push(...found);
10211
10476
  }
10212
10477
  }
@@ -10304,35 +10569,32 @@ function applyAttribute(selector, targetAttributeNameOrOptions, options) {
10304
10569
  });
10305
10570
  };
10306
10571
  }
10307
- function attribute(selector, targetAttributeNameOrOptions, options) {
10308
- return applyAttribute(selector, targetAttributeNameOrOptions, options);
10309
- }
10310
- function attributeThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
10311
- if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") {
10312
- return applyAttribute("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
10313
- }
10314
- if (typeof targetOrOptions === "string") {
10315
- return applyAttribute("$this", targetOrOptions, propertyKeyOrOptions);
10316
- } else if (targetOrOptions && typeof targetOrOptions === "object") {
10317
- return applyAttribute("$this", void 0, targetOrOptions);
10318
- } else {
10319
- return applyAttribute("$this", void 0, {});
10572
+ function attribute(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsOrDescriptor) {
10573
+ if (optionsOrDescriptor !== void 0 && (typeof attributeNameOrOptions === "string" || typeof attributeNameOrOptions === "symbol")) {
10574
+ return applyAttribute("$this", void 0, {})(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsOrDescriptor);
10575
+ }
10576
+ if (typeof selectorOrAttributeOrTarget === "string") {
10577
+ const isSelector = isCssSelector(selectorOrAttributeOrTarget);
10578
+ if (isSelector) {
10579
+ return applyAttribute(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsOrDescriptor);
10580
+ } else {
10581
+ const options = typeof attributeNameOrOptions === "object" && attributeNameOrOptions !== null ? attributeNameOrOptions : {};
10582
+ return applyAttribute("$this", selectorOrAttributeOrTarget, options);
10583
+ }
10320
10584
  }
10585
+ return applyAttribute("$this", void 0, selectorOrAttributeOrTarget);
10321
10586
  }
10322
- function setAttribute(selector, targetAttributeNameOrOptions, options) {
10323
- return applyAttribute(selector, targetAttributeNameOrOptions, options);
10324
- }
10325
- function setAttributeThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
10326
- if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
10327
- return applyAttribute("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
10328
- }
10329
- if (typeof targetOrOptions === "string") {
10330
- return applyAttribute("$this", targetOrOptions, propertyKeyOrOptions);
10331
- } else if (targetOrOptions && typeof targetOrOptions === "object") {
10332
- return applyAttribute("$this", void 0, targetOrOptions);
10333
- } else {
10334
- return applyAttribute("$this", void 0, {});
10587
+ function setAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions, optionsOrUndefined) {
10588
+ if (typeof selectorOrAttributeOrOptions === "string") {
10589
+ const isSelector = isCssSelector(selectorOrAttributeOrOptions);
10590
+ if (isSelector) {
10591
+ return applyAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions, optionsOrUndefined);
10592
+ } else {
10593
+ const options = typeof attributeNameOrOptions === "object" && attributeNameOrOptions !== null ? attributeNameOrOptions : {};
10594
+ return applyAttribute("$this", selectorOrAttributeOrOptions, options);
10595
+ }
10335
10596
  }
10597
+ return applyAttribute("$this", void 0, selectorOrAttributeOrOptions);
10336
10598
  }
10337
10599
  var findAllAttributeMetadata = (target) => {
10338
10600
  const actualTarget = target instanceof Function ? target : target.constructor;
@@ -10348,8 +10610,32 @@ var findAllAttributeApplyMetadata = (target) => {
10348
10610
 
10349
10611
  // src/decorators/applyNode.ts
10350
10612
  var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
10613
+ var resolveSelector = (selector, inst, win) => {
10614
+ if (typeof selector === "function") {
10615
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10616
+ const result = selector(inst, hostSet);
10617
+ if (result instanceof win.Element) {
10618
+ return result;
10619
+ }
10620
+ if (result instanceof win.NodeList) {
10621
+ return result.length > 0 ? result[0] : null;
10622
+ }
10623
+ if (Array.isArray(result)) {
10624
+ return result.length > 0 ? result[0] : null;
10625
+ }
10626
+ if (result === null) {
10627
+ return null;
10628
+ }
10629
+ return result;
10630
+ }
10631
+ return selector;
10632
+ };
10351
10633
  var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
10352
10634
  if (!targetEl) return;
10635
+ if (pos === "clearChildren") {
10636
+ targetEl.replaceChildren();
10637
+ return [];
10638
+ }
10353
10639
  const doc = win.document;
10354
10640
  const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
10355
10641
  const id = currentThis._swcId;
@@ -10385,7 +10671,16 @@ var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
10385
10671
  new ElementApply(targetEl, { id }).apply({ target: "noInitialized", context: stateContext, bind: currentThis });
10386
10672
  return nodes;
10387
10673
  };
10388
- function applyNode(selector, options = { position: "replaceChildren" }) {
10674
+ function applyNode(selectorOrOptions, maybeOptions) {
10675
+ let selector;
10676
+ let options;
10677
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10678
+ selector = selectorOrOptions;
10679
+ options = maybeOptions || { position: "replaceChildren" };
10680
+ } else {
10681
+ selector = "$this";
10682
+ options = selectorOrOptions || { position: "replaceChildren" };
10683
+ }
10389
10684
  return (targetObj, propertyKey, descriptor) => {
10390
10685
  const constructor = targetObj.constructor;
10391
10686
  let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
@@ -10411,14 +10706,22 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
10411
10706
  if (r === "all") return t.shadowRoot || t;
10412
10707
  return t;
10413
10708
  };
10414
- if (selector === "$this") return applyRoot(this);
10415
- if (selector === "$host") return applyRoot(hostSet.$host);
10416
- if (selector === "$parentHost") return applyRoot(hostSet.$parentHost);
10417
- if (selector === "$appHost") return applyRoot(hostSet.$appHost);
10418
- if (selector === "$firstHost") return applyRoot(hostSet.$firstHost);
10419
- if (selector === "$lastHost") return applyRoot(hostSet.$lastHost);
10709
+ const resolved = resolveSelector(selector, this, currentWin);
10710
+ if (resolved instanceof currentWin.Element) {
10711
+ return applyRoot(resolved);
10712
+ }
10713
+ if (resolved === null) {
10714
+ return null;
10715
+ }
10716
+ const stringSelector = resolved;
10717
+ if (stringSelector === "$this") return applyRoot(this);
10718
+ if (stringSelector === "$host") return applyRoot(hostSet.$host);
10719
+ if (stringSelector === "$parentHost") return applyRoot(hostSet.$parentHost);
10720
+ if (stringSelector === "$appHost") return applyRoot(hostSet.$appHost);
10721
+ if (stringSelector === "$firstHost") return applyRoot(hostSet.$firstHost);
10722
+ if (stringSelector === "$lastHost") return applyRoot(hostSet.$lastHost);
10420
10723
  const targetRoot = applyRoot(this);
10421
- return targetRoot ? targetRoot.querySelector(selector) : null;
10724
+ return targetRoot ? targetRoot.querySelector(stringSelector) : null;
10422
10725
  };
10423
10726
  const targetEl = getTarget();
10424
10727
  const res = original.apply(this, args);
@@ -10456,92 +10759,141 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
10456
10759
  };
10457
10760
  };
10458
10761
  }
10459
- function applyNodeThis(targetOrOptions, propertyKey, descriptor) {
10460
- const option = { position: "replaceChildren" };
10461
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10462
- const opt = targetOrOptions || {};
10463
- return applyNode("$this", { ...option, ...opt });
10464
- }
10465
- function replaceChildrenNodeThis(targetOrOptions, propertyKey, descriptor) {
10466
- const option = { position: "replaceChildren" };
10467
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10468
- const opt = targetOrOptions || {};
10469
- return applyNode("$this", { ...opt, ...option });
10470
- }
10471
- function beforeEndNodeThis(targetOrOptions, propertyKey, descriptor) {
10472
- const options = { position: "beforeEnd" };
10473
- if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
10474
- const opt = targetOrOptions || {};
10475
- return applyNode("$this", { ...opt, ...options });
10476
- }
10477
- function beforeEndLightNodeThis(targetOrOptions, propertyKey, descriptor) {
10478
- const option = { position: "beforeEnd", root: "light" };
10479
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10480
- const opt = targetOrOptions || {};
10481
- return applyNode("$this", { ...opt, ...option });
10762
+ function replaceChildren(selectorOrOptions, maybeOptions, descriptor) {
10763
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10764
+ return applyNode({ position: "replaceChildren" })(selectorOrOptions, maybeOptions, descriptor);
10765
+ }
10766
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10767
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren" });
10768
+ }
10769
+ return applyNode({ ...selectorOrOptions, position: "replaceChildren" });
10482
10770
  }
10483
- function beforeEndShadowNodeThis(targetOrOptions, propertyKey, descriptor) {
10484
- const option = { position: "beforeEnd", root: "shadow" };
10485
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10486
- const opt = targetOrOptions || {};
10487
- return applyNode("$this", { ...opt, ...option });
10771
+ function clearChildrenNode(selectorOrOptions, maybeOptions, descriptor) {
10772
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10773
+ return applyNode({ position: "clearChildren" })(selectorOrOptions, maybeOptions, descriptor);
10774
+ }
10775
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10776
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren" });
10777
+ }
10778
+ return applyNode({ ...selectorOrOptions, position: "clearChildren" });
10488
10779
  }
10489
- function afterBeginNodeThis(targetOrOptions, propertyKey, descriptor) {
10490
- const option = { position: "afterBegin" };
10491
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10492
- const opt = targetOrOptions || {};
10493
- return applyNode("$this", { ...opt, ...option });
10780
+ var clearNode = clearChildrenNode;
10781
+ function innerHtml(selectorOrOptions, maybeOptions, descriptor) {
10782
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10783
+ return applyNode({ position: "innerHtml" })(selectorOrOptions, maybeOptions, descriptor);
10784
+ }
10785
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10786
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml" });
10787
+ }
10788
+ return applyNode({ ...selectorOrOptions, position: "innerHtml" });
10494
10789
  }
10495
- function afterBeginLightNodeThis(targetOrOptions, propertyKey, descriptor) {
10496
- const option = { position: "afterBegin", root: "light" };
10497
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10498
- const opt = targetOrOptions || {};
10499
- return applyNode("$this", { ...opt, ...option });
10790
+ function innerHtmlLight(selectorOrOptions, maybeOptions, descriptor) {
10791
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10792
+ return applyNode({ position: "innerHtml", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10793
+ }
10794
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10795
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "light" });
10796
+ }
10797
+ return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "light" });
10500
10798
  }
10501
- function innerHtmlNodeThis(targetOrOptions, propertyKey, descriptor) {
10502
- const option = { position: "innerHtml" };
10503
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10504
- const opt = targetOrOptions || {};
10505
- return applyNode("$this", { ...opt, ...option });
10799
+ function innerHtmlShadow(selectorOrOptions, maybeOptions, descriptor) {
10800
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10801
+ return applyNode({ position: "innerHtml", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10802
+ }
10803
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10804
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "shadow" });
10805
+ }
10806
+ return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "shadow" });
10506
10807
  }
10507
- function innerTextNodeThis(targetOrOptions, propertyKey, descriptor) {
10508
- const option = { position: "innerText" };
10509
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10510
- const opt = targetOrOptions || {};
10511
- return applyNode("$this", { ...opt, ...option });
10808
+ function innerText(selectorOrOptions, maybeOptions, descriptor) {
10809
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10810
+ return applyNode({ position: "innerText" })(selectorOrOptions, maybeOptions, descriptor);
10811
+ }
10812
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10813
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText" });
10814
+ }
10815
+ return applyNode({ ...selectorOrOptions, position: "innerText" });
10512
10816
  }
10513
- function innerHtmlLightNodeThis(targetOrOptions, propertyKey, descriptor) {
10514
- const option = { position: "innerHtml", root: "light" };
10515
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10516
- const opt = targetOrOptions || {};
10517
- return applyNode("$this", { ...opt, ...option });
10817
+ function innerTextLight(selectorOrOptions, maybeOptions, descriptor) {
10818
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10819
+ return applyNode({ position: "innerText", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10820
+ }
10821
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10822
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "light" });
10823
+ }
10824
+ return applyNode({ ...selectorOrOptions, position: "innerText", root: "light" });
10518
10825
  }
10519
- function replaceChildrenLightNodeThis(targetOrOptions, propertyKey, descriptor) {
10520
- const option = { position: "replaceChildren", root: "light" };
10521
- if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
10522
- const opt = targetOrOptions || {};
10523
- return applyNode("$this", { ...opt, ...option });
10826
+ function innerTextShadow(selectorOrOptions, maybeOptions, descriptor) {
10827
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10828
+ return applyNode({ position: "innerText", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10829
+ }
10830
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10831
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "shadow" });
10832
+ }
10833
+ return applyNode({ ...selectorOrOptions, position: "innerText", root: "shadow" });
10524
10834
  }
10525
- function replaceChildrenNode(selector, options = {}) {
10526
- return applyNode(selector, { ...options, position: "replaceChildren" });
10835
+ function insertBeforeEnd(selectorOrOptions, maybeOptions, descriptor) {
10836
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10837
+ return applyNode({ position: "beforeEnd" })(selectorOrOptions, maybeOptions, descriptor);
10838
+ }
10839
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10840
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd" });
10841
+ }
10842
+ return applyNode({ ...selectorOrOptions, position: "beforeEnd" });
10527
10843
  }
10528
- function innerHtmlNode(selector, options = {}) {
10529
- return applyNode(selector, { ...options, position: "innerHtml" });
10844
+ function insertBeforeEndLight(selectorOrOptions, maybeOptions, descriptor) {
10845
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10846
+ return applyNode({ position: "beforeEnd", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10847
+ }
10848
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10849
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "light" });
10850
+ }
10851
+ return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "light" });
10530
10852
  }
10531
- function innerHtmlLightNode(selector, options = {}) {
10532
- return applyNode(selector, { ...options, position: "innerHtml", root: "light" });
10853
+ function insertBeforeEndShadow(selectorOrOptions, maybeOptions, descriptor) {
10854
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10855
+ return applyNode({ position: "beforeEnd", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10856
+ }
10857
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10858
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "shadow" });
10859
+ }
10860
+ return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "shadow" });
10533
10861
  }
10534
- function innerHtmlShadowNode(selector, options = {}) {
10535
- return applyNode(selector, { ...options, position: "innerHtml", root: "shadow" });
10862
+ function insertAfterBegin(selectorOrOptions, maybeOptions, descriptor) {
10863
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10864
+ return applyNode({ position: "afterBegin" })(selectorOrOptions, maybeOptions, descriptor);
10865
+ }
10866
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10867
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin" });
10868
+ }
10869
+ return applyNode({ ...selectorOrOptions, position: "afterBegin" });
10536
10870
  }
10537
- function innerTextNode(selector, options = {}) {
10538
- return applyNode(selector, { ...options, position: "innerText" });
10871
+ function insertAfterBeginLight(selectorOrOptions, maybeOptions, descriptor) {
10872
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10873
+ return applyNode({ position: "afterBegin", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10874
+ }
10875
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10876
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin", root: "light" });
10877
+ }
10878
+ return applyNode({ ...selectorOrOptions, position: "afterBegin", root: "light" });
10539
10879
  }
10540
- function innerTextLightNode(selector, options = {}) {
10541
- return applyNode(selector, { ...options, position: "innerText", root: "light" });
10880
+ function replaceChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
10881
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10882
+ return applyNode({ position: "replaceChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10883
+ }
10884
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10885
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren", root: "light" });
10886
+ }
10887
+ return applyNode({ ...selectorOrOptions, position: "replaceChildren", root: "light" });
10542
10888
  }
10543
- function innerTextShadowNode(selector, options = {}) {
10544
- return applyNode(selector, { ...options, position: "innerText", root: "shadow" });
10889
+ function clearChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
10890
+ if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10891
+ return applyNode({ position: "clearChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10892
+ }
10893
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10894
+ return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren", root: "light" });
10895
+ }
10896
+ return applyNode({ ...selectorOrOptions, position: "clearChildren", root: "light" });
10545
10897
  }
10546
10898
  var findAllApplyNodeMetadata = (target) => {
10547
10899
  const result = /* @__PURE__ */ new Map();
@@ -10556,6 +10908,58 @@ var findAllApplyNodeMetadata = (target) => {
10556
10908
 
10557
10909
  // src/decorators/applyClass.ts
10558
10910
  var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
10911
+ var resolveSelector2 = (selector, inst, win) => {
10912
+ if (typeof selector === "function") {
10913
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10914
+ const result = selector(inst, hostSet);
10915
+ if (result instanceof win.Element) {
10916
+ return [result];
10917
+ }
10918
+ if (result instanceof win.NodeList) {
10919
+ return Array.from(result);
10920
+ }
10921
+ if (Array.isArray(result)) {
10922
+ return result;
10923
+ }
10924
+ if (result === null) {
10925
+ return [];
10926
+ }
10927
+ return result;
10928
+ }
10929
+ return selector;
10930
+ };
10931
+ var getTargetElements = (selector, inst, win, root) => {
10932
+ const resolved = resolveSelector2(selector, inst, win);
10933
+ if (Array.isArray(resolved)) {
10934
+ return resolved;
10935
+ }
10936
+ const stringSelector = resolved;
10937
+ const targetEls = [];
10938
+ const host = inst;
10939
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10940
+ const applyRoot = (t) => {
10941
+ if (!t || !(t instanceof win.HTMLElement)) return;
10942
+ targetEls.push(t);
10943
+ };
10944
+ if (stringSelector === "$this" || !stringSelector) applyRoot(host);
10945
+ else if (stringSelector === "$host") applyRoot(hostSet.$host);
10946
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
10947
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
10948
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
10949
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
10950
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10951
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10952
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10953
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10954
+ else {
10955
+ const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
10956
+ if (targetRoot) {
10957
+ const found = targetRoot.querySelectorAll(stringSelector);
10958
+ if (found) targetEls.push(...Array.from(found));
10959
+ }
10960
+ }
10961
+ return targetEls;
10962
+ };
10559
10963
  function createClassDecorator(action) {
10560
10964
  return (selector, classMapOrOptions, options = {}) => {
10561
10965
  return (target, propertyKey, descriptor) => {
@@ -10590,28 +10994,7 @@ function createClassDecorator(action) {
10590
10994
  const host = this;
10591
10995
  const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
10592
10996
  const r = finalOptions.root || "auto";
10593
- const targetEls = [];
10594
- const applyRoot = (t) => {
10595
- if (!t || !(t instanceof win.HTMLElement)) return;
10596
- targetEls.push(t);
10597
- };
10598
- if (selector === "$this" || !selector) applyRoot(host);
10599
- else if (selector === "$host") applyRoot(hostSet.$host);
10600
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
10601
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
10602
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
10603
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
10604
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10605
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10606
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10607
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10608
- else {
10609
- const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
10610
- if (targetRoot) {
10611
- const found = targetRoot.querySelectorAll(selector);
10612
- if (found) targetEls.push(...Array.from(found));
10613
- }
10614
- }
10997
+ const targetEls = getTargetElements(selector, this, win, r);
10615
10998
  targetEls.forEach((targetEl) => {
10616
10999
  if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
10617
11000
  return;
@@ -10672,22 +11055,64 @@ function createClassDecorator(action) {
10672
11055
  };
10673
11056
  };
10674
11057
  }
10675
- function applyClass(selector, action = "update", options = {}) {
10676
- return createClassDecorator(action)(selector, options);
10677
- }
10678
- var setClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("set")(selector, classMapOrOptions, options);
10679
- var updateClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("update")(selector, classMapOrOptions, options);
10680
- var addClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("add")(selector, classMapOrOptions, options);
10681
- var removeClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("remove")(selector, classMapOrOptions, options);
10682
- var toggleClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("toggle")(selector, classMapOrOptions, options);
10683
- function applyClassThis(action = "update", options = {}) {
11058
+ function applyClass(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor) {
11059
+ if (optionsOrDescriptor !== void 0 && (typeof actionOrPropertyKey === "string" || typeof actionOrPropertyKey === "symbol")) {
11060
+ return createClassDecorator("update")("$this", {})(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor);
11061
+ }
11062
+ if (typeof selectorOrTarget === "string") {
11063
+ const action2 = typeof actionOrPropertyKey === "string" ? actionOrPropertyKey : "update";
11064
+ const options2 = typeof actionOrPropertyKey === "object" ? actionOrPropertyKey : optionsOrDescriptor;
11065
+ return createClassDecorator(action2)(selectorOrTarget, options2);
11066
+ }
11067
+ const action = typeof selectorOrTarget === "string" ? selectorOrTarget : "update";
11068
+ const options = typeof selectorOrTarget === "object" ? selectorOrTarget : actionOrPropertyKey;
10684
11069
  return createClassDecorator(action)("$this", options);
10685
11070
  }
10686
- var setClassThis = (classMapOrOptions, options = {}) => createClassDecorator("set")("$this", classMapOrOptions, options);
10687
- var updateClassThis = (classMapOrOptions, options = {}) => createClassDecorator("update")("$this", classMapOrOptions, options);
10688
- var addClassThis = (classMapOrOptions, options = {}) => createClassDecorator("add")("$this", classMapOrOptions, options);
10689
- var removeClassThis = (classMapOrOptions, options = {}) => createClassDecorator("remove")("$this", classMapOrOptions, options);
10690
- var toggleClassThis = (classMapOrOptions, options = {}) => createClassDecorator("toggle")("$this", classMapOrOptions, options);
11071
+ function setClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
11072
+ if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
11073
+ return createClassDecorator("set")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11074
+ }
11075
+ if (typeof selectorOrTarget === "string") {
11076
+ return createClassDecorator("set")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11077
+ }
11078
+ return createClassDecorator("set")("$this", selectorOrTarget);
11079
+ }
11080
+ function updateClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
11081
+ if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
11082
+ return createClassDecorator("update")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11083
+ }
11084
+ if (typeof selectorOrTarget === "string") {
11085
+ return createClassDecorator("update")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11086
+ }
11087
+ return createClassDecorator("update")("$this", selectorOrTarget);
11088
+ }
11089
+ function addClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
11090
+ if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
11091
+ return createClassDecorator("add")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11092
+ }
11093
+ if (typeof selectorOrTarget === "string") {
11094
+ return createClassDecorator("add")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11095
+ }
11096
+ return createClassDecorator("add")("$this", selectorOrTarget);
11097
+ }
11098
+ function removeClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
11099
+ if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
11100
+ return createClassDecorator("remove")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11101
+ }
11102
+ if (typeof selectorOrTarget === "string") {
11103
+ return createClassDecorator("remove")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11104
+ }
11105
+ return createClassDecorator("remove")("$this", selectorOrTarget);
11106
+ }
11107
+ function toggleClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
11108
+ if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
11109
+ return createClassDecorator("toggle")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11110
+ }
11111
+ if (typeof selectorOrTarget === "string") {
11112
+ return createClassDecorator("toggle")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
11113
+ }
11114
+ return createClassDecorator("toggle")("$this", selectorOrTarget);
11115
+ }
10691
11116
  var findAllClassMetadata = (target) => {
10692
11117
  const result = /* @__PURE__ */ new Map();
10693
11118
  const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
@@ -10701,6 +11126,58 @@ var findAllClassMetadata = (target) => {
10701
11126
 
10702
11127
  // src/decorators/applyStyle.ts
10703
11128
  var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
11129
+ var resolveSelector3 = (selector, inst, win) => {
11130
+ if (typeof selector === "function") {
11131
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11132
+ const result = selector(inst, hostSet);
11133
+ if (result instanceof win.Element) {
11134
+ return [result];
11135
+ }
11136
+ if (result instanceof win.NodeList) {
11137
+ return Array.from(result);
11138
+ }
11139
+ if (Array.isArray(result)) {
11140
+ return result;
11141
+ }
11142
+ if (result === null) {
11143
+ return [];
11144
+ }
11145
+ return result;
11146
+ }
11147
+ return selector;
11148
+ };
11149
+ var getTargetElements2 = (selector, inst, win, root) => {
11150
+ const resolved = resolveSelector3(selector, inst, win);
11151
+ if (Array.isArray(resolved)) {
11152
+ return resolved;
11153
+ }
11154
+ const stringSelector = resolved;
11155
+ const targetEls = [];
11156
+ const host = inst;
11157
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11158
+ const applyRoot = (t) => {
11159
+ if (!t || !(t instanceof win.HTMLElement)) return;
11160
+ targetEls.push(t);
11161
+ };
11162
+ if (stringSelector === "$this" || !stringSelector) applyRoot(host);
11163
+ else if (stringSelector === "$host") applyRoot(hostSet.$host);
11164
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
11165
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
11166
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
11167
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
11168
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
11169
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
11170
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
11171
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
11172
+ else {
11173
+ const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
11174
+ if (targetRoot) {
11175
+ const found = targetRoot.querySelectorAll(stringSelector);
11176
+ if (found) targetEls.push(...Array.from(found));
11177
+ }
11178
+ }
11179
+ return targetEls;
11180
+ };
10704
11181
  function createStyleDecorator(action) {
10705
11182
  return (selector, options = {}) => {
10706
11183
  return (target, propertyKey, descriptor) => {
@@ -10728,28 +11205,7 @@ function createStyleDecorator(action) {
10728
11205
  const host = this;
10729
11206
  const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
10730
11207
  const r = options.root || "auto";
10731
- const targetEls = [];
10732
- const applyRoot = (t) => {
10733
- if (!t || !(t instanceof win.HTMLElement)) return;
10734
- targetEls.push(t);
10735
- };
10736
- if (selector === "$this" || !selector) applyRoot(host);
10737
- else if (selector === "$host") applyRoot(hostSet.$host);
10738
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
10739
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
10740
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
10741
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
10742
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10743
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10744
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10745
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10746
- else {
10747
- const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
10748
- if (targetRoot) {
10749
- const found = targetRoot.querySelectorAll(selector);
10750
- if (found) targetEls.push(...Array.from(found));
10751
- }
10752
- }
11208
+ const targetEls = getTargetElements2(selector, this, win, r);
10753
11209
  targetEls.forEach((targetEl) => {
10754
11210
  if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
10755
11211
  return;
@@ -10796,18 +11252,46 @@ function createStyleDecorator(action) {
10796
11252
  };
10797
11253
  };
10798
11254
  }
10799
- function applyStyle(selector, action = "update", options = {}) {
10800
- return createStyleDecorator(action)(selector, options);
10801
- }
10802
- var setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
10803
- var updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
10804
- var removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
10805
- function applyStyleThis(action = "update", options = {}) {
11255
+ function applyStyle(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor) {
11256
+ if (optionsOrDescriptor !== void 0 && (typeof actionOrPropertyKey === "string" || typeof actionOrPropertyKey === "symbol")) {
11257
+ return createStyleDecorator("update")("$this", {})(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor);
11258
+ }
11259
+ if (typeof selectorOrTarget === "string") {
11260
+ const action2 = typeof actionOrPropertyKey === "string" ? actionOrPropertyKey : "update";
11261
+ const options2 = typeof actionOrPropertyKey === "object" ? actionOrPropertyKey : optionsOrDescriptor;
11262
+ return createStyleDecorator(action2)(selectorOrTarget, options2);
11263
+ }
11264
+ const action = typeof selectorOrTarget === "string" ? selectorOrTarget : "update";
11265
+ const options = typeof selectorOrTarget === "object" ? selectorOrTarget : actionOrPropertyKey;
10806
11266
  return createStyleDecorator(action)("$this", options);
10807
11267
  }
10808
- var setStyleThis = (options = {}) => createStyleDecorator("set")("$this", options);
10809
- var updateStyleThis = (options = {}) => createStyleDecorator("update")("$this", options);
10810
- var removeStyleThis = (options = {}) => createStyleDecorator("remove")("$this", options);
11268
+ function setStyle(selectorOrTarget, optionsOrPropertyKey, descriptor) {
11269
+ if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
11270
+ return createStyleDecorator("set")("$this", {})(selectorOrTarget, optionsOrPropertyKey, descriptor);
11271
+ }
11272
+ if (typeof selectorOrTarget === "string") {
11273
+ return createStyleDecorator("set")(selectorOrTarget, optionsOrPropertyKey);
11274
+ }
11275
+ return createStyleDecorator("set")("$this", selectorOrTarget);
11276
+ }
11277
+ function updateStyle(selectorOrTarget, optionsOrPropertyKey, descriptor) {
11278
+ if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
11279
+ return createStyleDecorator("update")("$this", {})(selectorOrTarget, optionsOrPropertyKey, descriptor);
11280
+ }
11281
+ if (typeof selectorOrTarget === "string") {
11282
+ return createStyleDecorator("update")(selectorOrTarget, optionsOrPropertyKey);
11283
+ }
11284
+ return createStyleDecorator("update")("$this", selectorOrTarget);
11285
+ }
11286
+ function removeStyle(selectorOrTarget, optionsOrPropertyKey, descriptor) {
11287
+ if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
11288
+ return createStyleDecorator("remove")("$this", {})(selectorOrTarget, optionsOrPropertyKey, descriptor);
11289
+ }
11290
+ if (typeof selectorOrTarget === "string") {
11291
+ return createStyleDecorator("remove")(selectorOrTarget, optionsOrPropertyKey);
11292
+ }
11293
+ return createStyleDecorator("remove")("$this", selectorOrTarget);
11294
+ }
10811
11295
  var findAllStyleMetadata = (target) => {
10812
11296
  const result = /* @__PURE__ */ new Map();
10813
11297
  const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
@@ -10855,6 +11339,7 @@ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKeyOr
10855
11339
  }
10856
11340
  return createSubscribeSwcAppRouteChangeWhileConnected(options);
10857
11341
  }
11342
+ var changedRoute = subscribeSwcAppRouteChangeWhileConnected;
10858
11343
  var getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
10859
11344
  const constructor = target instanceof Function ? target : target.constructor;
10860
11345
  const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
@@ -10895,6 +11380,7 @@ function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, opti
10895
11380
  }
10896
11381
  return createSubscribeSwcAppMessageWhileConnected(options, messageType);
10897
11382
  }
11383
+ var receiveMessage = subscribeSwcAppMessageWhileConnected;
10898
11384
  var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
10899
11385
  const constructor = target instanceof Function ? target : target.constructor;
10900
11386
  return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
@@ -10924,7 +11410,7 @@ function createPublishSwcAppMessage(messageType, options) {
10924
11410
  }
10925
11411
  return v;
10926
11412
  };
10927
- const publishMessage = (data) => {
11413
+ const publishMessage2 = (data) => {
10928
11414
  const appHost = SwcUtils.getAppHost(this);
10929
11415
  if (appHost) {
10930
11416
  appHost.publishMessage({
@@ -10937,13 +11423,13 @@ function createPublishSwcAppMessage(messageType, options) {
10937
11423
  if (result instanceof Promise) {
10938
11424
  result.then((data) => {
10939
11425
  const extracted = extractValue(data);
10940
- publishMessage(extracted);
11426
+ publishMessage2(extracted);
10941
11427
  }).catch((err) => {
10942
11428
  console.warn("publishSwcAppMessage async error:", err);
10943
11429
  });
10944
11430
  } else {
10945
11431
  const extracted = extractValue(result);
10946
- publishMessage(extracted);
11432
+ publishMessage2(extracted);
10947
11433
  }
10948
11434
  return result;
10949
11435
  };
@@ -10968,7 +11454,7 @@ function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions
10968
11454
  }
10969
11455
  return createPublishSwcAppMessage(messageType, options);
10970
11456
  }
10971
- var publish = publishSwcAppMessage;
11457
+ var publishMessage = publishSwcAppMessage;
10972
11458
  var getPublishSwcAppMessageMetadata = (target) => {
10973
11459
  const constructor = target instanceof Function ? target : target.constructor;
10974
11460
  return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
@@ -13085,6 +13571,10 @@ var ElementRouter = class extends Router {
13085
13571
  super(config);
13086
13572
  __publicField(this, "_history", []);
13087
13573
  __publicField(this, "_currentIndex", -1);
13574
+ if (config.firstUrl) {
13575
+ this._history.push({ url: config.firstUrl, data: null, title: void 0 });
13576
+ this._currentIndex = 0;
13577
+ }
13088
13578
  }
13089
13579
  // Override pushState to manage internal history
13090
13580
  pushState(data, title, path, config) {
@@ -13256,7 +13746,9 @@ var SwcAppEngine = class {
13256
13746
  if (this.router) otherInstanceSim.set(Router, this.router);
13257
13747
  this.simpleApplication.run(otherInstanceSim);
13258
13748
  if (this._config.onStartedLazyDefineComponent) {
13259
- await Promise.all(this._config.onStartedLazyDefineComponent.map((it) => it(this._config.window)));
13749
+ await Promise.all(this._config.onStartedLazyDefineComponent.map((it) => {
13750
+ it(this._config.window);
13751
+ }));
13260
13752
  }
13261
13753
  if (this._config.onEngineStarted) {
13262
13754
  await this._config.onEngineStarted(this.simpleApplication, this.host);
@@ -13333,6 +13825,13 @@ function SwcAppMixin(Base) {
13333
13825
  const methodName = metadata.propertyKey;
13334
13826
  let pathPattern = metadata.options?.path;
13335
13827
  const filter = metadata.options?.filter;
13828
+ const extractValue = (v) => {
13829
+ const keyToUse = metadata.options?.valueKey ?? SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY;
13830
+ if (v && typeof v === "object" && keyToUse in v) {
13831
+ return v[keyToUse];
13832
+ }
13833
+ return v;
13834
+ };
13336
13835
  if (typeof pathPattern === "function") {
13337
13836
  pathPattern = pathPattern(instance);
13338
13837
  }
@@ -13357,7 +13856,7 @@ function SwcAppMixin(Base) {
13357
13856
  const hostSet = SwcUtils.getHelperAndHostSet(this.config.window, this);
13358
13857
  const filterPassed = !filter || filter(this.router, { helper: hostSet, currentThis: instance });
13359
13858
  if (pathMatched && filterPassed && instance[methodName]) {
13360
- const result = await instance[methodName]({ ...re, pathData });
13859
+ const result = extractValue(await instance[methodName]({ ...re, pathData }));
13361
13860
  if (result !== void 0 && result !== null) {
13362
13861
  break;
13363
13862
  }
@@ -13472,7 +13971,15 @@ function SwcAppMixin(Base) {
13472
13971
  context: this,
13473
13972
  args: SwcUtils.getHelperAndHostSet(win, this)
13474
13973
  });
13475
- this.connect(userConfig);
13974
+ if (userConfig instanceof Promise) {
13975
+ userConfig.then((resolvedConfig) => {
13976
+ this.connect(resolvedConfig);
13977
+ }).catch((e) => {
13978
+ console.error("[SWC-MIXIN] Script execution failed:", e);
13979
+ });
13980
+ } else {
13981
+ this.connect(userConfig);
13982
+ }
13476
13983
  } catch (e) {
13477
13984
  console.error("[SWC-MIXIN] Script execution failed:", e);
13478
13985
  }
@@ -13745,6 +14252,7 @@ export {
13745
14252
  SwcAppAside,
13746
14253
  SwcAppBody,
13747
14254
  SwcAppDiv,
14255
+ SwcAppEngine,
13748
14256
  SwcAppFooter,
13749
14257
  SwcAppHeader,
13750
14258
  SwcAppMain,
@@ -13753,7 +14261,6 @@ export {
13753
14261
  SwcAppSection,
13754
14262
  SwcUtils,
13755
14263
  addClass,
13756
- addClassThis,
13757
14264
  addEventListener,
13758
14265
  addEventListenerAppHost,
13759
14266
  addEventListenerDelegate,
@@ -13763,28 +14270,21 @@ export {
13763
14270
  addEventListenerDocument,
13764
14271
  addEventListenerThis,
13765
14272
  addEventListenerWindow,
13766
- afterBeginLightNodeThis,
13767
- afterBeginNodeThis,
13768
- allAppHost,
13769
- allParentHost,
13770
14273
  appendHtmlSlot,
13771
14274
  appendSlot,
13772
14275
  appendTextSlot,
13773
14276
  applyAttribute,
13774
14277
  applyClass,
13775
- applyClassThis,
13776
14278
  applyNode,
13777
- applyNodeThis,
13778
14279
  applyProperty,
13779
14280
  applySlot,
13780
14281
  applyStyle,
13781
- applyStyleThis,
13782
14282
  attribute,
13783
- attributeThis,
13784
- beforeEndLightNodeThis,
13785
- beforeEndNodeThis,
13786
- beforeEndShadowNodeThis,
13787
- changedAttributeThis,
14283
+ changedAttribute,
14284
+ changedRoute,
14285
+ clearChildrenLight,
14286
+ clearChildrenNode,
14287
+ clearNode,
13788
14288
  clearSlot,
13789
14289
  commentNode,
13790
14290
  convertAttributeValue,
@@ -13804,7 +14304,6 @@ export {
13804
14304
  elementDefine,
13805
14305
  emit,
13806
14306
  emitCustomEvent,
13807
- emitCustomEventThis,
13808
14307
  ensureInit,
13809
14308
  event,
13810
14309
  eventDelegate,
@@ -13847,15 +14346,17 @@ export {
13847
14346
  htmlSectionElement,
13848
14347
  htmlSpanElement,
13849
14348
  htmlUlElement,
13850
- innerHtmlLightNode,
13851
- innerHtmlLightNodeThis,
13852
- innerHtmlNode,
13853
- innerHtmlNodeThis,
13854
- innerHtmlShadowNode,
13855
- innerTextLightNode,
13856
- innerTextNode,
13857
- innerTextNodeThis,
13858
- innerTextShadowNode,
14349
+ innerHtml,
14350
+ innerHtmlLight,
14351
+ innerHtmlShadow,
14352
+ innerText,
14353
+ innerTextLight,
14354
+ innerTextShadow,
14355
+ insertAfterBegin,
14356
+ insertAfterBeginLight,
14357
+ insertBeforeEnd,
14358
+ insertBeforeEndLight,
14359
+ insertBeforeEndShadow,
13859
14360
  isSSR,
13860
14361
  onAdopted,
13861
14362
  onAdoptedAfter,
@@ -13875,39 +14376,26 @@ export {
13875
14376
  prependSlot,
13876
14377
  prependTextSlot,
13877
14378
  property,
13878
- propertyThis,
13879
- publish,
14379
+ publishMessage,
13880
14380
  publishSwcAppMessage,
13881
14381
  query,
13882
14382
  queryAll,
13883
- queryAllThis,
13884
- queryAppHost,
13885
- queryDocument,
13886
- queryHost,
13887
- queryThis,
13888
- queryWindow,
14383
+ receiveMessage,
13889
14384
  removeClass,
13890
- removeClassThis,
13891
14385
  removeSSRAttribute,
13892
14386
  removeStyle,
13893
- removeStyleThis,
14387
+ replaceChildren,
13894
14388
  replaceChildrenHtmlSlot,
13895
- replaceChildrenLightNodeThis,
13896
- replaceChildrenNode,
13897
- replaceChildrenNodeThis,
14389
+ replaceChildrenLight,
13898
14390
  replaceChildrenSlot,
13899
14391
  replaceChildrenTextSlot,
13900
14392
  resolveAttributeTargets,
13901
14393
  resolvePropertyTargets,
13902
14394
  setAttribute,
13903
- setAttributeThis,
13904
14395
  setClass,
13905
- setClassThis,
13906
14396
  setProperty,
13907
- setPropertyThis,
13908
14397
  setSSRAttribute,
13909
14398
  setStyle,
13910
- setStyleThis,
13911
14399
  state,
13912
14400
  subscribeSwcAppMessageWhileConnected,
13913
14401
  subscribeSwcAppRouteChangeWhileConnected,
@@ -13924,11 +14412,8 @@ export {
13924
14412
  swcAppTagName,
13925
14413
  textNode,
13926
14414
  toggleClass,
13927
- toggleClassThis,
13928
14415
  updateClass,
13929
- updateClassThis,
13930
- updateStyle,
13931
- updateStyleThis
14416
+ updateStyle
13932
14417
  };
13933
14418
  /*! Bundled license information:
13934
14419