@dooboostore/simple-web-component 1.0.28 → 1.0.29
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 +7 -0
- package/dist/cjs/decorators/attribute.js +2 -1
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +6 -2
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +4 -0
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +3 -3
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +43 -5
- package/dist/cjs/elements/SwcAppMixin.js.map +3 -3
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +27 -1
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/attribute.js +2 -1
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +6 -2
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +4 -0
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +3 -3
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +43 -5
- package/dist/esm/elements/SwcAppMixin.js.map +3 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +27 -1
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +39 -4
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +2 -2
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +2 -0
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +7 -2
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +13 -0
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +39 -4
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +2 -2
- package/package.json +4 -4
- package/src/decorators/attribute.ts +6 -1
- package/src/decorators/elementDefine.ts +8 -4
- package/src/decorators/lifecycles.ts +3 -0
- package/src/elements/SwcAppEngine.ts +3 -3
- package/src/elements/SwcAppMixin.ts +76 -13
- package/src/types.ts +3 -0
- package/src/utils/Utils.ts +51 -1
|
@@ -7,6 +7,7 @@ const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-a
|
|
|
7
7
|
const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-adopted");
|
|
8
8
|
const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-adopted");
|
|
9
9
|
const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:on-add-event-listener");
|
|
10
|
+
const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for("simple-web-component:on-connected-swc-app");
|
|
10
11
|
const INNER_HTML_METADATA_KEY = Symbol.for("simple-web-component:inner-html");
|
|
11
12
|
const ATTRIBUTE_CHANGED_WILDCARD = "*";
|
|
12
13
|
function createLifecycleDecorator(metadataKey) {
|
|
@@ -31,6 +32,7 @@ const onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY)
|
|
|
31
32
|
const onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
|
|
32
33
|
const onAdopted = onAfterAdopted;
|
|
33
34
|
const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
|
|
35
|
+
const onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
34
36
|
function onConnectedInnerHtml(arg1, arg2, arg3) {
|
|
35
37
|
const decorator = (options, target, propertyKey) => {
|
|
36
38
|
const constructor = target.constructor;
|
|
@@ -66,6 +68,7 @@ export {
|
|
|
66
68
|
ON_BEFORE_ADOPTED_METADATA_KEY,
|
|
67
69
|
ON_BEFORE_CONNECTED_METADATA_KEY,
|
|
68
70
|
ON_BEFORE_DISCONNECTED_METADATA_KEY,
|
|
71
|
+
ON_CONNECTED_SWC_APP_METADATA_KEY,
|
|
69
72
|
ON_INITIALIZE_METADATA_KEY,
|
|
70
73
|
findAllLifecycleMetadata,
|
|
71
74
|
getOnConnectedInnerHtmlMetadata,
|
|
@@ -79,6 +82,7 @@ export {
|
|
|
79
82
|
onBeforeDisconnected,
|
|
80
83
|
onConnected,
|
|
81
84
|
onConnectedInnerHtml,
|
|
85
|
+
onConnectedSwcApp,
|
|
82
86
|
onDisconnected,
|
|
83
87
|
onInitialize
|
|
84
88
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/lifecycles.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_INITIALIZE_METADATA_KEY = Symbol.for('simple-web-component:on-constructor');\nexport const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-connected');\nexport const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-connected');\nexport const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-disconnected');\nexport const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-disconnected');\nexport const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');\nexport const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');\nexport const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');\nexport const INNER_HTML_METADATA_KEY = Symbol.for('simple-web-component:inner-html');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nfunction createLifecycleDecorator(metadataKey: symbol): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as (string | symbol)[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push(propertyKey);\n };\n}\n\nexport const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);\nexport const onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);\nexport const onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);\nexport const onConnected = onAfterConnected;\n\nexport const onBeforeDisconnected = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);\nexport const onAfterDisconnected = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);\nexport const onDisconnected = onAfterDisconnected;\n\nexport const onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);\nexport const onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);\nexport const onAdopted = onAfterAdopted;\n\nexport const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\n/**\n * \uD504\uB85C\uD1A0\uD0C0\uC785 \uCCB4\uC778\uC744 \uC21C\uD68C\uD558\uBA70 \uBAA8\uB4E0 \uB77C\uC774\uD504\uC0AC\uC774\uD074 \uBA54\uC11C\uB4DC\uB97C \uC218\uC9D1\uD569\uB2C8\uB2E4.\n */\nexport const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {\n const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target);\n return results.length > 0 ? (results as unknown as T) : undefined;\n};\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,6BAA6B,OAAO,IAAI,qCAAqC;AACnF,MAAM,mCAAmC,OAAO,IAAI,0CAA0C;AAC9F,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAC5F,MAAM,sCAAsC,OAAO,IAAI,6CAA6C;AACpG,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,gCAAgC,OAAO,IAAI,uCAAuC;AACxF,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAE5E,MAAM,6BAA6B;AAW1C,SAAS,yBAAyB,aAAsC;AACtE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,aAAa,WAAW;AAC/D,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,aAAa,MAAM,WAAW;AAAA,IAC5D;AACA,SAAK,KAAK,WAAW;AAAA,EACvB;AACF;AAEO,MAAM,eAAe,yBAAyB,0BAA0B;AACxE,MAAM,oBAAoB,yBAAyB,gCAAgC;AACnF,MAAM,mBAAmB,yBAAyB,+BAA+B;AACjF,MAAM,cAAc;AAEpB,MAAM,uBAAuB,yBAAyB,mCAAmC;AACzF,MAAM,sBAAsB,yBAAyB,kCAAkC;AACvF,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB,yBAAyB,8BAA8B;AAC/E,MAAM,iBAAiB,yBAAyB,6BAA6B;AAC7E,MAAM,YAAY;AAElB,MAAM,qBAAqB,yBAAyB,kCAAkC;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_INITIALIZE_METADATA_KEY = Symbol.for('simple-web-component:on-constructor');\nexport const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-connected');\nexport const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-connected');\nexport const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-disconnected');\nexport const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-disconnected');\nexport const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');\nexport const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');\nexport const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');\nexport const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');\nexport const INNER_HTML_METADATA_KEY = Symbol.for('simple-web-component:inner-html');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nfunction createLifecycleDecorator(metadataKey: symbol): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as (string | symbol)[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push(propertyKey);\n };\n}\n\nexport const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);\nexport const onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);\nexport const onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);\nexport const onConnected = onAfterConnected;\n\nexport const onBeforeDisconnected = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);\nexport const onAfterDisconnected = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);\nexport const onDisconnected = onAfterDisconnected;\n\nexport const onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);\nexport const onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);\nexport const onAdopted = onAfterAdopted;\n\nexport const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);\n\nexport const onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\n/**\n * \uD504\uB85C\uD1A0\uD0C0\uC785 \uCCB4\uC778\uC744 \uC21C\uD68C\uD558\uBA70 \uBAA8\uB4E0 \uB77C\uC774\uD504\uC0AC\uC774\uD074 \uBA54\uC11C\uB4DC\uB97C \uC218\uC9D1\uD569\uB2C8\uB2E4.\n */\nexport const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {\n const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target);\n return results.length > 0 ? (results as unknown as T) : undefined;\n};\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,6BAA6B,OAAO,IAAI,qCAAqC;AACnF,MAAM,mCAAmC,OAAO,IAAI,0CAA0C;AAC9F,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAC5F,MAAM,sCAAsC,OAAO,IAAI,6CAA6C;AACpG,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,gCAAgC,OAAO,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ACvD,cAAW,QAA6B,CAAC,GAAG,QAAQ,WAAW;AAAA,EACjE;AACF;AAKO,MAAM,2BAA2B,CAA0B,QAAa,gBAAuC;AACpH,QAAM,UAAU,aAAa,uBAAuB,aAAa,MAAM;AACvE,SAAO,QAAQ,SAAS,IAAK,UAA2B;AAC1D;AAEO,MAAM,kCAAkC,CAAC,WAAiD;AAC/F,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,yBAAyB,WAAW;AACtE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,11 +15,11 @@ class SwcAppEngine {
|
|
|
15
15
|
try {
|
|
16
16
|
this._config = config;
|
|
17
17
|
if (this._config.routeType === "path") {
|
|
18
|
-
this.router = new PathRouter({ window: this._config.window
|
|
18
|
+
this.router = new PathRouter({ window: this._config.window });
|
|
19
19
|
} else if (this._config.routeType === "hash") {
|
|
20
|
-
this.router = new HashRouter({ window: this._config.window
|
|
20
|
+
this.router = new HashRouter({ window: this._config.window });
|
|
21
21
|
} else if (this._config.routeType === "element") {
|
|
22
|
-
this.router = new ElementRouter({ window: this._config.window
|
|
22
|
+
this.router = new ElementRouter({ window: this._config.window });
|
|
23
23
|
}
|
|
24
24
|
const containerSymbol = this._config.container || this.host.getContainerSymbol?.();
|
|
25
25
|
this.simpleApplication = new SimpleApplication(
|
|
@@ -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 } from '@dooboostore/core-web';\nimport { HashRouter } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { Subscription } from '@dooboostore/core';\nimport { ConstructorType, OptionalType } from '@dooboostore/core';\nimport { FunctionUtils } from '@dooboostore/core';\nimport { SwcUtils } from '../utils/Utils';\n\nimport { SwcAppInterface } from '../types';\nimport {Intent} from \"@dooboostore/simple-boot\";\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n container?: symbol;\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\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 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
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,cAA+B;AAsBjC,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EACA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } from '@dooboostore/core-web';\nimport { HashRouter } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { Subscription } from '@dooboostore/core';\nimport { ConstructorType, OptionalType } from '@dooboostore/core';\nimport { FunctionUtils } from '@dooboostore/core';\nimport { SwcUtils } from '../utils/Utils';\n\nimport { SwcAppInterface } from '../types';\nimport {Intent} from \"@dooboostore/simple-boot\";\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n container?: symbol;\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\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 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 });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n const containerSymbol = this._config.container || (this.host as any).getContainerSymbol?.();\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [Node],\n container: containerSymbol\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\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);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,S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
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SwcAppEngine } from "./SwcAppEngine.js";
|
|
2
2
|
import { SwcUtils } from "../utils/Utils.js";
|
|
3
3
|
import { FunctionUtils } from "@dooboostore/core";
|
|
4
|
+
import { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from "../decorators/lifecycles.js";
|
|
4
5
|
import { getSubscribeSwcAppRouteChangeMetadata } from "../decorators/subscribeSwcAppRouteChange.js";
|
|
5
6
|
function SwcAppMixin(Base) {
|
|
6
7
|
return class extends Base {
|
|
@@ -8,6 +9,7 @@ function SwcAppMixin(Base) {
|
|
|
8
9
|
super(...arguments);
|
|
9
10
|
this.__swc_engine = new SwcAppEngine(this);
|
|
10
11
|
this._swc_connected_instance = /* @__PURE__ */ new Set();
|
|
12
|
+
this._connected_safari = [];
|
|
11
13
|
}
|
|
12
14
|
get simpleApplication() {
|
|
13
15
|
return this.__swc_engine.simpleApplication;
|
|
@@ -15,6 +17,10 @@ function SwcAppMixin(Base) {
|
|
|
15
17
|
get router() {
|
|
16
18
|
return this.__swc_engine.router;
|
|
17
19
|
}
|
|
20
|
+
// constructor() {
|
|
21
|
+
// super();
|
|
22
|
+
// console.log('cccccccccccccccccccccc');
|
|
23
|
+
// }
|
|
18
24
|
_invokeRouteChangeSubscribers(instance, re) {
|
|
19
25
|
const routeChangeSubscribers = getSubscribeSwcAppRouteChangeMetadata(instance);
|
|
20
26
|
if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
|
|
@@ -50,8 +56,11 @@ function SwcAppMixin(Base) {
|
|
|
50
56
|
_connected(instance) {
|
|
51
57
|
if (instance) {
|
|
52
58
|
this._swc_connected_instance.add(instance);
|
|
53
|
-
if (this.
|
|
54
|
-
this.
|
|
59
|
+
if (this.simpleApplication) {
|
|
60
|
+
this._invokeOnConnectedSwcAppStarted(instance);
|
|
61
|
+
if (this.router && this._lastRouterEvent) {
|
|
62
|
+
this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
}
|
|
@@ -98,14 +107,33 @@ function SwcAppMixin(Base) {
|
|
|
98
107
|
throw e;
|
|
99
108
|
}
|
|
100
109
|
}
|
|
110
|
+
this._connected_safari.forEach((instance) => {
|
|
111
|
+
this._swc_connected_instance.add(instance);
|
|
112
|
+
});
|
|
113
|
+
this._swc_connected_instance.forEach((instance) => {
|
|
114
|
+
this._invokeOnConnectedSwcAppStarted(instance);
|
|
115
|
+
});
|
|
101
116
|
if (!this._routerSubscription && this.router) {
|
|
102
117
|
this._routerSubscription = this.router.observable.subscribe((route) => {
|
|
103
118
|
this._handleRouteChange(route);
|
|
104
119
|
});
|
|
120
|
+
const config2 = this.__swc_engine.config;
|
|
121
|
+
if (config2?.path) {
|
|
122
|
+
this.router.go(config2.path);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
_invokeOnConnectedSwcAppStarted(instance) {
|
|
127
|
+
const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
128
|
+
if (startedMethods) {
|
|
129
|
+
for (const m of startedMethods) {
|
|
130
|
+
instance._invokeLifecycleMethod(m);
|
|
131
|
+
}
|
|
105
132
|
}
|
|
106
133
|
}
|
|
107
134
|
connectedCallback() {
|
|
108
|
-
if (super.connectedCallback)
|
|
135
|
+
if (super.connectedCallback)
|
|
136
|
+
super.connectedCallback();
|
|
109
137
|
const configStr = this.getAttribute("swc-get-application-config");
|
|
110
138
|
const win = this.ownerDocument?.defaultView || window;
|
|
111
139
|
if (configStr && win) {
|
|
@@ -123,7 +151,8 @@ function SwcAppMixin(Base) {
|
|
|
123
151
|
this.__swc_engine?.config?.onConnected?.(this);
|
|
124
152
|
}
|
|
125
153
|
disconnectedCallback() {
|
|
126
|
-
if (super.disconnectedCallback)
|
|
154
|
+
if (super.disconnectedCallback)
|
|
155
|
+
super.disconnectedCallback();
|
|
127
156
|
this._routerSubscription?.unsubscribe();
|
|
128
157
|
this._routerSubscription = void 0;
|
|
129
158
|
this._lastRouterEvent = void 0;
|
|
@@ -131,7 +160,16 @@ function SwcAppMixin(Base) {
|
|
|
131
160
|
this.__swc_engine?.config?.onDisconnected?.(this);
|
|
132
161
|
}
|
|
133
162
|
async routing(path) {
|
|
134
|
-
await this.
|
|
163
|
+
await this.router?.go(path);
|
|
164
|
+
}
|
|
165
|
+
back() {
|
|
166
|
+
this.router?.back();
|
|
167
|
+
}
|
|
168
|
+
forward() {
|
|
169
|
+
this.router?.forward();
|
|
170
|
+
}
|
|
171
|
+
reload() {
|
|
172
|
+
this.router?.reload();
|
|
135
173
|
}
|
|
136
174
|
};
|
|
137
175
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/SwcAppMixin.ts"],
|
|
4
|
-
"sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from './SwcAppEngine';\nimport { SwcAppInterface } from '../types';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, Subscription } from '@dooboostore/core';\nimport { RouterEventType } from '@dooboostore/core-web';\nimport { getSubscribeSwcAppRouteChangeMetadata } from '../decorators/subscribeSwcAppRouteChange';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n routeChangeSubscribers.forEach((metadata: any) => {\n const methodName = metadata.propertyKey || metadata;\n const pathPattern = metadata.pathPattern;\n const filter = metadata.filter;\n\n // Path pattern matching (support both string and array)\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n // pathPattern
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAA2D;AAEpE,SAAS,gBAAgB;AACzB,SAAS,qBAAmC;AAE5C,SAAS,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from './SwcAppEngine';\nimport { SwcAppInterface } from '../types';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, Subscription } from '@dooboostore/core';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from '../decorators/lifecycles';\nimport { getSubscribeSwcAppRouteChangeMetadata } from '../decorators/subscribeSwcAppRouteChange';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n //@ts-ignore\n return class extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n /*\n 사파리 is 일경우\n <script src=\"https://unpkg.com/@ungap/custom-elements\"></script>\n 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데\n 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다\n */\n _connected_safari = [];\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n // constructor() {\n // super();\n // console.log('cccccccccccccccccccccc');\n // }\n\n _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n routeChangeSubscribers.forEach((metadata: any) => {\n const methodName = metadata.propertyKey || metadata;\n const pathPattern = metadata.pathPattern;\n const filter = metadata.filter;\n\n // Path pattern matching (support both string and array)\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n // pathPattern이 없으면 모든 경로 매칭 (와일드카드)\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n // 배열: 하나라도 매칭되면 OK\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n // 문자열\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n // Filter validation\n const filterPassed = !filter || filter(this.router!);\n\n // Invoke method if conditions pass\n if (pathMatched && filterPassed) {\n instance[methodName]?.(re, pathData || {});\n }\n });\n }\n }\n\n _connected(instance: any) {\n // console.log('appmixin--> connected', instance);\n if (instance) {\n this._swc_connected_instance.add(instance);\n if (this.simpleApplication) {\n this._invokeOnConnectedSwcAppStarted(instance);\n // Notify current route subscribers immediately after connection\n if (this.router && this._lastRouterEvent) {\n this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);\n }\n }\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n }\n }\n\n _handleRouteChange(route: RouterEventType) {\n if (route.triggerPoint === 'end') {\n // Iterate through all connected component instances\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeRouteChangeSubscribers(instance, route);\n });\n }\n\n // Save last router event\n this._lastRouterEvent = route;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const swcConfig = {\n routeType: 'element',\n window: config.window,\n ...config\n } as SwcConfigType;\n\n const mode = config?.connectMode || 'direct';\n\n if (mode === 'direct') {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else if (mode === 'swap' && !this.parentNode) {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n this.parentNode.insertBefore(clonedApp, this.nextSibling);\n\n try {\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.setAttribute('swc-connect-mode', 'swap');\n clonedApp.style.display = '';\n } catch (e) {\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n throw e;\n }\n }\n\n // 사파리일떄 예외이다 is 일때 polyfill되는데 이떄 부모부터 만들어지는게 아니라 자식부터 만들어진다 그래서 부모가 만들어질때 자식들이 이미 만들어져있어서 부모가 자식들을 등록해주는 형태로 강제로 등록해준다\n this._connected_safari.forEach((instance: any) => {\n this._swc_connected_instance.add(instance);\n });\n // Invoke @onConnectedSwcApp lifecycle methods on all connected component instances\n // const hostSet = SwcUtils.getHostSet(this as any);\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeOnConnectedSwcAppStarted(instance);\n });\n\n // Safari fix: Manually scan DOM tree and register any SWC components that couldn't find parent\n // This handles the case where is=\"\" elements get upgraded in child-first order\n // const allElements = (this as any).querySelectorAll('*');\n // for (const el of allElements) {\n // const isConnected = (el as any).__swc_connected;\n // if (!isConnected && typeof (el as any)._resolveWindow === 'function') {\n // // Element is an SWC component but hasn't registered with app yet\n // try {\n // this._connected(el);\n // if ((el as any)._invokeOnConnectedSwcAppStarted) {\n // this._invokeOnConnectedSwcAppStarted(el);\n // }\n // } catch (e) {\n // console.warn('[SWC] Error registering discovered element:', el.tagName, e);\n // }\n // }\n // }\n\n // Subscribe to router changes after connect\n if (!this._routerSubscription && this.router) {\n this._routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n // console.log('Route changed:', route);\n this._handleRouteChange(route);\n });\n // Navigate to initial path if specified\n const config = this.__swc_engine.config;\n if (config?.path) {\n this.router.go(config.path);\n }\n }\n }\n\n _invokeOnConnectedSwcAppStarted(instance: any) {\n const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n if (startedMethods) {\n for (const m of startedMethods) {\n instance._invokeLifecycleMethod(m);\n }\n }\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n // console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, SwcUtils.findNearestSwcHost(this))\n });\n this.connect(userConfig);\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n\n this.__swc_engine?.config?.onConnected?.(this);\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAA2D;AAEpE,SAAS,gBAAgB;AACzB,SAAS,qBAAmC;AAE5C,SAAS,mCAAmC,gCAAgC;AAC5E,SAAS,6CAA6C;AAEhD,SAAU,YAA6D,MAAO;AAElF,SAAO,cAAc,KAAI;IAAlB,cAAA;;AACL,WAAA,eAAe,IAAI,aAAa,IAAW;AAC3C,WAAA,0BAA0B,oBAAI,IAAG;AAUjC,WAAA,oBAAoB,CAAA;IA8NtB;IA7NE,IAAI,oBAAiB;AACnB,aAAO,KAAK,aA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5B;MACF;IACF;IAEA,gCAAgC,UAAa;AAC3C,YAAM,iBAAiB,yBAAyB,UAAU,iCAAiC;AAC3F,UAAI,gBAAgB;AAClB,mBAAW,KAAK,gBAAgB;AAC9B,mBAAS,uBAAuB,CAAC;QACnC;MACF;IACF;IAEA,oBAAiB;AAEf,UAAI,MAAM;AAAmB,cAAM,kBAAiB;AAEpD,YAAM,YAAY,KAAK,aAAa,4BAA4B;AAChE,YAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAI,aAAa,KAAK;AACpB,YAAI;AAEF,gBAAM,aAAa,cAAc,cAAc;YAC7C,QAAQ;YACR,SAAS;YACT,MAAM,SAAS,oBAAoB,KAAK,SAAS,mBAAmB,IAAI,CAAC;WAC1E;AACD,eAAK,QAAQ,UAAU;QACzB,SAAS,GAAG;AACV,kBAAQ,MAAM,6CAA6C,CAAC;QAC9D;MACF;AAEA,WAAK,cAAc,QAAQ,cAAc,IAAI;IAC/C;IAEA,uBAAoB;AAElB,UAAI,MAAM;AAAsB,cAAM,qBAAoB;AAC1D,WAAK,qBAAqB,YAAW;AACrC,WAAK,sBAAsB;AAC3B,WAAK,mBAAmB;AACxB,WAAK,aAAa,WAAU;AAC5B,WAAK,cAAc,QAAQ,iBAAiB,IAAI;IAClD;IAEA,MAAM,QAAQ,MAAY;AACxB,YAAM,KAAK,QAAQ,GAAG,IAAI;IAC5B;IAEA,OAAI;AACF,WAAK,QAAQ,KAAI;IACnB;IAEA,UAAO;AACL,WAAK,QAAQ,QAAO;IACtB;IAEA,SAAM;AACJ,WAAK,QAAQ,OAAM;IACrB;;AAEJ;",
|
|
6
|
+
"names": ["config"]
|
|
7
7
|
}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web';\nimport {SwcAttributeConfigType} from \"./elements/SwcAppEngine\";\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type SwcRootType = 'light' | 'shadow' | 'all' | 'auto';\n\nexport type SpecialSelector = ':host' | ':window' | ':document' | ':parentHost' | ':appHost' | ':firstHost' | ':lastHost' | ':firstAppHost' | ':lastAppHost' | ':hosts' | ':appHosts';\n\nexport type SwcQueryOptions = { root?: SwcRootType };\n\nexport type HelperSet = {\n $d: Document;\n $w: Window;\n $q: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n $qa: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement[];\n $qi: (id: string, root?: Document | ShadowRoot) => HTMLElement | null;\n};\n\nexport type HostSet = {\n $host: HTMLElement; // Current component itself\n $parentHost: HTMLElement | null; // Nearest parent SWC component\n $hosts: HTMLElement[]; // [root, ..., parent, self]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $parentHost (for backward compatibility or clarity)\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport type HelperHostSet = HelperSet & HostSet;\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n connect(config?: SwcAttributeConfigType): Promise<void>;\n routing(path: string): Promise<void>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web';\nimport {SwcAttributeConfigType} from \"./elements/SwcAppEngine\";\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type SwcRootType = 'light' | 'shadow' | 'all' | 'auto';\n\nexport type SpecialSelector = ':host' | ':window' | ':document' | ':parentHost' | ':appHost' | ':firstHost' | ':lastHost' | ':firstAppHost' | ':lastAppHost' | ':hosts' | ':appHosts';\n\nexport type SwcQueryOptions = { root?: SwcRootType };\n\nexport type HelperSet = {\n $d: Document;\n $w: Window;\n $q: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n $qa: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement[];\n $qi: (id: string, root?: Document | ShadowRoot) => HTMLElement | null;\n};\n\nexport type HostSet = {\n $host: HTMLElement; // Current component itself\n $parentHost: HTMLElement | null; // Nearest parent SWC component\n $hosts: HTMLElement[]; // [root, ..., parent, self]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $parentHost (for backward compatibility or clarity)\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport type HelperHostSet = HelperSet & HostSet;\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n connect(config?: SwcAttributeConfigType): Promise<void>;\n routing(path: string): Promise<void>;\n reload(): void;\n back(): void;\n forward(): void;\n}\n"],
|
|
5
5
|
"mappings": "AAIO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,iBAAc;AACd,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;AAVN,SAAAA;AAAA,GAAA;",
|
|
6
6
|
"names": ["InjectSituationType"]
|
|
7
7
|
}
|
package/dist/esm/utils/Utils.js
CHANGED
|
@@ -194,6 +194,32 @@ var SwcUtils;
|
|
|
194
194
|
const appHostsWithoutSelf = appHosts.filter((h) => h !== el);
|
|
195
195
|
return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : void 0;
|
|
196
196
|
};
|
|
197
|
+
SwcUtils2.findParentAppHostDirect = (el) => {
|
|
198
|
+
const appHosts = (0, SwcUtils2.findAllParentAppHostsDirect)(el);
|
|
199
|
+
return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;
|
|
200
|
+
};
|
|
201
|
+
SwcUtils2.findAllParentAppHostsDirect = (el) => {
|
|
202
|
+
const appHosts = [];
|
|
203
|
+
let current = null;
|
|
204
|
+
const rootNode = el.getRootNode();
|
|
205
|
+
if (rootNode instanceof ShadowRoot) {
|
|
206
|
+
current = rootNode.host;
|
|
207
|
+
} else {
|
|
208
|
+
current = el.parentElement;
|
|
209
|
+
}
|
|
210
|
+
while (current) {
|
|
211
|
+
const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
|
|
212
|
+
if (isAppHost) {
|
|
213
|
+
appHosts.push(current);
|
|
214
|
+
}
|
|
215
|
+
if (current.shadowRoot) {
|
|
216
|
+
current = current.shadowRoot.host.parentElement;
|
|
217
|
+
} else {
|
|
218
|
+
current = current.parentElement;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return appHosts.reverse();
|
|
222
|
+
};
|
|
197
223
|
SwcUtils2.getHostSet = (el) => {
|
|
198
224
|
const isSwc = !!getElementConfig(el);
|
|
199
225
|
const ancestors = (0, SwcUtils2.findAllSwcHosts)(el);
|
|
@@ -217,7 +243,7 @@ var SwcUtils;
|
|
|
217
243
|
}
|
|
218
244
|
curr = curr.parentElement || curr.getRootNode().host;
|
|
219
245
|
}
|
|
220
|
-
const $appHosts =
|
|
246
|
+
const $appHosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
221
247
|
const $appHost = $appHosts.length > 0 ? $appHosts[$appHosts.length - 1] === el ? $appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null : $appHosts[$appHosts.length - 1] : null;
|
|
222
248
|
const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;
|
|
223
249
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/Utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\n\nexport const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {\n if ((el as any).__swc_host) return (el as any).__swc_host;\n // if ((el as any).__swc_proto_setup) return (el as any).__swc_proto_setup;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHosts = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHost(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHosts(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHost(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n const hosts = getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const isSwc = !!getElementConfig(el);\n const ancestors = findAllSwcHosts(el); // [root, ..., parent]\n\n let $host: HTMLElement;\n let $parentHost: HTMLElement | null;\n\n if (isSwc) {\n $host = el;\n $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n } else {\n $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;\n $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n }\n\n const $hosts = isSwc ? [...ancestors, el] : ancestors;\n const $firstHost = $hosts.length > 0 ? $hosts[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = $hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n\n export const parsePathPattern = (pattern: string | undefined, currentPath: string): { [key: string]: string } | null => {\n // pattern\uC774 null/undefined\uBA74 \uC640\uC77C\uB4DC\uCE74\uB4DC (\uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D)\n if (pattern === null || pattern === undefined) return {};\n \n // \uACF5\uBC31\uB9CC \uC788\uB294 \uD328\uD134\uB3C4 \uC640\uC77C\uB4DC\uCE74\uB4DC\n const trimmedPattern = pattern.trim();\n if (trimmedPattern === '' && pattern !== '') return {}; // \uACF5\uBC31 \uBB38\uC790\uB9CC \uC788\uB294 \uACBD\uC6B0\n \n // \uD328\uD134\uC744 \uC815\uADDC\uC2DD\uC73C\uB85C \uBCC0\uD658\n // \uC9C0\uC6D0 \uD615\uC2DD:\n // {id} \u2192 ([^/]+) \uAE30\uBCF8 (/ \uC81C\uC678\uD55C \uBAA8\uB4E0 \uBB38\uC790)\n // {tail:.*} \u2192 (.*) \uC815\uADDC\uD45C\uD604\uC2DD \uC9C1\uC811 \uC9C0\uC815\n // {slug:[a-z0-9-]+} \u2192 ([a-z0-9-]+)\n const paramNames: string[] = [];\n const regexPattern = trimmedPattern.replace(/{(\\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {\n paramNames.push(paramName);\n // customRegex\uAC00 \uC788\uC73C\uBA74 \uC0AC\uC6A9, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12 ([^/]+)\n return `(${customRegex || '[^/]+'})`;\n });\n \n const regex = new RegExp(`^${regexPattern}$`);\n const match = currentPath.match(regex);\n \n if (!match) return null;\n \n const result: { [key: string]: string } = {};\n paramNames.forEach((name, index) => {\n result[name] = match[index + 1];\n });\n \n return result;\n };\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAQ,wBAAuB;AAExB,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAGjE,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,QAAM,WAAW,EAAE,cAAc,UAAU;AAC3C,WAAS,YAAY,KAAK,KAAK;AAC/B,SAAO,SAAS;AAClB;AAEO,MAAM,WAAW,CAAC,MAAoB,QAAyB;AACpE,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,eAAe,SAAS,UAAa,SAAS,OAAO,OAAO,IAAI,IAAI,EAAE;AACjF;AAEO,MAAM,cAAc,CAAC,SAAuB,QAA4B;AAC7E,QAAM,IAAI,QAAQ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Symbol.for('simple-web-component:not-found');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {\n if ((el as any).__swc_host) return (el as any).__swc_host;\n // if ((el as any).__swc_proto_setup) return (el as any).__swc_proto_setup;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHosts = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHost(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHosts(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHost(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n const hosts = getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n /**\n * Find parent app host by traversing DOM tree directly.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findParentAppHostDirect = (el: HTMLElement): SwcAppInterface | null => {\n const appHosts = findAllParentAppHostsDirect(el);\n return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;\n };\n\n /**\n * Find all parent app hosts by traversing DOM tree directly.\n * Returns array of all parent app hosts in [closest-parent, ..., root] order.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAllParentAppHostsDirect = (el: HTMLElement): SwcAppInterface[] => {\n const appHosts: SwcAppInterface[] = [];\n \n // Start from shadow root's host if el is inside shadow DOM, otherwise from parentElement\n let current: HTMLElement | null = null;\n const rootNode = el.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n // Element is inside shadow DOM, start from shadow root's host\n current = (rootNode as any).host as HTMLElement;\n } else {\n // Element is in light DOM, start from parent\n current = el.parentElement;\n }\n \n while (current) {\n // console.log('vvvvvvv');\n // alert(1)\n // debugger;\n const isAppHost =\n current.tagName.toLowerCase() === 'swc-app' || \n current.getAttribute('is')?.startsWith('swc-app-');\n if (isAppHost) {\n appHosts.push(current as SwcAppInterface);\n }\n // Handle shadow DOM\n if (current.shadowRoot) {\n current = ((current.shadowRoot as any).host as HTMLElement).parentElement;\n } else {\n current = current.parentElement;\n }\n }\n return appHosts.reverse(); // [root, ..., closest-parent]\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const isSwc = !!getElementConfig(el);\n const ancestors = findAllSwcHosts(el); // [root, ..., parent]\n\n let $host: HTMLElement;\n let $parentHost: HTMLElement | null;\n\n if (isSwc) {\n $host = el;\n $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n } else {\n $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;\n $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n }\n\n const $hosts = isSwc ? [...ancestors, el] : ancestors;\n const $firstHost = $hosts.length > 0 ? $hosts[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = SwcUtils.findAllParentAppHostsDirect(el); //$hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n\n export const parsePathPattern = (pattern: string | undefined, currentPath: string): { [key: string]: string } | null => {\n // pattern\uC774 null/undefined\uBA74 \uC640\uC77C\uB4DC\uCE74\uB4DC (\uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D)\n if (pattern === null || pattern === undefined) return {};\n \n // \uACF5\uBC31\uB9CC \uC788\uB294 \uD328\uD134\uB3C4 \uC640\uC77C\uB4DC\uCE74\uB4DC\n const trimmedPattern = pattern.trim();\n if (trimmedPattern === '' && pattern !== '') return {}; // \uACF5\uBC31 \uBB38\uC790\uB9CC \uC788\uB294 \uACBD\uC6B0\n \n // \uD328\uD134\uC744 \uC815\uADDC\uC2DD\uC73C\uB85C \uBCC0\uD658\n // \uC9C0\uC6D0 \uD615\uC2DD:\n // {id} \u2192 ([^/]+) \uAE30\uBCF8 (/ \uC81C\uC678\uD55C \uBAA8\uB4E0 \uBB38\uC790)\n // {tail:.*} \u2192 (.*) \uC815\uADDC\uD45C\uD604\uC2DD \uC9C1\uC811 \uC9C0\uC815\n // {slug:[a-z0-9-]+} \u2192 ([a-z0-9-]+)\n const paramNames: string[] = [];\n const regexPattern = trimmedPattern.replace(/{(\\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {\n paramNames.push(paramName);\n // customRegex\uAC00 \uC788\uC73C\uBA74 \uC0AC\uC6A9, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12 ([^/]+)\n return `(${customRegex || '[^/]+'})`;\n });\n \n const regex = new RegExp(`^${regexPattern}$`);\n const match = currentPath.match(regex);\n \n if (!match) return null;\n \n const result: { [key: string]: string } = {};\n paramNames.forEach((name, index) => {\n result[name] = match[index + 1];\n });\n \n return result;\n };\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAQ,wBAAuB;AAExB,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAGjE,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,QAAM,WAAW,EAAE,cAAc,UAAU;AAC3C,WAAS,YAAY,KAAK,KAAK;AAC/B,SAAO,SAAS;AAClB;AAEO,MAAM,WAAW,CAAC,MAAoB,QAAyB;AACpE,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,eAAe,SAAS,UAAa,SAAS,OAAO,OAAO,IAAI,IAAI,EAAE;AACjF;AAEO,MAAM,cAAc,CAAC,SAAuB,QAA4B;AAC7E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,cAAc,YAAY,UAAa,YAAY,OAAO,OAAO,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YAAY,GAAG;AAC5C,UAAM,QAAQ,YAAY,MAAM,KAAK;AAErC,QAAI,CAAC,MAAO,QAAO;AAEnB,UAAM,SAAoC,CAAC;AAC3C,eAAW,QAAQ,CAAC,MAAM,UAAU;AAClC,aAAO,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,IAChC,CAAC;AAED,WAAO;AAAA,EACT;AAAA,GAzNe;",
|
|
6
6
|
"names": ["SwcUtils", "match"]
|
|
7
7
|
}
|
|
@@ -5759,6 +5759,7 @@ var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-aft
|
|
|
5759
5759
|
var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-adopted");
|
|
5760
5760
|
var ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-adopted");
|
|
5761
5761
|
var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:on-add-event-listener");
|
|
5762
|
+
var ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for("simple-web-component:on-connected-swc-app");
|
|
5762
5763
|
var INNER_HTML_METADATA_KEY = Symbol.for("simple-web-component:inner-html");
|
|
5763
5764
|
var ATTRIBUTE_CHANGED_WILDCARD = "*";
|
|
5764
5765
|
function createLifecycleDecorator(metadataKey) {
|
|
@@ -5783,6 +5784,7 @@ var onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);
|
|
|
5783
5784
|
var onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
|
|
5784
5785
|
var onAdopted = onAfterAdopted;
|
|
5785
5786
|
var onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
|
|
5787
|
+
var onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
5786
5788
|
function onConnectedInnerHtml(arg1, arg2, arg3) {
|
|
5787
5789
|
const decorator = (options, target, propertyKey) => {
|
|
5788
5790
|
const constructor = target.constructor;
|
|
@@ -5903,7 +5905,8 @@ function attribute(selector, options = {}) {
|
|
|
5903
5905
|
}
|
|
5904
5906
|
return null;
|
|
5905
5907
|
}
|
|
5906
|
-
|
|
5908
|
+
const data = convertValue(this[privateKey], targetType);
|
|
5909
|
+
return data;
|
|
5907
5910
|
},
|
|
5908
5911
|
set(nv) {
|
|
5909
5912
|
const attrName = options.name || String(propertyKey);
|
|
@@ -7016,6 +7019,32 @@ var SwcUtils;
|
|
|
7016
7019
|
const appHostsWithoutSelf = appHosts.filter((h) => h !== el);
|
|
7017
7020
|
return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : void 0;
|
|
7018
7021
|
};
|
|
7022
|
+
SwcUtils2.findParentAppHostDirect = (el) => {
|
|
7023
|
+
const appHosts = (0, SwcUtils2.findAllParentAppHostsDirect)(el);
|
|
7024
|
+
return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;
|
|
7025
|
+
};
|
|
7026
|
+
SwcUtils2.findAllParentAppHostsDirect = (el) => {
|
|
7027
|
+
const appHosts = [];
|
|
7028
|
+
let current = null;
|
|
7029
|
+
const rootNode = el.getRootNode();
|
|
7030
|
+
if (rootNode instanceof ShadowRoot) {
|
|
7031
|
+
current = rootNode.host;
|
|
7032
|
+
} else {
|
|
7033
|
+
current = el.parentElement;
|
|
7034
|
+
}
|
|
7035
|
+
while (current) {
|
|
7036
|
+
const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
|
|
7037
|
+
if (isAppHost) {
|
|
7038
|
+
appHosts.push(current);
|
|
7039
|
+
}
|
|
7040
|
+
if (current.shadowRoot) {
|
|
7041
|
+
current = current.shadowRoot.host.parentElement;
|
|
7042
|
+
} else {
|
|
7043
|
+
current = current.parentElement;
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
return appHosts.reverse();
|
|
7047
|
+
};
|
|
7019
7048
|
SwcUtils2.getHostSet = (el) => {
|
|
7020
7049
|
const isSwc = !!getElementConfig(el);
|
|
7021
7050
|
const ancestors = (0, SwcUtils2.findAllSwcHosts)(el);
|
|
@@ -7039,7 +7068,7 @@ var SwcUtils;
|
|
|
7039
7068
|
}
|
|
7040
7069
|
curr = curr.parentElement || curr.getRootNode().host;
|
|
7041
7070
|
}
|
|
7042
|
-
const $appHosts =
|
|
7071
|
+
const $appHosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
7043
7072
|
const $appHost = $appHosts.length > 0 ? $appHosts[$appHosts.length - 1] === el ? $appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null : $appHosts[$appHosts.length - 1] : null;
|
|
7044
7073
|
const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;
|
|
7045
7074
|
return {
|
|
@@ -7358,10 +7387,11 @@ var setupPrototype = (proto) => {
|
|
|
7358
7387
|
proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
|
|
7359
7388
|
ensureInit2(this);
|
|
7360
7389
|
if (typeof this[methodName] !== "function") return;
|
|
7361
|
-
const
|
|
7390
|
+
const useHostSet = hostSet ?? SwcUtils.getHostSet(this);
|
|
7391
|
+
const app = useHostSet?.$appHost.simpleApplication;
|
|
7362
7392
|
if (app) {
|
|
7363
7393
|
const otherStorage = /* @__PURE__ */ new Map();
|
|
7364
|
-
const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOSTSET" /* HOST_SET */, data:
|
|
7394
|
+
const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOSTSET" /* HOST_SET */, data: useHostSet }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://APPHOST" /* APP_HOST */, data: useHostSet.$appHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://APPHOSTS" /* APP_HOSTS */, data: useHostSet.$appHosts }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOST" /* HOST */, data: useHostSet.$host }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://HOSTS" /* HOSTS */, data: useHostSet.$hosts }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://FIRSTHOST" /* FIRST_HOST */, data: useHostSet.$firstHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://LASTHOST" /* LAST_HOST */, data: useHostSet.$lastHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://FIRSTAPPHOST" /* FIRST_APP_HOST */, data: useHostSet.$firstAppHost }), new SituationTypeContainer({ situationType: "SIMPLE_WEB_COMPONENT://LASTAPPHOST" /* LAST_APP_HOST */, data: useHostSet.$lastAppHost })]);
|
|
7365
7395
|
otherStorage.set(SituationTypeContainers, situations);
|
|
7366
7396
|
return app.simstanceManager.executeBindParameterSimPromise(
|
|
7367
7397
|
{
|
|
@@ -7632,6 +7662,9 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7632
7662
|
this.__swc_connected = true;
|
|
7633
7663
|
if (appHost2 && typeof appHost2._connected === "function") {
|
|
7634
7664
|
appHost2._connected(this);
|
|
7665
|
+
} else if (appHost2 && typeof appHost2) {
|
|
7666
|
+
appHost2._connected_safari ?? (appHost2._connected_safari = []);
|
|
7667
|
+
appHost2._connected_safari.push(this);
|
|
7635
7668
|
}
|
|
7636
7669
|
};
|
|
7637
7670
|
const originalDisconnected = proto.disconnectedCallback;
|
|
@@ -8524,6 +8557,7 @@ export {
|
|
|
8524
8557
|
ON_BEFORE_ADOPTED_METADATA_KEY,
|
|
8525
8558
|
ON_BEFORE_CONNECTED_METADATA_KEY,
|
|
8526
8559
|
ON_BEFORE_DISCONNECTED_METADATA_KEY,
|
|
8560
|
+
ON_CONNECTED_SWC_APP_METADATA_KEY,
|
|
8527
8561
|
ON_INITIALIZE_METADATA_KEY,
|
|
8528
8562
|
QUERY_ALL_METADATA_KEY,
|
|
8529
8563
|
QUERY_METADATA_KEY,
|
|
@@ -8606,6 +8640,7 @@ export {
|
|
|
8606
8640
|
onBeforeDisconnected,
|
|
8607
8641
|
onConnected,
|
|
8608
8642
|
onConnectedInnerHtml,
|
|
8643
|
+
onConnectedSwcApp,
|
|
8609
8644
|
onDisconnected,
|
|
8610
8645
|
onInitialize,
|
|
8611
8646
|
parentHost,
|