@dooboostore/simple-web-component 1.0.33 → 1.0.35
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 +23 -30
- package/dist/cjs/decorators/addEventListener.js.map +1 -1
- package/dist/cjs/decorators/applyAttribute.js +67 -57
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +80 -70
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +5 -8
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +66 -56
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +35 -29
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +32 -12
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +238 -180
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +67 -48
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +15 -17
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +50 -39
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +14 -8
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +154 -81
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +28 -18
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +68 -45
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +52 -30
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +109 -35
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/register.js +263 -131
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -2
- package/dist/cjs/router/ElementRouter.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +25 -7
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js.map +1 -1
- package/dist/esm/decorators/applyAttribute.js +67 -57
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +80 -70
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +5 -8
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +66 -56
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +35 -29
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +32 -12
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +240 -182
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +67 -48
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +15 -17
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +50 -39
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +14 -7
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +156 -82
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +28 -18
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +69 -46
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +53 -31
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +110 -36
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/register.js +264 -132
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +5 -2
- package/dist/esm/router/ElementRouter.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +25 -7
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +728 -595
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +4 -1
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +5 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +4 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +5 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +5 -1
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts +14 -3
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +15 -7
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +10 -7
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +5 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +2 -2
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -6
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +9 -3
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +12 -7
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +4 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +728 -595
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +5 -5
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +74 -61
- package/src/decorators/applyClass.ts +91 -77
- package/src/decorators/applyNode.ts +16 -13
- package/src/decorators/applyStyle.ts +75 -61
- package/src/decorators/attribute.ts +55 -43
- package/src/decorators/changedAttributeHost.ts +49 -15
- package/src/decorators/elementDefine.ts +401 -340
- package/src/decorators/emitCustomEvent.ts +92 -62
- package/src/decorators/lifecycles.ts +11 -10
- package/src/decorators/setProperty.ts +58 -44
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +11 -11
- package/src/elements/SwcAppEngine.ts +19 -13
- package/src/elements/SwcAppMixin.ts +214 -102
- package/src/elements/SwcAsync.ts +28 -17
- package/src/elements/SwcChoose.ts +94 -36
- package/src/elements/SwcIf.ts +59 -22
- package/src/elements/SwcLoop.ts +140 -27
- package/src/elements/register.ts +319 -100
- package/src/types.ts +1 -0
- package/src/utils/Utils.ts +38 -10
- package/tsconfig.json +2 -2
|
@@ -5727,6 +5727,11 @@ var Expression;
|
|
|
5727
5727
|
})(Expression || (Expression = {}));
|
|
5728
5728
|
|
|
5729
5729
|
// ../core/dist/esm/expression/ActionExpression.js
|
|
5730
|
+
var DEFAULT_EXPRESSION_CONFIG = {
|
|
5731
|
+
"callReturn": { start: "{{=", end: "}}" },
|
|
5732
|
+
"call": { start: "{{@", end: "}}" },
|
|
5733
|
+
"replace": { start: "{{", end: "}}" }
|
|
5734
|
+
};
|
|
5730
5735
|
var ActionExpression = class {
|
|
5731
5736
|
constructor(value, config) {
|
|
5732
5737
|
this.originalTemplate = value || "";
|
|
@@ -5740,12 +5745,19 @@ var ActionExpression = class {
|
|
|
5740
5745
|
}
|
|
5741
5746
|
this.maskingTemplate = value;
|
|
5742
5747
|
this.currentTemplate = value;
|
|
5743
|
-
|
|
5744
|
-
|
|
5748
|
+
const exprConfig = {
|
|
5749
|
+
"callReturn": config?.expression?.["callReturn"] || DEFAULT_EXPRESSION_CONFIG["callReturn"],
|
|
5750
|
+
"call": config?.expression?.call || DEFAULT_EXPRESSION_CONFIG.call,
|
|
5751
|
+
"replace": config?.expression?.replace || DEFAULT_EXPRESSION_CONFIG.replace
|
|
5752
|
+
};
|
|
5753
|
+
const types = ["callReturn", "call", "replace"];
|
|
5754
|
+
types.sort((a, b) => exprConfig[b].start.length - exprConfig[a].start.length);
|
|
5755
|
+
for (const type of types) {
|
|
5756
|
+
const marker = exprConfig[type];
|
|
5757
|
+
if (marker) {
|
|
5758
|
+
this.processExpressionType(type, marker.start, marker.end);
|
|
5759
|
+
}
|
|
5745
5760
|
}
|
|
5746
|
-
this.processCallReturnExpressions(this.currentTemplate);
|
|
5747
|
-
this.processCallExpressions(this.currentTemplate);
|
|
5748
|
-
this.processReplaceExpressions(this.currentTemplate);
|
|
5749
5761
|
this.sortExpressionsByPosition();
|
|
5750
5762
|
this.maskingTemplate = this.currentTemplate;
|
|
5751
5763
|
}
|
|
@@ -5756,45 +5768,17 @@ var ActionExpression = class {
|
|
|
5756
5768
|
});
|
|
5757
5769
|
this.expressions.sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
|
|
5758
5770
|
}
|
|
5759
|
-
|
|
5760
|
-
const
|
|
5761
|
-
const
|
|
5762
|
-
const
|
|
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;
|
|
5771
|
+
processExpressionType(type, start, end) {
|
|
5772
|
+
const escapedStart = start.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5773
|
+
const escapedEnd = end.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5774
|
+
const regex = new RegExp(`${escapedStart}\\s*([\\s\\S]+?)\\s*${escapedEnd}`, "g");
|
|
5785
5775
|
let match;
|
|
5786
|
-
|
|
5787
|
-
|
|
5776
|
+
const valueToMatch = this.currentTemplate;
|
|
5777
|
+
while ((match = regex.exec(valueToMatch)) !== null) {
|
|
5778
|
+
this.addExpression(match, type);
|
|
5788
5779
|
}
|
|
5789
5780
|
}
|
|
5790
|
-
|
|
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) {
|
|
5781
|
+
addExpression(match, type) {
|
|
5798
5782
|
const id = Math.random().toString(36).substr(2, 9);
|
|
5799
5783
|
const original = match[0];
|
|
5800
5784
|
const rawScript = match[1];
|
|
@@ -5809,13 +5793,9 @@ var ActionExpression = class {
|
|
|
5809
5793
|
original,
|
|
5810
5794
|
script: rawScript.trim(),
|
|
5811
5795
|
expressionStart,
|
|
5812
|
-
expressionEnd
|
|
5813
|
-
...wrap && { wrap }
|
|
5796
|
+
expressionEnd
|
|
5814
5797
|
});
|
|
5815
5798
|
}
|
|
5816
|
-
/**
|
|
5817
|
-
* 구현 메서드
|
|
5818
|
-
*/
|
|
5819
5799
|
replace(idOrExpr, valueOrCallback) {
|
|
5820
5800
|
const id = typeof idOrExpr === "string" ? idOrExpr : idOrExpr.id;
|
|
5821
5801
|
let expr;
|
|
@@ -5831,9 +5811,6 @@ var ActionExpression = class {
|
|
|
5831
5811
|
}
|
|
5832
5812
|
return this.getUnprocessedTemplate();
|
|
5833
5813
|
}
|
|
5834
|
-
/**
|
|
5835
|
-
* 구현 메서드
|
|
5836
|
-
*/
|
|
5837
5814
|
getExpressions(typeOrOptions) {
|
|
5838
5815
|
if (!typeOrOptions) {
|
|
5839
5816
|
return this.expressions;
|
|
@@ -5844,13 +5821,9 @@ var ActionExpression = class {
|
|
|
5844
5821
|
const options = typeOrOptions;
|
|
5845
5822
|
return this.expressions.filter((expr) => {
|
|
5846
5823
|
if (options.type && expr.type !== options.type) return false;
|
|
5847
|
-
if ("wrap" in options && expr.wrap !== options.wrap) return false;
|
|
5848
5824
|
return true;
|
|
5849
5825
|
});
|
|
5850
5826
|
}
|
|
5851
|
-
/**
|
|
5852
|
-
* 구현 메서드
|
|
5853
|
-
*/
|
|
5854
5827
|
getFirstExpression(typeOrOptions) {
|
|
5855
5828
|
if (!typeOrOptions) {
|
|
5856
5829
|
return this.getExpressions()[0];
|
|
@@ -5860,28 +5833,15 @@ var ActionExpression = class {
|
|
|
5860
5833
|
}
|
|
5861
5834
|
return this.getExpressions(typeOrOptions)[0];
|
|
5862
5835
|
}
|
|
5863
|
-
/**
|
|
5864
|
-
* 원본 템플릿을 반환합니다.
|
|
5865
|
-
*/
|
|
5866
5836
|
getOriginalTemplate() {
|
|
5867
5837
|
return this.originalTemplate;
|
|
5868
5838
|
}
|
|
5869
|
-
/**
|
|
5870
|
-
* 마스킹 처리된 템플릿을 반환합니다.
|
|
5871
|
-
*/
|
|
5872
5839
|
getMaskingTemplate() {
|
|
5873
5840
|
return this.maskingTemplate;
|
|
5874
5841
|
}
|
|
5875
|
-
/**
|
|
5876
|
-
* 현재 처리 상태의 템플릿을 반환합니다.
|
|
5877
|
-
*/
|
|
5878
5842
|
getCurrentTemplate() {
|
|
5879
5843
|
return this.currentTemplate;
|
|
5880
5844
|
}
|
|
5881
|
-
/**
|
|
5882
|
-
* 미처리된 마커들을 원본으로 복원한 템플릿을 반환합니다.
|
|
5883
|
-
* replace() 호출 후 처리되지 않은 표현식들을 원본 형태로 되돌립니다.
|
|
5884
|
-
*/
|
|
5885
5845
|
getUnprocessedTemplate() {
|
|
5886
5846
|
let result = this.currentTemplate;
|
|
5887
5847
|
for (const expr of this.expressions) {
|
|
@@ -5944,17 +5904,16 @@ function createLifecycleDecorator(metadataKey) {
|
|
|
5944
5904
|
};
|
|
5945
5905
|
}
|
|
5946
5906
|
var onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);
|
|
5947
|
-
var
|
|
5948
|
-
var
|
|
5949
|
-
var onConnected =
|
|
5950
|
-
var
|
|
5951
|
-
var
|
|
5952
|
-
var onDisconnected =
|
|
5953
|
-
var
|
|
5954
|
-
var
|
|
5955
|
-
var onAdopted =
|
|
5907
|
+
var onConnectedBefore = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
5908
|
+
var onConnectedAfter = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
5909
|
+
var onConnected = onConnectedAfter;
|
|
5910
|
+
var onDisconnectedBefore = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
5911
|
+
var onDisconnectedAfter = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
5912
|
+
var onDisconnected = onDisconnectedAfter;
|
|
5913
|
+
var onAdoptedBefore = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);
|
|
5914
|
+
var onAdoptedAfter = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
|
|
5915
|
+
var onAdopted = onAdoptedAfter;
|
|
5956
5916
|
var onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
|
|
5957
|
-
var onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
5958
5917
|
function onConnectedInnerHtml(arg1, arg2, arg3) {
|
|
5959
5918
|
const decorator = (options, target, propertyKey) => {
|
|
5960
5919
|
const constructor = target.constructor;
|
|
@@ -6110,13 +6069,25 @@ var htmlArticleElement = (options) => {
|
|
|
6110
6069
|
};
|
|
6111
6070
|
var SwcUtils;
|
|
6112
6071
|
((SwcUtils2) => {
|
|
6072
|
+
SwcUtils2.getParentContainer = (e) => {
|
|
6073
|
+
return e.parentElement ?? e.getRootNode();
|
|
6074
|
+
};
|
|
6113
6075
|
SwcUtils2.parsePathPatternsSetAttributeString = (pathPattern, path) => {
|
|
6114
6076
|
return JSON.stringify(SwcUtils2.parsePathPatternsSet(pathPattern, path)).replace(/"/g, "'");
|
|
6115
6077
|
};
|
|
6116
|
-
SwcUtils2.parsePathPatternsSet = (pathPattern,
|
|
6078
|
+
SwcUtils2.parsePathPatternsSet = (pathPattern, urlAndRouter) => {
|
|
6079
|
+
urlAndRouter ?? (urlAndRouter = "/");
|
|
6080
|
+
const p = typeof urlAndRouter === "string" ? urlAndRouter : urlAndRouter.value.url;
|
|
6081
|
+
const searchParams = new URLSearchParams();
|
|
6082
|
+
const qs = p.split("?")[1];
|
|
6083
|
+
qs?.split("&").forEach((it) => {
|
|
6084
|
+
const [k, v] = it.split("=");
|
|
6085
|
+
searchParams.set(k, v);
|
|
6086
|
+
});
|
|
6117
6087
|
return {
|
|
6118
|
-
path,
|
|
6119
|
-
|
|
6088
|
+
path: p,
|
|
6089
|
+
searchParams,
|
|
6090
|
+
pathData: SwcUtils2.parsePathPatterns(pathPattern, p)
|
|
6120
6091
|
};
|
|
6121
6092
|
};
|
|
6122
6093
|
SwcUtils2.parsePathPatterns = (pathPattern, path) => {
|
|
@@ -6157,7 +6128,8 @@ var SwcUtils;
|
|
|
6157
6128
|
return current;
|
|
6158
6129
|
};
|
|
6159
6130
|
SwcUtils2.findNearestSwcHost = (el) => {
|
|
6160
|
-
|
|
6131
|
+
const el1 = el;
|
|
6132
|
+
if (el1.__swc_host) return el1.__swc_host;
|
|
6161
6133
|
let current = el.parentElement || el.getRootNode?.()?.host;
|
|
6162
6134
|
const doc = el.ownerDocument;
|
|
6163
6135
|
const win = doc?.defaultView || (typeof window !== "undefined" ? window : void 0);
|
|
@@ -6187,8 +6159,8 @@ var SwcUtils;
|
|
|
6187
6159
|
return (0, SwcUtils2.findNearestSwcHost)(el);
|
|
6188
6160
|
};
|
|
6189
6161
|
SwcUtils2.getAppHosts = (el) => {
|
|
6190
|
-
const hosts =
|
|
6191
|
-
return hosts
|
|
6162
|
+
const hosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
6163
|
+
return hosts;
|
|
6192
6164
|
};
|
|
6193
6165
|
SwcUtils2.getAppHost = (el) => {
|
|
6194
6166
|
const appHosts = (0, SwcUtils2.getAppHosts)(el);
|
|
@@ -6201,6 +6173,10 @@ var SwcUtils;
|
|
|
6201
6173
|
};
|
|
6202
6174
|
SwcUtils2.findAllParentAppHostsDirect = (el) => {
|
|
6203
6175
|
const appHosts = [];
|
|
6176
|
+
const w = el.ownerDocument?.defaultView || (typeof window !== "undefined" ? window : void 0);
|
|
6177
|
+
if (!w) {
|
|
6178
|
+
return appHosts;
|
|
6179
|
+
}
|
|
6204
6180
|
let current = el;
|
|
6205
6181
|
while (current) {
|
|
6206
6182
|
const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
|
|
@@ -6211,7 +6187,7 @@ var SwcUtils;
|
|
|
6211
6187
|
current = current.parentElement;
|
|
6212
6188
|
} else {
|
|
6213
6189
|
const root = current.getRootNode();
|
|
6214
|
-
if (root instanceof ShadowRoot) {
|
|
6190
|
+
if (w.ShadowRoot && root instanceof w.ShadowRoot) {
|
|
6215
6191
|
current = root.host;
|
|
6216
6192
|
} else {
|
|
6217
6193
|
break;
|
|
@@ -6244,6 +6220,7 @@ var SwcUtils;
|
|
|
6244
6220
|
$hosts,
|
|
6245
6221
|
$firstHost,
|
|
6246
6222
|
$lastHost: $parentHost,
|
|
6223
|
+
$templateHost: el.__swc_template_host,
|
|
6247
6224
|
$appHost,
|
|
6248
6225
|
$appHosts,
|
|
6249
6226
|
$firstAppHost,
|
|
@@ -6286,54 +6263,67 @@ function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
|
6286
6263
|
}
|
|
6287
6264
|
list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
|
|
6288
6265
|
const original = descriptor.value;
|
|
6289
|
-
descriptor.value =
|
|
6266
|
+
descriptor.value = function(...args) {
|
|
6290
6267
|
ensureInit(this);
|
|
6291
|
-
const
|
|
6292
|
-
const
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
if (
|
|
6306
|
-
|
|
6307
|
-
if (
|
|
6308
|
-
|
|
6309
|
-
if (
|
|
6310
|
-
|
|
6311
|
-
if (
|
|
6312
|
-
|
|
6313
|
-
if (
|
|
6314
|
-
|
|
6315
|
-
if (
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
searchRoots.push(this);
|
|
6329
|
-
if (
|
|
6268
|
+
const res = original.apply(this, args);
|
|
6269
|
+
const handleResult = (detail) => {
|
|
6270
|
+
const event = new CustomEvent(type, {
|
|
6271
|
+
detail,
|
|
6272
|
+
bubbles: fullOptions.bubbles,
|
|
6273
|
+
composed: fullOptions.composed,
|
|
6274
|
+
cancelable: fullOptions.cancelable
|
|
6275
|
+
});
|
|
6276
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
6277
|
+
const conf = getElementConfig(this);
|
|
6278
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6279
|
+
const eventTargets = [];
|
|
6280
|
+
if (selectorOrTarget === ":window") eventTargets.push(currentWin);
|
|
6281
|
+
else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
|
|
6282
|
+
else if (selectorOrTarget === ":parentHost") {
|
|
6283
|
+
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
6284
|
+
} else if (selectorOrTarget === ":appHost") {
|
|
6285
|
+
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
6286
|
+
} else if (selectorOrTarget === ":firstHost") {
|
|
6287
|
+
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
6288
|
+
} else if (selectorOrTarget === ":lastHost") {
|
|
6289
|
+
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
6290
|
+
} else if (selectorOrTarget === ":firstAppHost") {
|
|
6291
|
+
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
6292
|
+
} else if (selectorOrTarget === ":lastAppHost") {
|
|
6293
|
+
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
6294
|
+
} else if (selectorOrTarget === ":hosts") {
|
|
6295
|
+
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
6296
|
+
} else if (selectorOrTarget === ":appHosts") {
|
|
6297
|
+
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
6298
|
+
} else if (selectorOrTarget === ":host" || !selectorOrTarget) {
|
|
6299
|
+
eventTargets.push(this);
|
|
6300
|
+
} else {
|
|
6301
|
+
const r = fullOptions.root || "auto";
|
|
6302
|
+
const searchRoots = [];
|
|
6303
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
6304
|
+
else if (r === "light") searchRoots.push(this);
|
|
6305
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6306
|
+
else if (r === "all") {
|
|
6307
|
+
searchRoots.push(this);
|
|
6308
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6309
|
+
}
|
|
6310
|
+
searchRoots.forEach((sr) => {
|
|
6311
|
+
sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
|
|
6312
|
+
});
|
|
6330
6313
|
}
|
|
6331
|
-
|
|
6332
|
-
|
|
6314
|
+
eventTargets.forEach((t) => {
|
|
6315
|
+
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
6316
|
+
return;
|
|
6317
|
+
}
|
|
6318
|
+
t.dispatchEvent(event);
|
|
6333
6319
|
});
|
|
6320
|
+
return detail;
|
|
6321
|
+
};
|
|
6322
|
+
if (res instanceof Promise) {
|
|
6323
|
+
return res.then(handleResult);
|
|
6324
|
+
} else {
|
|
6325
|
+
return handleResult(res);
|
|
6334
6326
|
}
|
|
6335
|
-
eventTargets.forEach((t) => t.dispatchEvent(event));
|
|
6336
|
-
return detail;
|
|
6337
6327
|
};
|
|
6338
6328
|
};
|
|
6339
6329
|
}
|
|
@@ -6341,30 +6331,41 @@ var getEmitCustomEventMetadataList = (target) => {
|
|
|
6341
6331
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
6342
6332
|
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
6343
6333
|
};
|
|
6344
|
-
function emitCustomEventHost(type,
|
|
6345
|
-
if (
|
|
6346
|
-
|
|
6334
|
+
function emitCustomEventHost(type, optionsOrAttributeaName) {
|
|
6335
|
+
if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
|
|
6336
|
+
return emitCustomEventHost(type, { attributeName: optionsOrAttributeaName });
|
|
6337
|
+
} else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "object") {
|
|
6338
|
+
if (!optionsOrAttributeaName.attributeName) {
|
|
6339
|
+
optionsOrAttributeaName.attributeName = `on-emit-${type}`;
|
|
6340
|
+
}
|
|
6341
|
+
return emitCustomEvent(":host", type, optionsOrAttributeaName);
|
|
6342
|
+
} else {
|
|
6343
|
+
return emitCustomEvent(":host", type, { attributeName: `on-emit-${type}` });
|
|
6347
6344
|
}
|
|
6348
|
-
return emitCustomEvent(":host", type, options);
|
|
6349
6345
|
}
|
|
6350
6346
|
|
|
6351
6347
|
// src/decorators/changedAttributeHost.ts
|
|
6352
6348
|
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
6353
|
-
|
|
6349
|
+
var convertValue = (val, type) => {
|
|
6350
|
+
if (val === null || val === void 0) return val;
|
|
6351
|
+
if (type === Number) return Number(val);
|
|
6352
|
+
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
6353
|
+
return val;
|
|
6354
|
+
};
|
|
6355
|
+
function changedAttributeHost(attributeName, options = {}) {
|
|
6354
6356
|
return (target, propertyKey) => {
|
|
6355
6357
|
const constructor = target.constructor;
|
|
6356
|
-
let
|
|
6357
|
-
if (!
|
|
6358
|
-
|
|
6359
|
-
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY,
|
|
6358
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6359
|
+
if (!metaList) {
|
|
6360
|
+
metaList = [];
|
|
6361
|
+
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
6360
6362
|
}
|
|
6361
6363
|
const name = attributeName || String(propertyKey);
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
}
|
|
6367
|
-
if (!methods.includes(propertyKey)) methods.push(propertyKey);
|
|
6364
|
+
metaList.push({
|
|
6365
|
+
attributeName: name,
|
|
6366
|
+
propertyKey,
|
|
6367
|
+
options
|
|
6368
|
+
});
|
|
6368
6369
|
};
|
|
6369
6370
|
}
|
|
6370
6371
|
var getChangedAttributeMetadata = (target) => {
|
|
@@ -6372,7 +6373,21 @@ var getChangedAttributeMetadata = (target) => {
|
|
|
6372
6373
|
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6373
6374
|
};
|
|
6374
6375
|
var findAllAttributeChangedMetadata = (target) => {
|
|
6375
|
-
|
|
6376
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
6377
|
+
const metaList = ReflectUtils.findAllMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
|
|
6378
|
+
const result = /* @__PURE__ */ new Map();
|
|
6379
|
+
metaList.forEach((meta) => {
|
|
6380
|
+
meta.forEach((item) => {
|
|
6381
|
+
if (!result.has(item.attributeName)) {
|
|
6382
|
+
result.set(item.attributeName, []);
|
|
6383
|
+
}
|
|
6384
|
+
result.get(item.attributeName).push(item);
|
|
6385
|
+
});
|
|
6386
|
+
});
|
|
6387
|
+
return result;
|
|
6388
|
+
};
|
|
6389
|
+
var convertAttributeValue = (val, type) => {
|
|
6390
|
+
return convertValue(val, type);
|
|
6376
6391
|
};
|
|
6377
6392
|
|
|
6378
6393
|
// src/decorators/applyAttribute.ts
|
|
@@ -6398,70 +6413,80 @@ function createAttributeDecorator(action) {
|
|
|
6398
6413
|
options: { ...finalOptions, name: attributeName }
|
|
6399
6414
|
});
|
|
6400
6415
|
const original = descriptor.value;
|
|
6401
|
-
descriptor.value =
|
|
6416
|
+
descriptor.value = function(...args) {
|
|
6402
6417
|
ensureInit(this);
|
|
6403
|
-
const res =
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6418
|
+
const res = original.apply(this, args);
|
|
6419
|
+
const handleResult = (resolvedValue) => {
|
|
6420
|
+
if (resolvedValue !== void 0) {
|
|
6421
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
6422
|
+
const host2 = this;
|
|
6423
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6424
|
+
const r = finalOptions.root || "auto";
|
|
6425
|
+
const targetEls = [];
|
|
6426
|
+
const applyRoot = (t) => {
|
|
6427
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6428
|
+
targetEls.push(t);
|
|
6429
|
+
};
|
|
6430
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6431
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6432
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6433
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6434
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6435
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6436
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6437
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6438
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6439
|
+
else {
|
|
6440
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6441
|
+
if (targetRoot) {
|
|
6442
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6443
|
+
if (found) targetEls.push(...Array.from(found));
|
|
6444
|
+
}
|
|
6428
6445
|
}
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6446
|
+
targetEls.forEach((targetEl) => {
|
|
6447
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6450
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
6451
|
+
if (action === "set" || action === "update") {
|
|
6452
|
+
if (attributeName) {
|
|
6453
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
6454
|
+
targetEl.removeAttribute(attributeName);
|
|
6455
|
+
} else {
|
|
6456
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
6457
|
+
}
|
|
6458
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6459
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6460
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6461
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6462
|
+
targetEl.removeAttribute(attr);
|
|
6463
|
+
} else {
|
|
6464
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6465
|
+
}
|
|
6466
|
+
});
|
|
6467
|
+
}
|
|
6468
|
+
} else if (action === "remove") {
|
|
6469
|
+
if (attributeName) {
|
|
6435
6470
|
targetEl.removeAttribute(attributeName);
|
|
6471
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6472
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6473
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
6474
|
+
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
6475
|
+
});
|
|
6436
6476
|
} else {
|
|
6437
|
-
|
|
6477
|
+
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6478
|
+
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
6438
6479
|
}
|
|
6439
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6440
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6441
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6442
|
-
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6443
|
-
targetEl.removeAttribute(attr);
|
|
6444
|
-
} else {
|
|
6445
|
-
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6446
|
-
}
|
|
6447
|
-
});
|
|
6448
6480
|
}
|
|
6449
|
-
}
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
} else {
|
|
6458
|
-
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6459
|
-
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
6460
|
-
}
|
|
6461
|
-
}
|
|
6462
|
-
});
|
|
6481
|
+
});
|
|
6482
|
+
}
|
|
6483
|
+
return resolvedValue;
|
|
6484
|
+
};
|
|
6485
|
+
if (res instanceof Promise) {
|
|
6486
|
+
return res.then(handleResult);
|
|
6487
|
+
} else {
|
|
6488
|
+
return handleResult(res);
|
|
6463
6489
|
}
|
|
6464
|
-
return res;
|
|
6465
6490
|
};
|
|
6466
6491
|
return descriptor;
|
|
6467
6492
|
};
|
|
@@ -7759,7 +7784,7 @@ var handleGlobalSwcEvent = async (event) => {
|
|
|
7759
7784
|
}
|
|
7760
7785
|
};
|
|
7761
7786
|
function buildEnv(configWindow) {
|
|
7762
|
-
const win = configWindow
|
|
7787
|
+
const win = configWindow;
|
|
7763
7788
|
const doc = win?.document;
|
|
7764
7789
|
const builtInTagMap = /* @__PURE__ */ new Map();
|
|
7765
7790
|
for (const [cls, tag] of HTML_TAG_ENTRIES) {
|
|
@@ -7798,7 +7823,7 @@ var setupPrototype = (proto) => {
|
|
|
7798
7823
|
const aConf = getElementConfig(ancestors[i]);
|
|
7799
7824
|
if (aConf?.window) return aConf.window;
|
|
7800
7825
|
}
|
|
7801
|
-
return typeof window !== "undefined" ? window : void 0;
|
|
7826
|
+
return getElementConfig(this).window ?? (typeof window !== "undefined" ? window : void 0);
|
|
7802
7827
|
};
|
|
7803
7828
|
proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
|
|
7804
7829
|
ensureInit(this);
|
|
@@ -7807,7 +7832,13 @@ var setupPrototype = (proto) => {
|
|
|
7807
7832
|
const app = useHostSet?.$appHost?.simpleApplication;
|
|
7808
7833
|
if (app) {
|
|
7809
7834
|
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({
|
|
7835
|
+
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({
|
|
7836
|
+
situationType: "SIMPLE_WEB_COMPONENT://HOST" /* HOST */,
|
|
7837
|
+
data: useHostSet.$host
|
|
7838
|
+
}), 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({
|
|
7839
|
+
situationType: "SIMPLE_WEB_COMPONENT://FIRSTAPPHOST" /* FIRST_APP_HOST */,
|
|
7840
|
+
data: useHostSet.$firstAppHost
|
|
7841
|
+
}), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://LASTAPPHOST" /* LAST_APP_HOST */, data: useHostSet.$lastAppHost })]);
|
|
7811
7842
|
otherStorage.set(SituationTypeContainers, situations);
|
|
7812
7843
|
return app.simstanceManager.executeBindParameterSim(
|
|
7813
7844
|
{
|
|
@@ -7900,195 +7931,243 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7900
7931
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
7901
7932
|
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
7902
7933
|
const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
|
|
7903
|
-
const
|
|
7904
|
-
|
|
7905
|
-
...attrChangeMap.keys(),
|
|
7906
|
-
...attributeApplyNames,
|
|
7907
|
-
...hostAttributes,
|
|
7908
|
-
...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
|
|
7909
|
-
...swcLifecycleAttributes,
|
|
7910
|
-
...swcOnEvents
|
|
7911
|
-
])];
|
|
7934
|
+
const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
|
|
7935
|
+
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
7912
7936
|
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
7913
7937
|
const proto = constructor.prototype;
|
|
7914
7938
|
setupPrototype(proto);
|
|
7939
|
+
let helperHostSet = null;
|
|
7915
7940
|
const originalConnected = proto.connectedCallback;
|
|
7916
|
-
proto.connectedCallback = function() {
|
|
7941
|
+
proto.connectedCallback = async function() {
|
|
7917
7942
|
ensureInit(this);
|
|
7918
|
-
|
|
7919
|
-
const appHost2 =
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
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);
|
|
7943
|
+
helperHostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
7944
|
+
const appHost2 = helperHostSet.$appHost;
|
|
7945
|
+
try {
|
|
7946
|
+
if (appHost2 && typeof appHost2._connected === "function") {
|
|
7947
|
+
await appHost2._connected(this);
|
|
7948
|
+
} else if (appHost2 && typeof appHost2) {
|
|
7949
|
+
appHost2._connected_safari ?? (appHost2._connected_safari = []);
|
|
7950
|
+
appHost2._connected_safari.push(this);
|
|
7956
7951
|
}
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
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
|
-
}
|
|
7952
|
+
const conf = getElementConfig(this);
|
|
7953
|
+
const currentWin = this._resolveWindow(conf);
|
|
7954
|
+
const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
|
|
7955
|
+
if (shadowMode && !this.shadowRoot) {
|
|
7956
|
+
const mode = shadowMode === true ? "open" : shadowMode;
|
|
7957
|
+
this.attachShadow({ mode });
|
|
7958
|
+
}
|
|
7959
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
7960
|
+
if (bMethods) {
|
|
7961
|
+
for (const m of bMethods) await this._invokeLifecycleMethod(m, helperHostSet);
|
|
7962
|
+
}
|
|
7963
|
+
this._executeSwcScript("swc-on-before-connected", helperHostSet);
|
|
7964
|
+
if (connectedInnerHtmlList.length > 0) {
|
|
7965
|
+
let sContent = "", lContent = "";
|
|
7966
|
+
for (const meta of connectedInnerHtmlList) {
|
|
7967
|
+
let res = await this._invokeLifecycleMethod(meta.propertyKey, helperHostSet);
|
|
7968
|
+
const actionExpression = new ActionExpression(res, {
|
|
7969
|
+
expression: {
|
|
7970
|
+
replace: {
|
|
7971
|
+
start: meta.options.replaceWrap?.start || "{%{",
|
|
7972
|
+
end: meta.options.replaceWrap?.end || "}%}"
|
|
7973
|
+
},
|
|
7974
|
+
callReturn: {
|
|
7975
|
+
start: meta.options.replaceWrap?.start || "{%{=",
|
|
7976
|
+
end: meta.options.replaceWrap?.end || "}%}"
|
|
7977
|
+
},
|
|
7978
|
+
call: {
|
|
7979
|
+
start: meta.options.replaceWrap?.start || "{%{@",
|
|
7980
|
+
end: meta.options.replaceWrap?.end || "}%}"
|
|
7995
7981
|
}
|
|
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
7982
|
}
|
|
7983
|
+
});
|
|
7984
|
+
actionExpression.getExpressions().filter((it) => it.type === "replace").forEach((it) => {
|
|
7985
|
+
try {
|
|
7986
|
+
const sr = FunctionUtils.executeReturn({ script: it.script, context: this, args: helperHostSet });
|
|
7987
|
+
actionExpression.replace(it, sr);
|
|
7988
|
+
} catch (e) {
|
|
7989
|
+
console.error(`[SWC] Failed to execute connectedInnerHTML:`, e);
|
|
7990
|
+
}
|
|
7991
|
+
});
|
|
7992
|
+
res = actionExpression.getUnprocessedTemplate();
|
|
7993
|
+
if (res !== void 0) {
|
|
7994
|
+
if (meta.options.useShadow || conf?.useShadow) sContent += res;
|
|
7995
|
+
else lContent += res;
|
|
8004
7996
|
}
|
|
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
7997
|
}
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
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);
|
|
7998
|
+
try {
|
|
7999
|
+
if (this.shadowRoot) {
|
|
8000
|
+
this.shadowRoot.innerHTML = sContent;
|
|
8001
|
+
}
|
|
8002
|
+
if (lContent) {
|
|
8003
|
+
this.innerHTML = lContent;
|
|
8004
|
+
}
|
|
8005
|
+
} catch (e) {
|
|
8006
|
+
console.error("[ElementDefine] innerHTML setting error:", e);
|
|
8043
8007
|
}
|
|
8044
|
-
|
|
8045
|
-
|
|
8008
|
+
}
|
|
8009
|
+
const root = this.getRootNode();
|
|
8010
|
+
if (!globalDelegatedRoots.has(root)) {
|
|
8011
|
+
DOM_EVENT_NAMES.forEach((type) => {
|
|
8012
|
+
root.addEventListener(type, handleGlobalSwcEvent);
|
|
8046
8013
|
});
|
|
8014
|
+
globalDelegatedRoots.add(root);
|
|
8047
8015
|
}
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8016
|
+
const delegateListeners = [];
|
|
8017
|
+
const nonDelegateListeners = [];
|
|
8018
|
+
addEventListenerList.forEach((meta) => {
|
|
8019
|
+
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 !== "") {
|
|
8020
|
+
delegateListeners.push(meta);
|
|
8021
|
+
} else {
|
|
8022
|
+
nonDelegateListeners.push(meta);
|
|
8023
|
+
}
|
|
8024
|
+
});
|
|
8025
|
+
const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
|
|
8026
|
+
delegateListeners.forEach((meta) => {
|
|
8027
|
+
const r = meta.options.root || "auto";
|
|
8028
|
+
const rootKey = `${meta.type}:${r}`;
|
|
8029
|
+
if (!delegatesByTypeAndRoot.has(rootKey)) {
|
|
8030
|
+
delegatesByTypeAndRoot.set(rootKey, []);
|
|
8031
|
+
}
|
|
8032
|
+
delegatesByTypeAndRoot.get(rootKey).push(meta);
|
|
8033
|
+
});
|
|
8034
|
+
delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
|
|
8035
|
+
const [type, rStr] = typeRootKey.split(":");
|
|
8036
|
+
const r = rStr === "auto" ? "auto" : rStr;
|
|
8037
|
+
const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
|
|
8038
|
+
const bindRoots = [];
|
|
8039
|
+
if (r === "auto") bindRoots.push(this.shadowRoot || this);
|
|
8040
|
+
else if (r === "light") bindRoots.push(this);
|
|
8041
|
+
else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
8042
|
+
else if (r === "all") {
|
|
8043
|
+
bindRoots.push(this);
|
|
8044
|
+
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
8045
|
+
}
|
|
8046
|
+
bindRoots.forEach((br) => {
|
|
8047
|
+
const sortedMetaList = [...metaList].sort((a, b) => {
|
|
8048
|
+
const aStop = a.options.stopPropagation ? 1 : 0;
|
|
8049
|
+
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
8050
|
+
return bStop - aStop;
|
|
8051
|
+
});
|
|
8052
|
+
const unifiedHandler = async (event) => {
|
|
8053
|
+
for (const meta of sortedMetaList) {
|
|
8054
|
+
const { selector, options } = meta;
|
|
8055
|
+
const matchedEl = event.target.closest(selector);
|
|
8056
|
+
if (matchedEl && br.contains(matchedEl)) {
|
|
8057
|
+
if (options.filter) {
|
|
8058
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
8059
|
+
if (!options.filter(event, helper)) {
|
|
8060
|
+
continue;
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
8064
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
8065
|
+
if (options.preventDefault) event.preventDefault();
|
|
8066
|
+
const currentHostSet = SwcUtils.getHostSet(this);
|
|
8067
|
+
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
8068
|
+
await this[meta.propertyKey](event, { ...currentHostSet, $matchedElement: matchedEl }, args);
|
|
8069
|
+
if (event.cancelBubble) break;
|
|
8070
|
+
}
|
|
8054
8071
|
}
|
|
8072
|
+
};
|
|
8073
|
+
br.addEventListener(type, unifiedHandler, opts);
|
|
8074
|
+
this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
|
|
8075
|
+
});
|
|
8076
|
+
});
|
|
8077
|
+
nonDelegateListeners.forEach((meta) => {
|
|
8078
|
+
const { selector, type, options } = meta;
|
|
8079
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
8080
|
+
const bindTargets = [];
|
|
8081
|
+
const r = options.root || "auto";
|
|
8082
|
+
const applyRootOption = (target) => {
|
|
8083
|
+
if (!target) return;
|
|
8084
|
+
if (r === "auto") {
|
|
8085
|
+
bindTargets.push(target.shadowRoot || target);
|
|
8086
|
+
} else {
|
|
8087
|
+
if (r === "light" || r === "all") bindTargets.push(target);
|
|
8088
|
+
if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
8055
8089
|
}
|
|
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
8090
|
};
|
|
8063
|
-
|
|
8064
|
-
if (
|
|
8065
|
-
|
|
8091
|
+
if (selector === ":window") bindTargets.push(currentWin);
|
|
8092
|
+
else if (selector === ":document") bindTargets.push(currentWin.document);
|
|
8093
|
+
else if (selector === ":parentHost") applyRootOption(helperHostSet.$parentHost);
|
|
8094
|
+
else if (selector === ":appHost") applyRootOption(helperHostSet.$appHost);
|
|
8095
|
+
else if (selector === ":firstHost") applyRootOption(helperHostSet.$firstHost);
|
|
8096
|
+
else if (selector === ":lastHost") applyRootOption(helperHostSet.$lastHost);
|
|
8097
|
+
else if (selector === ":firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
|
|
8098
|
+
else if (selector === ":lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
|
|
8099
|
+
else if (selector === ":hosts") helperHostSet.$hosts.forEach(applyRootOption);
|
|
8100
|
+
else if (selector === ":appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
|
|
8101
|
+
else if (selector === ":host" || !selector) applyRootOption(this);
|
|
8102
|
+
else {
|
|
8103
|
+
const searchRoots = [];
|
|
8104
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
8105
|
+
else if (r === "light") searchRoots.push(this);
|
|
8106
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
8107
|
+
else if (r === "all") {
|
|
8108
|
+
searchRoots.push(this);
|
|
8109
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
8110
|
+
}
|
|
8111
|
+
searchRoots.forEach((sr) => {
|
|
8112
|
+
sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
|
|
8113
|
+
});
|
|
8066
8114
|
}
|
|
8115
|
+
bindTargets.forEach((t) => {
|
|
8116
|
+
const handler = async (event) => {
|
|
8117
|
+
if (options.filter) {
|
|
8118
|
+
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
8119
|
+
if (!options.filter(event, { currentThis: this, helper })) {
|
|
8120
|
+
return;
|
|
8121
|
+
}
|
|
8122
|
+
}
|
|
8123
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
8124
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
8125
|
+
if (options.preventDefault) event.preventDefault();
|
|
8126
|
+
const currentHostSet = SwcUtils.getHostSet(this);
|
|
8127
|
+
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
8128
|
+
await this[meta.propertyKey](event, { currentHostSet, $$matchedElement: event.currentTarget }, args);
|
|
8129
|
+
};
|
|
8130
|
+
t.addEventListener(type, handler, opts);
|
|
8131
|
+
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
8132
|
+
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
8133
|
+
}
|
|
8134
|
+
});
|
|
8067
8135
|
});
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8136
|
+
if (originalConnected) await originalConnected.apply(this);
|
|
8137
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
8138
|
+
if (aMethods) {
|
|
8139
|
+
for (const m of aMethods) await this._invokeLifecycleMethod(m, helperHostSet);
|
|
8140
|
+
}
|
|
8141
|
+
this._executeSwcScript("swc-on-connected", helperHostSet);
|
|
8142
|
+
this._executeSwcScript("swc-on-after-connected", helperHostSet);
|
|
8143
|
+
this.__swc_connected = true;
|
|
8144
|
+
for (let [name2, metaList] of Array.from(attrChangeMap)) {
|
|
8145
|
+
for (const meta of metaList) {
|
|
8146
|
+
if (meta.options.while === "connected") {
|
|
8147
|
+
const val = getAttributeValue(this, name2, { type: meta.options.type });
|
|
8148
|
+
if (val !== null) {
|
|
8149
|
+
await this[meta.propertyKey](val, null, name2, helperHostSet);
|
|
8150
|
+
}
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
} finally {
|
|
8155
|
+
if (appHost2 && typeof appHost2._connectedDone === "function") {
|
|
8156
|
+
await appHost2._connectedDone(this);
|
|
8157
|
+
}
|
|
8083
8158
|
}
|
|
8084
8159
|
};
|
|
8085
8160
|
const originalDisconnected = proto.disconnectedCallback;
|
|
8086
8161
|
proto.disconnectedCallback = function() {
|
|
8087
|
-
|
|
8088
|
-
|
|
8162
|
+
console.log("disconnnnnnnnnnnnnnnnnnn", helperHostSet, this);
|
|
8163
|
+
const appHost2 = helperHostSet.$appHost;
|
|
8164
|
+
if (appHost2 && typeof appHost2._disconnected === "function") {
|
|
8165
|
+
appHost2._disconnected(this);
|
|
8166
|
+
}
|
|
8167
|
+
this._executeSwcScript("swc-on-before-disconnected", helperHostSet);
|
|
8089
8168
|
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
8090
8169
|
if (bMethods) {
|
|
8091
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m,
|
|
8170
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m, helperHostSet);
|
|
8092
8171
|
}
|
|
8093
8172
|
if (this._boundListeners) {
|
|
8094
8173
|
this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
@@ -8097,15 +8176,11 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8097
8176
|
if (originalDisconnected) originalDisconnected.apply(this);
|
|
8098
8177
|
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
8099
8178
|
if (aMethods) {
|
|
8100
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m,
|
|
8179
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m, helperHostSet);
|
|
8101
8180
|
}
|
|
8102
|
-
this._executeSwcScript("swc-on-disconnected",
|
|
8103
|
-
this._executeSwcScript("swc-on-after-disconnected",
|
|
8181
|
+
this._executeSwcScript("swc-on-disconnected", helperHostSet);
|
|
8182
|
+
this._executeSwcScript("swc-on-after-disconnected", helperHostSet);
|
|
8104
8183
|
this.__swc_connected = false;
|
|
8105
|
-
const appHost2 = hostSet.$appHost;
|
|
8106
|
-
if (appHost2 && typeof appHost2._disconnected === "function") {
|
|
8107
|
-
appHost2._disconnected(this);
|
|
8108
|
-
}
|
|
8109
8184
|
};
|
|
8110
8185
|
const originalAdopted = proto.adoptedCallback;
|
|
8111
8186
|
proto.adoptedCallback = function() {
|
|
@@ -8130,18 +8205,20 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8130
8205
|
let processedVal = newVal;
|
|
8131
8206
|
if (newVal !== null) {
|
|
8132
8207
|
const ae = new ActionExpression(newVal);
|
|
8133
|
-
const expr = ae.getFirstExpression("
|
|
8208
|
+
const expr = ae.getFirstExpression("callReturn");
|
|
8134
8209
|
if (expr) {
|
|
8135
8210
|
const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
|
|
8211
|
+
const helperAndHostSet = SwcUtils.getHelperAndHostSet(win2, this);
|
|
8212
|
+
const script = ConvertUtils2.decodeHtmlEntity(expr.script, win2.document);
|
|
8136
8213
|
try {
|
|
8137
8214
|
const result = FunctionUtils.executeReturn({
|
|
8138
|
-
script
|
|
8215
|
+
script,
|
|
8139
8216
|
context: this,
|
|
8140
|
-
args:
|
|
8217
|
+
args: helperAndHostSet
|
|
8141
8218
|
});
|
|
8142
|
-
processedVal =
|
|
8219
|
+
processedVal = result;
|
|
8143
8220
|
} catch (e) {
|
|
8144
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}
|
|
8221
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}: ${helperAndHostSet}`, e);
|
|
8145
8222
|
processedVal = newVal;
|
|
8146
8223
|
}
|
|
8147
8224
|
}
|
|
@@ -8156,9 +8233,15 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8156
8233
|
if (hostCustomEventMeta && newVal !== null) {
|
|
8157
8234
|
this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
|
|
8158
8235
|
}
|
|
8159
|
-
const
|
|
8160
|
-
if (
|
|
8161
|
-
for (const
|
|
8236
|
+
const metaList = attrChangeMap.get(name2);
|
|
8237
|
+
if (metaList && Array.isArray(metaList)) {
|
|
8238
|
+
for (const meta of metaList) {
|
|
8239
|
+
if (meta.options.while === "connected" && !this.__swc_connected) {
|
|
8240
|
+
continue;
|
|
8241
|
+
}
|
|
8242
|
+
const convertedVal = convertAttributeValue(processedVal, meta.options.type);
|
|
8243
|
+
this[meta.propertyKey](convertedVal, old, name2, hSet);
|
|
8244
|
+
}
|
|
8162
8245
|
}
|
|
8163
8246
|
};
|
|
8164
8247
|
Object.defineProperty(constructor, "observedAttributes", {
|
|
@@ -8175,12 +8258,38 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
8175
8258
|
|
|
8176
8259
|
// src/decorators/attribute.ts
|
|
8177
8260
|
var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
|
|
8178
|
-
var
|
|
8261
|
+
var convertValue2 = (val, type) => {
|
|
8179
8262
|
if (val === null || val === void 0) return val;
|
|
8180
8263
|
if (type === Number) return Number(val);
|
|
8181
8264
|
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
8182
8265
|
return val;
|
|
8183
8266
|
};
|
|
8267
|
+
var getAttributeValue = (inst, attrName, options) => {
|
|
8268
|
+
const conf = getElementConfig(inst);
|
|
8269
|
+
const currentWin = inst._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8270
|
+
const targets = options?.selector ? resolveTargetEls(inst, options.selector, options, currentWin) : [inst];
|
|
8271
|
+
const primaryTarget = targets[0];
|
|
8272
|
+
if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
|
|
8273
|
+
let domVal = primaryTarget.getAttribute(attrName);
|
|
8274
|
+
const ae = new ActionExpression(domVal);
|
|
8275
|
+
const expr = ae.getFirstExpression("callReturn");
|
|
8276
|
+
if (expr) {
|
|
8277
|
+
try {
|
|
8278
|
+
const result = FunctionUtils.executeReturn({
|
|
8279
|
+
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8280
|
+
context: inst,
|
|
8281
|
+
args: SwcUtils.getHelperAndHostSet(currentWin, inst)
|
|
8282
|
+
});
|
|
8283
|
+
return convertValue2(result, options?.type);
|
|
8284
|
+
} catch (e) {
|
|
8285
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8286
|
+
return convertValue2(domVal, options?.type);
|
|
8287
|
+
}
|
|
8288
|
+
}
|
|
8289
|
+
return convertValue2(domVal, options?.type);
|
|
8290
|
+
}
|
|
8291
|
+
return null;
|
|
8292
|
+
};
|
|
8184
8293
|
var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
8185
8294
|
const r = options.root || "auto";
|
|
8186
8295
|
const results = [];
|
|
@@ -8255,35 +8364,13 @@ function attribute(selector, options = {}) {
|
|
|
8255
8364
|
Object.defineProperty(target, propertyKey, {
|
|
8256
8365
|
get() {
|
|
8257
8366
|
const attrName = options.name || String(propertyKey);
|
|
8258
|
-
const
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
let domVal = primaryTarget.getAttribute(attrName);
|
|
8266
|
-
const ae = new ActionExpression(domVal);
|
|
8267
|
-
const expr = ae.getFirstExpression("call-return");
|
|
8268
|
-
if (expr) {
|
|
8269
|
-
try {
|
|
8270
|
-
const result = FunctionUtils.executeReturn({
|
|
8271
|
-
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8272
|
-
context: this,
|
|
8273
|
-
args: SwcUtils.getHelperAndHostSet(currentWin, this)
|
|
8274
|
-
});
|
|
8275
|
-
return convertValue(result, targetType);
|
|
8276
|
-
} catch (e) {
|
|
8277
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8278
|
-
return convertValue(domVal, targetType);
|
|
8279
|
-
}
|
|
8280
|
-
}
|
|
8281
|
-
return convertValue(domVal, targetType);
|
|
8282
|
-
}
|
|
8283
|
-
return null;
|
|
8284
|
-
}
|
|
8285
|
-
const data = convertValue(this[privateKey], targetType);
|
|
8286
|
-
return data;
|
|
8367
|
+
const mergedOptions = {
|
|
8368
|
+
...options,
|
|
8369
|
+
selector,
|
|
8370
|
+
type: options.type || designType
|
|
8371
|
+
};
|
|
8372
|
+
const result = getAttributeValue(this, attrName, mergedOptions);
|
|
8373
|
+
return result !== null ? result : this[privateKey];
|
|
8287
8374
|
},
|
|
8288
8375
|
set(nv) {
|
|
8289
8376
|
const attrName = options.name || String(propertyKey);
|
|
@@ -8396,14 +8483,7 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
|
8396
8483
|
const res = original.apply(this, args);
|
|
8397
8484
|
const runApply = (target, val) => {
|
|
8398
8485
|
const pos = options.position || "beforeEnd";
|
|
8399
|
-
|
|
8400
|
-
if (v instanceof Node) return !t.contains(v);
|
|
8401
|
-
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
8402
|
-
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
8403
|
-
return true;
|
|
8404
|
-
};
|
|
8405
|
-
const activeFilter = options.filter || defaultFilter;
|
|
8406
|
-
if (activeFilter(target, val, hostSet)) {
|
|
8486
|
+
if (!options.filter || options.filter(target, val, { currentThis: this, helper: hostSet })) {
|
|
8407
8487
|
applyToDom(target, val, pos, currentDoc);
|
|
8408
8488
|
}
|
|
8409
8489
|
};
|
|
@@ -8454,6 +8534,9 @@ function applyReplaceChildrenNode(selector, options = {}) {
|
|
|
8454
8534
|
function applyInnerHtmlNode(selector, options = {}) {
|
|
8455
8535
|
return applyNode(selector, { ...options, position: "innerHtml" });
|
|
8456
8536
|
}
|
|
8537
|
+
function applyInnerTextNode(selector, options = {}) {
|
|
8538
|
+
return applyNode(selector, { ...options, position: "innerText" });
|
|
8539
|
+
}
|
|
8457
8540
|
|
|
8458
8541
|
// src/decorators/applyClass.ts
|
|
8459
8542
|
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
@@ -8475,81 +8558,91 @@ function createClassDecorator(action) {
|
|
|
8475
8558
|
}
|
|
8476
8559
|
metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
|
|
8477
8560
|
const original = descriptor.value;
|
|
8478
|
-
descriptor.value =
|
|
8561
|
+
descriptor.value = function(...args) {
|
|
8479
8562
|
ensureInit(this);
|
|
8480
|
-
const res =
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
}
|
|
8507
|
-
targetEls.forEach((targetEl) => {
|
|
8508
|
-
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
8509
|
-
if (action === "set") {
|
|
8510
|
-
let classes = "";
|
|
8511
|
-
if (classMap && typeof classMap === "string") {
|
|
8512
|
-
classes = resolvedRes ? classMap : "";
|
|
8513
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8514
|
-
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8515
|
-
} else {
|
|
8516
|
-
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8563
|
+
const res = original.apply(this, args);
|
|
8564
|
+
const handleResult = (resolvedValue) => {
|
|
8565
|
+
if (resolvedValue !== void 0) {
|
|
8566
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8567
|
+
const host2 = this;
|
|
8568
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8569
|
+
const r = finalOptions.root || "auto";
|
|
8570
|
+
const targetEls = [];
|
|
8571
|
+
const applyRoot = (t) => {
|
|
8572
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8573
|
+
targetEls.push(t);
|
|
8574
|
+
};
|
|
8575
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8576
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8577
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8578
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8579
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8580
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8581
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8582
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8583
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8584
|
+
else {
|
|
8585
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8586
|
+
if (targetRoot) {
|
|
8587
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8588
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8517
8589
|
}
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
if (
|
|
8521
|
-
|
|
8522
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8523
|
-
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8524
|
-
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8525
|
-
targetEl.classList.toggle(cls, isActive);
|
|
8526
|
-
});
|
|
8527
|
-
} else {
|
|
8528
|
-
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8529
|
-
if (action === "update") targetEl.classList.add(...classes);
|
|
8530
|
-
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8590
|
+
}
|
|
8591
|
+
targetEls.forEach((targetEl) => {
|
|
8592
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8593
|
+
return;
|
|
8531
8594
|
}
|
|
8532
|
-
|
|
8533
|
-
if (
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
if (
|
|
8547
|
-
|
|
8595
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8596
|
+
if (action === "set") {
|
|
8597
|
+
let classes = "";
|
|
8598
|
+
if (classMap && typeof classMap === "string") {
|
|
8599
|
+
classes = resolvedRes ? classMap : "";
|
|
8600
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8601
|
+
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8602
|
+
} else {
|
|
8603
|
+
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8604
|
+
}
|
|
8605
|
+
targetEl.className = classes;
|
|
8606
|
+
} else if (action === "update" || action === "toggle") {
|
|
8607
|
+
if (classMap && typeof classMap === "string") {
|
|
8608
|
+
targetEl.classList.toggle(classMap, !!resolvedRes);
|
|
8609
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8610
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8611
|
+
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8612
|
+
targetEl.classList.toggle(cls, isActive);
|
|
8613
|
+
});
|
|
8614
|
+
} else {
|
|
8615
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8616
|
+
if (action === "update") targetEl.classList.add(...classes);
|
|
8617
|
+
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8618
|
+
}
|
|
8619
|
+
} else if (action === "add" || action === "remove") {
|
|
8620
|
+
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
8621
|
+
if (action === "add") targetEl.classList.add(classMap);
|
|
8622
|
+
else targetEl.classList.remove(classMap);
|
|
8623
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8624
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8625
|
+
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8626
|
+
if (shouldExecute) {
|
|
8627
|
+
if (action === "add") targetEl.classList.add(cls);
|
|
8628
|
+
else targetEl.classList.remove(cls);
|
|
8629
|
+
}
|
|
8630
|
+
});
|
|
8631
|
+
} else {
|
|
8632
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8633
|
+
if (action === "add") targetEl.classList.add(...classes);
|
|
8634
|
+
else targetEl.classList.remove(...classes);
|
|
8635
|
+
}
|
|
8548
8636
|
}
|
|
8549
|
-
}
|
|
8550
|
-
}
|
|
8637
|
+
});
|
|
8638
|
+
}
|
|
8639
|
+
return resolvedValue;
|
|
8640
|
+
};
|
|
8641
|
+
if (res instanceof Promise) {
|
|
8642
|
+
return res.then(handleResult);
|
|
8643
|
+
} else {
|
|
8644
|
+
return handleResult(res);
|
|
8551
8645
|
}
|
|
8552
|
-
return res;
|
|
8553
8646
|
};
|
|
8554
8647
|
return descriptor;
|
|
8555
8648
|
};
|
|
@@ -8595,67 +8688,77 @@ function createStyleDecorator(action) {
|
|
|
8595
8688
|
}
|
|
8596
8689
|
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
8597
8690
|
const original = descriptor.value;
|
|
8598
|
-
descriptor.value =
|
|
8691
|
+
descriptor.value = function(...args) {
|
|
8599
8692
|
ensureInit(this);
|
|
8600
|
-
const res =
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8693
|
+
const res = original.apply(this, args);
|
|
8694
|
+
const handleResult = (resolvedValue) => {
|
|
8695
|
+
if (resolvedValue !== void 0) {
|
|
8696
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8697
|
+
const host2 = this;
|
|
8698
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, host2);
|
|
8699
|
+
const r = options.root || "auto";
|
|
8700
|
+
const targetEls = [];
|
|
8701
|
+
const applyRoot = (t) => {
|
|
8702
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8703
|
+
targetEls.push(t);
|
|
8704
|
+
};
|
|
8705
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8706
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8707
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8708
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8709
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8710
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8711
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8712
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8713
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8714
|
+
else {
|
|
8715
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8716
|
+
if (targetRoot) {
|
|
8717
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8718
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8719
|
+
}
|
|
8625
8720
|
}
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
if (action === "set" || action === "update") {
|
|
8630
|
-
if (action === "set") targetEl.style.cssText = "";
|
|
8631
|
-
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8632
|
-
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8633
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8634
|
-
if (finalVal === null || finalVal === void 0) {
|
|
8635
|
-
targetEl.style.removeProperty(prop);
|
|
8636
|
-
} else {
|
|
8637
|
-
targetEl.style[prop] = String(finalVal);
|
|
8638
|
-
}
|
|
8639
|
-
});
|
|
8640
|
-
} else if (typeof resolvedRes === "string") {
|
|
8641
|
-
targetEl.style.cssText = resolvedRes;
|
|
8721
|
+
targetEls.forEach((targetEl) => {
|
|
8722
|
+
if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8723
|
+
return;
|
|
8642
8724
|
}
|
|
8643
|
-
|
|
8644
|
-
if (
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
targetEl
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8725
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8726
|
+
if (action === "set" || action === "update") {
|
|
8727
|
+
if (action === "set") targetEl.style.cssText = "";
|
|
8728
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8729
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8730
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8731
|
+
if (finalVal === null || finalVal === void 0) {
|
|
8732
|
+
targetEl.style.removeProperty(prop);
|
|
8733
|
+
} else {
|
|
8734
|
+
targetEl.style[prop] = String(finalVal);
|
|
8735
|
+
}
|
|
8736
|
+
});
|
|
8737
|
+
} else if (typeof resolvedRes === "string") {
|
|
8738
|
+
targetEl.style.cssText = resolvedRes;
|
|
8739
|
+
}
|
|
8740
|
+
} else if (action === "remove") {
|
|
8741
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8742
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8743
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
8744
|
+
if (shouldRemove) {
|
|
8745
|
+
targetEl.style.removeProperty(prop);
|
|
8746
|
+
}
|
|
8747
|
+
});
|
|
8748
|
+
} else {
|
|
8749
|
+
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
8750
|
+
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
8751
|
+
}
|
|
8654
8752
|
}
|
|
8655
|
-
}
|
|
8656
|
-
}
|
|
8753
|
+
});
|
|
8754
|
+
}
|
|
8755
|
+
return resolvedValue;
|
|
8756
|
+
};
|
|
8757
|
+
if (res instanceof Promise) {
|
|
8758
|
+
return res.then(handleResult);
|
|
8759
|
+
} else {
|
|
8760
|
+
return handleResult(res);
|
|
8657
8761
|
}
|
|
8658
|
-
return res;
|
|
8659
8762
|
};
|
|
8660
8763
|
return descriptor;
|
|
8661
8764
|
};
|
|
@@ -8705,48 +8808,59 @@ var setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
|
8705
8808
|
options: { ...finalOptions, name: propertyName }
|
|
8706
8809
|
});
|
|
8707
8810
|
const original = descriptor.value;
|
|
8708
|
-
descriptor.value =
|
|
8811
|
+
descriptor.value = function(...args) {
|
|
8709
8812
|
ensureInit(this);
|
|
8710
|
-
const res =
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8813
|
+
const res = original.apply(this, args);
|
|
8814
|
+
const handleResult = (resolvedValue) => {
|
|
8815
|
+
if (resolvedValue !== void 0) {
|
|
8816
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8817
|
+
const host2 = this;
|
|
8818
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8819
|
+
const r = finalOptions.root || "auto";
|
|
8820
|
+
const targetEls = [];
|
|
8821
|
+
const applyRoot = (t) => {
|
|
8822
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8823
|
+
targetEls.push(t);
|
|
8824
|
+
};
|
|
8825
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8826
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8827
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8828
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8829
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8830
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8831
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8832
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8833
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8834
|
+
else {
|
|
8835
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8836
|
+
if (targetRoot) {
|
|
8837
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8838
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8839
|
+
}
|
|
8735
8840
|
}
|
|
8841
|
+
targetEls.forEach((targetEl) => {
|
|
8842
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8843
|
+
return;
|
|
8844
|
+
}
|
|
8845
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8846
|
+
if (propertyName) {
|
|
8847
|
+
targetEl[propertyName] = resolvedRes;
|
|
8848
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8849
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8850
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8851
|
+
targetEl[prop] = finalVal;
|
|
8852
|
+
});
|
|
8853
|
+
} else {
|
|
8854
|
+
targetEl.value = resolvedRes;
|
|
8855
|
+
}
|
|
8856
|
+
});
|
|
8736
8857
|
}
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8744
|
-
targetEl[prop] = finalVal;
|
|
8745
|
-
});
|
|
8746
|
-
} else {
|
|
8747
|
-
targetEl.value = resolvedRes;
|
|
8748
|
-
}
|
|
8749
|
-
});
|
|
8858
|
+
return resolvedValue;
|
|
8859
|
+
};
|
|
8860
|
+
if (res instanceof Promise) {
|
|
8861
|
+
return res.then(handleResult);
|
|
8862
|
+
} else {
|
|
8863
|
+
return handleResult(res);
|
|
8750
8864
|
}
|
|
8751
8865
|
};
|
|
8752
8866
|
};
|
|
@@ -8767,7 +8881,7 @@ function createSubscribeSwcAppRouteChangeWhileConnected(options) {
|
|
|
8767
8881
|
list = [];
|
|
8768
8882
|
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
8769
8883
|
}
|
|
8770
|
-
list.push({ propertyKey,
|
|
8884
|
+
list.push({ propertyKey, options });
|
|
8771
8885
|
return descriptor;
|
|
8772
8886
|
};
|
|
8773
8887
|
}
|
|
@@ -8778,7 +8892,7 @@ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKey,
|
|
|
8778
8892
|
let options = {};
|
|
8779
8893
|
if (Array.isArray(targetOrOptions)) {
|
|
8780
8894
|
options.path = targetOrOptions;
|
|
8781
|
-
} else if (typeof targetOrOptions === "string") {
|
|
8895
|
+
} else if (typeof targetOrOptions === "string" || typeof targetOrOptions === "function") {
|
|
8782
8896
|
options.path = targetOrOptions;
|
|
8783
8897
|
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
8784
8898
|
options = targetOrOptions;
|
|
@@ -8924,6 +9038,22 @@ var RouterAction;
|
|
|
8924
9038
|
return typeof obj?.hasActivate === "function";
|
|
8925
9039
|
};
|
|
8926
9040
|
})(RouterAction || (RouterAction = {}));
|
|
9041
|
+
|
|
9042
|
+
// ../simple-boot/dist/esm/decorators/cache/CacheDecorator.js
|
|
9043
|
+
var CacheMetadataKey = Symbol.for("simple-boot:cache-metadata");
|
|
9044
|
+
|
|
9045
|
+
// ../simple-boot/dist/esm/fetch/ApiService.js
|
|
9046
|
+
var ApiServiceInterceptor;
|
|
9047
|
+
((ApiServiceInterceptor2) => {
|
|
9048
|
+
ApiServiceInterceptor2.TOKEN = Symbol.for("simple-boot:api-service-interceptor-token");
|
|
9049
|
+
ApiServiceInterceptor2.resolveAll = (simstanceManager) => {
|
|
9050
|
+
try {
|
|
9051
|
+
return (simstanceManager.findSims(ApiServiceInterceptor2.TOKEN) ?? []).map((it) => it.getValue()).filter(ValidUtils.isDefined);
|
|
9052
|
+
} catch (e) {
|
|
9053
|
+
return [];
|
|
9054
|
+
}
|
|
9055
|
+
};
|
|
9056
|
+
})(ApiServiceInterceptor || (ApiServiceInterceptor = {}));
|
|
8927
9057
|
export {
|
|
8928
9058
|
ADD_EVENT_LISTENER_METADATA_KEY,
|
|
8929
9059
|
APPLY_NODE_METADATA_KEY,
|
|
@@ -8976,6 +9106,7 @@ export {
|
|
|
8976
9106
|
applyClassHost,
|
|
8977
9107
|
applyInnerHtmlNode,
|
|
8978
9108
|
applyInnerHtmlNodeHost,
|
|
9109
|
+
applyInnerTextNode,
|
|
8979
9110
|
applyNode,
|
|
8980
9111
|
applyNodeHost,
|
|
8981
9112
|
applyReplaceChildrenNode,
|
|
@@ -8986,6 +9117,8 @@ export {
|
|
|
8986
9117
|
attributeHost,
|
|
8987
9118
|
changedAttributeHost,
|
|
8988
9119
|
commentNode,
|
|
9120
|
+
convertAttributeValue,
|
|
9121
|
+
convertValue2 as convertValue,
|
|
8989
9122
|
createElement,
|
|
8990
9123
|
elementDefine,
|
|
8991
9124
|
emitCustomEvent,
|
|
@@ -9001,6 +9134,7 @@ export {
|
|
|
9001
9134
|
firstAppHost,
|
|
9002
9135
|
firstHost,
|
|
9003
9136
|
getAddEventListenerMetadata,
|
|
9137
|
+
getAttributeValue,
|
|
9004
9138
|
getChangedAttributeMetadata,
|
|
9005
9139
|
getElementConfig,
|
|
9006
9140
|
getEmitCustomEventMetadataList,
|
|
@@ -9026,16 +9160,15 @@ export {
|
|
|
9026
9160
|
lastHost,
|
|
9027
9161
|
onAddEventListener,
|
|
9028
9162
|
onAdopted,
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
onAfterDisconnected,
|
|
9032
|
-
onBeforeAdopted,
|
|
9033
|
-
onBeforeConnected,
|
|
9034
|
-
onBeforeDisconnected,
|
|
9163
|
+
onAdoptedAfter,
|
|
9164
|
+
onAdoptedBefore,
|
|
9035
9165
|
onConnected,
|
|
9166
|
+
onConnectedAfter,
|
|
9167
|
+
onConnectedBefore,
|
|
9036
9168
|
onConnectedInnerHtml,
|
|
9037
|
-
onConnectedSwcApp,
|
|
9038
9169
|
onDisconnected,
|
|
9170
|
+
onDisconnectedAfter,
|
|
9171
|
+
onDisconnectedBefore,
|
|
9039
9172
|
onInitialize,
|
|
9040
9173
|
parentHost,
|
|
9041
9174
|
publishSwcAppMessage,
|