@dooboostore/simple-web-component 1.0.36 → 1.0.38
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 +396 -68
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +9 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- 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 +109 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +129 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js.map +1 -1
- package/dist/cjs/decorators/elementDefine.js +90 -52
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +1 -1
- package/dist/cjs/decorators/index.js +2 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +88 -24
- 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 +84 -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 +231 -0
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/SwcAppMixin.js +78 -80
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/index.js +2 -1
- package/dist/cjs/elements/index.js.map +2 -2
- package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsync.js +1 -0
- package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChoose.js +1 -0
- package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIf.js +1 -0
- package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoop.js +1 -0
- package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/tt/register.js +1 -0
- package/dist/cjs/elements/tt/register.js.map +7 -0
- package/dist/cjs/index.js +10 -8
- 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 +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/utils/Utils.js +168 -26
- package/dist/cjs/utils/Utils.js.map +3 -3
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +7 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- 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 +109 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +110 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js.map +1 -1
- package/dist/esm/decorators/elementDefine.js +96 -58
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +1 -1
- package/dist/esm/decorators/index.js +2 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +88 -24
- 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 +65 -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 +212 -0
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/SwcAppMixin.js +76 -78
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/index.js +2 -1
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
- package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsync.js +1 -0
- package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcChoose.js +1 -0
- package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcIf.js +1 -0
- package/dist/esm/elements/tt/SwcIf.js.map +7 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoop.js +1 -0
- package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/tt/register.js +1 -0
- package/dist/esm/elements/tt/register.js.map +7 -0
- package/dist/esm/index.js +11 -9
- 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/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/utils/Utils.js +168 -26
- package/dist/esm/utils/Utils.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +7477 -2828
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -0
- package/dist/types/decorators/addEventListener.d.ts +5 -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 +24 -8
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +27 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -0
- package/dist/types/decorators/applyStyle.d.ts.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 +2 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +26 -15
- 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 +36 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/SwcAppMixin.d.ts +26 -7
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/index.d.ts +2 -1
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcIf.d.ts +1 -0
- package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/tt/register.d.ts +1 -0
- package/dist/types/elements/tt/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/{types.d.ts → types/index.d.ts} +12 -12
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/Utils.d.ts +18 -5
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +7478 -2829
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +17 -8
- 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 +186 -66
- package/src/decorators/applySlot.ts +188 -0
- package/src/decorators/applyStyle.ts +4 -4
- package/src/decorators/attribute.ts +1 -1
- package/src/decorators/elementDefine.ts +142 -68
- package/src/decorators/emitCustomEvent.ts +1 -1
- package/src/decorators/index.ts +3 -0
- package/src/decorators/lifecycles.ts +119 -30
- 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 +84 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -1
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +4 -3
- package/src/elements/SwcApp.ts +241 -0
- package/src/elements/SwcAppMixin.ts +98 -146
- package/src/elements/index.ts +4 -1
- package/src/elements/tt/SwcAppMixin.ts +13 -0
- package/src/elements/tt/SwcAsync.ts +139 -0
- package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
- package/src/elements/tt/SwcChoose.ts +182 -0
- package/src/elements/tt/SwcChooseTemplate.ts +229 -0
- package/src/elements/tt/SwcIf.ts +145 -0
- package/src/elements/tt/SwcIfTemplate.ts +158 -0
- package/src/elements/tt/SwcLoop.ts +222 -0
- package/src/elements/tt/SwcLoopTemplate.ts +255 -0
- package/src/elements/tt/SwcSubTemplates.ts +6 -0
- package/src/elements/tt/register.ts +720 -0
- package/src/index.ts +11 -9
- package/src/{types.ts → types/index.ts} +15 -11
- package/src/types/window.d.ts +46 -0
- package/src/utils/Utils.ts +214 -24
- package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
- package/dist/cjs/elements/SwcAsync.js +0 -129
- package/dist/cjs/elements/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/SwcChoose.js +0 -155
- package/dist/cjs/elements/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/SwcIf.js +0 -117
- package/dist/cjs/elements/SwcIf.js.map +0 -7
- package/dist/cjs/elements/SwcLoop.js +0 -176
- package/dist/cjs/elements/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/SwcSubTemplates.js +0 -13
- package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/register.js +0 -1026
- package/dist/cjs/elements/register.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.js.map +0 -7
- package/dist/esm/elements/SwcAsync.js +0 -129
- package/dist/esm/elements/SwcAsync.js.map +0 -7
- package/dist/esm/elements/SwcChoose.js +0 -155
- package/dist/esm/elements/SwcChoose.js.map +0 -7
- package/dist/esm/elements/SwcIf.js +0 -117
- package/dist/esm/elements/SwcIf.js.map +0 -7
- package/dist/esm/elements/SwcLoop.js +0 -176
- package/dist/esm/elements/SwcLoop.js.map +0 -7
- package/dist/esm/elements/SwcSubTemplates.js +0 -13
- package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/register.js +0 -1007
- package/dist/esm/elements/register.js.map +0 -7
- package/dist/esm/types.js.map +0 -7
- package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
- package/dist/types/elements/SwcAsync.d.ts +0 -2
- package/dist/types/elements/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/SwcChoose.d.ts +0 -2
- package/dist/types/elements/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/SwcIf.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
- package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/register.d.ts +0 -4
- package/dist/types/elements/register.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/src/elements/SwcAsync.ts +0 -126
- package/src/elements/SwcChoose.ts +0 -190
- package/src/elements/SwcIf.ts +0 -124
- package/src/elements/SwcLoop.ts +0 -205
- package/src/elements/SwcSubTemplates.ts +0 -6
- package/src/elements/register.ts +0 -1022
|
@@ -8,21 +8,76 @@ export const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-compone
|
|
|
8
8
|
export const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');
|
|
9
9
|
export const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');
|
|
10
10
|
export const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');
|
|
11
|
+
export const ON_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component');
|
|
11
12
|
export const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');
|
|
12
|
-
export const
|
|
13
|
+
export const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');
|
|
13
14
|
|
|
14
15
|
export const ATTRIBUTE_CHANGED_WILDCARD = '*';
|
|
15
16
|
|
|
16
17
|
export interface InnerHtmlOptions {
|
|
17
|
-
|
|
18
|
+
ssrFirst?: boolean;
|
|
19
|
+
// replaceWrap?:{ start: string, end:string},
|
|
18
20
|
useShadow?: boolean;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
22
|
export interface InnerHtmlMetadata {
|
|
22
23
|
propertyKey: string | symbol;
|
|
23
24
|
options: InnerHtmlOptions;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
export interface OnConnectedOptions {
|
|
28
|
+
ssrFirst?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface OnConnectedMetadata {
|
|
31
|
+
propertyKey: string | symbol;
|
|
32
|
+
options: OnConnectedOptions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;
|
|
37
|
+
export function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
38
|
+
export function onConnectedBefore(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
39
|
+
const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {
|
|
40
|
+
const constructor = target.constructor;
|
|
41
|
+
let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);
|
|
42
|
+
if (!list) {
|
|
43
|
+
list = [];
|
|
44
|
+
ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);
|
|
45
|
+
}
|
|
46
|
+
list.push({ propertyKey, options });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (arg2) {
|
|
50
|
+
return decorator({}, arg1!, arg2);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
54
|
+
decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function onConnectedAfter(options: OnConnectedOptions): MethodDecorator;
|
|
59
|
+
export function onConnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
60
|
+
export function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
61
|
+
const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {
|
|
62
|
+
const constructor = target.constructor;
|
|
63
|
+
let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor);
|
|
64
|
+
if (!list) {
|
|
65
|
+
list = [];
|
|
66
|
+
ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);
|
|
67
|
+
}
|
|
68
|
+
list.push({ propertyKey, options });
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (arg2) {
|
|
72
|
+
return decorator({}, arg1!, arg2);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
76
|
+
decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
26
81
|
function createLifecycleDecorator(metadataKey: symbol): MethodDecorator {
|
|
27
82
|
return (target: Object, propertyKey: string | symbol) => {
|
|
28
83
|
const constructor = target.constructor;
|
|
@@ -36,9 +91,9 @@ function createLifecycleDecorator(metadataKey: symbol): MethodDecorator {
|
|
|
36
91
|
}
|
|
37
92
|
|
|
38
93
|
export const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);
|
|
39
|
-
export const onConnectedBefore = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
40
|
-
export const onConnectedAfter = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
41
|
-
export const onConnected = onConnectedAfter;
|
|
94
|
+
// export const onConnectedBefore = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
95
|
+
// export const onConnectedAfter = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
96
|
+
// export const onConnected = onConnectedAfter;
|
|
42
97
|
|
|
43
98
|
export const onDisconnectedBefore = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
44
99
|
export const onDisconnectedAfter = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
@@ -50,42 +105,76 @@ export const onAdopted = onAdoptedAfter;
|
|
|
50
105
|
|
|
51
106
|
export const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
|
|
52
107
|
|
|
53
|
-
|
|
108
|
+
export const onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
109
|
+
export const onConnectedCompleted = createLifecycleDecorator(ON_CONNECTED_COMPLETED_METADATA_KEY);
|
|
54
110
|
|
|
55
|
-
/**
|
|
56
|
-
* @onConnectedInnerHtml decorator to define the initial HTML content when connected.
|
|
57
|
-
*/
|
|
58
|
-
export function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;
|
|
59
|
-
export function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
60
|
-
export function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
61
|
-
const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {
|
|
62
|
-
const constructor = target.constructor;
|
|
63
|
-
let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);
|
|
64
|
-
if (!list) {
|
|
65
|
-
list = [];
|
|
66
|
-
ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
|
|
67
|
-
}
|
|
68
|
-
list.push({ propertyKey, options });
|
|
69
|
-
};
|
|
70
111
|
|
|
71
|
-
|
|
72
|
-
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {
|
|
116
|
+
const constructor = target.constructor;
|
|
117
|
+
let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(ON_CONNECTED_METADATA_KEY, constructor);
|
|
118
|
+
if (!list) {
|
|
119
|
+
list = [];
|
|
120
|
+
ReflectUtils.defineMetadata(ON_CONNECTED_METADATA_KEY, list, constructor);
|
|
121
|
+
}
|
|
122
|
+
list.push({ propertyKey, options });
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export function onConnectedShadowDom(options: Omit<InnerHtmlOptions, 'useShadow'>): MethodDecorator; // 파라미터있음
|
|
126
|
+
export function onConnectedShadowDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // 파라미터없음
|
|
127
|
+
export function onConnectedShadowDom(optionOrTarget: Omit<InnerHtmlOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
128
|
+
if (propertyKey) { // no parameter option @decorator
|
|
129
|
+
return decorator({useShadow: true}, optionOrTarget!, propertyKey);
|
|
73
130
|
}
|
|
131
|
+
// parameter option @decorator()
|
|
132
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
133
|
+
decorator({...optionOrTarget??{}, useShadow: true}, target, propertyKey);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
74
136
|
|
|
137
|
+
export function onConnectedLightDom(options: Omit<InnerHtmlOptions, 'useShadow'>): MethodDecorator; // 파라미터있음
|
|
138
|
+
export function onConnectedLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // 파라미터없음
|
|
139
|
+
export function onConnectedLightDom(optionOrTarget: Omit<InnerHtmlOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
140
|
+
if (propertyKey) { // no parameter option @decorator
|
|
141
|
+
return decorator({useShadow: false}, optionOrTarget!, propertyKey);
|
|
142
|
+
}
|
|
143
|
+
// parameter option @decorator()
|
|
75
144
|
return (target: Object, propertyKey: string | symbol) => {
|
|
76
|
-
decorator(
|
|
145
|
+
decorator({...optionOrTarget??{}, useShadow: false}, target, propertyKey);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export function onConnected(options: InnerHtmlOptions): MethodDecorator;
|
|
149
|
+
export function onConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
150
|
+
export function onConnected(optionOrTarget: InnerHtmlOptions | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
151
|
+
if (propertyKey) { // no parameter option @decorator
|
|
152
|
+
return decorator({}, optionOrTarget!, propertyKey);
|
|
153
|
+
}
|
|
154
|
+
// parameter option @decorator()
|
|
155
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
156
|
+
decorator((optionOrTarget as InnerHtmlOptions) || {}, target, propertyKey);
|
|
77
157
|
};
|
|
78
158
|
}
|
|
79
159
|
|
|
80
160
|
/**
|
|
81
161
|
* 프로토타입 체인을 순회하며 모든 라이프사이클 메서드를 수집합니다.
|
|
82
162
|
*/
|
|
83
|
-
export const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {
|
|
84
|
-
|
|
85
|
-
|
|
163
|
+
// export const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {
|
|
164
|
+
export const findAllLifecycleMetadata = (target: any, metadataKey: symbol): (string | symbol)[] => {
|
|
165
|
+
const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target)??[];
|
|
166
|
+
return results;
|
|
86
167
|
};
|
|
87
168
|
|
|
88
|
-
export const
|
|
169
|
+
export const findAllOnConnectedMetadata = (target: any): InnerHtmlMetadata[] => {
|
|
170
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
171
|
+
return ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
172
|
+
};
|
|
173
|
+
export const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {
|
|
174
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
175
|
+
return ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
176
|
+
};
|
|
177
|
+
export const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {
|
|
89
178
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
90
|
-
return ReflectUtils.getMetadata(
|
|
179
|
+
return ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
91
180
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SwcUtils } from '../utils/Utils';
|
|
1
|
+
import {ReflectUtils} from '@dooboostore/core';
|
|
2
|
+
import {SwcUtils} from '../utils/Utils';
|
|
4
3
|
|
|
5
4
|
export const PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for('simple-web-component:publish-swc-app-message');
|
|
6
5
|
|
package/src/decorators/query.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ReflectUtils } from '@dooboostore/core';
|
|
2
2
|
import { getElementConfig, ensureInit } from './elementDefine';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
|
-
import { SpecialSelector, SwcQueryOptions } from '../types';
|
|
4
|
+
import { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
|
|
5
5
|
|
|
6
6
|
export interface QueryMetadata {
|
|
7
7
|
propertyKey: string | symbol;
|
|
8
8
|
selector: string;
|
|
9
|
-
options: SwcQueryOptions;
|
|
9
|
+
options: SwcQueryOptions ;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const QUERY_METADATA_KEY = Symbol.for('simple-web-component:query');
|
|
@@ -180,7 +180,7 @@ export function queryAppHost(targetOrOptions?: any, propertyKey?: string | symbo
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
export const getQueryMetadata = (target: any): QueryMetadata[]
|
|
183
|
+
export const getQueryMetadata = (target: any): QueryMetadata[] => {
|
|
184
184
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
185
|
-
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
185
|
+
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor) ?? [];
|
|
186
186
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReflectUtils } from '@dooboostore/core';
|
|
2
2
|
import { getElementConfig, ensureInit } from './elementDefine';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
|
-
import { SpecialSelector, SwcQueryOptions } from '../types';
|
|
4
|
+
import { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
|
|
5
5
|
|
|
6
6
|
export interface QueryAllMetadata {
|
|
7
7
|
propertyKey: string | symbol;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReflectUtils } from '@dooboostore/core';
|
|
2
2
|
import { ensureInit } from './elementDefine';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
|
-
import {
|
|
4
|
+
import { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
|
|
5
5
|
|
|
6
6
|
export interface PropertySetOptions extends SwcQueryOptions {
|
|
7
7
|
name?: string;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {ReflectUtils} from '@dooboostore/core';
|
|
2
|
+
import {ElementApply} from "@dooboostore/core-web";
|
|
3
|
+
import {SwcUtils} from "../utils/Utils";
|
|
4
|
+
import {getElementConfig} from "./elementDefine";
|
|
5
|
+
|
|
6
|
+
export interface StateMetadata {
|
|
7
|
+
propertyKey: string | symbol;
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const STATE_METADATA_KEY = Symbol.for('simple-web-component:state');
|
|
12
|
+
|
|
13
|
+
// export function state(target: SpecialSelector): PropertyDecorator;
|
|
14
|
+
// export function state(): PropertyDecorator;
|
|
15
|
+
export function state(target: Object, propertyKey: string | symbol): void;
|
|
16
|
+
export function state(name: string): PropertyDecorator;
|
|
17
|
+
/**
|
|
18
|
+
* Supports both forms:
|
|
19
|
+
* - @state
|
|
20
|
+
* - @state()
|
|
21
|
+
* - @state('selector')
|
|
22
|
+
*/
|
|
23
|
+
export function state(nameOrTarget?: string | Object, propertyKey?: string | symbol): any {
|
|
24
|
+
|
|
25
|
+
const stateDefine = (targetObj: any, stateMetadata: StateMetadata) => {
|
|
26
|
+
|
|
27
|
+
let storage = targetObj[stateMetadata.propertyKey];
|
|
28
|
+
// console.log('ssssssssssssssss', storage, stateMetadata.propertyKey)
|
|
29
|
+
Object.defineProperty(targetObj, stateMetadata.propertyKey, {
|
|
30
|
+
set(this: any, nv: string) {
|
|
31
|
+
console.log('setState!!', nv)
|
|
32
|
+
storage = nv;
|
|
33
|
+
const config = getElementConfig(this)
|
|
34
|
+
const ea = new ElementApply(this, {id: this._swcId});
|
|
35
|
+
const helperHostSet = SwcUtils.getHelperAndHostSet(config.window, this);
|
|
36
|
+
const stateContext: any = {...helperHostSet};
|
|
37
|
+
findAllStateMetadata(this).forEach(it => {
|
|
38
|
+
stateContext[it.name] = this[it.propertyKey]
|
|
39
|
+
})
|
|
40
|
+
ea.apply({context:stateContext, targetVariableName: stateMetadata.name, bind: this});
|
|
41
|
+
},
|
|
42
|
+
get(this: any) {
|
|
43
|
+
return storage;
|
|
44
|
+
},
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// If used as @state (no parentheses), TypeScript will call this function with (target, propertyKey)
|
|
51
|
+
if (typeof nameOrTarget === 'object' && propertyKey) {
|
|
52
|
+
const targetObj = nameOrTarget as Object;
|
|
53
|
+
const name = String(propertyKey);
|
|
54
|
+
const constructor = (targetObj as any).constructor;
|
|
55
|
+
let states = ReflectUtils.getMetadata<StateMetadata[]>(STATE_METADATA_KEY, constructor);
|
|
56
|
+
if (!states) {
|
|
57
|
+
states = [];
|
|
58
|
+
ReflectUtils.defineMetadata(STATE_METADATA_KEY, states, constructor);
|
|
59
|
+
}
|
|
60
|
+
const stateMetadata = {propertyKey, name};
|
|
61
|
+
states.push(stateMetadata);
|
|
62
|
+
stateDefine(targetObj, stateMetadata);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Otherwise return a decorator factory
|
|
67
|
+
return (targetObj: Object, propertyKey: string | symbol): void => {
|
|
68
|
+
const name = String(nameOrTarget);
|
|
69
|
+
const constructor = targetObj.constructor;
|
|
70
|
+
let states = ReflectUtils.getMetadata<StateMetadata[]>(STATE_METADATA_KEY, constructor);
|
|
71
|
+
if (!states) {
|
|
72
|
+
states = [];
|
|
73
|
+
ReflectUtils.defineMetadata(STATE_METADATA_KEY, states, constructor);
|
|
74
|
+
}
|
|
75
|
+
const stateMetadata = {propertyKey, name};
|
|
76
|
+
states.push(stateMetadata);
|
|
77
|
+
stateDefine(targetObj, stateMetadata);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const findAllStateMetadata = (target: any): StateMetadata[] => {
|
|
82
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
83
|
+
return ReflectUtils.getMetadata(STATE_METADATA_KEY, constructor) ?? [];
|
|
84
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
-
import { SwcAppMessage } from '../types';
|
|
2
|
+
import { SwcAppMessage, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
|
|
3
3
|
|
|
4
4
|
export const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');
|
|
5
5
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {ReflectUtils} from '@dooboostore/core';
|
|
2
|
+
import {Router} from '@dooboostore/core-web';
|
|
3
|
+
import {HelperHostSet} from '../types';
|
|
3
4
|
|
|
4
5
|
export const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');
|
|
5
6
|
|
|
@@ -12,7 +13,7 @@ export interface SwcAppRouteChangeSubscriberMetadata {
|
|
|
12
13
|
|
|
13
14
|
export interface SwcAppRouteChangeOptions {
|
|
14
15
|
path?: RoutePathType;
|
|
15
|
-
filter?: (router: Router, currentThis: any) => boolean;
|
|
16
|
+
filter?: (router: Router, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
function createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {elementDefine} from "../decorators";
|
|
2
|
+
import {SwcAppInterface} from "../types";
|
|
3
|
+
import {SwcAppMixin} from "./SwcAppMixin";
|
|
4
|
+
import {SwcUtils, createElement, CreateElementConfig} from "../utils/Utils";
|
|
5
|
+
|
|
6
|
+
// ============================================
|
|
7
|
+
// SwcApp (HTMLElement)
|
|
8
|
+
// ============================================
|
|
9
|
+
export const swcAppTagName = 'swc-app';
|
|
10
|
+
|
|
11
|
+
export const SwcApp = (w: Window, data?: CreateElementConfig) => {
|
|
12
|
+
return createElement<SwcAppInterface>(w, swcAppTagName, data);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const defineSwcApp = async (w: Window) => {
|
|
16
|
+
const existing = w.customElements.get(swcAppTagName);
|
|
17
|
+
if (existing) return existing;
|
|
18
|
+
|
|
19
|
+
@elementDefine(swcAppTagName, {window: w})
|
|
20
|
+
class SwcAppImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
21
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return w.customElements.whenDefined(swcAppTagName);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// ============================================
|
|
28
|
+
// SwcAppBody (HTMLBodyElement)
|
|
29
|
+
// ============================================
|
|
30
|
+
export const swcAppBodyTagName = 'swc-app-body';
|
|
31
|
+
|
|
32
|
+
export const SwcAppBody = (w: Window, data?: CreateElementConfig) => {
|
|
33
|
+
return createElement<SwcAppInterface & HTMLBodyElement>(w, swcAppBodyTagName, data);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const defineSwcAppBody = async (w: Window) => {
|
|
37
|
+
const existing = w.customElements.get(swcAppBodyTagName);
|
|
38
|
+
if (existing) return existing;
|
|
39
|
+
|
|
40
|
+
@elementDefine(swcAppBodyTagName, {window: w, extends: 'body'})
|
|
41
|
+
class SwcAppBodyImpl extends SwcAppMixin(w.HTMLBodyElement) implements SwcAppInterface {
|
|
42
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return w.customElements.whenDefined(swcAppBodyTagName);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// ============================================
|
|
49
|
+
// SwcAppDiv (HTMLDivElement)
|
|
50
|
+
// ============================================
|
|
51
|
+
export const swcAppDivTagName = 'swc-app-div';
|
|
52
|
+
|
|
53
|
+
export const SwcAppDiv = (w: Window, data?: CreateElementConfig) => {
|
|
54
|
+
return createElement<SwcAppInterface & HTMLDivElement>(w, swcAppDivTagName, data);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const defineSwcAppDiv = async (w: Window) => {
|
|
58
|
+
const existing = w.customElements.get(swcAppDivTagName);
|
|
59
|
+
if (existing) return existing;
|
|
60
|
+
|
|
61
|
+
@elementDefine(swcAppDivTagName, {window: w, extends: 'div'})
|
|
62
|
+
class SwcAppDivImpl extends SwcAppMixin(w.HTMLDivElement) implements SwcAppInterface {
|
|
63
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return w.customElements.whenDefined(swcAppDivTagName);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// ============================================
|
|
70
|
+
// SwcAppSection (HTMLElement)
|
|
71
|
+
// ============================================
|
|
72
|
+
export const swcAppSectionTagName = 'swc-app-section';
|
|
73
|
+
|
|
74
|
+
export const SwcAppSection = (w: Window, data?: CreateElementConfig) => {
|
|
75
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppSectionTagName, data);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const defineSwcAppSection = async (w: Window) => {
|
|
79
|
+
const existing = w.customElements.get(swcAppSectionTagName);
|
|
80
|
+
if (existing) return existing;
|
|
81
|
+
|
|
82
|
+
@elementDefine(swcAppSectionTagName, {window: w, extends: 'section'})
|
|
83
|
+
class SwcAppSectionImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
84
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return w.customElements.whenDefined(swcAppSectionTagName);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// ============================================
|
|
91
|
+
// SwcAppMain (HTMLElement)
|
|
92
|
+
// ============================================
|
|
93
|
+
export const swcAppMainTagName = 'swc-app-main';
|
|
94
|
+
|
|
95
|
+
export const SwcAppMain = (w: Window, data?: CreateElementConfig) => {
|
|
96
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppMainTagName, data);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const defineSwcAppMain = async (w: Window) => {
|
|
100
|
+
const existing = w.customElements.get(swcAppMainTagName);
|
|
101
|
+
if (existing) return existing;
|
|
102
|
+
|
|
103
|
+
@elementDefine(swcAppMainTagName, {window: w, extends: 'main'})
|
|
104
|
+
class SwcAppMainImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
105
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return w.customElements.whenDefined(swcAppMainTagName);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// ============================================
|
|
112
|
+
// SwcAppArticle (HTMLElement)
|
|
113
|
+
// ============================================
|
|
114
|
+
export const swcAppArticleTagName = 'swc-app-article';
|
|
115
|
+
|
|
116
|
+
export const SwcAppArticle = (w: Window, data?: CreateElementConfig) => {
|
|
117
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppArticleTagName, data);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const defineSwcAppArticle = async (w: Window) => {
|
|
121
|
+
const existing = w.customElements.get(swcAppArticleTagName);
|
|
122
|
+
if (existing) return existing;
|
|
123
|
+
|
|
124
|
+
@elementDefine(swcAppArticleTagName, {window: w, extends: 'article'})
|
|
125
|
+
class SwcAppArticleImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
126
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return w.customElements.whenDefined(swcAppArticleTagName);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// ============================================
|
|
133
|
+
// SwcAppHeader (HTMLElement)
|
|
134
|
+
// ============================================
|
|
135
|
+
export const swcAppHeaderTagName = 'swc-app-header';
|
|
136
|
+
|
|
137
|
+
export const SwcAppHeader = (w: Window, data?: CreateElementConfig) => {
|
|
138
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppHeaderTagName, data);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const defineSwcAppHeader = async (w: Window) => {
|
|
142
|
+
const existing = w.customElements.get(swcAppHeaderTagName);
|
|
143
|
+
if (existing) return existing;
|
|
144
|
+
|
|
145
|
+
@elementDefine(swcAppHeaderTagName, {window: w, extends: 'header'})
|
|
146
|
+
class SwcAppHeaderImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
147
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return w.customElements.whenDefined(swcAppHeaderTagName);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// ============================================
|
|
154
|
+
// SwcAppFooter (HTMLElement)
|
|
155
|
+
// ============================================
|
|
156
|
+
export const swcAppFooterTagName = 'swc-app-footer';
|
|
157
|
+
|
|
158
|
+
export const SwcAppFooter = (w: Window, data?: CreateElementConfig) => {
|
|
159
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppFooterTagName, data);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const defineSwcAppFooter = async (w: Window) => {
|
|
163
|
+
const existing = w.customElements.get(swcAppFooterTagName);
|
|
164
|
+
if (existing) return existing;
|
|
165
|
+
|
|
166
|
+
@elementDefine(swcAppFooterTagName, {window: w, extends: 'footer'})
|
|
167
|
+
class SwcAppFooterImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
168
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return w.customElements.whenDefined(swcAppFooterTagName);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// ============================================
|
|
175
|
+
// SwcAppNav (HTMLElement)
|
|
176
|
+
// ============================================
|
|
177
|
+
export const swcAppNavTagName = 'swc-app-nav';
|
|
178
|
+
|
|
179
|
+
export const SwcAppNav = (w: Window, data?: CreateElementConfig) => {
|
|
180
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppNavTagName, data);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const defineSwcAppNav = async (w: Window) => {
|
|
184
|
+
const existing = w.customElements.get(swcAppNavTagName);
|
|
185
|
+
if (existing) return existing;
|
|
186
|
+
|
|
187
|
+
@elementDefine(swcAppNavTagName, {window: w, extends: 'nav'})
|
|
188
|
+
class SwcAppNavImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
189
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return w.customElements.whenDefined(swcAppNavTagName);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// ============================================
|
|
196
|
+
// SwcAppAside (HTMLElement)
|
|
197
|
+
// ============================================
|
|
198
|
+
export const swcAppAsideTagName = 'swc-app-aside';
|
|
199
|
+
|
|
200
|
+
export const SwcAppAside = (w: Window, data?: CreateElementConfig) => {
|
|
201
|
+
return createElement<SwcAppInterface & HTMLElement>(w, swcAppAsideTagName, data);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const defineSwcAppAside = async (w: Window) => {
|
|
205
|
+
const existing = w.customElements.get(swcAppAsideTagName);
|
|
206
|
+
if (existing) return existing;
|
|
207
|
+
|
|
208
|
+
@elementDefine(swcAppAsideTagName, {window: w, extends: 'aside'})
|
|
209
|
+
class SwcAppAsideImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
210
|
+
// SwcAppMixin에서 모든 기능을 상속받음
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return w.customElements.whenDefined(swcAppAsideTagName);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// ============================================
|
|
217
|
+
// Factory Array
|
|
218
|
+
// ============================================
|
|
219
|
+
export const swcAppFactories = [
|
|
220
|
+
defineSwcApp,
|
|
221
|
+
defineSwcAppBody,
|
|
222
|
+
defineSwcAppDiv,
|
|
223
|
+
defineSwcAppSection,
|
|
224
|
+
defineSwcAppMain,
|
|
225
|
+
defineSwcAppArticle,
|
|
226
|
+
defineSwcAppHeader,
|
|
227
|
+
defineSwcAppFooter,
|
|
228
|
+
defineSwcAppNav,
|
|
229
|
+
defineSwcAppAside
|
|
230
|
+
];
|
|
231
|
+
|
|
232
|
+
// ============================================
|
|
233
|
+
// Define All SwcApp Elements
|
|
234
|
+
// ============================================
|
|
235
|
+
export const defineSwcAppAll = async (w: Window) => {
|
|
236
|
+
await Promise.all(swcAppFactories.map(factory => factory(w)));
|
|
237
|
+
return w.customElements.whenDefined(swcAppTagName);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// Default export for backward compatibility
|
|
241
|
+
export default defineSwcAppAll;
|