@dooboostore/simple-web-component 1.0.37 → 1.0.39
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 -791
- package/dist/cjs/SwcAppEngine.js +3 -0
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +20 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js.map +1 -1
- package/dist/cjs/decorators/applyClass.js.map +1 -1
- package/dist/cjs/decorators/applyNode.js +104 -35
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +69 -57
- package/dist/cjs/decorators/applySlot.js.map +3 -3
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js.map +1 -1
- package/dist/cjs/decorators/elementDefine.js +65 -42
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +1 -1
- package/dist/cjs/decorators/index.js +1 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +47 -31
- package/dist/cjs/decorators/lifecycles.js.map +3 -3
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/cjs/decorators/query.js +1 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js.map +1 -1
- package/dist/cjs/decorators/setProperty.js.map +1 -1
- package/dist/cjs/decorators/state.js +83 -0
- package/dist/cjs/decorators/state.js.map +7 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcApp.js +193 -305
- package/dist/cjs/elements/SwcApp.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +291 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/index.js +3 -21
- package/dist/cjs/elements/index.js.map +3 -3
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/{types.js → types/index.js} +1 -1
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/cjs/utils/Utils.js +159 -20
- package/dist/cjs/utils/Utils.js.map +3 -3
- package/dist/esm/SwcAppEngine.js +3 -0
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +20 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js.map +1 -1
- package/dist/esm/decorators/applyClass.js.map +1 -1
- package/dist/esm/decorators/applyNode.js +104 -35
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +69 -57
- package/dist/esm/decorators/applySlot.js.map +3 -3
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js.map +1 -1
- package/dist/esm/decorators/elementDefine.js +69 -46
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +1 -1
- package/dist/esm/decorators/index.js +1 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +47 -31
- package/dist/esm/decorators/lifecycles.js.map +3 -3
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/query.js +1 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js.map +1 -1
- package/dist/esm/decorators/setProperty.js.map +1 -1
- package/dist/esm/decorators/state.js +64 -0
- package/dist/esm/decorators/state.js.map +7 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcApp.js +195 -307
- package/dist/esm/elements/SwcApp.js.map +3 -3
- package/dist/esm/elements/SwcAppMixin.js +273 -0
- package/dist/esm/elements/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/index.js +2 -7
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/{types.js → types/index.js} +1 -1
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/utils/Utils.js +159 -20
- package/dist/esm/utils/Utils.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +3448 -2584
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts +1 -1
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +5 -2
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +23 -7
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +14 -12
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +10 -14
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/decorators/state.d.ts +9 -0
- package/dist/types/decorators/state.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +35 -6
- package/dist/types/elements/SwcApp.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +405 -0
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/index.d.ts +2 -2
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/{types.d.ts → types/index.d.ts} +11 -11
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/Utils.d.ts +14 -2
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +3431 -2567
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/SwcAppEngine.ts +6 -2
- package/src/decorators/addEventListener.ts +21 -5
- package/src/decorators/applyAttribute.ts +1 -1
- package/src/decorators/applyClass.ts +1 -1
- package/src/decorators/applyNode.ts +183 -73
- package/src/decorators/applySlot.ts +99 -128
- package/src/decorators/applyStyle.ts +4 -4
- package/src/decorators/attribute.ts +1 -1
- package/src/decorators/elementDefine.ts +112 -60
- package/src/decorators/emitCustomEvent.ts +1 -1
- package/src/decorators/index.ts +2 -0
- package/src/decorators/lifecycles.ts +50 -26
- package/src/decorators/publishSwcAppMessage.ts +2 -3
- package/src/decorators/query.ts +4 -4
- package/src/decorators/queryAll.ts +1 -1
- package/src/decorators/setProperty.ts +1 -1
- package/src/decorators/state.ts +83 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -1
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +4 -3
- package/src/elements/SwcApp.ts +239 -441
- package/src/elements/SwcAppMixin.ts +328 -0
- package/src/elements/index.ts +2 -9
- package/src/index.ts +2 -4
- package/src/{types.ts → types/index.ts} +13 -10
- package/src/types/window.d.ts +3 -0
- package/src/utils/Utils.ts +205 -20
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/types.js.map +0 -7
- package/dist/types/types.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,
|
|
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}\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(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKey?: string | symbol, 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 (propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, 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 options.path = targetOrOptions;\n } else if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'function') {\n // \uBB38\uC790\uC5F4 \uB610\uB294 \uD568\uC218: @subscribeSwcAppRouteChangeWhileConnected('/path')\n options.path = targetOrOptions;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ... })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAQ,oBAAmB;AAIpB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;AAc3J,SAAS,+CAA+C,SAAqD;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,SAAS;AAC7B,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,6DAA6D,WAAW;AAC/G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,6DAA6D,MAAM,WAAW;AAAA,IAC5G;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAElC,WAAO;AAAA,EACT;AACF;AAUO,SAAS,yCAAyC,iBAAuB,aAA+B,YAAsC;AAGnJ,MAAI,gBAAgB,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACvF,WAAO,+CAA+C,CAAC,CAAC,EAAE,iBAAiB,aAAa,UAAU;AAAA,EACpG;AAGA,MAAI,UAAoC,CAAC;AAEzC,MAAI,MAAM,QAAQ,eAAe,GAAG;AAElC,YAAQ,OAAO;AAAA,EACjB,WAAW,OAAO,oBAAoB,YAAY,OAAO,oBAAoB,YAAY;AAEvF,YAAQ,OAAO;AAAA,EACjB,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,cAAU;AAAA,EACZ;AAEA,SAAO,+CAA+C,OAAO;AAC/D;AAGO,MAAM,sDAAsD,CAAC,WAAmE;AACrI,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,6DAA6D,WAAW;AAC7G;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,321 +4,209 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { elementDefine
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
return
|
|
7
|
+
import { elementDefine } from "../decorators/index.js";
|
|
8
|
+
import { SwcAppMixin } from "./SwcAppMixin.js";
|
|
9
|
+
import { createElement } from "../utils/Utils.js";
|
|
10
|
+
const swcAppTagName = "swc-app";
|
|
11
|
+
const SwcApp = (w, data) => {
|
|
12
|
+
return createElement(w, swcAppTagName, data);
|
|
13
13
|
};
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const defineSwcApp = async (w) => {
|
|
15
|
+
const existing = w.customElements.get(swcAppTagName);
|
|
16
|
+
if (existing)
|
|
17
|
+
return existing;
|
|
18
|
+
let SwcAppImpl = class SwcAppImpl extends SwcAppMixin(w.HTMLElement) {
|
|
19
|
+
};
|
|
20
|
+
SwcAppImpl = __decorate([
|
|
21
|
+
elementDefine(swcAppTagName, { window: w })
|
|
22
|
+
], SwcAppImpl);
|
|
23
|
+
return w.customElements.whenDefined(swcAppTagName);
|
|
24
|
+
};
|
|
25
|
+
const swcAppBodyTagName = "swc-app-body";
|
|
26
|
+
const SwcAppBody = (w, data) => {
|
|
27
|
+
return createElement(w, swcAppBodyTagName, data);
|
|
28
|
+
};
|
|
29
|
+
const defineSwcAppBody = async (w) => {
|
|
30
|
+
const existing = w.customElements.get(swcAppBodyTagName);
|
|
31
|
+
if (existing)
|
|
32
|
+
return existing;
|
|
33
|
+
let SwcAppBodyImpl = class SwcAppBodyImpl extends SwcAppMixin(w.HTMLBodyElement) {
|
|
34
|
+
};
|
|
35
|
+
SwcAppBodyImpl = __decorate([
|
|
36
|
+
elementDefine(swcAppBodyTagName, { window: w, extends: "body" })
|
|
37
|
+
], SwcAppBodyImpl);
|
|
38
|
+
return w.customElements.whenDefined(swcAppBodyTagName);
|
|
39
|
+
};
|
|
40
|
+
const swcAppDivTagName = "swc-app-div";
|
|
41
|
+
const SwcAppDiv = (w, data) => {
|
|
42
|
+
return createElement(w, swcAppDivTagName, data);
|
|
43
|
+
};
|
|
44
|
+
const defineSwcAppDiv = async (w) => {
|
|
45
|
+
const existing = w.customElements.get(swcAppDivTagName);
|
|
46
|
+
if (existing)
|
|
47
|
+
return existing;
|
|
48
|
+
let SwcAppDivImpl = class SwcAppDivImpl extends SwcAppMixin(w.HTMLDivElement) {
|
|
49
|
+
};
|
|
50
|
+
SwcAppDivImpl = __decorate([
|
|
51
|
+
elementDefine(swcAppDivTagName, { window: w, extends: "div" })
|
|
52
|
+
], SwcAppDivImpl);
|
|
53
|
+
return w.customElements.whenDefined(swcAppDivTagName);
|
|
54
|
+
};
|
|
55
|
+
const swcAppSectionTagName = "swc-app-section";
|
|
56
|
+
const SwcAppSection = (w, data) => {
|
|
57
|
+
return createElement(w, swcAppSectionTagName, data);
|
|
58
|
+
};
|
|
59
|
+
const defineSwcAppSection = async (w) => {
|
|
60
|
+
const existing = w.customElements.get(swcAppSectionTagName);
|
|
61
|
+
if (existing)
|
|
62
|
+
return existing;
|
|
63
|
+
let SwcAppSectionImpl = class SwcAppSectionImpl extends SwcAppMixin(w.HTMLElement) {
|
|
64
|
+
};
|
|
65
|
+
SwcAppSectionImpl = __decorate([
|
|
66
|
+
elementDefine(swcAppSectionTagName, { window: w, extends: "section" })
|
|
67
|
+
], SwcAppSectionImpl);
|
|
68
|
+
return w.customElements.whenDefined(swcAppSectionTagName);
|
|
69
|
+
};
|
|
70
|
+
const swcAppMainTagName = "swc-app-main";
|
|
71
|
+
const SwcAppMain = (w, data) => {
|
|
72
|
+
return createElement(w, swcAppMainTagName, data);
|
|
73
|
+
};
|
|
74
|
+
const defineSwcAppMain = async (w) => {
|
|
75
|
+
const existing = w.customElements.get(swcAppMainTagName);
|
|
76
|
+
if (existing)
|
|
77
|
+
return existing;
|
|
78
|
+
let SwcAppMainImpl = class SwcAppMainImpl extends SwcAppMixin(w.HTMLElement) {
|
|
79
|
+
};
|
|
80
|
+
SwcAppMainImpl = __decorate([
|
|
81
|
+
elementDefine(swcAppMainTagName, { window: w, extends: "main" })
|
|
82
|
+
], SwcAppMainImpl);
|
|
83
|
+
return w.customElements.whenDefined(swcAppMainTagName);
|
|
84
|
+
};
|
|
85
|
+
const swcAppArticleTagName = "swc-app-article";
|
|
86
|
+
const SwcAppArticle = (w, data) => {
|
|
87
|
+
return createElement(w, swcAppArticleTagName, data);
|
|
88
|
+
};
|
|
89
|
+
const defineSwcAppArticle = async (w) => {
|
|
90
|
+
const existing = w.customElements.get(swcAppArticleTagName);
|
|
91
|
+
if (existing)
|
|
92
|
+
return existing;
|
|
93
|
+
let SwcAppArticleImpl = class SwcAppArticleImpl extends SwcAppMixin(w.HTMLElement) {
|
|
94
|
+
};
|
|
95
|
+
SwcAppArticleImpl = __decorate([
|
|
96
|
+
elementDefine(swcAppArticleTagName, { window: w, extends: "article" })
|
|
97
|
+
], SwcAppArticleImpl);
|
|
98
|
+
return w.customElements.whenDefined(swcAppArticleTagName);
|
|
99
|
+
};
|
|
100
|
+
const swcAppHeaderTagName = "swc-app-header";
|
|
101
|
+
const SwcAppHeader = (w, data) => {
|
|
102
|
+
return createElement(w, swcAppHeaderTagName, data);
|
|
103
|
+
};
|
|
104
|
+
const defineSwcAppHeader = async (w) => {
|
|
105
|
+
const existing = w.customElements.get(swcAppHeaderTagName);
|
|
106
|
+
if (existing)
|
|
107
|
+
return existing;
|
|
108
|
+
let SwcAppHeaderImpl = class SwcAppHeaderImpl extends SwcAppMixin(w.HTMLElement) {
|
|
109
|
+
};
|
|
110
|
+
SwcAppHeaderImpl = __decorate([
|
|
111
|
+
elementDefine(swcAppHeaderTagName, { window: w, extends: "header" })
|
|
112
|
+
], SwcAppHeaderImpl);
|
|
113
|
+
return w.customElements.whenDefined(swcAppHeaderTagName);
|
|
16
114
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
115
|
+
const swcAppFooterTagName = "swc-app-footer";
|
|
116
|
+
const SwcAppFooter = (w, data) => {
|
|
117
|
+
return createElement(w, swcAppFooterTagName, data);
|
|
19
118
|
};
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const existing = w.customElements.get(tagName);
|
|
119
|
+
const defineSwcAppFooter = async (w) => {
|
|
120
|
+
const existing = w.customElements.get(swcAppFooterTagName);
|
|
23
121
|
if (existing)
|
|
24
122
|
return existing;
|
|
25
|
-
let
|
|
26
|
-
constructor() {
|
|
27
|
-
super(...arguments);
|
|
28
|
-
this.__swc_engine = new SwcAppEngine(this);
|
|
29
|
-
this._swc_connected_instance = /* @__PURE__ */ new Set();
|
|
30
|
-
this._routeChangeInvocations = 0;
|
|
31
|
-
this._connectedInvocations = 0;
|
|
32
|
-
this._connected_safari_and_standby = [];
|
|
33
|
-
}
|
|
34
|
-
get simpleApplication() {
|
|
35
|
-
return this.__swc_engine.simpleApplication;
|
|
36
|
-
}
|
|
37
|
-
get config() {
|
|
38
|
-
return this.__swc_engine?.config;
|
|
39
|
-
}
|
|
40
|
-
get router() {
|
|
41
|
-
return this.__swc_engine?.router;
|
|
42
|
-
}
|
|
43
|
-
async _invokeRouteChangeSubscribers(instance, re) {
|
|
44
|
-
if (instance.isConnected === false)
|
|
45
|
-
return;
|
|
46
|
-
this._routeChangeInvocations++;
|
|
47
|
-
if (this._childrenRouteChangedInterval) {
|
|
48
|
-
this.config.window.clearInterval(this._childrenRouteChangedInterval);
|
|
49
|
-
}
|
|
50
|
-
const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };
|
|
51
|
-
this._childrenRouteChangedInterval = debounceTimeIntervalLock(
|
|
52
|
-
() => this._routeChangeInvocations === 0,
|
|
53
|
-
() => {
|
|
54
|
-
this._childrenRouteChangedInterval = null;
|
|
55
|
-
this.config.onChildrenRouteChanged?.(re, this);
|
|
56
|
-
},
|
|
57
|
-
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
58
|
-
intervalConfig
|
|
59
|
-
// {setInterval: window.setInterval, clearInterval: window.clearInterval}
|
|
60
|
-
);
|
|
61
|
-
try {
|
|
62
|
-
const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
|
|
63
|
-
if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
|
|
64
|
-
const ps = routeChangeSubscribers.map(async (metadata) => {
|
|
65
|
-
const methodName = metadata.propertyKey;
|
|
66
|
-
let pathPattern = metadata.options?.path;
|
|
67
|
-
const filter = metadata.options?.filter;
|
|
68
|
-
if (typeof pathPattern === "function") {
|
|
69
|
-
pathPattern = pathPattern(instance);
|
|
70
|
-
}
|
|
71
|
-
let pathMatched = false;
|
|
72
|
-
let pathData = null;
|
|
73
|
-
if (!pathPattern) {
|
|
74
|
-
pathMatched = true;
|
|
75
|
-
pathData = {};
|
|
76
|
-
} else if (Array.isArray(pathPattern)) {
|
|
77
|
-
for (const pattern of pathPattern) {
|
|
78
|
-
const data = SwcUtils.parsePathPattern(pattern, re.path || "/");
|
|
79
|
-
if (data !== null) {
|
|
80
|
-
pathMatched = true;
|
|
81
|
-
pathData = data;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
pathData = SwcUtils.parsePathPattern(pathPattern, re.path || "/");
|
|
87
|
-
pathMatched = pathData !== null;
|
|
88
|
-
}
|
|
89
|
-
const filterPassed = !filter || filter(this.router, instance);
|
|
90
|
-
if (pathMatched && filterPassed && instance[methodName]) {
|
|
91
|
-
await instance[methodName]({ ...re, pathData });
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
await Promise.allSettled(ps);
|
|
95
|
-
}
|
|
96
|
-
} finally {
|
|
97
|
-
if (this.config?.ssr) {
|
|
98
|
-
setSSRAttribute(instance);
|
|
99
|
-
} else {
|
|
100
|
-
removeSSRAttribute(instance);
|
|
101
|
-
}
|
|
102
|
-
this._routeChangeInvocations = Math.max(0, this._routeChangeInvocations - 1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async _connected(instance, option) {
|
|
106
|
-
if (instance) {
|
|
107
|
-
if (!this.simpleApplication && !this.config) {
|
|
108
|
-
this._connected_safari_and_standby.push(instance);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this.config.onConnectedChildBefore?.(instance);
|
|
112
|
-
if (!option?.noIncrements) {
|
|
113
|
-
this._connectedInvocations++;
|
|
114
|
-
}
|
|
115
|
-
this._swc_connected_instance.add(instance);
|
|
116
|
-
const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY) ?? [];
|
|
117
|
-
for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {
|
|
118
|
-
await instance?._invokeLifecycleMethod?.(connectedSwcAppCallBack);
|
|
119
|
-
}
|
|
120
|
-
if (this._childrenConnectedDoneInterval) {
|
|
121
|
-
this.config.window.clearInterval(this._childrenConnectedDoneInterval);
|
|
122
|
-
}
|
|
123
|
-
const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };
|
|
124
|
-
this._childrenConnectedDoneInterval = debounceTimeIntervalLock(() => this._connectedInvocations === 0, () => {
|
|
125
|
-
this._childrenConnectedDoneInterval = null;
|
|
126
|
-
this.config.onChildrenConnectedDone?.(this);
|
|
127
|
-
}, this.config?.childrenConnectedDoneCheckIntervalTime ?? 30, intervalConfig);
|
|
128
|
-
if (this.simpleApplication) {
|
|
129
|
-
try {
|
|
130
|
-
if (this.router && this._lastRouterEvent) {
|
|
131
|
-
await this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);
|
|
132
|
-
}
|
|
133
|
-
} catch (e) {
|
|
134
|
-
throw e;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (this.config?.ssr) {
|
|
138
|
-
setSSRAttribute(instance);
|
|
139
|
-
} else {
|
|
140
|
-
removeSSRAttribute(instance);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
this.config.onConnectedChildAfter?.(instance);
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
async _connectedDone(instance) {
|
|
147
|
-
try {
|
|
148
|
-
} finally {
|
|
149
|
-
this._connectedInvocations = Math.max(0, this._connectedInvocations - 1);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
_disconnected(instance) {
|
|
153
|
-
if (instance) {
|
|
154
|
-
this._swc_connected_instance.delete(instance);
|
|
155
|
-
this.config?.onDisconnectedChildAfter?.(instance);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async _handleRouteChange(route) {
|
|
159
|
-
this._lastRouterEvent = route;
|
|
160
|
-
const swcConnectedInstance = Array.from(this._swc_connected_instance);
|
|
161
|
-
const ps = swcConnectedInstance.map((instance) => this._invokeRouteChangeSubscribers(instance, route));
|
|
162
|
-
await Promise.allSettled(ps);
|
|
163
|
-
}
|
|
164
|
-
async connect(config) {
|
|
165
|
-
console.log("[SWC] connect");
|
|
166
|
-
const swcConfig = {
|
|
167
|
-
routeType: "element",
|
|
168
|
-
window: config?.window,
|
|
169
|
-
...config
|
|
170
|
-
};
|
|
171
|
-
const mode = config?.connectMode || "direct";
|
|
172
|
-
if (mode === "direct" || mode === "hydrate") {
|
|
173
|
-
this.setAttribute("swc-connect-mode", mode);
|
|
174
|
-
await this.__swc_engine.connect(swcConfig);
|
|
175
|
-
} else if (mode === "swap" || mode === "clear-swap") {
|
|
176
|
-
if (!this.parentNode) {
|
|
177
|
-
await this.__swc_engine.connect(swcConfig);
|
|
178
|
-
this.setAttribute("swc-connect-mode", "direct");
|
|
179
|
-
} else {
|
|
180
|
-
const clonedApp = this.cloneNode(mode === "swap");
|
|
181
|
-
clonedApp.style.display = "none";
|
|
182
|
-
this.parentNode.insertBefore(clonedApp, this.nextSibling);
|
|
183
|
-
try {
|
|
184
|
-
await clonedApp.connect({ ...config || {}, connectMode: "direct" });
|
|
185
|
-
if (this.parentNode) {
|
|
186
|
-
this.parentNode.removeChild(this);
|
|
187
|
-
}
|
|
188
|
-
clonedApp.style.display = "";
|
|
189
|
-
clonedApp.setAttribute("swc-connect-mode", mode);
|
|
190
|
-
return;
|
|
191
|
-
} catch (e) {
|
|
192
|
-
if (clonedApp.parentNode) {
|
|
193
|
-
clonedApp.parentNode.removeChild(clonedApp);
|
|
194
|
-
}
|
|
195
|
-
await this.__swc_engine.connect(swcConfig);
|
|
196
|
-
this.setAttribute("swc-connect-mode", "direct");
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
this._connected_safari_and_standby.forEach((instance) => {
|
|
201
|
-
this._connected(instance, { noIncrements: true });
|
|
202
|
-
});
|
|
203
|
-
if (!this._routerSubscription && this.router) {
|
|
204
|
-
const config2 = this.__swc_engine.config;
|
|
205
|
-
this._routerSubscription = this.router.observable.subscribe(async (route) => {
|
|
206
|
-
console.log("[SWC] Router event received:", route.triggerPoint);
|
|
207
|
-
if (route.triggerPoint === "end") {
|
|
208
|
-
await this._handleRouteChange(route);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
if (config2?.path) {
|
|
212
|
-
console.log("[DEBUG] Navigating to initial path:", config2.path);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// async _invokeOnConnectedSwcAppStarted(instance: any) {
|
|
217
|
-
// this._swcAppStartedInvocations++;
|
|
218
|
-
// try {
|
|
219
|
-
// // 이미 시작된 인스턴스라면 스킵 (비동기 병렬 중복 호출 방지)
|
|
220
|
-
// if (this._swc_started_instances.has(instance)) return;
|
|
221
|
-
// this._swc_started_instances.add(instance);
|
|
222
|
-
//
|
|
223
|
-
// const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
224
|
-
// if (startedMethods) {
|
|
225
|
-
// const ps = startedMethods.map(m => instance._invokeLifecycleMethod(m));
|
|
226
|
-
// await Promise.allSettled(ps);
|
|
227
|
-
// }
|
|
228
|
-
// } finally {
|
|
229
|
-
// this._swcAppStartedInvocations--;
|
|
230
|
-
// }
|
|
231
|
-
// }
|
|
232
|
-
connectedCallback() {
|
|
233
|
-
if (super.connectedCallback)
|
|
234
|
-
super.connectedCallback();
|
|
235
|
-
const configStr = this.getAttribute("swc-get-application-config");
|
|
236
|
-
const win = this.ownerDocument?.defaultView || window;
|
|
237
|
-
if (configStr && win) {
|
|
238
|
-
try {
|
|
239
|
-
const userConfig = FunctionUtils.executeReturn({
|
|
240
|
-
script: configStr,
|
|
241
|
-
context: this,
|
|
242
|
-
args: SwcUtils.getHelperAndHostSet(win, this)
|
|
243
|
-
});
|
|
244
|
-
this.connect(userConfig);
|
|
245
|
-
} catch (e) {
|
|
246
|
-
console.error("[SWC-APP-ENGINE] Script execution failed:", e);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
this._connected(this);
|
|
250
|
-
this.__swc_engine?.config?.onConnected?.(this);
|
|
251
|
-
this._connectedDone(this);
|
|
252
|
-
}
|
|
253
|
-
disconnectedCallback() {
|
|
254
|
-
if (super.disconnectedCallback)
|
|
255
|
-
super.disconnectedCallback();
|
|
256
|
-
this._routerSubscription?.unsubscribe();
|
|
257
|
-
this._routerSubscription = void 0;
|
|
258
|
-
this._lastRouterEvent = void 0;
|
|
259
|
-
this.__swc_engine.disconnect();
|
|
260
|
-
this.__swc_engine?.config?.onDisconnected?.(this);
|
|
261
|
-
this._disconnected(this);
|
|
262
|
-
}
|
|
263
|
-
async routing(path) {
|
|
264
|
-
await this.router?.go(path);
|
|
265
|
-
}
|
|
266
|
-
back() {
|
|
267
|
-
this.router?.back();
|
|
268
|
-
}
|
|
269
|
-
forward() {
|
|
270
|
-
this.router?.forward();
|
|
271
|
-
}
|
|
272
|
-
reload() {
|
|
273
|
-
this.router?.reload();
|
|
274
|
-
}
|
|
275
|
-
// async completedSwcApp() {
|
|
276
|
-
// const ss = Array.from(this._swc_connected_instance).flatMap((it) => {
|
|
277
|
-
// const ms = findAllLifecycleMetadata(it, ON_CONNECTED_COMPLETED_SWC_APP_METADATA_KEY) ?? [];
|
|
278
|
-
// return ms.map((sit) => it[sit](this));
|
|
279
|
-
// });
|
|
280
|
-
// await Promise.allSettled(ss);
|
|
281
|
-
// }
|
|
282
|
-
publishMessage(message) {
|
|
283
|
-
this._swc_connected_instance.forEach((instance) => {
|
|
284
|
-
this._invokeMessageSubscribers(instance, message);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
_invokeMessageSubscribers(instance, message) {
|
|
288
|
-
const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);
|
|
289
|
-
if (messageSubscribers && Array.isArray(messageSubscribers)) {
|
|
290
|
-
messageSubscribers.forEach((metadata) => {
|
|
291
|
-
const methodName = metadata.propertyKey;
|
|
292
|
-
const messageType = metadata.messageType;
|
|
293
|
-
const filter = metadata.filter;
|
|
294
|
-
let typeMatched = false;
|
|
295
|
-
if (!messageType) {
|
|
296
|
-
typeMatched = true;
|
|
297
|
-
} else if (message.type === messageType) {
|
|
298
|
-
typeMatched = true;
|
|
299
|
-
}
|
|
300
|
-
let filterMatched = true;
|
|
301
|
-
if (filter && typeMatched) {
|
|
302
|
-
filterMatched = filter(message, instance);
|
|
303
|
-
}
|
|
304
|
-
if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
|
|
305
|
-
instance[methodName](message);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
}
|
|
123
|
+
let SwcAppFooterImpl = class SwcAppFooterImpl extends SwcAppMixin(w.HTMLElement) {
|
|
310
124
|
};
|
|
311
|
-
|
|
312
|
-
elementDefine(
|
|
313
|
-
],
|
|
314
|
-
;
|
|
315
|
-
|
|
125
|
+
SwcAppFooterImpl = __decorate([
|
|
126
|
+
elementDefine(swcAppFooterTagName, { window: w, extends: "footer" })
|
|
127
|
+
], SwcAppFooterImpl);
|
|
128
|
+
return w.customElements.whenDefined(swcAppFooterTagName);
|
|
129
|
+
};
|
|
130
|
+
const swcAppNavTagName = "swc-app-nav";
|
|
131
|
+
const SwcAppNav = (w, data) => {
|
|
132
|
+
return createElement(w, swcAppNavTagName, data);
|
|
133
|
+
};
|
|
134
|
+
const defineSwcAppNav = async (w) => {
|
|
135
|
+
const existing = w.customElements.get(swcAppNavTagName);
|
|
136
|
+
if (existing)
|
|
137
|
+
return existing;
|
|
138
|
+
let SwcAppNavImpl = class SwcAppNavImpl extends SwcAppMixin(w.HTMLElement) {
|
|
139
|
+
};
|
|
140
|
+
SwcAppNavImpl = __decorate([
|
|
141
|
+
elementDefine(swcAppNavTagName, { window: w, extends: "nav" })
|
|
142
|
+
], SwcAppNavImpl);
|
|
143
|
+
return w.customElements.whenDefined(swcAppNavTagName);
|
|
144
|
+
};
|
|
145
|
+
const swcAppAsideTagName = "swc-app-aside";
|
|
146
|
+
const SwcAppAside = (w, data) => {
|
|
147
|
+
return createElement(w, swcAppAsideTagName, data);
|
|
148
|
+
};
|
|
149
|
+
const defineSwcAppAside = async (w) => {
|
|
150
|
+
const existing = w.customElements.get(swcAppAsideTagName);
|
|
151
|
+
if (existing)
|
|
152
|
+
return existing;
|
|
153
|
+
let SwcAppAsideImpl = class SwcAppAsideImpl extends SwcAppMixin(w.HTMLElement) {
|
|
154
|
+
};
|
|
155
|
+
SwcAppAsideImpl = __decorate([
|
|
156
|
+
elementDefine(swcAppAsideTagName, { window: w, extends: "aside" })
|
|
157
|
+
], SwcAppAsideImpl);
|
|
158
|
+
return w.customElements.whenDefined(swcAppAsideTagName);
|
|
159
|
+
};
|
|
160
|
+
const swcAppFactories = [
|
|
161
|
+
defineSwcApp,
|
|
162
|
+
defineSwcAppBody,
|
|
163
|
+
defineSwcAppDiv,
|
|
164
|
+
defineSwcAppSection,
|
|
165
|
+
defineSwcAppMain,
|
|
166
|
+
defineSwcAppArticle,
|
|
167
|
+
defineSwcAppHeader,
|
|
168
|
+
defineSwcAppFooter,
|
|
169
|
+
defineSwcAppNav,
|
|
170
|
+
defineSwcAppAside
|
|
171
|
+
];
|
|
172
|
+
const defineSwcAppAll = async (w) => {
|
|
173
|
+
await Promise.all(swcAppFactories.map((factory) => factory(w)));
|
|
174
|
+
return w.customElements.whenDefined(swcAppTagName);
|
|
316
175
|
};
|
|
176
|
+
var SwcApp_default = defineSwcAppAll;
|
|
317
177
|
export {
|
|
178
|
+
SwcApp,
|
|
179
|
+
SwcAppArticle,
|
|
180
|
+
SwcAppAside,
|
|
181
|
+
SwcAppBody,
|
|
182
|
+
SwcAppDiv,
|
|
183
|
+
SwcAppFooter,
|
|
184
|
+
SwcAppHeader,
|
|
185
|
+
SwcAppMain,
|
|
186
|
+
SwcAppNav,
|
|
187
|
+
SwcAppSection,
|
|
318
188
|
SwcApp_default as default,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
189
|
+
defineSwcApp,
|
|
190
|
+
defineSwcAppAll,
|
|
191
|
+
defineSwcAppArticle,
|
|
192
|
+
defineSwcAppAside,
|
|
193
|
+
defineSwcAppBody,
|
|
194
|
+
defineSwcAppDiv,
|
|
195
|
+
defineSwcAppFooter,
|
|
196
|
+
defineSwcAppHeader,
|
|
197
|
+
defineSwcAppMain,
|
|
198
|
+
defineSwcAppNav,
|
|
199
|
+
defineSwcAppSection,
|
|
200
|
+
swcAppArticleTagName,
|
|
201
|
+
swcAppAsideTagName,
|
|
202
|
+
swcAppBodyTagName,
|
|
203
|
+
swcAppDivTagName,
|
|
204
|
+
swcAppFactories,
|
|
205
|
+
swcAppFooterTagName,
|
|
206
|
+
swcAppHeaderTagName,
|
|
207
|
+
swcAppMainTagName,
|
|
208
|
+
swcAppNavTagName,
|
|
209
|
+
swcAppSectionTagName,
|
|
210
|
+
swcAppTagName
|
|
323
211
|
};
|
|
324
212
|
//# sourceMappingURL=SwcApp.js.map
|