@dooboostore/simple-web-component 1.0.32 → 1.0.33

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.
Files changed (57) hide show
  1. package/README.md +280 -43
  2. package/dist/cjs/decorators/elementDefine.js +1 -1
  3. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  4. package/dist/cjs/decorators/index.js +3 -1
  5. package/dist/cjs/decorators/index.js.map +2 -2
  6. package/dist/cjs/decorators/publishSwcAppMessage.js +86 -0
  7. package/dist/cjs/decorators/publishSwcAppMessage.js.map +7 -0
  8. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +62 -0
  9. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
  10. package/dist/cjs/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +16 -16
  11. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
  12. package/dist/cjs/elements/SwcAppMixin.js +31 -2
  13. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  14. package/dist/cjs/types.js.map +1 -1
  15. package/dist/esm/decorators/elementDefine.js +1 -1
  16. package/dist/esm/decorators/elementDefine.js.map +2 -2
  17. package/dist/esm/decorators/index.js +3 -1
  18. package/dist/esm/decorators/index.js.map +2 -2
  19. package/dist/esm/decorators/publishSwcAppMessage.js +67 -0
  20. package/dist/esm/decorators/publishSwcAppMessage.js.map +7 -0
  21. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +43 -0
  22. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
  23. package/dist/esm/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +13 -13
  24. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
  25. package/dist/esm/elements/SwcAppMixin.js +31 -2
  26. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  27. package/dist/esm/types.js.map +1 -1
  28. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +119 -14
  29. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  30. package/dist/types/decorators/elementDefine.d.ts +1 -0
  31. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  32. package/dist/types/decorators/index.d.ts +3 -1
  33. package/dist/types/decorators/index.d.ts.map +1 -1
  34. package/dist/types/decorators/publishSwcAppMessage.d.ts +13 -0
  35. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -0
  36. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +16 -0
  37. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -0
  38. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +18 -0
  39. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -0
  40. package/dist/types/elements/SwcAppMixin.d.ts +3 -0
  41. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  42. package/dist/types/types.d.ts +6 -0
  43. package/dist/types/types.d.ts.map +1 -1
  44. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +119 -14
  45. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  46. package/package.json +4 -4
  47. package/src/decorators/elementDefine.ts +2 -1
  48. package/src/decorators/index.ts +3 -1
  49. package/src/decorators/publishSwcAppMessage.ts +100 -0
  50. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +73 -0
  51. package/src/decorators/{subscribeSwcAppRouteChange.ts → subscribeSwcAppRouteChangeWhileConnected.ts} +19 -19
  52. package/src/elements/SwcAppMixin.ts +42 -3
  53. package/src/types.ts +8 -0
  54. package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +0 -7
  55. package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +0 -7
  56. package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +0 -18
  57. package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +0 -1
@@ -2,7 +2,8 @@ import { SwcAppEngine } from "./SwcAppEngine.js";
2
2
  import { SwcUtils } from "../utils/Utils.js";
3
3
  import { FunctionUtils } from "@dooboostore/core";
