@dooboostore/simple-web-component 1.0.30 → 1.0.32
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 +220 -1
- package/dist/cjs/decorators/applyStyle.js +1 -1
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +17 -1
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +29 -12
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/elements/SwcAppEngine.js +3 -3
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +1 -8
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +71 -78
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +66 -81
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +52 -96
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +60 -103
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/SwcSubTemplates.js +0 -27
- package/dist/cjs/elements/SwcSubTemplates.js.map +2 -2
- package/dist/cjs/elements/register.js +314 -343
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +1 -8
- package/dist/cjs/router/ElementRouter.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +31 -24
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +1 -1
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +18 -2
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +27 -10
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/elements/SwcAppEngine.js +3 -3
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +1 -8
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +72 -60
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +67 -63
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +53 -78
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +61 -85
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/SwcSubTemplates.js +0 -8
- package/dist/esm/elements/SwcSubTemplates.js.map +2 -2
- package/dist/esm/elements/register.js +246 -275
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +1 -8
- package/dist/esm/router/ElementRouter.js.map +2 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +31 -24
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2223 -2009
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/SwcAsync.d.ts +1 -11
- package/dist/types/elements/SwcAsync.d.ts.map +1 -1
- package/dist/types/elements/SwcChoose.d.ts +1 -13
- package/dist/types/elements/SwcChoose.d.ts.map +1 -1
- package/dist/types/elements/SwcIf.d.ts +1 -13
- package/dist/types/elements/SwcIf.d.ts.map +1 -1
- package/dist/types/elements/SwcLoop.d.ts +1 -13
- package/dist/types/elements/SwcLoop.d.ts.map +1 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +6 -6
- package/dist/types/elements/SwcSubTemplates.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/router/ElementRouter.d.ts.map +1 -1
- package/dist/types/types.d.ts +11 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +10 -0
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2223 -2009
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/applyStyle.ts +1 -1
- package/src/decorators/attribute.ts +35 -30
- package/src/decorators/elementDefine.ts +32 -10
- package/src/elements/SwcAppEngine.ts +3 -3
- package/src/elements/SwcAppMixin.ts +6 -27
- package/src/elements/SwcAsync.ts +75 -57
- package/src/elements/SwcChoose.ts +69 -77
- package/src/elements/SwcIf.ts +50 -75
- package/src/elements/SwcLoop.ts +56 -82
- package/src/elements/SwcSubTemplates.ts +6 -6
- package/src/elements/register.ts +234 -285
- package/src/router/ElementRouter.ts +1 -12
- package/src/types.ts +9 -2
- package/src/utils/Utils.ts +48 -37
|
@@ -1181,7 +1181,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1181
1181
|
elementDefine: () => elementDefine,
|
|
1182
1182
|
emitCustomEvent: () => emitCustomEvent,
|
|
1183
1183
|
emitCustomEventHost: () => emitCustomEventHost,
|
|
1184
|
-
ensureInit: () =>
|
|
1184
|
+
ensureInit: () => ensureInit,
|
|
1185
1185
|
findAllApplyNodeMetadata: () => findAllApplyNodeMetadata,
|
|
1186
1186
|
findAllAttributeApplyMetadata: () => findAllAttributeApplyMetadata,
|
|
1187
1187
|
findAllAttributeChangedMetadata: () => findAllAttributeChangedMetadata,
|
|
@@ -5873,6 +5873,176 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5873
5873
|
})(Path = Expression2.Path || (Expression2.Path = {}));
|
|
5874
5874
|
})(Expression || (Expression = {}));
|
|
5875
5875
|
|
|
5876
|
+
// ../core/dist/esm/expression/ActionExpression.js
|
|
5877
|
+
var ActionExpression = class {
|
|
5878
|
+
constructor(value, config) {
|
|
5879
|
+
this.originalTemplate = value || "";
|
|
5880
|
+
this.idToMarker = /* @__PURE__ */ new Map();
|
|
5881
|
+
this.processedIds = /* @__PURE__ */ new Set();
|
|
5882
|
+
this.expressions = [];
|
|
5883
|
+
if (!value || typeof value !== "string") {
|
|
5884
|
+
this.maskingTemplate = this.originalTemplate;
|
|
5885
|
+
this.currentTemplate = this.originalTemplate;
|
|
5886
|
+
return;
|
|
5887
|
+
}
|
|
5888
|
+
this.maskingTemplate = value;
|
|
5889
|
+
this.currentTemplate = value;
|
|
5890
|
+
if (config?.wrapExpression) {
|
|
5891
|
+
this.processWrapExpressions(this.currentTemplate, config.wrapExpression);
|
|
5892
|
+
}
|
|
5893
|
+
this.processCallReturnExpressions(this.currentTemplate);
|
|
5894
|
+
this.processCallExpressions(this.currentTemplate);
|
|
5895
|
+
this.processReplaceExpressions(this.currentTemplate);
|
|
5896
|
+
this.sortExpressionsByPosition();
|
|
5897
|
+
this.maskingTemplate = this.currentTemplate;
|
|
5898
|
+
}
|
|
5899
|
+
sortExpressionsByPosition() {
|
|
5900
|
+
this.expressions.forEach((expr) => {
|
|
5901
|
+
const index = this.originalTemplate.indexOf(expr.original);
|
|
5902
|
+
expr.index = index >= 0 ? index : 0;
|
|
5903
|
+
});
|
|
5904
|
+
this.expressions.sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
|
|
5905
|
+
}
|
|
5906
|
+
processWrapExpressions(value, wrapExpression) {
|
|
5907
|
+
const wrapChar = wrapExpression.trim();
|
|
5908
|
+
const escapedWrap = wrapChar.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5909
|
+
const wrappedCallReturnRegex = new RegExp(`${escapedWrap}\\{\\{=\\s*(.+?)\\s*\\}\\}${escapedWrap}`, "g");
|
|
5910
|
+
let match;
|
|
5911
|
+
while ((match = wrappedCallReturnRegex.exec(value)) !== null) {
|
|
5912
|
+
this.addExpression(match, "call-return", wrapChar);
|
|
5913
|
+
}
|
|
5914
|
+
const wrappedCallRegex = new RegExp(`${escapedWrap}\\{\\{@\\s*(.+?)\\s*\\}\\}${escapedWrap}`, "g");
|
|
5915
|
+
while ((match = wrappedCallRegex.exec(value)) !== null) {
|
|
5916
|
+
this.addExpression(match, "call", wrapChar);
|
|
5917
|
+
}
|
|
5918
|
+
const wrappedReplaceRegex = new RegExp(`${escapedWrap}\\{\\{(?![=@])\\s*(.+?)\\s*\\}\\}${escapedWrap}`, "g");
|
|
5919
|
+
while ((match = wrappedReplaceRegex.exec(value)) !== null) {
|
|
5920
|
+
this.addExpression(match, "replace", wrapChar);
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
processCallReturnExpressions(value) {
|
|
5924
|
+
const callReturnRegex = /(?<![a-zA-Z0-9$_@#.])\{\{=\s*(.+?)\s*\}\}(?![a-zA-Z0-9$_@#.])/g;
|
|
5925
|
+
let match;
|
|
5926
|
+
while ((match = callReturnRegex.exec(value)) !== null) {
|
|
5927
|
+
this.addExpression(match, "call-return");
|
|
5928
|
+
}
|
|
5929
|
+
}
|
|
5930
|
+
processCallExpressions(value) {
|
|
5931
|
+
const callRegex = /(?<![a-zA-Z0-9$_@#.])\{\{@\s*(.+?)\s*\}\}(?![a-zA-Z0-9$_@#.])/g;
|
|
5932
|
+
let match;
|
|
5933
|
+
while ((match = callRegex.exec(value)) !== null) {
|
|
5934
|
+
this.addExpression(match, "call");
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
processReplaceExpressions(value) {
|
|
5938
|
+
const replaceRegex = /(?<![a-zA-Z0-9$_@#.])\{\{(?![=@])\s*(.+?)\s*\}\}(?![a-zA-Z0-9$_@#.])/g;
|
|
5939
|
+
let match;
|
|
5940
|
+
while ((match = replaceRegex.exec(value)) !== null) {
|
|
5941
|
+
this.addExpression(match, "replace");
|
|
5942
|
+
}
|
|
5943
|
+
}
|
|
5944
|
+
addExpression(match, type, wrap) {
|
|
5945
|
+
const id = Math.random().toString(36).substr(2, 9);
|
|
5946
|
+
const original = match[0];
|
|
5947
|
+
const rawScript = match[1];
|
|
5948
|
+
const marker = `__EXPR_${id}__`;
|
|
5949
|
+
const expressionStart = original.substring(0, original.indexOf(rawScript));
|
|
5950
|
+
const expressionEnd = original.substring(original.indexOf(rawScript) + rawScript.length);
|
|
5951
|
+
this.idToMarker.set(id, marker);
|
|
5952
|
+
this.currentTemplate = this.currentTemplate.replace(original, marker);
|
|
5953
|
+
this.expressions.push({
|
|
5954
|
+
id,
|
|
5955
|
+
type,
|
|
5956
|
+
original,
|
|
5957
|
+
script: rawScript.trim(),
|
|
5958
|
+
expressionStart,
|
|
5959
|
+
expressionEnd,
|
|
5960
|
+
...wrap && { wrap }
|
|
5961
|
+
});
|
|
5962
|
+
}
|
|
5963
|
+
/**
|
|
5964
|
+
* 구현 메서드
|
|
5965
|
+
*/
|
|
5966
|
+
replace(idOrExpr, valueOrCallback) {
|
|
5967
|
+
const id = typeof idOrExpr === "string" ? idOrExpr : idOrExpr.id;
|
|
5968
|
+
let expr;
|
|
5969
|
+
if (typeof valueOrCallback === "function") {
|
|
5970
|
+
expr = this.expressions.find((e) => e.id === id);
|
|
5971
|
+
if (!expr) return this.getUnprocessedTemplate();
|
|
5972
|
+
}
|
|
5973
|
+
const value = typeof valueOrCallback === "function" ? valueOrCallback(expr) : valueOrCallback;
|
|
5974
|
+
const marker = this.idToMarker.get(id);
|
|
5975
|
+
if (marker) {
|
|
5976
|
+
this.processedIds.add(id);
|
|
5977
|
+
this.currentTemplate = this.currentTemplate.replace(marker, value);
|
|
5978
|
+
}
|
|
5979
|
+
return this.getUnprocessedTemplate();
|
|
5980
|
+
}
|
|
5981
|
+
/**
|
|
5982
|
+
* 구현 메서드
|
|
5983
|
+
*/
|
|
5984
|
+
getExpressions(typeOrOptions) {
|
|
5985
|
+
if (!typeOrOptions) {
|
|
5986
|
+
return this.expressions;
|
|
5987
|
+
}
|
|
5988
|
+
if (typeof typeOrOptions === "string") {
|
|
5989
|
+
return this.expressions.filter((expr) => expr.type === typeOrOptions);
|
|
5990
|
+
}
|
|
5991
|
+
const options = typeOrOptions;
|
|
5992
|
+
return this.expressions.filter((expr) => {
|
|
5993
|
+
if (options.type && expr.type !== options.type) return false;
|
|
5994
|
+
if ("wrap" in options && expr.wrap !== options.wrap) return false;
|
|
5995
|
+
return true;
|
|
5996
|
+
});
|
|
5997
|
+
}
|
|
5998
|
+
/**
|
|
5999
|
+
* 구현 메서드
|
|
6000
|
+
*/
|
|
6001
|
+
getFirstExpression(typeOrOptions) {
|
|
6002
|
+
if (!typeOrOptions) {
|
|
6003
|
+
return this.getExpressions()[0];
|
|
6004
|
+
}
|
|
6005
|
+
if (typeof typeOrOptions === "string") {
|
|
6006
|
+
return this.getExpressions(typeOrOptions)[0];
|
|
6007
|
+
}
|
|
6008
|
+
return this.getExpressions(typeOrOptions)[0];
|
|
6009
|
+
}
|
|
6010
|
+
/**
|
|
6011
|
+
* 원본 템플릿을 반환합니다.
|
|
6012
|
+
*/
|
|
6013
|
+
getOriginalTemplate() {
|
|
6014
|
+
return this.originalTemplate;
|
|
6015
|
+
}
|
|
6016
|
+
/**
|
|
6017
|
+
* 마스킹 처리된 템플릿을 반환합니다.
|
|
6018
|
+
*/
|
|
6019
|
+
getMaskingTemplate() {
|
|
6020
|
+
return this.maskingTemplate;
|
|
6021
|
+
}
|
|
6022
|
+
/**
|
|
6023
|
+
* 현재 처리 상태의 템플릿을 반환합니다.
|
|
6024
|
+
*/
|
|
6025
|
+
getCurrentTemplate() {
|
|
6026
|
+
return this.currentTemplate;
|
|
6027
|
+
}
|
|
6028
|
+
/**
|
|
6029
|
+
* 미처리된 마커들을 원본으로 복원한 템플릿을 반환합니다.
|
|
6030
|
+
* replace() 호출 후 처리되지 않은 표현식들을 원본 형태로 되돌립니다.
|
|
6031
|
+
*/
|
|
6032
|
+
getUnprocessedTemplate() {
|
|
6033
|
+
let result = this.currentTemplate;
|
|
6034
|
+
for (const expr of this.expressions) {
|
|
6035
|
+
if (!this.processedIds.has(expr.id)) {
|
|
6036
|
+
const m = this.idToMarker.get(expr.id);
|
|
6037
|
+
if (m) {
|
|
6038
|
+
result = result.replace(m, expr.original);
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
return result;
|
|
6043
|
+
}
|
|
6044
|
+
};
|
|
6045
|
+
|
|
5876
6046
|
// src/decorators/addEventListener.ts
|
|
5877
6047
|
var ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
|
|
5878
6048
|
function addEventListener(selectorOrTarget, type, options = {}) {
|
|
@@ -5958,661 +6128,425 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5958
6128
|
return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
|
|
5959
6129
|
};
|
|
5960
6130
|
|
|
5961
|
-
// src/
|
|
5962
|
-
var
|
|
5963
|
-
var
|
|
5964
|
-
|
|
5965
|
-
if (
|
|
5966
|
-
|
|
5967
|
-
|
|
6131
|
+
// src/utils/Utils.ts
|
|
6132
|
+
var SWC_NOT_FOUND = Symbol.for("simple-web-component:not-found");
|
|
6133
|
+
var htmlFragment = (html, doc) => {
|
|
6134
|
+
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
6135
|
+
if (!d) throw new Error("Document is not available");
|
|
6136
|
+
const template = d.createElement("template");
|
|
6137
|
+
template.innerHTML = html.trim();
|
|
6138
|
+
return template.content;
|
|
5968
6139
|
};
|
|
5969
|
-
var
|
|
5970
|
-
const
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
if (
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
results.push(currentWin.document);
|
|
5987
|
-
} else {
|
|
5988
|
-
const hostSet = SwcUtils.getHostSet(inst);
|
|
5989
|
-
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
5990
|
-
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
5991
|
-
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
5992
|
-
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
5993
|
-
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
5994
|
-
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
5995
|
-
else {
|
|
5996
|
-
if (r === "shadow") {
|
|
5997
|
-
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
5998
|
-
if (found) results.push(...found);
|
|
5999
|
-
} else if (r === "light") {
|
|
6000
|
-
const found = inst.querySelectorAll(selector);
|
|
6001
|
-
if (found) results.push(...found);
|
|
6002
|
-
} else if (r === "all") {
|
|
6003
|
-
const sMatch = inst.shadowRoot?.querySelectorAll(selector);
|
|
6004
|
-
const lMatch = inst.querySelectorAll(selector);
|
|
6005
|
-
if (sMatch) results.push(...sMatch);
|
|
6006
|
-
if (lMatch) results.push(...lMatch);
|
|
6007
|
-
} else {
|
|
6008
|
-
const found = (inst.shadowRoot || inst).querySelectorAll(selector);
|
|
6009
|
-
if (found) results.push(...found);
|
|
6010
|
-
}
|
|
6011
|
-
}
|
|
6140
|
+
var textNode = (text, doc) => {
|
|
6141
|
+
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
6142
|
+
if (!d) throw new Error("Document is not available");
|
|
6143
|
+
return d.createTextNode(text !== void 0 && text !== null ? String(text) : "");
|
|
6144
|
+
};
|
|
6145
|
+
var commentNode = (comment, doc) => {
|
|
6146
|
+
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
6147
|
+
if (!d) throw new Error("Document is not available");
|
|
6148
|
+
return d.createComment(comment !== void 0 && comment !== null ? String(comment) : "");
|
|
6149
|
+
};
|
|
6150
|
+
var createElement = (tagName, options) => {
|
|
6151
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6152
|
+
if (!d) throw new Error("Document is not available");
|
|
6153
|
+
const el = d.createElement(tagName);
|
|
6154
|
+
if (options?.html) el.innerHTML = options.html;
|
|
6155
|
+
if (options?.attrs) {
|
|
6156
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6012
6157
|
}
|
|
6013
|
-
return
|
|
6158
|
+
return el;
|
|
6014
6159
|
};
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
metaList = [];
|
|
6023
|
-
ReflectUtils.defineMetadata(ATTRIBUTE_FIELD_METADATA_KEY, metaList, constructor);
|
|
6024
|
-
}
|
|
6025
|
-
metaList.push({ propertyKey, selector, options, privateKey });
|
|
6026
|
-
const applySetAttribute = (inst, targets, attrName, nv) => {
|
|
6027
|
-
targets.forEach((it) => {
|
|
6028
|
-
if (it && typeof it.setAttribute === "function") {
|
|
6029
|
-
if (nv === null) {
|
|
6030
|
-
it.removeAttribute(attrName);
|
|
6031
|
-
} else {
|
|
6032
|
-
it.setAttribute(attrName, String(nv));
|
|
6033
|
-
}
|
|
6034
|
-
} else {
|
|
6035
|
-
inst[privateKey] = nv;
|
|
6036
|
-
}
|
|
6037
|
-
});
|
|
6038
|
-
};
|
|
6039
|
-
try {
|
|
6040
|
-
Object.defineProperty(target, propertyKey, {
|
|
6041
|
-
get() {
|
|
6042
|
-
const attrName = options.name || String(propertyKey);
|
|
6043
|
-
const conf = getElementConfig(this);
|
|
6044
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6045
|
-
const targetType = options.type || designType;
|
|
6046
|
-
const targets = resolveTargetEls(this, selector, options, currentWin);
|
|
6047
|
-
const primaryTarget = targets[0];
|
|
6048
|
-
if (primaryTarget && typeof primaryTarget.hasAttribute === "function") {
|
|
6049
|
-
if (primaryTarget.hasAttribute(attrName)) {
|
|
6050
|
-
const domVal = primaryTarget.getAttribute(attrName);
|
|
6051
|
-
return convertValue(domVal, targetType);
|
|
6052
|
-
}
|
|
6053
|
-
return null;
|
|
6054
|
-
}
|
|
6055
|
-
const data = convertValue(this[privateKey], targetType);
|
|
6056
|
-
return data;
|
|
6057
|
-
},
|
|
6058
|
-
set(nv) {
|
|
6059
|
-
const attrName = options.name || String(propertyKey);
|
|
6060
|
-
const conf = getElementConfig(this);
|
|
6061
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6062
|
-
const targets = resolveTargetEls(this, selector, options, currentWin);
|
|
6063
|
-
applySetAttribute(this, targets, attrName, nv);
|
|
6064
|
-
},
|
|
6065
|
-
enumerable: true,
|
|
6066
|
-
configurable: true
|
|
6067
|
-
});
|
|
6068
|
-
} catch (err) {
|
|
6069
|
-
console.error("[SWC] defineProperty error:", err);
|
|
6070
|
-
}
|
|
6071
|
-
};
|
|
6072
|
-
}
|
|
6073
|
-
function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
|
|
6074
|
-
if (propertyKeyOrOptions !== void 0 && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
6075
|
-
return attribute(":host", { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
6160
|
+
var htmlDivElement = (html, options) => {
|
|
6161
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6162
|
+
if (!d) throw new Error("Document is not available");
|
|
6163
|
+
const el = d.createElement("div");
|
|
6164
|
+
el.innerHTML = html.trim();
|
|
6165
|
+
if (options?.attrs) {
|
|
6166
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6076
6167
|
}
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
} else {
|
|
6087
|
-
return (target, propertyKey) => {
|
|
6088
|
-
return attribute(":host", { name: String(propertyKey) })(target, propertyKey);
|
|
6089
|
-
};
|
|
6168
|
+
return el;
|
|
6169
|
+
};
|
|
6170
|
+
var htmlSpanElement = (html, options) => {
|
|
6171
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6172
|
+
if (!d) throw new Error("Document is not available");
|
|
6173
|
+
const el = d.createElement("span");
|
|
6174
|
+
el.innerHTML = html.trim();
|
|
6175
|
+
if (options?.attrs) {
|
|
6176
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6090
6177
|
}
|
|
6091
|
-
|
|
6092
|
-
var findAllAttributeMetadata = (target) => {
|
|
6093
|
-
const actualTarget = target instanceof Function ? target : target.constructor;
|
|
6094
|
-
return ReflectUtils.findAllMetadata(ATTRIBUTE_FIELD_METADATA_KEY, actualTarget).flat();
|
|
6178
|
+
return el;
|
|
6095
6179
|
};
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
|
|
6106
|
-
}
|
|
6107
|
-
const name = attributeName || String(propertyKey);
|
|
6108
|
-
let methods = meta.get(name);
|
|
6109
|
-
if (!methods) {
|
|
6110
|
-
methods = [];
|
|
6111
|
-
meta.set(name, methods);
|
|
6112
|
-
}
|
|
6113
|
-
if (!methods.includes(propertyKey)) methods.push(propertyKey);
|
|
6114
|
-
};
|
|
6115
|
-
}
|
|
6116
|
-
var getChangedAttributeMetadata = (target) => {
|
|
6117
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
6118
|
-
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6180
|
+
var htmlButtonElement = (html, options) => {
|
|
6181
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6182
|
+
if (!d) throw new Error("Document is not available");
|
|
6183
|
+
const el = d.createElement("button");
|
|
6184
|
+
el.innerHTML = html.trim();
|
|
6185
|
+
if (options?.attrs) {
|
|
6186
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6187
|
+
}
|
|
6188
|
+
return el;
|
|
6119
6189
|
};
|
|
6120
|
-
var
|
|
6121
|
-
|
|
6190
|
+
var htmlUlElement = (options) => {
|
|
6191
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6192
|
+
if (!d) throw new Error("Document is not available");
|
|
6193
|
+
const el = d.createElement("ul");
|
|
6194
|
+
if (options?.attrs) {
|
|
6195
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6196
|
+
}
|
|
6197
|
+
return el;
|
|
6122
6198
|
};
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6199
|
+
var htmlLiElement = (html, options) => {
|
|
6200
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6201
|
+
if (!d) throw new Error("Document is not available");
|
|
6202
|
+
const el = d.createElement("li");
|
|
6203
|
+
el.innerHTML = html.trim();
|
|
6204
|
+
if (options?.attrs) {
|
|
6205
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6206
|
+
}
|
|
6207
|
+
return el;
|
|
6132
6208
|
};
|
|
6133
|
-
var
|
|
6134
|
-
|
|
6135
|
-
if (
|
|
6136
|
-
|
|
6137
|
-
|
|
6209
|
+
var htmlAElement = (html, options) => {
|
|
6210
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6211
|
+
if (!d) throw new Error("Document is not available");
|
|
6212
|
+
const el = d.createElement("a");
|
|
6213
|
+
el.innerHTML = html.trim();
|
|
6214
|
+
if (options?.href) el.href = options.href;
|
|
6215
|
+
if (options?.attrs) {
|
|
6216
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6138
6217
|
}
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6218
|
+
return el;
|
|
6219
|
+
};
|
|
6220
|
+
var htmlPElement = (html, options) => {
|
|
6221
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6222
|
+
if (!d) throw new Error("Document is not available");
|
|
6223
|
+
const el = d.createElement("p");
|
|
6224
|
+
el.innerHTML = html.trim();
|
|
6225
|
+
if (options?.attrs) {
|
|
6226
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6144
6227
|
}
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
|
|
6155
|
-
else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
|
|
6228
|
+
return el;
|
|
6229
|
+
};
|
|
6230
|
+
var htmlHeadingElement = (level, html, options) => {
|
|
6231
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6232
|
+
if (!d) throw new Error("Document is not available");
|
|
6233
|
+
const el = d.createElement(`h${level}`);
|
|
6234
|
+
el.innerHTML = html.trim();
|
|
6235
|
+
if (options?.attrs) {
|
|
6236
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6156
6237
|
}
|
|
6238
|
+
return el;
|
|
6157
6239
|
};
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
const targetEl = getTarget();
|
|
6193
|
-
const res = original.apply(this, args);
|
|
6194
|
-
const runApply = (target, val) => {
|
|
6195
|
-
const pos = options.position || "beforeEnd";
|
|
6196
|
-
const defaultFilter = (t, v) => {
|
|
6197
|
-
if (v instanceof Node) return !t.contains(v);
|
|
6198
|
-
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
6199
|
-
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
6200
|
-
return true;
|
|
6201
|
-
};
|
|
6202
|
-
const activeFilter = options.filter || defaultFilter;
|
|
6203
|
-
if (activeFilter(target, val, hostSet)) {
|
|
6204
|
-
applyToDom(target, val, pos, currentDoc);
|
|
6205
|
-
}
|
|
6206
|
-
};
|
|
6207
|
-
if (res instanceof Promise) {
|
|
6208
|
-
if (targetEl && options.loading) {
|
|
6209
|
-
const loadingRes = options.loading.call(this, hostSet);
|
|
6210
|
-
applyToDom(targetEl, loadingRes, options.position || "beforeEnd", currentDoc);
|
|
6211
|
-
}
|
|
6212
|
-
return res.then((finalRes) => {
|
|
6213
|
-
if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
|
|
6214
|
-
return finalRes;
|
|
6215
|
-
});
|
|
6216
|
-
} else {
|
|
6217
|
-
if (res !== void 0 && targetEl) runApply(targetEl, res);
|
|
6218
|
-
return res;
|
|
6240
|
+
var htmlSectionElement = (options) => {
|
|
6241
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6242
|
+
if (!d) throw new Error("Document is not available");
|
|
6243
|
+
const el = d.createElement("section");
|
|
6244
|
+
if (options?.attrs) {
|
|
6245
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6246
|
+
}
|
|
6247
|
+
return el;
|
|
6248
|
+
};
|
|
6249
|
+
var htmlArticleElement = (options) => {
|
|
6250
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
6251
|
+
if (!d) throw new Error("Document is not available");
|
|
6252
|
+
const el = d.createElement("article");
|
|
6253
|
+
if (options?.attrs) {
|
|
6254
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6255
|
+
}
|
|
6256
|
+
return el;
|
|
6257
|
+
};
|
|
6258
|
+
var SwcUtils;
|
|
6259
|
+
((SwcUtils2) => {
|
|
6260
|
+
SwcUtils2.parsePathPatternsSetAttributeString = (pathPattern, path) => {
|
|
6261
|
+
return JSON.stringify(SwcUtils2.parsePathPatternsSet(pathPattern, path)).replace(/"/g, "'");
|
|
6262
|
+
};
|
|
6263
|
+
SwcUtils2.parsePathPatternsSet = (pathPattern, path) => {
|
|
6264
|
+
return {
|
|
6265
|
+
path,
|
|
6266
|
+
pathData: SwcUtils2.parsePathPatterns(pathPattern, path)
|
|
6267
|
+
};
|
|
6268
|
+
};
|
|
6269
|
+
SwcUtils2.parsePathPatterns = (pathPattern, path) => {
|
|
6270
|
+
for (const pattern of pathPattern) {
|
|
6271
|
+
const data = SwcUtils2.parsePathPattern(pattern, path || "/");
|
|
6272
|
+
if (data !== null) {
|
|
6273
|
+
return data;
|
|
6219
6274
|
}
|
|
6275
|
+
}
|
|
6276
|
+
};
|
|
6277
|
+
SwcUtils2.getHelperSet = (win) => {
|
|
6278
|
+
const doc = win.document;
|
|
6279
|
+
return {
|
|
6280
|
+
$d: doc,
|
|
6281
|
+
$w: win,
|
|
6282
|
+
$q: (sel, root) => (root ?? doc).querySelector(sel),
|
|
6283
|
+
$qa: (sel, root) => Array.from((root ?? doc).querySelectorAll(sel)),
|
|
6284
|
+
$qi: (id, root) => (root ?? doc).getElementById(id)
|
|
6220
6285
|
};
|
|
6221
6286
|
};
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6287
|
+
SwcUtils2.getHelperAndHostSet = (win, el) => {
|
|
6288
|
+
const helperSet = (0, SwcUtils2.getHelperSet)(win);
|
|
6289
|
+
const hostSet = (0, SwcUtils2.getHostSet)(el);
|
|
6290
|
+
return {
|
|
6291
|
+
...helperSet,
|
|
6292
|
+
...hostSet,
|
|
6293
|
+
$this: el
|
|
6294
|
+
};
|
|
6295
|
+
};
|
|
6296
|
+
SwcUtils2.getValueByPath = (obj, path, rootName) => {
|
|
6297
|
+
if (!obj || !path) return SWC_NOT_FOUND;
|
|
6298
|
+
const parts = path.split(".");
|
|
6299
|
+
let current = obj;
|
|
6300
|
+
for (const part of parts) {
|
|
6301
|
+
if (current === null || current === void 0) return SWC_NOT_FOUND;
|
|
6302
|
+
current = current[part];
|
|
6229
6303
|
}
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
return applyNode(":host", { position: "replaceChildren", ...opt });
|
|
6242
|
-
}
|
|
6243
|
-
function applyInnerHtmlNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6244
|
-
if (propertyKey !== void 0) return applyNode(":host", { position: "innerHtml" })(targetOrOptions, propertyKey, descriptor);
|
|
6245
|
-
const opt = targetOrOptions || {};
|
|
6246
|
-
return applyNode(":host", { position: "innerHtml", ...opt });
|
|
6247
|
-
}
|
|
6248
|
-
function applyReplaceChildrenNode(selector, options = {}) {
|
|
6249
|
-
return applyNode(selector, { ...options, position: "replaceChildren" });
|
|
6250
|
-
}
|
|
6251
|
-
function applyInnerHtmlNode(selector, options = {}) {
|
|
6252
|
-
return applyNode(selector, { ...options, position: "innerHtml" });
|
|
6253
|
-
}
|
|
6254
|
-
|
|
6255
|
-
// src/decorators/query.ts
|
|
6256
|
-
var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
6257
|
-
function query(selectorOrTarget, options = {}) {
|
|
6258
|
-
return (targetObj, propertyKey, descriptor) => {
|
|
6259
|
-
if (descriptor !== void 0) {
|
|
6260
|
-
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
6304
|
+
return current;
|
|
6305
|
+
};
|
|
6306
|
+
SwcUtils2.findNearestSwcHost = (el) => {
|
|
6307
|
+
if (el.__swc_host) return el.__swc_host;
|
|
6308
|
+
let current = el.parentElement || el.getRootNode?.()?.host;
|
|
6309
|
+
const doc = el.ownerDocument;
|
|
6310
|
+
const win = doc?.defaultView || (typeof window !== "undefined" ? window : void 0);
|
|
6311
|
+
while (current && current !== doc && current !== win) {
|
|
6312
|
+
if (current.__swc_host) return current.__swc_host;
|
|
6313
|
+
if (getElementConfig(current)) return current;
|
|
6314
|
+
current = current.parentElement || current.getRootNode?.()?.host;
|
|
6261
6315
|
}
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6316
|
+
return void 0;
|
|
6317
|
+
};
|
|
6318
|
+
SwcUtils2.findAllSwcHosts = (el) => {
|
|
6319
|
+
const hosts = [];
|
|
6320
|
+
let current = (0, SwcUtils2.findNearestSwcHost)(el);
|
|
6321
|
+
while (current) {
|
|
6322
|
+
hosts.push(current);
|
|
6323
|
+
current = (0, SwcUtils2.findNearestSwcHost)(current);
|
|
6267
6324
|
}
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
if (
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
if (r === "shadow")
|
|
6309
|
-
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
6310
|
-
if (r === "light")
|
|
6311
|
-
return this.querySelector(selector);
|
|
6312
|
-
if (r === "all") {
|
|
6313
|
-
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
6314
|
-
return shadowMatch || this.querySelector(selector);
|
|
6315
|
-
}
|
|
6316
|
-
return (this.shadowRoot || this).querySelector(selector);
|
|
6317
|
-
},
|
|
6318
|
-
set(nv) {
|
|
6319
|
-
ensureInit2(this);
|
|
6320
|
-
if (nv === null || nv === void 0) {
|
|
6321
|
-
const selector = selectorOrTarget;
|
|
6322
|
-
if (selector.startsWith(":") && selector !== ":host")
|
|
6323
|
-
return;
|
|
6324
|
-
const r = options.root || "auto";
|
|
6325
|
-
const targets = [];
|
|
6326
|
-
if (r === "shadow") {
|
|
6327
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
6328
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
6329
|
-
} else if (r === "light") {
|
|
6330
|
-
if (this.querySelector(selector))
|
|
6331
|
-
targets.push(this.querySelector(selector));
|
|
6332
|
-
} else if (r === "all") {
|
|
6333
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
6334
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
6335
|
-
if (this.querySelector(selector))
|
|
6336
|
-
targets.push(this.querySelector(selector));
|
|
6337
|
-
} else {
|
|
6338
|
-
const el = (this.shadowRoot || this).querySelector(selector);
|
|
6339
|
-
if (el)
|
|
6340
|
-
targets.push(el);
|
|
6341
|
-
}
|
|
6342
|
-
targets.forEach((t) => t.remove());
|
|
6325
|
+
return hosts.reverse();
|
|
6326
|
+
};
|
|
6327
|
+
SwcUtils2.getHosts = (el) => {
|
|
6328
|
+
const ancestors = (0, SwcUtils2.findAllSwcHosts)(el);
|
|
6329
|
+
if (getElementConfig(el)) return [...ancestors, el];
|
|
6330
|
+
return ancestors;
|
|
6331
|
+
};
|
|
6332
|
+
SwcUtils2.getHost = (el) => {
|
|
6333
|
+
if (getElementConfig(el)) return el;
|
|
6334
|
+
return (0, SwcUtils2.findNearestSwcHost)(el);
|
|
6335
|
+
};
|
|
6336
|
+
SwcUtils2.getAppHosts = (el) => {
|
|
6337
|
+
const hosts = (0, SwcUtils2.getHosts)(el);
|
|
6338
|
+
return hosts.filter((host2) => host2.tagName.toLowerCase() === "swc-app" || host2.getAttribute("is")?.startsWith("swc-app-"));
|
|
6339
|
+
};
|
|
6340
|
+
SwcUtils2.getAppHost = (el) => {
|
|
6341
|
+
const appHosts = (0, SwcUtils2.getAppHosts)(el);
|
|
6342
|
+
const appHostsWithoutSelf = appHosts.filter((h) => h !== el);
|
|
6343
|
+
return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : void 0;
|
|
6344
|
+
};
|
|
6345
|
+
SwcUtils2.findParentAppHostDirect = (el) => {
|
|
6346
|
+
const appHosts = (0, SwcUtils2.findAllParentAppHostsDirect)(el);
|
|
6347
|
+
return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;
|
|
6348
|
+
};
|
|
6349
|
+
SwcUtils2.findAllParentAppHostsDirect = (el) => {
|
|
6350
|
+
const appHosts = [];
|
|
6351
|
+
let current = el;
|
|
6352
|
+
while (current) {
|
|
6353
|
+
const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
|
|
6354
|
+
if (isAppHost) {
|
|
6355
|
+
appHosts.push(current);
|
|
6356
|
+
}
|
|
6357
|
+
if (current.parentElement) {
|
|
6358
|
+
current = current.parentElement;
|
|
6359
|
+
} else {
|
|
6360
|
+
const root = current.getRootNode();
|
|
6361
|
+
if (root instanceof ShadowRoot) {
|
|
6362
|
+
current = root.host;
|
|
6363
|
+
} else {
|
|
6364
|
+
break;
|
|
6343
6365
|
}
|
|
6344
|
-
}
|
|
6345
|
-
|
|
6346
|
-
|
|
6366
|
+
}
|
|
6367
|
+
}
|
|
6368
|
+
return appHosts.reverse();
|
|
6369
|
+
};
|
|
6370
|
+
SwcUtils2.getHostSet = (el) => {
|
|
6371
|
+
const ancestors = (0, SwcUtils2.findAllSwcHosts)(el);
|
|
6372
|
+
const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;
|
|
6373
|
+
const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;
|
|
6374
|
+
const $hosts = ancestors;
|
|
6375
|
+
const $firstHost = ancestors.length > 0 ? ancestors[0] : null;
|
|
6376
|
+
const loopContext = {};
|
|
6377
|
+
let curr = el;
|
|
6378
|
+
const rootEl = el.ownerDocument?.documentElement;
|
|
6379
|
+
while (curr && curr !== rootEl) {
|
|
6380
|
+
if (curr.__swc_loop_context) {
|
|
6381
|
+
Object.assign(loopContext, curr.__swc_loop_context);
|
|
6382
|
+
}
|
|
6383
|
+
curr = curr.parentElement || curr.getRootNode().host;
|
|
6384
|
+
}
|
|
6385
|
+
const $appHosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
6386
|
+
const $appHost = $appHosts.length > 0 ? $appHosts[$appHosts.length - 1] === el ? $appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null : $appHosts[$appHosts.length - 1] : null;
|
|
6387
|
+
const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;
|
|
6388
|
+
return {
|
|
6389
|
+
$host,
|
|
6390
|
+
$parentHost,
|
|
6391
|
+
$hosts,
|
|
6392
|
+
$firstHost,
|
|
6393
|
+
$lastHost: $parentHost,
|
|
6394
|
+
$appHost,
|
|
6395
|
+
$appHosts,
|
|
6396
|
+
$firstAppHost,
|
|
6397
|
+
$lastAppHost: $appHost,
|
|
6398
|
+
...loopContext
|
|
6399
|
+
};
|
|
6400
|
+
};
|
|
6401
|
+
SwcUtils2.parsePathPattern = (pattern, currentPath) => {
|
|
6402
|
+
if (pattern === null || pattern === void 0) return {};
|
|
6403
|
+
const trimmedPattern = pattern.trim();
|
|
6404
|
+
if (trimmedPattern === "" && pattern !== "") return {};
|
|
6405
|
+
const paramNames = [];
|
|
6406
|
+
const regexPattern = trimmedPattern.replace(/{(\w+)(?::(.+?))?}/g, (match2, paramName, customRegex) => {
|
|
6407
|
+
paramNames.push(paramName);
|
|
6408
|
+
return `(${customRegex || "[^/]+"})`;
|
|
6409
|
+
});
|
|
6410
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
6411
|
+
const match = currentPath.match(regex);
|
|
6412
|
+
if (!match) return null;
|
|
6413
|
+
const result = {};
|
|
6414
|
+
paramNames.forEach((name, index) => {
|
|
6415
|
+
result[name] = match[index + 1];
|
|
6347
6416
|
});
|
|
6417
|
+
return result;
|
|
6348
6418
|
};
|
|
6349
|
-
}
|
|
6350
|
-
function queryHost(targetOrOptions, propertyKey) {
|
|
6351
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6352
|
-
return query(":host", {})(targetOrOptions, propertyKey);
|
|
6353
|
-
}
|
|
6354
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6355
|
-
return query(":host", targetOrOptions);
|
|
6356
|
-
} else {
|
|
6357
|
-
return query(":host", {});
|
|
6358
|
-
}
|
|
6359
|
-
}
|
|
6360
|
-
var host = queryHost;
|
|
6361
|
-
function parentHost(targetOrOptions, propertyKey) {
|
|
6362
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6363
|
-
return query(":parentHost", {})(targetOrOptions, propertyKey);
|
|
6364
|
-
}
|
|
6365
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6366
|
-
return query(":parentHost", targetOrOptions);
|
|
6367
|
-
} else {
|
|
6368
|
-
return query(":parentHost", {});
|
|
6369
|
-
}
|
|
6370
|
-
}
|
|
6371
|
-
function appHost(targetOrOptions, propertyKey) {
|
|
6372
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6373
|
-
return query(":appHost", {})(targetOrOptions, propertyKey);
|
|
6374
|
-
}
|
|
6375
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6376
|
-
return query(":appHost", targetOrOptions);
|
|
6377
|
-
} else {
|
|
6378
|
-
return query(":appHost", {});
|
|
6379
|
-
}
|
|
6380
|
-
}
|
|
6381
|
-
function firstHost(targetOrOptions, propertyKey) {
|
|
6382
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6383
|
-
return query(":firstHost", {})(targetOrOptions, propertyKey);
|
|
6384
|
-
}
|
|
6385
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6386
|
-
return query(":firstHost", targetOrOptions);
|
|
6387
|
-
} else {
|
|
6388
|
-
return query(":firstHost", {});
|
|
6389
|
-
}
|
|
6390
|
-
}
|
|
6391
|
-
function lastHost(targetOrOptions, propertyKey) {
|
|
6392
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6393
|
-
return query(":lastHost", {})(targetOrOptions, propertyKey);
|
|
6394
|
-
}
|
|
6395
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6396
|
-
return query(":lastHost", targetOrOptions);
|
|
6397
|
-
} else {
|
|
6398
|
-
return query(":lastHost", {});
|
|
6399
|
-
}
|
|
6400
|
-
}
|
|
6401
|
-
function firstAppHost(targetOrOptions, propertyKey) {
|
|
6402
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6403
|
-
return query(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
6404
|
-
}
|
|
6405
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6406
|
-
return query(":firstAppHost", targetOrOptions);
|
|
6407
|
-
} else {
|
|
6408
|
-
return query(":firstAppHost", {});
|
|
6409
|
-
}
|
|
6410
|
-
}
|
|
6411
|
-
function lastAppHost(targetOrOptions, propertyKey) {
|
|
6412
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6413
|
-
return query(":lastAppHost", {})(targetOrOptions, propertyKey);
|
|
6414
|
-
}
|
|
6415
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6416
|
-
return query(":lastAppHost", targetOrOptions);
|
|
6417
|
-
} else {
|
|
6418
|
-
return query(":lastAppHost", {});
|
|
6419
|
-
}
|
|
6420
|
-
}
|
|
6421
|
-
var getQueryMetadata = (target) => {
|
|
6422
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
6423
|
-
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
6424
|
-
};
|
|
6419
|
+
})(SwcUtils || (SwcUtils = {}));
|
|
6425
6420
|
|
|
6426
|
-
// src/decorators/
|
|
6427
|
-
var
|
|
6428
|
-
function
|
|
6421
|
+
// src/decorators/emitCustomEvent.ts
|
|
6422
|
+
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for("simple-web-component:emit-custom-event");
|
|
6423
|
+
function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
6429
6424
|
return (targetObj, propertyKey, descriptor) => {
|
|
6430
|
-
if (descriptor !== void 0) {
|
|
6431
|
-
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
6432
|
-
}
|
|
6433
6425
|
const constructor = targetObj.constructor;
|
|
6434
|
-
|
|
6435
|
-
if (
|
|
6436
|
-
|
|
6437
|
-
|
|
6426
|
+
const fullOptions = { ...options, type };
|
|
6427
|
+
if (fullOptions.bubbles === void 0) fullOptions.bubbles = true;
|
|
6428
|
+
if (fullOptions.composed === void 0) fullOptions.composed = true;
|
|
6429
|
+
let list = ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
6430
|
+
if (!list) {
|
|
6431
|
+
list = [];
|
|
6432
|
+
ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
|
|
6438
6433
|
}
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
if (
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
if (
|
|
6478
|
-
|
|
6479
|
-
if (r === "
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
return Array.from(this.querySelectorAll(selector));
|
|
6483
|
-
if (r === "all") {
|
|
6484
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6485
|
-
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
6486
|
-
return [...sNodes, ...lNodes];
|
|
6487
|
-
}
|
|
6488
|
-
const root = this.shadowRoot || this;
|
|
6489
|
-
return Array.from(root.querySelectorAll(selector));
|
|
6490
|
-
},
|
|
6491
|
-
set(nv) {
|
|
6492
|
-
ensureInit2(this);
|
|
6493
|
-
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
6494
|
-
const selector = selectorOrTarget;
|
|
6495
|
-
if (selector.startsWith(":") && selector !== ":host")
|
|
6496
|
-
return;
|
|
6497
|
-
const r = options.root || "auto";
|
|
6498
|
-
let targets = [];
|
|
6499
|
-
if (r === "shadow")
|
|
6500
|
-
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6501
|
-
else if (r === "light")
|
|
6502
|
-
targets = Array.from(this.querySelectorAll(selector));
|
|
6503
|
-
else if (r === "all") {
|
|
6504
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6505
|
-
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
6506
|
-
targets = [...sNodes, ...lNodes];
|
|
6507
|
-
} else {
|
|
6508
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
6509
|
-
}
|
|
6510
|
-
targets.forEach((t) => t.remove());
|
|
6434
|
+
list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
|
|
6435
|
+
const original = descriptor.value;
|
|
6436
|
+
descriptor.value = async function(...args) {
|
|
6437
|
+
ensureInit(this);
|
|
6438
|
+
const detail = await original.apply(this, args);
|
|
6439
|
+
const event = new CustomEvent(type, {
|
|
6440
|
+
detail,
|
|
6441
|
+
bubbles: fullOptions.bubbles,
|
|
6442
|
+
composed: fullOptions.composed,
|
|
6443
|
+
cancelable: fullOptions.cancelable
|
|
6444
|
+
});
|
|
6445
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
6446
|
+
const conf = getElementConfig(this);
|
|
6447
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6448
|
+
const eventTargets = [];
|
|
6449
|
+
if (selectorOrTarget === ":window") eventTargets.push(currentWin);
|
|
6450
|
+
else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
|
|
6451
|
+
else if (selectorOrTarget === ":parentHost") {
|
|
6452
|
+
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
6453
|
+
} else if (selectorOrTarget === ":appHost") {
|
|
6454
|
+
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
6455
|
+
} else if (selectorOrTarget === ":firstHost") {
|
|
6456
|
+
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
6457
|
+
} else if (selectorOrTarget === ":lastHost") {
|
|
6458
|
+
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
6459
|
+
} else if (selectorOrTarget === ":firstAppHost") {
|
|
6460
|
+
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
6461
|
+
} else if (selectorOrTarget === ":lastAppHost") {
|
|
6462
|
+
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
6463
|
+
} else if (selectorOrTarget === ":hosts") {
|
|
6464
|
+
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
6465
|
+
} else if (selectorOrTarget === ":appHosts") {
|
|
6466
|
+
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
6467
|
+
} else if (selectorOrTarget === ":host" || !selectorOrTarget) eventTargets.push(this);
|
|
6468
|
+
else {
|
|
6469
|
+
const r = fullOptions.root || "auto";
|
|
6470
|
+
const searchRoots = [];
|
|
6471
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
6472
|
+
else if (r === "light") searchRoots.push(this);
|
|
6473
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6474
|
+
else if (r === "all") {
|
|
6475
|
+
searchRoots.push(this);
|
|
6476
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6511
6477
|
}
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6478
|
+
searchRoots.forEach((sr) => {
|
|
6479
|
+
sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
|
|
6480
|
+
});
|
|
6481
|
+
}
|
|
6482
|
+
eventTargets.forEach((t) => t.dispatchEvent(event));
|
|
6483
|
+
return detail;
|
|
6484
|
+
};
|
|
6516
6485
|
};
|
|
6517
6486
|
}
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
return queryAll(":host", {});
|
|
6526
|
-
}
|
|
6527
|
-
}
|
|
6528
|
-
var allHost = queryAllHost;
|
|
6529
|
-
function allParentHost(targetOrOptions, propertyKey) {
|
|
6530
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6531
|
-
return queryAll(":parentHost", {})(targetOrOptions, propertyKey);
|
|
6532
|
-
}
|
|
6533
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6534
|
-
return queryAll(":parentHost", targetOrOptions);
|
|
6535
|
-
} else {
|
|
6536
|
-
return queryAll(":parentHost", {});
|
|
6537
|
-
}
|
|
6538
|
-
}
|
|
6539
|
-
function allAppHost(targetOrOptions, propertyKey) {
|
|
6540
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6541
|
-
return queryAll(":appHost", {})(targetOrOptions, propertyKey);
|
|
6542
|
-
}
|
|
6543
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6544
|
-
return queryAll(":appHost", targetOrOptions);
|
|
6545
|
-
} else {
|
|
6546
|
-
return queryAll(":appHost", {});
|
|
6547
|
-
}
|
|
6548
|
-
}
|
|
6549
|
-
function allFirstHost(targetOrOptions, propertyKey) {
|
|
6550
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6551
|
-
return queryAll(":firstHost", {})(targetOrOptions, propertyKey);
|
|
6552
|
-
}
|
|
6553
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6554
|
-
return queryAll(":firstHost", targetOrOptions);
|
|
6555
|
-
} else {
|
|
6556
|
-
return queryAll(":firstHost", {});
|
|
6557
|
-
}
|
|
6558
|
-
}
|
|
6559
|
-
function allLastHost(targetOrOptions, propertyKey) {
|
|
6560
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6561
|
-
return queryAll(":lastHost", {})(targetOrOptions, propertyKey);
|
|
6562
|
-
}
|
|
6563
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6564
|
-
return queryAll(":lastHost", targetOrOptions);
|
|
6565
|
-
} else {
|
|
6566
|
-
return queryAll(":lastHost", {});
|
|
6567
|
-
}
|
|
6568
|
-
}
|
|
6569
|
-
function allFirstAppHost(targetOrOptions, propertyKey) {
|
|
6570
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6571
|
-
return queryAll(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
6572
|
-
}
|
|
6573
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6574
|
-
return queryAll(":firstAppHost", targetOrOptions);
|
|
6575
|
-
} else {
|
|
6576
|
-
return queryAll(":firstAppHost", {});
|
|
6487
|
+
var getEmitCustomEventMetadataList = (target) => {
|
|
6488
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
6489
|
+
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
6490
|
+
};
|
|
6491
|
+
function emitCustomEventHost(type, options = {}) {
|
|
6492
|
+
if (!options.attributeName) {
|
|
6493
|
+
options.attributeName = `on-emit-${type}`;
|
|
6577
6494
|
}
|
|
6495
|
+
return emitCustomEvent(":host", type, options);
|
|
6578
6496
|
}
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6497
|
+
|
|
6498
|
+
// src/decorators/changedAttributeHost.ts
|
|
6499
|
+
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
6500
|
+
function changedAttributeHost(attributeName) {
|
|
6501
|
+
return (target, propertyKey) => {
|
|
6502
|
+
const constructor = target.constructor;
|
|
6503
|
+
let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6504
|
+
if (!meta) {
|
|
6505
|
+
meta = /* @__PURE__ */ new Map();
|
|
6506
|
+
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
|
|
6507
|
+
}
|
|
6508
|
+
const name = attributeName || String(propertyKey);
|
|
6509
|
+
let methods = meta.get(name);
|
|
6510
|
+
if (!methods) {
|
|
6511
|
+
methods = [];
|
|
6512
|
+
meta.set(name, methods);
|
|
6513
|
+
}
|
|
6514
|
+
if (!methods.includes(propertyKey)) methods.push(propertyKey);
|
|
6515
|
+
};
|
|
6588
6516
|
}
|
|
6589
|
-
var
|
|
6517
|
+
var getChangedAttributeMetadata = (target) => {
|
|
6590
6518
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
6591
|
-
return ReflectUtils.getMetadata(
|
|
6519
|
+
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6520
|
+
};
|
|
6521
|
+
var findAllAttributeChangedMetadata = (target) => {
|
|
6522
|
+
return ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
|
|
6592
6523
|
};
|
|
6593
6524
|
|
|
6594
|
-
// src/decorators/
|
|
6595
|
-
var
|
|
6596
|
-
function
|
|
6597
|
-
return (selector,
|
|
6525
|
+
// src/decorators/applyAttribute.ts
|
|
6526
|
+
var ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
|
|
6527
|
+
function createAttributeDecorator(action) {
|
|
6528
|
+
return (selector, nameOrOptions, options = {}) => {
|
|
6598
6529
|
return (target, propertyKey, descriptor) => {
|
|
6599
6530
|
const constructor = target.constructor;
|
|
6600
|
-
let metaList = ReflectUtils.getOwnMetadata(
|
|
6531
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
|
|
6601
6532
|
if (!metaList) {
|
|
6602
6533
|
metaList = /* @__PURE__ */ new Map();
|
|
6603
|
-
ReflectUtils.defineMetadata(
|
|
6534
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
|
|
6604
6535
|
}
|
|
6605
|
-
let
|
|
6536
|
+
let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
|
|
6606
6537
|
let finalOptions = options;
|
|
6607
|
-
if (typeof
|
|
6608
|
-
|
|
6609
|
-
} else if (typeof classMapOrOptions === "object" && classMapOrOptions !== null && "root" in classMapOrOptions) {
|
|
6610
|
-
finalOptions = classMapOrOptions;
|
|
6538
|
+
if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
|
|
6539
|
+
finalOptions = nameOrOptions;
|
|
6611
6540
|
}
|
|
6612
|
-
metaList.set(propertyKey, {
|
|
6541
|
+
metaList.set(propertyKey, {
|
|
6542
|
+
propertyKey,
|
|
6543
|
+
selector,
|
|
6544
|
+
action,
|
|
6545
|
+
options: { ...finalOptions, name: attributeName }
|
|
6546
|
+
});
|
|
6613
6547
|
const original = descriptor.value;
|
|
6614
6548
|
descriptor.value = async function(...args) {
|
|
6615
|
-
|
|
6549
|
+
ensureInit(this);
|
|
6616
6550
|
const res = await original.apply(this, args);
|
|
6617
6551
|
if (res !== void 0) {
|
|
6618
6552
|
const win = this.ownerDocument?.defaultView || window;
|
|
@@ -6642,254 +6576,22 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6642
6576
|
}
|
|
6643
6577
|
targetEls.forEach((targetEl) => {
|
|
6644
6578
|
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
6645
|
-
if (action === "set") {
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6579
|
+
if (action === "set" || action === "update") {
|
|
6580
|
+
if (attributeName) {
|
|
6581
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
6582
|
+
targetEl.removeAttribute(attributeName);
|
|
6583
|
+
} else {
|
|
6584
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
6585
|
+
}
|
|
6649
6586
|
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6659
|
-
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
6660
|
-
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
6661
|
-
targetEl.classList.toggle(cls, isActive);
|
|
6662
|
-
});
|
|
6663
|
-
} else {
|
|
6664
|
-
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
6665
|
-
if (action === "update") targetEl.classList.add(...classes);
|
|
6666
|
-
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
6667
|
-
}
|
|
6668
|
-
} else if (action === "add" || action === "remove") {
|
|
6669
|
-
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
6670
|
-
if (action === "add") targetEl.classList.add(classMap);
|
|
6671
|
-
else targetEl.classList.remove(classMap);
|
|
6672
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6673
|
-
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
6674
|
-
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
6675
|
-
if (shouldExecute) {
|
|
6676
|
-
if (action === "add") targetEl.classList.add(cls);
|
|
6677
|
-
else targetEl.classList.remove(cls);
|
|
6678
|
-
}
|
|
6679
|
-
});
|
|
6680
|
-
} else {
|
|
6681
|
-
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
6682
|
-
if (action === "add") targetEl.classList.add(...classes);
|
|
6683
|
-
else targetEl.classList.remove(...classes);
|
|
6684
|
-
}
|
|
6685
|
-
}
|
|
6686
|
-
});
|
|
6687
|
-
}
|
|
6688
|
-
return res;
|
|
6689
|
-
};
|
|
6690
|
-
return descriptor;
|
|
6691
|
-
};
|
|
6692
|
-
};
|
|
6693
|
-
}
|
|
6694
|
-
function applyClass(selector, action = "update", options = {}) {
|
|
6695
|
-
return createClassDecorator(action)(selector, options);
|
|
6696
|
-
}
|
|
6697
|
-
var setClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("set")(selector, classMapOrOptions, options);
|
|
6698
|
-
var updateClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("update")(selector, classMapOrOptions, options);
|
|
6699
|
-
var addClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("add")(selector, classMapOrOptions, options);
|
|
6700
|
-
var removeClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("remove")(selector, classMapOrOptions, options);
|
|
6701
|
-
var toggleClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("toggle")(selector, classMapOrOptions, options);
|
|
6702
|
-
function applyClassHost(action = "update", options = {}) {
|
|
6703
|
-
return createClassDecorator(action)(":host", options);
|
|
6704
|
-
}
|
|
6705
|
-
var setClassHost = (classMapOrOptions, options = {}) => createClassDecorator("set")(":host", classMapOrOptions, options);
|
|
6706
|
-
var updateClassHost = (classMapOrOptions, options = {}) => createClassDecorator("update")(":host", classMapOrOptions, options);
|
|
6707
|
-
var addClassHost = (classMapOrOptions, options = {}) => createClassDecorator("add")(":host", classMapOrOptions, options);
|
|
6708
|
-
var removeClassHost = (classMapOrOptions, options = {}) => createClassDecorator("remove")(":host", classMapOrOptions, options);
|
|
6709
|
-
var toggleClassHost = (classMapOrOptions, options = {}) => createClassDecorator("toggle")(":host", classMapOrOptions, options);
|
|
6710
|
-
var findAllClassMetadata = (target) => {
|
|
6711
|
-
const result = /* @__PURE__ */ new Map();
|
|
6712
|
-
const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
|
|
6713
|
-
maps.forEach((map) => {
|
|
6714
|
-
if (map instanceof Map) {
|
|
6715
|
-
map.forEach((v, k) => result.set(k, v));
|
|
6716
|
-
}
|
|
6717
|
-
});
|
|
6718
|
-
return result;
|
|
6719
|
-
};
|
|
6720
|
-
|
|
6721
|
-
// src/decorators/applyStyle.ts
|
|
6722
|
-
var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
|
|
6723
|
-
function createStyleDecorator(action) {
|
|
6724
|
-
return (selector, options = {}) => {
|
|
6725
|
-
return (target, propertyKey, descriptor) => {
|
|
6726
|
-
const constructor = target.constructor;
|
|
6727
|
-
let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor);
|
|
6728
|
-
if (!metaList) {
|
|
6729
|
-
metaList = /* @__PURE__ */ new Map();
|
|
6730
|
-
ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
|
|
6731
|
-
}
|
|
6732
|
-
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
6733
|
-
const original = descriptor.value;
|
|
6734
|
-
descriptor.value = async function(...args) {
|
|
6735
|
-
ensureInit2(this);
|
|
6736
|
-
const res = await original.apply(this, args);
|
|
6737
|
-
if (res !== void 0) {
|
|
6738
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
6739
|
-
const host2 = this;
|
|
6740
|
-
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6741
|
-
const r = options.root || "auto";
|
|
6742
|
-
const targetEls = [];
|
|
6743
|
-
const applyRoot = (t) => {
|
|
6744
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6745
|
-
targetEls.push(t);
|
|
6746
|
-
};
|
|
6747
|
-
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6748
|
-
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6749
|
-
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6750
|
-
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6751
|
-
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6752
|
-
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6753
|
-
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6754
|
-
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6755
|
-
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6756
|
-
else {
|
|
6757
|
-
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6758
|
-
if (targetRoot) {
|
|
6759
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
6760
|
-
if (found) targetEls.push(...Array.from(found));
|
|
6761
|
-
}
|
|
6762
|
-
}
|
|
6763
|
-
targetEls.forEach((targetEl) => {
|
|
6764
|
-
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
6765
|
-
if (action === "set" || action === "update") {
|
|
6766
|
-
if (action === "set") targetEl.style.cssText = "";
|
|
6767
|
-
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6768
|
-
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
6769
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6770
|
-
if (finalVal === null || finalVal === void 0) {
|
|
6771
|
-
targetEl.style.removeProperty(prop);
|
|
6772
|
-
} else {
|
|
6773
|
-
targetEl.style[prop] = String(finalVal);
|
|
6774
|
-
}
|
|
6775
|
-
});
|
|
6776
|
-
} else if (typeof resolvedRes === "string") {
|
|
6777
|
-
targetEl.style.cssText = resolvedRes;
|
|
6778
|
-
}
|
|
6779
|
-
} else if (action === "remove") {
|
|
6780
|
-
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6781
|
-
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
6782
|
-
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
6783
|
-
if (shouldRemove) {
|
|
6784
|
-
targetEl.style.removeProperty(prop);
|
|
6785
|
-
}
|
|
6786
|
-
});
|
|
6787
|
-
} else {
|
|
6788
|
-
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6789
|
-
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
6790
|
-
}
|
|
6791
|
-
}
|
|
6792
|
-
});
|
|
6793
|
-
}
|
|
6794
|
-
return res;
|
|
6795
|
-
};
|
|
6796
|
-
return descriptor;
|
|
6797
|
-
};
|
|
6798
|
-
};
|
|
6799
|
-
}
|
|
6800
|
-
function applyStyle(selector, action = "update", options = {}) {
|
|
6801
|
-
return createStyleDecorator(action)(selector, options);
|
|
6802
|
-
}
|
|
6803
|
-
var setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
|
|
6804
|
-
var updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
|
|
6805
|
-
var removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
|
|
6806
|
-
function applyStyleHost(action = "update", options = {}) {
|
|
6807
|
-
return createStyleDecorator(action)(":host", options);
|
|
6808
|
-
}
|
|
6809
|
-
var setStyleHost = (options = {}) => createStyleDecorator("set")(":host", options);
|
|
6810
|
-
var updateStyleHost = (options = {}) => createStyleDecorator("update")(":host", options);
|
|
6811
|
-
var removeStyleHost = (options = {}) => createStyleDecorator("remove")(":host", options);
|
|
6812
|
-
var findAllStyleMetadata = (target) => {
|
|
6813
|
-
const result = /* @__PURE__ */ new Map();
|
|
6814
|
-
const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
|
|
6815
|
-
maps.forEach((map) => {
|
|
6816
|
-
if (map instanceof Map) {
|
|
6817
|
-
map.forEach((v, k) => result.set(k, v));
|
|
6818
|
-
}
|
|
6819
|
-
});
|
|
6820
|
-
return result;
|
|
6821
|
-
};
|
|
6822
|
-
|
|
6823
|
-
// src/decorators/applyAttribute.ts
|
|
6824
|
-
var ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
|
|
6825
|
-
function createAttributeDecorator(action) {
|
|
6826
|
-
return (selector, nameOrOptions, options = {}) => {
|
|
6827
|
-
return (target, propertyKey, descriptor) => {
|
|
6828
|
-
const constructor = target.constructor;
|
|
6829
|
-
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
|
|
6830
|
-
if (!metaList) {
|
|
6831
|
-
metaList = /* @__PURE__ */ new Map();
|
|
6832
|
-
ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
|
|
6833
|
-
}
|
|
6834
|
-
let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
|
|
6835
|
-
let finalOptions = options;
|
|
6836
|
-
if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
|
|
6837
|
-
finalOptions = nameOrOptions;
|
|
6838
|
-
}
|
|
6839
|
-
metaList.set(propertyKey, {
|
|
6840
|
-
propertyKey,
|
|
6841
|
-
selector,
|
|
6842
|
-
action,
|
|
6843
|
-
options: { ...finalOptions, name: attributeName }
|
|
6844
|
-
});
|
|
6845
|
-
const original = descriptor.value;
|
|
6846
|
-
descriptor.value = async function(...args) {
|
|
6847
|
-
ensureInit2(this);
|
|
6848
|
-
const res = await original.apply(this, args);
|
|
6849
|
-
if (res !== void 0) {
|
|
6850
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
6851
|
-
const host2 = this;
|
|
6852
|
-
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6853
|
-
const r = finalOptions.root || "auto";
|
|
6854
|
-
const targetEls = [];
|
|
6855
|
-
const applyRoot = (t) => {
|
|
6856
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6857
|
-
targetEls.push(t);
|
|
6858
|
-
};
|
|
6859
|
-
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6860
|
-
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6861
|
-
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6862
|
-
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6863
|
-
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6864
|
-
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6865
|
-
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6866
|
-
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6867
|
-
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6868
|
-
else {
|
|
6869
|
-
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6870
|
-
if (targetRoot) {
|
|
6871
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
6872
|
-
if (found) targetEls.push(...Array.from(found));
|
|
6873
|
-
}
|
|
6874
|
-
}
|
|
6875
|
-
targetEls.forEach((targetEl) => {
|
|
6876
|
-
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
6877
|
-
if (action === "set" || action === "update") {
|
|
6878
|
-
if (attributeName) {
|
|
6879
|
-
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
6880
|
-
targetEl.removeAttribute(attributeName);
|
|
6881
|
-
} else {
|
|
6882
|
-
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
6883
|
-
}
|
|
6884
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6885
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6886
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6887
|
-
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6888
|
-
targetEl.removeAttribute(attr);
|
|
6889
|
-
} else {
|
|
6890
|
-
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6891
|
-
}
|
|
6892
|
-
});
|
|
6587
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6588
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6589
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6590
|
+
targetEl.removeAttribute(attr);
|
|
6591
|
+
} else {
|
|
6592
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6593
|
+
}
|
|
6594
|
+
});
|
|
6893
6595
|
}
|
|
6894
6596
|
} else if (action === "remove") {
|
|
6895
6597
|
if (attributeName) {
|
|
@@ -6935,472 +6637,344 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6935
6637
|
return result;
|
|
6936
6638
|
};
|
|
6937
6639
|
|
|
6938
|
-
// src/decorators/
|
|
6939
|
-
var
|
|
6940
|
-
|
|
6941
|
-
return (
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
if (!metaList) {
|
|
6945
|
-
metaList = /* @__PURE__ */ new Map();
|
|
6946
|
-
ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);
|
|
6640
|
+
// src/decorators/query.ts
|
|
6641
|
+
var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
6642
|
+
function query(selectorOrTarget, options = {}) {
|
|
6643
|
+
return (targetObj, propertyKey, descriptor) => {
|
|
6644
|
+
if (descriptor !== void 0) {
|
|
6645
|
+
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
6947
6646
|
}
|
|
6948
|
-
|
|
6949
|
-
let
|
|
6950
|
-
if (
|
|
6951
|
-
|
|
6647
|
+
const constructor = targetObj.constructor;
|
|
6648
|
+
let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
6649
|
+
if (!queries) {
|
|
6650
|
+
queries = [];
|
|
6651
|
+
ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
|
|
6952
6652
|
}
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
descriptor.value = async function(...args) {
|
|
6960
|
-
ensureInit2(this);
|
|
6961
|
-
const res = await original.apply(this, args);
|
|
6962
|
-
if (res !== void 0) {
|
|
6963
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
6964
|
-
const host2 = this;
|
|
6965
|
-
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6966
|
-
const r = finalOptions.root || "auto";
|
|
6967
|
-
const targetEls = [];
|
|
6653
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options });
|
|
6654
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
6655
|
+
get() {
|
|
6656
|
+
ensureInit(this);
|
|
6657
|
+
const selector = selectorOrTarget;
|
|
6658
|
+
const r = options.root || "auto";
|
|
6968
6659
|
const applyRoot = (t) => {
|
|
6969
|
-
if (!t || !(t instanceof
|
|
6970
|
-
|
|
6660
|
+
if (!t || !(t instanceof HTMLElement))
|
|
6661
|
+
return t;
|
|
6662
|
+
if (r === "auto")
|
|
6663
|
+
return t.shadowRoot || t;
|
|
6664
|
+
if (r === "shadow")
|
|
6665
|
+
return t.shadowRoot;
|
|
6666
|
+
if (r === "light")
|
|
6667
|
+
return t;
|
|
6668
|
+
if (r === "all")
|
|
6669
|
+
return t.shadowRoot || t;
|
|
6670
|
+
return t;
|
|
6971
6671
|
};
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6672
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
6673
|
+
if (selector === ":parentHost")
|
|
6674
|
+
return applyRoot(hostSet.$parentHost);
|
|
6675
|
+
if (selector === ":appHost")
|
|
6676
|
+
return applyRoot(hostSet.$appHost);
|
|
6677
|
+
if (selector === ":firstHost")
|
|
6678
|
+
return applyRoot(hostSet.$firstHost);
|
|
6679
|
+
if (selector === ":lastHost")
|
|
6680
|
+
return applyRoot(hostSet.$lastHost);
|
|
6681
|
+
if (selector === ":firstAppHost")
|
|
6682
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
6683
|
+
if (selector === ":lastAppHost")
|
|
6684
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
6685
|
+
const config = getElementConfig(this);
|
|
6686
|
+
const win = config?.window || window;
|
|
6687
|
+
if (selector === ":window")
|
|
6688
|
+
return win;
|
|
6689
|
+
if (selector === ":document")
|
|
6690
|
+
return win.document;
|
|
6691
|
+
if (selector === ":host")
|
|
6692
|
+
return applyRoot(this);
|
|
6693
|
+
if (r === "shadow")
|
|
6694
|
+
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
6695
|
+
if (r === "light")
|
|
6696
|
+
return this.querySelector(selector);
|
|
6697
|
+
if (r === "all") {
|
|
6698
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
6699
|
+
return shadowMatch || this.querySelector(selector);
|
|
6987
6700
|
}
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6701
|
+
return (this.shadowRoot || this).querySelector(selector);
|
|
6702
|
+
},
|
|
6703
|
+
set(nv) {
|
|
6704
|
+
ensureInit(this);
|
|
6705
|
+
if (nv === null || nv === void 0) {
|
|
6706
|
+
const selector = selectorOrTarget;
|
|
6707
|
+
if (selector.startsWith(":") && selector !== ":host")
|
|
6708
|
+
return;
|
|
6709
|
+
const r = options.root || "auto";
|
|
6710
|
+
const targets = [];
|
|
6711
|
+
if (r === "shadow") {
|
|
6712
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
6713
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
6714
|
+
} else if (r === "light") {
|
|
6715
|
+
if (this.querySelector(selector))
|
|
6716
|
+
targets.push(this.querySelector(selector));
|
|
6717
|
+
} else if (r === "all") {
|
|
6718
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
6719
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
6720
|
+
if (this.querySelector(selector))
|
|
6721
|
+
targets.push(this.querySelector(selector));
|
|
6997
6722
|
} else {
|
|
6998
|
-
|
|
6723
|
+
const el = (this.shadowRoot || this).querySelector(selector);
|
|
6724
|
+
if (el)
|
|
6725
|
+
targets.push(el);
|
|
6999
6726
|
}
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
return setProperty(":host", propertyNameOrOptions, options);
|
|
7007
|
-
};
|
|
7008
|
-
|
|
7009
|
-
// src/decorators/subscribeSwcAppRouteChange.ts
|
|
7010
|
-
var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change");
|
|
7011
|
-
function createSwcAppRouteChangeSubscriber(options) {
|
|
7012
|
-
return (target, propertyKey, descriptor) => {
|
|
7013
|
-
const pathPattern = options?.path;
|
|
7014
|
-
const filter = options?.filter;
|
|
7015
|
-
const constructor = target.constructor;
|
|
7016
|
-
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
|
|
7017
|
-
if (!list) {
|
|
7018
|
-
list = [];
|
|
7019
|
-
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
|
|
7020
|
-
}
|
|
7021
|
-
list.push({ propertyKey, pathPattern, filter });
|
|
7022
|
-
return descriptor;
|
|
6727
|
+
targets.forEach((t) => t.remove());
|
|
6728
|
+
}
|
|
6729
|
+
},
|
|
6730
|
+
enumerable: true,
|
|
6731
|
+
configurable: true
|
|
6732
|
+
});
|
|
7023
6733
|
};
|
|
7024
6734
|
}
|
|
7025
|
-
function
|
|
7026
|
-
if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
7027
|
-
return
|
|
6735
|
+
function queryHost(targetOrOptions, propertyKey) {
|
|
6736
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6737
|
+
return query(":host", {})(targetOrOptions, propertyKey);
|
|
7028
6738
|
}
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
options.path = targetOrOptions;
|
|
7034
|
-
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
7035
|
-
options = targetOrOptions;
|
|
6739
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6740
|
+
return query(":host", targetOrOptions);
|
|
6741
|
+
} else {
|
|
6742
|
+
return query(":host", {});
|
|
7036
6743
|
}
|
|
7037
|
-
return createSwcAppRouteChangeSubscriber(options);
|
|
7038
6744
|
}
|
|
7039
|
-
var
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
// src/utils/Utils.ts
|
|
7045
|
-
var SWC_NOT_FOUND = Symbol.for("simple-web-component:not-found");
|
|
7046
|
-
var htmlFragment = (html, doc) => {
|
|
7047
|
-
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
7048
|
-
if (!d) throw new Error("Document is not available");
|
|
7049
|
-
const template = d.createElement("template");
|
|
7050
|
-
template.innerHTML = html.trim();
|
|
7051
|
-
return template.content;
|
|
7052
|
-
};
|
|
7053
|
-
var textNode = (text, doc) => {
|
|
7054
|
-
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
7055
|
-
if (!d) throw new Error("Document is not available");
|
|
7056
|
-
return d.createTextNode(text !== void 0 && text !== null ? String(text) : "");
|
|
7057
|
-
};
|
|
7058
|
-
var commentNode = (comment, doc) => {
|
|
7059
|
-
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
7060
|
-
if (!d) throw new Error("Document is not available");
|
|
7061
|
-
return d.createComment(comment !== void 0 && comment !== null ? String(comment) : "");
|
|
7062
|
-
};
|
|
7063
|
-
var createElement = (tagName, options) => {
|
|
7064
|
-
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
7065
|
-
if (!d) throw new Error("Document is not available");
|
|
7066
|
-
const el = d.createElement(tagName);
|
|
7067
|
-
if (options?.html) el.innerHTML = options.html;
|
|
7068
|
-
if (options?.attrs) {
|
|
7069
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6745
|
+
var host = queryHost;
|
|
6746
|
+
function parentHost(targetOrOptions, propertyKey) {
|
|
6747
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6748
|
+
return query(":parentHost", {})(targetOrOptions, propertyKey);
|
|
7070
6749
|
}
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
if (!d) throw new Error("Document is not available");
|
|
7076
|
-
const el = d.createElement("div");
|
|
7077
|
-
el.innerHTML = html.trim();
|
|
7078
|
-
if (options?.attrs) {
|
|
7079
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6750
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6751
|
+
return query(":parentHost", targetOrOptions);
|
|
6752
|
+
} else {
|
|
6753
|
+
return query(":parentHost", {});
|
|
7080
6754
|
}
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
if (!d) throw new Error("Document is not available");
|
|
7086
|
-
const el = d.createElement("span");
|
|
7087
|
-
el.innerHTML = html.trim();
|
|
7088
|
-
if (options?.attrs) {
|
|
7089
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6755
|
+
}
|
|
6756
|
+
function appHost(targetOrOptions, propertyKey) {
|
|
6757
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6758
|
+
return query(":appHost", {})(targetOrOptions, propertyKey);
|
|
7090
6759
|
}
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
if (!d) throw new Error("Document is not available");
|
|
7096
|
-
const el = d.createElement("button");
|
|
7097
|
-
el.innerHTML = html.trim();
|
|
7098
|
-
if (options?.attrs) {
|
|
7099
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6760
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6761
|
+
return query(":appHost", targetOrOptions);
|
|
6762
|
+
} else {
|
|
6763
|
+
return query(":appHost", {});
|
|
7100
6764
|
}
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
if (!d) throw new Error("Document is not available");
|
|
7106
|
-
const el = d.createElement("ul");
|
|
7107
|
-
if (options?.attrs) {
|
|
7108
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6765
|
+
}
|
|
6766
|
+
function firstHost(targetOrOptions, propertyKey) {
|
|
6767
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6768
|
+
return query(":firstHost", {})(targetOrOptions, propertyKey);
|
|
7109
6769
|
}
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
if (!d) throw new Error("Document is not available");
|
|
7115
|
-
const el = d.createElement("li");
|
|
7116
|
-
el.innerHTML = html.trim();
|
|
7117
|
-
if (options?.attrs) {
|
|
7118
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6770
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6771
|
+
return query(":firstHost", targetOrOptions);
|
|
6772
|
+
} else {
|
|
6773
|
+
return query(":firstHost", {});
|
|
7119
6774
|
}
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
if (!d) throw new Error("Document is not available");
|
|
7125
|
-
const el = d.createElement("a");
|
|
7126
|
-
el.innerHTML = html.trim();
|
|
7127
|
-
if (options?.href) el.href = options.href;
|
|
7128
|
-
if (options?.attrs) {
|
|
7129
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6775
|
+
}
|
|
6776
|
+
function lastHost(targetOrOptions, propertyKey) {
|
|
6777
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6778
|
+
return query(":lastHost", {})(targetOrOptions, propertyKey);
|
|
7130
6779
|
}
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
if (!d) throw new Error("Document is not available");
|
|
7136
|
-
const el = d.createElement("p");
|
|
7137
|
-
el.innerHTML = html.trim();
|
|
7138
|
-
if (options?.attrs) {
|
|
7139
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6780
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6781
|
+
return query(":lastHost", targetOrOptions);
|
|
6782
|
+
} else {
|
|
6783
|
+
return query(":lastHost", {});
|
|
7140
6784
|
}
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
if (!d) throw new Error("Document is not available");
|
|
7146
|
-
const el = d.createElement(`h${level}`);
|
|
7147
|
-
el.innerHTML = html.trim();
|
|
7148
|
-
if (options?.attrs) {
|
|
7149
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6785
|
+
}
|
|
6786
|
+
function firstAppHost(targetOrOptions, propertyKey) {
|
|
6787
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6788
|
+
return query(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
7150
6789
|
}
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
if (!d) throw new Error("Document is not available");
|
|
7156
|
-
const el = d.createElement("section");
|
|
7157
|
-
if (options?.attrs) {
|
|
7158
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6790
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6791
|
+
return query(":firstAppHost", targetOrOptions);
|
|
6792
|
+
} else {
|
|
6793
|
+
return query(":firstAppHost", {});
|
|
7159
6794
|
}
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
if (!d) throw new Error("Document is not available");
|
|
7165
|
-
const el = d.createElement("article");
|
|
7166
|
-
if (options?.attrs) {
|
|
7167
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
6795
|
+
}
|
|
6796
|
+
function lastAppHost(targetOrOptions, propertyKey) {
|
|
6797
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6798
|
+
return query(":lastAppHost", {})(targetOrOptions, propertyKey);
|
|
7168
6799
|
}
|
|
7169
|
-
|
|
6800
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6801
|
+
return query(":lastAppHost", targetOrOptions);
|
|
6802
|
+
} else {
|
|
6803
|
+
return query(":lastAppHost", {});
|
|
6804
|
+
}
|
|
6805
|
+
}
|
|
6806
|
+
var getQueryMetadata = (target) => {
|
|
6807
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
6808
|
+
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
7170
6809
|
};
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
$q: (sel, root) => (root ?? doc).querySelector(sel),
|
|
7179
|
-
$qa: (sel, root) => Array.from((root ?? doc).querySelectorAll(sel)),
|
|
7180
|
-
$qi: (id, root) => (root ?? doc).getElementById(id)
|
|
7181
|
-
};
|
|
7182
|
-
};
|
|
7183
|
-
SwcUtils2.getHelperAndHostSet = (win, el) => {
|
|
7184
|
-
const helperSet = (0, SwcUtils2.getHelperSet)(win);
|
|
7185
|
-
const hostSet = (0, SwcUtils2.getHostSet)(el);
|
|
7186
|
-
return {
|
|
7187
|
-
...helperSet,
|
|
7188
|
-
...hostSet
|
|
7189
|
-
};
|
|
7190
|
-
};
|
|
7191
|
-
SwcUtils2.getValueByPath = (obj, path, rootName) => {
|
|
7192
|
-
if (!obj || !path) return SWC_NOT_FOUND;
|
|
7193
|
-
const parts = path.split(".");
|
|
7194
|
-
let current = obj;
|
|
7195
|
-
for (const part of parts) {
|
|
7196
|
-
if (current === null || current === void 0) return SWC_NOT_FOUND;
|
|
7197
|
-
current = current[part];
|
|
7198
|
-
}
|
|
7199
|
-
return current;
|
|
7200
|
-
};
|
|
7201
|
-
SwcUtils2.findNearestSwcHost = (el) => {
|
|
7202
|
-
if (el.__swc_host) return el.__swc_host;
|
|
7203
|
-
let current = el.parentElement || el.getRootNode?.()?.host;
|
|
7204
|
-
const doc = el.ownerDocument;
|
|
7205
|
-
const win = doc?.defaultView || (typeof window !== "undefined" ? window : void 0);
|
|
7206
|
-
while (current && current !== doc && current !== win) {
|
|
7207
|
-
if (current.__swc_host) return current.__swc_host;
|
|
7208
|
-
if (getElementConfig(current)) return current;
|
|
7209
|
-
current = current.parentElement || current.getRootNode?.()?.host;
|
|
6810
|
+
|
|
6811
|
+
// src/decorators/queryAll.ts
|
|
6812
|
+
var QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
|
|
6813
|
+
function queryAll(selectorOrTarget, options = {}) {
|
|
6814
|
+
return (targetObj, propertyKey, descriptor) => {
|
|
6815
|
+
if (descriptor !== void 0) {
|
|
6816
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
7210
6817
|
}
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
while (current) {
|
|
7217
|
-
hosts.push(current);
|
|
7218
|
-
current = (0, SwcUtils2.findNearestSwcHost)(current);
|
|
6818
|
+
const constructor = targetObj.constructor;
|
|
6819
|
+
let queries = ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
6820
|
+
if (!queries) {
|
|
6821
|
+
queries = [];
|
|
6822
|
+
ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
7219
6823
|
}
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
appHosts
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
6824
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options });
|
|
6825
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
6826
|
+
get() {
|
|
6827
|
+
ensureInit(this);
|
|
6828
|
+
const selector = selectorOrTarget;
|
|
6829
|
+
const r = options.root || "auto";
|
|
6830
|
+
const applyRoot = (t) => {
|
|
6831
|
+
if (!t)
|
|
6832
|
+
return [];
|
|
6833
|
+
const items = Array.isArray(t) ? t : [t];
|
|
6834
|
+
const results = [];
|
|
6835
|
+
items.forEach((it) => {
|
|
6836
|
+
if (!(it instanceof HTMLElement)) {
|
|
6837
|
+
results.push(it);
|
|
6838
|
+
return;
|
|
6839
|
+
}
|
|
6840
|
+
if (r === "auto")
|
|
6841
|
+
results.push(it.shadowRoot || it);
|
|
6842
|
+
else {
|
|
6843
|
+
if (r === "light" || r === "all")
|
|
6844
|
+
results.push(it);
|
|
6845
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
6846
|
+
results.push(it.shadowRoot);
|
|
6847
|
+
}
|
|
6848
|
+
});
|
|
6849
|
+
return results;
|
|
6850
|
+
};
|
|
6851
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
6852
|
+
if (selector === ":hosts")
|
|
6853
|
+
return applyRoot(hostSet.$hosts);
|
|
6854
|
+
if (selector === ":appHosts")
|
|
6855
|
+
return applyRoot(hostSet.$appHosts);
|
|
6856
|
+
const config = getElementConfig(this);
|
|
6857
|
+
const win = config?.window || window;
|
|
6858
|
+
if (selector === ":window")
|
|
6859
|
+
return [win];
|
|
6860
|
+
if (selector === ":document")
|
|
6861
|
+
return [win.document];
|
|
6862
|
+
if (selector === ":host")
|
|
6863
|
+
return applyRoot(this);
|
|
6864
|
+
if (r === "shadow")
|
|
6865
|
+
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6866
|
+
if (r === "light")
|
|
6867
|
+
return Array.from(this.querySelectorAll(selector));
|
|
6868
|
+
if (r === "all") {
|
|
6869
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6870
|
+
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
6871
|
+
return [...sNodes, ...lNodes];
|
|
6872
|
+
}
|
|
6873
|
+
const root = this.shadowRoot || this;
|
|
6874
|
+
return Array.from(root.querySelectorAll(selector));
|
|
6875
|
+
},
|
|
6876
|
+
set(nv) {
|
|
6877
|
+
ensureInit(this);
|
|
6878
|
+
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
6879
|
+
const selector = selectorOrTarget;
|
|
6880
|
+
if (selector.startsWith(":") && selector !== ":host")
|
|
6881
|
+
return;
|
|
6882
|
+
const r = options.root || "auto";
|
|
6883
|
+
let targets = [];
|
|
6884
|
+
if (r === "shadow")
|
|
6885
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6886
|
+
else if (r === "light")
|
|
6887
|
+
targets = Array.from(this.querySelectorAll(selector));
|
|
6888
|
+
else if (r === "all") {
|
|
6889
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
6890
|
+
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
6891
|
+
targets = [...sNodes, ...lNodes];
|
|
7259
6892
|
} else {
|
|
7260
|
-
|
|
6893
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
7261
6894
|
}
|
|
7262
|
-
|
|
7263
|
-
current = current.parentElement;
|
|
6895
|
+
targets.forEach((t) => t.remove());
|
|
7264
6896
|
}
|
|
7265
|
-
}
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
SwcUtils2.getHostSet = (el) => {
|
|
7270
|
-
const isSwc = !!getElementConfig(el);
|
|
7271
|
-
const ancestors = (0, SwcUtils2.findAllSwcHosts)(el);
|
|
7272
|
-
let $host;
|
|
7273
|
-
let $parentHost;
|
|
7274
|
-
if (isSwc) {
|
|
7275
|
-
$host = el;
|
|
7276
|
-
$parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;
|
|
7277
|
-
} else {
|
|
7278
|
-
$host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;
|
|
7279
|
-
$parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;
|
|
7280
|
-
}
|
|
7281
|
-
const $hosts = isSwc ? [...ancestors, el] : ancestors;
|
|
7282
|
-
const $firstHost = $hosts.length > 0 ? $hosts[0] : null;
|
|
7283
|
-
const loopContext = {};
|
|
7284
|
-
let curr = el;
|
|
7285
|
-
const rootEl = el.ownerDocument?.documentElement;
|
|
7286
|
-
while (curr && curr !== rootEl) {
|
|
7287
|
-
if (curr.__swc_loop_context) {
|
|
7288
|
-
Object.assign(loopContext, curr.__swc_loop_context);
|
|
7289
|
-
}
|
|
7290
|
-
curr = curr.parentElement || curr.getRootNode().host;
|
|
7291
|
-
}
|
|
7292
|
-
const $appHosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
7293
|
-
const $appHost = $appHosts.length > 0 ? $appHosts[$appHosts.length - 1] === el ? $appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null : $appHosts[$appHosts.length - 1] : null;
|
|
7294
|
-
const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;
|
|
7295
|
-
return {
|
|
7296
|
-
$host,
|
|
7297
|
-
$parentHost,
|
|
7298
|
-
$hosts,
|
|
7299
|
-
$firstHost,
|
|
7300
|
-
$lastHost: $parentHost,
|
|
7301
|
-
$appHost,
|
|
7302
|
-
$appHosts,
|
|
7303
|
-
$firstAppHost,
|
|
7304
|
-
$lastAppHost: $appHost,
|
|
7305
|
-
...loopContext
|
|
7306
|
-
};
|
|
7307
|
-
};
|
|
7308
|
-
SwcUtils2.parsePathPattern = (pattern, currentPath) => {
|
|
7309
|
-
if (pattern === null || pattern === void 0) return {};
|
|
7310
|
-
const trimmedPattern = pattern.trim();
|
|
7311
|
-
if (trimmedPattern === "" && pattern !== "") return {};
|
|
7312
|
-
const paramNames = [];
|
|
7313
|
-
const regexPattern = trimmedPattern.replace(/{(\w+)(?::(.+?))?}/g, (match2, paramName, customRegex) => {
|
|
7314
|
-
paramNames.push(paramName);
|
|
7315
|
-
return `(${customRegex || "[^/]+"})`;
|
|
7316
|
-
});
|
|
7317
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
7318
|
-
const match = currentPath.match(regex);
|
|
7319
|
-
if (!match) return null;
|
|
7320
|
-
const result = {};
|
|
7321
|
-
paramNames.forEach((name, index) => {
|
|
7322
|
-
result[name] = match[index + 1];
|
|
7323
|
-
});
|
|
7324
|
-
return result;
|
|
7325
|
-
};
|
|
7326
|
-
})(SwcUtils || (SwcUtils = {}));
|
|
7327
|
-
|
|
7328
|
-
// src/decorators/emitCustomEvent.ts
|
|
7329
|
-
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for("simple-web-component:emit-custom-event");
|
|
7330
|
-
function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
7331
|
-
return (targetObj, propertyKey, descriptor) => {
|
|
7332
|
-
const constructor = targetObj.constructor;
|
|
7333
|
-
const fullOptions = { ...options, type };
|
|
7334
|
-
if (fullOptions.bubbles === void 0) fullOptions.bubbles = true;
|
|
7335
|
-
if (fullOptions.composed === void 0) fullOptions.composed = true;
|
|
7336
|
-
let list = ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
7337
|
-
if (!list) {
|
|
7338
|
-
list = [];
|
|
7339
|
-
ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
|
|
7340
|
-
}
|
|
7341
|
-
list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
|
|
7342
|
-
const original = descriptor.value;
|
|
7343
|
-
descriptor.value = async function(...args) {
|
|
7344
|
-
ensureInit2(this);
|
|
7345
|
-
const detail = await original.apply(this, args);
|
|
7346
|
-
const event = new CustomEvent(type, {
|
|
7347
|
-
detail,
|
|
7348
|
-
bubbles: fullOptions.bubbles,
|
|
7349
|
-
composed: fullOptions.composed,
|
|
7350
|
-
cancelable: fullOptions.cancelable
|
|
7351
|
-
});
|
|
7352
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
7353
|
-
const conf = getElementConfig(this);
|
|
7354
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
7355
|
-
const eventTargets = [];
|
|
7356
|
-
if (selectorOrTarget === ":window") eventTargets.push(currentWin);
|
|
7357
|
-
else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
|
|
7358
|
-
else if (selectorOrTarget === ":parentHost") {
|
|
7359
|
-
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
7360
|
-
} else if (selectorOrTarget === ":appHost") {
|
|
7361
|
-
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
7362
|
-
} else if (selectorOrTarget === ":firstHost") {
|
|
7363
|
-
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
7364
|
-
} else if (selectorOrTarget === ":lastHost") {
|
|
7365
|
-
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
7366
|
-
} else if (selectorOrTarget === ":firstAppHost") {
|
|
7367
|
-
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
7368
|
-
} else if (selectorOrTarget === ":lastAppHost") {
|
|
7369
|
-
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
7370
|
-
} else if (selectorOrTarget === ":hosts") {
|
|
7371
|
-
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
7372
|
-
} else if (selectorOrTarget === ":appHosts") {
|
|
7373
|
-
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
7374
|
-
} else if (selectorOrTarget === ":host" || !selectorOrTarget) eventTargets.push(this);
|
|
7375
|
-
else {
|
|
7376
|
-
const r = fullOptions.root || "auto";
|
|
7377
|
-
const searchRoots = [];
|
|
7378
|
-
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
7379
|
-
else if (r === "light") searchRoots.push(this);
|
|
7380
|
-
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
7381
|
-
else if (r === "all") {
|
|
7382
|
-
searchRoots.push(this);
|
|
7383
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
7384
|
-
}
|
|
7385
|
-
searchRoots.forEach((sr) => {
|
|
7386
|
-
sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
|
|
7387
|
-
});
|
|
7388
|
-
}
|
|
7389
|
-
eventTargets.forEach((t) => t.dispatchEvent(event));
|
|
7390
|
-
return detail;
|
|
7391
|
-
};
|
|
6897
|
+
},
|
|
6898
|
+
enumerable: true,
|
|
6899
|
+
configurable: true
|
|
6900
|
+
});
|
|
7392
6901
|
};
|
|
7393
6902
|
}
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
6903
|
+
function queryAllHost(targetOrOptions, propertyKey) {
|
|
6904
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6905
|
+
return queryAll(":host", {})(targetOrOptions, propertyKey);
|
|
6906
|
+
}
|
|
6907
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6908
|
+
return queryAll(":host", targetOrOptions);
|
|
6909
|
+
} else {
|
|
6910
|
+
return queryAll(":host", {});
|
|
6911
|
+
}
|
|
6912
|
+
}
|
|
6913
|
+
var allHost = queryAllHost;
|
|
6914
|
+
function allParentHost(targetOrOptions, propertyKey) {
|
|
6915
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6916
|
+
return queryAll(":parentHost", {})(targetOrOptions, propertyKey);
|
|
6917
|
+
}
|
|
6918
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6919
|
+
return queryAll(":parentHost", targetOrOptions);
|
|
6920
|
+
} else {
|
|
6921
|
+
return queryAll(":parentHost", {});
|
|
6922
|
+
}
|
|
6923
|
+
}
|
|
6924
|
+
function allAppHost(targetOrOptions, propertyKey) {
|
|
6925
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6926
|
+
return queryAll(":appHost", {})(targetOrOptions, propertyKey);
|
|
6927
|
+
}
|
|
6928
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6929
|
+
return queryAll(":appHost", targetOrOptions);
|
|
6930
|
+
} else {
|
|
6931
|
+
return queryAll(":appHost", {});
|
|
6932
|
+
}
|
|
6933
|
+
}
|
|
6934
|
+
function allFirstHost(targetOrOptions, propertyKey) {
|
|
6935
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6936
|
+
return queryAll(":firstHost", {})(targetOrOptions, propertyKey);
|
|
6937
|
+
}
|
|
6938
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6939
|
+
return queryAll(":firstHost", targetOrOptions);
|
|
6940
|
+
} else {
|
|
6941
|
+
return queryAll(":firstHost", {});
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
function allLastHost(targetOrOptions, propertyKey) {
|
|
6945
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6946
|
+
return queryAll(":lastHost", {})(targetOrOptions, propertyKey);
|
|
6947
|
+
}
|
|
6948
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6949
|
+
return queryAll(":lastHost", targetOrOptions);
|
|
6950
|
+
} else {
|
|
6951
|
+
return queryAll(":lastHost", {});
|
|
6952
|
+
}
|
|
6953
|
+
}
|
|
6954
|
+
function allFirstAppHost(targetOrOptions, propertyKey) {
|
|
6955
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6956
|
+
return queryAll(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
6957
|
+
}
|
|
6958
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6959
|
+
return queryAll(":firstAppHost", targetOrOptions);
|
|
6960
|
+
} else {
|
|
6961
|
+
return queryAll(":firstAppHost", {});
|
|
6962
|
+
}
|
|
6963
|
+
}
|
|
6964
|
+
function allLastAppHost(targetOrOptions, propertyKey) {
|
|
6965
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
6966
|
+
return queryAll(":lastAppHost", {})(targetOrOptions, propertyKey);
|
|
6967
|
+
}
|
|
6968
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6969
|
+
return queryAll(":lastAppHost", targetOrOptions);
|
|
6970
|
+
} else {
|
|
6971
|
+
return queryAll(":lastAppHost", {});
|
|
7401
6972
|
}
|
|
7402
|
-
return emitCustomEvent(":host", type, options);
|
|
7403
6973
|
}
|
|
6974
|
+
var getQueryAllMetadata = (target) => {
|
|
6975
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
6976
|
+
return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
6977
|
+
};
|
|
7404
6978
|
|
|
7405
6979
|
// src/config/config.ts
|
|
7406
6980
|
var HTML_TAG_ENTRIES = [
|
|
@@ -7507,668 +7081,177 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7507
7081
|
return InjectSituationType2;
|
|
7508
7082
|
})(InjectSituationType || {});
|
|
7509
7083
|
|
|
7510
|
-
//
|
|
7511
|
-
var
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
const attributeList = findAllAttributeMetadata(target);
|
|
7524
|
-
attributeList.forEach((meta) => {
|
|
7525
|
-
delete inst[meta.propertyKey];
|
|
7526
|
-
});
|
|
7527
|
-
const queryList = getQueryMetadata(target);
|
|
7528
|
-
if (queryList) {
|
|
7529
|
-
queryList.forEach((meta) => {
|
|
7530
|
-
delete inst[meta.propertyKey];
|
|
7531
|
-
});
|
|
7532
|
-
}
|
|
7533
|
-
const queryAllList = getQueryAllMetadata(target);
|
|
7534
|
-
if (queryAllList) {
|
|
7535
|
-
queryAllList.forEach((meta) => {
|
|
7536
|
-
delete inst[meta.propertyKey];
|
|
7537
|
-
});
|
|
7084
|
+
// ../core-web/dist/esm/element/CanvasUtils.js
|
|
7085
|
+
var CanvasUtils;
|
|
7086
|
+
((CanvasUtils2) => {
|
|
7087
|
+
let Context2D;
|
|
7088
|
+
((Context2D2) => {
|
|
7089
|
+
Context2D2.resetTransform = (context) => {
|
|
7090
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
7091
|
+
};
|
|
7092
|
+
})(Context2D = CanvasUtils2.Context2D || (CanvasUtils2.Context2D = {}));
|
|
7093
|
+
CanvasUtils2.fontSize = (ctx, config) => {
|
|
7094
|
+
const { text, maxWidth, maxHeight, fontOption } = config;
|
|
7095
|
+
if (!text || maxWidth <= 0 || maxHeight <= 0) {
|
|
7096
|
+
return 0;
|
|
7538
7097
|
}
|
|
7539
|
-
const
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
const cMethods = findAllLifecycleMetadata(inst, ON_INITIALIZE_METADATA_KEY);
|
|
7543
|
-
if (cMethods) {
|
|
7544
|
-
for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
|
|
7098
|
+
const lines = text.split("\n").filter((line) => line.trim().length > 0);
|
|
7099
|
+
if (lines.length === 0) {
|
|
7100
|
+
return 0;
|
|
7545
7101
|
}
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
if (event.__swc_handled) return;
|
|
7551
|
-
const path = event.composedPath();
|
|
7552
|
-
const type = event.type;
|
|
7553
|
-
const attrName = `swc-on-${type}`;
|
|
7554
|
-
for (const node of path) {
|
|
7555
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
7556
|
-
const script = node.getAttribute?.(attrName);
|
|
7557
|
-
if (script && !getElementConfig(node)) {
|
|
7558
|
-
const host2 = SwcUtils.findNearestSwcHost(node);
|
|
7559
|
-
if (host2 && host2.isConnected && typeof host2.__swc_executeAttributeEvent === "function") {
|
|
7560
|
-
await host2.__swc_executeAttributeEvent(node, attrName, script, event);
|
|
7561
|
-
event.__swc_handled = true;
|
|
7562
|
-
break;
|
|
7563
|
-
}
|
|
7102
|
+
const lineHeightMultiplier = 1.2;
|
|
7103
|
+
const maxFontSizeByHeight = Math.floor(maxHeight / (lines.length * lineHeightMultiplier));
|
|
7104
|
+
if (maxFontSizeByHeight <= 0) {
|
|
7105
|
+
return 0;
|
|
7564
7106
|
}
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
};
|
|
7581
|
-
var setupPrototype = (proto) => {
|
|
7582
|
-
if (proto.__swc_proto_setup) return;
|
|
7583
|
-
proto.__swc_proto_setup = true;
|
|
7584
|
-
proto._executeSwcScript = function(attrName, hostSet, extraArgs = {}) {
|
|
7585
|
-
ensureInit2(this);
|
|
7586
|
-
const script = this.getAttribute(attrName);
|
|
7587
|
-
if (script) {
|
|
7588
|
-
try {
|
|
7589
|
-
const conf = getElementConfig(this);
|
|
7590
|
-
const currentWin = this._resolveWindow(conf);
|
|
7591
|
-
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
7592
|
-
const args = { ...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode() };
|
|
7593
|
-
FunctionUtils.execute({ script, context: this, args });
|
|
7594
|
-
} catch (e) {
|
|
7595
|
-
console.error(`[SWC] Failed to execute ${attrName}:`, e);
|
|
7107
|
+
let minSizeForWidth = 1;
|
|
7108
|
+
let maxSizeForWidth = maxFontSizeByHeight;
|
|
7109
|
+
let bestSizeForWidth = 0;
|
|
7110
|
+
const maxIterations = 100;
|
|
7111
|
+
let iteration = 0;
|
|
7112
|
+
while (minSizeForWidth <= maxSizeForWidth && iteration < maxIterations) {
|
|
7113
|
+
const midSize = Math.floor((minSizeForWidth + maxSizeForWidth) / 2);
|
|
7114
|
+
if (midSize === 0) break;
|
|
7115
|
+
ctx.font = `${fontOption?.fontWeight || "normal"} ${midSize}px ${fontOption?.fontFamily || "sans-serif"}`;
|
|
7116
|
+
const maxLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
|
|
7117
|
+
if (maxLineWidth <= maxWidth) {
|
|
7118
|
+
bestSizeForWidth = midSize;
|
|
7119
|
+
minSizeForWidth = midSize + 1;
|
|
7120
|
+
} else {
|
|
7121
|
+
maxSizeForWidth = midSize - 1;
|
|
7596
7122
|
}
|
|
7123
|
+
iteration++;
|
|
7597
7124
|
}
|
|
7125
|
+
return Math.min(bestSizeForWidth, maxFontSizeByHeight);
|
|
7598
7126
|
};
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
if (localConfig?.window) return localConfig.window;
|
|
7602
|
-
const ancestors = SwcUtils.findAllSwcHosts(this);
|
|
7603
|
-
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
7604
|
-
const aConf = getElementConfig(ancestors[i]);
|
|
7605
|
-
if (aConf?.window) return aConf.window;
|
|
7606
|
-
}
|
|
7607
|
-
return typeof window !== "undefined" ? window : void 0;
|
|
7127
|
+
CanvasUtils2.textMetrics = (context, text) => {
|
|
7128
|
+
return context.measureText(text);
|
|
7608
7129
|
};
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
{
|
|
7620
|
-
target: this,
|
|
7621
|
-
targetKey: methodName,
|
|
7622
|
-
inputParameters: extraArgs
|
|
7623
|
-
},
|
|
7624
|
-
otherStorage
|
|
7625
|
-
);
|
|
7130
|
+
})(CanvasUtils || (CanvasUtils = {}));
|
|
7131
|
+
|
|
7132
|
+
// ../core-web/dist/esm/element/ElementUtils.js
|
|
7133
|
+
var ElementUtils;
|
|
7134
|
+
((ElementUtils2) => {
|
|
7135
|
+
function removeAllChildren(el, els) {
|
|
7136
|
+
if (!els) {
|
|
7137
|
+
el.replaceChildren();
|
|
7138
|
+
} else if (Array.isArray(els)) {
|
|
7139
|
+
el.replaceChildren(...els);
|
|
7626
7140
|
} else {
|
|
7627
|
-
|
|
7628
|
-
}
|
|
7629
|
-
};
|
|
7630
|
-
proto._bindAttributeEvent = function(el, attrName, script, eventName) {
|
|
7631
|
-
ensureInit2(this);
|
|
7632
|
-
if (!eventName) {
|
|
7633
|
-
if (!attrName.startsWith("swc-on-")) return;
|
|
7634
|
-
eventName = attrName.substring(7);
|
|
7141
|
+
el.replaceChildren(els);
|
|
7635
7142
|
}
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7143
|
+
}
|
|
7144
|
+
ElementUtils2.removeAllChildren = removeAllChildren;
|
|
7145
|
+
function loadImage(src, callback) {
|
|
7146
|
+
let targetCallback;
|
|
7147
|
+
let promise = void 0;
|
|
7148
|
+
if (callback) {
|
|
7149
|
+
targetCallback = callback.onload;
|
|
7150
|
+
} else {
|
|
7151
|
+
const r = Promises.withResolvers();
|
|
7152
|
+
promise = r.promise;
|
|
7153
|
+
targetCallback = r.resolve;
|
|
7641
7154
|
}
|
|
7642
|
-
const
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7646
|
-
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
7647
|
-
const conf = getElementConfig(this);
|
|
7648
|
-
const currentWin = this._resolveWindow(conf);
|
|
7649
|
-
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
7650
|
-
const args = {
|
|
7651
|
-
event,
|
|
7652
|
-
$data: event.detail,
|
|
7653
|
-
...hostSet,
|
|
7654
|
-
...helpers,
|
|
7655
|
-
$el: el,
|
|
7656
|
-
$root: this.getRootNode()
|
|
7657
|
-
};
|
|
7658
|
-
await FunctionUtils.execute({ script, context: el, args });
|
|
7659
|
-
};
|
|
7660
|
-
el.addEventListener(eventName, handler);
|
|
7661
|
-
handlers.set(attrName, handler);
|
|
7662
|
-
};
|
|
7663
|
-
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
|
|
7664
|
-
ensureInit2(this);
|
|
7665
|
-
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7666
|
-
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
7667
|
-
const conf = getElementConfig(this);
|
|
7668
|
-
const currentWin = this._resolveWindow(conf);
|
|
7669
|
-
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
7670
|
-
const detail = event.detail;
|
|
7671
|
-
const args = {
|
|
7672
|
-
event,
|
|
7673
|
-
$event: event,
|
|
7674
|
-
$data: detail,
|
|
7675
|
-
$detail: detail,
|
|
7676
|
-
...hostSet,
|
|
7677
|
-
...currentHelpers,
|
|
7678
|
-
$el: el,
|
|
7679
|
-
$root: this.getRootNode()
|
|
7155
|
+
const img = new Image();
|
|
7156
|
+
img.onload = () => {
|
|
7157
|
+
targetCallback(img);
|
|
7680
7158
|
};
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
};
|
|
7684
|
-
var elementDefine = (name, config = {}) => (constructor) => {
|
|
7685
|
-
const { win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS } = buildEnv(config.window);
|
|
7686
|
-
const metadata = { ...config, name, window: win };
|
|
7687
|
-
if (!metadata.window) {
|
|
7688
|
-
throw new Error("window is required");
|
|
7689
|
-
}
|
|
7690
|
-
let extendsTagName = metadata.extends;
|
|
7691
|
-
if (!extendsTagName) {
|
|
7692
|
-
let proto2 = constructor;
|
|
7693
|
-
const BaseHTMLElement = win.HTMLElement;
|
|
7694
|
-
while (proto2 && proto2 !== BaseHTMLElement && proto2 !== Function.prototype) {
|
|
7695
|
-
extendsTagName = BUILT_IN_TAG_MAP.get(proto2);
|
|
7696
|
-
if (extendsTagName) break;
|
|
7697
|
-
proto2 = Object.getPrototypeOf(proto2);
|
|
7159
|
+
if (callback && callback.onerror) {
|
|
7160
|
+
img.onerror = callback.onerror;
|
|
7698
7161
|
}
|
|
7699
|
-
|
|
7162
|
+
img.src = src;
|
|
7163
|
+
return promise;
|
|
7700
7164
|
}
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
...attributeApplyNames,
|
|
7715
|
-
...hostAttributes,
|
|
7716
|
-
...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
|
|
7717
|
-
...swcLifecycleAttributes,
|
|
7718
|
-
...swcOnEvents
|
|
7719
|
-
])];
|
|
7720
|
-
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
7721
|
-
const proto = constructor.prototype;
|
|
7722
|
-
setupPrototype(proto);
|
|
7723
|
-
const originalConnected = proto.connectedCallback;
|
|
7724
|
-
proto.connectedCallback = function() {
|
|
7725
|
-
ensureInit2(this);
|
|
7726
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
7727
|
-
const appHost2 = hostSet.$appHost;
|
|
7728
|
-
const conf = getElementConfig(this);
|
|
7729
|
-
const currentWin = this._resolveWindow(conf);
|
|
7730
|
-
if (connectedInnerHtmlList.some((it) => it.options.useShadow === true) && !this.shadowRoot) {
|
|
7731
|
-
this.attachShadow({ mode: "open" });
|
|
7732
|
-
}
|
|
7733
|
-
this._executeSwcScript("swc-on-before-connected", hostSet);
|
|
7734
|
-
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
7735
|
-
if (bMethods) {
|
|
7736
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
7737
|
-
}
|
|
7738
|
-
if (connectedInnerHtmlList.length > 0) {
|
|
7739
|
-
let sContent = "", lContent = "";
|
|
7740
|
-
for (const meta of connectedInnerHtmlList) {
|
|
7741
|
-
const res = this[meta.propertyKey]();
|
|
7742
|
-
if (res !== void 0) {
|
|
7743
|
-
if (meta.options.useShadow) sContent += res;
|
|
7744
|
-
else lContent += res;
|
|
7745
|
-
}
|
|
7746
|
-
}
|
|
7747
|
-
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
7748
|
-
if (lContent) this.innerHTML = lContent;
|
|
7749
|
-
}
|
|
7750
|
-
const root = this.getRootNode();
|
|
7751
|
-
if (!globalDelegatedRoots.has(root)) {
|
|
7752
|
-
DOM_EVENT_NAMES.forEach((type) => {
|
|
7753
|
-
root.addEventListener(type, handleGlobalSwcEvent);
|
|
7754
|
-
});
|
|
7755
|
-
globalDelegatedRoots.add(root);
|
|
7165
|
+
ElementUtils2.loadImage = loadImage;
|
|
7166
|
+
function loadAudio(src, callback) {
|
|
7167
|
+
let targetCallback;
|
|
7168
|
+
let error;
|
|
7169
|
+
let promise = void 0;
|
|
7170
|
+
if (callback) {
|
|
7171
|
+
targetCallback = callback.onload;
|
|
7172
|
+
error = callback.onerror;
|
|
7173
|
+
} else {
|
|
7174
|
+
const r = Promises.withResolvers();
|
|
7175
|
+
promise = r.promise;
|
|
7176
|
+
error = r.reject;
|
|
7177
|
+
targetCallback = r.resolve;
|
|
7756
7178
|
}
|
|
7757
|
-
const
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
|
|
7761
|
-
delegateListeners.push(meta);
|
|
7762
|
-
} else {
|
|
7763
|
-
nonDelegateListeners.push(meta);
|
|
7764
|
-
}
|
|
7179
|
+
const audio = new Audio("path/to/audio1.mp3");
|
|
7180
|
+
audio.addEventListener("canplay", () => {
|
|
7181
|
+
targetCallback?.(audio);
|
|
7765
7182
|
});
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
const r = meta.options.root || "auto";
|
|
7769
|
-
const rootKey = `${meta.type}:${r}`;
|
|
7770
|
-
if (!delegatesByTypeAndRoot.has(rootKey)) {
|
|
7771
|
-
delegatesByTypeAndRoot.set(rootKey, []);
|
|
7772
|
-
}
|
|
7773
|
-
delegatesByTypeAndRoot.get(rootKey).push(meta);
|
|
7183
|
+
audio.addEventListener("error", (e) => {
|
|
7184
|
+
callback?.onerror(e);
|
|
7774
7185
|
});
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
else if (r === "all") {
|
|
7784
|
-
bindRoots.push(this);
|
|
7785
|
-
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
7786
|
-
}
|
|
7787
|
-
bindRoots.forEach((br) => {
|
|
7788
|
-
const sortedMetaList = [...metaList].sort((a, b) => {
|
|
7789
|
-
const aStop = a.options.stopPropagation ? 1 : 0;
|
|
7790
|
-
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
7791
|
-
return bStop - aStop;
|
|
7792
|
-
});
|
|
7793
|
-
const unifiedHandler = async (event) => {
|
|
7794
|
-
for (const meta of sortedMetaList) {
|
|
7795
|
-
const { selector, options } = meta;
|
|
7796
|
-
const matchedEl = event.target.closest(selector);
|
|
7797
|
-
if (matchedEl && br.contains(matchedEl)) {
|
|
7798
|
-
if (options.filter) {
|
|
7799
|
-
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
7800
|
-
if (!options.filter(event, helper)) {
|
|
7801
|
-
continue;
|
|
7802
|
-
}
|
|
7803
|
-
}
|
|
7804
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
7805
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7806
|
-
if (options.preventDefault) event.preventDefault();
|
|
7807
|
-
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7808
|
-
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
7809
|
-
await this[meta.propertyKey](event, currentHostSet, matchedEl, args);
|
|
7810
|
-
if (event.cancelBubble) break;
|
|
7811
|
-
}
|
|
7812
|
-
}
|
|
7813
|
-
};
|
|
7814
|
-
br.addEventListener(type, unifiedHandler, opts);
|
|
7815
|
-
this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
|
|
7816
|
-
});
|
|
7817
|
-
});
|
|
7818
|
-
nonDelegateListeners.forEach((meta) => {
|
|
7819
|
-
const { selector, type, options } = meta;
|
|
7820
|
-
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
7821
|
-
const bindTargets = [];
|
|
7822
|
-
const r = options.root || "auto";
|
|
7823
|
-
const applyRootOption = (target) => {
|
|
7824
|
-
if (!target) return;
|
|
7825
|
-
if (r === "auto") {
|
|
7826
|
-
bindTargets.push(target.shadowRoot || target);
|
|
7827
|
-
} else {
|
|
7828
|
-
if (r === "light" || r === "all") bindTargets.push(target);
|
|
7829
|
-
if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
7830
|
-
}
|
|
7831
|
-
};
|
|
7832
|
-
if (selector === ":window") bindTargets.push(currentWin);
|
|
7833
|
-
else if (selector === ":document") bindTargets.push(currentWin.document);
|
|
7834
|
-
else if (selector === ":parentHost") applyRootOption(hostSet.$parentHost);
|
|
7835
|
-
else if (selector === ":appHost") applyRootOption(hostSet.$appHost);
|
|
7836
|
-
else if (selector === ":firstHost") applyRootOption(hostSet.$firstHost);
|
|
7837
|
-
else if (selector === ":lastHost") applyRootOption(hostSet.$lastHost);
|
|
7838
|
-
else if (selector === ":firstAppHost") applyRootOption(hostSet.$firstAppHost);
|
|
7839
|
-
else if (selector === ":lastAppHost") applyRootOption(hostSet.$lastAppHost);
|
|
7840
|
-
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRootOption);
|
|
7841
|
-
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRootOption);
|
|
7842
|
-
else if (selector === ":host" || !selector) applyRootOption(this);
|
|
7843
|
-
else {
|
|
7844
|
-
const searchRoots = [];
|
|
7845
|
-
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
7846
|
-
else if (r === "light") searchRoots.push(this);
|
|
7847
|
-
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
7848
|
-
else if (r === "all") {
|
|
7849
|
-
searchRoots.push(this);
|
|
7850
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
7851
|
-
}
|
|
7852
|
-
searchRoots.forEach((sr) => {
|
|
7853
|
-
sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
|
|
7854
|
-
});
|
|
7855
|
-
}
|
|
7856
|
-
bindTargets.forEach((t) => {
|
|
7857
|
-
const handler = async (event) => {
|
|
7858
|
-
if (options.filter) {
|
|
7859
|
-
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
7860
|
-
if (!options.filter(event, helper)) {
|
|
7861
|
-
return;
|
|
7862
|
-
}
|
|
7863
|
-
}
|
|
7864
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
7865
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7866
|
-
if (options.preventDefault) event.preventDefault();
|
|
7867
|
-
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7868
|
-
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
7869
|
-
await this[meta.propertyKey](event, currentHostSet, args);
|
|
7870
|
-
};
|
|
7871
|
-
t.addEventListener(type, handler, opts);
|
|
7872
|
-
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
7873
|
-
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
7874
|
-
}
|
|
7875
|
-
});
|
|
7876
|
-
});
|
|
7877
|
-
if (originalConnected) originalConnected.apply(this);
|
|
7878
|
-
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
7879
|
-
if (aMethods) {
|
|
7880
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
7881
|
-
}
|
|
7882
|
-
this._executeSwcScript("swc-on-connected", hostSet);
|
|
7883
|
-
this._executeSwcScript("swc-on-after-connected", hostSet);
|
|
7884
|
-
this.__swc_connected = true;
|
|
7885
|
-
const appHostss = SwcUtils.findAllParentAppHostsDirect(this);
|
|
7886
|
-
if (appHost2 && typeof appHost2._connected === "function") {
|
|
7887
|
-
appHost2._connected(this);
|
|
7888
|
-
} else if (appHost2 && typeof appHost2) {
|
|
7889
|
-
appHost2._connected_safari ?? (appHost2._connected_safari = []);
|
|
7890
|
-
appHost2._connected_safari.push(this);
|
|
7891
|
-
}
|
|
7186
|
+
audio.load();
|
|
7187
|
+
return promise;
|
|
7188
|
+
}
|
|
7189
|
+
ElementUtils2.loadAudio = loadAudio;
|
|
7190
|
+
ElementUtils2.toInnerHTML = (documentFragment, config) => {
|
|
7191
|
+
const tempDiv = config.document.createElement("div");
|
|
7192
|
+
tempDiv.appendChild(documentFragment.cloneNode(true));
|
|
7193
|
+
return tempDiv.innerHTML;
|
|
7892
7194
|
};
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
7900
|
-
}
|
|
7901
|
-
if (this._boundListeners) {
|
|
7902
|
-
this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
7903
|
-
this._boundListeners = [];
|
|
7904
|
-
}
|
|
7905
|
-
if (originalDisconnected) originalDisconnected.apply(this);
|
|
7906
|
-
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
7907
|
-
if (aMethods) {
|
|
7908
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
7909
|
-
}
|
|
7910
|
-
this._executeSwcScript("swc-on-disconnected", hostSet);
|
|
7911
|
-
this._executeSwcScript("swc-on-after-disconnected", hostSet);
|
|
7912
|
-
this.__swc_connected = false;
|
|
7913
|
-
const appHost2 = hostSet.$appHost;
|
|
7914
|
-
if (appHost2 && typeof appHost2._disconnected === "function") {
|
|
7915
|
-
appHost2._disconnected(this);
|
|
7195
|
+
ElementUtils2.htmlToFragment = (html, config = { document }) => {
|
|
7196
|
+
const tempDiv = config.document.createElement("div");
|
|
7197
|
+
tempDiv.innerHTML = html;
|
|
7198
|
+
const fragment = config.document.createDocumentFragment();
|
|
7199
|
+
while (tempDiv.firstChild) {
|
|
7200
|
+
fragment.appendChild(tempDiv.firstChild);
|
|
7916
7201
|
}
|
|
7202
|
+
return fragment;
|
|
7917
7203
|
};
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7204
|
+
ElementUtils2.replaceWith = (targetElement, replaceElement) => {
|
|
7205
|
+
targetElement.replaceWith(replaceElement);
|
|
7206
|
+
};
|
|
7207
|
+
ElementUtils2.nodeList = (documentFragment) => {
|
|
7208
|
+
return Array.from(documentFragment.childNodes);
|
|
7209
|
+
};
|
|
7210
|
+
ElementUtils2.cloneNodeList = (documentFragment) => {
|
|
7211
|
+
return Array.from(documentFragment.childNodes).map((node) => node.cloneNode(true));
|
|
7212
|
+
};
|
|
7213
|
+
ElementUtils2.querySelector = (e, selector) => {
|
|
7214
|
+
const elements = ElementUtils2.querySelectorAll(e, selector);
|
|
7215
|
+
if (elements.length > 0) {
|
|
7216
|
+
return elements[0];
|
|
7217
|
+
} else {
|
|
7218
|
+
return null;
|
|
7930
7219
|
}
|
|
7931
|
-
this._executeSwcScript("swc-on-adopted", hostSet);
|
|
7932
|
-
this._executeSwcScript("swc-on-after-adopted", hostSet);
|
|
7933
7220
|
};
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7221
|
+
ElementUtils2.querySelectorAll = (e, selector) => {
|
|
7222
|
+
if (e instanceof Element) {
|
|
7223
|
+
return Array.from(e.querySelectorAll(selector));
|
|
7224
|
+
} else {
|
|
7225
|
+
const startNode = e.start;
|
|
7226
|
+
const endNode = e.end;
|
|
7227
|
+
if (startNode && endNode && startNode.parentNode === endNode.parentNode) {
|
|
7228
|
+
const elements = [];
|
|
7229
|
+
let currentNode = startNode.nextSibling;
|
|
7230
|
+
while (currentNode && currentNode !== endNode) {
|
|
7231
|
+
if (currentNode.nodeType === Node.ELEMENT_NODE) {
|
|
7232
|
+
const currentElement = currentNode;
|
|
7233
|
+
if (currentElement.matches(selector)) {
|
|
7234
|
+
elements.push(currentElement);
|
|
7235
|
+
}
|
|
7236
|
+
elements.push(...Array.from(currentElement.querySelectorAll(selector)));
|
|
7237
|
+
}
|
|
7238
|
+
currentNode = currentNode.nextSibling;
|
|
7239
|
+
}
|
|
7240
|
+
return elements;
|
|
7942
7241
|
}
|
|
7943
7242
|
}
|
|
7944
|
-
|
|
7945
|
-
if (hostCustomEventMeta && newVal !== null) {
|
|
7946
|
-
this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
|
|
7947
|
-
}
|
|
7948
|
-
const mKeys = attrChangeMap.get(name2);
|
|
7949
|
-
if (mKeys && Array.isArray(mKeys)) {
|
|
7950
|
-
for (const key of mKeys) this[key](newVal, old, name2, hSet);
|
|
7951
|
-
}
|
|
7243
|
+
return [];
|
|
7952
7244
|
};
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
configurable: true
|
|
7956
|
-
});
|
|
7957
|
-
ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);
|
|
7958
|
-
const registry = metadata.customElementRegistry || win?.customElements;
|
|
7959
|
-
if (registry && !registry.get(metadata.name)) {
|
|
7960
|
-
registry.define(metadata.name, constructor, metadata.extends ? { extends: metadata.extends } : void 0);
|
|
7961
|
-
}
|
|
7962
|
-
return constructor;
|
|
7963
|
-
};
|
|
7964
|
-
|
|
7965
|
-
// ../simple-boot/dist/esm/decorators/SimDecorator.js
|
|
7966
|
-
var SimMetadataKey = Symbol.for("simple-boot:sim-metadata");
|
|
7967
|
-
var PostConstructMetadataKey = Symbol.for("simple-boot:post-construct-metadata");
|
|
7968
|
-
|
|
7969
|
-
// ../simple-boot/dist/esm/decorators/aop/AOPDecorator.js
|
|
7970
|
-
var AfterMetadataKey = Symbol.for("simple-boot:after-metadata");
|
|
7971
|
-
var BeforeMetadataKey = Symbol.for("simple-boot:before-metadata");
|
|
7972
|
-
var AroundMetadataKey = Symbol.for("simple-boot:around-metadata");
|
|
7973
|
-
|
|
7974
|
-
// ../simple-boot/dist/esm/decorators/exception/ExceptionDecorator.js
|
|
7975
|
-
var ExceptionHandlerMetadataKey = Symbol.for("simple-boot:exception-handler-metadata");
|
|
7976
|
-
|
|
7977
|
-
// ../simple-boot/dist/esm/decorators/SimNoProxy.js
|
|
7978
|
-
var SimNoProxyKey = Symbol.for("simple-boot:sim-no-proxy-metadata");
|
|
7979
|
-
|
|
7980
|
-
// ../simple-boot/dist/esm/decorators/inject/Injection.js
|
|
7981
|
-
var InjectionMetadataKey = Symbol("Injection");
|
|
7982
|
-
|
|
7983
|
-
// ../simple-boot/dist/esm/decorators/route/Router.js
|
|
7984
|
-
var RouterMetadataKey = Symbol.for("simple-boot:router-metadata");
|
|
7985
|
-
var RouteMetadataKey = Symbol.for("simple-boot:route-metadata");
|
|
7986
|
-
|
|
7987
|
-
// ../simple-boot/dist/esm/route/RouterAction.js
|
|
7988
|
-
var RouterAction;
|
|
7989
|
-
((RouterAction2) => {
|
|
7990
|
-
RouterAction2.isCanActivate = (obj) => {
|
|
7991
|
-
return typeof obj?.canActivate === "function";
|
|
7245
|
+
ElementUtils2.selectorElements = (selector, element = document) => {
|
|
7246
|
+
return Array.prototype.slice.call(element.querySelectorAll(selector));
|
|
7992
7247
|
};
|
|
7993
|
-
|
|
7994
|
-
return
|
|
7248
|
+
ElementUtils2.selectorNodes = (selector, element = document) => {
|
|
7249
|
+
return element.querySelectorAll(selector);
|
|
7995
7250
|
};
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
// ../core-web/dist/esm/element/CanvasUtils.js
|
|
8002
|
-
var CanvasUtils;
|
|
8003
|
-
((CanvasUtils2) => {
|
|
8004
|
-
let Context2D;
|
|
8005
|
-
((Context2D2) => {
|
|
8006
|
-
Context2D2.resetTransform = (context) => {
|
|
8007
|
-
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
8008
|
-
};
|
|
8009
|
-
})(Context2D = CanvasUtils2.Context2D || (CanvasUtils2.Context2D = {}));
|
|
8010
|
-
CanvasUtils2.fontSize = (ctx, config) => {
|
|
8011
|
-
const { text, maxWidth, maxHeight, fontOption } = config;
|
|
8012
|
-
if (!text || maxWidth <= 0 || maxHeight <= 0) {
|
|
8013
|
-
return 0;
|
|
8014
|
-
}
|
|
8015
|
-
const lines = text.split("\n").filter((line) => line.trim().length > 0);
|
|
8016
|
-
if (lines.length === 0) {
|
|
8017
|
-
return 0;
|
|
8018
|
-
}
|
|
8019
|
-
const lineHeightMultiplier = 1.2;
|
|
8020
|
-
const maxFontSizeByHeight = Math.floor(maxHeight / (lines.length * lineHeightMultiplier));
|
|
8021
|
-
if (maxFontSizeByHeight <= 0) {
|
|
8022
|
-
return 0;
|
|
8023
|
-
}
|
|
8024
|
-
let minSizeForWidth = 1;
|
|
8025
|
-
let maxSizeForWidth = maxFontSizeByHeight;
|
|
8026
|
-
let bestSizeForWidth = 0;
|
|
8027
|
-
const maxIterations = 100;
|
|
8028
|
-
let iteration = 0;
|
|
8029
|
-
while (minSizeForWidth <= maxSizeForWidth && iteration < maxIterations) {
|
|
8030
|
-
const midSize = Math.floor((minSizeForWidth + maxSizeForWidth) / 2);
|
|
8031
|
-
if (midSize === 0) break;
|
|
8032
|
-
ctx.font = `${fontOption?.fontWeight || "normal"} ${midSize}px ${fontOption?.fontFamily || "sans-serif"}`;
|
|
8033
|
-
const maxLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
|
|
8034
|
-
if (maxLineWidth <= maxWidth) {
|
|
8035
|
-
bestSizeForWidth = midSize;
|
|
8036
|
-
minSizeForWidth = midSize + 1;
|
|
8037
|
-
} else {
|
|
8038
|
-
maxSizeForWidth = midSize - 1;
|
|
8039
|
-
}
|
|
8040
|
-
iteration++;
|
|
8041
|
-
}
|
|
8042
|
-
return Math.min(bestSizeForWidth, maxFontSizeByHeight);
|
|
8043
|
-
};
|
|
8044
|
-
CanvasUtils2.textMetrics = (context, text) => {
|
|
8045
|
-
return context.measureText(text);
|
|
8046
|
-
};
|
|
8047
|
-
})(CanvasUtils || (CanvasUtils = {}));
|
|
8048
|
-
|
|
8049
|
-
// ../core-web/dist/esm/element/ElementUtils.js
|
|
8050
|
-
var ElementUtils;
|
|
8051
|
-
((ElementUtils2) => {
|
|
8052
|
-
function removeAllChildren(el, els) {
|
|
8053
|
-
if (!els) {
|
|
8054
|
-
el.replaceChildren();
|
|
8055
|
-
} else if (Array.isArray(els)) {
|
|
8056
|
-
el.replaceChildren(...els);
|
|
8057
|
-
} else {
|
|
8058
|
-
el.replaceChildren(els);
|
|
8059
|
-
}
|
|
8060
|
-
}
|
|
8061
|
-
ElementUtils2.removeAllChildren = removeAllChildren;
|
|
8062
|
-
function loadImage(src, callback) {
|
|
8063
|
-
let targetCallback;
|
|
8064
|
-
let promise = void 0;
|
|
8065
|
-
if (callback) {
|
|
8066
|
-
targetCallback = callback.onload;
|
|
8067
|
-
} else {
|
|
8068
|
-
const r = Promises.withResolvers();
|
|
8069
|
-
promise = r.promise;
|
|
8070
|
-
targetCallback = r.resolve;
|
|
8071
|
-
}
|
|
8072
|
-
const img = new Image();
|
|
8073
|
-
img.onload = () => {
|
|
8074
|
-
targetCallback(img);
|
|
8075
|
-
};
|
|
8076
|
-
if (callback && callback.onerror) {
|
|
8077
|
-
img.onerror = callback.onerror;
|
|
8078
|
-
}
|
|
8079
|
-
img.src = src;
|
|
8080
|
-
return promise;
|
|
8081
|
-
}
|
|
8082
|
-
ElementUtils2.loadImage = loadImage;
|
|
8083
|
-
function loadAudio(src, callback) {
|
|
8084
|
-
let targetCallback;
|
|
8085
|
-
let error;
|
|
8086
|
-
let promise = void 0;
|
|
8087
|
-
if (callback) {
|
|
8088
|
-
targetCallback = callback.onload;
|
|
8089
|
-
error = callback.onerror;
|
|
8090
|
-
} else {
|
|
8091
|
-
const r = Promises.withResolvers();
|
|
8092
|
-
promise = r.promise;
|
|
8093
|
-
error = r.reject;
|
|
8094
|
-
targetCallback = r.resolve;
|
|
8095
|
-
}
|
|
8096
|
-
const audio = new Audio("path/to/audio1.mp3");
|
|
8097
|
-
audio.addEventListener("canplay", () => {
|
|
8098
|
-
targetCallback?.(audio);
|
|
8099
|
-
});
|
|
8100
|
-
audio.addEventListener("error", (e) => {
|
|
8101
|
-
callback?.onerror(e);
|
|
8102
|
-
});
|
|
8103
|
-
audio.load();
|
|
8104
|
-
return promise;
|
|
8105
|
-
}
|
|
8106
|
-
ElementUtils2.loadAudio = loadAudio;
|
|
8107
|
-
ElementUtils2.toInnerHTML = (documentFragment, config) => {
|
|
8108
|
-
const tempDiv = config.document.createElement("div");
|
|
8109
|
-
tempDiv.appendChild(documentFragment.cloneNode(true));
|
|
8110
|
-
return tempDiv.innerHTML;
|
|
8111
|
-
};
|
|
8112
|
-
ElementUtils2.htmlToFragment = (html, config = { document }) => {
|
|
8113
|
-
const tempDiv = config.document.createElement("div");
|
|
8114
|
-
tempDiv.innerHTML = html;
|
|
8115
|
-
const fragment = config.document.createDocumentFragment();
|
|
8116
|
-
while (tempDiv.firstChild) {
|
|
8117
|
-
fragment.appendChild(tempDiv.firstChild);
|
|
8118
|
-
}
|
|
8119
|
-
return fragment;
|
|
8120
|
-
};
|
|
8121
|
-
ElementUtils2.replaceWith = (targetElement, replaceElement) => {
|
|
8122
|
-
targetElement.replaceWith(replaceElement);
|
|
8123
|
-
};
|
|
8124
|
-
ElementUtils2.nodeList = (documentFragment) => {
|
|
8125
|
-
return Array.from(documentFragment.childNodes);
|
|
8126
|
-
};
|
|
8127
|
-
ElementUtils2.cloneNodeList = (documentFragment) => {
|
|
8128
|
-
return Array.from(documentFragment.childNodes).map((node) => node.cloneNode(true));
|
|
8129
|
-
};
|
|
8130
|
-
ElementUtils2.querySelector = (e, selector) => {
|
|
8131
|
-
const elements = ElementUtils2.querySelectorAll(e, selector);
|
|
8132
|
-
if (elements.length > 0) {
|
|
8133
|
-
return elements[0];
|
|
8134
|
-
} else {
|
|
8135
|
-
return null;
|
|
8136
|
-
}
|
|
8137
|
-
};
|
|
8138
|
-
ElementUtils2.querySelectorAll = (e, selector) => {
|
|
8139
|
-
if (e instanceof Element) {
|
|
8140
|
-
return Array.from(e.querySelectorAll(selector));
|
|
8141
|
-
} else {
|
|
8142
|
-
const startNode = e.start;
|
|
8143
|
-
const endNode = e.end;
|
|
8144
|
-
if (startNode && endNode && startNode.parentNode === endNode.parentNode) {
|
|
8145
|
-
const elements = [];
|
|
8146
|
-
let currentNode = startNode.nextSibling;
|
|
8147
|
-
while (currentNode && currentNode !== endNode) {
|
|
8148
|
-
if (currentNode.nodeType === Node.ELEMENT_NODE) {
|
|
8149
|
-
const currentElement = currentNode;
|
|
8150
|
-
if (currentElement.matches(selector)) {
|
|
8151
|
-
elements.push(currentElement);
|
|
8152
|
-
}
|
|
8153
|
-
elements.push(...Array.from(currentElement.querySelectorAll(selector)));
|
|
8154
|
-
}
|
|
8155
|
-
currentNode = currentNode.nextSibling;
|
|
8156
|
-
}
|
|
8157
|
-
return elements;
|
|
8158
|
-
}
|
|
8159
|
-
}
|
|
8160
|
-
return [];
|
|
8161
|
-
};
|
|
8162
|
-
ElementUtils2.selectorElements = (selector, element = document) => {
|
|
8163
|
-
return Array.prototype.slice.call(element.querySelectorAll(selector));
|
|
8164
|
-
};
|
|
8165
|
-
ElementUtils2.selectorNodes = (selector, element = document) => {
|
|
8166
|
-
return element.querySelectorAll(selector);
|
|
8167
|
-
};
|
|
8168
|
-
ElementUtils2.removeAttribute = (result, attrs) => {
|
|
8169
|
-
attrs.forEach((it) => {
|
|
8170
|
-
result.removeAttribute(it);
|
|
8171
|
-
});
|
|
7251
|
+
ElementUtils2.removeAttribute = (result, attrs) => {
|
|
7252
|
+
attrs.forEach((it) => {
|
|
7253
|
+
result.removeAttribute(it);
|
|
7254
|
+
});
|
|
8172
7255
|
};
|
|
8173
7256
|
ElementUtils2.setAttribute = (result, attrs) => {
|
|
8174
7257
|
attrs.forEach((it) => {
|
|
@@ -8493,6 +7576,12 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8493
7576
|
});
|
|
8494
7577
|
}
|
|
8495
7578
|
ConvertUtils22.compressImage = compressImage;
|
|
7579
|
+
function decodeHtmlEntity(html, doc) {
|
|
7580
|
+
const textarea = doc.createElement("textarea");
|
|
7581
|
+
textarea.innerHTML = html;
|
|
7582
|
+
return textarea.value;
|
|
7583
|
+
}
|
|
7584
|
+
ConvertUtils22.decodeHtmlEntity = decodeHtmlEntity;
|
|
8496
7585
|
})(ConvertUtils2 || (ConvertUtils2 = {}));
|
|
8497
7586
|
|
|
8498
7587
|
// ../core-web/dist/esm/clipboard/ClipBoardUtils.js
|
|
@@ -8665,99 +7754,1224 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8665
7754
|
Array.from(rule.style).filter((prop) => prop.startsWith("--")).forEach((prop) => variables.add(prop));
|
|
8666
7755
|
}
|
|
8667
7756
|
});
|
|
8668
|
-
} catch (e) {
|
|
8669
|
-
console.warn("\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uC811\uADFC \uC81C\uD55C:", e);
|
|
7757
|
+
} catch (e) {
|
|
7758
|
+
console.warn("\uC2A4\uD0C0\uC77C\uC2DC\uD2B8 \uC811\uADFC \uC81C\uD55C:", e);
|
|
7759
|
+
}
|
|
7760
|
+
});
|
|
7761
|
+
}
|
|
7762
|
+
const computedStyles = config.window.getComputedStyle(targetElement);
|
|
7763
|
+
Array.from(computedStyles).filter((prop) => prop.startsWith("--")).forEach((it) => {
|
|
7764
|
+
variables.add(it);
|
|
7765
|
+
});
|
|
7766
|
+
return Array.from(variables).map((it) => [it, computedStyles.getPropertyValue(it)]);
|
|
7767
|
+
};
|
|
7768
|
+
})(StyleCssUtils || (StyleCssUtils = {}));
|
|
7769
|
+
|
|
7770
|
+
// ../core-web/dist/esm/animation/AnimationFrameUtils.js
|
|
7771
|
+
var AnimationFrameUtils;
|
|
7772
|
+
((AnimationFrameUtils2) => {
|
|
7773
|
+
function fps(params, callback) {
|
|
7774
|
+
let startTimestamp = null;
|
|
7775
|
+
let stop = false;
|
|
7776
|
+
const animate = (currentTimestamp) => {
|
|
7777
|
+
if (startTimestamp !== null) {
|
|
7778
|
+
const delta = currentTimestamp - startTimestamp;
|
|
7779
|
+
const fps2 = (params?.second ?? 1) * 1e3 / delta;
|
|
7780
|
+
callback({ fpsConfigParam: params, fps: fps2, startTimestamp, timestamp: currentTimestamp });
|
|
7781
|
+
}
|
|
7782
|
+
startTimestamp = currentTimestamp;
|
|
7783
|
+
if (!stop) {
|
|
7784
|
+
window.requestAnimationFrame(animate);
|
|
7785
|
+
}
|
|
7786
|
+
};
|
|
7787
|
+
window.requestAnimationFrame(animate);
|
|
7788
|
+
return new AutoCloseSubscription(() => stop = true);
|
|
7789
|
+
}
|
|
7790
|
+
AnimationFrameUtils2.fps = fps;
|
|
7791
|
+
AnimationFrameUtils2.dividePerFpsObservable = ({
|
|
7792
|
+
fpsConfig,
|
|
7793
|
+
divideSize
|
|
7794
|
+
}) => {
|
|
7795
|
+
return new Observable((subscriber) => {
|
|
7796
|
+
const handler = (event) => subscriber.next(event);
|
|
7797
|
+
let fps2 = 0;
|
|
7798
|
+
const getDrawFpsGap = () => {
|
|
7799
|
+
return Math.floor(fps2 / divideSize);
|
|
7800
|
+
};
|
|
7801
|
+
let gapPosition = 0;
|
|
7802
|
+
const fpsSubscription = AnimationFrameUtils2.fps(fpsConfig, (fpsConfig2) => {
|
|
7803
|
+
fps2 = fpsConfig2.fps;
|
|
7804
|
+
gapPosition++;
|
|
7805
|
+
const gapSize = getDrawFpsGap();
|
|
7806
|
+
if (gapPosition >= gapSize) {
|
|
7807
|
+
handler({ ...fpsConfig2, ...{ gapPosition, gapSize } });
|
|
7808
|
+
gapPosition = 0;
|
|
7809
|
+
}
|
|
7810
|
+
});
|
|
7811
|
+
return () => {
|
|
7812
|
+
fpsSubscription.unsubscribe();
|
|
7813
|
+
};
|
|
7814
|
+
});
|
|
7815
|
+
};
|
|
7816
|
+
})(AnimationFrameUtils || (AnimationFrameUtils = {}));
|
|
7817
|
+
|
|
7818
|
+
// ../core-web/dist/esm/valid/ValidUtils.js
|
|
7819
|
+
var ValidUtils2;
|
|
7820
|
+
((ValidUtils22) => {
|
|
7821
|
+
ValidUtils22.coreValidUtils = ValidUtils;
|
|
7822
|
+
ValidUtils22.isBrowser = (callBack) => {
|
|
7823
|
+
const boolean = typeof window !== "undefined" && typeof Window !== "undefined";
|
|
7824
|
+
if (boolean && callBack) {
|
|
7825
|
+
callBack(window);
|
|
7826
|
+
}
|
|
7827
|
+
return boolean;
|
|
7828
|
+
};
|
|
7829
|
+
ValidUtils22.hasParentWindow = (win) => ValidUtils22.isBrowser() && win.parent && win !== win.parent;
|
|
7830
|
+
ValidUtils22.isSocialNetworkServiceInappBrowser = () => {
|
|
7831
|
+
const userAgent = ValidUtils22.isBrowser() ? window.navigator.userAgent.toLowerCase() : "none";
|
|
7832
|
+
return /kakaotalk|naver|facebook|insta|FBAN|FBAV/.test(userAgent);
|
|
7833
|
+
};
|
|
7834
|
+
ValidUtils22.isWkWebview = () => ValidUtils22.isBrowser() && window["webkit"] != null && window["webkit"].messageHandlers != null && window["webkit"].messageHandlers["System"] != null;
|
|
7835
|
+
function isiPhone() {
|
|
7836
|
+
return ValidUtils22.isBrowser() && /iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase());
|
|
7837
|
+
}
|
|
7838
|
+
ValidUtils22.isiPhone = isiPhone;
|
|
7839
|
+
ValidUtils22.isAndroidWebview = () => {
|
|
7840
|
+
return ValidUtils22.isBrowser() && window["System"] != null;
|
|
7841
|
+
};
|
|
7842
|
+
ValidUtils22.isMobile = (win) => {
|
|
7843
|
+
const targetWindow = win ?? ((0, ValidUtils22.isBrowser)() ? window : void 0);
|
|
7844
|
+
if (!targetWindow) {
|
|
7845
|
+
return false;
|
|
7846
|
+
}
|
|
7847
|
+
return /Mobi/i.test(targetWindow.navigator.userAgent);
|
|
7848
|
+
};
|
|
7849
|
+
})(ValidUtils2 || (ValidUtils2 = {}));
|
|
7850
|
+
|
|
7851
|
+
// src/decorators/elementDefine.ts
|
|
7852
|
+
var ELEMENT_CONFIG_KEY = Symbol.for("simple-web-component:element-config");
|
|
7853
|
+
var getElementConfig = (target) => {
|
|
7854
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
7855
|
+
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
7856
|
+
};
|
|
7857
|
+
var ensureInit = (inst) => {
|
|
7858
|
+
if (!inst.__swc_initialized) {
|
|
7859
|
+
inst._swcId = Math.random().toString(36).substring(2, 11);
|
|
7860
|
+
inst._emitHandlers = /* @__PURE__ */ new Map();
|
|
7861
|
+
inst._boundListeners = [];
|
|
7862
|
+
inst.__swc_initialized = true;
|
|
7863
|
+
const target = inst instanceof Function ? inst : inst.constructor;
|
|
7864
|
+
const attributeList = findAllAttributeMetadata(target);
|
|
7865
|
+
attributeList.forEach((meta) => {
|
|
7866
|
+
delete inst[meta.propertyKey];
|
|
7867
|
+
});
|
|
7868
|
+
const queryList = getQueryMetadata(target);
|
|
7869
|
+
if (queryList) {
|
|
7870
|
+
queryList.forEach((meta) => {
|
|
7871
|
+
delete inst[meta.propertyKey];
|
|
7872
|
+
});
|
|
7873
|
+
}
|
|
7874
|
+
const queryAllList = getQueryAllMetadata(target);
|
|
7875
|
+
if (queryAllList) {
|
|
7876
|
+
queryAllList.forEach((meta) => {
|
|
7877
|
+
delete inst[meta.propertyKey];
|
|
7878
|
+
});
|
|
7879
|
+
}
|
|
7880
|
+
const hostSet = SwcUtils.getHostSet(inst);
|
|
7881
|
+
const appHosts = SwcUtils.findAllParentAppHostsDirect(inst);
|
|
7882
|
+
inst._executeSwcScript?.("swc-on-constructor", hostSet);
|
|
7883
|
+
const cMethods = findAllLifecycleMetadata(inst, ON_INITIALIZE_METADATA_KEY);
|
|
7884
|
+
if (cMethods) {
|
|
7885
|
+
for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
|
|
7886
|
+
}
|
|
7887
|
+
}
|
|
7888
|
+
};
|
|
7889
|
+
var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
|
|
7890
|
+
var handleGlobalSwcEvent = async (event) => {
|
|
7891
|
+
if (event.__swc_handled) return;
|
|
7892
|
+
const path = event.composedPath();
|
|
7893
|
+
const type = event.type;
|
|
7894
|
+
const attrName = `swc-on-${type}`;
|
|
7895
|
+
for (const node of path) {
|
|
7896
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
7897
|
+
const script = node.getAttribute?.(attrName);
|
|
7898
|
+
if (script && !getElementConfig(node)) {
|
|
7899
|
+
const host2 = SwcUtils.findNearestSwcHost(node);
|
|
7900
|
+
if (host2 && host2.isConnected && typeof host2.__swc_executeAttributeEvent === "function") {
|
|
7901
|
+
await host2.__swc_executeAttributeEvent(node, attrName, script, event);
|
|
7902
|
+
event.__swc_handled = true;
|
|
7903
|
+
break;
|
|
7904
|
+
}
|
|
7905
|
+
}
|
|
7906
|
+
}
|
|
7907
|
+
};
|
|
7908
|
+
function buildEnv(configWindow) {
|
|
7909
|
+
const win = configWindow || (typeof window !== "undefined" ? window : void 0);
|
|
7910
|
+
const doc = win?.document;
|
|
7911
|
+
const builtInTagMap = /* @__PURE__ */ new Map();
|
|
7912
|
+
for (const [cls, tag] of HTML_TAG_ENTRIES) {
|
|
7913
|
+
if (win?.[cls]) builtInTagMap.set(win[cls], tag);
|
|
7914
|
+
}
|
|
7915
|
+
const domHelpers = SwcUtils.getHelperSet(win);
|
|
7916
|
+
return { win, doc, builtInTagMap, domHelpers };
|
|
7917
|
+
}
|
|
7918
|
+
var getHandlers = (inst) => {
|
|
7919
|
+
if (!inst.__swc_attributeEventHandlers) inst.__swc_attributeEventHandlers = /* @__PURE__ */ new Map();
|
|
7920
|
+
return inst.__swc_attributeEventHandlers;
|
|
7921
|
+
};
|
|
7922
|
+
var setupPrototype = (proto) => {
|
|
7923
|
+
if (proto.__swc_proto_setup) return;
|
|
7924
|
+
proto.__swc_proto_setup = true;
|
|
7925
|
+
proto._executeSwcScript = function(attrName, hostSet, extraArgs = {}) {
|
|
7926
|
+
ensureInit(this);
|
|
7927
|
+
const script = this.getAttribute(attrName);
|
|
7928
|
+
if (script) {
|
|
7929
|
+
try {
|
|
7930
|
+
const conf = getElementConfig(this);
|
|
7931
|
+
const currentWin = this._resolveWindow(conf);
|
|
7932
|
+
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
7933
|
+
const args = { ...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode() };
|
|
7934
|
+
FunctionUtils.execute({ script, context: this, args });
|
|
7935
|
+
} catch (e) {
|
|
7936
|
+
console.error(`[SWC] Failed to execute ${attrName}:`, e);
|
|
7937
|
+
}
|
|
7938
|
+
}
|
|
7939
|
+
};
|
|
7940
|
+
proto._resolveWindow = function(localConfig) {
|
|
7941
|
+
ensureInit(this);
|
|
7942
|
+
if (localConfig?.window) return localConfig.window;
|
|
7943
|
+
const ancestors = SwcUtils.findAllSwcHosts(this);
|
|
7944
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
7945
|
+
const aConf = getElementConfig(ancestors[i]);
|
|
7946
|
+
if (aConf?.window) return aConf.window;
|
|
7947
|
+
}
|
|
7948
|
+
return typeof window !== "undefined" ? window : void 0;
|
|
7949
|
+
};
|
|
7950
|
+
proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
|
|
7951
|
+
ensureInit(this);
|
|
7952
|
+
if (typeof this[methodName] !== "function") return;
|
|
7953
|
+
const useHostSet = hostSet ?? SwcUtils.getHostSet(this);
|
|
7954
|
+
const app = useHostSet?.$appHost?.simpleApplication;
|
|
7955
|
+
if (app) {
|
|
7956
|
+
const otherStorage = /* @__PURE__ */ new Map();
|
|
7957
|
+
const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOSTSET" /* HOST_SET */, data: useHostSet }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://APPHOST" /* APP_HOST */, data: useHostSet.$appHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://APPHOSTS" /* APP_HOSTS */, data: useHostSet.$appHosts }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOST" /* HOST */, data: useHostSet.$host }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOSTS" /* HOSTS */, data: useHostSet.$hosts }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://FIRSTHOST" /* FIRST_HOST */, data: useHostSet.$firstHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://LASTHOST" /* LAST_HOST */, data: useHostSet.$lastHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://FIRSTAPPHOST" /* FIRST_APP_HOST */, data: useHostSet.$firstAppHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://LASTAPPHOST" /* LAST_APP_HOST */, data: useHostSet.$lastAppHost })]);
|
|
7958
|
+
otherStorage.set(SituationTypeContainers, situations);
|
|
7959
|
+
return app.simstanceManager.executeBindParameterSim(
|
|
7960
|
+
{
|
|
7961
|
+
target: this,
|
|
7962
|
+
targetKey: methodName,
|
|
7963
|
+
inputParameters: extraArgs
|
|
7964
|
+
},
|
|
7965
|
+
otherStorage
|
|
7966
|
+
);
|
|
7967
|
+
} else {
|
|
7968
|
+
return this[methodName](...extraArgs);
|
|
7969
|
+
}
|
|
7970
|
+
};
|
|
7971
|
+
proto._bindAttributeEvent = function(el, attrName, script, eventName) {
|
|
7972
|
+
ensureInit(this);
|
|
7973
|
+
if (!eventName) {
|
|
7974
|
+
if (!attrName.startsWith("swc-on-")) return;
|
|
7975
|
+
eventName = attrName.substring(7);
|
|
7976
|
+
}
|
|
7977
|
+
const elHandlers = getHandlers(this);
|
|
7978
|
+
let handlers = elHandlers.get(el);
|
|
7979
|
+
if (!handlers) {
|
|
7980
|
+
handlers = /* @__PURE__ */ new Map();
|
|
7981
|
+
elHandlers.set(el, handlers);
|
|
7982
|
+
}
|
|
7983
|
+
const oldHandler = handlers.get(attrName);
|
|
7984
|
+
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
7985
|
+
const handler = async (event) => {
|
|
7986
|
+
const hostSet = SwcUtils.getHostSet(el);
|
|
7987
|
+
const conf = getElementConfig(this);
|
|
7988
|
+
const currentWin = this._resolveWindow(conf);
|
|
7989
|
+
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
7990
|
+
const args = {
|
|
7991
|
+
event,
|
|
7992
|
+
$data: event.detail,
|
|
7993
|
+
...hostSet,
|
|
7994
|
+
...helpers,
|
|
7995
|
+
$el: el,
|
|
7996
|
+
$root: this.getRootNode()
|
|
7997
|
+
};
|
|
7998
|
+
await FunctionUtils.execute({ script, context: el, args });
|
|
7999
|
+
};
|
|
8000
|
+
el.addEventListener(eventName, handler);
|
|
8001
|
+
handlers.set(attrName, handler);
|
|
8002
|
+
};
|
|
8003
|
+
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
|
|
8004
|
+
ensureInit(this);
|
|
8005
|
+
const hostSet = SwcUtils.getHostSet(el);
|
|
8006
|
+
const conf = getElementConfig(this);
|
|
8007
|
+
const currentWin = this._resolveWindow(conf);
|
|
8008
|
+
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
8009
|
+
const detail = event.detail;
|
|
8010
|
+
const args = {
|
|
8011
|
+
event,
|
|
8012
|
+
$event: event,
|
|
8013
|
+
$data: detail,
|
|
8014
|
+
$detail: detail,
|
|
8015
|
+
...hostSet,
|
|
8016
|
+
...currentHelpers,
|
|
8017
|
+
$el: el,
|
|
8018
|
+
$root: this.getRootNode()
|
|
8019
|
+
};
|
|
8020
|
+
await FunctionUtils.execute({ script, context: el, args });
|
|
8021
|
+
};
|
|
8022
|
+
};
|
|
8023
|
+
var elementDefine = (name, config = {}) => (constructor) => {
|
|
8024
|
+
const { win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS } = buildEnv(config.window);
|
|
8025
|
+
const metadata = { ...config, name, window: win };
|
|
8026
|
+
if (!metadata.window) {
|
|
8027
|
+
throw new Error("window is required");
|
|
8028
|
+
}
|
|
8029
|
+
let extendsTagName = metadata.extends;
|
|
8030
|
+
if (!extendsTagName) {
|
|
8031
|
+
let proto2 = constructor;
|
|
8032
|
+
const BaseHTMLElement = win.HTMLElement;
|
|
8033
|
+
while (proto2 && proto2 !== BaseHTMLElement && proto2 !== Function.prototype) {
|
|
8034
|
+
extendsTagName = BUILT_IN_TAG_MAP.get(proto2);
|
|
8035
|
+
if (extendsTagName) break;
|
|
8036
|
+
proto2 = Object.getPrototypeOf(proto2);
|
|
8037
|
+
}
|
|
8038
|
+
metadata.extends = extendsTagName;
|
|
8039
|
+
}
|
|
8040
|
+
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
8041
|
+
const emitHostCustomEventList = emitCustomEventList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
8042
|
+
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
8043
|
+
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
8044
|
+
const attributeList = findAllAttributeMetadata(constructor);
|
|
8045
|
+
const applyAttributeMap = findAllAttributeApplyMetadata(constructor);
|
|
8046
|
+
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"];
|
|
8047
|
+
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
8048
|
+
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
8049
|
+
const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
|
|
8050
|
+
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
|
|
8051
|
+
...metadata.observedAttributes ?? [],
|
|
8052
|
+
...attrChangeMap.keys(),
|
|
8053
|
+
...attributeApplyNames,
|
|
8054
|
+
...hostAttributes,
|
|
8055
|
+
...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
|
|
8056
|
+
...swcLifecycleAttributes,
|
|
8057
|
+
...swcOnEvents
|
|
8058
|
+
])];
|
|
8059
|
+
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
8060
|
+
const proto = constructor.prototype;
|
|
8061
|
+
setupPrototype(proto);
|
|
8062
|
+
const originalConnected = proto.connectedCallback;
|
|
8063
|
+
proto.connectedCallback = function() {
|
|
8064
|
+
ensureInit(this);
|
|
8065
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
8066
|
+
const appHost2 = hostSet.$appHost;
|
|
8067
|
+
const conf = getElementConfig(this);
|
|
8068
|
+
const currentWin = this._resolveWindow(conf);
|
|
8069
|
+
if (connectedInnerHtmlList.some((it) => it.options.useShadow === true) && !this.shadowRoot) {
|
|
8070
|
+
this.attachShadow({ mode: "open" });
|
|
8071
|
+
}
|
|
8072
|
+
this._executeSwcScript("swc-on-before-connected", hostSet);
|
|
8073
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
8074
|
+
if (bMethods) {
|
|
8075
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
8076
|
+
}
|
|
8077
|
+
if (connectedInnerHtmlList.length > 0) {
|
|
8078
|
+
let sContent = "", lContent = "";
|
|
8079
|
+
for (const meta of connectedInnerHtmlList) {
|
|
8080
|
+
const res = this._invokeLifecycleMethod(meta.propertyKey, hostSet);
|
|
8081
|
+
if (res !== void 0) {
|
|
8082
|
+
if (meta.options.useShadow) sContent += res;
|
|
8083
|
+
else lContent += res;
|
|
8084
|
+
}
|
|
8085
|
+
}
|
|
8086
|
+
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
8087
|
+
if (lContent) this.innerHTML = lContent;
|
|
8088
|
+
}
|
|
8089
|
+
const root = this.getRootNode();
|
|
8090
|
+
if (!globalDelegatedRoots.has(root)) {
|
|
8091
|
+
DOM_EVENT_NAMES.forEach((type) => {
|
|
8092
|
+
root.addEventListener(type, handleGlobalSwcEvent);
|
|
8093
|
+
});
|
|
8094
|
+
globalDelegatedRoots.add(root);
|
|
8095
|
+
}
|
|
8096
|
+
const delegateListeners = [];
|
|
8097
|
+
const nonDelegateListeners = [];
|
|
8098
|
+
addEventListenerList.forEach((meta) => {
|
|
8099
|
+
if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
|
|
8100
|
+
delegateListeners.push(meta);
|
|
8101
|
+
} else {
|
|
8102
|
+
nonDelegateListeners.push(meta);
|
|
8103
|
+
}
|
|
8104
|
+
});
|
|
8105
|
+
const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
|
|
8106
|
+
delegateListeners.forEach((meta) => {
|
|
8107
|
+
const r = meta.options.root || "auto";
|
|
8108
|
+
const rootKey = `${meta.type}:${r}`;
|
|
8109
|
+
if (!delegatesByTypeAndRoot.has(rootKey)) {
|
|
8110
|
+
delegatesByTypeAndRoot.set(rootKey, []);
|
|
8111
|
+
}
|
|
8112
|
+
delegatesByTypeAndRoot.get(rootKey).push(meta);
|
|
8113
|
+
});
|
|
8114
|
+
delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
|
|
8115
|
+
const [type, rStr] = typeRootKey.split(":");
|
|
8116
|
+
const r = rStr === "auto" ? "auto" : rStr;
|
|
8117
|
+
const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
|
|
8118
|
+
const bindRoots = [];
|
|
8119
|
+
if (r === "auto") bindRoots.push(this.shadowRoot || this);
|
|
8120
|
+
else if (r === "light") bindRoots.push(this);
|
|
8121
|
+
else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
8122
|
+
else if (r === "all") {
|
|
8123
|
+
bindRoots.push(this);
|
|
8124
|
+
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
8125
|
+
}
|
|
8126
|
+
bindRoots.forEach((br) => {
|
|
8127
|
+
const sortedMetaList = [...metaList].sort((a, b) => {
|
|
8128
|
+
const aStop = a.options.stopPropagation ? 1 : 0;
|
|
8129
|
+
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
8130
|
+
return bStop - aStop;
|
|
8131
|
+
});
|
|
8132
|
+
const unifiedHandler = async (event) => {
|
|
8133
|
+
for (const meta of sortedMetaList) {
|
|
8134
|
+
const { selector, options } = meta;
|
|
8135
|
+
const matchedEl = event.target.closest(selector);
|
|
8136
|
+
if (matchedEl && br.contains(matchedEl)) {
|
|
8137
|
+
if (options.filter) {
|
|
8138
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
8139
|
+
if (!options.filter(event, helper)) {
|
|
8140
|
+
continue;
|
|
8141
|
+
}
|
|
8142
|
+
}
|
|
8143
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
8144
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
8145
|
+
if (options.preventDefault) event.preventDefault();
|
|
8146
|
+
const currentHostSet = SwcUtils.getHostSet(this);
|
|
8147
|
+
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
8148
|
+
await this[meta.propertyKey](event, currentHostSet, matchedEl, args);
|
|
8149
|
+
if (event.cancelBubble) break;
|
|
8150
|
+
}
|
|
8151
|
+
}
|
|
8152
|
+
};
|
|
8153
|
+
br.addEventListener(type, unifiedHandler, opts);
|
|
8154
|
+
this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
|
|
8155
|
+
});
|
|
8156
|
+
});
|
|
8157
|
+
nonDelegateListeners.forEach((meta) => {
|
|
8158
|
+
const { selector, type, options } = meta;
|
|
8159
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
8160
|
+
const bindTargets = [];
|
|
8161
|
+
const r = options.root || "auto";
|
|
8162
|
+
const applyRootOption = (target) => {
|
|
8163
|
+
if (!target) return;
|
|
8164
|
+
if (r === "auto") {
|
|
8165
|
+
bindTargets.push(target.shadowRoot || target);
|
|
8166
|
+
} else {
|
|
8167
|
+
if (r === "light" || r === "all") bindTargets.push(target);
|
|
8168
|
+
if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
8169
|
+
}
|
|
8170
|
+
};
|
|
8171
|
+
if (selector === ":window") bindTargets.push(currentWin);
|
|
8172
|
+
else if (selector === ":document") bindTargets.push(currentWin.document);
|
|
8173
|
+
else if (selector === ":parentHost") applyRootOption(hostSet.$parentHost);
|
|
8174
|
+
else if (selector === ":appHost") applyRootOption(hostSet.$appHost);
|
|
8175
|
+
else if (selector === ":firstHost") applyRootOption(hostSet.$firstHost);
|
|
8176
|
+
else if (selector === ":lastHost") applyRootOption(hostSet.$lastHost);
|
|
8177
|
+
else if (selector === ":firstAppHost") applyRootOption(hostSet.$firstAppHost);
|
|
8178
|
+
else if (selector === ":lastAppHost") applyRootOption(hostSet.$lastAppHost);
|
|
8179
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRootOption);
|
|
8180
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRootOption);
|
|
8181
|
+
else if (selector === ":host" || !selector) applyRootOption(this);
|
|
8182
|
+
else {
|
|
8183
|
+
const searchRoots = [];
|
|
8184
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
8185
|
+
else if (r === "light") searchRoots.push(this);
|
|
8186
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
8187
|
+
else if (r === "all") {
|
|
8188
|
+
searchRoots.push(this);
|
|
8189
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
8190
|
+
}
|
|
8191
|
+
searchRoots.forEach((sr) => {
|
|
8192
|
+
sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
|
|
8193
|
+
});
|
|
8194
|
+
}
|
|
8195
|
+
bindTargets.forEach((t) => {
|
|
8196
|
+
const handler = async (event) => {
|
|
8197
|
+
if (options.filter) {
|
|
8198
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
8199
|
+
if (!options.filter(event, helper)) {
|
|
8200
|
+
return;
|
|
8201
|
+
}
|
|
8202
|
+
}
|
|
8203
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
8204
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
8205
|
+
if (options.preventDefault) event.preventDefault();
|
|
8206
|
+
const currentHostSet = SwcUtils.getHostSet(this);
|
|
8207
|
+
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
8208
|
+
await this[meta.propertyKey](event, currentHostSet, args);
|
|
8209
|
+
};
|
|
8210
|
+
t.addEventListener(type, handler, opts);
|
|
8211
|
+
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
8212
|
+
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
8213
|
+
}
|
|
8214
|
+
});
|
|
8215
|
+
});
|
|
8216
|
+
if (originalConnected) originalConnected.apply(this);
|
|
8217
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
8218
|
+
if (aMethods) {
|
|
8219
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
8220
|
+
}
|
|
8221
|
+
this._executeSwcScript("swc-on-connected", hostSet);
|
|
8222
|
+
this._executeSwcScript("swc-on-after-connected", hostSet);
|
|
8223
|
+
this.__swc_connected = true;
|
|
8224
|
+
const appHostss = SwcUtils.findAllParentAppHostsDirect(this);
|
|
8225
|
+
if (appHost2 && typeof appHost2._connected === "function") {
|
|
8226
|
+
appHost2._connected(this);
|
|
8227
|
+
} else if (appHost2 && typeof appHost2) {
|
|
8228
|
+
appHost2._connected_safari ?? (appHost2._connected_safari = []);
|
|
8229
|
+
appHost2._connected_safari.push(this);
|
|
8230
|
+
}
|
|
8231
|
+
};
|
|
8232
|
+
const originalDisconnected = proto.disconnectedCallback;
|
|
8233
|
+
proto.disconnectedCallback = function() {
|
|
8234
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
8235
|
+
this._executeSwcScript("swc-on-before-disconnected", hostSet);
|
|
8236
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
8237
|
+
if (bMethods) {
|
|
8238
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
8239
|
+
}
|
|
8240
|
+
if (this._boundListeners) {
|
|
8241
|
+
this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
8242
|
+
this._boundListeners = [];
|
|
8243
|
+
}
|
|
8244
|
+
if (originalDisconnected) originalDisconnected.apply(this);
|
|
8245
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
8246
|
+
if (aMethods) {
|
|
8247
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
8248
|
+
}
|
|
8249
|
+
this._executeSwcScript("swc-on-disconnected", hostSet);
|
|
8250
|
+
this._executeSwcScript("swc-on-after-disconnected", hostSet);
|
|
8251
|
+
this.__swc_connected = false;
|
|
8252
|
+
const appHost2 = hostSet.$appHost;
|
|
8253
|
+
if (appHost2 && typeof appHost2._disconnected === "function") {
|
|
8254
|
+
appHost2._disconnected(this);
|
|
8255
|
+
}
|
|
8256
|
+
};
|
|
8257
|
+
const originalAdopted = proto.adoptedCallback;
|
|
8258
|
+
proto.adoptedCallback = function() {
|
|
8259
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
8260
|
+
this._executeSwcScript("swc-on-before-adopted", hostSet);
|
|
8261
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);
|
|
8262
|
+
if (bMethods) {
|
|
8263
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
8264
|
+
}
|
|
8265
|
+
if (originalAdopted) originalAdopted.apply(this);
|
|
8266
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);
|
|
8267
|
+
if (aMethods) {
|
|
8268
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
8269
|
+
}
|
|
8270
|
+
this._executeSwcScript("swc-on-adopted", hostSet);
|
|
8271
|
+
this._executeSwcScript("swc-on-after-adopted", hostSet);
|
|
8272
|
+
};
|
|
8273
|
+
const originalAttributeChanged = proto.attributeChangedCallback;
|
|
8274
|
+
proto.attributeChangedCallback = function(name2, old, newVal) {
|
|
8275
|
+
if (originalAttributeChanged) originalAttributeChanged.apply(this, [name2, old, newVal]);
|
|
8276
|
+
const hSet = SwcUtils.getHostSet(this);
|
|
8277
|
+
let processedVal = newVal;
|
|
8278
|
+
if (newVal !== null) {
|
|
8279
|
+
const ae = new ActionExpression(newVal);
|
|
8280
|
+
const expr = ae.getFirstExpression("call-return");
|
|
8281
|
+
if (expr) {
|
|
8282
|
+
const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
|
|
8283
|
+
try {
|
|
8284
|
+
const result = FunctionUtils.executeReturn({
|
|
8285
|
+
script: ConvertUtils2.decodeHtmlEntity(expr.script, win2.document),
|
|
8286
|
+
context: this,
|
|
8287
|
+
args: SwcUtils.getHelperAndHostSet(win2, this)
|
|
8288
|
+
});
|
|
8289
|
+
processedVal = String(result);
|
|
8290
|
+
} catch (e) {
|
|
8291
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}:`, e);
|
|
8292
|
+
processedVal = newVal;
|
|
8293
|
+
}
|
|
8294
|
+
}
|
|
8295
|
+
}
|
|
8296
|
+
if (name2.startsWith("swc-on-") && !swcLifecycleAttributes.includes(name2)) {
|
|
8297
|
+
if (newVal !== null) {
|
|
8298
|
+
const eventName = name2.substring(7);
|
|
8299
|
+
this._bindAttributeEvent(this, name2, newVal, eventName);
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8302
|
+
const hostCustomEventMeta = emitHostCustomEventList.find((it) => it.options.attributeName === name2);
|
|
8303
|
+
if (hostCustomEventMeta && newVal !== null) {
|
|
8304
|
+
this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
|
|
8305
|
+
}
|
|
8306
|
+
const mKeys = attrChangeMap.get(name2);
|
|
8307
|
+
if (mKeys && Array.isArray(mKeys)) {
|
|
8308
|
+
for (const key of mKeys) this[key](processedVal, old, name2, hSet);
|
|
8309
|
+
}
|
|
8310
|
+
};
|
|
8311
|
+
Object.defineProperty(constructor, "observedAttributes", {
|
|
8312
|
+
get: () => mergedObservedAttributes,
|
|
8313
|
+
configurable: true
|
|
8314
|
+
});
|
|
8315
|
+
ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);
|
|
8316
|
+
const registry = metadata.customElementRegistry || win?.customElements;
|
|
8317
|
+
if (registry && !registry.get(metadata.name)) {
|
|
8318
|
+
registry.define(metadata.name, constructor, metadata.extends ? { extends: metadata.extends } : void 0);
|
|
8319
|
+
}
|
|
8320
|
+
return constructor;
|
|
8321
|
+
};
|
|
8322
|
+
|
|
8323
|
+
// src/decorators/attribute.ts
|
|
8324
|
+
var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
|
|
8325
|
+
var convertValue = (val, type) => {
|
|
8326
|
+
if (val === null || val === void 0) return val;
|
|
8327
|
+
if (type === Number) return Number(val);
|
|
8328
|
+
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
8329
|
+
return val;
|
|
8330
|
+
};
|
|
8331
|
+
var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
8332
|
+
const r = options.root || "auto";
|
|
8333
|
+
const results = [];
|
|
8334
|
+
const applyRoot = (target) => {
|
|
8335
|
+
if (!target) return;
|
|
8336
|
+
if (r === "auto") {
|
|
8337
|
+
results.push(target);
|
|
8338
|
+
} else {
|
|
8339
|
+
if (r === "light" || r === "all") results.push(target);
|
|
8340
|
+
if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
|
|
8341
|
+
}
|
|
8342
|
+
};
|
|
8343
|
+
if (selector === ":host" || !selector) {
|
|
8344
|
+
applyRoot(inst);
|
|
8345
|
+
} else if (selector === ":window") {
|
|
8346
|
+
results.push(currentWin);
|
|
8347
|
+
} else if (selector === ":document") {
|
|
8348
|
+
results.push(currentWin.document);
|
|
8349
|
+
} else {
|
|
8350
|
+
const hostSet = SwcUtils.getHostSet(inst);
|
|
8351
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8352
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8353
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8354
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8355
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8356
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8357
|
+
else {
|
|
8358
|
+
if (r === "shadow") {
|
|
8359
|
+
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
8360
|
+
if (found) results.push(...found);
|
|
8361
|
+
} else if (r === "light") {
|
|
8362
|
+
const found = inst.querySelectorAll(selector);
|
|
8363
|
+
if (found) results.push(...found);
|
|
8364
|
+
} else if (r === "all") {
|
|
8365
|
+
const sMatch = inst.shadowRoot?.querySelectorAll(selector);
|
|
8366
|
+
const lMatch = inst.querySelectorAll(selector);
|
|
8367
|
+
if (sMatch) results.push(...sMatch);
|
|
8368
|
+
if (lMatch) results.push(...lMatch);
|
|
8369
|
+
} else {
|
|
8370
|
+
const found = (inst.shadowRoot || inst).querySelectorAll(selector);
|
|
8371
|
+
if (found) results.push(...found);
|
|
8372
|
+
}
|
|
8373
|
+
}
|
|
8374
|
+
}
|
|
8375
|
+
return results;
|
|
8376
|
+
};
|
|
8377
|
+
function attribute(selector, options = {}) {
|
|
8378
|
+
return (target, propertyKey) => {
|
|
8379
|
+
const constructor = target.constructor;
|
|
8380
|
+
const privateKey = Symbol(String(propertyKey));
|
|
8381
|
+
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
8382
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_FIELD_METADATA_KEY, constructor);
|
|
8383
|
+
if (!metaList) {
|
|
8384
|
+
metaList = [];
|
|
8385
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_FIELD_METADATA_KEY, metaList, constructor);
|
|
8386
|
+
}
|
|
8387
|
+
metaList.push({ propertyKey, selector, options, privateKey });
|
|
8388
|
+
const applySetAttribute = (inst, targets, attrName, nv) => {
|
|
8389
|
+
targets.forEach((it) => {
|
|
8390
|
+
if (it && typeof it.setAttribute === "function") {
|
|
8391
|
+
if (nv === null) {
|
|
8392
|
+
it.removeAttribute(attrName);
|
|
8393
|
+
} else {
|
|
8394
|
+
it.setAttribute(attrName, String(nv));
|
|
8395
|
+
}
|
|
8396
|
+
} else {
|
|
8397
|
+
inst[privateKey] = nv;
|
|
8398
|
+
}
|
|
8399
|
+
});
|
|
8400
|
+
};
|
|
8401
|
+
try {
|
|
8402
|
+
Object.defineProperty(target, propertyKey, {
|
|
8403
|
+
get() {
|
|
8404
|
+
const attrName = options.name || String(propertyKey);
|
|
8405
|
+
const conf = getElementConfig(this);
|
|
8406
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8407
|
+
const targetType = options.type || designType;
|
|
8408
|
+
const targets = resolveTargetEls(this, selector, options, currentWin);
|
|
8409
|
+
const primaryTarget = targets[0];
|
|
8410
|
+
if (primaryTarget && typeof primaryTarget.hasAttribute === "function") {
|
|
8411
|
+
if (primaryTarget.hasAttribute(attrName)) {
|
|
8412
|
+
let domVal = primaryTarget.getAttribute(attrName);
|
|
8413
|
+
const ae = new ActionExpression(domVal);
|
|
8414
|
+
const expr = ae.getFirstExpression("call-return");
|
|
8415
|
+
if (expr) {
|
|
8416
|
+
try {
|
|
8417
|
+
const result = FunctionUtils.executeReturn({
|
|
8418
|
+
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8419
|
+
context: this,
|
|
8420
|
+
args: SwcUtils.getHelperAndHostSet(currentWin, this)
|
|
8421
|
+
});
|
|
8422
|
+
return convertValue(result, targetType);
|
|
8423
|
+
} catch (e) {
|
|
8424
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8425
|
+
return convertValue(domVal, targetType);
|
|
8426
|
+
}
|
|
8427
|
+
}
|
|
8428
|
+
return convertValue(domVal, targetType);
|
|
8429
|
+
}
|
|
8430
|
+
return null;
|
|
8431
|
+
}
|
|
8432
|
+
const data = convertValue(this[privateKey], targetType);
|
|
8433
|
+
return data;
|
|
8434
|
+
},
|
|
8435
|
+
set(nv) {
|
|
8436
|
+
const attrName = options.name || String(propertyKey);
|
|
8437
|
+
const conf = getElementConfig(this);
|
|
8438
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8439
|
+
const targets = resolveTargetEls(this, selector, options, currentWin);
|
|
8440
|
+
applySetAttribute(this, targets, attrName, nv);
|
|
8441
|
+
},
|
|
8442
|
+
enumerable: true,
|
|
8443
|
+
configurable: true
|
|
8444
|
+
});
|
|
8445
|
+
} catch (err) {
|
|
8446
|
+
console.error("[SWC] defineProperty error:", err);
|
|
8447
|
+
}
|
|
8448
|
+
};
|
|
8449
|
+
}
|
|
8450
|
+
function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
|
|
8451
|
+
if (propertyKeyOrOptions !== void 0 && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
8452
|
+
return attribute(":host", { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
8453
|
+
}
|
|
8454
|
+
if (typeof targetOrAttrOrOptions === "string") {
|
|
8455
|
+
const attrName = targetOrAttrOrOptions;
|
|
8456
|
+
const options = typeof propertyKeyOrOptions === "object" ? propertyKeyOrOptions : {};
|
|
8457
|
+
return attribute(":host", { ...options, name: attrName });
|
|
8458
|
+
} else if (typeof targetOrAttrOrOptions === "object") {
|
|
8459
|
+
const options = targetOrAttrOrOptions;
|
|
8460
|
+
return (target, propertyKey) => {
|
|
8461
|
+
return attribute(":host", { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
8462
|
+
};
|
|
8463
|
+
} else {
|
|
8464
|
+
return (target, propertyKey) => {
|
|
8465
|
+
return attribute(":host", { name: String(propertyKey) })(target, propertyKey);
|
|
8466
|
+
};
|
|
8467
|
+
}
|
|
8468
|
+
}
|
|
8469
|
+
var findAllAttributeMetadata = (target) => {
|
|
8470
|
+
const actualTarget = target instanceof Function ? target : target.constructor;
|
|
8471
|
+
return ReflectUtils.findAllMetadata(ATTRIBUTE_FIELD_METADATA_KEY, actualTarget).flat();
|
|
8472
|
+
};
|
|
8473
|
+
|
|
8474
|
+
// src/decorators/applyNode.ts
|
|
8475
|
+
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
8476
|
+
var normalizeNodes = (res, doc) => {
|
|
8477
|
+
const items = Array.isArray(res) ? res : [res];
|
|
8478
|
+
return items.map((it) => {
|
|
8479
|
+
if (it instanceof Node) return it;
|
|
8480
|
+
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
8481
|
+
});
|
|
8482
|
+
};
|
|
8483
|
+
var applyToDom = (targetEl, res, pos, doc) => {
|
|
8484
|
+
if (!targetEl) return;
|
|
8485
|
+
if (pos === "innerHtml") {
|
|
8486
|
+
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
8487
|
+
return;
|
|
8488
|
+
}
|
|
8489
|
+
if (pos === "innerText") {
|
|
8490
|
+
if (targetEl.innerText !== void 0) {
|
|
8491
|
+
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
8492
|
+
}
|
|
8493
|
+
return;
|
|
8494
|
+
}
|
|
8495
|
+
const isShadowRoot = targetEl instanceof ShadowRoot;
|
|
8496
|
+
const nodes = normalizeNodes(res, doc);
|
|
8497
|
+
if (pos === "replace") {
|
|
8498
|
+
if (!isShadowRoot) targetEl.replaceWith(...nodes);
|
|
8499
|
+
} else if (pos === "replaceChildren") {
|
|
8500
|
+
targetEl.replaceChildren(...nodes);
|
|
8501
|
+
} else {
|
|
8502
|
+
if (pos === "beforeEnd") targetEl.append(...nodes);
|
|
8503
|
+
else if (pos === "afterBegin") targetEl.prepend(...nodes);
|
|
8504
|
+
else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
|
|
8505
|
+
else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
|
|
8506
|
+
}
|
|
8507
|
+
};
|
|
8508
|
+
function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
8509
|
+
return (targetObj, propertyKey, descriptor) => {
|
|
8510
|
+
const constructor = targetObj.constructor;
|
|
8511
|
+
let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
|
|
8512
|
+
if (!metaList) {
|
|
8513
|
+
metaList = /* @__PURE__ */ new Map();
|
|
8514
|
+
ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);
|
|
8515
|
+
}
|
|
8516
|
+
metaList.set(propertyKey, { propertyKey, selector, options });
|
|
8517
|
+
const original = descriptor.value;
|
|
8518
|
+
descriptor.value = function(...args) {
|
|
8519
|
+
ensureInit(this);
|
|
8520
|
+
const conf = getElementConfig(this);
|
|
8521
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8522
|
+
const currentDoc = currentWin.document;
|
|
8523
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
8524
|
+
const getTarget = () => {
|
|
8525
|
+
const r = options.root || "auto";
|
|
8526
|
+
const applyRoot = (t) => {
|
|
8527
|
+
if (!t) return t;
|
|
8528
|
+
if (r === "auto") return t.shadowRoot || t;
|
|
8529
|
+
if (r === "shadow") return t.shadowRoot;
|
|
8530
|
+
if (r === "light") return t;
|
|
8531
|
+
if (r === "all") return t.shadowRoot || t;
|
|
8532
|
+
return t;
|
|
8533
|
+
};
|
|
8534
|
+
if (selector === ":host") return applyRoot(this);
|
|
8535
|
+
if (selector === ":parentHost") return applyRoot(hostSet.$parentHost);
|
|
8536
|
+
if (selector === ":appHost") return applyRoot(hostSet.$appHost);
|
|
8537
|
+
if (selector === ":firstHost") return applyRoot(hostSet.$firstHost);
|
|
8538
|
+
if (selector === ":lastHost") return applyRoot(hostSet.$lastHost);
|
|
8539
|
+
const targetRoot = applyRoot(this);
|
|
8540
|
+
return targetRoot ? targetRoot.querySelector(selector) : null;
|
|
8541
|
+
};
|
|
8542
|
+
const targetEl = getTarget();
|
|
8543
|
+
const res = original.apply(this, args);
|
|
8544
|
+
const runApply = (target, val) => {
|
|
8545
|
+
const pos = options.position || "beforeEnd";
|
|
8546
|
+
const defaultFilter = (t, v) => {
|
|
8547
|
+
if (v instanceof Node) return !t.contains(v);
|
|
8548
|
+
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
8549
|
+
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
8550
|
+
return true;
|
|
8551
|
+
};
|
|
8552
|
+
const activeFilter = options.filter || defaultFilter;
|
|
8553
|
+
if (activeFilter(target, val, hostSet)) {
|
|
8554
|
+
applyToDom(target, val, pos, currentDoc);
|
|
8555
|
+
}
|
|
8556
|
+
};
|
|
8557
|
+
if (res instanceof Promise) {
|
|
8558
|
+
if (targetEl && options.loading) {
|
|
8559
|
+
const loadingRes = options.loading.call(this, hostSet);
|
|
8560
|
+
applyToDom(targetEl, loadingRes, options.position || "beforeEnd", currentDoc);
|
|
8561
|
+
}
|
|
8562
|
+
return res.then((finalRes) => {
|
|
8563
|
+
if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
|
|
8564
|
+
return finalRes;
|
|
8565
|
+
});
|
|
8566
|
+
} else {
|
|
8567
|
+
if (res !== void 0 && targetEl) runApply(targetEl, res);
|
|
8568
|
+
return res;
|
|
8569
|
+
}
|
|
8570
|
+
};
|
|
8571
|
+
};
|
|
8572
|
+
}
|
|
8573
|
+
var findAllApplyNodeMetadata = (target) => {
|
|
8574
|
+
const result = /* @__PURE__ */ new Map();
|
|
8575
|
+
const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
|
|
8576
|
+
maps.forEach((map) => {
|
|
8577
|
+
if (map instanceof Map) {
|
|
8578
|
+
map.forEach((v, k) => result.set(k, v));
|
|
8579
|
+
}
|
|
8580
|
+
});
|
|
8581
|
+
return result;
|
|
8582
|
+
};
|
|
8583
|
+
function applyNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
8584
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
|
|
8585
|
+
const opt = targetOrOptions || {};
|
|
8586
|
+
return applyNode(":host", { position: "beforeEnd", ...opt });
|
|
8587
|
+
}
|
|
8588
|
+
function applyReplaceChildrenNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
8589
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "replaceChildren" })(targetOrOptions, propertyKey, descriptor);
|
|
8590
|
+
const opt = targetOrOptions || {};
|
|
8591
|
+
return applyNode(":host", { position: "replaceChildren", ...opt });
|
|
8592
|
+
}
|
|
8593
|
+
function applyInnerHtmlNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
8594
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "innerHtml" })(targetOrOptions, propertyKey, descriptor);
|
|
8595
|
+
const opt = targetOrOptions || {};
|
|
8596
|
+
return applyNode(":host", { position: "innerHtml", ...opt });
|
|
8597
|
+
}
|
|
8598
|
+
function applyReplaceChildrenNode(selector, options = {}) {
|
|
8599
|
+
return applyNode(selector, { ...options, position: "replaceChildren" });
|
|
8600
|
+
}
|
|
8601
|
+
function applyInnerHtmlNode(selector, options = {}) {
|
|
8602
|
+
return applyNode(selector, { ...options, position: "innerHtml" });
|
|
8603
|
+
}
|
|
8604
|
+
|
|
8605
|
+
// src/decorators/applyClass.ts
|
|
8606
|
+
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
8607
|
+
function createClassDecorator(action) {
|
|
8608
|
+
return (selector, classMapOrOptions, options = {}) => {
|
|
8609
|
+
return (target, propertyKey, descriptor) => {
|
|
8610
|
+
const constructor = target.constructor;
|
|
8611
|
+
let metaList = ReflectUtils.getOwnMetadata(CLASS_METADATA_KEY, constructor);
|
|
8612
|
+
if (!metaList) {
|
|
8613
|
+
metaList = /* @__PURE__ */ new Map();
|
|
8614
|
+
ReflectUtils.defineMetadata(CLASS_METADATA_KEY, metaList, constructor);
|
|
8615
|
+
}
|
|
8616
|
+
let classMap = void 0;
|
|
8617
|
+
let finalOptions = options;
|
|
8618
|
+
if (typeof classMapOrOptions === "string" || typeof classMapOrOptions === "object" && classMapOrOptions !== null && !("root" in classMapOrOptions)) {
|
|
8619
|
+
classMap = classMapOrOptions;
|
|
8620
|
+
} else if (typeof classMapOrOptions === "object" && classMapOrOptions !== null && "root" in classMapOrOptions) {
|
|
8621
|
+
finalOptions = classMapOrOptions;
|
|
8622
|
+
}
|
|
8623
|
+
metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
|
|
8624
|
+
const original = descriptor.value;
|
|
8625
|
+
descriptor.value = async function(...args) {
|
|
8626
|
+
ensureInit(this);
|
|
8627
|
+
const res = await original.apply(this, args);
|
|
8628
|
+
if (res !== void 0) {
|
|
8629
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8630
|
+
const host2 = this;
|
|
8631
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8632
|
+
const r = finalOptions.root || "auto";
|
|
8633
|
+
const targetEls = [];
|
|
8634
|
+
const applyRoot = (t) => {
|
|
8635
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8636
|
+
targetEls.push(t);
|
|
8637
|
+
};
|
|
8638
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8639
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8640
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8641
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8642
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8643
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8644
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8645
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8646
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8647
|
+
else {
|
|
8648
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8649
|
+
if (targetRoot) {
|
|
8650
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8651
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8652
|
+
}
|
|
8653
|
+
}
|
|
8654
|
+
targetEls.forEach((targetEl) => {
|
|
8655
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
8656
|
+
if (action === "set") {
|
|
8657
|
+
let classes = "";
|
|
8658
|
+
if (classMap && typeof classMap === "string") {
|
|
8659
|
+
classes = resolvedRes ? classMap : "";
|
|
8660
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8661
|
+
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8662
|
+
} else {
|
|
8663
|
+
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8664
|
+
}
|
|
8665
|
+
targetEl.className = classes;
|
|
8666
|
+
} else if (action === "update" || action === "toggle") {
|
|
8667
|
+
if (classMap && typeof classMap === "string") {
|
|
8668
|
+
targetEl.classList.toggle(classMap, !!resolvedRes);
|
|
8669
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8670
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8671
|
+
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8672
|
+
targetEl.classList.toggle(cls, isActive);
|
|
8673
|
+
});
|
|
8674
|
+
} else {
|
|
8675
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8676
|
+
if (action === "update") targetEl.classList.add(...classes);
|
|
8677
|
+
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8678
|
+
}
|
|
8679
|
+
} else if (action === "add" || action === "remove") {
|
|
8680
|
+
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
8681
|
+
if (action === "add") targetEl.classList.add(classMap);
|
|
8682
|
+
else targetEl.classList.remove(classMap);
|
|
8683
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8684
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8685
|
+
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8686
|
+
if (shouldExecute) {
|
|
8687
|
+
if (action === "add") targetEl.classList.add(cls);
|
|
8688
|
+
else targetEl.classList.remove(cls);
|
|
8689
|
+
}
|
|
8690
|
+
});
|
|
8691
|
+
} else {
|
|
8692
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8693
|
+
if (action === "add") targetEl.classList.add(...classes);
|
|
8694
|
+
else targetEl.classList.remove(...classes);
|
|
8695
|
+
}
|
|
8696
|
+
}
|
|
8697
|
+
});
|
|
8698
|
+
}
|
|
8699
|
+
return res;
|
|
8700
|
+
};
|
|
8701
|
+
return descriptor;
|
|
8702
|
+
};
|
|
8703
|
+
};
|
|
8704
|
+
}
|
|
8705
|
+
function applyClass(selector, action = "update", options = {}) {
|
|
8706
|
+
return createClassDecorator(action)(selector, options);
|
|
8707
|
+
}
|
|
8708
|
+
var setClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("set")(selector, classMapOrOptions, options);
|
|
8709
|
+
var updateClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("update")(selector, classMapOrOptions, options);
|
|
8710
|
+
var addClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("add")(selector, classMapOrOptions, options);
|
|
8711
|
+
var removeClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("remove")(selector, classMapOrOptions, options);
|
|
8712
|
+
var toggleClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("toggle")(selector, classMapOrOptions, options);
|
|
8713
|
+
function applyClassHost(action = "update", options = {}) {
|
|
8714
|
+
return createClassDecorator(action)(":host", options);
|
|
8715
|
+
}
|
|
8716
|
+
var setClassHost = (classMapOrOptions, options = {}) => createClassDecorator("set")(":host", classMapOrOptions, options);
|
|
8717
|
+
var updateClassHost = (classMapOrOptions, options = {}) => createClassDecorator("update")(":host", classMapOrOptions, options);
|
|
8718
|
+
var addClassHost = (classMapOrOptions, options = {}) => createClassDecorator("add")(":host", classMapOrOptions, options);
|
|
8719
|
+
var removeClassHost = (classMapOrOptions, options = {}) => createClassDecorator("remove")(":host", classMapOrOptions, options);
|
|
8720
|
+
var toggleClassHost = (classMapOrOptions, options = {}) => createClassDecorator("toggle")(":host", classMapOrOptions, options);
|
|
8721
|
+
var findAllClassMetadata = (target) => {
|
|
8722
|
+
const result = /* @__PURE__ */ new Map();
|
|
8723
|
+
const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
|
|
8724
|
+
maps.forEach((map) => {
|
|
8725
|
+
if (map instanceof Map) {
|
|
8726
|
+
map.forEach((v, k) => result.set(k, v));
|
|
8727
|
+
}
|
|
8728
|
+
});
|
|
8729
|
+
return result;
|
|
8730
|
+
};
|
|
8731
|
+
|
|
8732
|
+
// src/decorators/applyStyle.ts
|
|
8733
|
+
var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
|
|
8734
|
+
function createStyleDecorator(action) {
|
|
8735
|
+
return (selector, options = {}) => {
|
|
8736
|
+
return (target, propertyKey, descriptor) => {
|
|
8737
|
+
const constructor = target.constructor;
|
|
8738
|
+
let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor);
|
|
8739
|
+
if (!metaList) {
|
|
8740
|
+
metaList = /* @__PURE__ */ new Map();
|
|
8741
|
+
ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
|
|
8742
|
+
}
|
|
8743
|
+
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
8744
|
+
const original = descriptor.value;
|
|
8745
|
+
descriptor.value = async function(...args) {
|
|
8746
|
+
ensureInit(this);
|
|
8747
|
+
const res = await original.apply(this, args);
|
|
8748
|
+
if (res !== void 0) {
|
|
8749
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8750
|
+
const host2 = this;
|
|
8751
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, host2);
|
|
8752
|
+
const r = options.root || "auto";
|
|
8753
|
+
const targetEls = [];
|
|
8754
|
+
const applyRoot = (t) => {
|
|
8755
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8756
|
+
targetEls.push(t);
|
|
8757
|
+
};
|
|
8758
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8759
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8760
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8761
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8762
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8763
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8764
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8765
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8766
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8767
|
+
else {
|
|
8768
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8769
|
+
if (targetRoot) {
|
|
8770
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8771
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8772
|
+
}
|
|
8773
|
+
}
|
|
8774
|
+
targetEls.forEach((targetEl) => {
|
|
8775
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
8776
|
+
if (action === "set" || action === "update") {
|
|
8777
|
+
if (action === "set") targetEl.style.cssText = "";
|
|
8778
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8779
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8780
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8781
|
+
if (finalVal === null || finalVal === void 0) {
|
|
8782
|
+
targetEl.style.removeProperty(prop);
|
|
8783
|
+
} else {
|
|
8784
|
+
targetEl.style[prop] = String(finalVal);
|
|
8785
|
+
}
|
|
8786
|
+
});
|
|
8787
|
+
} else if (typeof resolvedRes === "string") {
|
|
8788
|
+
targetEl.style.cssText = resolvedRes;
|
|
8789
|
+
}
|
|
8790
|
+
} else if (action === "remove") {
|
|
8791
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8792
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8793
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
8794
|
+
if (shouldRemove) {
|
|
8795
|
+
targetEl.style.removeProperty(prop);
|
|
8796
|
+
}
|
|
8797
|
+
});
|
|
8798
|
+
} else {
|
|
8799
|
+
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
8800
|
+
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
8801
|
+
}
|
|
8802
|
+
}
|
|
8803
|
+
});
|
|
8670
8804
|
}
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
variables.add(it);
|
|
8676
|
-
});
|
|
8677
|
-
return Array.from(variables).map((it) => [it, computedStyles.getPropertyValue(it)]);
|
|
8805
|
+
return res;
|
|
8806
|
+
};
|
|
8807
|
+
return descriptor;
|
|
8808
|
+
};
|
|
8678
8809
|
};
|
|
8679
|
-
}
|
|
8810
|
+
}
|
|
8811
|
+
function applyStyle(selector, action = "update", options = {}) {
|
|
8812
|
+
return createStyleDecorator(action)(selector, options);
|
|
8813
|
+
}
|
|
8814
|
+
var setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
|
|
8815
|
+
var updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
|
|
8816
|
+
var removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
|
|
8817
|
+
function applyStyleHost(action = "update", options = {}) {
|
|
8818
|
+
return createStyleDecorator(action)(":host", options);
|
|
8819
|
+
}
|
|
8820
|
+
var setStyleHost = (options = {}) => createStyleDecorator("set")(":host", options);
|
|
8821
|
+
var updateStyleHost = (options = {}) => createStyleDecorator("update")(":host", options);
|
|
8822
|
+
var removeStyleHost = (options = {}) => createStyleDecorator("remove")(":host", options);
|
|
8823
|
+
var findAllStyleMetadata = (target) => {
|
|
8824
|
+
const result = /* @__PURE__ */ new Map();
|
|
8825
|
+
const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
|
|
8826
|
+
maps.forEach((map) => {
|
|
8827
|
+
if (map instanceof Map) {
|
|
8828
|
+
map.forEach((v, k) => result.set(k, v));
|
|
8829
|
+
}
|
|
8830
|
+
});
|
|
8831
|
+
return result;
|
|
8832
|
+
};
|
|
8680
8833
|
|
|
8681
|
-
//
|
|
8682
|
-
var
|
|
8683
|
-
(
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
let
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8834
|
+
// src/decorators/setProperty.ts
|
|
8835
|
+
var PROPERTY_SET_METADATA_KEY = Symbol.for("simple-web-component:property-set");
|
|
8836
|
+
var setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
8837
|
+
return (target, propertyKey, descriptor) => {
|
|
8838
|
+
const constructor = target.constructor;
|
|
8839
|
+
let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor);
|
|
8840
|
+
if (!metaList) {
|
|
8841
|
+
metaList = /* @__PURE__ */ new Map();
|
|
8842
|
+
ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);
|
|
8843
|
+
}
|
|
8844
|
+
let propertyName = typeof propertyNameOrOptions === "string" ? propertyNameOrOptions : void 0;
|
|
8845
|
+
let finalOptions = options;
|
|
8846
|
+
if (typeof propertyNameOrOptions === "object" && propertyNameOrOptions !== null) {
|
|
8847
|
+
finalOptions = propertyNameOrOptions;
|
|
8848
|
+
}
|
|
8849
|
+
metaList.set(propertyKey, {
|
|
8850
|
+
propertyKey,
|
|
8851
|
+
selector,
|
|
8852
|
+
options: { ...finalOptions, name: propertyName }
|
|
8853
|
+
});
|
|
8854
|
+
const original = descriptor.value;
|
|
8855
|
+
descriptor.value = async function(...args) {
|
|
8856
|
+
ensureInit(this);
|
|
8857
|
+
const res = await original.apply(this, args);
|
|
8858
|
+
if (res !== void 0) {
|
|
8859
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8860
|
+
const host2 = this;
|
|
8861
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8862
|
+
const r = finalOptions.root || "auto";
|
|
8863
|
+
const targetEls = [];
|
|
8864
|
+
const applyRoot = (t) => {
|
|
8865
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8866
|
+
targetEls.push(t);
|
|
8867
|
+
};
|
|
8868
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8869
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8870
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8871
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8872
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8873
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8874
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8875
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8876
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8877
|
+
else {
|
|
8878
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8879
|
+
if (targetRoot) {
|
|
8880
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8881
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8884
|
+
targetEls.forEach((targetEl) => {
|
|
8885
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
8886
|
+
if (propertyName) {
|
|
8887
|
+
targetEl[propertyName] = resolvedRes;
|
|
8888
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8889
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8890
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8891
|
+
targetEl[prop] = finalVal;
|
|
8892
|
+
});
|
|
8893
|
+
} else {
|
|
8894
|
+
targetEl.value = resolvedRes;
|
|
8895
|
+
}
|
|
8896
|
+
});
|
|
8696
8897
|
}
|
|
8697
8898
|
};
|
|
8698
|
-
window.requestAnimationFrame(animate);
|
|
8699
|
-
return new AutoCloseSubscription(() => stop = true);
|
|
8700
|
-
}
|
|
8701
|
-
AnimationFrameUtils2.fps = fps;
|
|
8702
|
-
AnimationFrameUtils2.dividePerFpsObservable = ({
|
|
8703
|
-
fpsConfig,
|
|
8704
|
-
divideSize
|
|
8705
|
-
}) => {
|
|
8706
|
-
return new Observable((subscriber) => {
|
|
8707
|
-
const handler = (event) => subscriber.next(event);
|
|
8708
|
-
let fps2 = 0;
|
|
8709
|
-
const getDrawFpsGap = () => {
|
|
8710
|
-
return Math.floor(fps2 / divideSize);
|
|
8711
|
-
};
|
|
8712
|
-
let gapPosition = 0;
|
|
8713
|
-
const fpsSubscription = AnimationFrameUtils2.fps(fpsConfig, (fpsConfig2) => {
|
|
8714
|
-
fps2 = fpsConfig2.fps;
|
|
8715
|
-
gapPosition++;
|
|
8716
|
-
const gapSize = getDrawFpsGap();
|
|
8717
|
-
if (gapPosition >= gapSize) {
|
|
8718
|
-
handler({ ...fpsConfig2, ...{ gapPosition, gapSize } });
|
|
8719
|
-
gapPosition = 0;
|
|
8720
|
-
}
|
|
8721
|
-
});
|
|
8722
|
-
return () => {
|
|
8723
|
-
fpsSubscription.unsubscribe();
|
|
8724
|
-
};
|
|
8725
|
-
});
|
|
8726
8899
|
};
|
|
8727
|
-
}
|
|
8900
|
+
};
|
|
8901
|
+
var setPropertyHost = (propertyNameOrOptions, options = {}) => {
|
|
8902
|
+
return setProperty(":host", propertyNameOrOptions, options);
|
|
8903
|
+
};
|
|
8728
8904
|
|
|
8729
|
-
//
|
|
8730
|
-
var
|
|
8731
|
-
(
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
const
|
|
8735
|
-
|
|
8736
|
-
|
|
8905
|
+
// src/decorators/subscribeSwcAppRouteChange.ts
|
|
8906
|
+
var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change");
|
|
8907
|
+
function createSwcAppRouteChangeSubscriber(options) {
|
|
8908
|
+
return (target, propertyKey, descriptor) => {
|
|
8909
|
+
const pathPattern = options?.path;
|
|
8910
|
+
const filter = options?.filter;
|
|
8911
|
+
const constructor = target.constructor;
|
|
8912
|
+
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
|
|
8913
|
+
if (!list) {
|
|
8914
|
+
list = [];
|
|
8915
|
+
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
|
|
8737
8916
|
}
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
ValidUtils22.hasParentWindow = (win) => ValidUtils22.isBrowser() && win.parent && win !== win.parent;
|
|
8741
|
-
ValidUtils22.isSocialNetworkServiceInappBrowser = () => {
|
|
8742
|
-
const userAgent = ValidUtils22.isBrowser() ? window.navigator.userAgent.toLowerCase() : "none";
|
|
8743
|
-
return /kakaotalk|naver|facebook|insta|FBAN|FBAV/.test(userAgent);
|
|
8917
|
+
list.push({ propertyKey, pathPattern, filter });
|
|
8918
|
+
return descriptor;
|
|
8744
8919
|
};
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8920
|
+
}
|
|
8921
|
+
function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
|
|
8922
|
+
if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
8923
|
+
return createSwcAppRouteChangeSubscriber({})(targetOrOptions, propertyKey, descriptor);
|
|
8748
8924
|
}
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8925
|
+
let options = {};
|
|
8926
|
+
if (Array.isArray(targetOrOptions)) {
|
|
8927
|
+
options.path = targetOrOptions;
|
|
8928
|
+
} else if (typeof targetOrOptions === "string") {
|
|
8929
|
+
options.path = targetOrOptions;
|
|
8930
|
+
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
8931
|
+
options = targetOrOptions;
|
|
8932
|
+
}
|
|
8933
|
+
return createSwcAppRouteChangeSubscriber(options);
|
|
8934
|
+
}
|
|
8935
|
+
var getSubscribeSwcAppRouteChangeMetadata = (target) => {
|
|
8936
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
8937
|
+
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
|
|
8938
|
+
};
|
|
8939
|
+
|
|
8940
|
+
// ../simple-boot/dist/esm/decorators/SimDecorator.js
|
|
8941
|
+
var SimMetadataKey = Symbol.for("simple-boot:sim-metadata");
|
|
8942
|
+
var PostConstructMetadataKey = Symbol.for("simple-boot:post-construct-metadata");
|
|
8943
|
+
|
|
8944
|
+
// ../simple-boot/dist/esm/decorators/aop/AOPDecorator.js
|
|
8945
|
+
var AfterMetadataKey = Symbol.for("simple-boot:after-metadata");
|
|
8946
|
+
var BeforeMetadataKey = Symbol.for("simple-boot:before-metadata");
|
|
8947
|
+
var AroundMetadataKey = Symbol.for("simple-boot:around-metadata");
|
|
8948
|
+
|
|
8949
|
+
// ../simple-boot/dist/esm/decorators/exception/ExceptionDecorator.js
|
|
8950
|
+
var ExceptionHandlerMetadataKey = Symbol.for("simple-boot:exception-handler-metadata");
|
|
8951
|
+
|
|
8952
|
+
// ../simple-boot/dist/esm/decorators/SimNoProxy.js
|
|
8953
|
+
var SimNoProxyKey = Symbol.for("simple-boot:sim-no-proxy-metadata");
|
|
8954
|
+
|
|
8955
|
+
// ../simple-boot/dist/esm/decorators/inject/Injection.js
|
|
8956
|
+
var InjectionMetadataKey = Symbol("Injection");
|
|
8957
|
+
|
|
8958
|
+
// ../simple-boot/dist/esm/decorators/route/Router.js
|
|
8959
|
+
var RouterMetadataKey = Symbol.for("simple-boot:router-metadata");
|
|
8960
|
+
var RouteMetadataKey = Symbol.for("simple-boot:route-metadata");
|
|
8961
|
+
|
|
8962
|
+
// ../simple-boot/dist/esm/route/RouterAction.js
|
|
8963
|
+
var RouterAction;
|
|
8964
|
+
((RouterAction2) => {
|
|
8965
|
+
RouterAction2.isCanActivate = (obj) => {
|
|
8966
|
+
return typeof obj?.canActivate === "function";
|
|
8752
8967
|
};
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
if (!targetWindow) {
|
|
8756
|
-
return false;
|
|
8757
|
-
}
|
|
8758
|
-
return /Mobi/i.test(targetWindow.navigator.userAgent);
|
|
8968
|
+
RouterAction2.isOnRouting = (obj) => {
|
|
8969
|
+
return typeof obj?.onRouting === "function";
|
|
8759
8970
|
};
|
|
8760
|
-
|
|
8971
|
+
RouterAction2.isHasActivate = (obj) => {
|
|
8972
|
+
return typeof obj?.hasActivate === "function";
|
|
8973
|
+
};
|
|
8974
|
+
})(RouterAction || (RouterAction = {}));
|
|
8761
8975
|
return __toCommonJS(bundle_entry_exports);
|
|
8762
8976
|
})();
|
|
8763
8977
|
/*! Bundled license information:
|