@dooboostore/simple-web-component 1.0.44 → 1.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +25 -25
  2. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  3. package/dist/cjs/decorators/applyAttribute.js +36 -15
  4. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  5. package/dist/cjs/decorators/applyClass.js +53 -22
  6. package/dist/cjs/decorators/applyClass.js.map +2 -2
  7. package/dist/cjs/decorators/applyNode.js +54 -24
  8. package/dist/cjs/decorators/applyNode.js.map +2 -2
  9. package/dist/cjs/decorators/applyProperty.js +38 -17
  10. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  11. package/dist/cjs/decorators/applyStyle.js +53 -22
  12. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  13. package/dist/cjs/decorators/elementDefine.js +49 -33
  14. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  15. package/dist/cjs/decorators/emitCustomEvent.js +61 -47
  16. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +11 -36
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/decorators/query.js +91 -56
  20. package/dist/cjs/decorators/query.js.map +2 -2
  21. package/dist/cjs/decorators/queryAll.js +104 -66
  22. package/dist/cjs/decorators/queryAll.js.map +2 -2
  23. package/dist/cjs/elements/SwcAppMixin.js +6 -2
  24. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  25. package/dist/cjs/types/window.d.js.map +1 -1
  26. package/dist/esm/decorators/addEventListener.js.map +2 -2
  27. package/dist/esm/decorators/applyAttribute.js +36 -15
  28. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  29. package/dist/esm/decorators/applyClass.js +53 -22
  30. package/dist/esm/decorators/applyClass.js.map +2 -2
  31. package/dist/esm/decorators/applyNode.js +54 -24
  32. package/dist/esm/decorators/applyNode.js.map +2 -2
  33. package/dist/esm/decorators/applyProperty.js +38 -17
  34. package/dist/esm/decorators/applyProperty.js.map +2 -2
  35. package/dist/esm/decorators/applyStyle.js +53 -22
  36. package/dist/esm/decorators/applyStyle.js.map +2 -2
  37. package/dist/esm/decorators/elementDefine.js +50 -34
  38. package/dist/esm/decorators/elementDefine.js.map +2 -2
  39. package/dist/esm/decorators/emitCustomEvent.js +61 -47
  40. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  41. package/dist/esm/decorators/lifecycles.js +11 -36
  42. package/dist/esm/decorators/lifecycles.js.map +2 -2
  43. package/dist/esm/decorators/query.js +91 -56
  44. package/dist/esm/decorators/query.js.map +2 -2
  45. package/dist/esm/decorators/queryAll.js +104 -66
  46. package/dist/esm/decorators/queryAll.js.map +2 -2
  47. package/dist/esm/elements/SwcAppMixin.js +6 -2
  48. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  49. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +572 -320
  50. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  51. package/dist/types/decorators/addEventListener.d.ts +7 -6
  52. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  53. package/dist/types/decorators/applyAttribute.d.ts +13 -8
  54. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  55. package/dist/types/decorators/applyClass.d.ts +8 -7
  56. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  57. package/dist/types/decorators/applyNode.d.ts +18 -17
  58. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  59. package/dist/types/decorators/applyProperty.d.ts +14 -9
  60. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  61. package/dist/types/decorators/applyStyle.d.ts +6 -5
  62. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  63. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  64. package/dist/types/decorators/emitCustomEvent.d.ts +3 -2
  65. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  66. package/dist/types/decorators/lifecycles.d.ts +12 -13
  67. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  68. package/dist/types/decorators/query.d.ts +15 -5
  69. package/dist/types/decorators/query.d.ts.map +1 -1
  70. package/dist/types/decorators/queryAll.d.ts +15 -5
  71. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  72. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  73. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +572 -320
  74. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  75. package/package.json +3 -3
  76. package/src/decorators/addEventListener.ts +9 -7
  77. package/src/decorators/applyAttribute.ts +60 -27
  78. package/src/decorators/applyClass.ts +78 -32
  79. package/src/decorators/applyNode.ts +118 -73
  80. package/src/decorators/applyProperty.ts +63 -30
  81. package/src/decorators/applyStyle.ts +76 -30
  82. package/src/decorators/elementDefine.ts +57 -37
  83. package/src/decorators/emitCustomEvent.ts +63 -39
  84. package/src/decorators/lifecycles.ts +53 -52
  85. package/src/decorators/query.ts +111 -49
  86. package/src/decorators/queryAll.ts +121 -61
  87. package/src/elements/SwcAppMixin.ts +7 -3
  88. package/src/types/window.d.ts +3 -0
  89. package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
  90. package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
  91. package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
  92. package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
  93. package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
  94. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
  95. package/src/examples/RxJSOperatorsExample.ts +0 -279