4
4
  import { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from "../decorators/lifecycles.js";
5
- import { getSubscribeSwcAppRouteChangeMetadata } from "../decorators/subscribeSwcAppRouteChange.js";
5
+ import { getSubscribeSwcAppRouteChangeWhileConnectedMetadata } from "../decorators/subscribeSwcAppRouteChangeWhileConnected.js";
6
+ import { getSubscribeSwcAppMessageWhileConnectedMetadata } from "../decorators/subscribeSwcAppMessageWhileConnected.js";
6
7
  function SwcAppMixin(Base) {
7
8
  return class extends Base {
8
9
  constructor() {
@@ -18,7 +19,7 @@ function SwcAppMixin(Base) {
18
19
  return this.__swc_engine.router;
19
20
  }
20
21
  _invokeRouteChangeSubscribers(instance, re) {
21
- const routeChangeSubscribers = getSubscribeSwcAppRouteChangeMetadata(instance);
22
+ const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
22
23
  if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
23
24
  routeChangeSubscribers.forEach((metadata) => {
24
25
  const methodName = metadata.propertyKey || metadata;
@@ -164,6 +165,34 @@ function SwcAppMixin(Base) {
164
165
  reload() {
165
166
  this.router?.reload();
166
167
  }
168
+ publishMessage(message) {
169
+ this._swc_connected_instance.forEach((instance) => {
170
+ this._invokeMessageSubscribers(instance, message);
171
+ });
172
+ }
173
+ _invokeMessageSubscribers(instance, message) {
174
+ const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);
175
+ if (messageSubscribers && Array.isArray(messageSubscribers)) {
176
+ messageSubscribers.forEach((metadata) => {
177
+ const methodName = metadata.propertyKey;
178
+ const messageType = metadata.messageType;
179
+ const filter = metadata.filter;
180
+ let typeMatched = false;
181
+ if (!messageType) {
182
+ typeMatched = true;
183
+ } else if (message.type === messageType) {
184
+ typeMatched = true;
185
+ }
186
+ let filterMatched = true;
187
+ if (filter && typeMatched) {
188
+ filterMatched = filter(message);
189
+ }
190
+ if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
191
+ instance[methodName](message);
192
+ }
193
+ });
194
+ }
195
+ }
167
196
  };
168
197
  }
169
198
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAppMixin.ts"],
4
- "sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from './SwcAppEngine';\nimport { SwcAppInterface } from '../types';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, Subscription } from '@dooboostore/core';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from '../decorators/lifecycles';\nimport { getSubscribeSwcAppRouteChangeMetadata } from '../decorators/subscribeSwcAppRouteChange';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n //@ts-ignore\n return class extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n /*\n 사파리 is 일경우\n <script src=\"https://unpkg.com/@ungap/custom-elements\"></script>\n 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데\n 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다\n */\n _connected_safari = [];\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n routeChangeSubscribers.forEach((metadata: any) => {\n const methodName = metadata.propertyKey || metadata;\n const pathPattern = metadata.pathPattern;\n const filter = metadata.filter;\n\n // Path pattern matching (support both string and array)\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n // pathPattern이 없으면 모든 경로 매칭 (와일드카드)\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n // 배열: 하나라도 매칭되면 OK\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n // 문자열\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n // Filter validation\n const filterPassed = !filter || filter(this.router!);\n\n // Invoke method if conditions pass\n if (pathMatched && filterPassed) {\n instance[methodName]?.({...re, pathData: pathData});\n }\n });\n }\n }\n\n _connected(instance: any) {\n // console.log('appmixin--> connected', this, instance);\n if (instance) {\n this._swc_connected_instance.add(instance);\n if (this.simpleApplication) {\n this._invokeOnConnectedSwcAppStarted(instance);\n // Notify current route subscribers immediately after connection\n if (this.router && this._lastRouterEvent) {\n this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);\n }\n }\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n }\n }\n\n _handleRouteChange(route: RouterEventType) {\n if (route.triggerPoint === 'end') {\n // Iterate through all connected component instances\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeRouteChangeSubscribers(instance, route);\n });\n }\n\n // Save last router event\n this._lastRouterEvent = route;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const swcConfig = {\n routeType: 'element',\n window: config.window,\n ...config\n } as SwcConfigType;\n\n const mode = config?.connectMode || 'direct';\n\n if (mode === 'direct') {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else if (mode === 'swap' && !this.parentNode) {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n this.parentNode.insertBefore(clonedApp, this.nextSibling);\n\n try {\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.setAttribute('swc-connect-mode', 'swap');\n clonedApp.style.display = '';\n } catch (e) {\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n throw e;\n }\n }\n\n // 사파리일떄 예외이다 is 일때 polyfill되는데 이떄 부모부터 만들어지는게 아니라 자식부터 만들어진다 그래서 부모가 만들어질때 자식들이 이미 만들어져있어서 부모가 자식들을 등록해주는 형태로 강제로 등록해준다\n this._connected_safari.forEach((instance: any) => {\n this._swc_connected_instance.add(instance);\n });\n // Invoke @onConnectedSwcApp lifecycle methods on all connected component instances\n // const hostSet = SwcUtils.getHostSet(this as any);\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeOnConnectedSwcAppStarted(instance);\n });\n\n\n // Subscribe to router changes after connect\n if (!this._routerSubscription && this.router) {\n this._routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n //@ts-ignore\n // console.log('Route changed:', route, this._swcId);\n this._handleRouteChange(route);\n });\n // Navigate to initial path if specified\n const config = this.__swc_engine.config;\n // if (config?.path) {\n // this.router.go(config.path);\n // }\n }\n }\n\n _invokeOnConnectedSwcAppStarted(instance: any) {\n const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n if (startedMethods) {\n for (const m of startedMethods) {\n instance._invokeLifecycleMethod(m);\n }\n }\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n // console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n this.connect(userConfig);\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n\n this.__swc_engine?.config?.onConnected?.(this);\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n };\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAA2D;AAEpE,SAAS,gBAAgB;AACzB,SAAS,qBAAmC;AAE5C,SAAS,mCAAmC,gCAAgC;AAC5E,SAAS,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;IAyMtB;IAxME,IAAI,oBAAiB;AACnB,aAAO,KAAK,aAAa;IAC3B;IACA,IAAI,SAAM;AACR,aAAO,KAAK,aAAa;IAC3B;IAEA,8BAA8B,UAAe,IAAmB;AAC9D,YAAM,yBAAyB,sCAAsC,QAAQ;AAC7E,UAAI,0BAA0B,MAAM,QAAQ,sBAAsB,GAAG;AACnE,+BAAuB,QAAQ,CAAC,aAAiB;AAC/C,gBAAM,aAAa,SAAS,eAAe;AAC3C,gBAAM,cAAc,SAAS;AAC7B,gBAAM,SAAS,SAAS;AAGxB,cAAI,cAAc;AAClB,cAAI,WAAgB;AAEpB,cAAI,CAAC,aAAa;AAEhB,0BAAc;AAC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D,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;",
4
+ "sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from './SwcAppEngine';\nimport { SwcAppInterface, SwcAppMessage } from '../types';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, Subscription } from '@dooboostore/core';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { ON_CONNECTED_SWC_APP_METADATA_KEY, findAllLifecycleMetadata } from '../decorators/lifecycles';\nimport { getSubscribeSwcAppRouteChangeWhileConnectedMetadata } from '../decorators/subscribeSwcAppRouteChangeWhileConnected';\nimport { getSubscribeSwcAppMessageWhileConnectedMetadata } from '../decorators/subscribeSwcAppMessageWhileConnected';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n //@ts-ignore\n return class extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n /*\n 사파리 is 일경우\n <script src=\"https://unpkg.com/@ungap/custom-elements\"></script>\n 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데\n 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다\n */\n _connected_safari = [];\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n routeChangeSubscribers.forEach((metadata: any) => {\n const methodName = metadata.propertyKey || metadata;\n const pathPattern = metadata.pathPattern;\n const filter = metadata.filter;\n\n // Path pattern matching (support both string and array)\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n // pathPattern이 없으면 모든 경로 매칭 (와일드카드)\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n // 배열: 하나라도 매칭되면 OK\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n // 문자열\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n // Filter validation\n const filterPassed = !filter || filter(this.router!);\n\n // Invoke method if conditions pass\n if (pathMatched && filterPassed) {\n instance[methodName]?.({...re, pathData: pathData});\n }\n });\n }\n }\n\n _connected(instance: any) {\n // console.log('appmixin--> connected', this, instance);\n if (instance) {\n this._swc_connected_instance.add(instance);\n if (this.simpleApplication) {\n this._invokeOnConnectedSwcAppStarted(instance);\n // Notify current route subscribers immediately after connection\n if (this.router && this._lastRouterEvent) {\n this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent);\n }\n }\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n }\n }\n\n _handleRouteChange(route: RouterEventType) {\n if (route.triggerPoint === 'end') {\n // Iterate through all connected component instances\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeRouteChangeSubscribers(instance, route);\n });\n }\n\n // Save last router event\n this._lastRouterEvent = route;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const swcConfig = {\n routeType: 'element',\n window: config.window,\n ...config\n } as SwcConfigType;\n\n const mode = config?.connectMode || 'direct';\n\n if (mode === 'direct') {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else if (mode === 'swap' && !this.parentNode) {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n this.parentNode.insertBefore(clonedApp, this.nextSibling);\n\n try {\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.setAttribute('swc-connect-mode', 'swap');\n clonedApp.style.display = '';\n } catch (e) {\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n throw e;\n }\n }\n\n // 사파리일떄 예외이다 is 일때 polyfill되는데 이떄 부모부터 만들어지는게 아니라 자식부터 만들어진다 그래서 부모가 만들어질때 자식들이 이미 만들어져있어서 부모가 자식들을 등록해주는 형태로 강제로 등록해준다\n this._connected_safari.forEach((instance: any) => {\n this._swc_connected_instance.add(instance);\n });\n // Invoke @onConnectedSwcApp lifecycle methods on all connected component instances\n // const hostSet = SwcUtils.getHostSet(this as any);\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeOnConnectedSwcAppStarted(instance);\n });\n\n\n // Subscribe to router changes after connect\n if (!this._routerSubscription && this.router) {\n this._routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n //@ts-ignore\n // console.log('Route changed:', route, this._swcId);\n this._handleRouteChange(route);\n });\n // Navigate to initial path if specified\n const config = this.__swc_engine.config;\n // if (config?.path) {\n // this.router.go(config.path);\n // }\n }\n }\n\n _invokeOnConnectedSwcAppStarted(instance: any) {\n const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n if (startedMethods) {\n for (const m of startedMethods) {\n instance._invokeLifecycleMethod(m);\n }\n }\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n // console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n this.connect(userConfig);\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n\n this.__swc_engine?.config?.onConnected?.(this);\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n\n publishMessage(message: SwcAppMessage): void {\n // 메시지를 모든 connected component instances로 분배\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeMessageSubscribers(instance, message);\n });\n }\n\n _invokeMessageSubscribers(instance: any, message: SwcAppMessage) {\n const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);\n if (messageSubscribers && Array.isArray(messageSubscribers)) {\n messageSubscribers.forEach((metadata: any) => {\n const methodName = metadata.propertyKey;\n const messageType = metadata.messageType;\n const filter = metadata.filter;\n\n // 메시지 타입 확인\n let typeMatched = false;\n if (!messageType) {\n // messageType이 없으면 모든 메시지 매칭 (와일드카드)\n typeMatched = true;\n } else if (message.type === messageType) {\n typeMatched = true;\n }\n\n // 필터 적용\n let filterMatched = true;\n if (filter && typeMatched) {\n filterMatched = filter(message);\n }\n\n // 조건을 만족하면 메서드 호출\n if (typeMatched && filterMatched && typeof instance[methodName] === 'function') {\n instance[methodName](message);\n }\n });\n }\n }\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAA2D;AAEpE,SAAS,gBAAgB;AACzB,SAAS,qBAAmC;AAE5C,SAAS,mCAAmC,gCAAgC;AAC5E,SAAS,2DAA2D;AACpE,SAAS,uDAAuD;AAE1D,SAAU,YAA6D,MAAO;AAElF,SAAO,cAAc,KAAI;IAAlB,cAAA;;AACL,WAAA,eAAe,IAAI,aAAa,IAAW;AAC3C,WAAA,0BAA0B,oBAAI,IAAG;AAUjC,WAAA,oBAAoB,CAAA;IA+OtB;IA9OE,IAAI,oBAAiB;AACnB,aAAO,KAAK,aAAa;IAC3B;IACA,IAAI,SAAM;AACR,aAAO,KAAK,aAAa;IAC3B;IAEA,8BAA8B,UAAe,IAAmB;AAC9D,YAAM,yBAAyB,oDAAoD,QAAQ;AAC3F,UAAI,0BAA0B,MAAM,QAAQ,sBAAsB,GAAG;AACnE,+BAAuB,QAAQ,CAAC,aAAiB;AAC/C,gBAAM,aAAa,SAAS,eAAe;AAC3C,gBAAM,cAAc,SAAS;AAC7B,gBAAM,SAAS,SAAS;AAGxB,cAAI,cAAc;AAClB,cAAI,WAAgB;AAEpB,cAAI,CAAC,aAAa;AAEhB,0BAAc;AACd,uBAAW,CAAA;UACb,WAAW,MAAM,QAAQ,WAAW,GAAG;AAErC,uBAAW,WAAW,aAAa;AACjC,oBAAM,OAAO,SAAS,iBAAiB,SAAS,GAAG,QAAQ,GAAG;AAC9D,kBAAI,SAAS,MAAM;AACjB,8BAAc;AACd,2BAAW;AACX;cACF;YACF;UACF,OAAO;AAEL,uBAAW,SAAS,iBAAiB,aAAa,GAAG,QAAQ,GAAG;AAChE,0B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AU;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;IAEA,eAAe,SAAsB;AAEnC,WAAK,wBAAwB,QAAQ,CAAC,aAAiB;AACrD,aAAK,0BAA0B,UAAU,OAAO;MAClD,CAAC;IACH;IAEA,0BAA0B,UAAe,SAAsB;AAC7D,YAAM,qBAAqB,gDAAgD,QAAQ;AACnF,UAAI,sBAAsB,MAAM,QAAQ,kBAAkB,GAAG;AAC3D,2BAAmB,QAAQ,CAAC,aAAiB;AAC3C,gBAAM,aAAa,SAAS;AAC5B,gBAAM,cAAc,SAAS;AAC7B,gBAAM,SAAS,SAAS;AAGxB,cAAI,cAAc;AAClB,cAAI,CAAC,aAAa;AAEhB,0BAAc;UAChB,WAAW,QAAQ,SAAS,aAAa;AACvC,0BAAc;UAChB;AAGA,cAAI,gBAAgB;AACpB,cAAI,UAAU,aAAa;AACzB,4BAAgB,OAAO,OAAO;UAChC;AAGA,cAAI,eAAe,iBAAiB,OAAO,SAAS,UAAU,MAAM,YAAY;AAC9E,qBAAS,UAAU,EAAE,OAAO;UAC9B;QACF,CAAC;MACH;IACF;;AAEJ;",
6
6
  "names": ["config"]
7
7
  }
@@ -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 & {$this: any};\nexport interface SwcChooseInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\n}\nexport interface SwcIfInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\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"],
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 & {$this: any};\n\nexport type SwcAppMessage<T = any> = {\n publisher?: any;\n data?: T;\n type?: string;\n};\n\nexport interface SwcChooseInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\n}\nexport interface SwcIfInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\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 publishMessage(message: SwcAppMessage): 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
  }
