@dooboostore/simple-web-component 1.0.38 → 1.0.40
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/LICENSE.md +7 -0
- package/README.md +88 -871
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +194 -111
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +82 -80
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +213 -0
- package/dist/cjs/decorators/applyProperty.js.map +7 -0
- package/dist/cjs/decorators/applySlot.js +93 -82
- package/dist/cjs/decorators/applySlot.js.map +3 -3
- package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
- package/dist/cjs/decorators/elementDefine.js +14 -34
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -2
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +4 -4
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/state.js +0 -1
- package/dist/cjs/decorators/state.js.map +2 -2
- package/dist/cjs/elements/SwcApp.js.map +2 -2
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +196 -113
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +82 -80
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +194 -0
- package/dist/esm/decorators/applyProperty.js.map +7 -0
- package/dist/esm/decorators/applySlot.js +93 -82
- package/dist/esm/decorators/applySlot.js.map +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
- package/dist/esm/decorators/elementDefine.js +14 -34
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -2
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/lifecycles.js +4 -4
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/state.js +0 -1
- package/dist/esm/decorators/state.js.map +2 -2
- package/dist/esm/elements/SwcApp.js.map +2 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +525 -513
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +56 -15
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +28 -24
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +61 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -0
- package/dist/types/decorators/applySlot.d.ts +17 -15
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -2
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +4 -4
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/state.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -6
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +525 -513
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +1 -1
- package/src/SwcAppEngine.ts +1 -0
- package/src/decorators/applyAttribute.ts +311 -126
- package/src/decorators/applyNode.ts +108 -105
- package/src/decorators/applyProperty.ts +302 -0
- package/src/decorators/applySlot.ts +112 -94
- package/src/decorators/changedAttributeThis.ts +1 -1
- package/src/decorators/elementDefine.ts +44 -33
- package/src/decorators/index.ts +2 -3
- package/src/decorators/lifecycles.ts +6 -6
- package/src/decorators/state.ts +0 -1
- package/src/elements/SwcApp.ts +0 -1
- package/src/types/index.ts +7 -7
- package/dist/cjs/decorators/attribute.js +0 -187
- package/dist/cjs/decorators/attribute.js.map +0 -7
- package/dist/cjs/decorators/setProperty.js +0 -109
- package/dist/cjs/decorators/setProperty.js.map +0 -7
- package/dist/esm/decorators/attribute.js +0 -168
- package/dist/esm/decorators/attribute.js.map +0 -7
- package/dist/esm/decorators/setProperty.js +0 -90
- package/dist/esm/decorators/setProperty.js.map +0 -7
- package/dist/types/decorators/attribute.d.ts +0 -31
- package/dist/types/decorators/attribute.d.ts.map +0 -1
- package/dist/types/decorators/setProperty.d.ts +0 -17
- package/dist/types/decorators/setProperty.d.ts.map +0 -1
- package/src/decorators/attribute.ts +0 -223
- package/src/decorators/setProperty.ts +0 -112
|
@@ -4212,8 +4212,8 @@ var ConvertUtils;
|
|
|
4212
4212
|
}
|
|
4213
4213
|
}
|
|
4214
4214
|
if (ValidUtils.isObject(obj)) {
|
|
4215
|
-
for (const
|
|
4216
|
-
obj[
|
|
4215
|
+
for (const property2 in obj) {
|
|
4216
|
+
obj[property2] = ConvertUtils22.toObject(obj[property2]);
|
|
4217
4217
|
}
|
|
4218
4218
|
}
|
|
4219
4219
|
return obj;
|
|
@@ -4247,10 +4247,10 @@ var ConvertUtils;
|
|
|
4247
4247
|
};
|
|
4248
4248
|
ConvertUtils22.concatenateToString = (object_o, unionString_s = "=", spilString_s = " ", pairString_s = "") => {
|
|
4249
4249
|
const results = [];
|
|
4250
|
-
for (const
|
|
4251
|
-
const value = object_o[
|
|
4250
|
+
for (const property2 in object_o) {
|
|
4251
|
+
const value = object_o[property2];
|
|
4252
4252
|
if (value) {
|
|
4253
|
-
results.push(
|
|
4253
|
+
results.push(property2.toString() + unionString_s + pairString_s + value + pairString_s);
|
|
4254
4254
|
}
|
|
4255
4255
|
}
|
|
4256
4256
|
return results.join(spilString_s);
|
|
@@ -5993,9 +5993,9 @@ var ReflectUtils;
|
|
|
5993
5993
|
// ../core/dist/esm/function/FunctionUtils.js
|
|
5994
5994
|
var FunctionUtils;
|
|
5995
5995
|
((FunctionUtils2) => {
|
|
5996
|
-
FunctionUtils2.getParameterNames = (func,
|
|
5997
|
-
if (typeof func === "object" &&
|
|
5998
|
-
func = func[
|
|
5996
|
+
FunctionUtils2.getParameterNames = (func, property2) => {
|
|
5997
|
+
if (typeof func === "object" && property2) {
|
|
5998
|
+
func = func[property2];
|
|
5999
5999
|
}
|
|
6000
6000
|
return new RegExp("(?:" + func.name + "\\s*|^)\\s*\\((.*?)\\)").exec(func.toString().replace(/\n/g, ""))?.[1].replace(/\/\*.*?\*\//g, "").replace(/ /g, "").split(",") ?? [];
|
|
6001
6001
|
};
|
|
@@ -6414,7 +6414,7 @@ var decorator = (options, target, propertyKey) => {
|
|
|
6414
6414
|
}
|
|
6415
6415
|
list.push({ propertyKey, options });
|
|
6416
6416
|
};
|
|
6417
|
-
function
|
|
6417
|
+
function onConnectedShadow(optionOrTarget, propertyKey, arg3) {
|
|
6418
6418
|
if (propertyKey) {
|
|
6419
6419
|
return decorator({ useShadow: true }, optionOrTarget, propertyKey);
|
|
6420
6420
|
}
|
|
@@ -6422,7 +6422,7 @@ function onConnectedShadowDom(optionOrTarget, propertyKey, arg3) {
|
|
|
6422
6422
|
decorator({ ...optionOrTarget ?? {}, useShadow: true }, target, propertyKey2);
|
|
6423
6423
|
};
|
|
6424
6424
|
}
|
|
6425
|
-
function
|
|
6425
|
+
function onConnectedLight(optionOrTarget, propertyKey, arg3) {
|
|
6426
6426
|
if (propertyKey) {
|
|
6427
6427
|
return decorator({ useShadow: false }, optionOrTarget, propertyKey);
|
|
6428
6428
|
}
|
|
@@ -8904,132 +8904,6 @@ var convertAttributeValue = (val, type) => {
|
|
|
8904
8904
|
return convertValue(val, type);
|
|
8905
8905
|
};
|
|
8906
8906
|
|
|
8907
|
-
// src/decorators/applyAttribute.ts
|
|
8908
|
-
var ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
|
|
8909
|
-
function createAttributeDecorator(action) {
|
|
8910
|
-
return (selector, nameOrOptions, options = {}) => {
|
|
8911
|
-
return (target, propertyKey, descriptor) => {
|
|
8912
|
-
const constructor = target.constructor;
|
|
8913
|
-
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
|
|
8914
|
-
if (!metaList) {
|
|
8915
|
-
metaList = /* @__PURE__ */ new Map();
|
|
8916
|
-
ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
|
|
8917
|
-
}
|
|
8918
|
-
let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
|
|
8919
|
-
let finalOptions = options;
|
|
8920
|
-
if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
|
|
8921
|
-
finalOptions = nameOrOptions;
|
|
8922
|
-
}
|
|
8923
|
-
metaList.set(propertyKey, {
|
|
8924
|
-
propertyKey,
|
|
8925
|
-
selector,
|
|
8926
|
-
action,
|
|
8927
|
-
options: { ...finalOptions, name: attributeName }
|
|
8928
|
-
});
|
|
8929
|
-
const original = descriptor.value;
|
|
8930
|
-
descriptor.value = function(...args) {
|
|
8931
|
-
ensureInit(this);
|
|
8932
|
-
const res = original.apply(this, args);
|
|
8933
|
-
const handleResult = (resolvedValue) => {
|
|
8934
|
-
if (resolvedValue !== void 0) {
|
|
8935
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
8936
|
-
const host = this;
|
|
8937
|
-
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
8938
|
-
const r = finalOptions.root || "auto";
|
|
8939
|
-
const targetEls = [];
|
|
8940
|
-
const applyRoot = (t) => {
|
|
8941
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8942
|
-
targetEls.push(t);
|
|
8943
|
-
};
|
|
8944
|
-
if (selector === "$this" || !selector) applyRoot(host);
|
|
8945
|
-
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
8946
|
-
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
8947
|
-
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
8948
|
-
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
8949
|
-
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
8950
|
-
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8951
|
-
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8952
|
-
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8953
|
-
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8954
|
-
else {
|
|
8955
|
-
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
8956
|
-
if (targetRoot) {
|
|
8957
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
8958
|
-
if (found) targetEls.push(...Array.from(found));
|
|
8959
|
-
}
|
|
8960
|
-
}
|
|
8961
|
-
targetEls.forEach((targetEl) => {
|
|
8962
|
-
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8963
|
-
return;
|
|
8964
|
-
}
|
|
8965
|
-
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8966
|
-
if (action === "set" || action === "update") {
|
|
8967
|
-
if (attributeName) {
|
|
8968
|
-
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
8969
|
-
targetEl.removeAttribute(attributeName);
|
|
8970
|
-
} else {
|
|
8971
|
-
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
8972
|
-
}
|
|
8973
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8974
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
8975
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8976
|
-
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
8977
|
-
targetEl.removeAttribute(attr);
|
|
8978
|
-
} else {
|
|
8979
|
-
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
8980
|
-
}
|
|
8981
|
-
});
|
|
8982
|
-
}
|
|
8983
|
-
} else if (action === "remove") {
|
|
8984
|
-
if (attributeName) {
|
|
8985
|
-
targetEl.removeAttribute(attributeName);
|
|
8986
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8987
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
8988
|
-
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
8989
|
-
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
8990
|
-
});
|
|
8991
|
-
} else {
|
|
8992
|
-
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
8993
|
-
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
8994
|
-
}
|
|
8995
|
-
}
|
|
8996
|
-
});
|
|
8997
|
-
}
|
|
8998
|
-
return resolvedValue;
|
|
8999
|
-
};
|
|
9000
|
-
if (res instanceof Promise) {
|
|
9001
|
-
return res.then(handleResult);
|
|
9002
|
-
} else {
|
|
9003
|
-
return handleResult(res);
|
|
9004
|
-
}
|
|
9005
|
-
};
|
|
9006
|
-
return descriptor;
|
|
9007
|
-
};
|
|
9008
|
-
};
|
|
9009
|
-
}
|
|
9010
|
-
function applyAttribute(selector, action = "update", options = {}) {
|
|
9011
|
-
return createAttributeDecorator(action)(selector, options);
|
|
9012
|
-
}
|
|
9013
|
-
var setAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("set")(selector, nameOrOptions, options);
|
|
9014
|
-
var updateAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("update")(selector, nameOrOptions, options);
|
|
9015
|
-
var removeAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("remove")(selector, nameOrOptions, options);
|
|
9016
|
-
function applyAttributeThis(action = "update", options = {}) {
|
|
9017
|
-
return createAttributeDecorator(action)("$this", options);
|
|
9018
|
-
}
|
|
9019
|
-
var setAttributeThis = (nameOrOptions, options = {}) => createAttributeDecorator("set")("$this", nameOrOptions, options);
|
|
9020
|
-
var updateAttributeThis = (nameOrOptions, options = {}) => createAttributeDecorator("update")("$this", nameOrOptions, options);
|
|
9021
|
-
var removeAttributeThis = (nameOrOptions, options = {}) => createAttributeDecorator("remove")("$this", nameOrOptions, options);
|
|
9022
|
-
var findAllAttributeApplyMetadata = (target) => {
|
|
9023
|
-
const result = /* @__PURE__ */ new Map();
|
|
9024
|
-
const maps = ReflectUtils.findAllMetadata(ATTRIBUTE_APPLY_METADATA_KEY, target);
|
|
9025
|
-
maps.forEach((map) => {
|
|
9026
|
-
if (map instanceof Map) {
|
|
9027
|
-
map.forEach((v, k) => result.set(k, v));
|
|
9028
|
-
}
|
|
9029
|
-
});
|
|
9030
|
-
return result;
|
|
9031
|
-
};
|
|
9032
|
-
|
|
9033
8907
|
// src/decorators/query.ts
|
|
9034
8908
|
var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
9035
8909
|
function query(selectorOrTarget, options = {}) {
|
|
@@ -9443,98 +9317,6 @@ var InjectSituationType = /* @__PURE__ */ ((InjectSituationType2) => {
|
|
|
9443
9317
|
return InjectSituationType2;
|
|
9444
9318
|
})(InjectSituationType || {});
|
|
9445
9319
|
|
|
9446
|
-
// src/decorators/applySlot.ts
|
|
9447
|
-
var APPLY_SLOT_METADATA_KEY = Symbol.for("simple-web-component:apply-slot");
|
|
9448
|
-
function applySlot(id, options = { position: "replaceChildrenHtml" }) {
|
|
9449
|
-
return (targetObj, propertyKey, descriptor) => {
|
|
9450
|
-
const type = descriptor === void 0 ? "property" : "method";
|
|
9451
|
-
if (type === "property") {
|
|
9452
|
-
Object.defineProperty(targetObj, propertyKey, {
|
|
9453
|
-
get() {
|
|
9454
|
-
const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
|
|
9455
|
-
return nodeSlot;
|
|
9456
|
-
},
|
|
9457
|
-
set(nv) {
|
|
9458
|
-
if (nv) {
|
|
9459
|
-
} else {
|
|
9460
|
-
const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
|
|
9461
|
-
nodeSlot.clear();
|
|
9462
|
-
}
|
|
9463
|
-
},
|
|
9464
|
-
configurable: true,
|
|
9465
|
-
enumerable: true
|
|
9466
|
-
});
|
|
9467
|
-
}
|
|
9468
|
-
const constructor = targetObj.constructor;
|
|
9469
|
-
let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor);
|
|
9470
|
-
if (!metaList) {
|
|
9471
|
-
metaList = [];
|
|
9472
|
-
ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);
|
|
9473
|
-
}
|
|
9474
|
-
metaList.push({ propertyKey, id, type, options });
|
|
9475
|
-
if (type === "method") {
|
|
9476
|
-
const original = descriptor.value;
|
|
9477
|
-
descriptor.value = function(...args) {
|
|
9478
|
-
ensureInit(this);
|
|
9479
|
-
const conf = getElementConfig(this);
|
|
9480
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
9481
|
-
const currentDoc = currentWin.document;
|
|
9482
|
-
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
9483
|
-
let res = original.apply(this, args);
|
|
9484
|
-
if (res) {
|
|
9485
|
-
const nodeSlot = new NodeSlot(this, this._swcId);
|
|
9486
|
-
const pos = options.position || "replaceChildrenHtml";
|
|
9487
|
-
const doc = currentWin.document;
|
|
9488
|
-
if (pos === "replaceChildrenHtml") {
|
|
9489
|
-
nodeSlot.replaceChildrenHtml(id, res);
|
|
9490
|
-
} else if (pos === "replaceChildrenText") {
|
|
9491
|
-
nodeSlot.replaceChildrenText(id, res);
|
|
9492
|
-
} else if (pos === "appendHtml") {
|
|
9493
|
-
nodeSlot.appendHtml(id, res);
|
|
9494
|
-
} else if (pos === "appendText") {
|
|
9495
|
-
nodeSlot.appendText(id, res);
|
|
9496
|
-
} else if (pos === "prependHtml") {
|
|
9497
|
-
nodeSlot.prependHtml(id, res);
|
|
9498
|
-
} else if (pos === "prependText") {
|
|
9499
|
-
nodeSlot.prependText(id, res);
|
|
9500
|
-
} else if (pos === "clear") {
|
|
9501
|
-
nodeSlot.clear(id);
|
|
9502
|
-
}
|
|
9503
|
-
}
|
|
9504
|
-
return res;
|
|
9505
|
-
};
|
|
9506
|
-
}
|
|
9507
|
-
};
|
|
9508
|
-
}
|
|
9509
|
-
var findAllApplySlotMetadata = (target) => {
|
|
9510
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
9511
|
-
return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
|
|
9512
|
-
};
|
|
9513
|
-
function applySlotClear(id) {
|
|
9514
|
-
return applySlot(id, { position: "clear" });
|
|
9515
|
-
}
|
|
9516
|
-
function applySlotPrependHtml(id) {
|
|
9517
|
-
return applySlot(id, { position: "prependHtml" });
|
|
9518
|
-
}
|
|
9519
|
-
var applySlotPrepend = applySlotPrependHtml;
|
|
9520
|
-
function applySlotPrependText(id) {
|
|
9521
|
-
return applySlot(id, { position: "prependText" });
|
|
9522
|
-
}
|
|
9523
|
-
function applySlotAppendHtml(id) {
|
|
9524
|
-
return applySlot(id, { position: "appendHtml" });
|
|
9525
|
-
}
|
|
9526
|
-
function applySlotAppendText(id) {
|
|
9527
|
-
return applySlot(id, { position: "appendText" });
|
|
9528
|
-
}
|
|
9529
|
-
var applySlotAppend = applySlotAppendHtml;
|
|
9530
|
-
function applySlotReplaceChildrenHtml(id) {
|
|
9531
|
-
return applySlot(id, { position: "replaceChildrenHtml" });
|
|
9532
|
-
}
|
|
9533
|
-
var applySlotReplaceChildren = applySlotReplaceChildrenHtml;
|
|
9534
|
-
function applySlotReplaceChildrenText(id) {
|
|
9535
|
-
return applySlot(id, { position: "replaceChildrenText" });
|
|
9536
|
-
}
|
|
9537
|
-
|
|
9538
9320
|
// src/decorators/state.ts
|
|
9539
9321
|
var STATE_METADATA_KEY = Symbol.for("simple-web-component:state");
|
|
9540
9322
|
function state(nameOrTarget, propertyKey) {
|
|
@@ -9542,7 +9324,6 @@ function state(nameOrTarget, propertyKey) {
|
|
|
9542
9324
|
let storage = targetObj[stateMetadata.propertyKey];
|
|
9543
9325
|
Object.defineProperty(targetObj, stateMetadata.propertyKey, {
|
|
9544
9326
|
set(nv) {
|
|
9545
|
-
console.log("setState!!", nv);
|
|
9546
9327
|
storage = nv;
|
|
9547
9328
|
const config = getElementConfig(this);
|
|
9548
9329
|
const ea = new ElementApply(this, { id: this._swcId });
|
|
@@ -9592,6 +9373,185 @@ var findAllStateMetadata = (target) => {
|
|
|
9592
9373
|
return ReflectUtils.getMetadata(STATE_METADATA_KEY, constructor) ?? [];
|
|
9593
9374
|
};
|
|
9594
9375
|
|
|
9376
|
+
// src/decorators/applyProperty.ts
|
|
9377
|
+
var PROPERTY_METADATA_KEY = Symbol.for("simple-web-component:property");
|
|
9378
|
+
var resolvePropertyTargets = (inst, selector, options) => {
|
|
9379
|
+
const conf = getElementConfig(inst);
|
|
9380
|
+
const currentWin = conf.window;
|
|
9381
|
+
const r = options.root || "auto";
|
|
9382
|
+
const results = [];
|
|
9383
|
+
const applyRoot = (target) => {
|
|
9384
|
+
if (!target) return;
|
|
9385
|
+
if (r === "auto") {
|
|
9386
|
+
results.push(target);
|
|
9387
|
+
} else {
|
|
9388
|
+
if (r === "light" || r === "all") results.push(target);
|
|
9389
|
+
if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
|
|
9390
|
+
}
|
|
9391
|
+
};
|
|
9392
|
+
if (selector === "$this" || !selector) {
|
|
9393
|
+
applyRoot(inst);
|
|
9394
|
+
} else if (selector === "$window") {
|
|
9395
|
+
results.push(currentWin);
|
|
9396
|
+
} else if (selector === "$document") {
|
|
9397
|
+
results.push(currentWin.document);
|
|
9398
|
+
} else {
|
|
9399
|
+
const hostSet = SwcUtils.getHostSet(inst);
|
|
9400
|
+
if (selector === "$host") applyRoot(hostSet.$host);
|
|
9401
|
+
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
9402
|
+
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
9403
|
+
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
9404
|
+
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
9405
|
+
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
9406
|
+
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
9407
|
+
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
9408
|
+
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
9409
|
+
else {
|
|
9410
|
+
if (r === "shadow") {
|
|
9411
|
+
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
9412
|
+
if (found) results.push(...found);
|
|
9413
|
+
} else if (r === "light") {
|
|
9414
|
+
const found = inst.querySelectorAll(selector);
|
|
9415
|
+
if (found) results.push(...found);
|
|
9416
|
+
} else if (r === "all") {
|
|
9417
|
+
const sMatch = inst.shadowRoot?.querySelectorAll(selector);
|
|
9418
|
+
const lMatch = inst.querySelectorAll(selector);
|
|
9419
|
+
if (sMatch) results.push(...sMatch);
|
|
9420
|
+
if (lMatch) results.push(...lMatch);
|
|
9421
|
+
} else {
|
|
9422
|
+
const found = (inst.shadowRoot || inst).querySelectorAll(selector);
|
|
9423
|
+
if (found) results.push(...found);
|
|
9424
|
+
}
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
return results;
|
|
9428
|
+
};
|
|
9429
|
+
function applyProperty(selector, targetPropertyKeyOrOptions, options) {
|
|
9430
|
+
return (target, propertyKey, descriptor) => {
|
|
9431
|
+
const constructor = target.constructor;
|
|
9432
|
+
const metaType = descriptor && typeof descriptor.value === "function" ? "method" : "property";
|
|
9433
|
+
let finalOptions = {};
|
|
9434
|
+
let targetPropertyKey;
|
|
9435
|
+
if (typeof targetPropertyKeyOrOptions === "string" || typeof targetPropertyKeyOrOptions === "symbol") {
|
|
9436
|
+
targetPropertyKey = targetPropertyKeyOrOptions;
|
|
9437
|
+
finalOptions = options || {};
|
|
9438
|
+
} else if (targetPropertyKeyOrOptions) {
|
|
9439
|
+
finalOptions = targetPropertyKeyOrOptions;
|
|
9440
|
+
targetPropertyKey = finalOptions.name || propertyKey;
|
|
9441
|
+
} else {
|
|
9442
|
+
targetPropertyKey = propertyKey;
|
|
9443
|
+
}
|
|
9444
|
+
let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor);
|
|
9445
|
+
if (!metaList) {
|
|
9446
|
+
metaList = [];
|
|
9447
|
+
ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);
|
|
9448
|
+
}
|
|
9449
|
+
metaList.push({
|
|
9450
|
+
propertyKey,
|
|
9451
|
+
selector,
|
|
9452
|
+
targetPropertyKey,
|
|
9453
|
+
options: finalOptions,
|
|
9454
|
+
type: metaType
|
|
9455
|
+
});
|
|
9456
|
+
const applyValueToTargets = (inst, resolvedValue) => {
|
|
9457
|
+
if (resolvedValue === void 0) return resolvedValue;
|
|
9458
|
+
const targetEls = resolvePropertyTargets(inst, selector, finalOptions);
|
|
9459
|
+
const conf = getElementConfig(inst);
|
|
9460
|
+
const currentWin = conf.window;
|
|
9461
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
|
|
9462
|
+
targetEls.forEach((targetEl) => {
|
|
9463
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {
|
|
9464
|
+
return;
|
|
9465
|
+
}
|
|
9466
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
9467
|
+
targetEl[targetPropertyKey] = resolvedRes;
|
|
9468
|
+
});
|
|
9469
|
+
return resolvedValue;
|
|
9470
|
+
};
|
|
9471
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
9472
|
+
const original = descriptor.value;
|
|
9473
|
+
descriptor.value = function(...args) {
|
|
9474
|
+
ensureInit(this);
|
|
9475
|
+
const res = original.apply(this, args);
|
|
9476
|
+
if (res instanceof Promise) {
|
|
9477
|
+
return res.then((v) => {
|
|
9478
|
+
applyValueToTargets(this, v);
|
|
9479
|
+
return v;
|
|
9480
|
+
});
|
|
9481
|
+
} else {
|
|
9482
|
+
applyValueToTargets(this, res);
|
|
9483
|
+
return res;
|
|
9484
|
+
}
|
|
9485
|
+
};
|
|
9486
|
+
return;
|
|
9487
|
+
}
|
|
9488
|
+
Object.defineProperty(target, propertyKey, {
|
|
9489
|
+
configurable: true,
|
|
9490
|
+
enumerable: true,
|
|
9491
|
+
get() {
|
|
9492
|
+
ensureInit(this);
|
|
9493
|
+
const targetEls = resolvePropertyTargets(this, selector, finalOptions);
|
|
9494
|
+
const conf = getElementConfig(this);
|
|
9495
|
+
const currentWin = conf.window;
|
|
9496
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
9497
|
+
const filtered = targetEls.filter((el) => {
|
|
9498
|
+
if (finalOptions.filter && !finalOptions.filter(el, el[targetPropertyKey], { currentThis: this, helper: hostSet })) {
|
|
9499
|
+
return false;
|
|
9500
|
+
}
|
|
9501
|
+
return true;
|
|
9502
|
+
});
|
|
9503
|
+
const values = filtered.map((el) => el[targetPropertyKey]);
|
|
9504
|
+
return values.length === 1 ? values[0] : values;
|
|
9505
|
+
},
|
|
9506
|
+
set(value) {
|
|
9507
|
+
ensureInit(this);
|
|
9508
|
+
applyValueToTargets(this, value);
|
|
9509
|
+
}
|
|
9510
|
+
});
|
|
9511
|
+
};
|
|
9512
|
+
}
|
|
9513
|
+
function property(selector, targetPropertyKeyOrOptions, options) {
|
|
9514
|
+
return applyProperty(selector, targetPropertyKeyOrOptions, options);
|
|
9515
|
+
}
|
|
9516
|
+
function propertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
|
|
9517
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
9518
|
+
return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
|
|
9519
|
+
}
|
|
9520
|
+
if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
|
|
9521
|
+
return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
|
|
9522
|
+
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
9523
|
+
return applyProperty("$this", void 0, targetOrOptions);
|
|
9524
|
+
} else {
|
|
9525
|
+
return applyProperty("$this", void 0, {});
|
|
9526
|
+
}
|
|
9527
|
+
}
|
|
9528
|
+
function setProperty(selector, targetPropertyKeyOrOptions, options) {
|
|
9529
|
+
return applyProperty(selector, targetPropertyKeyOrOptions, options);
|
|
9530
|
+
}
|
|
9531
|
+
function setPropertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
|
|
9532
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
9533
|
+
return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
|
|
9534
|
+
}
|
|
9535
|
+
if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
|
|
9536
|
+
return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
|
|
9537
|
+
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
9538
|
+
return applyProperty("$this", void 0, targetOrOptions);
|
|
9539
|
+
} else {
|
|
9540
|
+
return applyProperty("$this", void 0, {});
|
|
9541
|
+
}
|
|
9542
|
+
}
|
|
9543
|
+
var findAllPropertyMetadata = (target) => {
|
|
9544
|
+
const actualTarget = target instanceof Function ? target : target.constructor;
|
|
9545
|
+
return ReflectUtils.findAllMetadata(PROPERTY_METADATA_KEY, actualTarget).flat();
|
|
9546
|
+
};
|
|
9547
|
+
var findAllPropertyApplyMetadata = (target) => {
|
|
9548
|
+
const result = /* @__PURE__ */ new Map();
|
|
9549
|
+
findAllPropertyMetadata(target).forEach((meta) => {
|
|
9550
|
+
result.set(meta.propertyKey, meta);
|
|
9551
|
+
});
|
|
9552
|
+
return result;
|
|
9553
|
+
};
|
|
9554
|
+
|
|
9595
9555
|
// src/decorators/elementDefine.ts
|
|
9596
9556
|
var ELEMENT_CONFIG_KEY = Symbol.for("simple-web-component:element-config");
|
|
9597
9557
|
var getElementConfig = (target) => {
|
|
@@ -9605,13 +9565,12 @@ var ensureInit = (inst) => {
|
|
|
9605
9565
|
inst._boundListeners = [];
|
|
9606
9566
|
inst.__swc_initialized = true;
|
|
9607
9567
|
const target = inst instanceof Function ? inst : inst.constructor;
|
|
9608
|
-
const
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
});
|
|
9568
|
+
const attributeAllList = findAllAttributeMetadata(target).filter((it) => it.type === "property");
|
|
9569
|
+
if (attributeAllList) {
|
|
9570
|
+
attributeAllList.forEach((meta) => {
|
|
9571
|
+
delete inst[meta.propertyKey];
|
|
9572
|
+
});
|
|
9573
|
+
}
|
|
9615
9574
|
const queryList = getQueryMetadata(target);
|
|
9616
9575
|
if (queryList) {
|
|
9617
9576
|
queryList.forEach((meta) => {
|
|
@@ -9624,9 +9583,9 @@ var ensureInit = (inst) => {
|
|
|
9624
9583
|
delete inst[meta.propertyKey];
|
|
9625
9584
|
});
|
|
9626
9585
|
}
|
|
9627
|
-
const
|
|
9628
|
-
if (
|
|
9629
|
-
|
|
9586
|
+
const propertyAllList = findAllPropertyMetadata(target).filter((it) => it.type === "property");
|
|
9587
|
+
if (propertyAllList) {
|
|
9588
|
+
propertyAllList.forEach((meta) => {
|
|
9630
9589
|
delete inst[meta.propertyKey];
|
|
9631
9590
|
});
|
|
9632
9591
|
}
|
|
@@ -9683,24 +9642,6 @@ var getHandlers = (inst) => {
|
|
|
9683
9642
|
var setupPrototype = (proto, win) => {
|
|
9684
9643
|
if (proto.__swc_proto_setup) return;
|
|
9685
9644
|
proto.__swc_proto_setup = true;
|
|
9686
|
-
proto.createSlotString = function(id) {
|
|
9687
|
-
return NodeSlot.slot(`${this._swcId}-${id}`);
|
|
9688
|
-
};
|
|
9689
|
-
proto.createEaHtml = function(id, script) {
|
|
9690
|
-
return ElementApply.html(id, script);
|
|
9691
|
-
};
|
|
9692
|
-
proto.createEaText = function(id, script) {
|
|
9693
|
-
return ElementApply.text(id, script);
|
|
9694
|
-
};
|
|
9695
|
-
proto.createEaAttribute = function(id, name, script) {
|
|
9696
|
-
return ElementApply.attribute(id, name, script);
|
|
9697
|
-
};
|
|
9698
|
-
proto.createEaEvent = function(id, name, script) {
|
|
9699
|
-
return ElementApply.event(id, name, script);
|
|
9700
|
-
};
|
|
9701
|
-
proto.createEaProperty = function(id, name, script) {
|
|
9702
|
-
return ElementApply.property(id, name, script);
|
|
9703
|
-
};
|
|
9704
9645
|
proto._executeSwcScript = function(attrName, hostSet, extraArgs = {}) {
|
|
9705
9646
|
ensureInit(this);
|
|
9706
9647
|
const script = this.getAttribute(attrName);
|
|
@@ -9830,8 +9771,8 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
9830
9771
|
const applyAttributeMap = findAllAttributeApplyMetadata(constructor);
|
|
9831
9772
|
const swcLifecycleAttributes = ["swc-on-constructor", "swc-on-connected", "swc-on-disconnected", "swc-on-before-connected", "swc-on-after-connected", "swc-on-before-disconnected", "swc-on-after-disconnected", "swc-on-before-adopted", "swc-on-after-adopted", "swc-on-attribute-changed"];
|
|
9832
9773
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
9833
|
-
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.
|
|
9834
|
-
const hostAttributes = attributeList.filter((it) => it.selector === "$this").map((it) => it.
|
|
9774
|
+
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.targetAttributeName).filter(Boolean);
|
|
9775
|
+
const hostAttributes = attributeList.filter((it) => it.selector === "$this").map((it) => it.propertyKey || String(it.propertyKey));
|
|
9835
9776
|
const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
|
|
9836
9777
|
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
9837
9778
|
const proto = constructor.prototype;
|
|
@@ -10158,8 +10099,8 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
10158
10099
|
return constructor;
|
|
10159
10100
|
};
|
|
10160
10101
|
|
|
10161
|
-
// src/decorators/
|
|
10162
|
-
var
|
|
10102
|
+
// src/decorators/applyAttribute.ts
|
|
10103
|
+
var ATTRIBUTE_METADATA_KEY = Symbol.for("simple-web-component:attribute");
|
|
10163
10104
|
var convertValue2 = (val, type) => {
|
|
10164
10105
|
if (val === null || val === void 0) return val;
|
|
10165
10106
|
if (type === Number) return Number(val);
|
|
@@ -10169,7 +10110,7 @@ var convertValue2 = (val, type) => {
|
|
|
10169
10110
|
var getAttributeValue = (inst, attrName, options) => {
|
|
10170
10111
|
const conf = getElementConfig(inst);
|
|
10171
10112
|
const currentWin = inst._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
10172
|
-
const targets = options?.selector ?
|
|
10113
|
+
const targets = options?.selector ? resolveAttributeTargets(inst, options.selector, options) : [inst];
|
|
10173
10114
|
const primaryTarget = targets[0];
|
|
10174
10115
|
if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
|
|
10175
10116
|
let domVal = primaryTarget.getAttribute(attrName);
|
|
@@ -10183,8 +10124,8 @@ var getAttributeValue = (inst, attrName, options) => {
|
|
|
10183
10124
|
args: SwcUtils.getHelperAndHostSet(currentWin, inst)
|
|
10184
10125
|
});
|
|
10185
10126
|
return convertValue2(result, options?.type);
|
|
10186
|
-
} catch (
|
|
10187
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`,
|
|
10127
|
+
} catch (err) {
|
|
10128
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, err);
|
|
10188
10129
|
return convertValue2(domVal, options?.type);
|
|
10189
10130
|
}
|
|
10190
10131
|
}
|
|
@@ -10192,7 +10133,9 @@ var getAttributeValue = (inst, attrName, options) => {
|
|
|
10192
10133
|
}
|
|
10193
10134
|
return null;
|
|
10194
10135
|
};
|
|
10195
|
-
var
|
|
10136
|
+
var resolveAttributeTargets = (inst, selector, options) => {
|
|
10137
|
+
const conf = getElementConfig(inst);
|
|
10138
|
+
const currentWin = conf.window;
|
|
10196
10139
|
const r = options.root || "auto";
|
|
10197
10140
|
const results = [];
|
|
10198
10141
|
const applyRoot = (target) => {
|
|
@@ -10206,10 +10149,6 @@ var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
|
10206
10149
|
};
|
|
10207
10150
|
if (selector === "$this" || !selector) {
|
|
10208
10151
|
applyRoot(inst);
|
|
10209
|
-
} else if (selector === "$window") {
|
|
10210
|
-
results.push(currentWin);
|
|
10211
|
-
} else if (selector === "$document") {
|
|
10212
|
-
results.push(currentWin.document);
|
|
10213
10152
|
} else {
|
|
10214
10153
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
10215
10154
|
if (selector === "$host") applyRoot(hostSet.$host);
|
|
@@ -10219,6 +10158,8 @@ var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
|
10219
10158
|
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10220
10159
|
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10221
10160
|
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10161
|
+
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10162
|
+
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10222
10163
|
else {
|
|
10223
10164
|
if (r === "shadow") {
|
|
10224
10165
|
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
@@ -10239,133 +10180,168 @@ var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
|
10239
10180
|
}
|
|
10240
10181
|
return results;
|
|
10241
10182
|
};
|
|
10242
|
-
function
|
|
10243
|
-
return (target, propertyKey) => {
|
|
10183
|
+
function applyAttribute(selector, targetAttributeNameOrOptions, options) {
|
|
10184
|
+
return (target, propertyKey, descriptor) => {
|
|
10244
10185
|
const constructor = target.constructor;
|
|
10245
|
-
const privateKey = Symbol(String(propertyKey));
|
|
10246
10186
|
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
10247
|
-
|
|
10187
|
+
const metaType = descriptor && typeof descriptor.value === "function" ? "method" : "property";
|
|
10188
|
+
let finalOptions = {};
|
|
10189
|
+
let targetAttributeName;
|
|
10190
|
+
if (typeof targetAttributeNameOrOptions === "string") {
|
|
10191
|
+
targetAttributeName = targetAttributeNameOrOptions;
|
|
10192
|
+
finalOptions = options || {};
|
|
10193
|
+
} else if (targetAttributeNameOrOptions) {
|
|
10194
|
+
finalOptions = targetAttributeNameOrOptions;
|
|
10195
|
+
targetAttributeName = finalOptions.name || String(propertyKey);
|
|
10196
|
+
} else {
|
|
10197
|
+
targetAttributeName = String(propertyKey);
|
|
10198
|
+
}
|
|
10199
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor);
|
|
10248
10200
|
if (!metaList) {
|
|
10249
10201
|
metaList = [];
|
|
10250
|
-
ReflectUtils.defineMetadata(
|
|
10251
|
-
}
|
|
10252
|
-
metaList.push({
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10202
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);
|
|
10203
|
+
}
|
|
10204
|
+
metaList.push({
|
|
10205
|
+
propertyKey,
|
|
10206
|
+
selector,
|
|
10207
|
+
targetAttributeName,
|
|
10208
|
+
options: finalOptions,
|
|
10209
|
+
type: metaType
|
|
10210
|
+
});
|
|
10211
|
+
const applyValueToTargets = (inst, resolvedValue) => {
|
|
10212
|
+
const conf = getElementConfig(inst);
|
|
10213
|
+
const currentWin = conf.window;
|
|
10214
|
+
const targetEls = resolveAttributeTargets(inst, selector, finalOptions);
|
|
10215
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
|
|
10216
|
+
targetEls.forEach((targetEl) => {
|
|
10217
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {
|
|
10218
|
+
return;
|
|
10219
|
+
}
|
|
10220
|
+
if (resolvedValue === null) {
|
|
10221
|
+
targetEl.removeAttribute(targetAttributeName);
|
|
10222
|
+
} else if (resolvedValue !== void 0) {
|
|
10223
|
+
targetEl.setAttribute(targetAttributeName, resolvedValue === true ? "" : String(resolvedValue));
|
|
10263
10224
|
}
|
|
10264
10225
|
});
|
|
10226
|
+
return resolvedValue;
|
|
10265
10227
|
};
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
const targets = resolveTargetEls(this, selector, options, currentWin);
|
|
10283
|
-
applySetAttribute(this, targets, attrName, nv);
|
|
10284
|
-
},
|
|
10285
|
-
enumerable: true,
|
|
10286
|
-
configurable: true
|
|
10287
|
-
});
|
|
10288
|
-
} catch (err) {
|
|
10289
|
-
console.error("[SWC] defineProperty error:", err);
|
|
10228
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
10229
|
+
const original = descriptor.value;
|
|
10230
|
+
descriptor.value = function(...args) {
|
|
10231
|
+
ensureInit(this);
|
|
10232
|
+
const res = original.apply(this, args);
|
|
10233
|
+
if (res instanceof Promise) {
|
|
10234
|
+
return res.then((v) => {
|
|
10235
|
+
applyValueToTargets(this, v);
|
|
10236
|
+
return v;
|
|
10237
|
+
});
|
|
10238
|
+
} else {
|
|
10239
|
+
applyValueToTargets(this, res);
|
|
10240
|
+
return res;
|
|
10241
|
+
}
|
|
10242
|
+
};
|
|
10243
|
+
return;
|
|
10290
10244
|
}
|
|
10245
|
+
Object.defineProperty(target, propertyKey, {
|
|
10246
|
+
configurable: true,
|
|
10247
|
+
enumerable: true,
|
|
10248
|
+
get() {
|
|
10249
|
+
ensureInit(this);
|
|
10250
|
+
const mergedOptions = { ...finalOptions, selector, type: finalOptions.type || designType };
|
|
10251
|
+
return getAttributeValue(this, targetAttributeName, mergedOptions);
|
|
10252
|
+
},
|
|
10253
|
+
set(value) {
|
|
10254
|
+
ensureInit(this);
|
|
10255
|
+
if (value instanceof Promise) {
|
|
10256
|
+
value.then((v) => applyValueToTargets(this, v)).catch(() => {
|
|
10257
|
+
});
|
|
10258
|
+
} else {
|
|
10259
|
+
applyValueToTargets(this, value);
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
});
|
|
10291
10263
|
};
|
|
10292
10264
|
}
|
|
10293
|
-
function
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
if (typeof
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
return (
|
|
10304
|
-
return attribute("$this", { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
10305
|
-
};
|
|
10265
|
+
function attribute(selector, targetAttributeNameOrOptions, options) {
|
|
10266
|
+
return applyAttribute(selector, targetAttributeNameOrOptions, options);
|
|
10267
|
+
}
|
|
10268
|
+
function attributeThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
|
|
10269
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") {
|
|
10270
|
+
return applyAttribute("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
|
|
10271
|
+
}
|
|
10272
|
+
if (typeof targetOrOptions === "string") {
|
|
10273
|
+
return applyAttribute("$this", targetOrOptions, propertyKeyOrOptions);
|
|
10274
|
+
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
10275
|
+
return applyAttribute("$this", void 0, targetOrOptions);
|
|
10306
10276
|
} else {
|
|
10307
|
-
return (
|
|
10308
|
-
|
|
10309
|
-
|
|
10277
|
+
return applyAttribute("$this", void 0, {});
|
|
10278
|
+
}
|
|
10279
|
+
}
|
|
10280
|
+
function setAttribute(selector, targetAttributeNameOrOptions, options) {
|
|
10281
|
+
return applyAttribute(selector, targetAttributeNameOrOptions, options);
|
|
10282
|
+
}
|
|
10283
|
+
function setAttributeThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
|
|
10284
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
10285
|
+
return applyAttribute("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
|
|
10286
|
+
}
|
|
10287
|
+
if (typeof targetOrOptions === "string") {
|
|
10288
|
+
return applyAttribute("$this", targetOrOptions, propertyKeyOrOptions);
|
|
10289
|
+
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
10290
|
+
return applyAttribute("$this", void 0, targetOrOptions);
|
|
10291
|
+
} else {
|
|
10292
|
+
return applyAttribute("$this", void 0, {});
|
|
10310
10293
|
}
|
|
10311
10294
|
}
|
|
10312
10295
|
var findAllAttributeMetadata = (target) => {
|
|
10313
10296
|
const actualTarget = target instanceof Function ? target : target.constructor;
|
|
10314
|
-
return ReflectUtils.findAllMetadata(
|
|
10297
|
+
return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, actualTarget).flat();
|
|
10298
|
+
};
|
|
10299
|
+
var findAllAttributeApplyMetadata = (target) => {
|
|
10300
|
+
const result = /* @__PURE__ */ new Map();
|
|
10301
|
+
findAllAttributeMetadata(target).forEach((meta) => {
|
|
10302
|
+
result.set(meta.propertyKey, meta);
|
|
10303
|
+
});
|
|
10304
|
+
return result;
|
|
10315
10305
|
};
|
|
10316
10306
|
|
|
10317
10307
|
// src/decorators/applyNode.ts
|
|
10318
10308
|
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
10319
|
-
var normalizeNodes = (res, doc) => {
|
|
10320
|
-
const items = Array.isArray(res) ? res : [res];
|
|
10321
|
-
return items.map((it) => {
|
|
10322
|
-
if (it instanceof Node) return it;
|
|
10323
|
-
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
10324
|
-
});
|
|
10325
|
-
};
|
|
10326
10309
|
var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
10327
10310
|
if (!targetEl) return;
|
|
10328
10311
|
const doc = win.document;
|
|
10329
10312
|
const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
|
|
10330
10313
|
const id = currentThis._swcId;
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
}
|
|
10339
|
-
|
|
10340
|
-
if (pos === "innerHtml") {
|
|
10341
|
-
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
10342
|
-
return;
|
|
10343
|
-
}
|
|
10344
|
-
if (pos === "innerText") {
|
|
10345
|
-
if (targetEl.innerText !== void 0) {
|
|
10346
|
-
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
10347
|
-
}
|
|
10348
|
-
return;
|
|
10349
|
-
}
|
|
10350
|
-
const stateContext = { ...hostSet };
|
|
10351
|
-
findAllStateMetadata(currentThis).forEach((it) => {
|
|
10352
|
-
stateContext[it.name] = currentThis[it.propertyKey];
|
|
10353
|
-
});
|
|
10354
|
-
new ElementApply(currentThis, { id: currentThis._swcId }).apply({ target: "noInitialized", context: stateContext, bind: currentThis });
|
|
10314
|
+
const nodes = [];
|
|
10315
|
+
if (typeof res === "string" && pos === "innerHtml") {
|
|
10316
|
+
const t = win.document.createElement("template");
|
|
10317
|
+
t.innerHTML = res;
|
|
10318
|
+
nodes.push(...Array.from(t.content.childNodes));
|
|
10319
|
+
} else if (typeof res === "string" && pos === "innerText") {
|
|
10320
|
+
nodes.push(win.document.createTextNode(res));
|
|
10321
|
+
}
|
|
10322
|
+
SwcUtils.projectProcessHtml(id, nodes, doc);
|
|
10355
10323
|
const isShadowRoot = targetEl instanceof win.ShadowRoot;
|
|
10356
|
-
const nodes = normalizeNodes(res, doc);
|
|
10357
10324
|
if (pos === "replace") {
|
|
10358
10325
|
if (!isShadowRoot) targetEl.replaceWith(...nodes);
|
|
10326
|
+
} else if (pos === "innerHtml") {
|
|
10327
|
+
targetEl.replaceChildren(...nodes);
|
|
10328
|
+
} else if (pos === "innerText") {
|
|
10329
|
+
targetEl.replaceChildren(...nodes);
|
|
10359
10330
|
} else if (pos === "replaceChildren") {
|
|
10360
10331
|
targetEl.replaceChildren(...nodes);
|
|
10361
10332
|
} else {
|
|
10362
10333
|
if (pos === "beforeEnd") {
|
|
10363
|
-
console.log("tarbbbbbbbbbbbbbb");
|
|
10364
10334
|
targetEl.append(...nodes);
|
|
10365
10335
|
} else if (pos === "afterBegin") targetEl.prepend(...nodes);
|
|
10366
10336
|
else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
|
|
10367
10337
|
else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
|
|
10368
10338
|
}
|
|
10339
|
+
const stateContext = { ...hostSet };
|
|
10340
|
+
findAllStateMetadata(currentThis).forEach((it) => {
|
|
10341
|
+
stateContext[it.name] = currentThis[it.propertyKey];
|
|
10342
|
+
});
|
|
10343
|
+
new ElementApply(targetEl, { id }).apply({ target: "noInitialized", context: stateContext, bind: currentThis });
|
|
10344
|
+
return nodes;
|
|
10369
10345
|
};
|
|
10370
10346
|
function applyNode(selector, options = { position: "replaceChildren" }) {
|
|
10371
10347
|
return (targetObj, propertyKey, descriptor) => {
|
|
@@ -10402,7 +10378,6 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
|
|
|
10402
10378
|
const targetRoot = applyRoot(this);
|
|
10403
10379
|
return targetRoot ? targetRoot.querySelector(selector) : null;
|
|
10404
10380
|
};
|
|
10405
|
-
console.log("fffffffffff");
|
|
10406
10381
|
const targetEl = getTarget();
|
|
10407
10382
|
const res = original.apply(this, args);
|
|
10408
10383
|
const runApply = (target, val) => {
|
|
@@ -10412,13 +10387,14 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
|
|
|
10412
10387
|
applyToDom(this, target, processedVal, pos, currentWin);
|
|
10413
10388
|
}
|
|
10414
10389
|
};
|
|
10390
|
+
const fallbackNodes = [];
|
|
10391
|
+
if (targetEl && options.fallback) {
|
|
10392
|
+
const loadingRes = options.fallback.call(this, hostSet);
|
|
10393
|
+
fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || "beforeEnd", currentWin));
|
|
10394
|
+
}
|
|
10415
10395
|
if (res instanceof Promise) {
|
|
10416
|
-
if (targetEl && options.fallback) {
|
|
10417
|
-
const loadingRes = options.fallback.call(this, hostSet);
|
|
10418
|
-
applyToDom(this, targetEl, loadingRes, options.position || "beforeEnd", currentWin);
|
|
10419
|
-
}
|
|
10420
10396
|
return res.then((finalRes) => {
|
|
10421
|
-
|
|
10397
|
+
fallbackNodes.forEach((it) => it.remove());
|
|
10422
10398
|
if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
|
|
10423
10399
|
return finalRes;
|
|
10424
10400
|
});
|
|
@@ -10429,91 +10405,103 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
|
|
|
10429
10405
|
};
|
|
10430
10406
|
};
|
|
10431
10407
|
}
|
|
10432
|
-
var findAllApplyNodeMetadata = (target) => {
|
|
10433
|
-
const result = /* @__PURE__ */ new Map();
|
|
10434
|
-
const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
|
|
10435
|
-
maps.forEach((map) => {
|
|
10436
|
-
if (map instanceof Map) {
|
|
10437
|
-
map.forEach((v, k) => result.set(k, v));
|
|
10438
|
-
}
|
|
10439
|
-
});
|
|
10440
|
-
return result;
|
|
10441
|
-
};
|
|
10442
10408
|
function applyNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10443
10409
|
const option = { position: "replaceChildren" };
|
|
10444
10410
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10445
10411
|
const opt = targetOrOptions || {};
|
|
10446
10412
|
return applyNode("$this", { ...option, ...opt });
|
|
10447
10413
|
}
|
|
10448
|
-
function
|
|
10414
|
+
function replaceChildrenNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10449
10415
|
const option = { position: "replaceChildren" };
|
|
10450
10416
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10451
10417
|
const opt = targetOrOptions || {};
|
|
10452
10418
|
return applyNode("$this", { ...opt, ...option });
|
|
10453
10419
|
}
|
|
10454
|
-
function
|
|
10455
|
-
const options = { position: "replaceChildren", root: "light" };
|
|
10456
|
-
if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
|
|
10457
|
-
const opt = targetOrOptions || {};
|
|
10458
|
-
return applyNode("$this", { ...opt, ...options });
|
|
10459
|
-
}
|
|
10460
|
-
function applyNodeThisBeforeEnd(targetOrOptions, propertyKey, descriptor) {
|
|
10420
|
+
function beforeEndNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10461
10421
|
const options = { position: "beforeEnd" };
|
|
10462
10422
|
if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
|
|
10463
10423
|
const opt = targetOrOptions || {};
|
|
10464
10424
|
return applyNode("$this", { ...opt, ...options });
|
|
10465
10425
|
}
|
|
10466
|
-
function
|
|
10426
|
+
function beforeEndLightNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10467
10427
|
const option = { position: "beforeEnd", root: "light" };
|
|
10468
10428
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10469
10429
|
const opt = targetOrOptions || {};
|
|
10470
10430
|
return applyNode("$this", { ...opt, ...option });
|
|
10471
10431
|
}
|
|
10472
|
-
function
|
|
10432
|
+
function beforeEndShadowNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10473
10433
|
const option = { position: "beforeEnd", root: "shadow" };
|
|
10474
10434
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10475
10435
|
const opt = targetOrOptions || {};
|
|
10476
10436
|
return applyNode("$this", { ...opt, ...option });
|
|
10477
10437
|
}
|
|
10478
|
-
function
|
|
10438
|
+
function afterBeginNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10479
10439
|
const option = { position: "afterBegin" };
|
|
10480
10440
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10481
10441
|
const opt = targetOrOptions || {};
|
|
10482
10442
|
return applyNode("$this", { ...opt, ...option });
|
|
10483
10443
|
}
|
|
10484
|
-
function
|
|
10444
|
+
function afterBeginLightNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10485
10445
|
const option = { position: "afterBegin", root: "light" };
|
|
10486
10446
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10487
10447
|
const opt = targetOrOptions || {};
|
|
10488
10448
|
return applyNode("$this", { ...opt, ...option });
|
|
10489
10449
|
}
|
|
10490
|
-
function
|
|
10450
|
+
function innerHtmlNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10491
10451
|
const option = { position: "innerHtml" };
|
|
10492
10452
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10493
10453
|
const opt = targetOrOptions || {};
|
|
10494
10454
|
return applyNode("$this", { ...opt, ...option });
|
|
10495
10455
|
}
|
|
10496
|
-
function
|
|
10456
|
+
function innerTextNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10457
|
+
const option = { position: "innerText" };
|
|
10458
|
+
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10459
|
+
const opt = targetOrOptions || {};
|
|
10460
|
+
return applyNode("$this", { ...opt, ...option });
|
|
10461
|
+
}
|
|
10462
|
+
function innerHtmlLightNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10497
10463
|
const option = { position: "innerHtml", root: "light" };
|
|
10498
10464
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10499
10465
|
const opt = targetOrOptions || {};
|
|
10500
10466
|
return applyNode("$this", { ...opt, ...option });
|
|
10501
10467
|
}
|
|
10502
|
-
function
|
|
10468
|
+
function replaceChildrenLightNodeThis(targetOrOptions, propertyKey, descriptor) {
|
|
10503
10469
|
const option = { position: "replaceChildren", root: "light" };
|
|
10504
10470
|
if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
|
|
10505
10471
|
const opt = targetOrOptions || {};
|
|
10506
10472
|
return applyNode("$this", { ...opt, ...option });
|
|
10507
10473
|
}
|
|
10508
|
-
function
|
|
10474
|
+
function replaceChildrenNode(selector, options = {}) {
|
|
10509
10475
|
return applyNode(selector, { ...options, position: "replaceChildren" });
|
|
10510
10476
|
}
|
|
10511
|
-
function
|
|
10477
|
+
function innerHtmlNode(selector, options = {}) {
|
|
10512
10478
|
return applyNode(selector, { ...options, position: "innerHtml" });
|
|
10513
10479
|
}
|
|
10514
|
-
function
|
|
10480
|
+
function innerHtmlLightNode(selector, options = {}) {
|
|
10481
|
+
return applyNode(selector, { ...options, position: "innerHtml", root: "light" });
|
|
10482
|
+
}
|
|
10483
|
+
function innerHtmlShadowNode(selector, options = {}) {
|
|
10484
|
+
return applyNode(selector, { ...options, position: "innerHtml", root: "shadow" });
|
|
10485
|
+
}
|
|
10486
|
+
function innerTextNode(selector, options = {}) {
|
|
10515
10487
|
return applyNode(selector, { ...options, position: "innerText" });
|
|
10516
10488
|
}
|
|
10489
|
+
function innerTextLightNode(selector, options = {}) {
|
|
10490
|
+
return applyNode(selector, { ...options, position: "innerText", root: "light" });
|
|
10491
|
+
}
|
|
10492
|
+
function innerTextShadowNode(selector, options = {}) {
|
|
10493
|
+
return applyNode(selector, { ...options, position: "innerText", root: "shadow" });
|
|
10494
|
+
}
|
|
10495
|
+
var findAllApplyNodeMetadata = (target) => {
|
|
10496
|
+
const result = /* @__PURE__ */ new Map();
|
|
10497
|
+
const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
|
|
10498
|
+
maps.forEach((map) => {
|
|
10499
|
+
if (map instanceof Map) {
|
|
10500
|
+
map.forEach((v, k) => result.set(k, v));
|
|
10501
|
+
}
|
|
10502
|
+
});
|
|
10503
|
+
return result;
|
|
10504
|
+
};
|
|
10517
10505
|
|
|
10518
10506
|
// src/decorators/applyClass.ts
|
|
10519
10507
|
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
@@ -10766,89 +10754,6 @@ var findAllStyleMetadata = (target) => {
|
|
|
10766
10754
|
return result;
|
|
10767
10755
|
};
|
|
10768
10756
|
|
|
10769
|
-
// src/decorators/setProperty.ts
|
|
10770
|
-
var PROPERTY_SET_METADATA_KEY = Symbol.for("simple-web-component:property-set");
|
|
10771
|
-
var setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
10772
|
-
return (target, propertyKey, descriptor) => {
|
|
10773
|
-
const constructor = target.constructor;
|
|
10774
|
-
let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor);
|
|
10775
|
-
if (!metaList) {
|
|
10776
|
-
metaList = /* @__PURE__ */ new Map();
|
|
10777
|
-
ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);
|
|
10778
|
-
}
|
|
10779
|
-
let propertyName = typeof propertyNameOrOptions === "string" ? propertyNameOrOptions : void 0;
|
|
10780
|
-
let finalOptions = options;
|
|
10781
|
-
if (typeof propertyNameOrOptions === "object" && propertyNameOrOptions !== null) {
|
|
10782
|
-
finalOptions = propertyNameOrOptions;
|
|
10783
|
-
}
|
|
10784
|
-
metaList.set(propertyKey, {
|
|
10785
|
-
propertyKey,
|
|
10786
|
-
selector,
|
|
10787
|
-
options: { ...finalOptions, name: propertyName }
|
|
10788
|
-
});
|
|
10789
|
-
const original = descriptor.value;
|
|
10790
|
-
descriptor.value = function(...args) {
|
|
10791
|
-
ensureInit(this);
|
|
10792
|
-
const res = original.apply(this, args);
|
|
10793
|
-
const handleResult = (resolvedValue) => {
|
|
10794
|
-
if (resolvedValue !== void 0) {
|
|
10795
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
10796
|
-
const host = this;
|
|
10797
|
-
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
10798
|
-
const r = finalOptions.root || "auto";
|
|
10799
|
-
const targetEls = [];
|
|
10800
|
-
const applyRoot = (t) => {
|
|
10801
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
10802
|
-
targetEls.push(t);
|
|
10803
|
-
};
|
|
10804
|
-
if (selector === "$this" || !selector) applyRoot(host);
|
|
10805
|
-
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
10806
|
-
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10807
|
-
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10808
|
-
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10809
|
-
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10810
|
-
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10811
|
-
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10812
|
-
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10813
|
-
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10814
|
-
else {
|
|
10815
|
-
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
10816
|
-
if (targetRoot) {
|
|
10817
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
10818
|
-
if (found) targetEls.push(...Array.from(found));
|
|
10819
|
-
}
|
|
10820
|
-
}
|
|
10821
|
-
targetEls.forEach((targetEl) => {
|
|
10822
|
-
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
10823
|
-
return;
|
|
10824
|
-
}
|
|
10825
|
-
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
10826
|
-
if (propertyName) {
|
|
10827
|
-
targetEl[propertyName] = resolvedRes;
|
|
10828
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
10829
|
-
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
10830
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
10831
|
-
targetEl[prop] = finalVal;
|
|
10832
|
-
});
|
|
10833
|
-
} else {
|
|
10834
|
-
targetEl.value = resolvedRes;
|
|
10835
|
-
}
|
|
10836
|
-
});
|
|
10837
|
-
}
|
|
10838
|
-
return resolvedValue;
|
|
10839
|
-
};
|
|
10840
|
-
if (res instanceof Promise) {
|
|
10841
|
-
return res.then(handleResult);
|
|
10842
|
-
} else {
|
|
10843
|
-
return handleResult(res);
|
|
10844
|
-
}
|
|
10845
|
-
};
|
|
10846
|
-
};
|
|
10847
|
-
};
|
|
10848
|
-
var setPropertyThis = (propertyNameOrOptions, options = {}) => {
|
|
10849
|
-
return setProperty("$this", propertyNameOrOptions, options);
|
|
10850
|
-
};
|
|
10851
|
-
|
|
10852
10757
|
// src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts
|
|
10853
10758
|
var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change-while-connected");
|
|
10854
10759
|
function createSubscribeSwcAppRouteChangeWhileConnected(options) {
|
|
@@ -10983,6 +10888,109 @@ var getPublishSwcAppMessageMetadata = (target) => {
|
|
|
10983
10888
|
return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
10984
10889
|
};
|
|
10985
10890
|
|
|
10891
|
+
// src/decorators/applySlot.ts
|
|
10892
|
+
var APPLY_SLOT_METADATA_KEY = Symbol.for("simple-web-component:apply-slot");
|
|
10893
|
+
var applyToDom2 = (swcId, id, pos, nodes) => {
|
|
10894
|
+
const nodeSlot = new NodeSlot(void 0, swcId);
|
|
10895
|
+
if (pos === "replaceChildrenText" || pos === "replaceChildren" || pos === "replaceChildrenHtml") {
|
|
10896
|
+
nodeSlot.replaceChildren(id, ...nodes);
|
|
10897
|
+
} else if (pos === "appendHtml" || pos === "append" || pos === "appendText") {
|
|
10898
|
+
nodeSlot.append(id, ...nodes);
|
|
10899
|
+
} else if (pos === "prependHtml" || pos === "prepend" || pos === "prependText") {
|
|
10900
|
+
nodeSlot.prepend(id, ...nodes);
|
|
10901
|
+
} else if (pos === "clear") {
|
|
10902
|
+
nodeSlot.clear(id);
|
|
10903
|
+
}
|
|
10904
|
+
};
|
|
10905
|
+
function applySlot(targetId, opt) {
|
|
10906
|
+
return (targetObj, propertyKey, descriptor) => {
|
|
10907
|
+
const options = { position: "replaceChildren", ...opt };
|
|
10908
|
+
const constructor = targetObj.constructor;
|
|
10909
|
+
let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor);
|
|
10910
|
+
if (!metaList) {
|
|
10911
|
+
metaList = [];
|
|
10912
|
+
ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);
|
|
10913
|
+
}
|
|
10914
|
+
metaList.push({ propertyKey, targetId, options });
|
|
10915
|
+
const original = descriptor.value;
|
|
10916
|
+
descriptor.value = function(...args) {
|
|
10917
|
+
ensureInit(this);
|
|
10918
|
+
const conf = getElementConfig(this);
|
|
10919
|
+
const currentWin = conf.window;
|
|
10920
|
+
const swcId = this._swcId;
|
|
10921
|
+
const currentDoc = currentWin.document;
|
|
10922
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
10923
|
+
const pos = options.position;
|
|
10924
|
+
const resToNodes = (res2) => {
|
|
10925
|
+
const nodes = [];
|
|
10926
|
+
if (typeof res2 === "string" && (pos === "replaceChildrenHtml" || pos === "appendHtml" || pos === "prependHtml")) {
|
|
10927
|
+
const t = currentWin.document.createElement("template");
|
|
10928
|
+
t.innerHTML = res2;
|
|
10929
|
+
nodes.push(...Array.from(t.content.childNodes));
|
|
10930
|
+
} else if (typeof res2 === "string" && (pos === "replaceChildrenText" || pos === "prependText" || pos === "appendText")) {
|
|
10931
|
+
nodes.push(currentWin.document.createTextNode(res2));
|
|
10932
|
+
} else if (typeof res2 === "object") {
|
|
10933
|
+
nodes.push(res2);
|
|
10934
|
+
}
|
|
10935
|
+
SwcUtils.projectProcessHtml(swcId, nodes, currentDoc);
|
|
10936
|
+
return nodes;
|
|
10937
|
+
};
|
|
10938
|
+
const fallbackNodes = [];
|
|
10939
|
+
if (options.fallback) {
|
|
10940
|
+
const res2 = options.fallback.call(this, hostSet);
|
|
10941
|
+
const nodes = resToNodes(res2);
|
|
10942
|
+
fallbackNodes.push(...nodes);
|
|
10943
|
+
applyToDom2(swcId, targetId, options.position, nodes);
|
|
10944
|
+
}
|
|
10945
|
+
let res = original.apply(this, args);
|
|
10946
|
+
if (res instanceof Promise) {
|
|
10947
|
+
return res.then((asyncRes) => {
|
|
10948
|
+
const nodes = resToNodes(asyncRes);
|
|
10949
|
+
fallbackNodes.forEach((it) => it.remove());
|
|
10950
|
+
applyToDom2(swcId, targetId, options.position, nodes);
|
|
10951
|
+
});
|
|
10952
|
+
} else {
|
|
10953
|
+
const nodes = resToNodes(res);
|
|
10954
|
+
applyToDom2(swcId, targetId, options.position, nodes);
|
|
10955
|
+
}
|
|
10956
|
+
};
|
|
10957
|
+
};
|
|
10958
|
+
}
|
|
10959
|
+
function clearSlot(targetId) {
|
|
10960
|
+
return applySlot(targetId, { position: "clear" });
|
|
10961
|
+
}
|
|
10962
|
+
function prependHtmlSlot(targetId) {
|
|
10963
|
+
return applySlot(targetId, { position: "prependHtml" });
|
|
10964
|
+
}
|
|
10965
|
+
function prependSlot(targetId) {
|
|
10966
|
+
return applySlot(targetId, { position: "prepend" });
|
|
10967
|
+
}
|
|
10968
|
+
function prependTextSlot(targetId) {
|
|
10969
|
+
return applySlot(targetId, { position: "prependText" });
|
|
10970
|
+
}
|
|
10971
|
+
function appendHtmlSlot(targetId) {
|
|
10972
|
+
return applySlot(targetId, { position: "appendHtml" });
|
|
10973
|
+
}
|
|
10974
|
+
function appendTextSlot(targetId) {
|
|
10975
|
+
return applySlot(targetId, { position: "appendText" });
|
|
10976
|
+
}
|
|
10977
|
+
function appendSlot(targetId) {
|
|
10978
|
+
return applySlot(targetId, { position: "append" });
|
|
10979
|
+
}
|
|
10980
|
+
function replaceChildrenHtmlSlot(targetId) {
|
|
10981
|
+
return applySlot(targetId, { position: "replaceChildrenHtml" });
|
|
10982
|
+
}
|
|
10983
|
+
function replaceChildrenSlot(targetId) {
|
|
10984
|
+
return applySlot(targetId, { position: "replaceChildren" });
|
|
10985
|
+
}
|
|
10986
|
+
function replaceChildrenTextSlot(targetId) {
|
|
10987
|
+
return applySlot(targetId, { position: "replaceChildrenText" });
|
|
10988
|
+
}
|
|
10989
|
+
var findAllApplySlotMetadata = (target) => {
|
|
10990
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
10991
|
+
return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
|
|
10992
|
+
};
|
|
10993
|
+
|
|
10986
10994
|
// ../simple-boot/dist/esm/index.js
|
|
10987
10995
|
var import_reflect_metadata = __toESM(require_Reflect(), 1);
|
|
10988
10996
|
|
|
@@ -11130,9 +11138,9 @@ var MetaDataAtomic = class {
|
|
|
11130
11138
|
}
|
|
11131
11139
|
};
|
|
11132
11140
|
var MetaDataPropertyAtomic = class extends MetaDataAtomic {
|
|
11133
|
-
constructor(target, metaData,
|
|
11141
|
+
constructor(target, metaData, property2, parameter) {
|
|
11134
11142
|
super(target, metaData);
|
|
11135
|
-
this.property =
|
|
11143
|
+
this.property = property2;
|
|
11136
11144
|
this.parameter = parameter;
|
|
11137
11145
|
}
|
|
11138
11146
|
call(...parameter) {
|
|
@@ -13605,9 +13613,8 @@ export {
|
|
|
13605
13613
|
ADD_EVENT_LISTENER_METADATA_KEY,
|
|
13606
13614
|
APPLY_NODE_METADATA_KEY,
|
|
13607
13615
|
APPLY_SLOT_METADATA_KEY,
|
|
13608
|
-
ATTRIBUTE_APPLY_METADATA_KEY,
|
|
13609
13616
|
ATTRIBUTE_CHANGED_WILDCARD,
|
|
13610
|
-
|
|
13617
|
+
ATTRIBUTE_METADATA_KEY,
|
|
13611
13618
|
BROWSER_GLOBALS,
|
|
13612
13619
|
CLASS_METADATA_KEY,
|
|
13613
13620
|
DOM_EVENT_NAMES,
|
|
@@ -13627,7 +13634,7 @@ export {
|
|
|
13627
13634
|
ON_CONNECTED_METADATA_KEY,
|
|
13628
13635
|
ON_CONNECTED_SWC_APP_METADATA_KEY,
|
|
13629
13636
|
ON_INITIALIZE_METADATA_KEY,
|
|
13630
|
-
|
|
13637
|
+
PROPERTY_METADATA_KEY,
|
|
13631
13638
|
PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
|
|
13632
13639
|
QUERY_ALL_METADATA_KEY,
|
|
13633
13640
|
QUERY_METADATA_KEY,
|
|
@@ -13659,43 +13666,29 @@ export {
|
|
|
13659
13666
|
addEventListenerDocument,
|
|
13660
13667
|
addEventListenerThis,
|
|
13661
13668
|
addEventListenerWindow,
|
|
13669
|
+
afterBeginLightNodeThis,
|
|
13670
|
+
afterBeginNodeThis,
|
|
13662
13671
|
allAppHost,
|
|
13663
13672
|
allParentHost,
|
|
13673
|
+
appendHtmlSlot,
|
|
13674
|
+
appendSlot,
|
|
13675
|
+
appendTextSlot,
|
|
13664
13676
|
applyAttribute,
|
|
13665
|
-
applyAttributeThis,
|
|
13666
13677
|
applyClass,
|
|
13667
13678
|
applyClassThis,
|
|
13668
13679
|
applyNode,
|
|
13669
|
-
applyNodeInnerHtml,
|
|
13670
|
-
applyNodeInnerText,
|
|
13671
|
-
applyNodeReplaceChildren,
|
|
13672
13680
|
applyNodeThis,
|
|
13673
|
-
|
|
13674
|
-
applyNodeThisAfterBeginLightDom,
|
|
13675
|
-
applyNodeThisBeforeEnd,
|
|
13676
|
-
applyNodeThisBeforeEndLightDom,
|
|
13677
|
-
applyNodeThisBeforeEndShadow,
|
|
13678
|
-
applyNodeThisReplaceChildren,
|
|
13679
|
-
applyNodeThisReplaceChildrenLightDom,
|
|
13681
|
+
applyProperty,
|
|
13680
13682
|
applySlot,
|
|
13681
|
-
applySlotAppend,
|
|
13682
|
-
applySlotAppendHtml,
|
|
13683
|
-
applySlotAppendText,
|
|
13684
|
-
applySlotClear,
|
|
13685
|
-
applySlotPrepend,
|
|
13686
|
-
applySlotPrependHtml,
|
|
13687
|
-
applySlotPrependText,
|
|
13688
|
-
applySlotReplaceChildren,
|
|
13689
|
-
applySlotReplaceChildrenHtml,
|
|
13690
|
-
applySlotReplaceChildrenText,
|
|
13691
13683
|
applyStyle,
|
|
13692
13684
|
applyStyleThis,
|
|
13693
|
-
applyThisInnerHtmlNode,
|
|
13694
|
-
applyThisInnerHtmlNodeLightDom,
|
|
13695
|
-
applyThisReplaceChildrenNodeLightDom,
|
|
13696
13685
|
attribute,
|
|
13697
13686
|
attributeThis,
|
|
13687
|
+
beforeEndLightNodeThis,
|
|
13688
|
+
beforeEndNodeThis,
|
|
13689
|
+
beforeEndShadowNodeThis,
|
|
13698
13690
|
changedAttributeThis,
|
|
13691
|
+
clearSlot,
|
|
13699
13692
|
commentNode,
|
|
13700
13693
|
convertAttributeValue,
|
|
13701
13694
|
convertValue2 as convertValue,
|
|
@@ -13725,6 +13718,8 @@ export {
|
|
|
13725
13718
|
findAllOnConnectedAfterMetadata,
|
|
13726
13719
|
findAllOnConnectedBeforeMetadata,
|
|
13727
13720
|
findAllOnConnectedMetadata,
|
|
13721
|
+
findAllPropertyApplyMetadata,
|
|
13722
|
+
findAllPropertyMetadata,
|
|
13728
13723
|
findAllStateMetadata,
|
|
13729
13724
|
findAllStyleMetadata,
|
|
13730
13725
|
getAddEventListenerMetadata,
|
|
@@ -13749,6 +13744,15 @@ export {
|
|
|
13749
13744
|
htmlSectionElement,
|
|
13750
13745
|
htmlSpanElement,
|
|
13751
13746
|
htmlUlElement,
|
|
13747
|
+
innerHtmlLightNode,
|
|
13748
|
+
innerHtmlLightNodeThis,
|
|
13749
|
+
innerHtmlNode,
|
|
13750
|
+
innerHtmlNodeThis,
|
|
13751
|
+
innerHtmlShadowNode,
|
|
13752
|
+
innerTextLightNode,
|
|
13753
|
+
innerTextNode,
|
|
13754
|
+
innerTextNodeThis,
|
|
13755
|
+
innerTextShadowNode,
|
|
13752
13756
|
isSSR,
|
|
13753
13757
|
onAddEventListener,
|
|
13754
13758
|
onAdopted,
|
|
@@ -13758,13 +13762,18 @@ export {
|
|
|
13758
13762
|
onConnectedAfter,
|
|
13759
13763
|
onConnectedBefore,
|
|
13760
13764
|
onConnectedCompleted,
|
|
13761
|
-
|
|
13762
|
-
|
|
13765
|
+
onConnectedLight,
|
|
13766
|
+
onConnectedShadow,
|
|
13763
13767
|
onConnectedSwcApp,
|
|
13764
13768
|
onDisconnected,
|
|
13765
13769
|
onDisconnectedAfter,
|
|
13766
13770
|
onDisconnectedBefore,
|
|
13767
13771
|
onInitialize,
|
|
13772
|
+
prependHtmlSlot,
|
|
13773
|
+
prependSlot,
|
|
13774
|
+
prependTextSlot,
|
|
13775
|
+
property,
|
|
13776
|
+
propertyThis,
|
|
13768
13777
|
publishSwcAppMessage,
|
|
13769
13778
|
query,
|
|
13770
13779
|
queryAll,
|
|
@@ -13774,14 +13783,19 @@ export {
|
|
|
13774
13783
|
queryHost,
|
|
13775
13784
|
queryThis,
|
|
13776
13785
|
queryWindow,
|
|
13777
|
-
removeAttribute,
|
|
13778
|
-
removeAttributeThis,
|
|
13779
13786
|
removeClass,
|
|
13780
13787
|
removeClassThis,
|
|
13781
13788
|
removeSSRAttribute,
|
|
13782
13789
|
removeStyle,
|
|
13783
13790
|
removeStyleThis,
|
|
13784
|
-
|
|
13791
|
+
replaceChildrenHtmlSlot,
|
|
13792
|
+
replaceChildrenLightNodeThis,
|
|
13793
|
+
replaceChildrenNode,
|
|
13794
|
+
replaceChildrenNodeThis,
|
|
13795
|
+
replaceChildrenSlot,
|
|
13796
|
+
replaceChildrenTextSlot,
|
|
13797
|
+
resolveAttributeTargets,
|
|
13798
|
+
resolvePropertyTargets,
|
|
13785
13799
|
setAttribute,
|
|
13786
13800
|
setAttributeThis,
|
|
13787
13801
|
setClass,
|
|
@@ -13808,8 +13822,6 @@ export {
|
|
|
13808
13822
|
textNode,
|
|
13809
13823
|
toggleClass,
|
|
13810
13824
|
toggleClassThis,
|
|
13811
|
-
updateAttribute,
|
|
13812
|
-
updateAttributeThis,
|
|
13813
13825
|
updateClass,
|
|
13814
13826
|
updateClassThis,
|
|
13815
13827
|
updateStyle,
|