@@ -1140,8 +1140,8 @@ var dooboostoreSimpleWebComponent = (() => {
1140
1140
  ON_BEFORE_ADOPTED_METADATA_KEY: () => ON_BEFORE_ADOPTED_METADATA_KEY,
1141
1141
  ON_BEFORE_CONNECTED_METADATA_KEY: () => ON_BEFORE_CONNECTED_METADATA_KEY,
1142
1142
  ON_BEFORE_DISCONNECTED_METADATA_KEY: () => ON_BEFORE_DISCONNECTED_METADATA_KEY,
1143
+ ON_CONNECTED_BODY_METADATA_KEY: () => ON_CONNECTED_BODY_METADATA_KEY,
1143
1144
  ON_CONNECTED_COMPLETED_METADATA_KEY: () => ON_CONNECTED_COMPLETED_METADATA_KEY,
1144
- ON_CONNECTED_METADATA_KEY: () => ON_CONNECTED_METADATA_KEY,
1145
1145
  ON_CONNECTED_SWC_APP_METADATA_KEY: () => ON_CONNECTED_SWC_APP_METADATA_KEY,
1146
1146
  ON_INITIALIZE_METADATA_KEY: () => ON_INITIALIZE_METADATA_KEY,
1147
1147
  PROPERTY_METADATA_KEY: () => PROPERTY_METADATA_KEY,
@@ -1267,12 +1267,12 @@ var dooboostoreSimpleWebComponent = (() => {
1267
1267
  onAdopted: () => onAdopted,
1268
1268
  onAdoptedAfter: () => onAdoptedAfter,
1269
1269
  onAdoptedBefore: () => onAdoptedBefore,
1270
- onConnected: () => onConnected,
1271
1270
  onConnectedAfter: () => onConnectedAfter,
1272
1271
  onConnectedBefore: () => onConnectedBefore,
1272
+ onConnectedBody: () => onConnectedBody,
1273
+ onConnectedBodyLight: () => onConnectedBodyLight,
1274
+ onConnectedBodyShadow: () => onConnectedBodyShadow,
1273
1275
  onConnectedCompleted: () => onConnectedCompleted,
1274
- onConnectedLight: () => onConnectedLight,
1275
- onConnectedShadow: () => onConnectedShadow,
1276
1276
  onConnectedSwcApp: () => onConnectedSwcApp,
1277
1277
  onDisconnected: () => onDisconnected,
1278
1278
  onDisconnectedAfter: () => onDisconnectedAfter,
@@ -1376,11 +1376,11 @@ var dooboostoreSimpleWebComponent = (() => {
1376
1376
  ValidUtils22.isNullOrUndefined = (data) => {
1377
1377
  return data == null || void 0 === data;
1378
1378
  };
1379
- ValidUtils22.isConstructor = (obj) => {
1380
- return typeof obj === "function" && obj.prototype !== void 0 && obj.prototype.constructor === obj;
1379
+ ValidUtils22.isClassType = (obj) => {
1380
+ return typeof obj === "function" && /^\s*class\s+/.test(obj.toString());
1381
1381
  };
1382
- ValidUtils22.isFunction = (obj) => {
1383
- return typeof obj === "function" && !(0, ValidUtils22.isConstructor)(obj);
1382
+ ValidUtils22.isFunctionType = (obj) => {
1383
+ return typeof obj === "function";
1384
1384
  };
1385
1385
  ValidUtils22.isNullish = (data) => {
1386
1386
  return ValidUtils22.isNotNullish(data);
@@ -1529,6 +1529,13 @@ var dooboostoreSimpleWebComponent = (() => {
1529
1529
  // ../core/dist/esm/array/ArrayUtils.js
1530
1530
  var ArrayUtils;
1531
1531
  ((ArrayUtils2) => {
1532
+ ArrayUtils2.split = (data, length) => {
1533
+ const result = [];
1534
+ for (let i = 0; i < data.length; i += length) {
1535
+ result.push(data.slice(i, i + length));
1536
+ }
1537
+ return result;
1538
+ };
1532
1539
  ArrayUtils2.create2DArray = (rows, cols, initialValue) => {
1533
1540
  const array = [];
1534
1541
  for (let row = 0; row < rows; row++) {
@@ -4299,6 +4306,10 @@ var dooboostoreSimpleWebComponent = (() => {
4299
4306
  const rotatedY = translatedX * Math.sin(angleInRadians) + translatedY * Math.cos(angleInRadians);
4300
4307
  return new Point2D(rotatedX + center.x, rotatedY + center.y);
4301
4308
  };
4309
+ MathUtil2.quadraticBezier = (p0, p1, p2, t) => {
4310
+ const mt = 1 - t;
4311
+ return mt * mt * p0 + 2 * mt * t * p1 + t * t * p2;
4312
+ };
4302
4313
  })(MathUtil || (MathUtil = {}));
4303
4314
 
4304
4315
  // ../core/dist/esm/convert/ConvertUtils.js
@@ -5254,7 +5265,7 @@ var dooboostoreSimpleWebComponent = (() => {
5254
5265
  } catch (e) {
5255
5266
  const targetHas = Array.isArray(has) ? has : [has];
5256
5267
  for (let ha of targetHas) {
5257
- if (ValidUtils.isConstructor(ha)) {
5268
+ if (ValidUtils.isFunctionType(ha)) {
5258
5269
  if (e instanceof ha) {
5259
5270
  return e;
5260
5271
  }
@@ -6709,7 +6720,7 @@ var dooboostoreSimpleWebComponent = (() => {
6709
6720
  var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-adopted");
6710
6721
  var ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-adopted");
6711
6722
  var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:on-add-event-listener");
6712
- var ON_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component");
6723
+ var ON_CONNECTED_BODY_METADATA_KEY = Symbol.for("simple-web-component:on-connected-body");
6713
6724
  var ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for("simple-web-component:on-connected-swc-app");
6714
6725
  var ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for("simple-web-component:on-completed");
6715
6726
  var ATTRIBUTE_CHANGED_WILDCARD = "*";
@@ -6795,14 +6806,14 @@ var dooboostoreSimpleWebComponent = (() => {
6795
6806
  }
6796
6807
  var decorator = (options, target, propertyKey) => {
6797
6808
  const constructor = target.constructor;
6798
- let list = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor);
6809
+ let list = ReflectUtils.getMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor);
6799
6810
  if (!list) {
6800
6811
  list = [];
6801
- ReflectUtils.defineMetadata(ON_CONNECTED_METADATA_KEY, list, constructor);
6812
+ ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);
6802
6813
  }
6803
6814
  list.push({ propertyKey, options });
6804
6815
  };
6805
- function onConnectedShadow(optionOrTarget, propertyKey, arg3) {
6816
+ function onConnectedBodyShadow(optionOrTarget, propertyKey, arg3) {
6806
6817
  if (propertyKey) {
6807
6818
  return decorator({ useShadow: true }, optionOrTarget, propertyKey);
6808
6819
  }
@@ -6810,7 +6821,7 @@ var dooboostoreSimpleWebComponent = (() => {
6810
6821
  decorator({ ...optionOrTarget ?? {}, useShadow: true }, target, propertyKey2);
6811
6822
  };
6812
6823
  }
6813
- function onConnectedLight(optionOrTarget, propertyKey, arg3) {
6824
+ function onConnectedBodyLight(optionOrTarget, propertyKey, arg3) {
6814
6825
  if (propertyKey) {
6815
6826
  return decorator({ useShadow: false }, optionOrTarget, propertyKey);
6816
6827
  }
@@ -6818,7 +6829,7 @@ var dooboostoreSimpleWebComponent = (() => {
6818
6829
  decorator({ ...optionOrTarget ?? {}, useShadow: false }, target, propertyKey2);
6819
6830
  };
6820
6831
  }
6821
- function onConnected(optionOrTarget, propertyKey, arg3) {
6832
+ function onConnectedBody(optionOrTarget, propertyKey, arg3) {
6822
6833
  if (propertyKey) {
6823
6834
  return decorator({}, optionOrTarget, propertyKey);
6824
6835
  }
@@ -6833,7 +6844,7 @@ var dooboostoreSimpleWebComponent = (() => {
6833
6844
  };
6834
6845
  var findAllOnConnectedMetadata = (target) => {
6835
6846
  const constructor = target instanceof Function ? target : target.constructor;
6836
- const results = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
6847
+ const results = ReflectUtils.getMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor) ?? [];
6837
6848
  return [...results].sort((a, b) => {
6838
6849
  const orderA = a.options?.order ?? 0;
6839
6850
  const orderB = b.options?.order ?? 0;
@@ -9162,7 +9173,7 @@ var dooboostoreSimpleWebComponent = (() => {
9162
9173
  if (typeof selectorOrTarget === "object" && typeof typeOrPropertyKey === "string" && typeof optionsOrDescriptor === "object" && "value" in optionsOrDescriptor) {
9163
9174
  throw new Error(`@emitCustomEvent decorator cannot be used on properties. (Property: ${String(typeOrPropertyKey)})`);
9164
9175
  }
9165
- if (typeof selectorOrTarget === "string" && typeof typeOrPropertyKey === "string") {
9176
+ if ((typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") && typeof typeOrPropertyKey === "string") {
9166
9177
  return createEmitDecorator(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor);
9167
9178
  }
9168
9179
  if (typeof selectorOrTarget === "string" && typeOrPropertyKey !== "string") {
@@ -9195,58 +9206,72 @@ var dooboostoreSimpleWebComponent = (() => {
9195
9206
  composed: fullOptions.composed,
9196
9207
  cancelable: fullOptions.cancelable
9197
9208
  });
9198
- const hostSet = SwcUtils.getHostSet(this);
9199
9209
  const conf = getElementConfig(this);
9200
9210
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
9211
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
9201
9212
  const eventTargets = [];
9202
- if (selector === "$window")
9203
- eventTargets.push(currentWin);
9204
- else if (selector === "$document")
9205
- eventTargets.push(currentWin.document);
9206
- else if (selector === "$host") {
9207
- if (hostSet.$host)
9208
- eventTargets.push(hostSet.$host);
9209
- } else if (selector === "$parentHost") {
9210
- if (hostSet.$parentHost)
9211
- eventTargets.push(hostSet.$parentHost);
9212
- } else if (selector === "$appHost") {
9213
- if (hostSet.$appHost)
9214
- eventTargets.push(hostSet.$appHost);
9215
- } else if (selector === "$firstHost") {
9216
- if (hostSet.$firstHost)
9217
- eventTargets.push(hostSet.$firstHost);
9218
- } else if (selector === "$lastHost") {
9219
- if (hostSet.$lastHost)
9220
- eventTargets.push(hostSet.$lastHost);
9221
- } else if (selector === "$firstAppHost") {
9222
- if (hostSet.$firstAppHost)
9223
- eventTargets.push(hostSet.$firstAppHost);
9224
- } else if (selector === "$lastAppHost") {
9225
- if (hostSet.$lastAppHost)
9226
- eventTargets.push(hostSet.$lastAppHost);
9227
- } else if (selector === "$hosts") {
9228
- hostSet.$hosts.forEach((h) => eventTargets.push(h));
9229
- } else if (selector === "$appHosts") {
9230
- hostSet.$appHosts.forEach((h) => eventTargets.push(h));
9231
- } else if (selector === "$this" || !selector) {
9232
- eventTargets.push(this);
9213
+ let resolvedSelector = selector;
9214
+ if (typeof selector === "function") {
9215
+ resolvedSelector = selector(this, hostSet);
9216
+ }
9217
+ if (resolvedSelector instanceof currentWin.Element) {
9218
+ eventTargets.push(resolvedSelector);
9219
+ } else if (resolvedSelector instanceof currentWin.NodeList) {
9220
+ eventTargets.push(...Array.from(resolvedSelector));
9221
+ } else if (Array.isArray(resolvedSelector)) {
9222
+ eventTargets.push(...resolvedSelector);
9223
+ } else if (resolvedSelector === null) {
9233
9224
  } else {
9234
- const r = fullOptions.root || "auto";
9235
- const searchRoots = [];
9236
- if (r === "auto")
9237
- searchRoots.push(this.shadowRoot || this);
9238
- else if (r === "light")
9239
- searchRoots.push(this);
9240
- else if (r === "shadow" && this.shadowRoot)
9241
- searchRoots.push(this.shadowRoot);
9242
- else if (r === "all") {
9243
- searchRoots.push(this);
9244
- if (this.shadowRoot)
9225
+ const stringSelector = resolvedSelector;
9226
+ if (stringSelector === "$window")
9227
+ eventTargets.push(currentWin);
9228
+ else if (stringSelector === "$document")
9229
+ eventTargets.push(currentWin.document);
9230
+ else if (stringSelector === "$host") {
9231
+ if (hostSet.$host)
9232
+ eventTargets.push(hostSet.$host);
9233
+ } else if (stringSelector === "$parentHost") {
9234
+ if (hostSet.$parentHost)
9235
+ eventTargets.push(hostSet.$parentHost);
9236
+ } else if (stringSelector === "$appHost") {
9237
+ if (hostSet.$appHost)
9238
+ eventTargets.push(hostSet.$appHost);
9239
+ } else if (stringSelector === "$firstHost") {
9240
+ if (hostSet.$firstHost)
9241
+ eventTargets.push(hostSet.$firstHost);
9242
+ } else if (stringSelector === "$lastHost") {
9243
+ if (hostSet.$lastHost)
9244
+ eventTargets.push(hostSet.$lastHost);
9245
+ } else if (stringSelector === "$firstAppHost") {
9246
+ if (hostSet.$firstAppHost)
9247
+ eventTargets.push(hostSet.$firstAppHost);
9248
+ } else if (stringSelector === "$lastAppHost") {
9249
+ if (hostSet.$lastAppHost)
9250
+ eventTargets.push(hostSet.$lastAppHost);
9251
+ } else if (stringSelector === "$hosts") {
9252
+ hostSet.$hosts.forEach((h) => eventTargets.push(h));
9253
+ } else if (stringSelector === "$appHosts") {
9254
+ hostSet.$appHosts.forEach((h) => eventTargets.push(h));
9255
+ } else if (stringSelector === "$this" || !stringSelector) {
9256
+ eventTargets.push(this);
9257
+ } else {
9258
+ const r = fullOptions.root || "auto";
9259
+ const searchRoots = [];
9260
+ if (r === "auto")
9261
+ searchRoots.push(this.shadowRoot || this);
9262
+ else if (r === "light")
9263
+ searchRoots.push(this);
9264
+ else if (r === "shadow" && this.shadowRoot)
9245
9265
  searchRoots.push(this.shadowRoot);
9266
+ else if (r === "all") {
9267
+ searchRoots.push(this);
9268
+ if (this.shadowRoot)
9269
+ searchRoots.push(this.shadowRoot);
9270
+ }
9271
+ searchRoots.forEach((sr) => {
9272
+ sr.querySelectorAll(stringSelector).forEach((el) => eventTargets.push(el));
9273
+ });
9246
9274
  }
9247
- searchRoots.forEach((sr) => {
9248
- sr.querySelectorAll(selector).forEach((el) => eventTargets.push(el));
9249
- });
9250
9275
  }
9251
9276
  eventTargets.forEach((t) => {
9252
9277
  if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
@@ -9322,7 +9347,7 @@ var dooboostoreSimpleWebComponent = (() => {
9322
9347
  if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
9323
9348
  throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
9324
9349
  }
9325
- if (typeof selectorOrTarget === "string") {
9350
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
9326
9351
  return (targetObj, propertyKey, descriptor2) => {
9327
9352
  if (descriptor2 !== void 0) {
9328
9353
  throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
@@ -9337,75 +9362,110 @@ var dooboostoreSimpleWebComponent = (() => {
9337
9362
  Object.defineProperty(targetObj, propertyKey, {
9338
9363
  get() {
9339
9364
  ensureInit(this);
9340
- const selector = selectorOrTarget;
9341
- const r = optionsOrPropertyKey?.root || "auto";
9342
- const applyRoot = (t) => {
9343
- if (!t || !(t instanceof HTMLElement))
9344
- return t;
9345
- if (r === "auto")
9346
- return t.shadowRoot || t;
9347
- if (r === "shadow")
9348
- return t.shadowRoot;
9349
- if (r === "light")
9350
- return t;
9351
- if (r === "all")
9352
- return t.shadowRoot || t;
9353
- return t;
9354
- };
9355
- const hostSet = SwcUtils.getHostSet(this);
9356
- if (selector === "$this")
9357
- return applyRoot(this);
9358
- if (selector === "$host")
9359
- return applyRoot(hostSet.$host);
9360
- if (selector === "$parentHost")
9361
- return applyRoot(hostSet.$parentHost);
9362
- if (selector === "$appHost")
9363
- return applyRoot(hostSet.$appHost);
9364
- if (selector === "$firstHost")
9365
- return applyRoot(hostSet.$firstHost);
9366
- if (selector === "$lastHost")
9367
- return applyRoot(hostSet.$lastHost);
9368
- if (selector === "$firstAppHost")
9369
- return applyRoot(hostSet.$firstAppHost);
9370
- if (selector === "$lastAppHost")
9371
- return applyRoot(hostSet.$lastAppHost);
9372
9365
  const config = getElementConfig(this);
9373
9366
  const win = config?.window || window;
9374
- if (selector === "$window")
9375
- return win;
9376
- if (selector === "$document")
9377
- return win.document;
9378
- if (r === "shadow")
9379
- return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
9380
- if (r === "light")
9381
- return this.querySelector(selector);
9382
- if (r === "all") {
9383
- const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
9384
- return shadowMatch || this.querySelector(selector);
9367
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9368
+ let resolvedSelector;
9369
+ let resolvedElement = null;
9370
+ if (typeof selectorOrTarget === "function") {
9371
+ const result = selectorOrTarget(this, hostSet);
9372
+ if (result instanceof win.Node || result instanceof win.Element) {
9373
+ resolvedElement = result instanceof win.HTMLElement ? result : null;
9374
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
9375
+ resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? result[0] : null;
9376
+ }
9377
+ } else {
9378
+ resolvedSelector = selectorOrTarget;
9379
+ const r = optionsOrPropertyKey?.root || "auto";
9380
+ const applyRoot = (t) => {
9381
+ if (!t || !(t instanceof HTMLElement))
9382
+ return t;
9383
+ if (r === "auto")
9384
+ return t.shadowRoot || t;
9385
+ if (r === "shadow")
9386
+ return t.shadowRoot;
9387
+ if (r === "light")
9388
+ return t;
9389
+ if (r === "all")
9390
+ return t.shadowRoot || t;
9391
+ return t;
9392
+ };
9393
+ if (resolvedSelector === "$this")
9394
+ resolvedElement = applyRoot(this);
9395
+ else if (resolvedSelector === "$host")
9396
+ resolvedElement = applyRoot(hostSet.$host);
9397
+ else if (resolvedSelector === "$parentHost")
9398
+ resolvedElement = applyRoot(hostSet.$parentHost);
9399
+ else if (resolvedSelector === "$appHost")
9400
+ resolvedElement = applyRoot(hostSet.$appHost);
9401
+ else if (resolvedSelector === "$firstHost")
9402
+ resolvedElement = applyRoot(hostSet.$firstHost);
9403
+ else if (resolvedSelector === "$lastHost")
9404
+ resolvedElement = applyRoot(hostSet.$lastHost);
9405
+ else if (resolvedSelector === "$firstAppHost")
9406
+ resolvedElement = applyRoot(hostSet.$firstAppHost);
9407
+ else if (resolvedSelector === "$lastAppHost")
9408
+ resolvedElement = applyRoot(hostSet.$lastAppHost);
9409
+ else if (resolvedSelector === "$window")
9410
+ return win;
9411
+ else if (resolvedSelector === "$document")
9412
+ return win.document;
9413
+ else {
9414
+ if (r === "shadow")
9415
+ resolvedElement = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
9416
+ else if (r === "light")
9417
+ resolvedElement = this.querySelector(resolvedSelector);
9418
+ else if (r === "all") {
9419
+ const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
9420
+ resolvedElement = shadowMatch || this.querySelector(resolvedSelector);
9421
+ } else
9422
+ resolvedElement = (this.shadowRoot || this).querySelector(resolvedSelector);
9423
+ }
9424
+ }
9425
+ if (resolvedElement instanceof win.HTMLElement && optionsOrPropertyKey?.filter) {
9426
+ const shouldInclude = optionsOrPropertyKey.filter(resolvedElement, { currentThis: this, helper: hostSet });
9427
+ if (!shouldInclude) {
9428
+ return null;
9429
+ }
9385
9430
  }
9386
- return (this.shadowRoot || this).querySelector(selector);
9431
+ return resolvedElement;
9387
9432
  },
9388
9433
  set(nv) {
9389
9434
  ensureInit(this);
9390
9435
  if (nv === null || nv === void 0) {
9391
- const selector = selectorOrTarget;
9392
- if (selector.startsWith("$") && selector !== "$this")
9436
+ const config = getElementConfig(this);
9437
+ const win = config?.window || window;
9438
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9439
+ if (typeof selectorOrTarget === "function") {
9440
+ const result = selectorOrTarget(this, hostSet);
9441
+ if (result instanceof win.Element) {
9442
+ result.remove();
9443
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
9444
+ const el = result.length > 0 ? result[0] : null;
9445
+ if (el instanceof win.Element) {
9446
+ el.remove();
9447
+ }
9448
+ }
9449
+ return;
9450
+ }
9451
+ const resolvedSelector = selectorOrTarget;
9452
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
9393
9453
  return;
9394
9454
  const r = optionsOrPropertyKey?.root || "auto";
9395
9455
  const targets = [];
9396
9456
  if (r === "shadow") {
9397
- if (this.shadowRoot?.querySelector(selector))
9398
- targets.push(this.shadowRoot.querySelector(selector));
9457
+ if (this.shadowRoot?.querySelector(resolvedSelector))
9458
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
9399
9459
  } else if (r === "light") {
9400
- if (this.querySelector(selector))
9401
- targets.push(this.querySelector(selector));
9460
+ if (this.querySelector(resolvedSelector))
9461
+ targets.push(this.querySelector(resolvedSelector));
9402
9462
  } else if (r === "all") {
9403
- if (this.shadowRoot?.querySelector(selector))
9404
- targets.push(this.shadowRoot.querySelector(selector));
9405
- if (this.querySelector(selector))
9406
- targets.push(this.querySelector(selector));
9463
+ if (this.shadowRoot?.querySelector(resolvedSelector))
9464
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
9465
+ if (this.querySelector(resolvedSelector))
9466
+ targets.push(this.querySelector(resolvedSelector));
9407
9467
  } else {
9408
- const el = (this.shadowRoot || this).querySelector(selector);
9468
+ const el = (this.shadowRoot || this).querySelector(resolvedSelector);
9409
9469
  if (el)
9410
9470
  targets.push(el);
9411
9471
  }
@@ -9430,7 +9490,7 @@ var dooboostoreSimpleWebComponent = (() => {
9430
9490
  if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
9431
9491
  throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
9432
9492
  }
9433
- if (typeof selectorOrTarget === "string") {
9493
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
9434
9494
  return (targetObj, propertyKey, descriptor2) => {
9435
9495
  if (descriptor2 !== void 0) {
9436
9496
  throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
@@ -9445,86 +9505,124 @@ var dooboostoreSimpleWebComponent = (() => {
9445
9505
  Object.defineProperty(targetObj, propertyKey, {
9446
9506
  get() {
9447
9507
  ensureInit(this);
9448
- const selector = selectorOrTarget;
9449
- const r = optionsOrPropertyKey?.root || "auto";
9450
- const applyRoot = (t) => {
9451
- if (!t)
9452
- return [];
9453
- const items = Array.isArray(t) ? t : [t];
9454
- const results = [];
9455
- items.forEach((it) => {
9456
- if (!(it instanceof HTMLElement)) {
9457
- results.push(it);
9458
- return;
9459
- }
9460
- if (r === "auto")
9461
- results.push(it.shadowRoot || it);
9462
- else {
9463
- if (r === "light" || r === "all")
9464
- results.push(it);
9465
- if ((r === "shadow" || r === "all") && it.shadowRoot)
9466
- results.push(it.shadowRoot);
9467
- }
9468
- });
9469
- return results;
9470
- };
9471
- const hostSet = SwcUtils.getHostSet(this);
9472
- if (selector === "$hosts")
9473
- return applyRoot(hostSet.$hosts);
9474
- if (selector === "$appHosts")
9475
- return applyRoot(hostSet.$appHosts);
9476
- if (selector === "$host")
9477
- return applyRoot(hostSet.$host);
9478
- if (selector === "$parentHost")
9479
- return applyRoot(hostSet.$parentHost);
9480
- if (selector === "$appHost")
9481
- return applyRoot(hostSet.$appHost);
9482
- if (selector === "$firstHost")
9483
- return applyRoot(hostSet.$firstHost);
9484
- if (selector === "$lastHost")
9485
- return applyRoot(hostSet.$lastHost);
9486
- if (selector === "$firstAppHost")
9487
- return applyRoot(hostSet.$firstAppHost);
9488
- if (selector === "$lastAppHost")
9489
- return applyRoot(hostSet.$lastAppHost);
9490
9508
  const config = getElementConfig(this);
9491
9509
  const win = config?.window || window;
9492
- if (selector === "$window")
9493
- return [win];
9494
- if (selector === "$document")
9495
- return [win.document];
9496
- if (selector === "$this")
9497
- return applyRoot(this);
9498
- if (r === "shadow")
9499
- return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9500
- if (r === "light")
9501
- return Array.from(this.querySelectorAll(selector));
9502
- if (r === "all") {
9503
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9504
- const lNodes = Array.from(this.querySelectorAll(selector));
9505
- return [...sNodes, ...lNodes];
9510
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9511
+ let resolvedSelector;
9512
+ let resolvedElements = [];
9513
+ if (typeof selectorOrTarget === "function") {
9514
+ const result = selectorOrTarget(this, hostSet);
9515
+ if (result instanceof win.NodeList) {
9516
+ resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
9517
+ } else if (Array.isArray(result)) {
9518
+ resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
9519
+ }
9520
+ } else {
9521
+ resolvedSelector = selectorOrTarget;
9522
+ const r = optionsOrPropertyKey?.root || "auto";
9523
+ const applyRoot = (t) => {
9524
+ if (!t)
9525
+ return [];
9526
+ const items = Array.isArray(t) ? t : [t];
9527
+ const results = [];
9528
+ items.forEach((it) => {
9529
+ if (!(it instanceof HTMLElement)) {
9530
+ results.push(it);
9531
+ return;
9532
+ }
9533
+ if (r === "auto")
9534
+ results.push(it.shadowRoot || it);
9535
+ else {
9536
+ if (r === "light" || r === "all")
9537
+ results.push(it);
9538
+ if ((r === "shadow" || r === "all") && it.shadowRoot)
9539
+ results.push(it.shadowRoot);
9540
+ }
9541
+ });
9542
+ return results;
9543
+ };
9544
+ if (resolvedSelector === "$hosts")
9545
+ resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
9546
+ else if (resolvedSelector === "$appHosts")
9547
+ resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
9548
+ else if (resolvedSelector === "$host")
9549
+ resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
9550
+ else if (resolvedSelector === "$parentHost")
9551
+ resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
9552
+ else if (resolvedSelector === "$appHost")
9553
+ resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
9554
+ else if (resolvedSelector === "$firstHost")
9555
+ resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
9556
+ else if (resolvedSelector === "$lastHost")
9557
+ resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
9558
+ else if (resolvedSelector === "$firstAppHost")
9559
+ resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
9560
+ else if (resolvedSelector === "$lastAppHost")
9561
+ resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
9562
+ else if (resolvedSelector === "$window")
9563
+ return [win];
9564
+ else if (resolvedSelector === "$document")
9565
+ return [win.document];
9566
+ else if (resolvedSelector === "$this")
9567
+ resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
9568
+ else {
9569
+ if (r === "shadow")
9570
+ resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9571
+ else if (r === "light")
9572
+ resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
9573
+ else if (r === "all") {
9574
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9575
+ const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
9576
+ resolvedElements = [...sNodes, ...lNodes];
9577
+ } else
9578
+ resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
9579
+ }
9506
9580
  }
9507
- const root = this.shadowRoot || this;
9508
- return Array.from(root.querySelectorAll(selector));
9581
+ if (optionsOrPropertyKey?.filter) {
9582
+ resolvedElements = resolvedElements.filter((el) => {
9583
+ if (!(el instanceof win.HTMLElement))
9584
+ return true;
9585
+ return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
9586
+ });
9587
+ }
9588
+ return resolvedElements;
9509
9589
  },
9510
9590
  set(nv) {
9511
9591
  ensureInit(this);
9512
9592
  if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
9513
- const selector = selectorOrTarget;
9514
- if (selector.startsWith("$") && selector !== "$this")
9593
+ const config = getElementConfig(this);
9594
+ const win = config?.window || window;
9595
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9596
+ if (typeof selectorOrTarget === "function") {
9597
+ const result = selectorOrTarget(this, hostSet);
9598
+ if (result instanceof win.NodeList) {
9599
+ Array.from(result).forEach((el) => {
9600
+ if (el instanceof win.Element)
9601
+ el.remove();
9602
+ });
9603
+ } else if (Array.isArray(result)) {
9604
+ result.forEach((el) => {
9605
+ if (el instanceof win.Element)
9606
+ el.remove();
9607
+ });
9608
+ }
9609
+ return;
9610
+ }
9611
+ const resolvedSelector = selectorOrTarget;
9612
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
9515
9613
  return;
9516
9614
  const r = optionsOrPropertyKey?.root || "auto";
9517
9615
  let targets = [];
9518
9616
  if (r === "shadow")
9519
- targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9617
+ targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9520
9618
  else if (r === "light")
9521
- targets = Array.from(this.querySelectorAll(selector));
9619
+ targets = Array.from(this.querySelectorAll(resolvedSelector));
9522
9620
  else if (r === "all") {
9523
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9524
- const lNodes = Array.from(this.querySelectorAll(selector));
9621
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9622
+ const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
9525
9623
  targets = [...sNodes, ...lNodes];
9526
9624
  } else {
9527
- targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
9625
+ targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
9528
9626
  }
9529
9627
  targets.forEach((t) => t.remove());
9530
9628
  }
@@ -9724,6 +9822,27 @@ var dooboostoreSimpleWebComponent = (() => {
9724
9822
  const currentWin = conf.window;
9725
9823
  const r = options.root || "auto";
9726
9824
  const results = [];
9825
+ let resolvedSelector = selector;
9826
+ if (typeof selector === "function") {
9827
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
9828
+ resolvedSelector = selector(inst, hostSet);
9829
+ }
9830
+ if (resolvedSelector instanceof currentWin.Element) {
9831
+ results.push(resolvedSelector);
9832
+ return results;
9833
+ }
9834
+ if (resolvedSelector instanceof currentWin.NodeList) {
9835
+ results.push(...Array.from(resolvedSelector));
9836
+ return results;
9837
+ }
9838
+ if (Array.isArray(resolvedSelector)) {
9839
+ results.push(...resolvedSelector);
9840
+ return results;
9841
+ }
9842
+ if (resolvedSelector === null) {
9843
+ return results;
9844
+ }
9845
+ const stringSelector = resolvedSelector;
9727
9846
  const applyRoot = (target) => {
9728
9847
  if (!target) return;
9729
9848
  if (r === "auto") {
@@ -9733,37 +9852,37 @@ var dooboostoreSimpleWebComponent = (() => {
9733
9852
  if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
9734
9853
  }
9735
9854
  };
9736
- if (selector === "$this" || !selector) {
9855
+ if (stringSelector === "$this" || !stringSelector) {
9737
9856
  applyRoot(inst);
9738
- } else if (selector === "$window") {
9857
+ } else if (stringSelector === "$window") {
9739
9858
  results.push(currentWin);
9740
- } else if (selector === "$document") {
9859
+ } else if (stringSelector === "$document") {
9741
9860
  results.push(currentWin.document);
9742
9861
  } else {
9743
9862
  const hostSet = SwcUtils.getHostSet(inst);
9744
- if (selector === "$host") applyRoot(hostSet.$host);
9745
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
9746
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
9747
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
9748
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
9749
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
9750
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
9751
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
9752
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
9863
+ if (stringSelector === "$host") applyRoot(hostSet.$host);
9864
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
9865
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
9866
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
9867
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
9868
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
9869
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
9870
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
9871
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
9753
9872
  else {
9754
9873
  if (r === "shadow") {
9755
- const found = inst.shadowRoot?.querySelectorAll(selector);
9874
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
9756
9875
  if (found) results.push(...found);
9757
9876
  } else if (r === "light") {
9758
- const found = inst.querySelectorAll(selector);
9877
+ const found = inst.querySelectorAll(stringSelector);
9759
9878
  if (found) results.push(...found);
9760
9879
  } else if (r === "all") {
9761
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
9762
- const lMatch = inst.querySelectorAll(selector);
9880
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
9881
+ const lMatch = inst.querySelectorAll(stringSelector);
9763
9882
  if (sMatch) results.push(...sMatch);
9764
9883
  if (lMatch) results.push(...lMatch);
9765
9884
  } else {
9766
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
9885
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
9767
9886
  if (found) results.push(...found);
9768
9887
  }
9769
9888
  }
@@ -10128,10 +10247,10 @@ var dooboostoreSimpleWebComponent = (() => {
10128
10247
  }
10129
10248
  const conf = getElementConfig(this);
10130
10249
  const currentWin = this._resolveWindow(conf);
10131
- const bMethods = findAllOnConnectedBeforeMetadata(this).filter((it) => useSsr ? !it.options.ssrFirst : true);
10250
+ const bMethods = findAllOnConnectedBeforeMetadata(this);
10132
10251
  for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10133
10252
  this._executeSwcScript("swc-on-before-connected", helperHostSet);
10134
- const targetConnectedList = findAllOnConnectedMetadata(constructor).filter((it) => useSsr ? !it.options.ssrFirst : true);
10253
+ const targetConnectedList = useSsr ? [] : findAllOnConnectedMetadata(constructor);
10135
10254
  const shadowMode = conf?.useShadow || targetConnectedList.find((it) => it.options.useShadow)?.options.useShadow;
10136
10255
  if (shadowMode && !this.shadowRoot) {
10137
10256
  const mode = shadowMode === true ? "open" : shadowMode;
@@ -10188,7 +10307,8 @@ var dooboostoreSimpleWebComponent = (() => {
10188
10307
  const delegateListeners = [];
10189
10308
  const nonDelegateListeners = [];
10190
10309
  addEventListenerList.forEach((meta) => {
10191
- 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 !== "") {
10310
+ const isStringSelector = typeof meta.selector === "string";
10311
+ 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 !== "") {
10192
10312
  delegateListeners.push(meta);
10193
10313
  } else {
10194
10314
  nonDelegateListeners.push(meta);
@@ -10224,7 +10344,7 @@ var dooboostoreSimpleWebComponent = (() => {
10224
10344
  const unifiedHandler = async (event2) => {
10225
10345
  for (const meta of sortedMetaList) {
10226
10346
  const { selector, options } = meta;
10227
- const matchedEl = event2.target.closest(selector);
10347
+ const matchedEl = event2.target?.closest(selector);
10228
10348
  if (matchedEl && br.contains(matchedEl)) {
10229
10349
  if (options.filter) {
10230
10350
  const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
@@ -10251,6 +10371,22 @@ var dooboostoreSimpleWebComponent = (() => {
10251
10371
  const opts = { capture: options.capture, once: options.once, passive: options.passive };
10252
10372
  const bindTargets = [];
10253
10373
  const r = options.root || "auto";
10374
+ let resolvedSelector = null;
10375
+ if (typeof selector === "function") {
10376
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
10377
+ const result = selector(this, hostSet);
10378
+ if (typeof result === "string") {
10379
+ resolvedSelector = result;
10380
+ } else if (result instanceof currentWin.Element) {
10381
+ bindTargets.push(result);
10382
+ } else if (result instanceof currentWin.NodeList) {
10383
+ bindTargets.push(...Array.from(result));
10384
+ } else if (Array.isArray(result)) {
10385
+ bindTargets.push(...result);
10386
+ }
10387
+ } else {
10388
+ resolvedSelector = selector;
10389
+ }
10254
10390
  const applyRootOption = (target) => {
10255
10391
  if (!target) return;
10256
10392
  if (r === "auto") {
@@ -10260,30 +10396,32 @@ var dooboostoreSimpleWebComponent = (() => {
10260
10396
  if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
10261
10397
  }
10262
10398
  };
10263
- if (selector === "$window") bindTargets.push(currentWin);
10264
- else if (selector === "$document") bindTargets.push(currentWin.document);
10265
- else if (selector === "$host") applyRootOption(helperHostSet.$host);
10266
- else if (selector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
10267
- else if (selector === "$appHost") applyRootOption(helperHostSet.$appHost);
10268
- else if (selector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
10269
- else if (selector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
10270
- else if (selector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
10271
- else if (selector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
10272
- else if (selector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
10273
- else if (selector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
10274
- else if (selector === "$this" || !selector) applyRootOption(this);
10275
- else {
10276
- const searchRoots = [];
10277
- if (r === "auto") searchRoots.push(this.shadowRoot || this);
10278
- else if (r === "light") searchRoots.push(this);
10279
- else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
10280
- else if (r === "all") {
10281
- searchRoots.push(this);
10282
- if (this.shadowRoot) searchRoots.push(this.shadowRoot);
10399
+ if (resolvedSelector) {
10400
+ if (resolvedSelector === "$window") bindTargets.push(currentWin);
10401
+ else if (resolvedSelector === "$document") bindTargets.push(currentWin.document);
10402
+ else if (resolvedSelector === "$host") applyRootOption(helperHostSet.$host);
10403
+ else if (resolvedSelector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
10404
+ else if (resolvedSelector === "$appHost") applyRootOption(helperHostSet.$appHost);
10405
+ else if (resolvedSelector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
10406
+ else if (resolvedSelector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
10407
+ else if (resolvedSelector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
10408
+ else if (resolvedSelector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
10409
+ else if (resolvedSelector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
10410
+ else if (resolvedSelector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
10411
+ else if (resolvedSelector === "$this" || !resolvedSelector) applyRootOption(this);
10412
+ else {
10413
+ const searchRoots = [];
10414
+ if (r === "auto") searchRoots.push(this.shadowRoot || this);
10415
+ else if (r === "light") searchRoots.push(this);
10416
+ else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
10417
+ else if (r === "all") {
10418
+ searchRoots.push(this);
10419
+ if (this.shadowRoot) searchRoots.push(this.shadowRoot);
10420
+ }
10421
+ searchRoots.forEach((sr) => {
10422
+ sr.querySelectorAll(resolvedSelector).forEach((el) => bindTargets.push(el));
10423
+ });
10283
10424
  }
10284
- searchRoots.forEach((sr) => {
10285
- sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
10286
- });
10287
10425
  }
10288
10426
  bindTargets.forEach((t) => {
10289
10427
  const handler = async (event2) => {
@@ -10298,7 +10436,7 @@ var dooboostoreSimpleWebComponent = (() => {
10298
10436
  if (options.preventDefault) event2.preventDefault();
10299
10437
  const currentHostSet = SwcUtils.getHostSet(this);
10300
10438
  const args = { event: event2, ...currentHostSet, $el: t, $root: t };
10301
- await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
10439
+ await this[meta.propertyKey](event2, { currentHostSet, $matchedElement: event2.currentTarget }, args);
10302
10440
  };
10303
10441
  const eventSubject = new Subject();
10304
10442
  let eventStream = eventSubject;
@@ -10329,9 +10467,7 @@ var dooboostoreSimpleWebComponent = (() => {
10329
10467
  });
10330
10468
  });
10331
10469
  if (originalConnected) await originalConnected.apply(this);
10332
- const aMethods = findAllOnConnectedAfterMetadata(this).filter((it) => {
10333
- return useSsr ? !it.options.ssrFirst : true;
10334
- });
10470
+ const aMethods = findAllOnConnectedAfterMetadata(this);
10335
10471
  for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10336
10472
  this._executeSwcScript("swc-on-connected", helperHostSet);
10337
10473
  this._executeSwcScript("swc-on-after-connected", helperHostSet);
@@ -10497,6 +10633,27 @@ var dooboostoreSimpleWebComponent = (() => {
10497
10633
  const currentWin = conf.window;
10498
10634
  const r = options.root || "auto";
10499
10635
  const results = [];
10636
+ let resolvedSelector = selector;
10637
+ if (typeof selector === "function") {
10638
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
10639
+ resolvedSelector = selector(inst, hostSet);
10640
+ }
10641
+ if (resolvedSelector instanceof currentWin.Element) {
10642
+ results.push(resolvedSelector);
10643
+ return results;
10644
+ }
10645
+ if (resolvedSelector instanceof currentWin.NodeList) {
10646
+ results.push(...Array.from(resolvedSelector));
10647
+ return results;
10648
+ }
10649
+ if (Array.isArray(resolvedSelector)) {
10650
+ results.push(...resolvedSelector);
10651
+ return results;
10652
+ }
10653
+ if (resolvedSelector === null) {
10654
+ return results;
10655
+ }
10656
+ const stringSelector = resolvedSelector;
10500
10657
  const applyRoot = (target) => {
10501
10658
  if (!target) return;
10502
10659
  if (r === "auto") {
@@ -10506,33 +10663,33 @@ var dooboostoreSimpleWebComponent = (() => {
10506
10663
  if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
10507
10664
  }
10508
10665
  };
10509
- if (selector === "$this" || !selector) {
10666
+ if (stringSelector === "$this" || !stringSelector) {
10510
10667
  applyRoot(inst);
10511
10668
  } else {
10512
10669
  const hostSet = SwcUtils.getHostSet(inst);
10513
- if (selector === "$host") applyRoot(hostSet.$host);
10514
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
10515
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
10516
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
10517
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
10518
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10519
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10520
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10521
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10670
+ if (stringSelector === "$host") applyRoot(hostSet.$host);
10671
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
10672
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
10673
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
10674
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
10675
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10676
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10677
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10678
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10522
10679
  else {
10523
10680
  if (r === "shadow") {
10524
- const found = inst.shadowRoot?.querySelectorAll(selector);
10681
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
10525
10682
  if (found) results.push(...found);
10526
10683
  } else if (r === "light") {
10527
- const found = inst.querySelectorAll(selector);
10684
+ const found = inst.querySelectorAll(stringSelector);
10528
10685
  if (found) results.push(...found);
10529
10686
  } else if (r === "all") {
10530
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
10531
- const lMatch = inst.querySelectorAll(selector);
10687
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
10688
+ const lMatch = inst.querySelectorAll(stringSelector);
10532
10689
  if (sMatch) results.push(...sMatch);
10533
10690
  if (lMatch) results.push(...lMatch);
10534
10691
  } else {
10535
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
10692
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
10536
10693
  if (found) results.push(...found);
10537
10694
  }
10538
10695
  }
@@ -10671,6 +10828,26 @@ var dooboostoreSimpleWebComponent = (() => {
10671
10828
 
10672
10829
  // src/decorators/applyNode.ts
10673
10830
  var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
10831
+ var resolveSelector = (selector, inst, win) => {
10832
+ if (typeof selector === "function") {
10833
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10834
+ const result = selector(inst, hostSet);
10835
+ if (result instanceof win.Element) {
10836
+ return result;
10837
+ }
10838
+ if (result instanceof win.NodeList) {
10839
+ return result.length > 0 ? result[0] : null;
10840
+ }
10841
+ if (Array.isArray(result)) {
10842
+ return result.length > 0 ? result[0] : null;
10843
+ }
10844
+ if (result === null) {
10845
+ return null;
10846
+ }
10847
+ return result;
10848
+ }
10849
+ return selector;
10850
+ };
10674
10851
  var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
10675
10852
  if (!targetEl) return;
10676
10853
  if (pos === "clearChildren") {
@@ -10681,7 +10858,9 @@ var dooboostoreSimpleWebComponent = (() => {
10681
10858
  const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
10682
10859
  const id = currentThis._swcId;
10683
10860
  const nodes = [];
10684
- if (typeof res === "string" && pos === "innerHtml") {
10861
+ if (res instanceof win.Node) {
10862
+ nodes.push(res);
10863
+ } else if (typeof res === "string" && pos === "innerHtml") {
10685
10864
  const t = win.document.createElement("template");
10686
10865
  t.innerHTML = res;
10687
10866
  nodes.push(...Array.from(t.content.childNodes));
@@ -10715,7 +10894,7 @@ var dooboostoreSimpleWebComponent = (() => {
10715
10894
  function applyNode(selectorOrOptions, maybeOptions) {
10716
10895
  let selector;
10717
10896
  let options;
10718
- if (typeof selectorOrOptions === "string") {
10897
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10719
10898
  selector = selectorOrOptions;
10720
10899
  options = maybeOptions || { position: "replaceChildren" };
10721
10900
  } else {
@@ -10747,14 +10926,22 @@ var dooboostoreSimpleWebComponent = (() => {
10747
10926
  if (r === "all") return t.shadowRoot || t;
10748
10927
  return t;
10749
10928
  };
10750
- if (selector === "$this") return applyRoot(this);
10751
- if (selector === "$host") return applyRoot(hostSet.$host);
10752
- if (selector === "$parentHost") return applyRoot(hostSet.$parentHost);
10753
- if (selector === "$appHost") return applyRoot(hostSet.$appHost);
10754
- if (selector === "$firstHost") return applyRoot(hostSet.$firstHost);
10755
- if (selector === "$lastHost") return applyRoot(hostSet.$lastHost);
10929
+ const resolved = resolveSelector(selector, this, currentWin);
10930
+ if (resolved instanceof currentWin.Element) {
10931
+ return applyRoot(resolved);
10932
+ }
10933
+ if (resolved === null) {
10934
+ return null;
10935
+ }
10936
+ const stringSelector = resolved;
10937
+ if (stringSelector === "$this") return applyRoot(this);
10938
+ if (stringSelector === "$host") return applyRoot(hostSet.$host);
10939
+ if (stringSelector === "$parentHost") return applyRoot(hostSet.$parentHost);
10940
+ if (stringSelector === "$appHost") return applyRoot(hostSet.$appHost);
10941
+ if (stringSelector === "$firstHost") return applyRoot(hostSet.$firstHost);
10942
+ if (stringSelector === "$lastHost") return applyRoot(hostSet.$lastHost);
10756
10943
  const targetRoot = applyRoot(this);
10757
- return targetRoot ? targetRoot.querySelector(selector) : null;
10944
+ return targetRoot ? targetRoot.querySelector(stringSelector) : null;
10758
10945
  };
10759
10946
  const targetEl = getTarget();
10760
10947
  const res = original.apply(this, args);
@@ -10796,7 +10983,7 @@ var dooboostoreSimpleWebComponent = (() => {
10796
10983
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10797
10984
  return applyNode({ position: "replaceChildren" })(selectorOrOptions, maybeOptions, descriptor);
10798
10985
  }
10799
- if (typeof selectorOrOptions === "string") {
10986
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10800
10987
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren" });
10801
10988
  }
10802
10989
  return applyNode({ ...selectorOrOptions, position: "replaceChildren" });
@@ -10805,7 +10992,7 @@ var dooboostoreSimpleWebComponent = (() => {
10805
10992
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10806
10993
  return applyNode({ position: "clearChildren" })(selectorOrOptions, maybeOptions, descriptor);
10807
10994
  }
10808
- if (typeof selectorOrOptions === "string") {
10995
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10809
10996
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren" });
10810
10997
  }
10811
10998
  return applyNode({ ...selectorOrOptions, position: "clearChildren" });
@@ -10815,7 +11002,7 @@ var dooboostoreSimpleWebComponent = (() => {
10815
11002
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10816
11003
  return applyNode({ position: "innerHtml" })(selectorOrOptions, maybeOptions, descriptor);
10817
11004
  }
10818
- if (typeof selectorOrOptions === "string") {
11005
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10819
11006
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml" });
10820
11007
  }
10821
11008
  return applyNode({ ...selectorOrOptions, position: "innerHtml" });
@@ -10824,7 +11011,7 @@ var dooboostoreSimpleWebComponent = (() => {
10824
11011
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10825
11012
  return applyNode({ position: "innerHtml", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10826
11013
  }
10827
- if (typeof selectorOrOptions === "string") {
11014
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10828
11015
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "light" });
10829
11016
  }
10830
11017
  return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "light" });
@@ -10833,7 +11020,7 @@ var dooboostoreSimpleWebComponent = (() => {
10833
11020
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10834
11021
  return applyNode({ position: "innerHtml", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10835
11022
  }
10836
- if (typeof selectorOrOptions === "string") {
11023
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10837
11024
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "shadow" });
10838
11025
  }
10839
11026
  return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "shadow" });
@@ -10842,7 +11029,7 @@ var dooboostoreSimpleWebComponent = (() => {
10842
11029
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10843
11030
  return applyNode({ position: "innerText" })(selectorOrOptions, maybeOptions, descriptor);
10844
11031
  }
10845
- if (typeof selectorOrOptions === "string") {
11032
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10846
11033
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText" });
10847
11034
  }
10848
11035
  return applyNode({ ...selectorOrOptions, position: "innerText" });
@@ -10851,7 +11038,7 @@ var dooboostoreSimpleWebComponent = (() => {
10851
11038
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10852
11039
  return applyNode({ position: "innerText", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10853
11040
  }
10854
- if (typeof selectorOrOptions === "string") {
11041
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10855
11042
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "light" });
10856
11043
  }
10857
11044
  return applyNode({ ...selectorOrOptions, position: "innerText", root: "light" });
@@ -10860,7 +11047,7 @@ var dooboostoreSimpleWebComponent = (() => {
10860
11047
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10861
11048
  return applyNode({ position: "innerText", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10862
11049
  }
10863
- if (typeof selectorOrOptions === "string") {
11050
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10864
11051
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "shadow" });
10865
11052
  }
10866
11053
  return applyNode({ ...selectorOrOptions, position: "innerText", root: "shadow" });
@@ -10869,7 +11056,7 @@ var dooboostoreSimpleWebComponent = (() => {
10869
11056
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10870
11057
  return applyNode({ position: "beforeEnd" })(selectorOrOptions, maybeOptions, descriptor);
10871
11058
  }
10872
- if (typeof selectorOrOptions === "string") {
11059
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10873
11060
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd" });
10874
11061
  }
10875
11062
  return applyNode({ ...selectorOrOptions, position: "beforeEnd" });
@@ -10878,7 +11065,7 @@ var dooboostoreSimpleWebComponent = (() => {
10878
11065
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10879
11066
  return applyNode({ position: "beforeEnd", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10880
11067
  }
10881
- if (typeof selectorOrOptions === "string") {
11068
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10882
11069
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "light" });
10883
11070
  }
10884
11071
  return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "light" });
@@ -10887,7 +11074,7 @@ var dooboostoreSimpleWebComponent = (() => {
10887
11074
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10888
11075
  return applyNode({ position: "beforeEnd", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10889
11076
  }
10890
- if (typeof selectorOrOptions === "string") {
11077
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10891
11078
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "shadow" });
10892
11079
  }
10893
11080
  return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "shadow" });
@@ -10896,7 +11083,7 @@ var dooboostoreSimpleWebComponent = (() => {
10896
11083
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10897
11084
  return applyNode({ position: "afterBegin" })(selectorOrOptions, maybeOptions, descriptor);
10898
11085
  }
10899
- if (typeof selectorOrOptions === "string") {
11086
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10900
11087
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin" });
10901
11088
  }
10902
11089
  return applyNode({ ...selectorOrOptions, position: "afterBegin" });
@@ -10905,7 +11092,7 @@ var dooboostoreSimpleWebComponent = (() => {
10905
11092
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10906
11093
  return applyNode({ position: "afterBegin", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10907
11094
  }
10908
- if (typeof selectorOrOptions === "string") {
11095
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10909
11096
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin", root: "light" });
10910
11097
  }
10911
11098
  return applyNode({ ...selectorOrOptions, position: "afterBegin", root: "light" });
@@ -10914,7 +11101,7 @@ var dooboostoreSimpleWebComponent = (() => {
10914
11101
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10915
11102
  return applyNode({ position: "replaceChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10916
11103
  }
10917
- if (typeof selectorOrOptions === "string") {
11104
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10918
11105
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren", root: "light" });
10919
11106
  }
10920
11107
  return applyNode({ ...selectorOrOptions, position: "replaceChildren", root: "light" });
@@ -10923,7 +11110,7 @@ var dooboostoreSimpleWebComponent = (() => {
10923
11110
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10924
11111
  return applyNode({ position: "clearChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10925
11112
  }
10926
- if (typeof selectorOrOptions === "string") {
11113
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10927
11114
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren", root: "light" });
10928
11115
  }
10929
11116
  return applyNode({ ...selectorOrOptions, position: "clearChildren", root: "light" });
@@ -10941,6 +11128,58 @@ var dooboostoreSimpleWebComponent = (() => {
10941
11128
 
10942
11129
  // src/decorators/applyClass.ts
10943
11130
  var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
11131
+ var resolveSelector2 = (selector, inst, win) => {
11132
+ if (typeof selector === "function") {
11133
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11134
+ const result = selector(inst, hostSet);
11135
+ if (result instanceof win.Element) {
11136
+ return [result];
11137
+ }
11138
+ if (result instanceof win.NodeList) {
11139
+ return Array.from(result);
11140
+ }
11141
+ if (Array.isArray(result)) {
11142
+ return result;
11143
+ }
11144
+ if (result === null) {
11145
+ return [];
11146
+ }
11147
+ return result;
11148
+ }
11149
+ return selector;
11150
+ };
11151
+ var getTargetElements = (selector, inst, win, root) => {
11152
+ const resolved = resolveSelector2(selector, inst, win);
11153
+ if (Array.isArray(resolved)) {
11154
+ return resolved;
11155
+ }
11156
+ const stringSelector = resolved;
11157
+ const targetEls = [];
11158
+ const host = inst;
11159
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11160
+ const applyRoot = (t) => {
11161
+ if (!t || !(t instanceof win.HTMLElement)) return;
11162
+ targetEls.push(t);
11163
+ };
11164
+ if (stringSelector === "$this" || !stringSelector) applyRoot(host);
11165
+ else if (stringSelector === "$host") applyRoot(hostSet.$host);
11166
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
11167
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
11168
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
11169
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
11170
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
11171
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
11172
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
11173
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
11174
+ else {
11175
+ const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
11176
+ if (targetRoot) {
11177
+ const found = targetRoot.querySelectorAll(stringSelector);
11178
+ if (found) targetEls.push(...Array.from(found));
11179
+ }
11180
+ }
11181
+ return targetEls;
11182
+ };
10944
11183
  function createClassDecorator(action) {
10945
11184
  return (selector, classMapOrOptions, options = {}) => {
10946
11185
  return (target, propertyKey, descriptor) => {
@@ -10975,28 +11214,7 @@ var dooboostoreSimpleWebComponent = (() => {
10975
11214
  const host = this;
10976
11215
  const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
10977
11216
  const r = finalOptions.root || "auto";
10978
- const targetEls = [];
10979
- const applyRoot = (t) => {
10980
- if (!t || !(t instanceof win.HTMLElement)) return;
10981
- targetEls.push(t);
10982
- };
10983
- if (selector === "$this" || !selector) applyRoot(host);
10984
- else if (selector === "$host") applyRoot(hostSet.$host);
10985
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
10986
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
10987
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
10988
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
10989
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10990
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10991
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10992
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10993
- else {
10994
- const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
10995
- if (targetRoot) {
10996
- const found = targetRoot.querySelectorAll(selector);
10997
- if (found) targetEls.push(...Array.from(found));
10998
- }
10999
- }
11217
+ const targetEls = getTargetElements(selector, this, win, r);
11000
11218
  targetEls.forEach((targetEl) => {
11001
11219
  if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
11002
11220
  return;
@@ -11128,6 +11346,58 @@ var dooboostoreSimpleWebComponent = (() => {
11128
11346
 
11129
11347
  // src/decorators/applyStyle.ts
11130
11348
  var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
11349
+ var resolveSelector3 = (selector, inst, win) => {
11350
+ if (typeof selector === "function") {
11351
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11352
+ const result = selector(inst, hostSet);
11353
+ if (result instanceof win.Element) {
11354
+ return [result];
11355
+ }
11356
+ if (result instanceof win.NodeList) {
11357
+ return Array.from(result);
11358
+ }
11359
+ if (Array.isArray(result)) {
11360
+ return result;
11361
+ }
11362
+ if (result === null) {
11363
+ return [];
11364
+ }
11365
+ return result;
11366
+ }
11367
+ return selector;
11368
+ };
11369
+ var getTargetElements2 = (selector, inst, win, root) => {
11370
+ const resolved = resolveSelector3(selector, inst, win);
11371
+ if (Array.isArray(resolved)) {
11372
+ return resolved;
11373
+ }
11374
+ const stringSelector = resolved;
11375
+ const targetEls = [];
11376
+ const host = inst;
11377
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11378
+ const applyRoot = (t) => {
11379
+ if (!t || !(t instanceof win.HTMLElement)) return;
11380
+ targetEls.push(t);
11381
+ };
11382
+ if (stringSelector === "$this" || !stringSelector) applyRoot(host);
11383
+ else if (stringSelector === "$host") applyRoot(hostSet.$host);
11384
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
11385
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
11386
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
11387
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
11388
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
11389
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
11390
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
11391
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
11392
+ else {
11393
+ const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
11394
+ if (targetRoot) {
11395
+ const found = targetRoot.querySelectorAll(stringSelector);
11396
+ if (found) targetEls.push(...Array.from(found));
11397
+ }
11398
+ }
11399
+ return targetEls;
11400
+ };
11131
11401
  function createStyleDecorator(action) {
11132
11402
  return (selector, options = {}) => {
11133
11403
  return (target, propertyKey, descriptor) => {
@@ -11155,28 +11425,7 @@ var dooboostoreSimpleWebComponent = (() => {
11155
11425
  const host = this;
11156
11426
  const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
11157
11427
  const r = options.root || "auto";
11158
- const targetEls = [];
11159
- const applyRoot = (t) => {
11160
- if (!t || !(t instanceof win.HTMLElement)) return;
11161
- targetEls.push(t);
11162
- };
11163
- if (selector === "$this" || !selector) applyRoot(host);
11164
- else if (selector === "$host") applyRoot(hostSet.$host);
11165
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
11166
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
11167
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
11168
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
11169
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
11170
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
11171
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
11172
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
11173
- else {
11174
- const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
11175
- if (targetRoot) {
11176
- const found = targetRoot.querySelectorAll(selector);
11177
- if (found) targetEls.push(...Array.from(found));
11178
- }
11179
- }
11428
+ const targetEls = getTargetElements2(selector, this, win, r);
11180
11429
  targetEls.forEach((targetEl) => {
11181
11430
  if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
11182
11431
  return;
@@ -12100,7 +12349,7 @@ var dooboostoreSimpleWebComponent = (() => {
12100
12349
  otherStorage,
12101
12350
  newInstanceCarrier
12102
12351
  });
12103
- const r = ValidUtils.isFunction(target) && !target.prototype ? target(...parameters) : new target(...parameters);
12352
+ const r = ValidUtils.isFunctionType(target) && !target.prototype ? target(...parameters) : new target(...parameters);
12104
12353
  let p = this.proxy(r);
12105
12354
  const config = getSim(target);
12106
12355
  if (config?.proxy) {
@@ -12256,7 +12505,7 @@ var dooboostoreSimpleWebComponent = (() => {
12256
12505
  }
12257
12506
  }
12258
12507
  if (inject.proxy && obj) {
12259
- if (ValidUtils.isConstructor(inject.proxy)) {
12508
+ if (ValidUtils.isClassType(inject.proxy)) {
12260
12509
  const handler = getSim(inject.proxy) ? this.getOrNewSim({ target: inject.proxy }) : new inject.proxy();
12261
12510
  if (handler) {
12262
12511
  obj = new Proxy(obj, handler);
@@ -13835,7 +14084,8 @@ var dooboostoreSimpleWebComponent = (() => {
13835
14084
  }
13836
14085
  }
13837
14086
  } finally {
13838
- if (this.config?.ssr) {
14087
+ const isBrowser = ValidUtils2.isBrowser();
14088
+ if (!isBrowser && this.config?.ssr) {
13839
14089
  setSSRAttribute(instance);
13840
14090
  } else {
13841
14091
  removeSSRAttribute(instance);
@@ -13880,7 +14130,9 @@ var dooboostoreSimpleWebComponent = (() => {
13880
14130
  throw e;
13881
14131
  }
13882
14132
  }
13883
- if (this.config?.ssr) {
14133
+ const isBrowser = ValidUtils2.isBrowser();
14134
+ console.log("------>", isBrowser, this.config?.ssr);
14135
+ if (!isBrowser && this.config?.ssr) {
13884
14136
  setSSRAttribute(instance);
13885
14137
  } else {
13886
14138
  removeSSRAttribute(instance);