@@ -7919,7 +7919,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
7919
7919
  const appHost2 = hostSet.$appHost;
7920
7920
  const conf = getElementConfig(this);
7921
7921
  const currentWin = this._resolveWindow(conf);
7922
- if (connectedInnerHtmlList.some((it) => it.options.useShadow === true) && !this.shadowRoot) {
7922
+ if ((connectedInnerHtmlList.some((it) => it.options.useShadow === true) || conf?.useShadow === true) && !this.shadowRoot) {
7923
7923
  this.attachShadow({ mode: "open" });
7924
7924
  }
7925
7925
  this._executeSwcScript("swc-on-before-connected", hostSet);
@@ -8755,25 +8755,25 @@ var setPropertyHost = (propertyNameOrOptions, options = {}) => {
8755
8755
  return setProperty(":host", propertyNameOrOptions, options);
8756
8756
  };
8757
8757
 
8758
- // src/decorators/subscribeSwcAppRouteChange.ts
8759
- var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change");
8760
- function createSwcAppRouteChangeSubscriber(options) {
8758
+ // src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts
8759
+ var SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change-while-connected");
8760
+ function createSubscribeSwcAppRouteChangeWhileConnected(options) {
8761
8761
  return (target, propertyKey, descriptor) => {
8762
8762
  const pathPattern = options?.path;
8763
8763
  const filter = options?.filter;
8764
8764
  const constructor = target.constructor;
8765
- let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
8765
+ let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
8766
8766
  if (!list) {
8767
8767
  list = [];
8768
- ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
8768
+ ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
8769
8769
  }
8770
8770
  list.push({ propertyKey, pathPattern, filter });
8771
8771
  return descriptor;
8772
8772
  };
8773
8773
  }
8774
- function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
8774
+ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKey, descriptor) {
8775
8775
  if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
8776
- return createSwcAppRouteChangeSubscriber({})(targetOrOptions, propertyKey, descriptor);
8776
+ return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);
8777
8777
  }
