@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
|
@@ -6187,8 +6187,8 @@ var SwcUtils;
|
|
|
6187
6187
|
return (0, SwcUtils2.findNearestSwcHost)(el);
|
|
6188
6188
|
};
|
|
6189
6189
|
SwcUtils2.getAppHosts = (el) => {
|
|
6190
|
-
const hosts =
|
|
6191
|
-
return hosts
|
|
6190
|
+
const hosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
6191
|
+
return hosts;
|
|
6192
6192
|
};
|
|
6193
6193
|
SwcUtils2.getAppHost = (el) => {
|
|
6194
6194
|
const appHosts = (0, SwcUtils2.getAppHosts)(el);
|
|
@@ -6201,6 +6201,10 @@ var SwcUtils;
|
|
|
6201
6201
|
};
|
|
6202
6202
|
SwcUtils2.findAllParentAppHostsDirect = (el) => {
|
|
6203
6203
|
const appHosts = [];
|
|
6204
|
+
const w = el.ownerDocument?.defaultView || (typeof window !== "undefined" ? window : void 0);
|
|
6205
|
+
if (!w) {
|
|
6206
|
+
return appHosts;
|
|
6207
|
+
}
|
|
6204
6208
|
let current = el;
|
|
6205
6209
|
while (current) {
|
|
6206
6210
|
const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
|
|
@@ -6211,7 +6215,7 @@ var SwcUtils;
|
|
|
6211
6215
|
current = current.parentElement;
|
|
6212
6216
|
} else {
|
|
6213
6217
|
const root = current.getRootNode();
|
|
6214
|
-
if (root instanceof ShadowRoot) {
|
|
6218
|
+
if (w.ShadowRoot && root instanceof w.ShadowRoot) {
|
|
6215
6219
|
current = root.host;
|
|
6216
6220
|
} else {
|
|
6217
6221
|
break;
|
|
@@ -6286,54 +6290,67 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
|
6286
6290
|
}
|
|
6287
6291
|
list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
|
|
6288
6292
|
const original = descriptor.value;
|
|
6289
|
-
descriptor.value =
|
|
6293
|
+
descriptor.value = function(...args) {
|
|
6290
6294
|
ensureInit(this);
|
|
6291
|
-
const
|
|
6292
|
-
const
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
if (
|
|
6306
|
-
|
|
6307
|
-
if (
|
|
6308
|
-
|
|
6309
|
-
if (
|
|
6310
|
-
|
|
6311
|
-
if (
|
|
6312
|
-
|
|
6313
|
-
if (
|
|
6314
|
-
|
|
6315
|
-
if (
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
searchRoots.push(this);
|
|
6329
|
-
if (
|
|
6295
|
+
const res = original.apply(this, args);
|
|
6296
|
+
const handleResult = (detail) => {
|
|
6297
|
+
const event = new CustomEvent(type, {
|
|
6298
|
+
detail,
|
|
6299
|
+
bubbles: fullOptions.bubbles,
|
|
6300
|
+
composed: fullOptions.composed,
|
|
6301
|
+
cancelable: fullOptions.cancelable
|
|
6302
|
+
});
|
|
6303
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
6304
|
+
const conf = getElementConfig(this);
|
|
6305
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6306
|
+
const eventTargets = [];
|
|
6307
|
+
if (selectorOrTarget === ":window") eventTargets.push(currentWin);
|
|
6308
|
+
else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
|
|
6309
|
+
else if (selectorOrTarget === ":parentHost") {
|
|
6310
|
+
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
6311
|
+
} else if (selectorOrTarget === ":appHost") {
|
|
6312
|
+
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
6313
|
+
} else if (selectorOrTarget === ":firstHost") {
|
|
6314
|
+
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
6315
|
+
} else if (selectorOrTarget === ":lastHost") {
|
|
6316
|
+
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
6317
|
+
} else if (selectorOrTarget === ":firstAppHost") {
|
|
6318
|
+
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
6319
|
+
} else if (selectorOrTarget === ":lastAppHost") {
|
|
6320
|
+
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
6321
|
+
} else if (selectorOrTarget === ":hosts") {
|
|
6322
|
+
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
6323
|
+
} else if (selectorOrTarget === ":appHosts") {
|
|
6324
|
+
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
6325
|
+
} else if (selectorOrTarget === ":host" || !selectorOrTarget) {
|
|
6326
|
+
eventTargets.push(this);
|
|
6327
|
+
} else {
|
|
6328
|
+
const r = fullOptions.root || "auto";
|
|
6329
|
+
const searchRoots = [];
|
|
6330
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
6331
|
+
else if (r === "light") searchRoots.push(this);
|
|
6332
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6333
|
+
else if (r === "all") {
|
|
6334
|
+
searchRoots.push(this);
|
|
6335
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6336
|
+
}
|
|
6337
|
+
searchRoots.forEach((sr) => {
|
|
6338
|
+
sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
|
|
6339
|
+
});
|
|
6330
6340
|
}
|
|
6331
|
-
|
|
6332
|
-
|
|
6341
|
+
eventTargets.forEach((t) => {
|
|
6342
|
+
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
6343
|
+
return;
|
|
6344
|
+
}
|
|
6345
|
+
t.dispatchEvent(event);
|
|
6333
6346
|
});
|
|
6347
|
+
return detail;
|
|
6348
|
+
};
|
|
6349
|
+
if (res instanceof Promise) {
|
|
6350
|
+
return res.then(handleResult);
|
|
6351
|
+
} else {
|
|
6352
|
+
return handleResult(res);
|
|
6334
6353
|
}
|
|
6335
|
-
eventTargets.forEach((t) => t.dispatchEvent(event));
|
|
6336
|
-
return detail;
|
|
6337
6354
|
};
|
|
6338
6355
|
};
|
|
6339
6356
|
}
|
|
@@ -6350,21 +6367,26 @@ function emitCustomEventHost(type, options = {}) {
|
|
|
6350
6367
|
|
|
6351
6368
|
// src/decorators/changedAttributeHost.ts
|
|
6352
6369
|
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
6353
|
-
|
|
6370
|
+
var convertValue = (val, type) => {
|
|
6371
|
+
if (val === null || val === void 0) return val;
|
|
6372
|
+
if (type === Number) return Number(val);
|
|
6373
|
+
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
6374
|
+
return val;
|
|
6375
|
+
};
|
|
6376
|
+
function changedAttributeHost(attributeName, options = {}) {
|
|
6354
6377
|
return (target, propertyKey) => {
|
|
6355
6378
|
const constructor = target.constructor;
|
|
6356
|
-
let
|
|
6357
|
-
if (!
|
|
6358
|
-
|
|
6359
|
-
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY,
|
|
6379
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6380
|
+
if (!metaList) {
|
|
6381
|
+
metaList = [];
|
|
6382
|
+
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
6360
6383
|
}
|
|
6361
6384
|
const name = attributeName || String(propertyKey);
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
}
|
|
6367
|
-
if (!methods.includes(propertyKey)) methods.push(propertyKey);
|
|
6385
|
+
metaList.push({
|
|
6386
|
+
attributeName: name,
|
|
6387
|
+
propertyKey,
|
|
6388
|
+
options
|
|
6389
|
+
});
|
|
6368
6390
|
};
|
|
6369
6391
|
}
|
|
6370
6392
|
var getChangedAttributeMetadata = (target) => {
|
|
@@ -6372,7 +6394,21 @@ var getChangedAttributeMetadata = (target) => {
|
|
|
6372
6394
|
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6373
6395
|
};
|
|
6374
6396
|
var findAllAttributeChangedMetadata = (target) => {
|
|
6375
|
-
|
|
6397
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
6398
|
+
const metaList = ReflectUtils.findAllMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
|
|
6399
|
+
const result = /* @__PURE__ */ new Map();
|
|
6400
|
+
metaList.forEach((meta) => {
|
|
6401
|
+
meta.forEach((item) => {
|
|
6402
|
+
if (!result.has(item.attributeName)) {
|
|
6403
|
+
result.set(item.attributeName, []);
|
|
6404
|
+
}
|
|
6405
|
+
result.get(item.attributeName).push(item);
|
|
6406
|
+
});
|
|
6407
|
+
});
|
|
6408
|
+
return result;
|
|
6409
|
+
};
|
|
6410
|
+
var convertAttributeValue = (val, type) => {
|
|
6411
|
+
return convertValue(val, type);
|
|
6376
6412
|
};
|
|
6377
6413
|
|
|
6378
6414
|
// src/decorators/applyAttribute.ts
|
|
@@ -6398,70 +6434,80 @@ function createAttributeDecorator(action) {
|
|
|
6398
6434
|
options: { ...finalOptions, name: attributeName }
|
|
6399
6435
|
});
|
|
6400
6436
|
const original = descriptor.value;
|
|
6401
|
-
descriptor.value =
|
|
6437
|
+
descriptor.value = function(...args) {
|
|
6402
6438
|
ensureInit(this);
|
|
6403
|
-
const res =
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6439
|
+
const res = original.apply(this, args);
|
|
6440
|
+
const handleResult = (resolvedValue) => {
|
|
6441
|
+
if (resolvedValue !== void 0) {
|
|
6442
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
6443
|
+
const host2 = this;
|
|
6444
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6445
|
+
const r = finalOptions.root || "auto";
|
|
6446
|
+
const targetEls = [];
|
|
6447
|
+
const applyRoot = (t) => {
|
|
6448
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6449
|
+
targetEls.push(t);
|
|
6450
|
+
};
|
|
6451
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6452
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6453
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6454
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6455
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6456
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6457
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6458
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6459
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6460
|
+
else {
|
|
6461
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6462
|
+
if (targetRoot) {
|
|
6463
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6464
|
+
if (found) targetEls.push(...Array.from(found));
|
|
6465
|
+
}
|
|
6428
6466
|
}
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6467
|
+
targetEls.forEach((targetEl) => {
|
|
6468
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
6469
|
+
return;
|
|
6470
|
+
}
|
|
6471
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
6472
|
+
if (action === "set" || action === "update") {
|
|
6473
|
+
if (attributeName) {
|
|
6474
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
6475
|
+
targetEl.removeAttribute(attributeName);
|
|
6476
|
+
} else {
|
|
6477
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
6478
|
+
}
|
|
6479
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6480
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6481
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6482
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6483
|
+
targetEl.removeAttribute(attr);
|
|
6484
|
+
} else {
|
|
6485
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6486
|
+
}
|
|
6487
|
+
});
|
|
6488
|
+
}
|
|
6489
|
+
} else if (action === "remove") {
|
|
6490
|
+
if (attributeName) {
|
|
6435
6491
|
targetEl.removeAttribute(attributeName);
|
|
6492
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6493
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6494
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
6495
|
+
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
6496
|
+
});
|
|
6436
6497
|
} else {
|
|
6437
|
-
|
|
6498
|
+
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6499
|
+
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
6438
6500
|
}
|
|
6439
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6440
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6441
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6442
|
-
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6443
|
-
targetEl.removeAttribute(attr);
|
|
6444
|
-
} else {
|
|
6445
|
-
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6446
|
-
}
|
|
6447
|
-
});
|
|
6448
|
-
}
|
|
6449
|
-
} else if (action === "remove") {
|
|
6450
|
-
if (attributeName) {
|
|
6451
|
-
targetEl.removeAttribute(attributeName);
|
|
6452
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6453
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6454
|
-
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
6455
|
-
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
6456
|
-
});
|
|
6457
|
-
} else {
|
|
6458
|
-
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6459
|
-
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
6460
6501
|
}
|
|
6461
|
-
}
|
|
6462
|
-
}
|
|
6502
|
+
});
|
|
6503
|
+
}
|
|
6504
|
+
return resolvedValue;
|
|
6505
|
+
};
|
|
6506
|
+
if (res instanceof Promise) {
|
|
6507
|
+
return res.then(handleResult);
|
|
6508
|
+
} else {
|
|
6509
|
+
return handleResult(res);
|
|
6463
6510
|
}
|
|
6464
|
-
return res;
|
|
6465
6511
|
};
|
|
6466
6512
|
return descriptor;
|
|
6467
6513
|
};
|
|
@@ -7759,7 +7805,7 @@ var handleGlobalSwcEvent = async (event) => {
|
|
|
7759
7805
|
}
|
|
7760
7806
|
};
|
|
7761
7807
|
function buildEnv(configWindow) {
|
|
7762
|
-
const win = configWindow
|
|
7808
|
+
const win = configWindow;
|
|
7763
7809
|
const doc = win?.document;
|
|
7764
7810
|
const builtInTagMap = /* @__PURE__ */ new Map();
|
|
7765
7811
|
for (const [cls, tag] of HTML_TAG_ENTRIES) {
|
|
@@ -7798,7 +7844,7 @@ var setupPrototype = (proto) => {
|
|
|
7798
7844
|
const aConf = getElementConfig(ancestors[i]);
|
|
7799
7845
|
if (aConf?.window) return aConf.window;
|
|
7800
7846
|
}
|
|
7801
|
-
return typeof window !== "undefined" ? window : void 0;
|
|
7847
|
+
return getElementConfig(this).window ?? (typeof window !== "undefined" ? window : void 0);
|
|
7802
7848
|
};
|
|
7803
7849
|
proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
|
|
7804
7850
|
ensureInit(this);
|
|
@@ -7900,8 +7946,11 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7900
7946
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
7901
7947
|
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
7902
7948
|
const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
|
|
7949
|
+
const proto = constructor.prototype;
|
|
7950
|
+
const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
|
|
7903
7951
|
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
|
|
7904
7952
|
...metadata.observedAttributes ?? [],
|
|
7953
|
+
...originalStaticObservedAttributes,
|
|
7905
7954
|
...attrChangeMap.keys(),
|
|
7906
7955
|
...attributeApplyNames,
|
|
7907
7956
|
...hostAttributes,
|
|
@@ -7910,7 +7959,6 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7910
7959
|
...swcOnEvents
|
|
7911
7960
|
])];
|
|
7912
7961
|
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
7913
|
-
const proto = constructor.prototype;
|
|
7914
7962
|
setupPrototype(proto);
|
|
7915
7963
|
const originalConnected = proto.connectedCallback;
|
|
7916
7964
|
proto.connectedCallback = function() {
|
|
@@ -7919,8 +7967,10 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7919
7967
|
const appHost2 = hostSet.$appHost;
|
|
7920
7968
|
const conf = getElementConfig(this);
|
|
7921
7969
|
const currentWin = this._resolveWindow(conf);
|
|
7922
|
-
|
|
7923
|
-
|
|
7970
|
+
const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
|
|
7971
|
+
if (shadowMode && !this.shadowRoot) {
|
|
7972
|
+
const mode = shadowMode === true ? "open" : shadowMode;
|
|
7973
|
+
this.attachShadow({ mode });
|
|
7924
7974
|
}
|
|
7925
7975
|
this._executeSwcScript("swc-on-before-connected", hostSet);
|
|
7926
7976
|
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
@@ -7932,12 +7982,16 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7932
7982
|
for (const meta of connectedInnerHtmlList) {
|
|
7933
7983
|
const res = this._invokeLifecycleMethod(meta.propertyKey, hostSet);
|
|
7934
7984
|
if (res !== void 0) {
|
|
7935
|
-
if (meta.options.useShadow) sContent += res;
|
|
7985
|
+
if (meta.options.useShadow || conf?.useShadow) sContent += res;
|
|
7936
7986
|
else lContent += res;
|
|
7937
7987
|
}
|
|
7938
7988
|
}
|
|
7939
|
-
|
|
7940
|
-
|
|
7989
|
+
try {
|
|
7990
|
+
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
7991
|
+
if (lContent) this.innerHTML = lContent;
|
|
7992
|
+
} catch (e) {
|
|
7993
|
+
console.error("[ElementDefine] innerHTML setting error:", e);
|
|
7994
|
+
}
|
|
7941
7995
|
}
|
|
7942
7996
|
const root = this.getRootNode();
|
|
7943
7997
|
if (!globalDelegatedRoots.has(root)) {
|
|
@@ -8049,7 +8103,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8049
8103
|
const handler = async (event) => {
|
|
8050
8104
|
if (options.filter) {
|
|
8051
8105
|
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
8052
|
-
if (!options.filter(event, helper)) {
|
|
8106
|
+
if (!options.filter(event, { currentThis: this, helper })) {
|
|
8053
8107
|
return;
|
|
8054
8108
|
}
|
|
8055
8109
|
}
|
|
@@ -8133,15 +8187,17 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8133
8187
|
const expr = ae.getFirstExpression("call-return");
|
|
8134
8188
|
if (expr) {
|
|
8135
8189
|
const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
|
|
8190
|
+
const helperAndHostSet = SwcUtils.getHelperAndHostSet(win2, this);
|
|
8136
8191
|
try {
|
|
8192
|
+
const script = ConvertUtils2.decodeHtmlEntity(expr.script, win2.document);
|
|
8137
8193
|
const result = FunctionUtils.executeReturn({
|
|
8138
|
-
script
|
|
8194
|
+
script,
|
|
8139
8195
|
context: this,
|
|
8140
|
-
args:
|
|
8196
|
+
args: helperAndHostSet
|
|
8141
8197
|
});
|
|
8142
|
-
processedVal =
|
|
8198
|
+
processedVal = result;
|
|
8143
8199
|
} catch (e) {
|
|
8144
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}
|
|
8200
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}: ${helperAndHostSet}`, e);
|
|
8145
8201
|
processedVal = newVal;
|
|
8146
8202
|
}
|
|
8147
8203
|
}
|
|
@@ -8156,9 +8212,12 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8156
8212
|
if (hostCustomEventMeta && newVal !== null) {
|
|
8157
8213
|
this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
|
|
8158
8214
|
}
|
|
8159
|
-
const
|
|
8160
|
-
if (
|
|
8161
|
-
for (const
|
|
8215
|
+
const metaList = attrChangeMap.get(name2);
|
|
8216
|
+
if (metaList && Array.isArray(metaList)) {
|
|
8217
|
+
for (const meta of metaList) {
|
|
8218
|
+
const convertedVal = convertAttributeValue(processedVal, meta.options.type);
|
|
8219
|
+
this[meta.propertyKey](convertedVal, old, name2, hSet);
|
|
8220
|
+
}
|
|
8162
8221
|
}
|
|
8163
8222
|
};
|
|
8164
8223
|
Object.defineProperty(constructor, "observedAttributes", {
|
|
@@ -8175,12 +8234,38 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8175
8234
|
|
|
8176
8235
|
// src/decorators/attribute.ts
|
|
8177
8236
|
var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
|
|
8178
|
-
var
|
|
8237
|
+
var convertValue2 = (val, type) => {
|
|
8179
8238
|
if (val === null || val === void 0) return val;
|
|
8180
8239
|
if (type === Number) return Number(val);
|
|
8181
8240
|
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
8182
8241
|
return val;
|
|
8183
8242
|
};
|
|
8243
|
+
var getAttributeValue = (inst, attrName, options) => {
|
|
8244
|
+
const conf = getElementConfig(inst);
|
|
8245
|
+
const currentWin = inst._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8246
|
+
const targets = options?.selector ? resolveTargetEls(inst, options.selector, options, currentWin) : [inst];
|
|
8247
|
+
const primaryTarget = targets[0];
|
|
8248
|
+
if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
|
|
8249
|
+
let domVal = primaryTarget.getAttribute(attrName);
|
|
8250
|
+
const ae = new ActionExpression(domVal);
|
|
8251
|
+
const expr = ae.getFirstExpression("call-return");
|
|
8252
|
+
if (expr) {
|
|
8253
|
+
try {
|
|
8254
|
+
const result = FunctionUtils.executeReturn({
|
|
8255
|
+
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8256
|
+
context: inst,
|
|
8257
|
+
args: SwcUtils.getHelperAndHostSet(currentWin, inst)
|
|
8258
|
+
});
|
|
8259
|
+
return convertValue2(result, options?.type);
|
|
8260
|
+
} catch (e) {
|
|
8261
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8262
|
+
return convertValue2(domVal, options?.type);
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
return convertValue2(domVal, options?.type);
|
|
8266
|
+
}
|
|
8267
|
+
return null;
|
|
8268
|
+
};
|
|
8184
8269
|
var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
8185
8270
|
const r = options.root || "auto";
|
|
8186
8271
|
const results = [];
|
|
@@ -8255,35 +8340,13 @@ function attribute(selector, options = {}) {
|
|
|
8255
8340
|
Object.defineProperty(target, propertyKey, {
|
|
8256
8341
|
get() {
|
|
8257
8342
|
const attrName = options.name || String(propertyKey);
|
|
8258
|
-
const
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
let domVal = primaryTarget.getAttribute(attrName);
|
|
8266
|
-
const ae = new ActionExpression(domVal);
|
|
8267
|
-
const expr = ae.getFirstExpression("call-return");
|
|
8268
|
-
if (expr) {
|
|
8269
|
-
try {
|
|
8270
|
-
const result = FunctionUtils.executeReturn({
|
|
8271
|
-
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8272
|
-
context: this,
|
|
8273
|
-
args: SwcUtils.getHelperAndHostSet(currentWin, this)
|
|
8274
|
-
});
|
|
8275
|
-
return convertValue(result, targetType);
|
|
8276
|
-
} catch (e) {
|
|
8277
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8278
|
-
return convertValue(domVal, targetType);
|
|
8279
|
-
}
|
|
8280
|
-
}
|
|
8281
|
-
return convertValue(domVal, targetType);
|
|
8282
|
-
}
|
|
8283
|
-
return null;
|
|
8284
|
-
}
|
|
8285
|
-
const data = convertValue(this[privateKey], targetType);
|
|
8286
|
-
return data;
|
|
8343
|
+
const mergedOptions = {
|
|
8344
|
+
...options,
|
|
8345
|
+
selector,
|
|
8346
|
+
type: options.type || designType
|
|
8347
|
+
};
|
|
8348
|
+
const result = getAttributeValue(this, attrName, mergedOptions);
|
|
8349
|
+
return result !== null ? result : this[privateKey];
|
|
8287
8350
|
},
|
|
8288
8351
|
set(nv) {
|
|
8289
8352
|
const attrName = options.name || String(propertyKey);
|
|
@@ -8396,14 +8459,7 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
|
8396
8459
|
const res = original.apply(this, args);
|
|
8397
8460
|
const runApply = (target, val) => {
|
|
8398
8461
|
const pos = options.position || "beforeEnd";
|
|
8399
|
-
|
|
8400
|
-
if (v instanceof Node) return !t.contains(v);
|
|
8401
|
-
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
8402
|
-
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
8403
|
-
return true;
|
|
8404
|
-
};
|
|
8405
|
-
const activeFilter = options.filter || defaultFilter;
|
|
8406
|
-
if (activeFilter(target, val, hostSet)) {
|
|
8462
|
+
if (!options.filter || options.filter(target, val, { currentThis: this, helper: hostSet })) {
|
|
8407
8463
|
applyToDom(target, val, pos, currentDoc);
|
|
8408
8464
|
}
|
|
8409
8465
|
};
|
|
@@ -8475,81 +8531,91 @@ function createClassDecorator(action) {
|
|
|
8475
8531
|
}
|
|
8476
8532
|
metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
|
|
8477
8533
|
const original = descriptor.value;
|
|
8478
|
-
descriptor.value =
|
|
8534
|
+
descriptor.value = function(...args) {
|
|
8479
8535
|
ensureInit(this);
|
|
8480
|
-
const res =
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
}
|
|
8507
|
-
targetEls.forEach((targetEl) => {
|
|
8508
|
-
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
8509
|
-
if (action === "set") {
|
|
8510
|
-
let classes = "";
|
|
8511
|
-
if (classMap && typeof classMap === "string") {
|
|
8512
|
-
classes = resolvedRes ? classMap : "";
|
|
8513
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8514
|
-
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8515
|
-
} else {
|
|
8516
|
-
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8536
|
+
const res = original.apply(this, args);
|
|
8537
|
+
const handleResult = (resolvedValue) => {
|
|
8538
|
+
if (resolvedValue !== void 0) {
|
|
8539
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8540
|
+
const host2 = this;
|
|
8541
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8542
|
+
const r = finalOptions.root || "auto";
|
|
8543
|
+
const targetEls = [];
|
|
8544
|
+
const applyRoot = (t) => {
|
|
8545
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8546
|
+
targetEls.push(t);
|
|
8547
|
+
};
|
|
8548
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8549
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8550
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8551
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8552
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8553
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8554
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8555
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8556
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8557
|
+
else {
|
|
8558
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8559
|
+
if (targetRoot) {
|
|
8560
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8561
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8517
8562
|
}
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
if (
|
|
8521
|
-
|
|
8522
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8523
|
-
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8524
|
-
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8525
|
-
targetEl.classList.toggle(cls, isActive);
|
|
8526
|
-
});
|
|
8527
|
-
} else {
|
|
8528
|
-
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8529
|
-
if (action === "update") targetEl.classList.add(...classes);
|
|
8530
|
-
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8563
|
+
}
|
|
8564
|
+
targetEls.forEach((targetEl) => {
|
|
8565
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8566
|
+
return;
|
|
8531
8567
|
}
|
|
8532
|
-
|
|
8533
|
-
if (
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
if (
|
|
8547
|
-
|
|
8568
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8569
|
+
if (action === "set") {
|
|
8570
|
+
let classes = "";
|
|
8571
|
+
if (classMap && typeof classMap === "string") {
|
|
8572
|
+
classes = resolvedRes ? classMap : "";
|
|
8573
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8574
|
+
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8575
|
+
} else {
|
|
8576
|
+
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8577
|
+
}
|
|
8578
|
+
targetEl.className = classes;
|
|
8579
|
+
} else if (action === "update" || action === "toggle") {
|
|
8580
|
+
if (classMap && typeof classMap === "string") {
|
|
8581
|
+
targetEl.classList.toggle(classMap, !!resolvedRes);
|
|
8582
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8583
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8584
|
+
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8585
|
+
targetEl.classList.toggle(cls, isActive);
|
|
8586
|
+
});
|
|
8587
|
+
} else {
|
|
8588
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8589
|
+
if (action === "update") targetEl.classList.add(...classes);
|
|
8590
|
+
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8591
|
+
}
|
|
8592
|
+
} else if (action === "add" || action === "remove") {
|
|
8593
|
+
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
8594
|
+
if (action === "add") targetEl.classList.add(classMap);
|
|
8595
|
+
else targetEl.classList.remove(classMap);
|
|
8596
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8597
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8598
|
+
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8599
|
+
if (shouldExecute) {
|
|
8600
|
+
if (action === "add") targetEl.classList.add(cls);
|
|
8601
|
+
else targetEl.classList.remove(cls);
|
|
8602
|
+
}
|
|
8603
|
+
});
|
|
8604
|
+
} else {
|
|
8605
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8606
|
+
if (action === "add") targetEl.classList.add(...classes);
|
|
8607
|
+
else targetEl.classList.remove(...classes);
|
|
8608
|
+
}
|
|
8548
8609
|
}
|
|
8549
|
-
}
|
|
8550
|
-
}
|
|
8610
|
+
});
|
|
8611
|
+
}
|
|
8612
|
+
return resolvedValue;
|
|
8613
|
+
};
|
|
8614
|
+
if (res instanceof Promise) {
|
|
8615
|
+
return res.then(handleResult);
|
|
8616
|
+
} else {
|
|
8617
|
+
return handleResult(res);
|
|
8551
8618
|
}
|
|
8552
|
-
return res;
|
|
8553
8619
|
};
|
|
8554
8620
|
return descriptor;
|
|
8555
8621
|
};
|
|
@@ -8595,67 +8661,77 @@ function createStyleDecorator(action) {
|
|
|
8595
8661
|
}
|
|
8596
8662
|
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
8597
8663
|
const original = descriptor.value;
|
|
8598
|
-
descriptor.value =
|
|
8664
|
+
descriptor.value = function(...args) {
|
|
8599
8665
|
ensureInit(this);
|
|
8600
|
-
const res =
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8666
|
+
const res = original.apply(this, args);
|
|
8667
|
+
const handleResult = (resolvedValue) => {
|
|
8668
|
+
if (resolvedValue !== void 0) {
|
|
8669
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8670
|
+
const host2 = this;
|
|
8671
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, host2);
|
|
8672
|
+
const r = options.root || "auto";
|
|
8673
|
+
const targetEls = [];
|
|
8674
|
+
const applyRoot = (t) => {
|
|
8675
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8676
|
+
targetEls.push(t);
|
|
8677
|
+
};
|
|
8678
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8679
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8680
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8681
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8682
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8683
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8684
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8685
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8686
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8687
|
+
else {
|
|
8688
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8689
|
+
if (targetRoot) {
|
|
8690
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8691
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8692
|
+
}
|
|
8625
8693
|
}
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
if (action === "set" || action === "update") {
|
|
8630
|
-
if (action === "set") targetEl.style.cssText = "";
|
|
8631
|
-
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8632
|
-
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8633
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8634
|
-
if (finalVal === null || finalVal === void 0) {
|
|
8635
|
-
targetEl.style.removeProperty(prop);
|
|
8636
|
-
} else {
|
|
8637
|
-
targetEl.style[prop] = String(finalVal);
|
|
8638
|
-
}
|
|
8639
|
-
});
|
|
8640
|
-
} else if (typeof resolvedRes === "string") {
|
|
8641
|
-
targetEl.style.cssText = resolvedRes;
|
|
8694
|
+
targetEls.forEach((targetEl) => {
|
|
8695
|
+
if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8696
|
+
return;
|
|
8642
8697
|
}
|
|
8643
|
-
|
|
8644
|
-
if (
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
targetEl
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8698
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8699
|
+
if (action === "set" || action === "update") {
|
|
8700
|
+
if (action === "set") targetEl.style.cssText = "";
|
|
8701
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8702
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8703
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8704
|
+
if (finalVal === null || finalVal === void 0) {
|
|
8705
|
+
targetEl.style.removeProperty(prop);
|
|
8706
|
+
} else {
|
|
8707
|
+
targetEl.style[prop] = String(finalVal);
|
|
8708
|
+
}
|
|
8709
|
+
});
|
|
8710
|
+
} else if (typeof resolvedRes === "string") {
|
|
8711
|
+
targetEl.style.cssText = resolvedRes;
|
|
8712
|
+
}
|
|
8713
|
+
} else if (action === "remove") {
|
|
8714
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8715
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8716
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
8717
|
+
if (shouldRemove) {
|
|
8718
|
+
targetEl.style.removeProperty(prop);
|
|
8719
|
+
}
|
|
8720
|
+
});
|
|
8721
|
+
} else {
|
|
8722
|
+
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
8723
|
+
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
8724
|
+
}
|
|
8654
8725
|
}
|
|
8655
|
-
}
|
|
8656
|
-
}
|
|
8726
|
+
});
|
|
8727
|
+
}
|
|
8728
|
+
return resolvedValue;
|
|
8729
|
+
};
|
|
8730
|
+
if (res instanceof Promise) {
|
|
8731
|
+
return res.then(handleResult);
|
|
8732
|
+
} else {
|
|
8733
|
+
return handleResult(res);
|
|
8657
8734
|
}
|
|
8658
|
-
return res;
|
|
8659
8735
|
};
|
|
8660
8736
|
return descriptor;
|
|
8661
8737
|
};
|
|
@@ -8705,48 +8781,59 @@ var setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
|
8705
8781
|
options: { ...finalOptions, name: propertyName }
|
|
8706
8782
|
});
|
|
8707
8783
|
const original = descriptor.value;
|
|
8708
|
-
descriptor.value =
|
|
8784
|
+
descriptor.value = function(...args) {
|
|
8709
8785
|
ensureInit(this);
|
|
8710
|
-
const res =
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8786
|
+
const res = original.apply(this, args);
|
|
8787
|
+
const handleResult = (resolvedValue) => {
|
|
8788
|
+
if (resolvedValue !== void 0) {
|
|
8789
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8790
|
+
const host2 = this;
|
|
8791
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8792
|
+
const r = finalOptions.root || "auto";
|
|
8793
|
+
const targetEls = [];
|
|
8794
|
+
const applyRoot = (t) => {
|
|
8795
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8796
|
+
targetEls.push(t);
|
|
8797
|
+
};
|
|
8798
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8799
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8800
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8801
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8802
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8803
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8804
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8805
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8806
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8807
|
+
else {
|
|
8808
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8809
|
+
if (targetRoot) {
|
|
8810
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8811
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8812
|
+
}
|
|
8735
8813
|
}
|
|
8814
|
+
targetEls.forEach((targetEl) => {
|
|
8815
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8816
|
+
return;
|
|
8817
|
+
}
|
|
8818
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8819
|
+
if (propertyName) {
|
|
8820
|
+
targetEl[propertyName] = resolvedRes;
|
|
8821
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8822
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8823
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8824
|
+
targetEl[prop] = finalVal;
|
|
8825
|
+
});
|
|
8826
|
+
} else {
|
|
8827
|
+
targetEl.value = resolvedRes;
|
|
8828
|
+
}
|
|
8829
|
+
});
|
|
8736
8830
|
}
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8744
|
-
targetEl[prop] = finalVal;
|
|
8745
|
-
});
|
|
8746
|
-
} else {
|
|
8747
|
-
targetEl.value = resolvedRes;
|
|
8748
|
-
}
|
|
8749
|
-
});
|
|
8831
|
+
return resolvedValue;
|
|
8832
|
+
};
|
|
8833
|
+
if (res instanceof Promise) {
|
|
8834
|
+
return res.then(handleResult);
|
|
8835
|
+
} else {
|
|
8836
|
+
return handleResult(res);
|
|
8750
8837
|
}
|
|
8751
8838
|
};
|
|
8752
8839
|
};
|
|
@@ -8755,25 +8842,25 @@ var setPropertyHost = (propertyNameOrOptions, options = {}) => {
|
|
|
8755
8842
|
return setProperty(":host", propertyNameOrOptions, options);
|
|
8756
8843
|
};
|
|
8757
8844
|
|
|
8758
|
-
// src/decorators/
|
|
8759
|
-
var
|
|
8760
|
-
function
|
|
8845
|
+
// src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts
|
|
8846
|
+
var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change-while-connected");
|
|
8847
|
+
function createSubscribeSwcAppRouteChangeWhileConnected(options) {
|
|
8761
8848
|
return (target, propertyKey, descriptor) => {
|
|
8762
8849
|
const pathPattern = options?.path;
|
|
8763
8850
|
const filter = options?.filter;
|
|
8764
8851
|
const constructor = target.constructor;
|
|
8765
|
-
let list = ReflectUtils.getOwnMetadata(
|
|
8852
|
+
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
8766
8853
|
if (!list) {
|
|
8767
8854
|
list = [];
|
|
8768
|
-
ReflectUtils.defineMetadata(
|
|
8855
|
+
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
8769
8856
|
}
|
|
8770
8857
|
list.push({ propertyKey, pathPattern, filter });
|
|
8771
8858
|
return descriptor;
|
|
8772
8859
|
};
|
|
8773
8860
|
}
|
|
8774
|
-
function
|
|
8861
|
+
function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKey, descriptor) {
|
|
8775
8862
|
if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
8776
|
-
return
|
|
8863
|
+
return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);
|
|
8777
8864
|
}
|
|
8778
8865
|
let options = {};
|
|
8779
8866
|
if (Array.isArray(targetOrOptions)) {
|
|
@@ -8783,11 +8870,110 @@ function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
|
|
|
8783
8870
|
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
8784
8871
|
options = targetOrOptions;
|
|
8785
8872
|
}
|
|
8786
|
-
return
|
|
8873
|
+
return createSubscribeSwcAppRouteChangeWhileConnected(options);
|
|
8874
|
+
}
|
|
8875
|
+
var getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
|
|
8876
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
8877
|
+
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
8878
|
+
};
|
|
8879
|
+
|
|
8880
|
+
// src/decorators/subscribeSwcAppMessageWhileConnected.ts
|
|
8881
|
+
var SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-message-while-connected");
|
|
8882
|
+
function createSubscribeSwcAppMessageWhileConnected(options, messageType) {
|
|
8883
|
+
return (target, propertyKey, descriptor) => {
|
|
8884
|
+
const filter = options?.filter;
|
|
8885
|
+
const constructor = target.constructor;
|
|
8886
|
+
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
8887
|
+
if (!list) {
|
|
8888
|
+
list = [];
|
|
8889
|
+
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
8890
|
+
}
|
|
8891
|
+
list.push({ propertyKey, messageType, filter });
|
|
8892
|
+
return descriptor;
|
|
8893
|
+
};
|
|
8894
|
+
}
|
|
8895
|
+
function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, optionsOrPropertyKey, descriptor) {
|
|
8896
|
+
if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && optionsOrPropertyKey && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol") && descriptor) {
|
|
8897
|
+
const target = targetOrMessageTypeOrOptions;
|
|
8898
|
+
const propertyKey = optionsOrPropertyKey;
|
|
8899
|
+
return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);
|
|
8900
|
+
}
|
|
8901
|
+
let messageType;
|
|
8902
|
+
let options = {};
|
|
8903
|
+
if (typeof targetOrMessageTypeOrOptions === "string") {
|
|
8904
|
+
messageType = targetOrMessageTypeOrOptions;
|
|
8905
|
+
if (optionsOrPropertyKey && typeof optionsOrPropertyKey === "object") {
|
|
8906
|
+
options = optionsOrPropertyKey;
|
|
8907
|
+
}
|
|
8908
|
+
} else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object") {
|
|
8909
|
+
options = targetOrMessageTypeOrOptions;
|
|
8910
|
+
}
|
|
8911
|
+
return createSubscribeSwcAppMessageWhileConnected(options, messageType);
|
|
8912
|
+
}
|
|
8913
|
+
var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
|
|
8914
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
8915
|
+
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
8916
|
+
};
|
|
8917
|
+
|
|
8918
|
+
// src/decorators/publishSwcAppMessage.ts
|
|
8919
|
+
var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
|
|
8920
|
+
function createPublishSwcAppMessage(messageType) {
|
|
8921
|
+
return (target, propertyKey, descriptor) => {
|
|
8922
|
+
const constructor = target.constructor;
|
|
8923
|
+
let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
8924
|
+
if (!list) {
|
|
8925
|
+
list = [];
|
|
8926
|
+
ReflectUtils.defineMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);
|
|
8927
|
+
}
|
|
8928
|
+
list.push({ propertyKey, messageType });
|
|
8929
|
+
if (!descriptor) {
|
|
8930
|
+
return descriptor;
|
|
8931
|
+
}
|
|
8932
|
+
const originalMethod = descriptor.value;
|
|
8933
|
+
descriptor.value = function(...args) {
|
|
8934
|
+
const result = originalMethod.apply(this, args);
|
|
8935
|
+
if (result instanceof Promise) {
|
|
8936
|
+
result.then((data) => {
|
|
8937
|
+
const appHost2 = SwcUtils.getAppHost(this);
|
|
8938
|
+
if (appHost2) {
|
|
8939
|
+
appHost2.publishMessage({
|
|
8940
|
+
publisher: this,
|
|
8941
|
+
data,
|
|
8942
|
+
type: messageType
|
|
8943
|
+
});
|
|
8944
|
+
}
|
|
8945
|
+
}).catch((err) => {
|
|
8946
|
+
console.warn("publishSwcAppMessage async error:", err);
|
|
8947
|
+
});
|
|
8948
|
+
} else {
|
|
8949
|
+
const appHost2 = SwcUtils.getAppHost(this);
|
|
8950
|
+
if (appHost2) {
|
|
8951
|
+
appHost2.publishMessage({
|
|
8952
|
+
publisher: this,
|
|
8953
|
+
data: result,
|
|
8954
|
+
type: messageType
|
|
8955
|
+
});
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
return result;
|
|
8959
|
+
};
|
|
8960
|
+
return descriptor;
|
|
8961
|
+
};
|
|
8962
|
+
}
|
|
8963
|
+
function publishSwcAppMessage(targetOrMessageType, propertyKey, descriptor) {
|
|
8964
|
+
if (targetOrMessageType && typeof targetOrMessageType === "object" && propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol") && descriptor) {
|
|
8965
|
+
const target = targetOrMessageType;
|
|
8966
|
+
return createPublishSwcAppMessage()(target, propertyKey, descriptor);
|
|
8967
|
+
}
|
|
8968
|
+
let messageType;
|
|
8969
|
+
if (typeof targetOrMessageType === "string") {
|
|
8970
|
+
messageType = targetOrMessageType;
|
|
8971
|
+
}
|
|
8972
|
+
return createPublishSwcAppMessage(messageType);
|
|
8787
8973
|
}
|
|
8788
|
-
var
|
|
8974
|
+
var getPublishSwcAppMessageMetadata = (target) => {
|
|
8789
8975
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
8790
|
-
return ReflectUtils.getOwnMetadata(
|
|
8976
|
+
return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
8791
8977
|
};
|
|
8792
8978
|
|
|
8793
8979
|
// ../simple-boot/dist/esm/decorators/SimDecorator.js
|
|
@@ -8850,10 +9036,12 @@ export {
|
|
|
8850
9036
|
ON_CONNECTED_SWC_APP_METADATA_KEY,
|
|
8851
9037
|
ON_INITIALIZE_METADATA_KEY,
|
|
8852
9038
|
PROPERTY_SET_METADATA_KEY,
|
|
9039
|
+
PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
|
|
8853
9040
|
QUERY_ALL_METADATA_KEY,
|
|
8854
9041
|
QUERY_METADATA_KEY,
|
|
8855
9042
|
STYLE_METADATA_KEY,
|
|
8856
|
-
|
|
9043
|
+
SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
|
|
9044
|
+
SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY,
|
|
8857
9045
|
SWC_NOT_FOUND,
|
|
8858
9046
|
SwcUtils,
|
|
8859
9047
|
addClass,
|
|
@@ -8885,6 +9073,8 @@ export {
|
|
|
8885
9073
|
attributeHost,
|
|
8886
9074
|
changedAttributeHost,
|
|
8887
9075
|
commentNode,
|
|
9076
|
+
convertAttributeValue,
|
|
9077
|
+
convertValue2 as convertValue,
|
|
8888
9078
|
createElement,
|
|
8889
9079
|
elementDefine,
|
|
8890
9080
|
emitCustomEvent,
|
|
@@ -8900,13 +9090,16 @@ export {
|
|
|
8900
9090
|
firstAppHost,
|
|
8901
9091
|
firstHost,
|
|
8902
9092
|
getAddEventListenerMetadata,
|
|
9093
|
+
getAttributeValue,
|
|
8903
9094
|
getChangedAttributeMetadata,
|
|
8904
9095
|
getElementConfig,
|
|
8905
9096
|
getEmitCustomEventMetadataList,
|
|
8906
9097
|
getOnConnectedInnerHtmlMetadata,
|
|
9098
|
+
getPublishSwcAppMessageMetadata,
|
|
8907
9099
|
getQueryAllMetadata,
|
|
8908
9100
|
getQueryMetadata,
|
|
8909
|
-
|
|
9101
|
+
getSubscribeSwcAppMessageWhileConnectedMetadata,
|
|
9102
|
+
getSubscribeSwcAppRouteChangeWhileConnectedMetadata,
|
|
8910
9103
|
host,
|
|
8911
9104
|
htmlAElement,
|
|
8912
9105
|
htmlArticleElement,
|
|
@@ -8935,6 +9128,7 @@ export {
|
|
|
8935
9128
|
onDisconnected,
|
|
8936
9129
|
onInitialize,
|
|
8937
9130
|
parentHost,
|
|
9131
|
+
publishSwcAppMessage,
|
|
8938
9132
|
query,
|
|
8939
9133
|
queryAll,
|
|
8940
9134
|
queryAllHost,
|
|
@@ -8954,7 +9148,8 @@ export {
|
|
|
8954
9148
|
setPropertyHost,
|
|
8955
9149
|
setStyle,
|
|
8956
9150
|
setStyleHost,
|
|
8957
|
-
|
|
9151
|
+
subscribeSwcAppMessageWhileConnected,
|
|
9152
|
+
subscribeSwcAppRouteChangeWhileConnected,
|
|
8958
9153
|
textNode,
|
|
8959
9154
|
toggleClass,
|
|
8960
9155
|
toggleClassHost,
|