@dooboostore/simple-web-component 1.0.35 → 1.0.37
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 +58 -21
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +6 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- package/dist/cjs/decorators/addEventListener.js +12 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +19 -18
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +23 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +28 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +122 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js +20 -19
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +16 -15
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
- package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +59 -50
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +18 -16
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +56 -8
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +38 -60
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +31 -63
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +13 -12
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/elements/{SwcAppMixin.js → SwcApp.js} +107 -57
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/index.js +21 -2
- package/dist/cjs/elements/index.js.map +3 -3
- package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsync.js +1 -0
- package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChoose.js +1 -0
- package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIf.js +1 -0
- package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoop.js +1 -0
- package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/tt/register.js +1 -0
- package/dist/cjs/elements/tt/register.js.map +7 -0
- package/dist/cjs/index.js +12 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types/window.d.js +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +22 -19
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +4 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- package/dist/esm/decorators/addEventListener.js +12 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +19 -18
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +23 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +28 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +103 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js +20 -19
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +16 -15
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +60 -51
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +18 -16
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +56 -8
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +38 -60
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +31 -63
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +13 -12
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/elements/{SwcAppMixin.js → SwcApp.js} +102 -53
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/index.js +7 -1
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
- package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsync.js +1 -0
- package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcChoose.js +1 -0
- package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcIf.js +1 -0
- package/dist/esm/elements/tt/SwcIf.js.map +7 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoop.js +1 -0
- package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/tt/register.js +1 -0
- package/dist/esm/elements/tt/register.js.map +7 -0
- package/dist/esm/index.js +13 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +22 -19
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4189 -456
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -0
- package/dist/types/decorators/addEventListener.d.ts +5 -7
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +4 -4
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -6
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +9 -9
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +27 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -0
- package/dist/types/decorators/applyStyle.d.ts +4 -4
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -5
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
- package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +21 -6
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +17 -63
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -63
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +7 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/index.d.ts +2 -1
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcIf.d.ts +1 -0
- package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/tt/register.d.ts +1 -0
- package/dist/types/elements/tt/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +13 -12
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4189 -456
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +12 -7
- package/src/decorators/addEventListener.ts +11 -9
- package/src/decorators/applyAttribute.ts +16 -15
- package/src/decorators/applyClass.ts +18 -17
- package/src/decorators/applyNode.ts +30 -27
- package/src/decorators/applySlot.ts +228 -0
- package/src/decorators/applyStyle.ts +17 -16
- package/src/decorators/attribute.ts +20 -19
- package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
- package/src/decorators/elementDefine.ts +80 -57
- package/src/decorators/emitCustomEvent.ts +21 -26
- package/src/decorators/index.ts +2 -1
- package/src/decorators/lifecycles.ts +76 -11
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/elements/{SwcAppMixin.ts → SwcApp.ts} +98 -31
- package/src/elements/index.ts +11 -1
- package/src/elements/tt/SwcAppMixin.ts +13 -0
- package/src/elements/tt/SwcAsync.ts +139 -0
- package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
- package/src/elements/tt/SwcChoose.ts +182 -0
- package/src/elements/tt/SwcChooseTemplate.ts +229 -0
- package/src/elements/tt/SwcIf.ts +145 -0
- package/src/elements/tt/SwcIfTemplate.ts +158 -0
- package/src/elements/tt/SwcLoop.ts +222 -0
- package/src/elements/tt/SwcLoopTemplate.ts +255 -0
- package/src/elements/tt/SwcSubTemplates.ts +6 -0
- package/src/elements/tt/register.ts +720 -0
- package/src/index.ts +13 -9
- package/src/types/window.d.ts +43 -0
- package/src/types.ts +9 -8
- package/src/utils/Utils.ts +28 -24
- package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
- package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
- package/dist/cjs/elements/SwcAppMixin.js.map +0 -7
- package/dist/cjs/elements/SwcAsync.js +0 -129
- package/dist/cjs/elements/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/SwcChoose.js +0 -155
- package/dist/cjs/elements/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/SwcIf.js +0 -117
- package/dist/cjs/elements/SwcIf.js.map +0 -7
- package/dist/cjs/elements/SwcLoop.js +0 -176
- package/dist/cjs/elements/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/SwcSubTemplates.js +0 -13
- package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/register.js +0 -1026
- package/dist/cjs/elements/register.js.map +0 -7
- package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.js.map +0 -7
- package/dist/esm/elements/SwcAppMixin.js.map +0 -7
- package/dist/esm/elements/SwcAsync.js +0 -129
- package/dist/esm/elements/SwcAsync.js.map +0 -7
- package/dist/esm/elements/SwcChoose.js +0 -155
- package/dist/esm/elements/SwcChoose.js.map +0 -7
- package/dist/esm/elements/SwcIf.js +0 -117
- package/dist/esm/elements/SwcIf.js.map +0 -7
- package/dist/esm/elements/SwcLoop.js +0 -176
- package/dist/esm/elements/SwcLoop.js.map +0 -7
- package/dist/esm/elements/SwcSubTemplates.js +0 -13
- package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/register.js +0 -1007
- package/dist/esm/elements/register.js.map +0 -7
- package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
- package/dist/types/elements/SwcAppMixin.d.ts +0 -386
- package/dist/types/elements/SwcAppMixin.d.ts.map +0 -1
- package/dist/types/elements/SwcAsync.d.ts +0 -2
- package/dist/types/elements/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/SwcChoose.d.ts +0 -2
- package/dist/types/elements/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/SwcIf.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
- package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/register.d.ts +0 -4
- package/dist/types/elements/register.d.ts.map +0 -1
- package/src/elements/SwcAsync.ts +0 -126
- package/src/elements/SwcChoose.ts +0 -190
- package/src/elements/SwcIf.ts +0 -124
- package/src/elements/SwcLoop.ts +0 -205
- package/src/elements/SwcSubTemplates.ts +0 -6
- package/src/elements/register.ts +0 -1022
|
@@ -41,17 +41,31 @@ function queryAll(selectorOrTarget, options = {}) {
|
|
|
41
41
|
return results;
|
|
42
42
|
};
|
|
43
43
|
const hostSet = SwcUtils.getHostSet(this);
|
|
44
|
-
if (selector === "
|
|
44
|
+
if (selector === "$hosts")
|
|
45
45
|
return applyRoot(hostSet.$hosts);
|
|
46
|
-
if (selector === "
|
|
46
|
+
if (selector === "$appHosts")
|
|
47
47
|
return applyRoot(hostSet.$appHosts);
|
|
48
|
+
if (selector === "$host")
|
|
49
|
+
return applyRoot(hostSet.$host);
|
|
50
|
+
if (selector === "$parentHost")
|
|
51
|
+
return applyRoot(hostSet.$parentHost);
|
|
52
|
+
if (selector === "$appHost")
|
|
53
|
+
return applyRoot(hostSet.$appHost);
|
|
54
|
+
if (selector === "$firstHost")
|
|
55
|
+
return applyRoot(hostSet.$firstHost);
|
|
56
|
+
if (selector === "$lastHost")
|
|
57
|
+
return applyRoot(hostSet.$lastHost);
|
|
58
|
+
if (selector === "$firstAppHost")
|
|
59
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
60
|
+
if (selector === "$lastAppHost")
|
|
61
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
48
62
|
const config = getElementConfig(this);
|
|
49
63
|
const win = config?.window || window;
|
|
50
|
-
if (selector === "
|
|
64
|
+
if (selector === "$window")
|
|
51
65
|
return [win];
|
|
52
|
-
if (selector === "
|
|
66
|
+
if (selector === "$document")
|
|
53
67
|
return [win.document];
|
|
54
|
-
if (selector === "
|
|
68
|
+
if (selector === "$this")
|
|
55
69
|
return applyRoot(this);
|
|
56
70
|
if (r === "shadow")
|
|
57
71
|
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
@@ -69,7 +83,7 @@ function queryAll(selectorOrTarget, options = {}) {
|
|
|
69
83
|
ensureInit(this);
|
|
70
84
|
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
71
85
|
const selector = selectorOrTarget;
|
|
72
|
-
if (selector.startsWith("
|
|
86
|
+
if (selector.startsWith("$") && selector !== "$this")
|
|
73
87
|
return;
|
|
74
88
|
const r = options.root || "auto";
|
|
75
89
|
let targets = [];
|
|
@@ -92,75 +106,34 @@ function queryAll(selectorOrTarget, options = {}) {
|
|
|
92
106
|
});
|
|
93
107
|
};
|
|
94
108
|
}
|
|
95
|
-
function
|
|
109
|
+
function queryAllThis(targetOrOptions, propertyKey) {
|
|
96
110
|
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
97
|
-
return queryAll("
|
|
111
|
+
return queryAll("$this", {})(targetOrOptions, propertyKey);
|
|
98
112
|
}
|
|
99
113
|
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
100
|
-
return queryAll("
|
|
114
|
+
return queryAll("$this", targetOrOptions);
|
|
101
115
|
} else {
|
|
102
|
-
return queryAll("
|
|
116
|
+
return queryAll("$this", {});
|
|
103
117
|
}
|
|
104
118
|
}
|
|
105
|
-
const allHost = queryAllHost;
|
|
106
119
|
function allParentHost(targetOrOptions, propertyKey) {
|
|
107
120
|
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
108
|
-
return queryAll("
|
|
121
|
+
return queryAll("$host", {})(targetOrOptions, propertyKey);
|
|
109
122
|
}
|
|
110
123
|
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
111
|
-
return queryAll("
|
|
124
|
+
return queryAll("$host", targetOrOptions);
|
|
112
125
|
} else {
|
|
113
|
-
return queryAll("
|
|
126
|
+
return queryAll("$host", {});
|
|
114
127
|
}
|
|
115
128
|
}
|
|
116
129
|
function allAppHost(targetOrOptions, propertyKey) {
|
|
117
130
|
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
118
|
-
return queryAll("
|
|
131
|
+
return queryAll("$appHost", {})(targetOrOptions, propertyKey);
|
|
119
132
|
}
|
|
120
133
|
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
121
|
-
return queryAll("
|
|
134
|
+
return queryAll("$appHost", targetOrOptions);
|
|
122
135
|
} else {
|
|
123
|
-
return queryAll("
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function allFirstHost(targetOrOptions, propertyKey) {
|
|
127
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
128
|
-
return queryAll(":firstHost", {})(targetOrOptions, propertyKey);
|
|
129
|
-
}
|
|
130
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
131
|
-
return queryAll(":firstHost", targetOrOptions);
|
|
132
|
-
} else {
|
|
133
|
-
return queryAll(":firstHost", {});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function allLastHost(targetOrOptions, propertyKey) {
|
|
137
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
138
|
-
return queryAll(":lastHost", {})(targetOrOptions, propertyKey);
|
|
139
|
-
}
|
|
140
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
141
|
-
return queryAll(":lastHost", targetOrOptions);
|
|
142
|
-
} else {
|
|
143
|
-
return queryAll(":lastHost", {});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function allFirstAppHost(targetOrOptions, propertyKey) {
|
|
147
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
148
|
-
return queryAll(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
149
|
-
}
|
|
150
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
151
|
-
return queryAll(":firstAppHost", targetOrOptions);
|
|
152
|
-
} else {
|
|
153
|
-
return queryAll(":firstAppHost", {});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function allLastAppHost(targetOrOptions, propertyKey) {
|
|
157
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
158
|
-
return queryAll(":lastAppHost", {})(targetOrOptions, propertyKey);
|
|
159
|
-
}
|
|
160
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
161
|
-
return queryAll(":lastAppHost", targetOrOptions);
|
|
162
|
-
} else {
|
|
163
|
-
return queryAll(":lastAppHost", {});
|
|
136
|
+
return queryAll("$appHost", {});
|
|
164
137
|
}
|
|
165
138
|
}
|
|
166
139
|
const getQueryAllMetadata = (target) => {
|
|
@@ -170,14 +143,9 @@ const getQueryAllMetadata = (target) => {
|
|
|
170
143
|
export {
|
|
171
144
|
QUERY_ALL_METADATA_KEY,
|
|
172
145
|
allAppHost,
|
|
173
|
-
allFirstAppHost,
|
|
174
|
-
allFirstHost,
|
|
175
|
-
allHost,
|
|
176
|
-
allLastAppHost,
|
|
177
|
-
allLastHost,
|
|
178
146
|
allParentHost,
|
|
179
147
|
getQueryAllMetadata,
|
|
180
148
|
queryAll,
|
|
181
|
-
|
|
149
|
+
queryAllThis
|
|
182
150
|
};
|
|
183
151
|
//# sourceMappingURL=queryAll.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/queryAll.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');\n\nexport function queryAll(target: SpecialSelector): PropertyDecorator;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.root || 'auto';\n const applyRoot = (t: any): any[] => {\n if (!t) return [];\n const items = Array.isArray(t) ? t : [t];\n const results: any[] = [];\n items.forEach(it => {\n if (!(it instanceof HTMLElement)) {\n results.push(it);\n return;\n }\n if (r === 'auto') results.push(it.shadowRoot || it);\n else {\n if (r === 'light' || r === 'all') results.push(it);\n if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);\n }\n });\n return results;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === ':hosts') return applyRoot(hostSet.$hosts);\n if (selector === ':appHosts') return applyRoot(hostSet.$appHosts);\n\n // --- Special Selectors: Env ---\n const config = getElementConfig(this);\n const win = config?.window || window;\n if (selector === ':window') return [win];\n if (selector === ':document') return [win.document];\n if (selector === ':host') return applyRoot(this);\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n if (r === 'light') return Array.from(this.querySelectorAll(selector));\n if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n return [...sNodes, ...lNodes];\n }\n const root = this.shadowRoot || this;\n return Array.from(root.querySelectorAll(selector));\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\n const selector = selectorOrTarget;\n if (selector.startsWith(':') && selector !== ':host') return;\n\n const r = options.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n/**\n * @hostQueryAll decorator - simplified version of @queryAll for :host selector\n * Usage: @hostQueryAll()\n * Usage: @hostQueryAll({ root: 'shadow' })\n */\n/**\n * @queryAllHost decorator - simplified version of @queryAll for :host selector\n * Usage: @queryAllHost items: HTMLElement[];\n * Usage: @queryAllHost() items: HTMLElement[];\n * Usage: @queryAllHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport function queryAllHost(target: Object, propertyKey: string | symbol): void;\nexport function queryAllHost(): PropertyDecorator;\nexport function queryAllHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryAllHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryAllHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryAllHost() or @queryAllHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':host', {});\n }\n}\n\n/**\n * @allHost - Alias for @queryAllHost decorator\n * Usage: @allHost items: HTMLElement[];\n * Usage: @allHost() items: HTMLElement[];\n * Usage: @allHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport const allHost = queryAllHost;\n/**\n * @allParentHost - Query all :parentHost (All parent SWC components)\n * Usage: @allParentHost parents: HTMLElement[];\n * Usage: @allParentHost() parents: HTMLElement[];\n * Usage: @allParentHost({ root: 'shadow' }) parents: HTMLElement[];\n */\nexport function allParentHost(target: Object, propertyKey: string | symbol): void;\nexport function allParentHost(): PropertyDecorator;\nexport function allParentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':parentHost', {});\n }\n}\n\n/**\n * @allAppHost - Query all :appHost (All <swc-app> instances)\n * Usage: @allAppHost apps: SwcAppInterface[];\n * Usage: @allAppHost() apps: SwcAppInterface[];\n * Usage: @allAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allAppHost(): PropertyDecorator;\nexport function allAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':appHost', {});\n }\n}\n\n/**\n * @allFirstHost - Query all :firstHost (All first components in hierarchy)\n * Usage: @allFirstHost firsts: HTMLElement[];\n * Usage: @allFirstHost() firsts: HTMLElement[];\n * Usage: @allFirstHost({ root: 'shadow' }) firsts: HTMLElement[];\n */\nexport function allFirstHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstHost(): PropertyDecorator;\nexport function allFirstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstHost', {});\n }\n}\n\n/**\n * @allLastHost - Query all :lastHost (All last components in hierarchy)\n * Usage: @allLastHost lasts: HTMLElement[];\n * Usage: @allLastHost() lasts: HTMLElement[];\n * Usage: @allLastHost({ root: 'shadow' }) lasts: HTMLElement[];\n */\nexport function allLastHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastHost(): PropertyDecorator;\nexport function allLastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastHost', {});\n }\n}\n\n/**\n * @allFirstAppHost - Query all :firstAppHost (All first <swc-app> in hierarchy)\n * Usage: @allFirstAppHost apps: SwcAppInterface[];\n * Usage: @allFirstAppHost() apps: SwcAppInterface[];\n * Usage: @allFirstAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allFirstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstAppHost(): PropertyDecorator;\nexport function allFirstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstAppHost', {});\n }\n}\n\n/**\n * @allLastAppHost - Query all :lastAppHost (All last <swc-app> in hierarchy)\n * Usage: @allLastAppHost apps: SwcAppInterface[];\n * Usage: @allLastAppHost() apps: SwcAppInterface[];\n * Usage: @allLastAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allLastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastAppHost(): PropertyDecorator;\nexport function allLastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastAppHost', {});\n }\n}\n\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAO3E,SAAU,SAAS,kBAA0B,UAAe,CAAA,GAAE;AAClE,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,2DAA2D,OAAO,WAAW,CAAC,GAAG;IACnG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,aAAa,YAAgC,wBAAwB,WAAW;AAC9F,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,wBAAwB,SAAS,WAAW;IAC1E;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAEjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,mBAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAiB;AAClC,cAAI,CAAC;AAAG,mBAAO,CAAA;AACf,gBAAM,QAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACvC,gBAAM,UAAiB,CAAA;AACvB,gBAAM,QAAQ,QAAK;AACjB,gBAAI,EAAE,cAAc,cAAc;AAChC,sBAAQ,KAAK,EAAE;AACf;YACF;AACA,gBAAI,MAAM;AAAQ,sBAAQ,KAAK,GAAG,cAAc,EAAE;iBAC7C;AACH,kBAAI,MAAM,WAAW,MAAM;AAAO,wBAAQ,KAAK,EAAE;AACjD,mBAAK,MAAM,YAAY,MAAM,UAAU,GAAG;AAAY,wBAAQ,KAAK,GAAG,UAAU;YAClF;UACF,CAAC;AACD,iBAAO;QACT;AAGA,cAAM,UAAU,SAAS,WAAW,IAAI;AACxC,YAAI,aAAa;AAAU,iBAAO,UAAU,QAAQ,MAAM;AAC1D,YAAI,aAAa;AAAa,iBAAO,UAAU,QAAQ,SAAS;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');\n\nexport function queryAll(target: SpecialSelector): PropertyDecorator;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.root || 'auto';\n const applyRoot = (t: any): any[] => {\n if (!t) return [];\n const items = Array.isArray(t) ? t : [t];\n const results: any[] = [];\n items.forEach(it => {\n if (!(it instanceof HTMLElement)) {\n results.push(it);\n return;\n }\n if (r === 'auto') results.push(it.shadowRoot || it);\n else {\n if (r === 'light' || r === 'all') results.push(it);\n if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);\n }\n });\n return results;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === '$hosts') return applyRoot(hostSet.$hosts);\n if (selector === '$appHosts') return applyRoot(hostSet.$appHosts);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);\n if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);\n\n // --- Special Selectors: Env ---\n const config = getElementConfig(this);\n const win = config?.window || window;\n if (selector === '$window') return [win];\n if (selector === '$document') return [win.document];\n if (selector === '$this') return applyRoot(this);\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n if (r === 'light') return Array.from(this.querySelectorAll(selector));\n if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n return [...sNodes, ...lNodes];\n }\n const root = this.shadowRoot || this;\n return Array.from(root.querySelectorAll(selector));\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\n const selector = selectorOrTarget;\n if (selector.startsWith('$') && selector !== '$this') return;\n\n const r = options.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\n/**\n * @queryAllThis decorator - simplified version of @queryAll for $this selector\n */\nexport function queryAllThis(target: Object, propertyKey: string | symbol): void;\nexport function queryAllThis(): PropertyDecorator;\nexport function queryAllThis(options: SwcQueryOptions): PropertyDecorator;\nexport function queryAllThis(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll('$this', {})(targetOrOptions, propertyKey);\n }\n\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll('$this', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll('$this', {});\n }\n}\n\n/**\n * @allParentHost - Query all parent SWC components\n */\nexport function allParentHost(target: Object, propertyKey: string | symbol): void;\nexport function allParentHost(): PropertyDecorator;\nexport function allParentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll('$host', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll('$host', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll('$host', {});\n }\n}\n\n/**\n * @allAppHost - Query all $appHost (All <swc-app> instances)\n */\nexport function allAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allAppHost(): PropertyDecorator;\nexport function allAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll('$appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll('$appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll('$appHost', {});\n }\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAO3E,SAAU,SAAS,kBAA0B,UAAe,CAAA,GAAE;AAClE,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,2DAA2D,OAAO,WAAW,CAAC,GAAG;IACnG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,aAAa,YAAgC,wBAAwB,WAAW;AAC9F,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,wBAAwB,SAAS,WAAW;IAC1E;AACA,YAAQ,KA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|
@@ -35,15 +35,16 @@ const setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
|
35
35
|
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
36
36
|
targetEls.push(t);
|
|
37
37
|
};
|
|
38
|
-
if (selector === "
|
|
39
|
-
else if (selector === "
|
|
40
|
-
else if (selector === "
|
|
41
|
-
else if (selector === "
|
|
42
|
-
else if (selector === "
|
|
43
|
-
else if (selector === "
|
|
44
|
-
else if (selector === "
|
|
45
|
-
else if (selector === "
|
|
46
|
-
else if (selector === "
|
|
38
|
+
if (selector === "$this" || !selector) applyRoot(host);
|
|
39
|
+
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
40
|
+
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
41
|
+
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
42
|
+
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
43
|
+
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
44
|
+
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
45
|
+
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
46
|
+
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
47
|
+
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
47
48
|
else {
|
|
48
49
|
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
49
50
|
if (targetRoot) {
|
|
@@ -78,12 +79,12 @@ const setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
};
|
|
81
|
-
const
|
|
82
|
-
return setProperty("
|
|
82
|
+
const setPropertyThis = (propertyNameOrOptions, options = {}) => {
|
|
83
|
+
return setProperty("$this", propertyNameOrOptions, options);
|
|
83
84
|
};
|
|
84
85
|
export {
|
|
85
86
|
PROPERTY_SET_METADATA_KEY,
|
|
86
87
|
setProperty,
|
|
87
|
-
|
|
88
|
+
setPropertyThis
|
|
88
89
|
};
|
|
89
90
|
//# sourceMappingURL=setProperty.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/setProperty.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { HelperHostSet, SwcQueryOptions } from '../types';\n\nexport interface PropertySetOptions extends SwcQueryOptions {\n name?: string;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface PropertySetMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: PropertySetOptions;\n}\n\nexport const PROPERTY_SET_METADATA_KEY = Symbol.for('simple-web-component:property-set');\n\nexport const setProperty = (selector: string, propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor) as Map<string | symbol, PropertySetMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, PropertySetMetadata>();\n ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);\n }\n\n let propertyName = typeof propertyNameOrOptions === 'string' ? propertyNameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof propertyNameOrOptions === 'object' && propertyNameOrOptions !== null) {\n finalOptions = propertyNameOrOptions as PropertySetOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n options: { ...finalOptions, name: propertyName } \n });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAclB,MAAM,4BAA4B,OAAO,IAAI,mCAAmC;AAEhF,MAAM,cAAc,CAAC,UAAkB,uBAAqD,UAA8B,CAAC,MAAuB;AACvJ,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAA0C;AACzD,mBAAa,eAAe,2BAA2B,UAAU,WAAW;AAAA,IAC9E;AAEA,QAAI,eAAe,OAAO,0BAA0B,WAAW,wBAAwB;AACvF,QAAI,eAAe;AAEnB,QAAI,OAAO,0BAA0B,YAAY,0BAA0B,MAAM;AAC/E,qBAAe;AAAA,IACjB;AAEA,aAAS,IAAI,aAAa;AAAA,MACxB;AAAA,MACA;AAAA,MACA,SAAS,EAAE,GAAG,cAAc,MAAM,aAAa;AAAA,IACjD,CAAC;AAED,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,YAAa,MAAa;AAC3C,iBAAW,IAAI;AACf,YAAM,MAAO,SAAiB,MAAM,MAAM,IAAI;AAE9C,YAAM,eAAe,CAAC,kBAAuB;AAC3C,YAAI,kBAAkB,QAAW;AAC/B,gBAAM,MAAO,KAAa,eAAe,eAAe;AACxD,gBAAM,OAAO;AACb,gBAAM,UAAU,EAAE,GAAG,SAAS,oBAAoB,KAAK,IAAI,GAAG,OAAO,KAAK;AAC1E,gBAAM,IAAI,aAAa,QAAQ;AAC/B,gBAAM,YAA2B,CAAC;AAElC,gBAAM,YAAY,CAAC,MAAW;AAC5B,gBAAI,CAAC,KAAK,EAAE,aAAa,IAAI,aAAc;AAC3C,sBAAU,KAAK,CAAC;AAAA,UAClB;AAEA,cAAI,aAAa,cAAe,WAAU,QAAQ,WAAW;AAAA,
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { HelperHostSet, SwcQueryOptions } from '../types';\n\nexport interface PropertySetOptions extends SwcQueryOptions {\n name?: string;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface PropertySetMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: PropertySetOptions;\n}\n\nexport const PROPERTY_SET_METADATA_KEY = Symbol.for('simple-web-component:property-set');\n\nexport const setProperty = (selector: string, propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor) as Map<string | symbol, PropertySetMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, PropertySetMetadata>();\n ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);\n }\n\n let propertyName = typeof propertyNameOrOptions === 'string' ? propertyNameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof propertyNameOrOptions === 'object' && propertyNameOrOptions !== null) {\n finalOptions = propertyNameOrOptions as PropertySetOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n options: { ...finalOptions, name: propertyName } \n });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (propertyName) {\n // Case: @setProperty(selector, 'propertyName')\n (targetEl as any)[propertyName] = resolvedRes;\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @setProperty(selector) with Object return - assign multiple properties\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n (targetEl as any)[prop] = finalVal;\n });\n } else {\n // Simple value - assign to 'value' property by default\n (targetEl as any).value = resolvedRes;\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n};\n\nexport const setPropertyThis = (propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return setProperty('$this', propertyNameOrOptions, options);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAclB,MAAM,4BAA4B,OAAO,IAAI,mCAAmC;AAEhF,MAAM,cAAc,CAAC,UAAkB,uBAAqD,UAA8B,CAAC,MAAuB;AACvJ,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAA0C;AACzD,mBAAa,eAAe,2BAA2B,UAAU,WAAW;AAAA,IAC9E;AAEA,QAAI,eAAe,OAAO,0BAA0B,WAAW,wBAAwB;AACvF,QAAI,eAAe;AAEnB,QAAI,OAAO,0BAA0B,YAAY,0BAA0B,MAAM;AAC/E,qBAAe;AAAA,IACjB;AAEA,aAAS,IAAI,aAAa;AAAA,MACxB;AAAA,MACA;AAAA,MACA,SAAS,EAAE,GAAG,cAAc,MAAM,aAAa;AAAA,IACjD,CAAC;AAED,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,YAAa,MAAa;AAC3C,iBAAW,IAAI;AACf,YAAM,MAAO,SAAiB,MAAM,MAAM,IAAI;AAE9C,YAAM,eAAe,CAAC,kBAAuB;AAC3C,YAAI,kBAAkB,QAAW;AAC/B,gBAAM,MAAO,KAAa,eAAe,eAAe;AACxD,gBAAM,OAAO;AACb,gBAAM,UAAU,EAAE,GAAG,SAAS,oBAAoB,KAAK,IAAI,GAAG,OAAO,KAAK;AAC1E,gBAAM,IAAI,aAAa,QAAQ;AAC/B,gBAAM,YAA2B,CAAC;AAElC,gBAAM,YAAY,CAAC,MAAW;AAC5B,gBAAI,CAAC,KAAK,EA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,OAAO,IAAI;AACtE,gBAAC,SAAiB,IAAI,IAAI;AAAA,cAC5B,CAAC;AAAA,YACH,OAAO;AAEL,cAAC,SAAiB,QAAQ;AAAA,YAC5B;AAAA,UACF,CAAC;AAAA,QACH;AACA,eAAO;AAAA,MACT;AAEA,UAAI,eAAe,SAAS;AAC1B,eAAO,IAAI,KAAK,YAAY;AAAA,MAC9B,OAAO;AACL,eAAO,aAAa,GAAG;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,kBAAkB,CAAC,uBAAqD,UAA8B,CAAC,MAAuB;AACzI,SAAO,YAAY,SAAS,uBAAuB,OAAO;AAC5D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { elementDefine, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY } from "../decorators/index.js";
|
|
8
|
+
import { SwcAppEngine } from "../SwcAppEngine.js";
|
|
6
9
|
import { debounceTimeIntervalLock, FunctionUtils } from "@dooboostore/core";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
import { SwcUtils } from "../utils/Utils.js";
|
|
11
|
+
const isSSR = (i) => {
|
|
12
|
+
return i.hasAttribute("swc-use-ssr");
|
|
13
|
+
};
|
|
14
|
+
const setSSRAttribute = (i) => {
|
|
15
|
+
i.setAttribute("swc-use-ssr", i._swcId ?? "");
|
|
16
|
+
};
|
|
17
|
+
const removeSSRAttribute = (i) => {
|
|
18
|
+
i.removeAttribute("swc-use-ssr");
|
|
19
|
+
};
|
|
20
|
+
const tagName = "swc-app";
|
|
21
|
+
var SwcApp_default = async (w) => {
|
|
22
|
+
const existing = w.customElements.get(tagName);
|
|
23
|
+
if (existing)
|
|
24
|
+
return existing;
|
|
25
|
+
let SwcApp = class SwcApp extends w.HTMLElement {
|
|
11
26
|
constructor() {
|
|
12
27
|
super(...arguments);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
__publicField(this, "_routeChangeInvocations", 0);
|
|
19
|
-
__publicField(this, "_connectedInvocations", 0);
|
|
20
|
-
__publicField(this, "_childrenRouteChangedInterval");
|
|
21
|
-
__publicField(this, "_childrenConnectedDoneInterval");
|
|
22
|
-
/*
|
|
23
|
-
사파리 is 일경우
|
|
24
|
-
<script src="https://unpkg.com/@ungap/custom-elements"><\/script>
|
|
25
|
-
이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
|
|
26
|
-
저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
|
|
27
|
-
*/
|
|
28
|
-
__publicField(this, "_connected_safari", []);
|
|
28
|
+
this.__swc_engine = new SwcAppEngine(this);
|
|
29
|
+
this._swc_connected_instance = /* @__PURE__ */ new Set();
|
|
30
|
+
this._routeChangeInvocations = 0;
|
|
31
|
+
this._connectedInvocations = 0;
|
|
32
|
+
this._connected_safari_and_standby = [];
|
|
29
33
|
}
|
|
30
34
|
get simpleApplication() {
|
|
31
35
|
return this.__swc_engine.simpleApplication;
|
|
@@ -37,19 +41,21 @@ function SwcAppMixin(Base) {
|
|
|
37
41
|
return this.__swc_engine?.router;
|
|
38
42
|
}
|
|
39
43
|
async _invokeRouteChangeSubscribers(instance, re) {
|
|
40
|
-
if (instance.isConnected === false)
|
|
44
|
+
if (instance.isConnected === false)
|
|
45
|
+
return;
|
|
41
46
|
this._routeChangeInvocations++;
|
|
42
47
|
if (this._childrenRouteChangedInterval) {
|
|
43
|
-
clearInterval(this._childrenRouteChangedInterval);
|
|
48
|
+
this.config.window.clearInterval(this._childrenRouteChangedInterval);
|
|
44
49
|
}
|
|
50
|
+
const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };
|
|
45
51
|
this._childrenRouteChangedInterval = debounceTimeIntervalLock(
|
|
46
52
|
() => this._routeChangeInvocations === 0,
|
|
47
53
|
() => {
|
|
48
54
|
this._childrenRouteChangedInterval = null;
|
|
49
|
-
this.config.onChildrenRouteChanged(re, this);
|
|
55
|
+
this.config.onChildrenRouteChanged?.(re, this);
|
|
50
56
|
},
|
|
51
57
|
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
52
|
-
|
|
58
|
+
intervalConfig
|
|
53
59
|
// {setInterval: window.setInterval, clearInterval: window.clearInterval}
|
|
54
60
|
);
|
|
55
61
|
try {
|
|
@@ -88,25 +94,37 @@ function SwcAppMixin(Base) {
|
|
|
88
94
|
await Promise.allSettled(ps);
|
|
89
95
|
}
|
|
90
96
|
} finally {
|
|
91
|
-
this.
|
|
97
|
+
if (this.config?.ssr) {
|
|
98
|
+
setSSRAttribute(instance);
|
|
99
|
+
} else {
|
|
100
|
+
removeSSRAttribute(instance);
|
|
101
|
+
}
|
|
102
|
+
this._routeChangeInvocations = Math.max(0, this._routeChangeInvocations - 1);
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
|
-
async _connected(instance) {
|
|
105
|
+
async _connected(instance, option) {
|
|
95
106
|
if (instance) {
|
|
96
|
-
this.
|
|
107
|
+
if (!this.simpleApplication && !this.config) {
|
|
108
|
+
this._connected_safari_and_standby.push(instance);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.config.onConnectedChildBefore?.(instance);
|
|
112
|
+
if (!option?.noIncrements) {
|
|
113
|
+
this._connectedInvocations++;
|
|
114
|
+
}
|
|
97
115
|
this._swc_connected_instance.add(instance);
|
|
116
|
+
const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY) ?? [];
|
|
117
|
+
for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {
|
|
118
|
+
await instance?._invokeLifecycleMethod?.(connectedSwcAppCallBack);
|
|
119
|
+
}
|
|
98
120
|
if (this._childrenConnectedDoneInterval) {
|
|
99
|
-
clearInterval(this._childrenConnectedDoneInterval);
|
|
121
|
+
this.config.window.clearInterval(this._childrenConnectedDoneInterval);
|
|
100
122
|
}
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
108
|
-
{ setInterval: window.setInterval, clearInterval: window.clearInterval }
|
|
109
|
-
);
|
|
123
|
+
const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };
|
|
124
|
+
this._childrenConnectedDoneInterval = debounceTimeIntervalLock(() => this._connectedInvocations === 0, () => {
|
|
125
|
+
this._childrenConnectedDoneInterval = null;
|
|
126
|
+
this.config.onChildrenConnectedDone?.(this);
|
|
127
|
+
}, this.config?.childrenConnectedDoneCheckIntervalTime ?? 30, intervalConfig);
|
|
110
128
|
if (this.simpleApplication) {
|
|
111
129
|
try {
|
|
112
130
|
if (this.router && this._lastRouterEvent) {
|
|
@@ -116,17 +134,25 @@ function SwcAppMixin(Base) {
|
|
|
116
134
|
throw e;
|
|
117
135
|
}
|
|
118
136
|
}
|
|
137
|
+
if (this.config?.ssr) {
|
|
138
|
+
setSSRAttribute(instance);
|
|
139
|
+
} else {
|
|
140
|
+
removeSSRAttribute(instance);
|
|
141
|
+
}
|
|
119
142
|
}
|
|
143
|
+
this.config.onConnectedChildAfter?.(instance);
|
|
144
|
+
return this;
|
|
120
145
|
}
|
|
121
146
|
async _connectedDone(instance) {
|
|
122
147
|
try {
|
|
123
148
|
} finally {
|
|
124
|
-
this._connectedInvocations
|
|
149
|
+
this._connectedInvocations = Math.max(0, this._connectedInvocations - 1);
|
|
125
150
|
}
|
|
126
151
|
}
|
|
127
152
|
_disconnected(instance) {
|
|
128
153
|
if (instance) {
|
|
129
154
|
this._swc_connected_instance.delete(instance);
|
|
155
|
+
this.config?.onDisconnectedChildAfter?.(instance);
|
|
130
156
|
}
|
|
131
157
|
}
|
|
132
158
|
async _handleRouteChange(route) {
|
|
@@ -136,15 +162,16 @@ function SwcAppMixin(Base) {
|
|
|
136
162
|
await Promise.allSettled(ps);
|
|
137
163
|
}
|
|
138
164
|
async connect(config) {
|
|
165
|
+
console.log("[SWC] connect");
|
|
139
166
|
const swcConfig = {
|
|
140
167
|
routeType: "element",
|
|
141
168
|
window: config?.window,
|
|
142
169
|
...config
|
|
143
170
|
};
|
|
144
171
|
const mode = config?.connectMode || "direct";
|
|
145
|
-
if (mode === "direct") {
|
|
172
|
+
if (mode === "direct" || mode === "hydrate") {
|
|
173
|
+
this.setAttribute("swc-connect-mode", mode);
|
|
146
174
|
await this.__swc_engine.connect(swcConfig);
|
|
147
|
-
this.setAttribute("swc-connect-mode", "direct");
|
|
148
175
|
} else if (mode === "swap" || mode === "clear-swap") {
|
|
149
176
|
if (!this.parentNode) {
|
|
150
177
|
await this.__swc_engine.connect(swcConfig);
|
|
@@ -170,18 +197,19 @@ function SwcAppMixin(Base) {
|
|
|
170
197
|
}
|
|
171
198
|
}
|
|
172
199
|
}
|
|
173
|
-
this.
|
|
174
|
-
this._connected(instance);
|
|
200
|
+
this._connected_safari_and_standby.forEach((instance) => {
|
|
201
|
+
this._connected(instance, { noIncrements: true });
|
|
175
202
|
});
|
|
176
203
|
if (!this._routerSubscription && this.router) {
|
|
177
204
|
const config2 = this.__swc_engine.config;
|
|
178
205
|
this._routerSubscription = this.router.observable.subscribe(async (route) => {
|
|
206
|
+
console.log("[SWC] Router event received:", route.triggerPoint);
|
|
179
207
|
if (route.triggerPoint === "end") {
|
|
180
208
|
await this._handleRouteChange(route);
|
|
181
209
|
}
|
|
182
210
|
});
|
|
183
211
|
if (config2?.path) {
|
|
184
|
-
|
|
212
|
+
console.log("[DEBUG] Navigating to initial path:", config2.path);
|
|
185
213
|
}
|
|
186
214
|
}
|
|
187
215
|
}
|
|
@@ -202,7 +230,8 @@ function SwcAppMixin(Base) {
|
|
|
202
230
|
// }
|
|
203
231
|
// }
|
|
204
232
|
connectedCallback() {
|
|
205
|
-
if (super.connectedCallback)
|
|
233
|
+
if (super.connectedCallback)
|
|
234
|
+
super.connectedCallback();
|
|
206
235
|
const configStr = this.getAttribute("swc-get-application-config");
|
|
207
236
|
const win = this.ownerDocument?.defaultView || window;
|
|
208
237
|
if (configStr && win) {
|
|
@@ -217,15 +246,19 @@ function SwcAppMixin(Base) {
|
|
|
217
246
|
console.error("[SWC-APP-ENGINE] Script execution failed:", e);
|
|
218
247
|
}
|
|
219
248
|
}
|
|
249
|
+
this._connected(this);
|
|
220
250
|
this.__swc_engine?.config?.onConnected?.(this);
|
|
251
|
+
this._connectedDone(this);
|
|
221
252
|
}
|
|
222
253
|
disconnectedCallback() {
|
|
223
|
-
if (super.disconnectedCallback)
|
|
254
|
+
if (super.disconnectedCallback)
|
|
255
|
+
super.disconnectedCallback();
|
|
224
256
|
this._routerSubscription?.unsubscribe();
|
|
225
257
|
this._routerSubscription = void 0;
|
|
226
258
|
this._lastRouterEvent = void 0;
|
|
227
259
|
this.__swc_engine.disconnect();
|
|
228
260
|
this.__swc_engine?.config?.onDisconnected?.(this);
|
|
261
|
+
this._disconnected(this);
|
|
229
262
|
}
|
|
230
263
|
async routing(path) {
|
|
231
264
|
await this.router?.go(path);
|
|
@@ -239,6 +272,13 @@ function SwcAppMixin(Base) {
|
|
|
239
272
|
reload() {
|
|
240
273
|
this.router?.reload();
|
|
241
274
|
}
|
|
275
|
+
// async completedSwcApp() {
|
|
276
|
+
// const ss = Array.from(this._swc_connected_instance).flatMap((it) => {
|
|
277
|
+
// const ms = findAllLifecycleMetadata(it, ON_CONNECTED_COMPLETED_SWC_APP_METADATA_KEY) ?? [];
|
|
278
|
+
// return ms.map((sit) => it[sit](this));
|
|
279
|
+
// });
|
|
280
|
+
// await Promise.allSettled(ss);
|
|
281
|
+
// }
|
|
242
282
|
publishMessage(message) {
|
|
243
283
|
this._swc_connected_instance.forEach((instance) => {
|
|
244
284
|
this._invokeMessageSubscribers(instance, message);
|
|
@@ -268,8 +308,17 @@ function SwcAppMixin(Base) {
|
|
|
268
308
|
}
|
|
269
309
|
}
|
|
270
310
|
};
|
|
271
|
-
|
|
311
|
+
SwcApp = __decorate([
|
|
312
|
+
elementDefine(tagName, { window: w })
|
|
313
|
+
], SwcApp);
|
|
314
|
+
;
|
|
315
|
+
return w.customElements.whenDefined(tagName);
|
|
316
|
+
};
|
|
272
317
|
export {
|
|
273
|
-
|
|
318
|
+
SwcApp_default as default,
|
|
319
|
+
isSSR,
|
|
320
|
+
removeSSRAttribute,
|
|
321
|
+
setSSRAttribute,
|
|
322
|
+
tagName
|
|
274
323
|
};
|
|
275
|
-
//# sourceMappingURL=
|
|
324
|
+
//# sourceMappingURL=SwcApp.js.map
|