@dooboostore/simple-web-component 1.0.32 → 1.0.34
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 +280 -43
- package/dist/cjs/decorators/addEventListener.js.map +1 -1
- package/dist/cjs/decorators/applyAttribute.js +67 -57
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +80 -70
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +1 -8
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +66 -56
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +35 -29
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +32 -12
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +29 -16
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +57 -44
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +3 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +86 -0
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +7 -0
- package/dist/cjs/decorators/setProperty.js +50 -39
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +62 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
- package/dist/cjs/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +16 -16
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
- package/dist/cjs/elements/SwcAppEngine.js +7 -7
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +90 -43
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +19 -15
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/register.js +21 -16
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +7 -3
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js.map +1 -1
- package/dist/esm/decorators/applyAttribute.js +67 -57
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +80 -70
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +1 -8
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +66 -56
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +35 -29
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +32 -12
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +30 -17
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +57 -44
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +3 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/publishSwcAppMessage.js +67 -0
- package/dist/esm/decorators/publishSwcAppMessage.js.map +7 -0
- package/dist/esm/decorators/setProperty.js +50 -39
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +43 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
- package/dist/esm/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +13 -13
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
- package/dist/esm/elements/SwcAppEngine.js +6 -6
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +90 -43
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +20 -16
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/register.js +22 -17
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +7 -3
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +543 -348
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +4 -1
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +5 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +4 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +4 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +5 -1
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts +13 -3
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +5 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +3 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +13 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -0
- package/dist/types/decorators/setProperty.d.ts +5 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +16 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +18 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -0
- package/dist/types/elements/SwcAppEngine.d.ts +6 -3
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +8 -3
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +543 -348
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +74 -61
- package/src/decorators/applyClass.ts +91 -77
- package/src/decorators/applyNode.ts +3 -12
- package/src/decorators/applyStyle.ts +75 -61
- package/src/decorators/attribute.ts +55 -43
- package/src/decorators/changedAttributeHost.ts +47 -14
- package/src/decorators/elementDefine.ts +38 -19
- package/src/decorators/emitCustomEvent.ts +65 -49
- package/src/decorators/index.ts +3 -1
- package/src/decorators/publishSwcAppMessage.ts +100 -0
- package/src/decorators/setProperty.ts +58 -44
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +73 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +71 -0
- package/src/elements/SwcAppEngine.ts +11 -12
- package/src/elements/SwcAppMixin.ts +115 -44
- package/src/elements/SwcChoose.ts +28 -7
- package/src/elements/register.ts +28 -7
- package/src/types.ts +8 -0
- package/src/utils/Utils.ts +15 -5
- package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +0 -7
- package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +0 -7
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +0 -18
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +0 -1
- package/src/decorators/subscribeSwcAppRouteChange.ts +0 -71
|
@@ -2,13 +2,22 @@ import { SwcAppEngine } from "./SwcAppEngine.js";
|
|
|
2
2
|
import { SwcUtils } from "../utils/Utils.js";
|
|
3
3
|
import { FunctionUtils } from "@dooboostore/core";
|
|
4
4
|
import { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from "../decorators/lifecycles.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getSubscribeSwcAppRouteChangeWhileConnectedMetadata } from "../decorators/subscribeSwcAppRouteChangeWhileConnected.js";
|
|
6
|
+
import { getSubscribeSwcAppMessageWhileConnectedMetadata } from "../decorators/subscribeSwcAppMessageWhileConnected.js";
|
|
6
7
|
function SwcAppMixin(Base) {
|
|
7
8
|
return class extends Base {
|
|
8
9
|
constructor() {
|
|
9
10
|
super(...arguments);
|
|
10
11
|
this.__swc_engine = new SwcAppEngine(this);
|
|
11
12
|
this._swc_connected_instance = /* @__PURE__ */ new Set();
|
|
13
|
+
this._swc_started_instances = /* @__PURE__ */ new WeakSet();
|
|
14
|
+
this._swc_notified_routes = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
/*
|
|
16
|
+
사파리 is 일경우
|
|
17
|
+
<script src="https://unpkg.com/@ungap/custom-elements"><\/script>
|
|
18
|
+
이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
|
|
19
|
+
저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
|
|
20
|
+
*/
|
|
12
21
|
this._connected_safari = [];
|
|
13
22
|
}
|
|
14
23
|
get simpleApplication() {
|
|
@@ -17,11 +26,13 @@ function SwcAppMixin(Base) {
|
|
|
17
26
|
get router() {
|
|
18
27
|
return this.__swc_engine.router;
|
|
19
28
|
}
|
|
20
|
-
_invokeRouteChangeSubscribers(instance, re) {
|
|
21
|
-
|
|
29
|
+
async _invokeRouteChangeSubscribers(instance, re) {
|
|
30
|
+
if (this._swc_notified_routes.get(instance) === re) return;
|
|
31
|
+
this._swc_notified_routes.set(instance, re);
|
|
32
|
+
const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
|
|
22
33
|
if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
|
|
23
|
-
routeChangeSubscribers.
|
|
24
|
-
const methodName = metadata.propertyKey
|
|
34
|
+
const ps = routeChangeSubscribers.map(async (metadata) => {
|
|
35
|
+
const methodName = metadata.propertyKey;
|
|
25
36
|
const pathPattern = metadata.pathPattern;
|
|
26
37
|
const filter = metadata.filter;
|
|
27
38
|
let pathMatched = false;
|
|
@@ -42,11 +53,12 @@ function SwcAppMixin(Base) {
|
|
|
42
53
|
pathData = SwcUtils.parsePathPattern(pathPattern, re.path || "/");
|
|
43
54
|
pathMatched = pathData !== null;
|
|
44
55
|
}
|
|
45
|
-
const filterPassed = !filter || filter(this.router);
|
|
46
|
-
if (pathMatched && filterPassed) {
|
|
47
|
-
instance[methodName]
|
|
56
|
+
const filterPassed = !filter || filter(this.router, instance);
|
|
57
|
+
if (pathMatched && filterPassed && instance[methodName]) {
|
|
58
|
+
await instance[methodName]({ ...re, pathData });
|
|
48
59
|
}
|
|
49
60
|
});
|
|
61
|
+
return await Promise.allSettled(ps);
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
_connected(instance) {
|
|
@@ -63,15 +75,17 @@ function SwcAppMixin(Base) {
|
|
|
63
75
|
_disconnected(instance) {
|
|
64
76
|
if (instance) {
|
|
65
77
|
this._swc_connected_instance.delete(instance);
|
|
78
|
+
this._swc_started_instances.delete(instance);
|
|
79
|
+
this._swc_notified_routes.delete(instance);
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
|
-
_handleRouteChange(route) {
|
|
82
|
+
async _handleRouteChange(route) {
|
|
83
|
+
this._lastRouterEvent = route;
|
|
69
84
|
if (route.triggerPoint === "end") {
|
|
70
|
-
this._swc_connected_instance
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
const swcConnectedInstance = Array.from(this._swc_connected_instance);
|
|
86
|
+
const ps = swcConnectedInstance.map((instance) => this._invokeRouteChangeSubscribers(instance, route));
|
|
87
|
+
await Promise.allSettled(ps);
|
|
73
88
|
}
|
|
74
|
-
this._lastRouterEvent = route;
|
|
75
89
|
}
|
|
76
90
|
async connect(config) {
|
|
77
91
|
const swcConfig = {
|
|
@@ -83,50 +97,56 @@ function SwcAppMixin(Base) {
|
|
|
83
97
|
if (mode === "direct") {
|
|
84
98
|
await this.__swc_engine.connect(swcConfig);
|
|
85
99
|
this.setAttribute("swc-connect-mode", "direct");
|
|
86
|
-
} else if (mode === "swap"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
} else if (mode === "swap" || mode === "clear-swap") {
|
|
101
|
+
if (!this.parentNode) {
|
|
102
|
+
await this.__swc_engine.connect(swcConfig);
|
|
103
|
+
this.setAttribute("swc-connect-mode", "direct");
|
|
104
|
+
} else {
|
|
105
|
+
const clonedApp = this.cloneNode(mode === "swap");
|
|
106
|
+
clonedApp.style.display = "none";
|
|
107
|
+
this.parentNode.insertBefore(clonedApp, this.nextSibling);
|
|
108
|
+
try {
|
|
109
|
+
await clonedApp.connect({ ...config || {}, connectMode: "direct" });
|
|
110
|
+
if (this.parentNode) {
|
|
111
|
+
this.parentNode.removeChild(this);
|
|
112
|
+
}
|
|
113
|
+
clonedApp.style.display = "";
|
|
114
|
+
clonedApp.setAttribute("swc-connect-mode", mode);
|
|
115
|
+
return;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
if (clonedApp.parentNode) {
|
|
118
|
+
clonedApp.parentNode.removeChild(clonedApp);
|
|
119
|
+
}
|
|
120
|
+
await this.__swc_engine.connect(swcConfig);
|
|
121
|
+
this.setAttribute("swc-connect-mode", "direct");
|
|
102
122
|
}
|
|
103
|
-
throw e;
|
|
104
123
|
}
|
|
105
124
|
}
|
|
106
125
|
this._connected_safari.forEach((instance) => {
|
|
107
126
|
this._swc_connected_instance.add(instance);
|
|
108
127
|
});
|
|
109
|
-
this._swc_connected_instance
|
|
110
|
-
|
|
111
|
-
});
|
|
128
|
+
const scis = Array.from(this._swc_connected_instance);
|
|
129
|
+
await Promise.allSettled(scis.map((instance) => this._invokeOnConnectedSwcAppStarted(instance)));
|
|
112
130
|
if (!this._routerSubscription && this.router) {
|
|
131
|
+
const config2 = this.__swc_engine.config;
|
|
113
132
|
this._routerSubscription = this.router.observable.subscribe((route) => {
|
|
114
|
-
this._handleRouteChange(route)
|
|
133
|
+
this._handleRouteChange(route).then((it) => {
|
|
134
|
+
config2?.onRouteChanged?.(route, this);
|
|
135
|
+
});
|
|
115
136
|
});
|
|
116
|
-
const config2 = this.__swc_engine.config;
|
|
117
137
|
}
|
|
118
138
|
}
|
|
119
|
-
_invokeOnConnectedSwcAppStarted(instance) {
|
|
139
|
+
async _invokeOnConnectedSwcAppStarted(instance) {
|
|
140
|
+
if (this._swc_started_instances.has(instance)) return;
|
|
141
|
+
this._swc_started_instances.add(instance);
|
|
120
142
|
const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
121
143
|
if (startedMethods) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
144
|
+
const ps = startedMethods.map((m) => instance._invokeLifecycleMethod(m));
|
|
145
|
+
return await Promise.allSettled(ps);
|
|
125
146
|
}
|
|
126
147
|
}
|
|
127
148
|
connectedCallback() {
|
|
128
|
-
if (super.connectedCallback)
|
|
129
|
-
super.connectedCallback();
|
|
149
|
+
if (super.connectedCallback) super.connectedCallback();
|
|
130
150
|
const configStr = this.getAttribute("swc-get-application-config");
|
|
131
151
|
const win = this.ownerDocument?.defaultView || window;
|
|
132
152
|
if (configStr && win) {
|
|
@@ -144,8 +164,7 @@ function SwcAppMixin(Base) {
|
|
|
144
164
|
this.__swc_engine?.config?.onConnected?.(this);
|
|
145
165
|
}
|
|
146
166
|
disconnectedCallback() {
|
|
147
|
-
if (super.disconnectedCallback)
|
|
148
|
-
super.disconnectedCallback();
|
|
167
|
+
if (super.disconnectedCallback) super.disconnectedCallback();
|
|
149
168
|
this._routerSubscription?.unsubscribe();
|
|
150
169
|
this._routerSubscription = void 0;
|
|
151
170
|
this._lastRouterEvent = void 0;
|
|
@@ -164,6 +183,34 @@ function SwcAppMixin(Base) {
|
|
|
164
183
|
reload() {
|
|
165
184
|
this.router?.reload();
|
|
166
185
|
}
|
|
186
|
+
publishMessage(message) {
|
|
187
|
+
this._swc_connected_instance.forEach((instance) => {
|
|
188
|
+
this._invokeMessageSubscribers(instance, message);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
_invokeMessageSubscribers(instance, message) {
|
|
192
|
+
const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);
|
|
193
|
+
if (messageSubscribers && Array.isArray(messageSubscribers)) {
|
|
194
|
+
messageSubscribers.forEach((metadata) => {
|
|
195
|
+
const methodName = metadata.propertyKey;
|
|
196
|
+
const messageType = metadata.messageType;
|
|
197
|
+
const filter = metadata.filter;
|
|
198
|
+
let typeMatched = false;
|
|
199
|
+
if (!messageType) {
|
|
200
|
+
typeMatched = true;
|
|
201
|
+
} else if (message.type === messageType) {
|
|
202
|
+
typeMatched = true;
|
|
203
|
+
}
|
|
204
|
+
let filterMatched = true;
|
|
205
|
+
if (filter && typeMatched) {
|
|
206
|
+
filterMatched = filter(message, instance);
|
|
207
|
+
}
|
|
208
|
+
if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
|
|
209
|
+
instance[methodName](message);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
167
214
|
};
|
|
168
215
|
}
|
|
169
216
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/SwcAppMixin.ts"],
|
|
4
|
-
"sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from './SwcAppEngine';\nimport { SwcAppInterface } from '../types';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, Subscription } from '@dooboostore/core';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from '../decorators/lifecycles';\nimport { getSubscribeSwcAppRouteChangeMetadata } from '../decorators/subscribeSwcAppRouteChange';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n //@ts-ignore\n return class extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n /*\n 사파리 is 일경우\n <script src=\"https://unpkg.com/@ungap/custom-elements\"></script>\n 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데\n 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다\n */\n _connected_safari = [];\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n routeChangeSubscribers.forEach((metadata: any) => {\n const methodName = metadata.propertyKey || metadata;\n const pathPattern = metadata.pathPattern;\n const filter = metadata.filter;\n\n // Path pattern matching (support both string and array)\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n // pathPattern이 없으면 모든 경로 매칭 (와일드카드)\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n // 배열: 하나라도 매칭되면 OK\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n // 문자열\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n // Filter validation\n const filterPassed = !filter || filter(this.router!);\n\n // Invoke method if conditions pass\n if (pathMatched && filterPassed) {\n instance[methodName]?.({...re, pathData: pathData});\n }\n });\n }\n }\n\n _connected(instance: any) {\n // console.log('appmixin--> connected', this, instance);\n if (instance) {\n this._swc_connected_instance.add(instance);\n if (this.simpleApplication) {\n this._invokeOnConnectedSwcAppStarted(instance);\n // Notify current route subscribers immediately after connection\n if (this.router && this._lastRouterEvent) {\n this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);\n }\n }\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n }\n }\n\n _handleRouteChange(route: RouterEventType) {\n if (route.triggerPoint === 'end') {\n // Iterate through all connected component instances\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeRouteChangeSubscribers(instance, route);\n });\n }\n\n // Save last router event\n this._lastRouterEvent = route;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const swcConfig = {\n routeType: 'element',\n window: config.window,\n ...config\n } as SwcConfigType;\n\n const mode = config?.connectMode || 'direct';\n\n if (mode === 'direct') {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else if (mode === 'swap' && !this.parentNode) {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n this.parentNode.insertBefore(clonedApp, this.nextSibling);\n\n try {\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.setAttribute('swc-connect-mode', 'swap');\n clonedApp.style.display = '';\n } catch (e) {\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n throw e;\n }\n }\n\n // 사파리일떄 예외이다 is 일때 polyfill되는데 이떄 부모부터 만들어지는게 아니라 자식부터 만들어진다 그래서 부모가 만들어질때 자식들이 이미 만들어져있어서 부모가 자식들을 등록해주는 형태로 강제로 등록해준다\n this._connected_safari.forEach((instance: any) => {\n this._swc_connected_instance.add(instance);\n });\n // Invoke @onConnectedSwcApp lifecycle methods on all connected component instances\n // const hostSet = SwcUtils.getHostSet(this as any);\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeOnConnectedSwcAppStarted(instance);\n });\n\n\n // Subscribe to router changes after connect\n if (!this._routerSubscription && this.router) {\n this._routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n //@ts-ignore\n // console.log('Route changed:', route, this._swcId);\n this._handleRouteChange(route);\n });\n // Navigate to initial path if specified\n const config = this.__swc_engine.config;\n // if (config?.path) {\n // this.router.go(config.path);\n // }\n }\n }\n\n _invokeOnConnectedSwcAppStarted(instance: any) {\n const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n if (startedMethods) {\n for (const m of startedMethods) {\n instance._invokeLifecycleMethod(m);\n }\n }\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n // console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n this.connect(userConfig);\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n\n this.__swc_engine?.config?.onConnected?.(this);\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAA2D;AAEpE,SAAS,gBAAgB;AACzB,SAAS,qBAAmC;AAE5C,SAAS,mCAAmC,gCAAgC;AAC5E,SAAS,
|
|
4
|
+
"sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from './SwcAppEngine';\nimport { SwcAppInterface, SwcAppMessage } from '../types';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, Subscription } from '@dooboostore/core';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from '../decorators/lifecycles';\nimport { getSubscribeSwcAppRouteChangeWhileConnectedMetadata } from '../decorators/subscribeSwcAppRouteChangeWhileConnected';\nimport { getSubscribeSwcAppMessageWhileConnectedMetadata } from '../decorators/subscribeSwcAppMessageWhileConnected';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n //@ts-ignore\n return class extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _swc_started_instances = new WeakSet<any>();\n _swc_notified_routes = new WeakMap<any, RouterEventType>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n /*\n \uC0AC\uD30C\uB9AC is \uC77C\uACBD\uC6B0\n <script src=\"https://unpkg.com/@ungap/custom-elements\"></script>\n \uC774\uAC78\uC0AC\uC6A9\uD558\uB294\uB370 is \uB300\uC751\uD558\uB294\uAC70\uB2E4 \uADF8\uB7F0\uB370 \uC774\uB54C \uCC98\uB9AC\uB418\uB294 \uC21C\uC11C\uAC00 \uD06C\uB86C\uC774\uB098 \uD45C\uC900\uC5D0\uC11C\uB294 \uBD80\uBAA8\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uACE0 \uC790\uC2DD\uB4E4\uC774 \uB9CC\uB4E4\uC5B4\uC9C0\uB294\uB370\n \uC800 polyfill\uC5D0\uC11C\uB294 \uC790\uC2DD\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uACE0 \uBD80\uBAA8\uAC00 \uB9CC\uB4E4\uC5B4\uC9C4\uB2E4 is\uC77C\uB54C \uC544 .. \uC774\uBB38\uC81C\uB54C\uBB38\uC5D0 \uC790\uC2DD\uC774 _connected_safari \uC5D0 \uAC15\uC81C\uB85C \uC790\uAE30\uC790\uC2DD\uB123\uC5B4\uC900\uB2E4\n */\n _connected_safari = [];\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n async _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n // \uC774\uBBF8 \uC774 \uB77C\uC6B0\uD2B8 \uC774\uBCA4\uD2B8\uC5D0 \uB300\uD574 \uCC98\uB9AC\uB41C \uC778\uC2A4\uD134\uC2A4\uB77C\uBA74 \uC2A4\uD0B5 (\uB3D9\uC2DC\uC131/\uC911\uBCF5 \uBC29\uC9C0)\n if (this._swc_notified_routes.get(instance) === re) return;\n this._swc_notified_routes.set(instance, re);\n\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n const ps = routeChangeSubscribers.map(async metadata => {\n const methodName = metadata.propertyKey;\n const pathPattern = metadata.pathPattern;\n const filter = metadata.filter;\n\n // Path pattern matching (support both string and array)\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n // pathPattern\uC774 \uC5C6\uC73C\uBA74 \uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D (\uC640\uC77C\uB4DC\uCE74\uB4DC)\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n // \uBC30\uC5F4: \uD558\uB098\uB77C\uB3C4 \uB9E4\uCE6D\uB418\uBA74 OK\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n // \uBB38\uC790\uC5F4\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n // Filter validation\n const filterPassed = !filter || filter(this.router!, instance);\n\n // Invoke method if conditions pass\n if (pathMatched && filterPassed && instance[methodName]) {\n await instance[methodName]({ ...re, pathData: pathData });\n }\n });\n return await Promise.allSettled(ps);\n }\n }\n\n _connected(instance: any) {\n // console.log('appmixin--> connected', this, instance);\n if (instance) {\n this._swc_connected_instance.add(instance);\n if (this.simpleApplication) {\n this._invokeOnConnectedSwcAppStarted(instance);\n // Notify current route subscribers immediately after connection\n if (this.router && this._lastRouterEvent) {\n this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);\n }\n }\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n this._swc_started_instances.delete(instance);\n this._swc_notified_routes.delete(instance);\n }\n }\n\n async _handleRouteChange(route: RouterEventType) {\n // Save last router event\n this._lastRouterEvent = route;\n if (route.triggerPoint === 'end') {\n // Iterate through all connected component instances\n const swcConnectedInstance = Array.from(this._swc_connected_instance);\n const ps = swcConnectedInstance.map((instance: any) => this._invokeRouteChangeSubscribers(instance, route));\n await Promise.allSettled(ps);\n }\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const swcConfig = {\n routeType: 'element',\n window: config.window,\n ...config\n } as SwcConfigType;\n\n const mode = config?.connectMode || 'direct';\n\n // console.log('-------mode', mode);\n if (mode === 'direct') {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else if (mode === 'swap' || mode === 'clear-swap') {\n if (!this.parentNode) {\n // \uBD80\uBAA8\uAC00 \uC5C6\uC73C\uBA74 swap\uC744 \uD560 \uC218 \uC5C6\uC73C\uBBC0\uB85C direct\uB85C \uD3F4\uBC31\uD569\uB2C8\uB2E4.\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else {\n // 1. \uD604\uC7AC SSR \uC0C1\uD0DC(\uD654\uBA74)\uB97C \uADF8\uB300\uB85C \uC720\uC9C0\uD55C \uCC44\uB85C, \uBC31\uADF8\uB77C\uC6B4\uB4DC\uC6A9 \uD074\uB860\uC744 \uB9CC\uB4ED\uB2C8\uB2E4.\n const clonedApp = this.cloneNode(mode === 'swap') as any; // clear-swap \uBAA8\uB4DC\uBA74 \uC790\uC2DD \uB178\uB4DC\uB97C \uD074\uB860\uD558\uC9C0 \uC54A\uC74C(false)\n clonedApp.style.display = 'none';\n \n // 2. DOM\uC5D0 \uD074\uB860\uC744 \uBAB0\uB798 \uBD99\uC785\uB2C8\uB2E4.\n this.parentNode.insertBefore(clonedApp, this.nextSibling);\n\n try {\n // 3. \uD074\uB860\uC744 direct \uBAA8\uB4DC\uB85C \uC5F0\uACB0(\uCD08\uAE30\uD654/\uB80C\uB354\uB9C1) \uC2DC\uD0B5\uB2C8\uB2E4.\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n \n // 4. \uD074\uB860\uC758 \uB80C\uB354\uB9C1\uC774 \uC644\uC804\uD788 \uB05D\uB098\uBA74, \uAE30\uC874 SSR \uD654\uBA74(this)\uC744 \uC9C0\uC6B0\uACE0 \uD074\uB860\uC744 \uBCF4\uC5EC\uC90D\uB2C8\uB2E4.\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.style.display = '';\n clonedApp.setAttribute('swc-connect-mode', mode);\n \n // \u2605 \uB9E4\uC6B0 \uC911\uC694: \uAD50\uCCB4\uAC00 \uC644\uB8CC\uB418\uC5C8\uC73C\uBBC0\uB85C \uAE30\uC874 \uC571(this)\uC740 \uC5EC\uAE30\uC11C \uC989\uC2DC \uC885\uB8CC\uD558\uC5EC \uBD88\uD544\uC694\uD55C \uB77C\uC6B0\uD130/\uC774\uBCA4\uD2B8 \uAD6C\uB3C5\uC744 \uB9C9\uC544\uC57C \uD569\uB2C8\uB2E4!\n return;\n } catch (e) {\n // \uC2E4\uD328 \uC2DC \uD074\uB860\uC744 \uC9C0\uC6B0\uACE0 \uC6D0\uBCF8\uC744 direct\uB85C \uAC15\uC81C \uC5F0\uACB0\uD569\uB2C8\uB2E4.\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n }\n }\n }\n\n // \uC0AC\uD30C\uB9AC\uC77C\uB584 \uC608\uC678\uC774\uB2E4 is \uC77C\uB54C polyfill\uB418\uB294\uB370 \uC774\uB584 \uBD80\uBAA8\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uB294\uAC8C \uC544\uB2C8\uB77C \uC790\uC2DD\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C4\uB2E4 \uADF8\uB798\uC11C \uBD80\uBAA8\uAC00 \uB9CC\uB4E4\uC5B4\uC9C8\uB54C \uC790\uC2DD\uB4E4\uC774 \uC774\uBBF8 \uB9CC\uB4E4\uC5B4\uC838\uC788\uC5B4\uC11C \uBD80\uBAA8\uAC00 \uC790\uC2DD\uB4E4\uC744 \uB4F1\uB85D\uD574\uC8FC\uB294 \uD615\uD0DC\uB85C \uAC15\uC81C\uB85C \uB4F1\uB85D\uD574\uC900\uB2E4\n this._connected_safari.forEach((instance: any) => {\n this._swc_connected_instance.add(instance);\n });\n // Invoke @onConnectedSwcApp lifecycle methods on all connected component instances\n // const hostSet = SwcUtils.getHostSet(this as any);\n const scis = Array.from(this._swc_connected_instance);\n await Promise.allSettled(scis.map(instance => this._invokeOnConnectedSwcAppStarted(instance)));\n // this._swc_connected_instance.forEach((instance: any) => {\n // this._invokeOnConnectedSwcAppStarted(instance);\n // });\n\n // Subscribe to router changes after connect\n if (!this._routerSubscription && this.router) {\n const config = this.__swc_engine.config;\n this._routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n //@ts-ignore\n // console.log('Route changed:', route, this._swcId);\n this._handleRouteChange(route).then(it => {\n config?.onRouteChanged?.(route, this);\n });\n });\n // Navigate to initial path if specified\n // if (config?.path) {\n // this.router.go(config.path);\n // }\n }\n }\n\n async _invokeOnConnectedSwcAppStarted(instance: any) {\n // \uC774\uBBF8 \uC2DC\uC791\uB41C \uC778\uC2A4\uD134\uC2A4\uB77C\uBA74 \uC2A4\uD0B5 (\uBE44\uB3D9\uAE30 \uBCD1\uB82C \uC911\uBCF5 \uD638\uCD9C \uBC29\uC9C0)\n if (this._swc_started_instances.has(instance)) return;\n this._swc_started_instances.add(instance);\n\n const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n if (startedMethods) {\n const ps = startedMethods.map(m => instance._invokeLifecycleMethod(m));\n return await Promise.allSettled(ps)\n // for (const m of startedMethods) {\n // instance._invokeLifecycleMethod(m);\n // }\n }\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n // console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n this.connect(userConfig);\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n\n this.__swc_engine?.config?.onConnected?.(this);\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n\n publishMessage(message: SwcAppMessage): void {\n // \uBA54\uC2DC\uC9C0\uB97C \uBAA8\uB4E0 connected component instances\uB85C \uBD84\uBC30\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeMessageSubscribers(instance, message);\n });\n }\n\n _invokeMessageSubscribers(instance: any, message: SwcAppMessage) {\n const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);\n if (messageSubscribers && Array.isArray(messageSubscribers)) {\n messageSubscribers.forEach(metadata => {\n const methodName = metadata.propertyKey;\n const messageType = metadata.messageType;\n const filter = metadata.filter;\n\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uD655\uC778\n let typeMatched = false;\n if (!messageType) {\n // messageType\uC774 \uC5C6\uC73C\uBA74 \uBAA8\uB4E0 \uBA54\uC2DC\uC9C0 \uB9E4\uCE6D (\uC640\uC77C\uB4DC\uCE74\uB4DC)\n typeMatched = true;\n } else if (message.type === messageType) {\n typeMatched = true;\n }\n\n // \uD544\uD130 \uC801\uC6A9\n let filterMatched = true;\n if (filter && typeMatched) {\n filterMatched = filter(message, instance);\n }\n\n // \uC870\uAC74\uC744 \uB9CC\uC871\uD558\uBA74 \uBA54\uC11C\uB4DC \uD638\uCD9C\n if (typeMatched && filterMatched && typeof instance[methodName] === 'function') {\n instance[methodName](message);\n }\n });\n }\n }\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAA2D;AAEpE,SAAS,gBAAgB;AACzB,SAAS,qBAAmC;AAE5C,SAAS,mCAAmC,gCAAgC;AAC5E,SAAS,2DAA2D;AACpE,SAAS,uDAAuD;AAEzD,SAAS,YAA6D,MAAS;AAEpF,SAAO,cAAc,KAAgC;AAAA,IAA9C;AAAA;AACL,0BAAe,IAAI,aAAa,IAAW;AAC3C,qCAA0B,oBAAI,IAAS;AACvC,oCAAyB,oBAAI,QAAa;AAC1C,kCAAuB,oBAAI,QAA8B;AAUzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoB,CAAC;AAAA;AAAA,IACrB,IAAI,oBAAoB;AACtB,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,IAAI,SAAS;AACX,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IAEA,MAAM,8BAA8B,UAAe,IAAqB;AAEtE,UAAI,KAAK,qBAAqB,IAAI,QAAQ,MAAM,GAAI;AACpD,WAAK,qBAAqB,IAAI,UAAU,EAAE;AAE1C,YAAM,yBAAyB,oDAAoD,QAAQ;AAC3F,UAAI,0BAA0B,MAAM,QAAQ,sBAAsB,GAAG;AACnE,cAAM,KAAK,uBAAuB,IAAI,OAAM,aAAY;AACtD,gBAAM,aAAa,SAAS;AAC5B,gBAAM,cAAc,SAAS;AAC7B,gBAAM,SAAS,SAAS;AAGxB,cAAI,cAAc;AAClB,cAAI,WAAgB;AAEpB,cAAI,CAAC,aAAa;AAEhB,0BAAc;AACd,uBAAW,CAAC;AAAA,UACd,WAAW,MAAM,QAAQ,WAAW,GAAG;AAErC,uBAAW,WAAW,aAAa;AACjC,oBAAM,OAAO,SAAS,iBAAiB,SAAS,GAAG,QAAQ,GAAG;AAC9D,kBAAI,SAAS,MAAM;AACjB,8BAAc;AACd,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;AAAA,IAEA,SAAe;AACb,WAAK,QAAQ,OAAO;AAAA,IACtB;AAAA,IAEA,eAAe,SAA8B;AAE3C,WAAK,wBAAwB,QAAQ,CAAC,aAAkB;AACtD,aAAK,0BAA0B,UAAU,OAAO;AAAA,MAClD,CAAC;AAAA,IACH;AAAA,IAEA,0BAA0B,UAAe,SAAwB;AAC/D,YAAM,qBAAqB,gDAAgD,QAAQ;AACnF,UAAI,sBAAsB,MAAM,QAAQ,kBAAkB,GAAG;AAC3D,2BAAmB,QAAQ,cAAY;AACrC,gBAAM,aAAa,SAAS;AAC5B,gBAAM,cAAc,SAAS;AAC7B,gBAAM,SAAS,SAAS;AAGxB,cAAI,cAAc;AAClB,cAAI,CAAC,aAAa;AAEhB,0BAAc;AAAA,UAChB,WAAW,QAAQ,SAAS,aAAa;AACvC,0BAAc;AAAA,UAChB;AAGA,cAAI,gBAAgB;AACpB,cAAI,UAAU,aAAa;AACzB,4BAAgB,OAAO,SAAS,QAAQ;AAAA,UAC1C;AAGA,cAAI,eAAe,iBAAiB,OAAO,SAAS,UAAU,MAAM,YAAY;AAC9E,qBAAS,UAAU,EAAE,OAAO;AAAA,UAC9B;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["config"]
|
|
7
7
|
}
|
|
@@ -11,21 +11,28 @@ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
|
|
|
11
11
|
import { SwcUtils } from "../utils/Utils.js";
|
|
12
12
|
import { FunctionUtils, ActionExpression } from "@dooboostore/core";
|
|
13
13
|
import { ConvertUtils } from "@dooboostore/core-web";
|
|
14
|
-
import { attributeHost } from "../decorators/index.js";
|
|
14
|
+
import { attributeHost, getAttributeValue, getElementConfig } from "../decorators/index.js";
|
|
15
15
|
class SwcChoose extends HTMLTemplateElement {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this._nodes = [];
|
|
19
|
-
this._previousTemplate = null;
|
|
20
|
-
}
|
|
21
16
|
get value() {
|
|
22
17
|
return this._value;
|
|
23
18
|
}
|
|
24
19
|
set value(nv) {
|
|
25
|
-
this.
|
|
20
|
+
this._value = nv;
|
|
21
|
+
this.refresh(this._value);
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this._nodes = [];
|
|
26
|
+
this._previousTemplate = null;
|
|
27
|
+
}
|
|
28
|
+
// static get observedAttributes() {
|
|
29
|
+
// return ['value'];
|
|
30
|
+
// }
|
|
31
|
+
attributeChangedCallback(na, o, n) {
|
|
32
|
+
}
|
|
33
|
+
setValue(value, o, n) {
|
|
34
|
+
this._value = value;
|
|
35
|
+
this.refresh(this._value);
|
|
29
36
|
}
|
|
30
37
|
setReplaceWrap(replaceWrapAttr) {
|
|
31
38
|
this.refresh();
|
|
@@ -49,11 +56,12 @@ class SwcChoose extends HTMLTemplateElement {
|
|
|
49
56
|
}
|
|
50
57
|
return ae.getUnprocessedTemplate();
|
|
51
58
|
}
|
|
52
|
-
refresh(value
|
|
59
|
+
refresh(value) {
|
|
60
|
+
value = getAttributeValue(this, "value") ?? this._value;
|
|
53
61
|
const portal = this.parentElement;
|
|
54
62
|
if (!portal)
|
|
55
63
|
return;
|
|
56
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
64
|
+
const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;
|
|
57
65
|
const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
58
66
|
const groupArgs = { ...helperSet, $value: value };
|
|
59
67
|
const templates = Array.from(this.content.querySelectorAll("template"));
|
|
@@ -109,10 +117,6 @@ class SwcChoose extends HTMLTemplateElement {
|
|
|
109
117
|
this.cleanup();
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
|
-
__decorate([
|
|
113
|
-
attributeHost("value"),
|
|
114
|
-
__metadata("design:type", Object)
|
|
115
|
-
], SwcChoose.prototype, "_value", void 0);
|
|
116
120
|
__decorate([
|
|
117
121
|
attributeHost("replace-wrap"),
|
|
118
122
|
__metadata("design:type", String)
|
|
@@ -120,7 +124,7 @@ __decorate([
|
|
|
120
124
|
__decorate([
|
|
121
125
|
changedAttributeHost("value"),
|
|
122
126
|
__metadata("design:type", Function),
|
|
123
|
-
__metadata("design:paramtypes", []),
|
|
127
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
124
128
|
__metadata("design:returntype", void 0)
|
|
125
129
|
], SwcChoose.prototype, "setValue", null);
|
|
126
130
|
__decorate([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/SwcChoose.ts"],
|
|
4
|
-
"sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ConvertUtils } from '@dooboostore/core-web';\nimport { SwcChooseInterface } from '../types';\nimport { attributeHost } from '../decorators';\n\nclass SwcChoose extends HTMLTemplateElement implements SwcChooseInterface {\n @attributeHost('value')\n _value: any;\n\n @attributeHost('replace-wrap')\n _replaceWrap: string | null;\n\n private _nodes: Node[] = [];\n private _previousTemplate: HTMLTemplateElement | null = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this.refresh(
|
|
5
|
-
"mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,eAAe,wBAAwB;AAChD,SAAS,oBAAoB;AAE7B,SAAS,
|
|
4
|
+
"sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ConvertUtils } from '@dooboostore/core-web';\nimport { SwcChooseInterface } from '../types';\nimport { attributeHost, getAttributeValue, getElementConfig } from '../decorators';\n\nclass SwcChoose extends HTMLTemplateElement implements SwcChooseInterface {\n // @attributeHost('value')\n // fetchValue: any;\n\n _value: any;\n\n @attributeHost('replace-wrap')\n _replaceWrap: string | null;\n\n private _nodes: Node[] = [];\n private _previousTemplate: HTMLTemplateElement | null = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this._value = nv;\n this.refresh(this._value);\n }\n\n constructor() {\n super();\n // console.log('swc chooooooooooooooooooooooooose constructor called!');\n // console.log('swc cccccccss', this.getAttribute('value'));\n }\n\n // static get observedAttributes() {\n // return ['value'];\n // }\n\n attributeChangedCallback(na, o, n) {\n // console.log('-----------------choooooooose attr origin', na, o, n);\n }\n\n @changedAttributeHost('value')\n private setValue(value: any, o: string, n: string) {\n // console.log('-----------------choooooooose attr setValue', value, o, n);\n this._value = value;\n this.refresh(this._value);\n }\n\n @changedAttributeHost('replace-wrap')\n private setReplaceWrap(replaceWrapAttr?: string | null) {\n this.refresh();\n }\n\n private replaceExpressions(html: string, groupArgs: any, context: any, wrap?: string | null): string {\n const config = wrap ? { wrapExpression: wrap } : undefined;\n const ae = new ActionExpression(html, config);\n const filterOptions = wrap ? { type: 'replace' as const, wrap } : 'replace';\n const win = this.ownerDocument?.defaultView || window;\n\n // @ts-ignore\n for (const expr of ae.getExpressions(filterOptions)) {\n try {\n const value = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),\n context,\n args: groupArgs\n });\n ae.replace(expr, String(value));\n } catch (e) {\n console.error(`[SWC] Failed to execute ${expr.original}:`, e);\n }\n }\n return ae.getUnprocessedTemplate();\n }\n\n refresh(value?: any) {\n value = getAttributeValue(this, 'value') ?? this._value;\n // console.log('chooooooooo refresh->', value);\n const portal = this.parentElement;\n if (!portal) return;\n\n const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n const groupArgs = { ...helperSet, $value: value };\n\n const templates = Array.from(this.content.querySelectorAll('template'));\n let selected: HTMLTemplateElement | null = null;\n\n for (const t of templates) {\n if (t.getAttribute('is') === 'swc-when') {\n const attrVal = t.getAttribute('value') || '';\n let matches = false;\n\n // Use ActionExpression to parse and extract script from value attribute\n const ae = new ActionExpression(attrVal);\n const expr = ae.getFirstExpression('replace');\n\n if (expr) {\n const decodedScript = ConvertUtils.decodeHtmlEntity(expr.script, win.document);\n const result = FunctionUtils.executeReturn({\n script: decodedScript,\n context: t,\n args: groupArgs\n });\n matches = !!result;\n } else {\n matches = String(attrVal) === String(value);\n }\n\n if (matches) {\n selected = t;\n break;\n }\n }\n }\n\n const target = selected || (this.content.querySelector('template[is=\"swc-otherwise\"]') as HTMLTemplateElement);\n\n const skipValue = target?.getAttribute?.('skip-if-same');\n const skipValue2 = this._previousTemplate?.getAttribute?.('skip-if-same');\n const hasSkipIfSame = target?.hasAttribute?.('skip-if-same');\n const isSame = this._previousTemplate === target;\n // console.log('---rrrr---', this._previousTemplate, target, hasSkipIfSame, isSame, skipValue, skipValue2);\n if (hasSkipIfSame && isSame) {\n return;\n }\n\n this.cleanup();\n this._previousTemplate = target;\n\n if (target) {\n let htmlString = target.innerHTML;\n htmlString = this.replaceExpressions(htmlString, groupArgs, this, this._replaceWrap);\n\n const result = this.ownerDocument?.createElement('template') || document.createElement('template');\n result.innerHTML = htmlString;\n const processedFragment = result.content;\n\n this._nodes = Array.from(processedFragment.childNodes);\n portal.insertBefore(processedFragment, this.nextSibling);\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,eAAe,wBAAwB;AAChD,SAAS,oBAAoB;AAE7B,SAAS,eAAe,mBAAmB,wBAAwB;AAEnE,MAAM,kBAAkB,oBAAmB;EAYzC,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EAEA,IAAI,MAAM,IAAO;AACf,SAAK,SA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A8BrB,WAAA;EADP,qBAAqB,OAAO;;;;;AAQrB,WAAA;EADP,qBAAqB,cAAc;;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
7
7
|
var __metadata = function(k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { elementDefine, attributeHost, changedAttributeHost } from "../decorators/index.js";
|
|
10
|
+
import { getElementConfig, elementDefine, attributeHost, changedAttributeHost, getAttributeValue } from "../decorators/index.js";
|
|
11
11
|
import { SwcAppMixin } from "./SwcAppMixin.js";
|
|
12
12
|
import { SwcUtils } from "../utils/Utils.js";
|
|
13
13
|
import { FunctionUtils, ActionExpression } from "@dooboostore/core";
|
|
@@ -284,19 +284,26 @@ const registerAllElements = (w) => {
|
|
|
284
284
|
elementDefine("swc-loop", { extends: "template", window: w })
|
|
285
285
|
], SwcLoop);
|
|
286
286
|
let SwcChoose = class SwcChoose extends HTMLTemplateElement {
|
|
287
|
-
constructor() {
|
|
288
|
-
super(...arguments);
|
|
289
|
-
this._nodes = [];
|
|
290
|
-
this._previousTemplate = null;
|
|
291
|
-
}
|
|
292
287
|
get value() {
|
|
293
288
|
return this._value;
|
|
294
289
|
}
|
|
295
290
|
set value(nv) {
|
|
296
|
-
this.
|
|
291
|
+
this._value = nv;
|
|
292
|
+
this.refresh(this._value);
|
|
297
293
|
}
|
|
298
|
-
|
|
299
|
-
|
|
294
|
+
constructor() {
|
|
295
|
+
super();
|
|
296
|
+
this._nodes = [];
|
|
297
|
+
this._previousTemplate = null;
|
|
298
|
+
}
|
|
299
|
+
// static get observedAttributes() {
|
|
300
|
+
// return ['value'];
|
|
301
|
+
// }
|
|
302
|
+
attributeChangedCallback(na, o, n) {
|
|
303
|
+
}
|
|
304
|
+
setValue(value, o, n) {
|
|
305
|
+
this._value = value;
|
|
306
|
+
this.refresh(this._value);
|
|
300
307
|
}
|
|
301
308
|
setReplaceWrap(replaceWrapAttr) {
|
|
302
309
|
this.refresh();
|
|
@@ -320,11 +327,12 @@ const registerAllElements = (w) => {
|
|
|
320
327
|
}
|
|
321
328
|
return ae.getUnprocessedTemplate();
|
|
322
329
|
}
|
|
323
|
-
refresh(value
|
|
330
|
+
refresh(value) {
|
|
331
|
+
value = getAttributeValue(this, "value") ?? this._value;
|
|
324
332
|
const portal = this.parentElement;
|
|
325
333
|
if (!portal)
|
|
326
334
|
return;
|
|
327
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
335
|
+
const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;
|
|
328
336
|
const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
329
337
|
const groupArgs = { ...helperSet, $value: value };
|
|
330
338
|
const templates = Array.from(this.content.querySelectorAll("template"));
|
|
@@ -380,10 +388,6 @@ const registerAllElements = (w) => {
|
|
|
380
388
|
this.cleanup();
|
|
381
389
|
}
|
|
382
390
|
};
|
|
383
|
-
__decorate([
|
|
384
|
-
attributeHost("value"),
|
|
385
|
-
__metadata("design:type", Object)
|
|
386
|
-
], SwcChoose.prototype, "_value", void 0);
|
|
387
391
|
__decorate([
|
|
388
392
|
attributeHost("replace-wrap"),
|
|
389
393
|
__metadata("design:type", String)
|
|
@@ -391,7 +395,7 @@ const registerAllElements = (w) => {
|
|
|
391
395
|
__decorate([
|
|
392
396
|
changedAttributeHost("value"),
|
|
393
397
|
__metadata("design:type", Function),
|
|
394
|
-
__metadata("design:paramtypes", []),
|
|
398
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
395
399
|
__metadata("design:returntype", void 0)
|
|
396
400
|
], SwcChoose.prototype, "setValue", null);
|
|
397
401
|
__decorate([
|
|
@@ -401,7 +405,8 @@ const registerAllElements = (w) => {
|
|
|
401
405
|
__metadata("design:returntype", void 0)
|
|
402
406
|
], SwcChoose.prototype, "setReplaceWrap", null);
|
|
403
407
|
SwcChoose = __decorate([
|
|
404
|
-
elementDefine("swc-choose", { extends: "template", window: w })
|
|
408
|
+
elementDefine("swc-choose", { extends: "template", window: w }),
|
|
409
|
+
__metadata("design:paramtypes", [])
|
|
405
410
|
], SwcChoose);
|
|
406
411
|
let SwcAsync = class SwcAsync extends HTMLTemplateElement {
|
|
407
412
|
constructor() {
|