@dooboostore/simple-web-component 1.0.42 → 1.0.44
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.
- package/README.md +689 -85
- package/dist/cjs/SwcAppEngine.js +3 -1
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +10 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +41 -30
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +66 -23
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +176 -107
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +21 -30
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +11 -2
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +48 -17
- package/dist/cjs/decorators/applyStyle.js.map +3 -3
- package/dist/cjs/decorators/{changedAttributeThis.js → changedAttribute.js} +6 -6
- package/dist/cjs/decorators/changedAttribute.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +37 -6
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +58 -42
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +1 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/cjs/decorators/query.js +96 -145
- package/dist/cjs/decorators/query.js.map +3 -3
- package/dist/cjs/decorators/queryAll.js +104 -131
- package/dist/cjs/decorators/queryAll.js.map +3 -3
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +17 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -0
- package/dist/cjs/router/ElementRouter.js.map +2 -2
- package/dist/esm/SwcAppEngine.js +3 -1
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +10 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +41 -30
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +66 -23
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +176 -107
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +21 -30
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +11 -2
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +48 -17
- package/dist/esm/decorators/applyStyle.js.map +3 -3
- package/dist/esm/decorators/{changedAttributeThis.js → changedAttribute.js} +3 -3
- package/dist/esm/decorators/changedAttribute.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +35 -4
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +58 -42
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -1
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
- package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/esm/decorators/query.js +96 -145
- package/dist/esm/decorators/query.js.map +3 -3
- package/dist/esm/decorators/queryAll.js +104 -131
- package/dist/esm/decorators/queryAll.js.map +3 -3
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +18 -3
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
- package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +4 -0
- package/dist/esm/router/ElementRouter.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +900 -578
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +22 -14
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +61 -20
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +22 -36
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +178 -30
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +53 -18
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +6 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +13 -7
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/{changedAttributeThis.d.ts → changedAttribute.d.ts} +2 -2
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +20 -10
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +3 -26
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +3 -20
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +4 -4
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/router/ElementRouter.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +900 -578
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +7 -9
- package/src/SwcAppEngine.ts +3 -1
- package/src/decorators/addEventListener.ts +35 -24
- package/src/decorators/applyAttribute.ts +167 -65
- package/src/decorators/applyClass.ts +113 -17
- package/src/decorators/applyNode.ts +383 -102
- package/src/decorators/applyProperty.ts +99 -65
- package/src/decorators/applySlot.ts +24 -10
- package/src/decorators/applyStyle.ts +83 -13
- package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
- package/src/decorators/elementDefine.ts +47 -4
- package/src/decorators/emitCustomEvent.ts +62 -35
- package/src/decorators/index.ts +1 -1
- package/src/decorators/publishSwcAppMessage.ts +71 -27
- package/src/decorators/query.ts +90 -159
- package/src/decorators/queryAll.ts +92 -134
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +3 -1
- package/src/elements/SwcAppMixin.ts +43 -24
- package/src/examples/RxJSOperatorsExample.ts +279 -0
- package/src/index.ts +2 -0
- package/src/router/ElementRouter.ts +4 -0
- package/dist/cjs/decorators/changedAttributeThis.js.map +0 -7
- package/dist/esm/decorators/changedAttributeThis.js.map +0 -7
- package/dist/types/decorators/changedAttributeThis.d.ts.map +0 -1
|
@@ -6320,6 +6320,11 @@ function addEventListenerDelegateAllDom(selector, type, options) {
|
|
|
6320
6320
|
function addEventListenerDelegate(selector, type, options) {
|
|
6321
6321
|
return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
|
|
6322
6322
|
}
|
|
6323
|
+
var event = addEventListener;
|
|
6324
|
+
var eventDelegateLightDom = addEventListenerDelegateLightDom;
|
|
6325
|
+
var eventDelegateShadowDom = addEventListenerDelegateShadowDom;
|
|
6326
|
+
var eventDelegateAllDom = addEventListenerDelegateAllDom;
|
|
6327
|
+
var eventDelegate = addEventListenerDelegate;
|
|
6323
6328
|
function addEventListenerThis(type, options) {
|
|
6324
6329
|
return addEventListener("$this", type, options);
|
|
6325
6330
|
}
|
|
@@ -6337,6 +6342,155 @@ var getAddEventListenerMetadata = (target) => {
|
|
|
6337
6342
|
return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
|
|
6338
6343
|
};
|
|
6339
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
|
+
|
|
6340
6494
|
// src/decorators/lifecycles.ts
|
|
6341
6495
|
var ON_INITIALIZE_METADATA_KEY = Symbol.for("simple-web-component:on-constructor");
|
|
6342
6496
|
var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-connected");
|
|
@@ -6841,7 +6995,7 @@ var ElementApply = class _ElementApply {
|
|
|
6841
6995
|
if (!config?.targetVariableName || config?.targetVariableName && tit.variables.find((v) => v === config?.targetVariableName)) {
|
|
6842
6996
|
const data = new Function("ctx", `
|
|
6843
6997
|
with(ctx) {
|
|
6844
|
-
return function(){
|
|
6998
|
+
return function(event){
|
|
6845
6999
|
return (${this.stripWrap(tit.script)});
|
|
6846
7000
|
}
|
|
6847
7001
|
}
|
|
@@ -7494,7 +7648,7 @@ var DocumentUtils;
|
|
|
7494
7648
|
};
|
|
7495
7649
|
DocumentUtils2.eventObservable = (document2, type, options) => {
|
|
7496
7650
|
return new Observable((subscriber) => {
|
|
7497
|
-
const handler = (
|
|
7651
|
+
const handler = (event2) => subscriber.next(event2);
|
|
7498
7652
|
window.addEventListener(type, handler, options);
|
|
7499
7653
|
return () => {
|
|
7500
7654
|
window.removeEventListener(type, handler, options);
|
|
@@ -7508,7 +7662,7 @@ var EventUtils;
|
|
|
7508
7662
|
((EventUtils2) => {
|
|
7509
7663
|
EventUtils2.htmlElementEventObservable = (element, type, options) => {
|
|
7510
7664
|
return new Observable((subscriber) => {
|
|
7511
|
-
const handler = (
|
|
7665
|
+
const handler = (event2) => subscriber.next(event2);
|
|
7512
7666
|
element.addEventListener(type, handler, options);
|
|
7513
7667
|
return () => {
|
|
7514
7668
|
element.removeEventListener(type, handler, options);
|
|
@@ -7522,7 +7676,7 @@ var WindowUtils;
|
|
|
7522
7676
|
((WindowUtils2) => {
|
|
7523
7677
|
WindowUtils2.eventObservable = (window2, type, options) => {
|
|
7524
7678
|
return new Observable((subscriber) => {
|
|
7525
|
-
const handler = (
|
|
7679
|
+
const handler = (event2) => subscriber.next(event2);
|
|
7526
7680
|
window2.addEventListener(type, handler, options);
|
|
7527
7681
|
return () => {
|
|
7528
7682
|
window2.removeEventListener(type, handler, options);
|
|
@@ -7899,7 +8053,7 @@ var Router = class {
|
|
|
7899
8053
|
routeData = { ...this.getRouteData(), triggerPoint: "first-end" };
|
|
7900
8054
|
this.behaviorSubject = new BehaviorSubject(routeData);
|
|
7901
8055
|
}
|
|
7902
|
-
this.config.window.addEventListener("popstate", (
|
|
8056
|
+
this.config.window.addEventListener("popstate", (event2) => {
|
|
7903
8057
|
const routeData2 = { ...this.getRouteData(), triggerPoint: "end" };
|
|
7904
8058
|
this.behaviorSubject.next(routeData2);
|
|
7905
8059
|
});
|
|
@@ -8291,7 +8445,7 @@ var AnimationFrameUtils;
|
|
|
8291
8445
|
divideSize
|
|
8292
8446
|
}) => {
|
|
8293
8447
|
return new Observable((subscriber) => {
|
|
8294
|
-
const handler = (
|
|
8448
|
+
const handler = (event2) => subscriber.next(event2);
|
|
8295
8449
|
let fps2 = 0;
|
|
8296
8450
|
const getDrawFpsGap = () => {
|
|
8297
8451
|
return Math.floor(fps2 / divideSize);
|
|
@@ -8795,24 +8949,38 @@ var SwcUtils;
|
|
|
8795
8949
|
|
|
8796
8950
|
// src/decorators/emitCustomEvent.ts
|
|
8797
8951
|
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for("simple-web-component:emit-custom-event");
|
|
8798
|
-
function emitCustomEvent(selectorOrTarget,
|
|
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 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) {
|
|
8799
8965
|
return (targetObj, propertyKey, descriptor) => {
|
|
8800
8966
|
const constructor = targetObj.constructor;
|
|
8801
|
-
const fullOptions = { ...options, type };
|
|
8802
|
-
if (fullOptions.bubbles === void 0)
|
|
8803
|
-
|
|
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;
|
|
8804
8972
|
let list = ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
8805
8973
|
if (!list) {
|
|
8806
8974
|
list = [];
|
|
8807
8975
|
ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
|
|
8808
8976
|
}
|
|
8809
|
-
list.push({ propertyKey, selector
|
|
8977
|
+
list.push({ propertyKey, selector, type, options: fullOptions });
|
|
8810
8978
|
const original = descriptor.value;
|
|
8811
8979
|
descriptor.value = function(...args) {
|
|
8812
8980
|
ensureInit(this);
|
|
8813
8981
|
const res = original.apply(this, args);
|
|
8814
8982
|
const handleResult = (detail) => {
|
|
8815
|
-
const
|
|
8983
|
+
const event2 = new CustomEvent(type, {
|
|
8816
8984
|
detail,
|
|
8817
8985
|
bubbles: fullOptions.bubbles,
|
|
8818
8986
|
composed: fullOptions.composed,
|
|
@@ -8822,47 +8990,60 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
|
8822
8990
|
const conf = getElementConfig(this);
|
|
8823
8991
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8824
8992
|
const eventTargets = [];
|
|
8825
|
-
if (
|
|
8826
|
-
|
|
8827
|
-
else if (
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
if (hostSet.$
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
} else if (
|
|
8836
|
-
if (hostSet.$
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
} else if (
|
|
8993
|
+
if (selector === "$window")
|
|
8994
|
+
eventTargets.push(currentWin);
|
|
8995
|
+
else if (selector === "$document")
|
|
8996
|
+
eventTargets.push(currentWin.document);
|
|
8997
|
+
else if (selector === "$host") {
|
|
8998
|
+
if (hostSet.$host)
|
|
8999
|
+
eventTargets.push(hostSet.$host);
|
|
9000
|
+
} else if (selector === "$parentHost") {
|
|
9001
|
+
if (hostSet.$parentHost)
|
|
9002
|
+
eventTargets.push(hostSet.$parentHost);
|
|
9003
|
+
} else if (selector === "$appHost") {
|
|
9004
|
+
if (hostSet.$appHost)
|
|
9005
|
+
eventTargets.push(hostSet.$appHost);
|
|
9006
|
+
} else if (selector === "$firstHost") {
|
|
9007
|
+
if (hostSet.$firstHost)
|
|
9008
|
+
eventTargets.push(hostSet.$firstHost);
|
|
9009
|
+
} else if (selector === "$lastHost") {
|
|
9010
|
+
if (hostSet.$lastHost)
|
|
9011
|
+
eventTargets.push(hostSet.$lastHost);
|
|
9012
|
+
} else if (selector === "$firstAppHost") {
|
|
9013
|
+
if (hostSet.$firstAppHost)
|
|
9014
|
+
eventTargets.push(hostSet.$firstAppHost);
|
|
9015
|
+
} else if (selector === "$lastAppHost") {
|
|
9016
|
+
if (hostSet.$lastAppHost)
|
|
9017
|
+
eventTargets.push(hostSet.$lastAppHost);
|
|
9018
|
+
} else if (selector === "$hosts") {
|
|
8842
9019
|
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
8843
|
-
} else if (
|
|
9020
|
+
} else if (selector === "$appHosts") {
|
|
8844
9021
|
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
8845
|
-
} else if (
|
|
9022
|
+
} else if (selector === "$this" || !selector) {
|
|
8846
9023
|
eventTargets.push(this);
|
|
8847
9024
|
} else {
|
|
8848
9025
|
const r = fullOptions.root || "auto";
|
|
8849
9026
|
const searchRoots = [];
|
|
8850
|
-
if (r === "auto")
|
|
8851
|
-
|
|
8852
|
-
else if (r === "
|
|
9027
|
+
if (r === "auto")
|
|
9028
|
+
searchRoots.push(this.shadowRoot || this);
|
|
9029
|
+
else if (r === "light")
|
|
9030
|
+
searchRoots.push(this);
|
|
9031
|
+
else if (r === "shadow" && this.shadowRoot)
|
|
9032
|
+
searchRoots.push(this.shadowRoot);
|
|
8853
9033
|
else if (r === "all") {
|
|
8854
9034
|
searchRoots.push(this);
|
|
8855
|
-
if (this.shadowRoot)
|
|
9035
|
+
if (this.shadowRoot)
|
|
9036
|
+
searchRoots.push(this.shadowRoot);
|
|
8856
9037
|
}
|
|
8857
9038
|
searchRoots.forEach((sr) => {
|
|
8858
|
-
sr.querySelectorAll(
|
|
9039
|
+
sr.querySelectorAll(selector).forEach((el) => eventTargets.push(el));
|
|
8859
9040
|
});
|
|
8860
9041
|
}
|
|
8861
9042
|
eventTargets.forEach((t) => {
|
|
8862
9043
|
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
8863
9044
|
return;
|
|
8864
9045
|
}
|
|
8865
|
-
t.dispatchEvent(
|
|
9046
|
+
t.dispatchEvent(event2);
|
|
8866
9047
|
});
|
|
8867
9048
|
return detail;
|
|
8868
9049
|
};
|
|
@@ -8878,20 +9059,9 @@ var getEmitCustomEventMetadataList = (target) => {
|
|
|
8878
9059
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
8879
9060
|
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
8880
9061
|
};
|
|
8881
|
-
|
|
8882
|
-
if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
|
|
8883
|
-
return emitCustomEventThis(type, { attributeName: optionsOrAttributeaName });
|
|
8884
|
-
} else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "object") {
|
|
8885
|
-
if (!optionsOrAttributeaName.attributeName) {
|
|
8886
|
-
optionsOrAttributeaName.attributeName = `on-emit-${type}`;
|
|
8887
|
-
}
|
|
8888
|
-
return emitCustomEvent("$this", type, optionsOrAttributeaName);
|
|
8889
|
-
} else {
|
|
8890
|
-
return emitCustomEvent("$this", type, { attributeName: `on-emit-${type}` });
|
|
8891
|
-
}
|
|
8892
|
-
}
|
|
9062
|
+
var emit = emitCustomEvent;
|
|
8893
9063
|
|
|
8894
|
-
// src/decorators/
|
|
9064
|
+
// src/decorators/changedAttribute.ts
|
|
8895
9065
|
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
8896
9066
|
var convertValue = (val, type) => {
|
|
8897
9067
|
if (val === null || val === void 0) return val;
|
|
@@ -8899,7 +9069,7 @@ var convertValue = (val, type) => {
|
|
|
8899
9069
|
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
8900
9070
|
return val;
|
|
8901
9071
|
};
|
|
8902
|
-
function
|
|
9072
|
+
function changedAttribute(attributeName, options = {}) {
|
|
8903
9073
|
return (target, propertyKey) => {
|
|
8904
9074
|
const constructor = target.constructor;
|
|
8905
9075
|
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
@@ -8939,150 +9109,106 @@ var convertAttributeValue = (val, type) => {
|
|
|
8939
9109
|
|
|
8940
9110
|
// src/decorators/query.ts
|
|
8941
9111
|
var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
8942
|
-
function query(selectorOrTarget,
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
9112
|
+
function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
9113
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
9114
|
+
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
9115
|
+
}
|
|
9116
|
+
if (typeof selectorOrTarget === "string") {
|
|
9117
|
+
return (targetObj, propertyKey, descriptor2) => {
|
|
9118
|
+
if (descriptor2 !== void 0) {
|
|
9119
|
+
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
9120
|
+
}
|
|
9121
|
+
const constructor = targetObj.constructor;
|
|
9122
|
+
let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
9123
|
+
if (!queries) {
|
|
9124
|
+
queries = [];
|
|
9125
|
+
ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
|
|
9126
|
+
}
|
|
9127
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
|
|
9128
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
9129
|
+
get() {
|
|
9130
|
+
ensureInit(this);
|
|
9131
|
+
const selector = selectorOrTarget;
|
|
9132
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9133
|
+
const applyRoot = (t) => {
|
|
9134
|
+
if (!t || !(t instanceof HTMLElement))
|
|
9135
|
+
return t;
|
|
9136
|
+
if (r === "auto")
|
|
9137
|
+
return t.shadowRoot || t;
|
|
9138
|
+
if (r === "shadow")
|
|
9139
|
+
return t.shadowRoot;
|
|
9140
|
+
if (r === "light")
|
|
9141
|
+
return t;
|
|
9142
|
+
if (r === "all")
|
|
9143
|
+
return t.shadowRoot || t;
|
|
8961
9144
|
return t;
|
|
8962
|
-
|
|
8963
|
-
|
|
9145
|
+
};
|
|
9146
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
9147
|
+
if (selector === "$this")
|
|
9148
|
+
return applyRoot(this);
|
|
9149
|
+
if (selector === "$host")
|
|
9150
|
+
return applyRoot(hostSet.$host);
|
|
9151
|
+
if (selector === "$parentHost")
|
|
9152
|
+
return applyRoot(hostSet.$parentHost);
|
|
9153
|
+
if (selector === "$appHost")
|
|
9154
|
+
return applyRoot(hostSet.$appHost);
|
|
9155
|
+
if (selector === "$firstHost")
|
|
9156
|
+
return applyRoot(hostSet.$firstHost);
|
|
9157
|
+
if (selector === "$lastHost")
|
|
9158
|
+
return applyRoot(hostSet.$lastHost);
|
|
9159
|
+
if (selector === "$firstAppHost")
|
|
9160
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
9161
|
+
if (selector === "$lastAppHost")
|
|
9162
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
9163
|
+
const config = getElementConfig(this);
|
|
9164
|
+
const win = config?.window || window;
|
|
9165
|
+
if (selector === "$window")
|
|
9166
|
+
return win;
|
|
9167
|
+
if (selector === "$document")
|
|
9168
|
+
return win.document;
|
|
8964
9169
|
if (r === "shadow")
|
|
8965
|
-
return
|
|
9170
|
+
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
8966
9171
|
if (r === "light")
|
|
8967
|
-
return
|
|
8968
|
-
if (r === "all")
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
};
|
|
8972
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
8973
|
-
if (selector === "$this")
|
|
8974
|
-
return applyRoot(this);
|
|
8975
|
-
if (selector === "$host")
|
|
8976
|
-
return applyRoot(hostSet.$host);
|
|
8977
|
-
if (selector === "$parentHost")
|
|
8978
|
-
return applyRoot(hostSet.$parentHost);
|
|
8979
|
-
if (selector === "$appHost")
|
|
8980
|
-
return applyRoot(hostSet.$appHost);
|
|
8981
|
-
if (selector === "$firstHost")
|
|
8982
|
-
return applyRoot(hostSet.$firstHost);
|
|
8983
|
-
if (selector === "$lastHost")
|
|
8984
|
-
return applyRoot(hostSet.$lastHost);
|
|
8985
|
-
if (selector === "$firstAppHost")
|
|
8986
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
8987
|
-
if (selector === "$lastAppHost")
|
|
8988
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
8989
|
-
const config = getElementConfig(this);
|
|
8990
|
-
const win = config?.window || window;
|
|
8991
|
-
if (selector === "$window")
|
|
8992
|
-
return win;
|
|
8993
|
-
if (selector === "$document")
|
|
8994
|
-
return win.document;
|
|
8995
|
-
if (r === "shadow")
|
|
8996
|
-
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
8997
|
-
if (r === "light")
|
|
8998
|
-
return this.querySelector(selector);
|
|
8999
|
-
if (r === "all") {
|
|
9000
|
-
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
9001
|
-
return shadowMatch || this.querySelector(selector);
|
|
9002
|
-
}
|
|
9003
|
-
return (this.shadowRoot || this).querySelector(selector);
|
|
9004
|
-
},
|
|
9005
|
-
set(nv) {
|
|
9006
|
-
ensureInit(this);
|
|
9007
|
-
if (nv === null || nv === void 0) {
|
|
9008
|
-
const selector = selectorOrTarget;
|
|
9009
|
-
if (selector.startsWith("$") && selector !== "$this")
|
|
9010
|
-
return;
|
|
9011
|
-
const r = options.root || "auto";
|
|
9012
|
-
const targets = [];
|
|
9013
|
-
if (r === "shadow") {
|
|
9014
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
9015
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
9016
|
-
} else if (r === "light") {
|
|
9017
|
-
if (this.querySelector(selector))
|
|
9018
|
-
targets.push(this.querySelector(selector));
|
|
9019
|
-
} else if (r === "all") {
|
|
9020
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
9021
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
9022
|
-
if (this.querySelector(selector))
|
|
9023
|
-
targets.push(this.querySelector(selector));
|
|
9024
|
-
} else {
|
|
9025
|
-
const el = (this.shadowRoot || this).querySelector(selector);
|
|
9026
|
-
if (el)
|
|
9027
|
-
targets.push(el);
|
|
9172
|
+
return this.querySelector(selector);
|
|
9173
|
+
if (r === "all") {
|
|
9174
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
9175
|
+
return shadowMatch || this.querySelector(selector);
|
|
9028
9176
|
}
|
|
9029
|
-
|
|
9030
|
-
}
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
}
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
return query("$document", targetOrOptions);
|
|
9063
|
-
} else {
|
|
9064
|
-
return query("$document", {});
|
|
9065
|
-
}
|
|
9066
|
-
}
|
|
9067
|
-
function queryHost(targetOrOptions, propertyKey) {
|
|
9068
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
9069
|
-
return query("$host", {})(targetOrOptions, propertyKey);
|
|
9070
|
-
}
|
|
9071
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
9072
|
-
return query("$host", targetOrOptions);
|
|
9073
|
-
} else {
|
|
9074
|
-
return query("$host", {});
|
|
9075
|
-
}
|
|
9076
|
-
}
|
|
9077
|
-
function queryAppHost(targetOrOptions, propertyKey) {
|
|
9078
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
9079
|
-
return query("$appHost", {})(targetOrOptions, propertyKey);
|
|
9080
|
-
}
|
|
9081
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
9082
|
-
return query("$appHost", targetOrOptions);
|
|
9083
|
-
} else {
|
|
9084
|
-
return query("$appHost", {});
|
|
9177
|
+
return (this.shadowRoot || this).querySelector(selector);
|
|
9178
|
+
},
|
|
9179
|
+
set(nv) {
|
|
9180
|
+
ensureInit(this);
|
|
9181
|
+
if (nv === null || nv === void 0) {
|
|
9182
|
+
const selector = selectorOrTarget;
|
|
9183
|
+
if (selector.startsWith("$") && selector !== "$this")
|
|
9184
|
+
return;
|
|
9185
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9186
|
+
const targets = [];
|
|
9187
|
+
if (r === "shadow") {
|
|
9188
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
9189
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
9190
|
+
} else if (r === "light") {
|
|
9191
|
+
if (this.querySelector(selector))
|
|
9192
|
+
targets.push(this.querySelector(selector));
|
|
9193
|
+
} else if (r === "all") {
|
|
9194
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
9195
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
9196
|
+
if (this.querySelector(selector))
|
|
9197
|
+
targets.push(this.querySelector(selector));
|
|
9198
|
+
} else {
|
|
9199
|
+
const el = (this.shadowRoot || this).querySelector(selector);
|
|
9200
|
+
if (el)
|
|
9201
|
+
targets.push(el);
|
|
9202
|
+
}
|
|
9203
|
+
targets.forEach((t) => t.remove());
|
|
9204
|
+
}
|
|
9205
|
+
},
|
|
9206
|
+
enumerable: true,
|
|
9207
|
+
configurable: true
|
|
9208
|
+
});
|
|
9209
|
+
};
|
|
9085
9210
|
}
|
|
9211
|
+
return query("$this", selectorOrTarget);
|
|
9086
9212
|
}
|
|
9087
9213
|
var getQueryMetadata = (target) => {
|
|
9088
9214
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
@@ -9091,139 +9217,115 @@ var getQueryMetadata = (target) => {
|
|
|
9091
9217
|
|
|
9092
9218
|
// src/decorators/queryAll.ts
|
|
9093
9219
|
var QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
|
|
9094
|
-
function queryAll(selectorOrTarget,
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
return [];
|
|
9114
|
-
const items = Array.isArray(t) ? t : [t];
|
|
9115
|
-
const results = [];
|
|
9116
|
-
items.forEach((it) => {
|
|
9117
|
-
if (!(it instanceof HTMLElement)) {
|
|
9118
|
-
results.push(it);
|
|
9119
|
-
return;
|
|
9120
|
-
}
|
|
9121
|
-
if (r === "auto")
|
|
9122
|
-
results.push(it.shadowRoot || it);
|
|
9123
|
-
else {
|
|
9124
|
-
if (r === "light" || r === "all")
|
|
9125
|
-
results.push(it);
|
|
9126
|
-
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
9127
|
-
results.push(it.shadowRoot);
|
|
9128
|
-
}
|
|
9129
|
-
});
|
|
9130
|
-
return results;
|
|
9131
|
-
};
|
|
9132
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
9133
|
-
if (selector === "$hosts")
|
|
9134
|
-
return applyRoot(hostSet.$hosts);
|
|
9135
|
-
if (selector === "$appHosts")
|
|
9136
|
-
return applyRoot(hostSet.$appHosts);
|
|
9137
|
-
if (selector === "$host")
|
|
9138
|
-
return applyRoot(hostSet.$host);
|
|
9139
|
-
if (selector === "$parentHost")
|
|
9140
|
-
return applyRoot(hostSet.$parentHost);
|
|
9141
|
-
if (selector === "$appHost")
|
|
9142
|
-
return applyRoot(hostSet.$appHost);
|
|
9143
|
-
if (selector === "$firstHost")
|
|
9144
|
-
return applyRoot(hostSet.$firstHost);
|
|
9145
|
-
if (selector === "$lastHost")
|
|
9146
|
-
return applyRoot(hostSet.$lastHost);
|
|
9147
|
-
if (selector === "$firstAppHost")
|
|
9148
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
9149
|
-
if (selector === "$lastAppHost")
|
|
9150
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
9151
|
-
const config = getElementConfig(this);
|
|
9152
|
-
const win = config?.window || window;
|
|
9153
|
-
if (selector === "$window")
|
|
9154
|
-
return [win];
|
|
9155
|
-
if (selector === "$document")
|
|
9156
|
-
return [win.document];
|
|
9157
|
-
if (selector === "$this")
|
|
9158
|
-
return applyRoot(this);
|
|
9159
|
-
if (r === "shadow")
|
|
9160
|
-
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
9161
|
-
if (r === "light")
|
|
9162
|
-
return Array.from(this.querySelectorAll(selector));
|
|
9163
|
-
if (r === "all") {
|
|
9164
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
9165
|
-
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
9166
|
-
return [...sNodes, ...lNodes];
|
|
9167
|
-
}
|
|
9168
|
-
const root = this.shadowRoot || this;
|
|
9169
|
-
return Array.from(root.querySelectorAll(selector));
|
|
9170
|
-
},
|
|
9171
|
-
set(nv) {
|
|
9172
|
-
ensureInit(this);
|
|
9173
|
-
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
9220
|
+
function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
9221
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
9222
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
9223
|
+
}
|
|
9224
|
+
if (typeof selectorOrTarget === "string") {
|
|
9225
|
+
return (targetObj, propertyKey, descriptor2) => {
|
|
9226
|
+
if (descriptor2 !== void 0) {
|
|
9227
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
9228
|
+
}
|
|
9229
|
+
const constructor = targetObj.constructor;
|
|
9230
|
+
let queries = ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
9231
|
+
if (!queries) {
|
|
9232
|
+
queries = [];
|
|
9233
|
+
ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
9234
|
+
}
|
|
9235
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
|
|
9236
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
9237
|
+
get() {
|
|
9238
|
+
ensureInit(this);
|
|
9174
9239
|
const selector = selectorOrTarget;
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9240
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9241
|
+
const applyRoot = (t) => {
|
|
9242
|
+
if (!t)
|
|
9243
|
+
return [];
|
|
9244
|
+
const items = Array.isArray(t) ? t : [t];
|
|
9245
|
+
const results = [];
|
|
9246
|
+
items.forEach((it) => {
|
|
9247
|
+
if (!(it instanceof HTMLElement)) {
|
|
9248
|
+
results.push(it);
|
|
9249
|
+
return;
|
|
9250
|
+
}
|
|
9251
|
+
if (r === "auto")
|
|
9252
|
+
results.push(it.shadowRoot || it);
|
|
9253
|
+
else {
|
|
9254
|
+
if (r === "light" || r === "all")
|
|
9255
|
+
results.push(it);
|
|
9256
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
9257
|
+
results.push(it.shadowRoot);
|
|
9258
|
+
}
|
|
9259
|
+
});
|
|
9260
|
+
return results;
|
|
9261
|
+
};
|
|
9262
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
9263
|
+
if (selector === "$hosts")
|
|
9264
|
+
return applyRoot(hostSet.$hosts);
|
|
9265
|
+
if (selector === "$appHosts")
|
|
9266
|
+
return applyRoot(hostSet.$appHosts);
|
|
9267
|
+
if (selector === "$host")
|
|
9268
|
+
return applyRoot(hostSet.$host);
|
|
9269
|
+
if (selector === "$parentHost")
|
|
9270
|
+
return applyRoot(hostSet.$parentHost);
|
|
9271
|
+
if (selector === "$appHost")
|
|
9272
|
+
return applyRoot(hostSet.$appHost);
|
|
9273
|
+
if (selector === "$firstHost")
|
|
9274
|
+
return applyRoot(hostSet.$firstHost);
|
|
9275
|
+
if (selector === "$lastHost")
|
|
9276
|
+
return applyRoot(hostSet.$lastHost);
|
|
9277
|
+
if (selector === "$firstAppHost")
|
|
9278
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
9279
|
+
if (selector === "$lastAppHost")
|
|
9280
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
9281
|
+
const config = getElementConfig(this);
|
|
9282
|
+
const win = config?.window || window;
|
|
9283
|
+
if (selector === "$window")
|
|
9284
|
+
return [win];
|
|
9285
|
+
if (selector === "$document")
|
|
9286
|
+
return [win.document];
|
|
9287
|
+
if (selector === "$this")
|
|
9288
|
+
return applyRoot(this);
|
|
9179
9289
|
if (r === "shadow")
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9290
|
+
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
9291
|
+
if (r === "light")
|
|
9292
|
+
return Array.from(this.querySelectorAll(selector));
|
|
9293
|
+
if (r === "all") {
|
|
9184
9294
|
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
9185
9295
|
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
9186
|
-
|
|
9187
|
-
} else {
|
|
9188
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
9296
|
+
return [...sNodes, ...lNodes];
|
|
9189
9297
|
}
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
}
|
|
9218
|
-
|
|
9219
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
9220
|
-
return queryAll("$appHost", {})(targetOrOptions, propertyKey);
|
|
9221
|
-
}
|
|
9222
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
9223
|
-
return queryAll("$appHost", targetOrOptions);
|
|
9224
|
-
} else {
|
|
9225
|
-
return queryAll("$appHost", {});
|
|
9298
|
+
const root = this.shadowRoot || this;
|
|
9299
|
+
return Array.from(root.querySelectorAll(selector));
|
|
9300
|
+
},
|
|
9301
|
+
set(nv) {
|
|
9302
|
+
ensureInit(this);
|
|
9303
|
+
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
9304
|
+
const selector = selectorOrTarget;
|
|
9305
|
+
if (selector.startsWith("$") && selector !== "$this")
|
|
9306
|
+
return;
|
|
9307
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9308
|
+
let targets = [];
|
|
9309
|
+
if (r === "shadow")
|
|
9310
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
9311
|
+
else if (r === "light")
|
|
9312
|
+
targets = Array.from(this.querySelectorAll(selector));
|
|
9313
|
+
else if (r === "all") {
|
|
9314
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
9315
|
+
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
9316
|
+
targets = [...sNodes, ...lNodes];
|
|
9317
|
+
} else {
|
|
9318
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
9319
|
+
}
|
|
9320
|
+
targets.forEach((t) => t.remove());
|
|
9321
|
+
}
|
|
9322
|
+
},
|
|
9323
|
+
enumerable: true,
|
|
9324
|
+
configurable: true
|
|
9325
|
+
});
|
|
9326
|
+
};
|
|
9226
9327
|
}
|
|
9328
|
+
return queryAll("$this", selectorOrTarget);
|
|
9227
9329
|
}
|
|
9228
9330
|
var getQueryAllMetadata = (target) => {
|
|
9229
9331
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
@@ -9506,13 +9608,21 @@ function applyProperty(selector, targetPropertyKeyOrOptions, options) {
|
|
|
9506
9608
|
descriptor.value = function(...args) {
|
|
9507
9609
|
ensureInit(this);
|
|
9508
9610
|
const res = original.apply(this, args);
|
|
9611
|
+
const extractValue = (v) => {
|
|
9612
|
+
if (v && typeof v === "object" && PROPERTY_METADATA_KEY in v) {
|
|
9613
|
+
return v[PROPERTY_METADATA_KEY];
|
|
9614
|
+
}
|
|
9615
|
+
return v;
|
|
9616
|
+
};
|
|
9509
9617
|
if (res instanceof Promise) {
|
|
9510
9618
|
return res.then((v) => {
|
|
9511
|
-
|
|
9619
|
+
const extracted = extractValue(v);
|
|
9620
|
+
applyValueToTargets(this, extracted);
|
|
9512
9621
|
return v;
|
|
9513
9622
|
});
|
|
9514
9623
|
} else {
|
|
9515
|
-
|
|
9624
|
+
const extracted = extractValue(res);
|
|
9625
|
+
applyValueToTargets(this, extracted);
|
|
9516
9626
|
return res;
|
|
9517
9627
|
}
|
|
9518
9628
|
};
|
|
@@ -9543,35 +9653,20 @@ function applyProperty(selector, targetPropertyKeyOrOptions, options) {
|
|
|
9543
9653
|
});
|
|
9544
9654
|
};
|
|
9545
9655
|
}
|
|
9546
|
-
function property(
|
|
9547
|
-
|
|
9548
|
-
}
|
|
9549
|
-
function propertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
|
|
9550
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
9551
|
-
return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
|
|
9656
|
+
function property(selectorOrTarget, targetPropertyKeyOrOptions, optionsOrDescriptor) {
|
|
9657
|
+
if (optionsOrDescriptor !== void 0 && (typeof targetPropertyKeyOrOptions === "string" || typeof targetPropertyKeyOrOptions === "symbol")) {
|
|
9658
|
+
return applyProperty("$this", void 0, {})(selectorOrTarget, targetPropertyKeyOrOptions, optionsOrDescriptor);
|
|
9552
9659
|
}
|
|
9553
|
-
if (typeof
|
|
9554
|
-
return applyProperty(
|
|
9555
|
-
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
9556
|
-
return applyProperty("$this", void 0, targetOrOptions);
|
|
9557
|
-
} else {
|
|
9558
|
-
return applyProperty("$this", void 0, {});
|
|
9660
|
+
if (typeof selectorOrTarget === "string") {
|
|
9661
|
+
return applyProperty(selectorOrTarget, targetPropertyKeyOrOptions, optionsOrDescriptor);
|
|
9559
9662
|
}
|
|
9663
|
+
return applyProperty("$this", void 0, selectorOrTarget);
|
|
9560
9664
|
}
|
|
9561
|
-
function setProperty(
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
function setPropertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
|
|
9565
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
9566
|
-
return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
|
|
9567
|
-
}
|
|
9568
|
-
if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
|
|
9569
|
-
return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
|
|
9570
|
-
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
9571
|
-
return applyProperty("$this", void 0, targetOrOptions);
|
|
9572
|
-
} else {
|
|
9573
|
-
return applyProperty("$this", void 0, {});
|
|
9665
|
+
function setProperty(selectorOrOptions, targetPropertyKeyOrOptions, optionsOrUndefined) {
|
|
9666
|
+
if (typeof selectorOrOptions === "string") {
|
|
9667
|
+
return applyProperty(selectorOrOptions, targetPropertyKeyOrOptions, optionsOrUndefined);
|
|
9574
9668
|
}
|
|
9669
|
+
return applyProperty("$this", void 0, selectorOrOptions);
|
|
9575
9670
|
}
|
|
9576
9671
|
var findAllPropertyMetadata = (target) => {
|
|
9577
9672
|
const actualTarget = target instanceof Function ? target : target.constructor;
|
|
@@ -9638,10 +9733,10 @@ var ensureInit = (inst) => {
|
|
|
9638
9733
|
}
|
|
9639
9734
|
};
|
|
9640
9735
|
var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
|
|
9641
|
-
var handleGlobalSwcEvent = async (
|
|
9642
|
-
if (
|
|
9643
|
-
const path =
|
|
9644
|
-
const type =
|
|
9736
|
+
var handleGlobalSwcEvent = async (event2) => {
|
|
9737
|
+
if (event2.__swc_handled) return;
|
|
9738
|
+
const path = event2.composedPath();
|
|
9739
|
+
const type = event2.type;
|
|
9645
9740
|
const attrName = `swc-on-${type}`;
|
|
9646
9741
|
for (const node of path) {
|
|
9647
9742
|
if (!(node instanceof HTMLElement)) continue;
|
|
@@ -9649,8 +9744,8 @@ var handleGlobalSwcEvent = async (event) => {
|
|
|
9649
9744
|
if (script && !getElementConfig(node)) {
|
|
9650
9745
|
const host = SwcUtils.findNearestSwcHostIncludingSelf(node);
|
|
9651
9746
|
if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === "function") {
|
|
9652
|
-
await host.__swc_executeAttributeEvent(node, attrName, script,
|
|
9653
|
-
|
|
9747
|
+
await host.__swc_executeAttributeEvent(node, attrName, script, event2);
|
|
9748
|
+
event2.__swc_handled = true;
|
|
9654
9749
|
break;
|
|
9655
9750
|
}
|
|
9656
9751
|
}
|
|
@@ -9739,14 +9834,14 @@ var setupPrototype = (proto, win) => {
|
|
|
9739
9834
|
}
|
|
9740
9835
|
const oldHandler = handlers.get(attrName);
|
|
9741
9836
|
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
9742
|
-
const handler = async (
|
|
9837
|
+
const handler = async (event2) => {
|
|
9743
9838
|
const hostSet = SwcUtils.getHostSet(el);
|
|
9744
9839
|
const conf = getElementConfig(this);
|
|
9745
9840
|
const currentWin = this._resolveWindow(conf);
|
|
9746
9841
|
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
9747
9842
|
const args = {
|
|
9748
|
-
event,
|
|
9749
|
-
$data:
|
|
9843
|
+
event: event2,
|
|
9844
|
+
$data: event2.detail,
|
|
9750
9845
|
...hostSet,
|
|
9751
9846
|
...helpers,
|
|
9752
9847
|
$el: el,
|
|
@@ -9757,16 +9852,16 @@ var setupPrototype = (proto, win) => {
|
|
|
9757
9852
|
el.addEventListener(eventName, handler);
|
|
9758
9853
|
handlers.set(attrName, handler);
|
|
9759
9854
|
};
|
|
9760
|
-
proto.__swc_executeAttributeEvent = async function(el, attrName, script,
|
|
9855
|
+
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event2) {
|
|
9761
9856
|
ensureInit(this);
|
|
9762
9857
|
const hostSet = SwcUtils.getHostSet(el);
|
|
9763
9858
|
const conf = getElementConfig(this);
|
|
9764
9859
|
const currentWin = this._resolveWindow(conf);
|
|
9765
9860
|
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
9766
|
-
const detail =
|
|
9861
|
+
const detail = event2.detail;
|
|
9767
9862
|
const args = {
|
|
9768
|
-
event,
|
|
9769
|
-
$event:
|
|
9863
|
+
event: event2,
|
|
9864
|
+
$event: event2,
|
|
9770
9865
|
$data: detail,
|
|
9771
9866
|
$detail: detail,
|
|
9772
9867
|
...hostSet,
|
|
@@ -9917,24 +10012,24 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
9917
10012
|
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
9918
10013
|
return bStop - aStop;
|
|
9919
10014
|
});
|
|
9920
|
-
const unifiedHandler = async (
|
|
10015
|
+
const unifiedHandler = async (event2) => {
|
|
9921
10016
|
for (const meta of sortedMetaList) {
|
|
9922
10017
|
const { selector, options } = meta;
|
|
9923
|
-
const matchedEl =
|
|
10018
|
+
const matchedEl = event2.target.closest(selector);
|
|
9924
10019
|
if (matchedEl && br.contains(matchedEl)) {
|
|
9925
10020
|
if (options.filter) {
|
|
9926
10021
|
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
9927
|
-
if (!options.filter(
|
|
10022
|
+
if (!options.filter(event2, helper)) {
|
|
9928
10023
|
continue;
|
|
9929
10024
|
}
|
|
9930
10025
|
}
|
|
9931
|
-
if (options.stopPropagation)
|
|
9932
|
-
if (options.stopImmediatePropagation)
|
|
9933
|
-
if (options.preventDefault)
|
|
10026
|
+
if (options.stopPropagation) event2.stopPropagation();
|
|
10027
|
+
if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
10028
|
+
if (options.preventDefault) event2.preventDefault();
|
|
9934
10029
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
9935
|
-
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
9936
|
-
await this[meta.propertyKey](
|
|
9937
|
-
if (
|
|
10030
|
+
const args = { event: event2, ...currentHostSet, $el: matchedEl, $root: br };
|
|
10031
|
+
await this[meta.propertyKey](event2, { ...currentHostSet, $matchedElement: matchedEl }, args);
|
|
10032
|
+
if (event2.cancelBubble) break;
|
|
9938
10033
|
}
|
|
9939
10034
|
}
|
|
9940
10035
|
};
|
|
@@ -9982,22 +10077,46 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
9982
10077
|
});
|
|
9983
10078
|
}
|
|
9984
10079
|
bindTargets.forEach((t) => {
|
|
9985
|
-
const handler = async (
|
|
10080
|
+
const handler = async (event2) => {
|
|
9986
10081
|
if (options.filter) {
|
|
9987
10082
|
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
9988
|
-
if (!options.filter(
|
|
10083
|
+
if (!options.filter(event2, { currentThis: this, helper })) {
|
|
9989
10084
|
return;
|
|
9990
10085
|
}
|
|
9991
10086
|
}
|
|
9992
|
-
if (options.stopPropagation)
|
|
9993
|
-
if (options.stopImmediatePropagation)
|
|
9994
|
-
if (options.preventDefault)
|
|
10087
|
+
if (options.stopPropagation) event2.stopPropagation();
|
|
10088
|
+
if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
10089
|
+
if (options.preventDefault) event2.preventDefault();
|
|
9995
10090
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
9996
|
-
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
9997
|
-
await this[meta.propertyKey](
|
|
10091
|
+
const args = { event: event2, ...currentHostSet, $el: t, $root: t };
|
|
10092
|
+
await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
|
|
10093
|
+
};
|
|
10094
|
+
const eventSubject = new Subject();
|
|
10095
|
+
let eventStream = eventSubject;
|
|
10096
|
+
if (options.debounceTime !== void 0 && options.debounceTime > 0) {
|
|
10097
|
+
eventStream = eventStream.pipe(debounceTime(options.debounceTime));
|
|
10098
|
+
}
|
|
10099
|
+
if (options.throttleTime !== void 0 && options.throttleTime > 0) {
|
|
10100
|
+
eventStream = eventStream.pipe(throttleTime(options.throttleTime));
|
|
10101
|
+
}
|
|
10102
|
+
if (options.distinctUntilChanged !== void 0 && options.distinctUntilChanged !== false) {
|
|
10103
|
+
if (typeof options.distinctUntilChanged === "function") {
|
|
10104
|
+
eventStream = eventStream.pipe(distinctUntilChanged(options.distinctUntilChanged));
|
|
10105
|
+
} else {
|
|
10106
|
+
eventStream = eventStream.pipe(distinctUntilChanged());
|
|
10107
|
+
}
|
|
10108
|
+
}
|
|
10109
|
+
const subscription = eventStream.subscribe({
|
|
10110
|
+
next: (event2) => {
|
|
10111
|
+
handler(event2).catch((err) => console.error("Event handler error:", err));
|
|
10112
|
+
},
|
|
10113
|
+
error: (err) => console.error("Event stream error:", err)
|
|
10114
|
+
});
|
|
10115
|
+
const wrappedHandler = (event2) => {
|
|
10116
|
+
eventSubject.next(event2);
|
|
9998
10117
|
};
|
|
9999
|
-
t.addEventListener(type,
|
|
10000
|
-
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
10118
|
+
t.addEventListener(type, wrappedHandler, opts);
|
|
10119
|
+
this._boundListeners.push({ target: t, type, handler: wrappedHandler, options: opts, subscription });
|
|
10001
10120
|
});
|
|
10002
10121
|
});
|
|
10003
10122
|
if (originalConnected) await originalConnected.apply(this);
|
|
@@ -10037,7 +10156,12 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
10037
10156
|
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
10038
10157
|
for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
10039
10158
|
if (this._boundListeners) {
|
|
10040
|
-
this._boundListeners.forEach((l) =>
|
|
10159
|
+
this._boundListeners.forEach((l) => {
|
|
10160
|
+
l.target.removeEventListener(l.type, l.handler, l.options);
|
|
10161
|
+
if (l.subscription && typeof l.subscription.unsubscribe === "function") {
|
|
10162
|
+
l.subscription.unsubscribe();
|
|
10163
|
+
}
|
|
10164
|
+
});
|
|
10041
10165
|
this._boundListeners = [];
|
|
10042
10166
|
}
|
|
10043
10167
|
new ElementApply(this, { id: this._swcId }).removeAllEventListener();
|
|
@@ -10120,6 +10244,13 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
10120
10244
|
|
|
10121
10245
|
// src/decorators/applyAttribute.ts
|
|
10122
10246
|
var ATTRIBUTE_METADATA_KEY = Symbol.for("simple-web-component:attribute");
|
|
10247
|
+
var isCssSelector = (str) => {
|
|
10248
|
+
if (!str) return false;
|
|
10249
|
+
if (str.startsWith("$")) return true;
|
|
10250
|
+
if (/^[#.\[\:>+~]/.test(str)) return true;
|
|
10251
|
+
if (/[>+~:\[\]]/.test(str)) return true;
|
|
10252
|
+
return false;
|
|
10253
|
+
};
|
|
10123
10254
|
var convertValue2 = (val, type) => {
|
|
10124
10255
|
if (val === null || val === void 0) return val;
|
|
10125
10256
|
if (type === Number) return Number(val);
|
|
@@ -10249,13 +10380,22 @@ function applyAttribute(selector, targetAttributeNameOrOptions, options) {
|
|
|
10249
10380
|
descriptor.value = function(...args) {
|
|
10250
10381
|
ensureInit(this);
|
|
10251
10382
|
const res = original.apply(this, args);
|
|
10383
|
+
const extractValue = (v) => {
|
|
10384
|
+
const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;
|
|
10385
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10386
|
+
return v[keyToUse];
|
|
10387
|
+
}
|
|
10388
|
+
return v;
|
|
10389
|
+
};
|
|
10252
10390
|
if (res instanceof Promise) {
|
|
10253
10391
|
return res.then((v) => {
|
|
10254
|
-
|
|
10392
|
+
const extracted = extractValue(v);
|
|
10393
|
+
applyValueToTargets(this, extracted);
|
|
10255
10394
|
return v;
|
|
10256
10395
|
});
|
|
10257
10396
|
} else {
|
|
10258
|
-
|
|
10397
|
+
const extracted = extractValue(res);
|
|
10398
|
+
applyValueToTargets(this, extracted);
|
|
10259
10399
|
return res;
|
|
10260
10400
|
}
|
|
10261
10401
|
};
|
|
@@ -10281,35 +10421,32 @@ function applyAttribute(selector, targetAttributeNameOrOptions, options) {
|
|
|
10281
10421
|
});
|
|
10282
10422
|
};
|
|
10283
10423
|
}
|
|
10284
|
-
function attribute(
|
|
10285
|
-
|
|
10286
|
-
}
|
|
10287
|
-
|
|
10288
|
-
if (typeof
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
return applyAttribute("$this", void 0, {});
|
|
10424
|
+
function attribute(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsOrDescriptor) {
|
|
10425
|
+
if (optionsOrDescriptor !== void 0 && (typeof attributeNameOrOptions === "string" || typeof attributeNameOrOptions === "symbol")) {
|
|
10426
|
+
return applyAttribute("$this", void 0, {})(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsOrDescriptor);
|
|
10427
|
+
}
|
|
10428
|
+
if (typeof selectorOrAttributeOrTarget === "string") {
|
|
10429
|
+
const isSelector = isCssSelector(selectorOrAttributeOrTarget);
|
|
10430
|
+
if (isSelector) {
|
|
10431
|
+
return applyAttribute(selectorOrAttributeOrTarget, attributeNameOrOptions, optionsOrDescriptor);
|
|
10432
|
+
} else {
|
|
10433
|
+
const options = typeof attributeNameOrOptions === "object" && attributeNameOrOptions !== null ? attributeNameOrOptions : {};
|
|
10434
|
+
return applyAttribute("$this", selectorOrAttributeOrTarget, options);
|
|
10435
|
+
}
|
|
10297
10436
|
}
|
|
10437
|
+
return applyAttribute("$this", void 0, selectorOrAttributeOrTarget);
|
|
10298
10438
|
}
|
|
10299
|
-
function setAttribute(
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
10309
|
-
return applyAttribute("$this", void 0, targetOrOptions);
|
|
10310
|
-
} else {
|
|
10311
|
-
return applyAttribute("$this", void 0, {});
|
|
10439
|
+
function setAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions, optionsOrUndefined) {
|
|
10440
|
+
if (typeof selectorOrAttributeOrOptions === "string") {
|
|
10441
|
+
const isSelector = isCssSelector(selectorOrAttributeOrOptions);
|
|
10442
|
+
if (isSelector) {
|
|
10443
|
+
return applyAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions, optionsOrUndefined);
|
|
10444
|
+
} else {
|
|
10445
|
+
const options = typeof attributeNameOrOptions === "object" && attributeNameOrOptions !== null ? attributeNameOrOptions : {};
|
|
10446
|
+
return applyAttribute("$this", selectorOrAttributeOrOptions, options);
|
|
10447
|
+
}
|
|
10312
10448
|
}
|
|
10449
|
+
return applyAttribute("$this", void 0, selectorOrAttributeOrOptions);
|
|
10313
10450
|
}
|
|
10314
10451
|
var findAllAttributeMetadata = (target) => {
|
|
10315
10452
|
const actualTarget = target instanceof Function ? target : target.constructor;
|
|
@@ -10327,6 +10464,10 @@ var findAllAttributeApplyMetadata = (target) => {
|
|
|
10327
10464
|
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
10328
10465
|
var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
10329
10466
|
if (!targetEl) return;
|
|
10467
|
+
if (pos === "clearChildren") {
|
|
10468
|
+
targetEl.replaceChildren();
|
|
10469
|
+
return [];
|
|
10470
|
+
}
|
|
10330
10471
|
const doc = win.document;
|
|
10331
10472
|
const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
|
|
10332
10473
|
const id = currentThis._swcId;
|
|
@@ -10362,7 +10503,16 @@ var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
|
10362
10503
|
new ElementApply(targetEl, { id }).apply({ target: "noInitialized", context: stateContext, bind: currentThis });
|
|
10363
10504
|
return nodes;
|
|
10364
10505
|
};
|
|
10365
|
-
function applyNode(
|
|
10506
|
+
function applyNode(selectorOrOptions, maybeOptions) {
|
|
10507
|
+
let selector;
|
|
10508
|
+
let options;
|
|
10509
|
+
if (typeof selectorOrOptions === "string") {
|
|
10510
|
+
selector = selectorOrOptions;
|
|
10511
|
+
options = maybeOptions || { position: "replaceChildren" };
|
|
10512
|
+
} else {
|
|
10513
|
+
selector = "$this";
|
|
10514
|
+
options = selectorOrOptions || { position: "replaceChildren" };
|
|
10515
|
+
}
|
|
10366
10516
|
return (targetObj, propertyKey, descriptor) => {
|
|
10367
10517
|
const constructor = targetObj.constructor;
|
|
10368
10518
|
let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
|
|
@@ -10399,6 +10549,13 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
|
|
|
10399
10549
|
};
|
|
10400
10550
|
const targetEl = getTarget();
|
|
10401
10551
|
const res = original.apply(this, args);
|
|
10552
|
+
const extractValue = (v) => {
|
|
10553
|
+
const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;
|
|
10554
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10555
|
+
return v[keyToUse];
|
|
10556
|
+
}
|
|
10557
|
+
return v;
|
|
10558
|
+
};
|
|
10402
10559
|
const runApply = (target, val) => {
|
|
10403
10560
|
const pos = options.position || "beforeEnd";
|
|
10404
10561
|
const processedVal = val;
|
|
@@ -10413,103 +10570,154 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
|
|
|
10413
10570
|
}
|
|
10414
10571
|
if (res instanceof Promise) {
|
|
10415
10572
|
return res.then((finalRes) => {
|
|
10573
|
+
const extracted = extractValue(finalRes);
|
|
10416
10574
|
fallbackNodes.forEach((it) => it.remove());
|
|
10417
|
-
if (
|
|
10575
|
+
if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
|
|
10418
10576
|
return finalRes;
|
|
10419
10577
|
});
|
|
10420
10578
|
} else {
|
|
10421
|
-
|
|
10579
|
+
const extracted = extractValue(res);
|
|
10580
|
+
if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
|
|
10422
10581
|
return res;
|
|
10423
10582
|
}
|
|
10424
10583
|
};
|
|
10425
10584
|
};
|
|
10426
10585
|
}
|
|
10427
|
-
function
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
}
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10436
|
-
const opt = targetOrOptions || {};
|
|
10437
|
-
return applyNode("$this", { ...opt, ...option });
|
|
10438
|
-
}
|
|
10439
|
-
function beforeEndNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10440
|
-
const options = { position: "beforeEnd" };
|
|
10441
|
-
if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
|
|
10442
|
-
const opt = targetOrOptions || {};
|
|
10443
|
-
return applyNode("$this", { ...opt, ...options });
|
|
10444
|
-
}
|
|
10445
|
-
function beforeEndLightNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10446
|
-
const option = { position: "beforeEnd", root: "light" };
|
|
10447
|
-
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10448
|
-
const opt = targetOrOptions || {};
|
|
10449
|
-
return applyNode("$this", { ...opt, ...option });
|
|
10586
|
+
function replaceChildren(selectorOrOptions, maybeOptions, descriptor) {
|
|
10587
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10588
|
+
return applyNode({ position: "replaceChildren" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10589
|
+
}
|
|
10590
|
+
if (typeof selectorOrOptions === "string") {
|
|
10591
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren" });
|
|
10592
|
+
}
|
|
10593
|
+
return applyNode({ ...selectorOrOptions, position: "replaceChildren" });
|
|
10450
10594
|
}
|
|
10451
|
-
function
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10595
|
+
function clearChildrenNode(selectorOrOptions, maybeOptions, descriptor) {
|
|
10596
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10597
|
+
return applyNode({ position: "clearChildren" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10598
|
+
}
|
|
10599
|
+
if (typeof selectorOrOptions === "string") {
|
|
10600
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren" });
|
|
10601
|
+
}
|
|
10602
|
+
return applyNode({ ...selectorOrOptions, position: "clearChildren" });
|
|
10456
10603
|
}
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
if (
|
|
10460
|
-
|
|
10461
|
-
|
|
10604
|
+
var clearNode = clearChildrenNode;
|
|
10605
|
+
function innerHtml(selectorOrOptions, maybeOptions, descriptor) {
|
|
10606
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10607
|
+
return applyNode({ position: "innerHtml" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10608
|
+
}
|
|
10609
|
+
if (typeof selectorOrOptions === "string") {
|
|
10610
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml" });
|
|
10611
|
+
}
|
|
10612
|
+
return applyNode({ ...selectorOrOptions, position: "innerHtml" });
|
|
10462
10613
|
}
|
|
10463
|
-
function
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10614
|
+
function innerHtmlLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
10615
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10616
|
+
return applyNode({ position: "innerHtml", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10617
|
+
}
|
|
10618
|
+
if (typeof selectorOrOptions === "string") {
|
|
10619
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "light" });
|
|
10620
|
+
}
|
|
10621
|
+
return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "light" });
|
|
10468
10622
|
}
|
|
10469
|
-
function
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10623
|
+
function innerHtmlShadow(selectorOrOptions, maybeOptions, descriptor) {
|
|
10624
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10625
|
+
return applyNode({ position: "innerHtml", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10626
|
+
}
|
|
10627
|
+
if (typeof selectorOrOptions === "string") {
|
|
10628
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "shadow" });
|
|
10629
|
+
}
|
|
10630
|
+
return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "shadow" });
|
|
10474
10631
|
}
|
|
10475
|
-
function
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10632
|
+
function innerText(selectorOrOptions, maybeOptions, descriptor) {
|
|
10633
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10634
|
+
return applyNode({ position: "innerText" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10635
|
+
}
|
|
10636
|
+
if (typeof selectorOrOptions === "string") {
|
|
10637
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText" });
|
|
10638
|
+
}
|
|
10639
|
+
return applyNode({ ...selectorOrOptions, position: "innerText" });
|
|
10480
10640
|
}
|
|
10481
|
-
function
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10641
|
+
function innerTextLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
10642
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10643
|
+
return applyNode({ position: "innerText", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10644
|
+
}
|
|
10645
|
+
if (typeof selectorOrOptions === "string") {
|
|
10646
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "light" });
|
|
10647
|
+
}
|
|
10648
|
+
return applyNode({ ...selectorOrOptions, position: "innerText", root: "light" });
|
|
10486
10649
|
}
|
|
10487
|
-
function
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10650
|
+
function innerTextShadow(selectorOrOptions, maybeOptions, descriptor) {
|
|
10651
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10652
|
+
return applyNode({ position: "innerText", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10653
|
+
}
|
|
10654
|
+
if (typeof selectorOrOptions === "string") {
|
|
10655
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "shadow" });
|
|
10656
|
+
}
|
|
10657
|
+
return applyNode({ ...selectorOrOptions, position: "innerText", root: "shadow" });
|
|
10492
10658
|
}
|
|
10493
|
-
function
|
|
10494
|
-
|
|
10659
|
+
function insertBeforeEnd(selectorOrOptions, maybeOptions, descriptor) {
|
|
10660
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10661
|
+
return applyNode({ position: "beforeEnd" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10662
|
+
}
|
|
10663
|
+
if (typeof selectorOrOptions === "string") {
|
|
10664
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd" });
|
|
10665
|
+
}
|
|
10666
|
+
return applyNode({ ...selectorOrOptions, position: "beforeEnd" });
|
|
10495
10667
|
}
|
|
10496
|
-
function
|
|
10497
|
-
|
|
10668
|
+
function insertBeforeEndLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
10669
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10670
|
+
return applyNode({ position: "beforeEnd", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10671
|
+
}
|
|
10672
|
+
if (typeof selectorOrOptions === "string") {
|
|
10673
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "light" });
|
|
10674
|
+
}
|
|
10675
|
+
return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "light" });
|
|
10498
10676
|
}
|
|
10499
|
-
function
|
|
10500
|
-
|
|
10677
|
+
function insertBeforeEndShadow(selectorOrOptions, maybeOptions, descriptor) {
|
|
10678
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10679
|
+
return applyNode({ position: "beforeEnd", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10680
|
+
}
|
|
10681
|
+
if (typeof selectorOrOptions === "string") {
|
|
10682
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "shadow" });
|
|
10683
|
+
}
|
|
10684
|
+
return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "shadow" });
|
|
10501
10685
|
}
|
|
10502
|
-
function
|
|
10503
|
-
|
|
10686
|
+
function insertAfterBegin(selectorOrOptions, maybeOptions, descriptor) {
|
|
10687
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10688
|
+
return applyNode({ position: "afterBegin" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10689
|
+
}
|
|
10690
|
+
if (typeof selectorOrOptions === "string") {
|
|
10691
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin" });
|
|
10692
|
+
}
|
|
10693
|
+
return applyNode({ ...selectorOrOptions, position: "afterBegin" });
|
|
10504
10694
|
}
|
|
10505
|
-
function
|
|
10506
|
-
|
|
10695
|
+
function insertAfterBeginLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
10696
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10697
|
+
return applyNode({ position: "afterBegin", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10698
|
+
}
|
|
10699
|
+
if (typeof selectorOrOptions === "string") {
|
|
10700
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin", root: "light" });
|
|
10701
|
+
}
|
|
10702
|
+
return applyNode({ ...selectorOrOptions, position: "afterBegin", root: "light" });
|
|
10507
10703
|
}
|
|
10508
|
-
function
|
|
10509
|
-
|
|
10704
|
+
function replaceChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
10705
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10706
|
+
return applyNode({ position: "replaceChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10707
|
+
}
|
|
10708
|
+
if (typeof selectorOrOptions === "string") {
|
|
10709
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren", root: "light" });
|
|
10710
|
+
}
|
|
10711
|
+
return applyNode({ ...selectorOrOptions, position: "replaceChildren", root: "light" });
|
|
10510
10712
|
}
|
|
10511
|
-
function
|
|
10512
|
-
|
|
10713
|
+
function clearChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
10714
|
+
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10715
|
+
return applyNode({ position: "clearChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10716
|
+
}
|
|
10717
|
+
if (typeof selectorOrOptions === "string") {
|
|
10718
|
+
return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren", root: "light" });
|
|
10719
|
+
}
|
|
10720
|
+
return applyNode({ ...selectorOrOptions, position: "clearChildren", root: "light" });
|
|
10513
10721
|
}
|
|
10514
10722
|
var findAllApplyNodeMetadata = (target) => {
|
|
10515
10723
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -10545,6 +10753,13 @@ function createClassDecorator(action) {
|
|
|
10545
10753
|
descriptor.value = function(...args) {
|
|
10546
10754
|
ensureInit(this);
|
|
10547
10755
|
const res = original.apply(this, args);
|
|
10756
|
+
const extractValue = (v) => {
|
|
10757
|
+
const keyToUse = finalOptions.valueKey ?? CLASS_METADATA_KEY;
|
|
10758
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10759
|
+
return v[keyToUse];
|
|
10760
|
+
}
|
|
10761
|
+
return v;
|
|
10762
|
+
};
|
|
10548
10763
|
const handleResult = (resolvedValue) => {
|
|
10549
10764
|
if (resolvedValue !== void 0) {
|
|
10550
10765
|
const win = this.ownerDocument?.defaultView || window;
|
|
@@ -10624,31 +10839,73 @@ function createClassDecorator(action) {
|
|
|
10624
10839
|
return resolvedValue;
|
|
10625
10840
|
};
|
|
10626
10841
|
if (res instanceof Promise) {
|
|
10627
|
-
return res.then(handleResult);
|
|
10842
|
+
return res.then((v) => handleResult(extractValue(v)));
|
|
10628
10843
|
} else {
|
|
10629
|
-
return handleResult(res);
|
|
10844
|
+
return handleResult(extractValue(res));
|
|
10630
10845
|
}
|
|
10631
10846
|
};
|
|
10632
10847
|
return descriptor;
|
|
10633
10848
|
};
|
|
10634
10849
|
};
|
|
10635
10850
|
}
|
|
10636
|
-
function applyClass(
|
|
10637
|
-
|
|
10638
|
-
}
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10851
|
+
function applyClass(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor) {
|
|
10852
|
+
if (optionsOrDescriptor !== void 0 && (typeof actionOrPropertyKey === "string" || typeof actionOrPropertyKey === "symbol")) {
|
|
10853
|
+
return createClassDecorator("update")("$this", {})(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor);
|
|
10854
|
+
}
|
|
10855
|
+
if (typeof selectorOrTarget === "string") {
|
|
10856
|
+
const action2 = typeof actionOrPropertyKey === "string" ? actionOrPropertyKey : "update";
|
|
10857
|
+
const options2 = typeof actionOrPropertyKey === "object" ? actionOrPropertyKey : optionsOrDescriptor;
|
|
10858
|
+
return createClassDecorator(action2)(selectorOrTarget, options2);
|
|
10859
|
+
}
|
|
10860
|
+
const action = typeof selectorOrTarget === "string" ? selectorOrTarget : "update";
|
|
10861
|
+
const options = typeof selectorOrTarget === "object" ? selectorOrTarget : actionOrPropertyKey;
|
|
10645
10862
|
return createClassDecorator(action)("$this", options);
|
|
10646
10863
|
}
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10864
|
+
function setClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
|
|
10865
|
+
if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
|
|
10866
|
+
return createClassDecorator("set")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10867
|
+
}
|
|
10868
|
+
if (typeof selectorOrTarget === "string") {
|
|
10869
|
+
return createClassDecorator("set")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10870
|
+
}
|
|
10871
|
+
return createClassDecorator("set")("$this", selectorOrTarget);
|
|
10872
|
+
}
|
|
10873
|
+
function updateClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
|
|
10874
|
+
if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
|
|
10875
|
+
return createClassDecorator("update")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10876
|
+
}
|
|
10877
|
+
if (typeof selectorOrTarget === "string") {
|
|
10878
|
+
return createClassDecorator("update")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10879
|
+
}
|
|
10880
|
+
return createClassDecorator("update")("$this", selectorOrTarget);
|
|
10881
|
+
}
|
|
10882
|
+
function addClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
|
|
10883
|
+
if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
|
|
10884
|
+
return createClassDecorator("add")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10885
|
+
}
|
|
10886
|
+
if (typeof selectorOrTarget === "string") {
|
|
10887
|
+
return createClassDecorator("add")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10888
|
+
}
|
|
10889
|
+
return createClassDecorator("add")("$this", selectorOrTarget);
|
|
10890
|
+
}
|
|
10891
|
+
function removeClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
|
|
10892
|
+
if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
|
|
10893
|
+
return createClassDecorator("remove")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10894
|
+
}
|
|
10895
|
+
if (typeof selectorOrTarget === "string") {
|
|
10896
|
+
return createClassDecorator("remove")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10897
|
+
}
|
|
10898
|
+
return createClassDecorator("remove")("$this", selectorOrTarget);
|
|
10899
|
+
}
|
|
10900
|
+
function toggleClass(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor) {
|
|
10901
|
+
if (optionsOrDescriptor !== void 0 && (typeof classMapOrOptionsOrPropertyKey === "string" || typeof classMapOrOptionsOrPropertyKey === "symbol")) {
|
|
10902
|
+
return createClassDecorator("toggle")("$this", {})(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10903
|
+
}
|
|
10904
|
+
if (typeof selectorOrTarget === "string") {
|
|
10905
|
+
return createClassDecorator("toggle")(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor);
|
|
10906
|
+
}
|
|
10907
|
+
return createClassDecorator("toggle")("$this", selectorOrTarget);
|
|
10908
|
+
}
|
|
10652
10909
|
var findAllClassMetadata = (target) => {
|
|
10653
10910
|
const result = /* @__PURE__ */ new Map();
|
|
10654
10911
|
const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
|
|
@@ -10676,6 +10933,13 @@ function createStyleDecorator(action) {
|
|
|
10676
10933
|
descriptor.value = function(...args) {
|
|
10677
10934
|
ensureInit(this);
|
|
10678
10935
|
const res = original.apply(this, args);
|
|
10936
|
+
const extractValue = (v) => {
|
|
10937
|
+
const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;
|
|
10938
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10939
|
+
return v[keyToUse];
|
|
10940
|
+
}
|
|
10941
|
+
return v;
|
|
10942
|
+
};
|
|
10679
10943
|
const handleResult = (resolvedValue) => {
|
|
10680
10944
|
if (resolvedValue !== void 0) {
|
|
10681
10945
|
const win = this.ownerDocument?.defaultView || window;
|
|
@@ -10741,27 +11005,55 @@ function createStyleDecorator(action) {
|
|
|
10741
11005
|
return resolvedValue;
|
|
10742
11006
|
};
|
|
10743
11007
|
if (res instanceof Promise) {
|
|
10744
|
-
return res.then(handleResult);
|
|
11008
|
+
return res.then((v) => handleResult(extractValue(v)));
|
|
10745
11009
|
} else {
|
|
10746
|
-
return handleResult(res);
|
|
11010
|
+
return handleResult(extractValue(res));
|
|
10747
11011
|
}
|
|
10748
11012
|
};
|
|
10749
11013
|
return descriptor;
|
|
10750
11014
|
};
|
|
10751
11015
|
};
|
|
10752
11016
|
}
|
|
10753
|
-
function applyStyle(
|
|
10754
|
-
|
|
10755
|
-
}
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
11017
|
+
function applyStyle(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor) {
|
|
11018
|
+
if (optionsOrDescriptor !== void 0 && (typeof actionOrPropertyKey === "string" || typeof actionOrPropertyKey === "symbol")) {
|
|
11019
|
+
return createStyleDecorator("update")("$this", {})(selectorOrTarget, actionOrPropertyKey, optionsOrDescriptor);
|
|
11020
|
+
}
|
|
11021
|
+
if (typeof selectorOrTarget === "string") {
|
|
11022
|
+
const action2 = typeof actionOrPropertyKey === "string" ? actionOrPropertyKey : "update";
|
|
11023
|
+
const options2 = typeof actionOrPropertyKey === "object" ? actionOrPropertyKey : optionsOrDescriptor;
|
|
11024
|
+
return createStyleDecorator(action2)(selectorOrTarget, options2);
|
|
11025
|
+
}
|
|
11026
|
+
const action = typeof selectorOrTarget === "string" ? selectorOrTarget : "update";
|
|
11027
|
+
const options = typeof selectorOrTarget === "object" ? selectorOrTarget : actionOrPropertyKey;
|
|
10760
11028
|
return createStyleDecorator(action)("$this", options);
|
|
10761
11029
|
}
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
11030
|
+
function setStyle(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
11031
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
11032
|
+
return createStyleDecorator("set")("$this", {})(selectorOrTarget, optionsOrPropertyKey, descriptor);
|
|
11033
|
+
}
|
|
11034
|
+
if (typeof selectorOrTarget === "string") {
|
|
11035
|
+
return createStyleDecorator("set")(selectorOrTarget, optionsOrPropertyKey);
|
|
11036
|
+
}
|
|
11037
|
+
return createStyleDecorator("set")("$this", selectorOrTarget);
|
|
11038
|
+
}
|
|
11039
|
+
function updateStyle(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
11040
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
11041
|
+
return createStyleDecorator("update")("$this", {})(selectorOrTarget, optionsOrPropertyKey, descriptor);
|
|
11042
|
+
}
|
|
11043
|
+
if (typeof selectorOrTarget === "string") {
|
|
11044
|
+
return createStyleDecorator("update")(selectorOrTarget, optionsOrPropertyKey);
|
|
11045
|
+
}
|
|
11046
|
+
return createStyleDecorator("update")("$this", selectorOrTarget);
|
|
11047
|
+
}
|
|
11048
|
+
function removeStyle(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
11049
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
11050
|
+
return createStyleDecorator("remove")("$this", {})(selectorOrTarget, optionsOrPropertyKey, descriptor);
|
|
11051
|
+
}
|
|
11052
|
+
if (typeof selectorOrTarget === "string") {
|
|
11053
|
+
return createStyleDecorator("remove")(selectorOrTarget, optionsOrPropertyKey);
|
|
11054
|
+
}
|
|
11055
|
+
return createStyleDecorator("remove")("$this", selectorOrTarget);
|
|
11056
|
+
}
|
|
10765
11057
|
var findAllStyleMetadata = (target) => {
|
|
10766
11058
|
const result = /* @__PURE__ */ new Map();
|
|
10767
11059
|
const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
|
|
@@ -10809,6 +11101,7 @@ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKeyOr
|
|
|
10809
11101
|
}
|
|
10810
11102
|
return createSubscribeSwcAppRouteChangeWhileConnected(options);
|
|
10811
11103
|
}
|
|
11104
|
+
var changedRoute = subscribeSwcAppRouteChangeWhileConnected;
|
|
10812
11105
|
var getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
|
|
10813
11106
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
10814
11107
|
const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
@@ -10849,6 +11142,7 @@ function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, opti
|
|
|
10849
11142
|
}
|
|
10850
11143
|
return createSubscribeSwcAppMessageWhileConnected(options, messageType);
|
|
10851
11144
|
}
|
|
11145
|
+
var receiveMessage = subscribeSwcAppMessageWhileConnected;
|
|
10852
11146
|
var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
|
|
10853
11147
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
10854
11148
|
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
@@ -10856,7 +11150,7 @@ var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
|
|
|
10856
11150
|
|
|
10857
11151
|
// src/decorators/publishSwcAppMessage.ts
|
|
10858
11152
|
var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
|
|
10859
|
-
function createPublishSwcAppMessage(messageType) {
|
|
11153
|
+
function createPublishSwcAppMessage(messageType, options) {
|
|
10860
11154
|
return (target, propertyKey, descriptor) => {
|
|
10861
11155
|
const constructor = target.constructor;
|
|
10862
11156
|
let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
@@ -10871,45 +11165,58 @@ function createPublishSwcAppMessage(messageType) {
|
|
|
10871
11165
|
const originalMethod = descriptor.value;
|
|
10872
11166
|
descriptor.value = function(...args) {
|
|
10873
11167
|
const result = originalMethod.apply(this, args);
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
});
|
|
10883
|
-
}
|
|
10884
|
-
}).catch((err) => {
|
|
10885
|
-
console.warn("publishSwcAppMessage async error:", err);
|
|
10886
|
-
});
|
|
10887
|
-
} else {
|
|
11168
|
+
const extractValue = (v) => {
|
|
11169
|
+
const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;
|
|
11170
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
11171
|
+
return v[keyToUse];
|
|
11172
|
+
}
|
|
11173
|
+
return v;
|
|
11174
|
+
};
|
|
11175
|
+
const publishMessage2 = (data) => {
|
|
10888
11176
|
const appHost = SwcUtils.getAppHost(this);
|
|
10889
11177
|
if (appHost) {
|
|
10890
11178
|
appHost.publishMessage({
|
|
10891
11179
|
publisher: this,
|
|
10892
|
-
data
|
|
11180
|
+
data,
|
|
10893
11181
|
type: messageType
|
|
10894
11182
|
});
|
|
10895
11183
|
}
|
|
11184
|
+
};
|
|
11185
|
+
if (result instanceof Promise) {
|
|
11186
|
+
result.then((data) => {
|
|
11187
|
+
const extracted = extractValue(data);
|
|
11188
|
+
publishMessage2(extracted);
|
|
11189
|
+
}).catch((err) => {
|
|
11190
|
+
console.warn("publishSwcAppMessage async error:", err);
|
|
11191
|
+
});
|
|
11192
|
+
} else {
|
|
11193
|
+
const extracted = extractValue(result);
|
|
11194
|
+
publishMessage2(extracted);
|
|
10896
11195
|
}
|
|
10897
11196
|
return result;
|
|
10898
11197
|
};
|
|
10899
11198
|
return descriptor;
|
|
10900
11199
|
};
|
|
10901
11200
|
}
|
|
10902
|
-
function publishSwcAppMessage(
|
|
10903
|
-
if (
|
|
10904
|
-
const target =
|
|
10905
|
-
return createPublishSwcAppMessage()(target,
|
|
11201
|
+
function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions, descriptor) {
|
|
11202
|
+
if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && propertyKeyOrOptions && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") && descriptor) {
|
|
11203
|
+
const target = targetOrMessageTypeOrOptions;
|
|
11204
|
+
return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);
|
|
10906
11205
|
}
|
|
10907
11206
|
let messageType;
|
|
10908
|
-
|
|
10909
|
-
|
|
11207
|
+
let options;
|
|
11208
|
+
if (typeof targetOrMessageTypeOrOptions === "string") {
|
|
11209
|
+
messageType = targetOrMessageTypeOrOptions;
|
|
11210
|
+
if (typeof propertyKeyOrOptions === "object" && propertyKeyOrOptions !== null) {
|
|
11211
|
+
options = propertyKeyOrOptions;
|
|
11212
|
+
}
|
|
11213
|
+
} else if (typeof targetOrMessageTypeOrOptions === "object" && targetOrMessageTypeOrOptions !== null) {
|
|
11214
|
+
options = targetOrMessageTypeOrOptions;
|
|
11215
|
+
messageType = options.messageType;
|
|
10910
11216
|
}
|
|
10911
|
-
return createPublishSwcAppMessage(messageType);
|
|
11217
|
+
return createPublishSwcAppMessage(messageType, options);
|
|
10912
11218
|
}
|
|
11219
|
+
var publishMessage = publishSwcAppMessage;
|
|
10913
11220
|
var getPublishSwcAppMessageMetadata = (target) => {
|
|
10914
11221
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
10915
11222
|
return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
@@ -10969,15 +11276,24 @@ function applySlot(targetId, opt) {
|
|
|
10969
11276
|
fallbackNodes.push(...nodes);
|
|
10970
11277
|
applyToDom2(swcId, targetId, options.position, nodes);
|
|
10971
11278
|
}
|
|
11279
|
+
const extractValue = (v) => {
|
|
11280
|
+
const keyToUse = options.valueKey ?? APPLY_SLOT_METADATA_KEY;
|
|
11281
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
11282
|
+
return v[keyToUse];
|
|
11283
|
+
}
|
|
11284
|
+
return v;
|
|
11285
|
+
};
|
|
10972
11286
|
let res = original.apply(this, args);
|
|
10973
11287
|
if (res instanceof Promise) {
|
|
10974
11288
|
return res.then((asyncRes) => {
|
|
10975
|
-
const
|
|
11289
|
+
const extracted = extractValue(asyncRes);
|
|
11290
|
+
const nodes = resToNodes(extracted);
|
|
10976
11291
|
fallbackNodes.forEach((it) => it.remove());
|
|
10977
11292
|
applyToDom2(swcId, targetId, options.position, nodes);
|
|
10978
11293
|
});
|
|
10979
11294
|
} else {
|
|
10980
|
-
const
|
|
11295
|
+
const extracted = extractValue(res);
|
|
11296
|
+
const nodes = resToNodes(extracted);
|
|
10981
11297
|
applyToDom2(swcId, targetId, options.position, nodes);
|
|
10982
11298
|
}
|
|
10983
11299
|
};
|
|
@@ -13017,6 +13333,10 @@ var ElementRouter = class extends Router {
|
|
|
13017
13333
|
super(config);
|
|
13018
13334
|
__publicField(this, "_history", []);
|
|
13019
13335
|
__publicField(this, "_currentIndex", -1);
|
|
13336
|
+
if (config.firstUrl) {
|
|
13337
|
+
this._history.push({ url: config.firstUrl, data: null, title: void 0 });
|
|
13338
|
+
this._currentIndex = 0;
|
|
13339
|
+
}
|
|
13020
13340
|
}
|
|
13021
13341
|
// Override pushState to manage internal history
|
|
13022
13342
|
pushState(data, title, path, config) {
|
|
@@ -13188,7 +13508,9 @@ var SwcAppEngine = class {
|
|
|
13188
13508
|
if (this.router) otherInstanceSim.set(Router, this.router);
|
|
13189
13509
|
this.simpleApplication.run(otherInstanceSim);
|
|
13190
13510
|
if (this._config.onStartedLazyDefineComponent) {
|
|
13191
|
-
await Promise.all(this._config.onStartedLazyDefineComponent.map((it) =>
|
|
13511
|
+
await Promise.all(this._config.onStartedLazyDefineComponent.map((it) => {
|
|
13512
|
+
it(this._config.window);
|
|
13513
|
+
}));
|
|
13192
13514
|
}
|
|
13193
13515
|
if (this._config.onEngineStarted) {
|
|
13194
13516
|
await this._config.onEngineStarted(this.simpleApplication, this.host);
|
|
@@ -13265,6 +13587,13 @@ function SwcAppMixin(Base) {
|
|
|
13265
13587
|
const methodName = metadata.propertyKey;
|
|
13266
13588
|
let pathPattern = metadata.options?.path;
|
|
13267
13589
|
const filter = metadata.options?.filter;
|
|
13590
|
+
const extractValue = (v) => {
|
|
13591
|
+
const keyToUse = metadata.options?.valueKey ?? SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY;
|
|
13592
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
13593
|
+
return v[keyToUse];
|
|
13594
|
+
}
|
|
13595
|
+
return v;
|
|
13596
|
+
};
|
|
13268
13597
|
if (typeof pathPattern === "function") {
|
|
13269
13598
|
pathPattern = pathPattern(instance);
|
|
13270
13599
|
}
|
|
@@ -13289,7 +13618,7 @@ function SwcAppMixin(Base) {
|
|
|
13289
13618
|
const hostSet = SwcUtils.getHelperAndHostSet(this.config.window, this);
|
|
13290
13619
|
const filterPassed = !filter || filter(this.router, { helper: hostSet, currentThis: instance });
|
|
13291
13620
|
if (pathMatched && filterPassed && instance[methodName]) {
|
|
13292
|
-
const result = await instance[methodName]({ ...re, pathData });
|
|
13621
|
+
const result = extractValue(await instance[methodName]({ ...re, pathData }));
|
|
13293
13622
|
if (result !== void 0 && result !== null) {
|
|
13294
13623
|
break;
|
|
13295
13624
|
}
|
|
@@ -13404,7 +13733,15 @@ function SwcAppMixin(Base) {
|
|
|
13404
13733
|
context: this,
|
|
13405
13734
|
args: SwcUtils.getHelperAndHostSet(win, this)
|
|
13406
13735
|
});
|
|
13407
|
-
|
|
13736
|
+
if (userConfig instanceof Promise) {
|
|
13737
|
+
userConfig.then((resolvedConfig) => {
|
|
13738
|
+
this.connect(resolvedConfig);
|
|
13739
|
+
}).catch((e) => {
|
|
13740
|
+
console.error("[SWC-MIXIN] Script execution failed:", e);
|
|
13741
|
+
});
|
|
13742
|
+
} else {
|
|
13743
|
+
this.connect(userConfig);
|
|
13744
|
+
}
|
|
13408
13745
|
} catch (e) {
|
|
13409
13746
|
console.error("[SWC-MIXIN] Script execution failed:", e);
|
|
13410
13747
|
}
|
|
@@ -13677,6 +14014,7 @@ export {
|
|
|
13677
14014
|
SwcAppAside,
|
|
13678
14015
|
SwcAppBody,
|
|
13679
14016
|
SwcAppDiv,
|
|
14017
|
+
SwcAppEngine,
|
|
13680
14018
|
SwcAppFooter,
|
|
13681
14019
|
SwcAppHeader,
|
|
13682
14020
|
SwcAppMain,
|
|
@@ -13685,7 +14023,6 @@ export {
|
|
|
13685
14023
|
SwcAppSection,
|
|
13686
14024
|
SwcUtils,
|
|
13687
14025
|
addClass,
|
|
13688
|
-
addClassThis,
|
|
13689
14026
|
addEventListener,
|
|
13690
14027
|
addEventListenerAppHost,
|
|
13691
14028
|
addEventListenerDelegate,
|
|
@@ -13695,28 +14032,21 @@ export {
|
|
|
13695
14032
|
addEventListenerDocument,
|
|
13696
14033
|
addEventListenerThis,
|
|
13697
14034
|
addEventListenerWindow,
|
|
13698
|
-
afterBeginLightNodeThis,
|
|
13699
|
-
afterBeginNodeThis,
|
|
13700
|
-
allAppHost,
|
|
13701
|
-
allParentHost,
|
|
13702
14035
|
appendHtmlSlot,
|
|
13703
14036
|
appendSlot,
|
|
13704
14037
|
appendTextSlot,
|
|
13705
14038
|
applyAttribute,
|
|
13706
14039
|
applyClass,
|
|
13707
|
-
applyClassThis,
|
|
13708
14040
|
applyNode,
|
|
13709
|
-
applyNodeThis,
|
|
13710
14041
|
applyProperty,
|
|
13711
14042
|
applySlot,
|
|
13712
14043
|
applyStyle,
|
|
13713
|
-
applyStyleThis,
|
|
13714
14044
|
attribute,
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
14045
|
+
changedAttribute,
|
|
14046
|
+
changedRoute,
|
|
14047
|
+
clearChildrenLight,
|
|
14048
|
+
clearChildrenNode,
|
|
14049
|
+
clearNode,
|
|
13720
14050
|
clearSlot,
|
|
13721
14051
|
commentNode,
|
|
13722
14052
|
convertAttributeValue,
|
|
@@ -13734,9 +14064,14 @@ export {
|
|
|
13734
14064
|
defineSwcAppNav,
|
|
13735
14065
|
defineSwcAppSection,
|
|
13736
14066
|
elementDefine,
|
|
14067
|
+
emit,
|
|
13737
14068
|
emitCustomEvent,
|
|
13738
|
-
emitCustomEventThis,
|
|
13739
14069
|
ensureInit,
|
|
14070
|
+
event,
|
|
14071
|
+
eventDelegate,
|
|
14072
|
+
eventDelegateAllDom,
|
|
14073
|
+
eventDelegateLightDom,
|
|
14074
|
+
eventDelegateShadowDom,
|
|
13740
14075
|
findAllApplyNodeMetadata,
|
|
13741
14076
|
findAllApplySlotMetadata,
|
|
13742
14077
|
findAllAttributeApplyMetadata,
|
|
@@ -13773,15 +14108,17 @@ export {
|
|
|
13773
14108
|
htmlSectionElement,
|
|
13774
14109
|
htmlSpanElement,
|
|
13775
14110
|
htmlUlElement,
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
14111
|
+
innerHtml,
|
|
14112
|
+
innerHtmlLight,
|
|
14113
|
+
innerHtmlShadow,
|
|
14114
|
+
innerText,
|
|
14115
|
+
innerTextLight,
|
|
14116
|
+
innerTextShadow,
|
|
14117
|
+
insertAfterBegin,
|
|
14118
|
+
insertAfterBeginLight,
|
|
14119
|
+
insertBeforeEnd,
|
|
14120
|
+
insertBeforeEndLight,
|
|
14121
|
+
insertBeforeEndShadow,
|
|
13785
14122
|
isSSR,
|
|
13786
14123
|
onAdopted,
|
|
13787
14124
|
onAdoptedAfter,
|
|
@@ -13801,38 +14138,26 @@ export {
|
|
|
13801
14138
|
prependSlot,
|
|
13802
14139
|
prependTextSlot,
|
|
13803
14140
|
property,
|
|
13804
|
-
|
|
14141
|
+
publishMessage,
|
|
13805
14142
|
publishSwcAppMessage,
|
|
13806
14143
|
query,
|
|
13807
14144
|
queryAll,
|
|
13808
|
-
|
|
13809
|
-
queryAppHost,
|
|
13810
|
-
queryDocument,
|
|
13811
|
-
queryHost,
|
|
13812
|
-
queryThis,
|
|
13813
|
-
queryWindow,
|
|
14145
|
+
receiveMessage,
|
|
13814
14146
|
removeClass,
|
|
13815
|
-
removeClassThis,
|
|
13816
14147
|
removeSSRAttribute,
|
|
13817
14148
|
removeStyle,
|
|
13818
|
-
|
|
14149
|
+
replaceChildren,
|
|
13819
14150
|
replaceChildrenHtmlSlot,
|
|
13820
|
-
|
|
13821
|
-
replaceChildrenNode,
|
|
13822
|
-
replaceChildrenNodeThis,
|
|
14151
|
+
replaceChildrenLight,
|
|
13823
14152
|
replaceChildrenSlot,
|
|
13824
14153
|
replaceChildrenTextSlot,
|
|
13825
14154
|
resolveAttributeTargets,
|
|
13826
14155
|
resolvePropertyTargets,
|
|
13827
14156
|
setAttribute,
|
|
13828
|
-
setAttributeThis,
|
|
13829
14157
|
setClass,
|
|
13830
|
-
setClassThis,
|
|
13831
14158
|
setProperty,
|
|
13832
|
-
setPropertyThis,
|
|
13833
14159
|
setSSRAttribute,
|
|
13834
14160
|
setStyle,
|
|
13835
|
-
setStyleThis,
|
|
13836
14161
|
state,
|
|
13837
14162
|
subscribeSwcAppMessageWhileConnected,
|
|
13838
14163
|
subscribeSwcAppRouteChangeWhileConnected,
|
|
@@ -13849,11 +14174,8 @@ export {
|
|
|
13849
14174
|
swcAppTagName,
|
|
13850
14175
|
textNode,
|
|
13851
14176
|
toggleClass,
|
|
13852
|
-
toggleClassThis,
|
|
13853
14177
|
updateClass,
|
|
13854
|
-
|
|
13855
|
-
updateStyle,
|
|
13856
|
-
updateStyleThis
|
|
14178
|
+
updateStyle
|
|
13857
14179
|
};
|
|
13858
14180
|
/*! Bundled license information:
|
|
13859
14181
|
|