8778
8778
  let options = {};
8779
8779
  if (Array.isArray(targetOrOptions)) {
@@ -8783,11 +8783,110 @@ function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
8783
8783
  } else if (targetOrOptions && typeof targetOrOptions === "object") {
8784
8784
  options = targetOrOptions;
8785
8785
  }
8786
- return createSwcAppRouteChangeSubscriber(options);
8786
+ return createSubscribeSwcAppRouteChangeWhileConnected(options);
8787
8787
  }
8788
- var getSubscribeSwcAppRouteChangeMetadata = (target) => {
8788
+ var getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
8789
8789
  const constructor = target instanceof Function ? target : target.constructor;
8790
- return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
8790
+ return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
8791
+ };
8792
+
8793
+ // src/decorators/subscribeSwcAppMessageWhileConnected.ts
8794
+ var SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-message-while-connected");
8795
+ function createSubscribeSwcAppMessageWhileConnected(options, messageType) {
8796
+ return (target, propertyKey, descriptor) => {
8797
+ const filter = options?.filter;
8798
+ const constructor = target.constructor;
8799
+ let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
8800
+ if (!list) {
8801
+ list = [];
8802
+ ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
8803
+ }
8804
+ list.push({ propertyKey, messageType, filter });
8805
+ return descriptor;
8806
+ };
8807
+ }
8808
+ function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, optionsOrPropertyKey, descriptor) {
8809
+ if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && optionsOrPropertyKey && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol") && descriptor) {
8810
+ const target = targetOrMessageTypeOrOptions;
8811
+ const propertyKey = optionsOrPropertyKey;
8812
+ return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);
8813
+ }
8814
+ let messageType;
8815
+ let options = {};
8816
+ if (typeof targetOrMessageTypeOrOptions === "string") {
8817
+ messageType = targetOrMessageTypeOrOptions;
8818
+ if (optionsOrPropertyKey && typeof optionsOrPropertyKey === "object") {
8819
+ options = optionsOrPropertyKey;
8820
+ }
8821
+ } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object") {
8822
+ options = targetOrMessageTypeOrOptions;
8823
+ }
8824
+ return createSubscribeSwcAppMessageWhileConnected(options, messageType);
8825
+ }
8826
+ var getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
8827
+ const constructor = target instanceof Function ? target : target.constructor;
8828
+ return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
8829
+ };
8830
+
8831
+ // src/decorators/publishSwcAppMessage.ts
8832
+ var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
8833
+ function createPublishSwcAppMessage(messageType) {
8834
+ return (target, propertyKey, descriptor) => {
8835
+ const constructor = target.constructor;
8836
+ let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
8837
+ if (!list) {
8838
+ list = [];
8839
+ ReflectUtils.defineMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);
8840
+ }
8841
+ list.push({ propertyKey, messageType });
8842
+ if (!descriptor) {
8843
+ return descriptor;
8844
+ }
8845
+ const originalMethod = descriptor.value;
8846
+ descriptor.value = function(...args) {
8847
+ const result = originalMethod.apply(this, args);
8848
+ if (result instanceof Promise) {
8849
+ result.then((data) => {
8850
+ const appHost2 = SwcUtils.getAppHost(this);
8851
+ if (appHost2) {
8852
+ appHost2.publishMessage({
8853
+ publisher: this,
8854
+ data,
8855
+ type: messageType
8856
+ });
8857
+ }
8858
+ }).catch((err) => {
8859
+ console.warn("publishSwcAppMessage async error:", err);
8860
+ });
8861
+ } else {
8862
+ const appHost2 = SwcUtils.getAppHost(this);
8863
+ if (appHost2) {
8864
+ appHost2.publishMessage({
8865
+ publisher: this,
8866
+ data: result,
8867
+ type: messageType
8868
+ });
8869
+ }
8870
+ }
8871
+ return result;
8872
+ };
8873
+ return descriptor;
8874
+ };
8875
+ }
8876
+ function publishSwcAppMessage(targetOrMessageType, propertyKey, descriptor) {
8877
+ if (targetOrMessageType && typeof targetOrMessageType === "object" && propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol") && descriptor) {
8878
+ const target = targetOrMessageType;
8879
+ return createPublishSwcAppMessage()(target, propertyKey, descriptor);
8880
+ }
8881
+ let messageType;
8882
+ if (typeof targetOrMessageType === "string") {
8883
+ messageType = targetOrMessageType;
8884
+ }
8885
+ return createPublishSwcAppMessage(messageType);
8886
+ }
8887
+ var getPublishSwcAppMessageMetadata = (target) => {
8888
+ const constructor = target instanceof Function ? target : target.constructor;
8889
+ return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
8791
8890
  };
