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