@dooboostore/simple-web-component 1.0.43 → 1.0.45
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 +312 -63
- package/dist/cjs/SwcAppEngine.js +3 -1
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +66 -43
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +110 -43
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +200 -112
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +49 -45
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +92 -37
- package/dist/cjs/decorators/applyStyle.js.map +3 -3
- package/dist/cjs/decorators/{changedAttributeThis.js → changedAttribute.js} +6 -6
- package/dist/cjs/decorators/changedAttribute.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +81 -31
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +80 -52
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +1 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +5 -5
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/cjs/decorators/query.js +133 -147
- package/dist/cjs/decorators/query.js.map +3 -3
- package/dist/cjs/decorators/queryAll.js +143 -132
- package/dist/cjs/decorators/queryAll.js.map +3 -3
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +17 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -0
- package/dist/cjs/router/ElementRouter.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/esm/SwcAppEngine.js +3 -1
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +66 -43
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +110 -43
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +200 -112
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +49 -45
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +92 -37
- package/dist/esm/decorators/applyStyle.js.map +3 -3
- package/dist/esm/decorators/{changedAttributeThis.js → changedAttribute.js} +3 -3
- package/dist/esm/decorators/changedAttribute.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +79 -29
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +80 -52
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -1
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/publishSwcAppMessage.js +5 -5
- package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/esm/decorators/query.js +133 -147
- package/dist/esm/decorators/query.js.map +3 -3
- package/dist/esm/decorators/queryAll.js +143 -132
- package/dist/esm/decorators/queryAll.js.map +3 -3
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +18 -3
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
- package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +4 -0
- package/dist/esm/router/ElementRouter.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1118 -633
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +19 -15
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +45 -26
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +19 -38
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +175 -32
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +38 -25
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +10 -9
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/{changedAttributeThis.d.ts → changedAttribute.d.ts} +2 -2
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +6 -12
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +16 -29
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +16 -23
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +4 -4
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/router/ElementRouter.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1118 -633
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +1 -1
- package/src/SwcAppEngine.ts +3 -1
- package/src/decorators/addEventListener.ts +31 -25
- package/src/decorators/applyAttribute.ts +164 -86
- package/src/decorators/applyClass.ts +161 -41
- package/src/decorators/applyNode.ts +408 -108
- package/src/decorators/applyProperty.ts +100 -89
- package/src/decorators/applyStyle.ts +131 -37
- package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
- package/src/decorators/elementDefine.ts +96 -30
- package/src/decorators/emitCustomEvent.ts +92 -60
- package/src/decorators/index.ts +1 -1
- package/src/decorators/publishSwcAppMessage.ts +1 -1
- package/src/decorators/query.ts +155 -162
- package/src/decorators/queryAll.ts +157 -139
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +3 -1
- package/src/elements/SwcAppMixin.ts +43 -24
- package/src/examples/RxJSOperatorsExample.ts +279 -0
- package/src/index.ts +2 -0
- package/src/router/ElementRouter.ts +4 -0
- package/src/types/window.d.ts +3 -0
- package/dist/cjs/decorators/changedAttributeThis.js.map +0 -7
- package/dist/esm/decorators/changedAttributeThis.js.map +0 -7
- package/dist/types/decorators/changedAttributeThis.d.ts.map +0 -1
|
@@ -18,150 +18,161 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var queryAll_exports = {};
|
|
19
19
|
__export(queryAll_exports, {
|
|
20
20
|
QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
|
|
21
|
-
allAppHost: () => allAppHost,
|
|
22
|
-
allParentHost: () => allParentHost,
|
|
23
21
|
getQueryAllMetadata: () => getQueryAllMetadata,
|
|
24
|
-
queryAll: () => queryAll
|
|
25
|
-
queryAllThis: () => queryAllThis
|
|
22
|
+
queryAll: () => queryAll
|
|
26
23
|
});
|
|
27
24
|
module.exports = __toCommonJS(queryAll_exports);
|
|
28
25
|
var import_core = require("@dooboostore/core");
|
|
29
26
|
var import_elementDefine = require("./elementDefine");
|
|
30
27
|
var import_Utils = require("../utils/Utils");
|
|
31
28
|
const QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
|
|
32
|
-
function queryAll(selectorOrTarget,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
30
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
31
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
34
|
+
return (targetObj, propertyKey, descriptor2) => {
|
|
35
|
+
if (descriptor2 !== void 0) {
|
|
36
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
37
|
+
}
|
|
38
|
+
const constructor = targetObj.constructor;
|
|
39
|
+
let queries = import_core.ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
40
|
+
if (!queries) {
|
|
41
|
+
queries = [];
|
|
42
|
+
import_core.ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
43
|
+
}
|
|
44
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
|
|
45
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
46
|
+
get() {
|
|
47
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
48
|
+
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
49
|
+
const win = config?.window || window;
|
|
50
|
+
const hostSet = import_Utils.SwcUtils.getHelperAndHostSet(win, this);
|
|
51
|
+
let resolvedSelector;
|
|
52
|
+
let resolvedElements = [];
|
|
53
|
+
if (typeof selectorOrTarget === "function") {
|
|
54
|
+
const result = selectorOrTarget(this, hostSet);
|
|
55
|
+
if (result instanceof win.NodeList) {
|
|
56
|
+
resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
|
|
57
|
+
} else if (Array.isArray(result)) {
|
|
58
|
+
resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
} else {
|
|
61
|
+
resolvedSelector = selectorOrTarget;
|
|
62
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
63
|
+
const applyRoot = (t) => {
|
|
64
|
+
if (!t)
|
|
65
|
+
return [];
|
|
66
|
+
const items = Array.isArray(t) ? t : [t];
|
|
67
|
+
const results = [];
|
|
68
|
+
items.forEach((it) => {
|
|
69
|
+
if (!(it instanceof HTMLElement)) {
|
|
70
|
+
results.push(it);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (r === "auto")
|
|
74
|
+
results.push(it.shadowRoot || it);
|
|
75
|
+
else {
|
|
76
|
+
if (r === "light" || r === "all")
|
|
77
|
+
results.push(it);
|
|
78
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
79
|
+
results.push(it.shadowRoot);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return results;
|
|
83
|
+
};
|
|
84
|
+
if (resolvedSelector === "$hosts")
|
|
85
|
+
resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
|
|
86
|
+
else if (resolvedSelector === "$appHosts")
|
|
87
|
+
resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
|
|
88
|
+
else if (resolvedSelector === "$host")
|
|
89
|
+
resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
|
|
90
|
+
else if (resolvedSelector === "$parentHost")
|
|
91
|
+
resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
|
|
92
|
+
else if (resolvedSelector === "$appHost")
|
|
93
|
+
resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
|
|
94
|
+
else if (resolvedSelector === "$firstHost")
|
|
95
|
+
resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
|
|
96
|
+
else if (resolvedSelector === "$lastHost")
|
|
97
|
+
resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
|
|
98
|
+
else if (resolvedSelector === "$firstAppHost")
|
|
99
|
+
resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
|
|
100
|
+
else if (resolvedSelector === "$lastAppHost")
|
|
101
|
+
resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
|
|
102
|
+
else if (resolvedSelector === "$window")
|
|
103
|
+
return [win];
|
|
104
|
+
else if (resolvedSelector === "$document")
|
|
105
|
+
return [win.document];
|
|
106
|
+
else if (resolvedSelector === "$this")
|
|
107
|
+
resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
|
|
61
108
|
else {
|
|
62
|
-
if (r === "
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
109
|
+
if (r === "shadow")
|
|
110
|
+
resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
111
|
+
else if (r === "light")
|
|
112
|
+
resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
|
|
113
|
+
else if (r === "all") {
|
|
114
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
115
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
116
|
+
resolvedElements = [...sNodes, ...lNodes];
|
|
117
|
+
} else
|
|
118
|
+
resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
66
119
|
}
|
|
67
|
-
});
|
|
68
|
-
return results;
|
|
69
|
-
};
|
|
70
|
-
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
71
|
-
if (selector === "$hosts")
|
|
72
|
-
return applyRoot(hostSet.$hosts);
|
|
73
|
-
if (selector === "$appHosts")
|
|
74
|
-
return applyRoot(hostSet.$appHosts);
|
|
75
|
-
if (selector === "$host")
|
|
76
|
-
return applyRoot(hostSet.$host);
|
|
77
|
-
if (selector === "$parentHost")
|
|
78
|
-
return applyRoot(hostSet.$parentHost);
|
|
79
|
-
if (selector === "$appHost")
|
|
80
|
-
return applyRoot(hostSet.$appHost);
|
|
81
|
-
if (selector === "$firstHost")
|
|
82
|
-
return applyRoot(hostSet.$firstHost);
|
|
83
|
-
if (selector === "$lastHost")
|
|
84
|
-
return applyRoot(hostSet.$lastHost);
|
|
85
|
-
if (selector === "$firstAppHost")
|
|
86
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
87
|
-
if (selector === "$lastAppHost")
|
|
88
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
89
|
-
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
90
|
-
const win = config?.window || window;
|
|
91
|
-
if (selector === "$window")
|
|
92
|
-
return [win];
|
|
93
|
-
if (selector === "$document")
|
|
94
|
-
return [win.document];
|
|
95
|
-
if (selector === "$this")
|
|
96
|
-
return applyRoot(this);
|
|
97
|
-
if (r === "shadow")
|
|
98
|
-
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
99
|
-
if (r === "light")
|
|
100
|
-
return Array.from(this.querySelectorAll(selector));
|
|
101
|
-
if (r === "all") {
|
|
102
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
103
|
-
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
104
|
-
return [...sNodes, ...lNodes];
|
|
105
|
-
}
|
|
106
|
-
const root = this.shadowRoot || this;
|
|
107
|
-
return Array.from(root.querySelectorAll(selector));
|
|
108
|
-
},
|
|
109
|
-
set(nv) {
|
|
110
|
-
(0, import_elementDefine.ensureInit)(this);
|
|
111
|
-
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
112
|
-
const selector = selectorOrTarget;
|
|
113
|
-
if (selector.startsWith("$") && selector !== "$this")
|
|
114
|
-
return;
|
|
115
|
-
const r = options.root || "auto";
|
|
116
|
-
let targets = [];
|
|
117
|
-
if (r === "shadow")
|
|
118
|
-
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
119
|
-
else if (r === "light")
|
|
120
|
-
targets = Array.from(this.querySelectorAll(selector));
|
|
121
|
-
else if (r === "all") {
|
|
122
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
123
|
-
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
124
|
-
targets = [...sNodes, ...lNodes];
|
|
125
|
-
} else {
|
|
126
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
127
120
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
121
|
+
if (optionsOrPropertyKey?.filter) {
|
|
122
|
+
resolvedElements = resolvedElements.filter((el) => {
|
|
123
|
+
if (!(el instanceof win.HTMLElement))
|
|
124
|
+
return true;
|
|
125
|
+
return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return resolvedElements;
|
|
129
|
+
},
|
|
130
|
+
set(nv) {
|
|
131
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
132
|
+
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
133
|
+
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
134
|
+
const win = config?.window || window;
|
|
135
|
+
const hostSet = import_Utils.SwcUtils.getHelperAndHostSet(win, this);
|
|
136
|
+
if (typeof selectorOrTarget === "function") {
|
|
137
|
+
const result = selectorOrTarget(this, hostSet);
|
|
138
|
+
if (result instanceof win.NodeList) {
|
|
139
|
+
Array.from(result).forEach((el) => {
|
|
140
|
+
if (el instanceof win.Element)
|
|
141
|
+
el.remove();
|
|
142
|
+
});
|
|
143
|
+
} else if (Array.isArray(result)) {
|
|
144
|
+
result.forEach((el) => {
|
|
145
|
+
if (el instanceof win.Element)
|
|
146
|
+
el.remove();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const resolvedSelector = selectorOrTarget;
|
|
152
|
+
if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
|
|
153
|
+
return;
|
|
154
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
155
|
+
let targets = [];
|
|
156
|
+
if (r === "shadow")
|
|
157
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
158
|
+
else if (r === "light")
|
|
159
|
+
targets = Array.from(this.querySelectorAll(resolvedSelector));
|
|
160
|
+
else if (r === "all") {
|
|
161
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
162
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
163
|
+
targets = [...sNodes, ...lNodes];
|
|
164
|
+
} else {
|
|
165
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
166
|
+
}
|
|
167
|
+
targets.forEach((t) => t.remove());
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
enumerable: true,
|
|
171
|
+
configurable: true
|
|
172
|
+
});
|
|
173
|
+
};
|
|
164
174
|
}
|
|
175
|
+
return queryAll("$this", selectorOrTarget);
|
|
165
176
|
}
|
|
166
177
|
const getQueryAllMetadata = (target) => {
|
|
167
178
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
@@ -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, HelperHostSet } 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
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface QueryAllOptions extends SwcQueryOptions {\n /**\n * Filter function to determine whether to include the element.\n * If it returns false, the element is skipped.\n */\n filter?: (target: HTMLElement, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n}\n\nexport interface QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n options: QueryAllOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');\n\nexport function queryAll(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;\nexport function queryAll(selector: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null), options?: QueryAllOptions): PropertyDecorator;\nexport function queryAll(options?: QueryAllOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n * \n * Supports both string selectors and function-based selectors:\n * - String selector: @queryAll('.item')\n * - Function selector: @queryAll((currentThis, helper) => currentThis.shadowRoot?.querySelectorAll('.item'))\n * \n * Supports filtering:\n * - @queryAll('.item', { filter: (target, meta) => target.hasAttribute('active') })\n */\nexport function queryAll(selectorOrTarget?: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null) | Object, optionsOrPropertyKey?: QueryAllOptions | string | symbol, descriptor?: PropertyDescriptor): any {\n // Bare decorator: @queryAll\n if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {\n throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);\n }\n // With selector\n if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {\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 as any, options: optionsOrPropertyKey as QueryAllOptions || {} });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const config = getElementConfig(this);\n const win = config?.window || window;\n const hostSet = SwcUtils.getHelperAndHostSet(win, this);\n \n // Resolve selector - can be string or function\n let resolvedSelector: string;\n let resolvedElements: HTMLElement[] = [];\n \n if (typeof selectorOrTarget === 'function') {\n const result = (selectorOrTarget as any)(this, hostSet);\n // If function returns NodeList or Element[], convert to array\n if (result instanceof win.NodeList) {\n resolvedElements = Array.from(result).filter(el => el instanceof win.HTMLElement) as HTMLElement[];\n } else if (Array.isArray(result)) {\n resolvedElements = result.filter(el => el instanceof win.HTMLElement) as HTMLElement[];\n }\n } else {\n resolvedSelector = selectorOrTarget;\n\n const r = (optionsOrPropertyKey as QueryAllOptions)?.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 if (resolvedSelector === '$hosts') resolvedElements = applyRoot(hostSet.$hosts).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$appHosts') resolvedElements = applyRoot(hostSet.$appHosts).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$host') resolvedElements = applyRoot(hostSet.$host).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$parentHost') resolvedElements = applyRoot(hostSet.$parentHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$appHost') resolvedElements = applyRoot(hostSet.$appHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$firstHost') resolvedElements = applyRoot(hostSet.$firstHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$lastHost') resolvedElements = applyRoot(hostSet.$lastHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$firstAppHost') resolvedElements = applyRoot(hostSet.$firstAppHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$lastAppHost') resolvedElements = applyRoot(hostSet.$lastAppHost).filter(el => el instanceof HTMLElement);\n // --- Special Selectors: Env ---\n else if (resolvedSelector === '$window') return [win];\n else if (resolvedSelector === '$document') return [win.document];\n else if (resolvedSelector === '$this') resolvedElements = applyRoot(this).filter(el => el instanceof HTMLElement);\n // --- Standard Selectors ---\n else {\n if (r === 'shadow') resolvedElements = this.shadowRoot ? (Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) as HTMLElement[]) : [];\n else if (r === 'light') resolvedElements = Array.from(this.querySelectorAll(resolvedSelector)) as HTMLElement[];\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? (Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) as HTMLElement[]) : [];\n const lNodes = Array.from(this.querySelectorAll(resolvedSelector)) as HTMLElement[];\n resolvedElements = [...sNodes, ...lNodes];\n }\n else resolvedElements = (Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector)) as HTMLElement[]);\n }\n }\n\n // Apply filter if provided\n if ((optionsOrPropertyKey as QueryAllOptions)?.filter) {\n resolvedElements = resolvedElements.filter(el => {\n if (!(el instanceof win.HTMLElement)) return true;\n return (optionsOrPropertyKey as QueryAllOptions).filter!(el, { currentThis: this, helper: hostSet });\n });\n }\n\n return resolvedElements;\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\n const config = getElementConfig(this);\n const win = config?.window || window;\n const hostSet = SwcUtils.getHelperAndHostSet(win, this);\n \n // Resolve selector - can be string or function\n if (typeof selectorOrTarget === 'function') {\n // Get elements from function and remove them\n const result = (selectorOrTarget as any)(this, hostSet);\n if (result instanceof win.NodeList) {\n Array.from(result).forEach(el => {\n if (el instanceof win.Element) (el as Element).remove();\n });\n } else if (Array.isArray(result)) {\n result.forEach(el => {\n if (el instanceof win.Element) (el as Element).remove();\n });\n }\n return;\n }\n \n const resolvedSelector = selectorOrTarget;\n \n if (resolvedSelector.startsWith('$') && resolvedSelector !== '$this') return;\n\n const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(resolvedSelector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];\n const lNodes = Array.from(this.querySelectorAll(resolvedSelector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n }\n // Without selector (defaults to $this)\n return queryAll('$this', selectorOrTarget as SwcQueryOptions);\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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
19
|
__export(subscribeSwcAppMessageWhileConnected_exports, {
|
|
20
20
|
SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY: () => SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
|
|
21
21
|
getSubscribeSwcAppMessageWhileConnectedMetadata: () => getSubscribeSwcAppMessageWhileConnectedMetadata,
|
|
22
|
+
receiveMessage: () => receiveMessage,
|
|
22
23
|
subscribeSwcAppMessageWhileConnected: () => subscribeSwcAppMessageWhileConnected
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(subscribeSwcAppMessageWhileConnected_exports);
|
|
@@ -55,6 +56,7 @@ function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, opti
|
|
|
55
56
|
}
|
|
56
57
|
return createSubscribeSwcAppMessageWhileConnected(options, messageType);
|
|
57
58
|
}
|
|
59
|
+
const receiveMessage = subscribeSwcAppMessageWhileConnected;
|
|
58
60
|
const getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
|
|
59
61
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
60
62
|
return import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/subscribeSwcAppMessageWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAGtB,MAAM,yDAAyD,OAAO,IAAI,gEAAgE;AAYjJ,SAAS,2CAA2C,SAAgC,aAAuC;AACzH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,wDAAwD,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,wDAAwD,MAAM,WAAW;AAAA,IACvG;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,qCAAqC,8BAAoC,sBAA4B,YAAsC;AAEzJ,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,2CAA2C,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,2CAA2C,SAAS,WAAW;AACxE;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\nexport const receiveMessage = subscribeSwcAppMessageWhileConnected;\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAGtB,MAAM,yDAAyD,OAAO,IAAI,gEAAgE;AAYjJ,SAAS,2CAA2C,SAAgC,aAAuC;AACzH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,wDAAwD,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,wDAAwD,MAAM,WAAW;AAAA,IACvG;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,qCAAqC,8BAAoC,sBAA4B,YAAsC;AAEzJ,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,2CAA2C,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,2CAA2C,SAAS,WAAW;AACxE;AAEO,MAAM,iBAAiB;AAEvB,MAAM,kDAAkD,CAAC,WAA+D;AAC7H,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,eAAe,wDAAwD,WAAW;AACxG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var subscribeSwcAppRouteChangeWhileConnected_exports = {};
|
|
19
19
|
__export(subscribeSwcAppRouteChangeWhileConnected_exports, {
|
|
20
20
|
SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY: () => SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY,
|
|
21
|
+
changedRoute: () => changedRoute,
|
|
21
22
|
getSubscribeSwcAppRouteChangeWhileConnectedMetadata: () => getSubscribeSwcAppRouteChangeWhileConnectedMetadata,
|
|
22
23
|
subscribeSwcAppRouteChangeWhileConnected: () => subscribeSwcAppRouteChangeWhileConnected
|
|
23
24
|
});
|
|
@@ -58,6 +59,7 @@ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKeyOr
|
|
|
58
59
|
}
|
|
59
60
|
return createSubscribeSwcAppRouteChangeWhileConnected(options);
|
|
60
61
|
}
|
|
62
|
+
const changedRoute = subscribeSwcAppRouteChangeWhileConnected;
|
|
61
63
|
const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
|
|
62
64
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
63
65
|
const results = import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {Router} from '@dooboostore/core-web';\nimport {HelperHostSet} from '../types';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport type RoutePathType = string | string[] | ((currentThis: any) => string | string[]);\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n options?: SwcAppRouteChangeOptions;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: RoutePathType;\n filter?: (router: Router, meta: {currentThis: any
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAIpB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {Router} from '@dooboostore/core-web';\nimport {HelperHostSet} from '../types';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport type RoutePathType = string | string[] | ((currentThis: any) => string | string[]);\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n options?: SwcAppRouteChangeOptions;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: RoutePathType;\n filter?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => boolean;\n order?: number;\n valueKey?: symbol | string;\n}\n\nfunction createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n\n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType, config: Omit<SwcAppRouteChangeOptions, 'path'>): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKeyOrConfig?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChangeWhileConnected\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKeyOrConfig && (typeof propertyKeyOrConfig === 'string' || typeof propertyKeyOrConfig === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKeyOrConfig, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])\n // \uB610\uB294: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'], { order: 1 })\n options.path = targetOrOptions;\n if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {\n options = { ...options, ...propertyKeyOrConfig };\n }\n } else if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'function') {\n // \uBB38\uC790\uC5F4 \uB610\uB294 \uD568\uC218: @subscribeSwcAppRouteChangeWhileConnected('/path')\n // \uB610\uB294: @subscribeSwcAppRouteChangeWhileConnected('/path', { order: 1 })\n options.path = targetOrOptions;\n if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {\n options = { ...options, ...propertyKeyOrConfig };\n }\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ..., order: 1 })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\nexport const changedRoute = subscribeSwcAppRouteChangeWhileConnected;\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n if (!results) return [];\n \n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAIpB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;AA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AAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -91,6 +91,13 @@ function SwcAppMixin(Base) {
|
|
|
91
91
|
const methodName = metadata.propertyKey;
|
|
92
92
|
let pathPattern = metadata.options?.path;
|
|
93
93
|
const filter = metadata.options?.filter;
|
|
94
|
+
const extractValue = (v) => {
|
|
95
|
+
const keyToUse = metadata.options?.valueKey ?? import_decorators.SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY;
|
|
96
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
97
|
+
return v[keyToUse];
|
|
98
|
+
}
|
|
99
|
+
return v;
|
|
100
|
+
};
|
|
94
101
|
if (typeof pathPattern === "function") {
|
|
95
102
|
pathPattern = pathPattern(instance);
|
|
96
103
|
}
|
|
@@ -115,7 +122,7 @@ function SwcAppMixin(Base) {
|
|
|
115
122
|
const hostSet = import_Utils.SwcUtils.getHelperAndHostSet(this.config.window, this);
|
|
116
123
|
const filterPassed = !filter || filter(this.router, { helper: hostSet, currentThis: instance });
|
|
117
124
|
if (pathMatched && filterPassed && instance[methodName]) {
|
|
118
|
-
const result = await instance[methodName]({ ...re, pathData });
|
|
125
|
+
const result = extractValue(await instance[methodName]({ ...re, pathData }));
|
|
119
126
|
if (result !== void 0 && result !== null) {
|
|
120
127
|
break;
|
|
121
128
|
}
|
|
@@ -230,7 +237,15 @@ function SwcAppMixin(Base) {
|
|
|
230
237
|
context: this,
|
|
231
238
|
args: import_Utils.SwcUtils.getHelperAndHostSet(win, this)
|
|
232
239
|
});
|
|
233
|
-
|
|
240
|
+
if (userConfig instanceof Promise) {
|
|
241
|
+
userConfig.then((resolvedConfig) => {
|
|
242
|
+
this.connect(resolvedConfig);
|
|
243
|
+
}).catch((e) => {
|
|
244
|
+
console.error("[SWC-MIXIN] Script execution failed:", e);
|
|
245
|
+
});
|
|
246
|
+
} else {
|
|
247
|
+
this.connect(userConfig);
|
|
248
|
+
}
|
|
234
249
|
} catch (e) {
|
|
235
250
|
console.error("[SWC-MIXIN] Script execution failed:", e);
|
|
236
251
|
}
|