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