8792
8891
 
8793
8892
  // ../simple-boot/dist/esm/decorators/SimDecorator.js
@@ -8850,10 +8949,12 @@ export {
8850
8949
  ON_CONNECTED_SWC_APP_METADATA_KEY,
8851
8950
  ON_INITIALIZE_METADATA_KEY,
8852
8951
  PROPERTY_SET_METADATA_KEY,
8952
+ PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
8853
8953
  QUERY_ALL_METADATA_KEY,
8854
8954
  QUERY_METADATA_KEY,
8855
8955
  STYLE_METADATA_KEY,
8856
- SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY,
8956
+ SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
8957
+ SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY,
8857
8958
  SWC_NOT_FOUND,
8858
8959
  SwcUtils,
8859
8960
  addClass,
@@ -8904,9 +9005,11 @@ export {
8904
9005
  getElementConfig,
8905
9006
  getEmitCustomEventMetadataList,
8906
9007
  getOnConnectedInnerHtmlMetadata,
9008
+ getPublishSwcAppMessageMetadata,
8907
9009
  getQueryAllMetadata,
8908
9010
  getQueryMetadata,
8909
- getSubscribeSwcAppRouteChangeMetadata,
9011
+ getSubscribeSwcAppMessageWhileConnectedMetadata,
9012
+ getSubscribeSwcAppRouteChangeWhileConnectedMetadata,
8910
9013
  host,
8911
9014
  htmlAElement,
8912
9015
  htmlArticleElement,
@@ -8935,6 +9038,7 @@ export {
8935
9038
  onDisconnected,
8936
9039
  onInitialize,
8937
9040
  parentHost,
9041
+ publishSwcAppMessage,
8938
9042
  query,
8939
9043
  queryAll,
8940
9044
  queryAllHost,
@@ -8954,7 +9058,8 @@ export {
8954
9058
  setPropertyHost,
8955
9059
  setStyle,
8956
9060
  setStyleHost,
8957
- subscribeSwcAppRouteChange,
9061
+ subscribeSwcAppMessageWhileConnected,
9062
+ subscribeSwcAppRouteChangeWhileConnected,
8958
9063
  textNode,
8959
9064
  toggleClass,
8960
9065
  toggleClassHost,