@dooboostore/simple-web-component 1.0.33 → 1.0.35
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 +23 -30
- 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 +5 -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 +238 -180
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +67 -48
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +15 -17
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +50 -39
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +14 -8
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +154 -81
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +28 -18
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +68 -45
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +52 -30
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +109 -35
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/register.js +263 -131
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -2
- package/dist/cjs/router/ElementRouter.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +25 -7
- 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 +5 -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 +240 -182
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +67 -48
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +15 -17
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +50 -39
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +14 -7
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +156 -82
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +28 -18
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +69 -46
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +53 -31
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +110 -36
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/register.js +264 -132
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +5 -2
- package/dist/esm/router/ElementRouter.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +25 -7
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +728 -595
- 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 +5 -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 +14 -3
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +15 -7
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +10 -7
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- 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 +2 -2
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -6
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +9 -3
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +12 -7
- 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 +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +4 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +728 -595
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +5 -5
- 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 +16 -13
- package/src/decorators/applyStyle.ts +75 -61
- package/src/decorators/attribute.ts +55 -43
- package/src/decorators/changedAttributeHost.ts +49 -15
- package/src/decorators/elementDefine.ts +401 -340
- package/src/decorators/emitCustomEvent.ts +92 -62
- package/src/decorators/lifecycles.ts +11 -10
- package/src/decorators/setProperty.ts +58 -44
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +11 -11
- package/src/elements/SwcAppEngine.ts +19 -13
- package/src/elements/SwcAppMixin.ts +214 -102
- package/src/elements/SwcAsync.ts +28 -17
- package/src/elements/SwcChoose.ts +94 -36
- package/src/elements/SwcIf.ts +59 -22
- package/src/elements/SwcLoop.ts +140 -27
- package/src/elements/register.ts +319 -100
- package/src/types.ts +1 -0
- package/src/utils/Utils.ts +38 -10
- package/tsconfig.json +2 -2
|
@@ -21,48 +21,59 @@ const setProperty = (selector, propertyNameOrOptions, options = {}) => {
|
|
|
21
21
|
options: { ...finalOptions, name: propertyName }
|
|
22
22
|
});
|
|
23
23
|
const original = descriptor.value;
|
|
24
|
-
descriptor.value =
|
|
24
|
+
descriptor.value = function(...args) {
|
|
25
25
|
ensureInit(this);
|
|
26
|
-
const res =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
const res = original.apply(this, args);
|
|
27
|
+
const handleResult = (resolvedValue) => {
|
|
28
|
+
if (resolvedValue !== void 0) {
|
|
29
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
30
|
+
const host = this;
|
|
31
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
32
|
+
const r = finalOptions.root || "auto";
|
|
33
|
+
const targetEls = [];
|
|
34
|
+
const applyRoot = (t) => {
|
|
35
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
36
|
+
targetEls.push(t);
|
|
37
|
+
};
|
|
38
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
39
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
40
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
41
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
42
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
43
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
44
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
45
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
46
|
+
else if (selector === ":host" || !selector) applyRoot(host);
|
|
47
|
+
else {
|
|
48
|
+
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
49
|
+
if (targetRoot) {
|
|
50
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
51
|
+
if (found) targetEls.push(...Array.from(found));
|
|
52
|
+
}
|
|
51
53
|
}
|
|
54
|
+
targetEls.forEach((targetEl) => {
|
|
55
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
59
|
+
if (propertyName) {
|
|
60
|
+
targetEl[propertyName] = resolvedRes;
|
|
61
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
62
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
63
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
64
|
+
targetEl[prop] = finalVal;
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
targetEl.value = resolvedRes;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
52
70
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
60
|
-
targetEl[prop] = finalVal;
|
|
61
|
-
});
|
|
62
|
-
} else {
|
|
63
|
-
targetEl.value = resolvedRes;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
71
|
+
return resolvedValue;
|
|
72
|
+
};
|
|
73
|
+
if (res instanceof Promise) {
|
|
74
|
+
return res.then(handleResult);
|
|
75
|
+
} else {
|
|
76
|
+
return handleResult(res);
|
|
66
77
|
}
|
|
67
78
|
};
|
|
68
79
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/setProperty.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport interface PropertySetOptions extends SwcQueryOptions {\n name?: string;\n}\n\nexport interface PropertySetMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: PropertySetOptions;\n}\n\nexport const PROPERTY_SET_METADATA_KEY = Symbol.for('simple-web-component:property-set');\n\nexport const setProperty = (selector: string, propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor) as Map<string | symbol, PropertySetMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, PropertySetMetadata>();\n ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);\n }\n\n let propertyName = typeof propertyNameOrOptions === 'string' ? propertyNameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof propertyNameOrOptions === 'object' && propertyNameOrOptions !== null) {\n finalOptions = propertyNameOrOptions as PropertySetOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n options: { ...finalOptions, name: propertyName } \n });\n\n const original = descriptor.value;\n descriptor.value =
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { HelperHostSet, SwcQueryOptions } from '../types';\n\nexport interface PropertySetOptions extends SwcQueryOptions {\n name?: string;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface PropertySetMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: PropertySetOptions;\n}\n\nexport const PROPERTY_SET_METADATA_KEY = Symbol.for('simple-web-component:property-set');\n\nexport const setProperty = (selector: string, propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor) as Map<string | symbol, PropertySetMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, PropertySetMetadata>();\n ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);\n }\n\n let propertyName = typeof propertyNameOrOptions === 'string' ? propertyNameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof propertyNameOrOptions === 'object' && propertyNameOrOptions !== null) {\n finalOptions = propertyNameOrOptions as PropertySetOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n options: { ...finalOptions, name: propertyName } \n });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(host);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (propertyName) {\n // Case: @setProperty(selector, 'propertyName')\n (targetEl as any)[propertyName] = resolvedRes;\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @setProperty(selector) with Object return - assign multiple properties\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n (targetEl as any)[prop] = finalVal;\n });\n } else {\n // Simple value - assign to 'value' property by default\n (targetEl as any).value = resolvedRes;\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n};\n\nexport const setPropertyHost = (propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return setProperty(':host', propertyNameOrOptions, options);\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/subscribeSwcAppMessageWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,yDAAyD,OAAO,IAAI,gEAAgE;AAYjJ,SAAS,2CAA2C,SAAgC,aAAuC;AACzH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,wDAAwD,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,wDAAwD,MAAM,WAAW;AAAA,IACvG;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,qCAAqC,8BAAoC,sBAA4B,YAAsC;AAEzJ,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,2CAA2C,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,2CAA2C,SAAS,WAAW;AACxE;AAGO,MAAM,kDAAkD,CAAC,WAA+D;AAC7H,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,wDAAwD,WAAW;AACxG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,7 +10,7 @@ function createSubscribeSwcAppRouteChangeWhileConnected(options) {
|
|
|
10
10
|
list = [];
|
|
11
11
|
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
12
12
|
}
|
|
13
|
-
list.push({ propertyKey,
|
|
13
|
+
list.push({ propertyKey, options });
|
|
14
14
|
return descriptor;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -21,7 +21,7 @@ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKey,
|
|
|
21
21
|
let options = {};
|
|
22
22
|
if (Array.isArray(targetOrOptions)) {
|
|
23
23
|
options.path = targetOrOptions;
|
|
24
|
-
} else if (typeof targetOrOptions === "string") {
|
|
24
|
+
} else if (typeof targetOrOptions === "string" || typeof targetOrOptions === "function") {
|
|
25
25
|
options.path = targetOrOptions;
|
|
26
26
|
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
27
27
|
options = targetOrOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { Router } from '@dooboostore/core-web';\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
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { Router } from '@dooboostore/core-web';\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, currentThis: any) => 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,SAAS,oBAAoB;AAGtB,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
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import { SimpleApplication } from "@dooboostore/simple-boot/SimpleApplication";
|
|
2
|
-
import { PathRouter } from "@dooboostore/core-web";
|
|
3
|
-
import { HashRouter } from "@dooboostore/core-web";
|
|
5
|
+
import { HashRouter, PathRouter, Router } from "@dooboostore/core-web";
|
|
4
6
|
import { ElementRouter } from "../router/ElementRouter.js";
|
|
5
7
|
import { SimOption } from "@dooboostore/simple-boot/SimOption";
|
|
6
|
-
import { Router } from "@dooboostore/core-web";
|
|
7
8
|
class SwcAppEngine {
|
|
8
9
|
constructor(host) {
|
|
9
10
|
this.host = host;
|
|
11
|
+
__publicField(this, "simpleApplication");
|
|
12
|
+
__publicField(this, "router");
|
|
13
|
+
__publicField(this, "routerSubscription");
|
|
14
|
+
__publicField(this, "_config");
|
|
10
15
|
}
|
|
11
16
|
get config() {
|
|
12
17
|
return this._config;
|
|
@@ -21,21 +26,23 @@ class SwcAppEngine {
|
|
|
21
26
|
} else if (this._config.routeType === "element") {
|
|
22
27
|
this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });
|
|
23
28
|
}
|
|
24
|
-
const containerSymbol = this._config.container || this.host.getContainerSymbol?.();
|
|
25
29
|
this.simpleApplication = new SimpleApplication(
|
|
26
30
|
new SimOption({
|
|
27
|
-
excludeProxys: [Node],
|
|
28
|
-
container:
|
|
31
|
+
excludeProxys: [this._config.window.Node],
|
|
32
|
+
container: this._config.container
|
|
29
33
|
})
|
|
30
34
|
);
|
|
31
35
|
const otherInstanceSim = /* @__PURE__ */ new Map();
|
|
36
|
+
this.config?.otherInstanceSim?.forEach((v, k) => {
|
|
37
|
+
otherInstanceSim.set(k, v);
|
|
38
|
+
});
|
|
32
39
|
if (this.router) otherInstanceSim.set(Router, this.router);
|
|
33
40
|
this.simpleApplication.run(otherInstanceSim);
|
|
34
41
|
if (this._config.onEngineStarted) {
|
|
35
42
|
this._config.onEngineStarted(this.simpleApplication, this.host);
|
|
36
43
|
}
|
|
37
44
|
} catch (e) {
|
|
38
|
-
console.error("[SWC-APP-ENGINE] Init failed:", e);
|
|
45
|
+
console.error("[SWC-APP-ENGINE] Init failed:", e, this._config);
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
disconnect() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/SwcAppEngine.ts"],
|
|
4
|
-
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { HashRouter, PathRouter, Router, RouterEventType } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { ConstructorType, OptionalType, Subscription } from '@dooboostore/core';\n\nimport { SwcAppInterface } from '../types';\nimport { SimConfig } from '@dooboostore/simple-boot';\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap' | 'clear-swap';\n container?: symbol;\n otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n\n onChildrenConnectedDone?: (app: SwcAppInterface) => void;\n // onChildrenSwcAppStartedDone?: (app: SwcAppInterface) => void;\n // childrenSwcAppStartedDoneCheckIntervalTime?: number;\n onChildrenRouteChanged?: (event: RouterEventType, app: SwcAppInterface) => void;\n childrenRouteChangedCheckIntervalTime?: number; // \uC790\uC2DD \uC5F0\uACB0 \uC644\uB8CC \uC774\uBCA4\uD2B8 \uB514\uBC14\uC6B4\uC2A4 \uD0C0\uC784 (ms)\n childrenConnectedDoneCheckIntervalTime?: number;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n\n async connect(config: SwcConfigType) {\n try {\n this._config = config;\n\n // Router Selection\n if (this._config.routeType === 'path') {\n this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [(this._config.window as any).Node],\n container: this._config.container\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n this.config?.otherInstanceSim?.forEach((v, k) => {\n otherInstanceSim.set(k, v);\n });\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n if (this._config.onEngineStarted) {\n this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,SAAS,yBAAyB;AAClC,SAAS,YAAY,YAAY,cAA+B;AAChE,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AA2BnB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AALpB,wBAAO;AACP,wBAAO;AACP,wBAAQ;AACR,wBAAQ;AAAA,EAEgC;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,cAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,UAAU;AAAA,UACZ,eAAe,CAAE,KAAK,QAAQ,OAAe,IAAI;AAAA,UACjD,WAAW,KAAK,QAAQ;AAAA,QAC1B,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,WAAK,QAAQ,kBAAkB,QAAQ,CAAC,GAAG,MAAM;AAC/C,yBAAiB,IAAI,GAAG,CAAC;AAAA,MAC3B,CAAC;AACD,UAAI,KAAK,OAAQ,kBAAiB,IAAI,QAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAE3C,UAAI,KAAK,QAAQ,iBAAiB;AAChC,aAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MAC9F;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,GAAG,KAAK,OAAO;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,133 +1,208 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import { SwcAppEngine } from "./SwcAppEngine.js";
|
|
2
5
|
import { SwcUtils } from "../utils/Utils.js";
|
|
3
|
-
import { FunctionUtils } from "@dooboostore/core";
|
|
4
|
-
import { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from "../decorators/lifecycles.js";
|
|
6
|
+
import { debounceTimeIntervalLock, FunctionUtils } from "@dooboostore/core";
|
|
5
7
|
import { getSubscribeSwcAppRouteChangeWhileConnectedMetadata } from "../decorators/subscribeSwcAppRouteChangeWhileConnected.js";
|
|
6
8
|
import { getSubscribeSwcAppMessageWhileConnectedMetadata } from "../decorators/subscribeSwcAppMessageWhileConnected.js";
|
|
7
9
|
function SwcAppMixin(Base) {
|
|
8
10
|
return class extends Base {
|
|
9
11
|
constructor() {
|
|
10
12
|
super(...arguments);
|
|
11
|
-
this
|
|
12
|
-
this
|
|
13
|
-
|
|
13
|
+
__publicField(this, "__swc_engine", new SwcAppEngine(this));
|
|
14
|
+
__publicField(this, "_swc_connected_instance", /* @__PURE__ */ new Set());
|
|
15
|
+
// _swc_notified_routes = new WeakMap<any, RouterEventType>();
|
|
16
|
+
__publicField(this, "_routerSubscription");
|
|
17
|
+
__publicField(this, "_lastRouterEvent");
|
|
18
|
+
__publicField(this, "_routeChangeInvocations", 0);
|
|
19
|
+
__publicField(this, "_connectedInvocations", 0);
|
|
20
|
+
__publicField(this, "_childrenRouteChangedInterval");
|
|
21
|
+
__publicField(this, "_childrenConnectedDoneInterval");
|
|
22
|
+
/*
|
|
23
|
+
사파리 is 일경우
|
|
24
|
+
<script src="https://unpkg.com/@ungap/custom-elements"><\/script>
|
|
25
|
+
이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
|
|
26
|
+
저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
|
|
27
|
+
*/
|
|
28
|
+
__publicField(this, "_connected_safari", []);
|
|
14
29
|
}
|
|
15
30
|
get simpleApplication() {
|
|
16
31
|
return this.__swc_engine.simpleApplication;
|
|
17
32
|
}
|
|
33
|
+
get config() {
|
|
34
|
+
return this.__swc_engine?.config;
|
|
35
|
+
}
|
|
18
36
|
get router() {
|
|
19
|
-
return this.__swc_engine
|
|
20
|
-
}
|
|
21
|
-
_invokeRouteChangeSubscribers(instance, re) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
return this.__swc_engine?.router;
|
|
38
|
+
}
|
|
39
|
+
async _invokeRouteChangeSubscribers(instance, re) {
|
|
40
|
+
if (instance.isConnected === false) return;
|
|
41
|
+
this._routeChangeInvocations++;
|
|
42
|
+
if (this._childrenRouteChangedInterval) {
|
|
43
|
+
clearInterval(this._childrenRouteChangedInterval);
|
|
44
|
+
}
|
|
45
|
+
this._childrenRouteChangedInterval = debounceTimeIntervalLock(
|
|
46
|
+
() => this._routeChangeInvocations === 0,
|
|
47
|
+
() => {
|
|
48
|
+
this._childrenRouteChangedInterval = null;
|
|
49
|
+
this.config.onChildrenRouteChanged(re, this);
|
|
50
|
+
},
|
|
51
|
+
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
52
|
+
{ setInterval: window.setInterval, clearInterval: window.clearInterval }
|
|
53
|
+
// {setInterval: window.setInterval, clearInterval: window.clearInterval}
|
|
54
|
+
);
|
|
55
|
+
try {
|
|
56
|
+
const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
|
|
57
|
+
if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
|
|
58
|
+
const ps = routeChangeSubscribers.map(async (metadata) => {
|
|
59
|
+
const methodName = metadata.propertyKey;
|
|
60
|
+
let pathPattern = metadata.options?.path;
|
|
61
|
+
const filter = metadata.options?.filter;
|
|
62
|
+
if (typeof pathPattern === "function") {
|
|
63
|
+
pathPattern = pathPattern(instance);
|
|
64
|
+
}
|
|
65
|
+
let pathMatched = false;
|
|
66
|
+
let pathData = null;
|
|
67
|
+
if (!pathPattern) {
|
|
68
|
+
pathMatched = true;
|
|
69
|
+
pathData = {};
|
|
70
|
+
} else if (Array.isArray(pathPattern)) {
|
|
71
|
+
for (const pattern of pathPattern) {
|
|
72
|
+
const data = SwcUtils.parsePathPattern(pattern, re.path || "/");
|
|
73
|
+
if (data !== null) {
|
|
74
|
+
pathMatched = true;
|
|
75
|
+
pathData = data;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
40
78
|
}
|
|
79
|
+
} else {
|
|
80
|
+
pathData = SwcUtils.parsePathPattern(pathPattern, re.path || "/");
|
|
81
|
+
pathMatched = pathData !== null;
|
|
41
82
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
83
|
+
const filterPassed = !filter || filter(this.router, instance);
|
|
84
|
+
if (pathMatched && filterPassed && instance[methodName]) {
|
|
85
|
+
await instance[methodName]({ ...re, pathData });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
await Promise.allSettled(ps);
|
|
89
|
+
}
|
|
90
|
+
} finally {
|
|
91
|
+
this._routeChangeInvocations--;
|
|
51
92
|
}
|
|
52
93
|
}
|
|
53
|
-
_connected(instance) {
|
|
94
|
+
async _connected(instance) {
|
|
54
95
|
if (instance) {
|
|
96
|
+
this._connectedInvocations++;
|
|
55
97
|
this._swc_connected_instance.add(instance);
|
|
98
|
+
if (this._childrenConnectedDoneInterval) {
|
|
99
|
+
clearInterval(this._childrenConnectedDoneInterval);
|
|
100
|
+
}
|
|
101
|
+
this._childrenConnectedDoneInterval = debounceTimeIntervalLock(
|
|
102
|
+
() => this._connectedInvocations === 0,
|
|
103
|
+
() => {
|
|
104
|
+
this._childrenConnectedDoneInterval = null;
|
|
105
|
+
this.config.onChildrenConnectedDone(this);
|
|
106
|
+
},
|
|
107
|
+
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
108
|
+
{ setInterval: window.setInterval, clearInterval: window.clearInterval }
|
|
109
|
+
);
|
|
56
110
|
if (this.simpleApplication) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
111
|
+
try {
|
|
112
|
+
if (this.router && this._lastRouterEvent) {
|
|
113
|
+
await this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);
|
|
114
|
+
}
|
|
115
|
+
} catch (e) {
|
|
116
|
+
throw e;
|
|
60
117
|
}
|
|
61
118
|
}
|
|
62
119
|
}
|
|
63
120
|
}
|
|
121
|
+
async _connectedDone(instance) {
|
|
122
|
+
try {
|
|
123
|
+
} finally {
|
|
124
|
+
this._connectedInvocations--;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
64
127
|
_disconnected(instance) {
|
|
65
128
|
if (instance) {
|
|
66
129
|
this._swc_connected_instance.delete(instance);
|
|
67
130
|
}
|
|
68
131
|
}
|
|
69
|
-
_handleRouteChange(route) {
|
|
70
|
-
if (route.triggerPoint === "end") {
|
|
71
|
-
this._swc_connected_instance.forEach((instance) => {
|
|
72
|
-
this._invokeRouteChangeSubscribers(instance, route);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
132
|
+
async _handleRouteChange(route) {
|
|
75
133
|
this._lastRouterEvent = route;
|
|
134
|
+
const swcConnectedInstance = Array.from(this._swc_connected_instance);
|
|
135
|
+
const ps = swcConnectedInstance.map((instance) => this._invokeRouteChangeSubscribers(instance, route));
|
|
136
|
+
await Promise.allSettled(ps);
|
|
76
137
|
}
|
|
77
138
|
async connect(config) {
|
|
78
139
|
const swcConfig = {
|
|
79
140
|
routeType: "element",
|
|
80
|
-
window: config
|
|
141
|
+
window: config?.window,
|
|
81
142
|
...config
|
|
82
143
|
};
|
|
83
144
|
const mode = config?.connectMode || "direct";
|
|
84
145
|
if (mode === "direct") {
|
|
85
146
|
await this.__swc_engine.connect(swcConfig);
|
|
86
147
|
this.setAttribute("swc-connect-mode", "direct");
|
|
87
|
-
} else if (mode === "swap"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
148
|
+
} else if (mode === "swap" || mode === "clear-swap") {
|
|
149
|
+
if (!this.parentNode) {
|
|
150
|
+
await this.__swc_engine.connect(swcConfig);
|
|
151
|
+
this.setAttribute("swc-connect-mode", "direct");
|
|
152
|
+
} else {
|
|
153
|
+
const clonedApp = this.cloneNode(mode === "swap");
|
|
154
|
+
clonedApp.style.display = "none";
|
|
155
|
+
this.parentNode.insertBefore(clonedApp, this.nextSibling);
|
|
156
|
+
try {
|
|
157
|
+
await clonedApp.connect({ ...config || {}, connectMode: "direct" });
|
|
158
|
+
if (this.parentNode) {
|
|
159
|
+
this.parentNode.removeChild(this);
|
|
160
|
+
}
|
|
161
|
+
clonedApp.style.display = "";
|
|
162
|
+
clonedApp.setAttribute("swc-connect-mode", mode);
|
|
163
|
+
return;
|
|
164
|
+
} catch (e) {
|
|
165
|
+
if (clonedApp.parentNode) {
|
|
166
|
+
clonedApp.parentNode.removeChild(clonedApp);
|
|
167
|
+
}
|
|
168
|
+
await this.__swc_engine.connect(swcConfig);
|
|
169
|
+
this.setAttribute("swc-connect-mode", "direct");
|
|
103
170
|
}
|
|
104
|
-
throw e;
|
|
105
171
|
}
|
|
106
172
|
}
|
|
107
173
|
this._connected_safari.forEach((instance) => {
|
|
108
|
-
this.
|
|
109
|
-
});
|
|
110
|
-
this._swc_connected_instance.forEach((instance) => {
|
|
111
|
-
this._invokeOnConnectedSwcAppStarted(instance);
|
|
174
|
+
this._connected(instance);
|
|
112
175
|
});
|
|
113
176
|
if (!this._routerSubscription && this.router) {
|
|
114
|
-
this._routerSubscription = this.router.observable.subscribe((route) => {
|
|
115
|
-
this._handleRouteChange(route);
|
|
116
|
-
});
|
|
117
177
|
const config2 = this.__swc_engine.config;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
178
|
+
this._routerSubscription = this.router.observable.subscribe(async (route) => {
|
|
179
|
+
if (route.triggerPoint === "end") {
|
|
180
|
+
await this._handleRouteChange(route);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
if (config2?.path) {
|
|
184
|
+
this.router.go(config2.path);
|
|
125
185
|
}
|
|
126
186
|
}
|
|
127
187
|
}
|
|
188
|
+
// async _invokeOnConnectedSwcAppStarted(instance: any) {
|
|
189
|
+
// this._swcAppStartedInvocations++;
|
|
190
|
+
// try {
|
|
191
|
+
// // 이미 시작된 인스턴스라면 스킵 (비동기 병렬 중복 호출 방지)
|
|
192
|
+
// if (this._swc_started_instances.has(instance)) return;
|
|
193
|
+
// this._swc_started_instances.add(instance);
|
|
194
|
+
//
|
|
195
|
+
// const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
196
|
+
// if (startedMethods) {
|
|
197
|
+
// const ps = startedMethods.map(m => instance._invokeLifecycleMethod(m));
|
|
198
|
+
// await Promise.allSettled(ps);
|
|
199
|
+
// }
|
|
200
|
+
// } finally {
|
|
201
|
+
// this._swcAppStartedInvocations--;
|
|
202
|
+
// }
|
|
203
|
+
// }
|
|
128
204
|
connectedCallback() {
|
|
129
|
-
if (super.connectedCallback)
|
|
130
|
-
super.connectedCallback();
|
|
205
|
+
if (super.connectedCallback) super.connectedCallback();
|
|
131
206
|
const configStr = this.getAttribute("swc-get-application-config");
|
|
132
207
|
const win = this.ownerDocument?.defaultView || window;
|
|
133
208
|
if (configStr && win) {
|
|
@@ -145,8 +220,7 @@ function SwcAppMixin(Base) {
|
|
|
145
220
|
this.__swc_engine?.config?.onConnected?.(this);
|
|
146
221
|
}
|
|
147
222
|
disconnectedCallback() {
|
|
148
|
-
if (super.disconnectedCallback)
|
|
149
|
-
super.disconnectedCallback();
|
|
223
|
+
if (super.disconnectedCallback) super.disconnectedCallback();
|
|
150
224
|
this._routerSubscription?.unsubscribe();
|
|
151
225
|
this._routerSubscription = void 0;
|
|
152
226
|
this._lastRouterEvent = void 0;
|
|
@@ -185,7 +259,7 @@ function SwcAppMixin(Base) {
|
|
|
185
259
|
}
|
|
186
260
|
let filterMatched = true;
|
|
187
261
|
if (filter && typeMatched) {
|
|
188
|
-
filterMatched = filter(message);
|
|
262
|
+
filterMatched = filter(message, instance);
|
|
189
263
|
}
|
|
190
264
|
if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
|
|
191
265
|
instance[methodName](message);
|