@dooboostore/simple-web-component 1.0.33 → 1.0.34

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 (114) hide show
  1. package/dist/cjs/decorators/addEventListener.js.map +1 -1
  2. package/dist/cjs/decorators/applyAttribute.js +67 -57
  3. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  4. package/dist/cjs/decorators/applyClass.js +80 -70
  5. package/dist/cjs/decorators/applyClass.js.map +2 -2
  6. package/dist/cjs/decorators/applyNode.js +1 -8
  7. package/dist/cjs/decorators/applyNode.js.map +2 -2
  8. package/dist/cjs/decorators/applyStyle.js +66 -56
  9. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  10. package/dist/cjs/decorators/attribute.js +35 -29
  11. package/dist/cjs/decorators/attribute.js.map +2 -2
  12. package/dist/cjs/decorators/changedAttributeHost.js +32 -12
  13. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  14. package/dist/cjs/decorators/elementDefine.js +29 -16
  15. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  16. package/dist/cjs/decorators/emitCustomEvent.js +57 -44
  17. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  18. package/dist/cjs/decorators/setProperty.js +50 -39
  19. package/dist/cjs/decorators/setProperty.js.map +2 -2
  20. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  21. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +1 -1
  22. package/dist/cjs/elements/SwcAppEngine.js +7 -7
  23. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  24. package/dist/cjs/elements/SwcAppMixin.js +60 -42
  25. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  26. package/dist/cjs/elements/SwcChoose.js +19 -15
  27. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  28. package/dist/cjs/elements/register.js +21 -16
  29. package/dist/cjs/elements/register.js.map +2 -2
  30. package/dist/cjs/utils/Utils.js +7 -3
  31. package/dist/cjs/utils/Utils.js.map +2 -2
  32. package/dist/esm/decorators/addEventListener.js.map +1 -1
  33. package/dist/esm/decorators/applyAttribute.js +67 -57
  34. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  35. package/dist/esm/decorators/applyClass.js +80 -70
  36. package/dist/esm/decorators/applyClass.js.map +2 -2
  37. package/dist/esm/decorators/applyNode.js +1 -8
  38. package/dist/esm/decorators/applyNode.js.map +2 -2
  39. package/dist/esm/decorators/applyStyle.js +66 -56
  40. package/dist/esm/decorators/applyStyle.js.map +2 -2
  41. package/dist/esm/decorators/attribute.js +35 -29
  42. package/dist/esm/decorators/attribute.js.map +2 -2
  43. package/dist/esm/decorators/changedAttributeHost.js +32 -12
  44. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  45. package/dist/esm/decorators/elementDefine.js +30 -17
  46. package/dist/esm/decorators/elementDefine.js.map +2 -2
  47. package/dist/esm/decorators/emitCustomEvent.js +57 -44
  48. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  49. package/dist/esm/decorators/setProperty.js +50 -39
  50. package/dist/esm/decorators/setProperty.js.map +2 -2
  51. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  52. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +1 -1
  53. package/dist/esm/elements/SwcAppEngine.js +6 -6
  54. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  55. package/dist/esm/elements/SwcAppMixin.js +60 -42
  56. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  57. package/dist/esm/elements/SwcChoose.js +20 -16
  58. package/dist/esm/elements/SwcChoose.js.map +2 -2
  59. package/dist/esm/elements/register.js +22 -17
  60. package/dist/esm/elements/register.js.map +2 -2
  61. package/dist/esm/utils/Utils.js +7 -3
  62. package/dist/esm/utils/Utils.js.map +2 -2
  63. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +425 -335
  64. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  65. package/dist/types/decorators/addEventListener.d.ts +4 -1
  66. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  67. package/dist/types/decorators/applyAttribute.d.ts +5 -1
  68. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  69. package/dist/types/decorators/applyClass.d.ts +4 -0
  70. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  71. package/dist/types/decorators/applyNode.d.ts +4 -1
  72. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  73. package/dist/types/decorators/applyStyle.d.ts +5 -1
  74. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  75. package/dist/types/decorators/attribute.d.ts +5 -0
  76. package/dist/types/decorators/attribute.d.ts.map +1 -1
  77. package/dist/types/decorators/changedAttributeHost.d.ts +13 -3
  78. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  79. package/dist/types/decorators/elementDefine.d.ts +1 -1
  80. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  81. package/dist/types/decorators/emitCustomEvent.d.ts +5 -1
  82. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  83. package/dist/types/decorators/setProperty.d.ts +5 -1
  84. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  85. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +2 -2
  86. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  87. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -2
  88. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  89. package/dist/types/elements/SwcAppEngine.d.ts +6 -3
  90. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  91. package/dist/types/elements/SwcAppMixin.d.ts +5 -3
  92. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  93. package/dist/types/elements/register.d.ts.map +1 -1
  94. package/dist/types/utils/Utils.d.ts.map +1 -1
  95. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +425 -335
  96. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  97. package/package.json +3 -3
  98. package/src/decorators/addEventListener.ts +1 -1
  99. package/src/decorators/applyAttribute.ts +74 -61
  100. package/src/decorators/applyClass.ts +91 -77
  101. package/src/decorators/applyNode.ts +3 -12
  102. package/src/decorators/applyStyle.ts +75 -61
  103. package/src/decorators/attribute.ts +55 -43
  104. package/src/decorators/changedAttributeHost.ts +47 -14
  105. package/src/decorators/elementDefine.ts +38 -20
  106. package/src/decorators/emitCustomEvent.ts +65 -49
  107. package/src/decorators/setProperty.ts +58 -44
  108. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
  109. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +2 -2
  110. package/src/elements/SwcAppEngine.ts +11 -12
  111. package/src/elements/SwcAppMixin.ts +76 -44
  112. package/src/elements/SwcChoose.ts +28 -7
  113. package/src/elements/register.ts +28 -7
  114. package/src/utils/Utils.ts +15 -5
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { Router } from '@dooboostore/core-web';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n pathPattern?: string | string[];\n filter?: (router: Router) => boolean;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: string | string[];\n filter?: (router: Router) => boolean;\n}\n\nfunction createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, pathPattern, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: string): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPatterns: string[]): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChangeWhileConnected\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);\n }\n \n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])\n options.path = targetOrOptions;\n } else if (typeof targetOrOptions === 'string') {\n // \uBB38\uC790\uC5F4: @subscribeSwcAppRouteChangeWhileConnected('/path')\n options.path = targetOrOptions;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ... })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { Router } from '@dooboostore/core-web';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n pathPattern?: string | string[];\n filter?: (router: Router, currentThis: any) => boolean;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: string | string[];\n filter?: (router: Router, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, pathPattern, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: string): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPatterns: string[]): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChangeWhileConnected\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);\n }\n \n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])\n options.path = targetOrOptions;\n } else if (typeof targetOrOptions === 'string') {\n // \uBB38\uC790\uC5F4: @subscribeSwcAppRouteChangeWhileConnected('/path')\n options.path = targetOrOptions;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ... })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
5
5
  "mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;AAa3J,SAAS,+CAA+C,SAAqD;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,SAAS;AAC7B,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,6DAA6D,WAAW;AAC/G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,6DAA6D,MAAM,WAAW;AAAA,IAC5G;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,yCAAyC,iBAAuB,aAA+B,YAAsC;AAGnJ,MAAI,gBAAgB,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACvF,WAAO,+CAA+C,CAAC,CAAC,EAAE,iBAAiB,aAAa,UAAU;AAAA,EACpG;AAGA,MAAI,UAAoC,CAAC;AAEzC,MAAI,MAAM,QAAQ,eAAe,GAAG;AAElC,YAAQ,OAAO;AAAA,EACjB,WAAW,OAAO,oBAAoB,UAAU;AAE9C,YAAQ,OAAO;AAAA,EACjB,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,cAAU;AAAA,EACZ;AAEA,SAAO,+CAA+C,OAAO;AAC/D;AAGO,MAAM,sDAAsD,CAAC,WAAmE;AACrI,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,6DAA6D,WAAW;AAC7G;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,7 @@
1
1
  import { SimpleApplication } from "@dooboostore/simple-boot/SimpleApplication";
2
- import { PathRouter } from "@dooboostore/core-web";
3
- import { HashRouter } from "@dooboostore/core-web";
2
+ import { HashRouter, PathRouter, Router } from "@dooboostore/core-web";
4
3
  import { ElementRouter } from "../router/ElementRouter.js";
5
4
  import { SimOption } from "@dooboostore/simple-boot/SimOption";
6
- import { Router } from "@dooboostore/core-web";
7
5
  class SwcAppEngine {
8
6
  constructor(host) {
9
7
  this.host = host;
@@ -21,21 +19,23 @@ class SwcAppEngine {
21
19
  } else if (this._config.routeType === "element") {
22
20
  this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });
23
21
  }
24
- const containerSymbol = this._config.container || this.host.getContainerSymbol?.();
25
22
  this.simpleApplication = new SimpleApplication(
26
23
  new SimOption({
27
24
  excludeProxys: [Node],
28
- container: containerSymbol
25
+ container: this._config.container
29
26
  })
30
27
  );
31
28
  const otherInstanceSim = /* @__PURE__ */ new Map();
29
+ this.config.otherInstanceSim?.forEach((v, k) => {
30
+ otherInstanceSim.set(k, v);
31
+ });
32
32
  if (this.router) otherInstanceSim.set(Router, this.router);
33
33
  this.simpleApplication.run(otherInstanceSim);
34
34
  if (this._config.onEngineStarted) {
35
35
  this._config.onEngineStarted(this.simpleApplication, this.host);
36
36
  }
37
37
  } catch (e) {
38
- console.error("[SWC-APP-ENGINE] Init failed:", e);
38
+ console.error("[SWC-APP-ENGINE] Init failed:", e, this._config);
39
39
  }
40
40
  }
41
41
  disconnect() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAppEngine.ts"],
4
- "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } 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, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n 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,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,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,cAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,YAAM,kBAAkB,KAAK,QAAQ,aAAc,KAAK,KAAa,qBAAqB;AAC1F,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,UAAU;AAAA,UACZ,eAAe,CAAC,IAAI;AAAA,UACpB,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,UAAI,KAAK,OAAQ,kBAAiB,IAAI,QAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAE3C,UAAI,KAAK,QAAQ,iBAAiB;AAChC,aAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MAC9F;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClD;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
4
+ "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { HashRouter, PathRouter, Router, RouterEventType } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { ConstructorType, OptionalType, Subscription } from '@dooboostore/core';\n\nimport { SwcAppInterface } from '../types';\nimport { SimConfig } from '@dooboostore/simple-boot';\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap' | 'clear-swap';\n container?: symbol;\n otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n onRouteChanged?: (event: RouterEventType, 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, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [Node],\n container: this._config.container\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n this.config.otherInstanceSim?.forEach((v, k) => {\n otherInstanceSim.set(k, v);\n });\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n if (this._config.onEngineStarted) {\n this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,YAAY,YAAY,cAA+B;AAChE,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAqBnB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EAC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ected_instance = /* @__PURE__ */ new Set();
13
+ this._swc_started_instances = /* @__PURE__ */ new WeakSet();
14
+ this._swc_notified_routes = /* @__PURE__ */ new WeakMap();
15
+ /*
16
+ 사파리 is 일경우
17
+ <script src="https://unpkg.com/@ungap/custom-elements"><\/script>
18
+ 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
19
+ 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
20
+ */
13
21
  this._connected_safari = [];
14
22
  }
15
23
  get simpleApplication() {
@@ -18,11 +26,13 @@ function SwcAppMixin(Base) {
18
26
  get router() {
19
27
  return this.__swc_engine.router;
20
28
  }
21
- _invokeRouteChangeSubscribers(instance, re) {
29
+ async _invokeRouteChangeSubscribers(instance, re) {
30
+ if (this._swc_notified_routes.get(instance) === re) return;
31
+ this._swc_notified_routes.set(instance, re);
22
32
  const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
23
33
  if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
24
- routeChangeSubscribers.forEach((metadata) => {
25
- const methodName = metadata.propertyKey || metadata;
34
+ const ps = routeChangeSubscribers.map(async (metadata) => {
35
+ const methodName = metadata.propertyKey;
26
36
  const pathPattern = metadata.pathPattern;
27
37
  const filter = metadata.filter;
28
38
  let pathMatched = false;
@@ -43,11 +53,12 @@ function SwcAppMixin(Base) {
43
53
  pathData = SwcUtils.parsePathPattern(pathPattern, re.path || "/");
44
54
  pathMatched = pathData !== null;
45
55
  }
46
- const filterPassed = !filter || filter(this.router);
47
- if (pathMatched && filterPassed) {
48
- instance[methodName]?.({ ...re, pathData });
56
+ const filterPassed = !filter || filter(this.router, instance);
57
+ if (pathMatched && filterPassed && instance[methodName]) {
58
+ await instance[methodName]({ ...re, pathData });
49
59
  }
50
60
  });
61
+ return await Promise.allSettled(ps);
51
62
  }
52
63
  }
53
64
  _connected(instance) {
@@ -64,15 +75,17 @@ function SwcAppMixin(Base) {
64
75
  _disconnected(instance) {
65
76
  if (instance) {
66
77
  this._swc_connected_instance.delete(instance);
78
+ this._swc_started_instances.delete(instance);
79
+ this._swc_notified_routes.delete(instance);
67
80
  }
68
81
  }
69
- _handleRouteChange(route) {
82
+ async _handleRouteChange(route) {
83
+ this._lastRouterEvent = route;
70
84
  if (route.triggerPoint === "end") {
71
- this._swc_connected_instance.forEach((instance) => {
72
- this._invokeRouteChangeSubscribers(instance, route);
73
- });
85
+ const swcConnectedInstance = Array.from(this._swc_connected_instance);
86
+ const ps = swcConnectedInstance.map((instance) => this._invokeRouteChangeSubscribers(instance, route));
87
+ await Promise.allSettled(ps);
74
88
  }
75
- this._lastRouterEvent = route;
76
89
  }
77
90
  async connect(config) {
78
91
  const swcConfig = {
@@ -84,50 +97,56 @@ function SwcAppMixin(Base) {
84
97
  if (mode === "direct") {
85
98
  await this.__swc_engine.connect(swcConfig);
86
99
  this.setAttribute("swc-connect-mode", "direct");
87
- } else if (mode === "swap" && !this.parentNode) {
88
- await this.__swc_engine.connect(swcConfig);
89
- this.setAttribute("swc-connect-mode", "direct");
90
- const clonedApp = this.cloneNode(true);
91
- clonedApp.style.display = "none";
92
- this.parentNode.insertBefore(clonedApp, this.nextSibling);
93
- try {
94
- await clonedApp.connect({ ...config || {}, connectMode: "direct" });
95
- if (this.parentNode) {
96
- this.parentNode.removeChild(this);
97
- }
98
- clonedApp.setAttribute("swc-connect-mode", "swap");
99
- clonedApp.style.display = "";
100
- } catch (e) {
101
- if (clonedApp.parentNode) {
102
- clonedApp.parentNode.removeChild(clonedApp);
100
+ } else if (mode === "swap" || mode === "clear-swap") {
101
+ if (!this.parentNode) {
102
+ await this.__swc_engine.connect(swcConfig);
103
+ this.setAttribute("swc-connect-mode", "direct");
104
+ } else {
105
+ const clonedApp = this.cloneNode(mode === "swap");
106
+ clonedApp.style.display = "none";
107
+ this.parentNode.insertBefore(clonedApp, this.nextSibling);
108
+ try {
109
+ await clonedApp.connect({ ...config || {}, connectMode: "direct" });
110
+ if (this.parentNode) {
111
+ this.parentNode.removeChild(this);
112
+ }
113
+ clonedApp.style.display = "";
114
+ clonedApp.setAttribute("swc-connect-mode", mode);
115
+ return;
116
+ } catch (e) {
117
+ if (clonedApp.parentNode) {
118
+ clonedApp.parentNode.removeChild(clonedApp);
119
+ }
120
+ await this.__swc_engine.connect(swcConfig);
121
+ this.setAttribute("swc-connect-mode", "direct");
103
122
  }
104
- throw e;
105
123
  }
106
124
  }
107
125
  this._connected_safari.forEach((instance) => {
108
126
  this._swc_connected_instance.add(instance);
109
127
  });
110
- this._swc_connected_instance.forEach((instance) => {
111
- this._invokeOnConnectedSwcAppStarted(instance);
112
- });
128
+ const scis = Array.from(this._swc_connected_instance);
129
+ await Promise.allSettled(scis.map((instance) => this._invokeOnConnectedSwcAppStarted(instance)));
113
130
  if (!this._routerSubscription && this.router) {
131
+ const config2 = this.__swc_engine.config;
114
132
  this._routerSubscription = this.router.observable.subscribe((route) => {
115
- this._handleRouteChange(route);
133
+ this._handleRouteChange(route).then((it) => {
134
+ config2?.onRouteChanged?.(route, this);
135
+ });
116
136
  });
117
- const config2 = this.__swc_engine.config;
118
137
  }
119
138
  }
120
- _invokeOnConnectedSwcAppStarted(instance) {
139
+ async _invokeOnConnectedSwcAppStarted(instance) {
140
+ if (this._swc_started_instances.has(instance)) return;
141
+ this._swc_started_instances.add(instance);
121
142
  const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
122
143
  if (startedMethods) {
123
- for (const m of startedMethods) {
124
- instance._invokeLifecycleMethod(m);
125
- }
144
+ const ps = startedMethods.map((m) => instance._invokeLifecycleMethod(m));
145
+ return await Promise.allSettled(ps);
126
146
  }
127
147
  }
128
148
  connectedCallback() {
129
- if (super.connectedCallback)
130
- super.connectedCallback();
149
+ if (super.connectedCallback) super.connectedCallback();
131
150
  const configStr = this.getAttribute("swc-get-application-config");
132
151
  const win = this.ownerDocument?.defaultView || window;
133
152
  if (configStr && win) {
@@ -145,8 +164,7 @@ function SwcAppMixin(Base) {
145
164
  this.__swc_engine?.config?.onConnected?.(this);
146
165
  }
147
166
  disconnectedCallback() {
148
- if (super.disconnectedCallback)
149
- super.disconnectedCallback();
167
+ if (super.disconnectedCallback) super.disconnectedCallback();
150
168
  this._routerSubscription?.unsubscribe();
151
169
  this._routerSubscription = void 0;
152
170
  this._lastRouterEvent = void 0;
@@ -185,7 +203,7 @@ function SwcAppMixin(Base) {
185
203
  }
186
204
  let filterMatched = true;
187
205
  if (filter && typeMatched) {
188
- filterMatched = filter(message);
206
+ filterMatched = filter(message, instance);
189
207
  }
190
208
  if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
191
209
  instance[methodName](message);
@@ -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, 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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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;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;",
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 _swc_started_instances = new WeakSet<any>();\n _swc_notified_routes = new WeakMap<any, RouterEventType>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n\n /*\n \uC0AC\uD30C\uB9AC is \uC77C\uACBD\uC6B0\n <script src=\"https://unpkg.com/@ungap/custom-elements\"></script>\n \uC774\uAC78\uC0AC\uC6A9\uD558\uB294\uB370 is \uB300\uC751\uD558\uB294\uAC70\uB2E4 \uADF8\uB7F0\uB370 \uC774\uB54C \uCC98\uB9AC\uB418\uB294 \uC21C\uC11C\uAC00 \uD06C\uB86C\uC774\uB098 \uD45C\uC900\uC5D0\uC11C\uB294 \uBD80\uBAA8\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uACE0 \uC790\uC2DD\uB4E4\uC774 \uB9CC\uB4E4\uC5B4\uC9C0\uB294\uB370\n \uC800 polyfill\uC5D0\uC11C\uB294 \uC790\uC2DD\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uACE0 \uBD80\uBAA8\uAC00 \uB9CC\uB4E4\uC5B4\uC9C4\uB2E4 is\uC77C\uB54C \uC544 .. \uC774\uBB38\uC81C\uB54C\uBB38\uC5D0 \uC790\uC2DD\uC774 _connected_safari \uC5D0 \uAC15\uC81C\uB85C \uC790\uAE30\uC790\uC2DD\uB123\uC5B4\uC900\uB2E4\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 async _invokeRouteChangeSubscribers(instance: any, re: RouterEventType) {\n // \uC774\uBBF8 \uC774 \uB77C\uC6B0\uD2B8 \uC774\uBCA4\uD2B8\uC5D0 \uB300\uD574 \uCC98\uB9AC\uB41C \uC778\uC2A4\uD134\uC2A4\uB77C\uBA74 \uC2A4\uD0B5 (\uB3D9\uC2DC\uC131/\uC911\uBCF5 \uBC29\uC9C0)\n if (this._swc_notified_routes.get(instance) === re) return;\n this._swc_notified_routes.set(instance, re);\n\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);\n if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {\n const ps = routeChangeSubscribers.map(async metadata => {\n const methodName = metadata.propertyKey;\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\uC774 \uC5C6\uC73C\uBA74 \uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D (\uC640\uC77C\uB4DC\uCE74\uB4DC)\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n // \uBC30\uC5F4: \uD558\uB098\uB77C\uB3C4 \uB9E4\uCE6D\uB418\uBA74 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 // \uBB38\uC790\uC5F4\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n // Filter validation\n const filterPassed = !filter || filter(this.router!, instance);\n\n // Invoke method if conditions pass\n if (pathMatched && filterPassed && instance[methodName]) {\n await instance[methodName]({ ...re, pathData: pathData });\n }\n });\n return await Promise.allSettled(ps);\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 this._swc_started_instances.delete(instance);\n this._swc_notified_routes.delete(instance);\n }\n }\n\n async _handleRouteChange(route: RouterEventType) {\n // Save last router event\n this._lastRouterEvent = route;\n if (route.triggerPoint === 'end') {\n // Iterate through all connected component instances\n const swcConnectedInstance = Array.from(this._swc_connected_instance);\n const ps = swcConnectedInstance.map((instance: any) => this._invokeRouteChangeSubscribers(instance, route));\n await Promise.allSettled(ps);\n }\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 // console.log('-------mode', mode);\n if (mode === 'direct') {\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else if (mode === 'swap' || mode === 'clear-swap') {\n if (!this.parentNode) {\n // \uBD80\uBAA8\uAC00 \uC5C6\uC73C\uBA74 swap\uC744 \uD560 \uC218 \uC5C6\uC73C\uBBC0\uB85C direct\uB85C \uD3F4\uBC31\uD569\uB2C8\uB2E4.\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n } else {\n // 1. \uD604\uC7AC SSR \uC0C1\uD0DC(\uD654\uBA74)\uB97C \uADF8\uB300\uB85C \uC720\uC9C0\uD55C \uCC44\uB85C, \uBC31\uADF8\uB77C\uC6B4\uB4DC\uC6A9 \uD074\uB860\uC744 \uB9CC\uB4ED\uB2C8\uB2E4.\n const clonedApp = this.cloneNode(mode === 'swap') as any; // clear-swap \uBAA8\uB4DC\uBA74 \uC790\uC2DD \uB178\uB4DC\uB97C \uD074\uB860\uD558\uC9C0 \uC54A\uC74C(false)\n clonedApp.style.display = 'none';\n \n // 2. DOM\uC5D0 \uD074\uB860\uC744 \uBAB0\uB798 \uBD99\uC785\uB2C8\uB2E4.\n this.parentNode.insertBefore(clonedApp, this.nextSibling);\n\n try {\n // 3. \uD074\uB860\uC744 direct \uBAA8\uB4DC\uB85C \uC5F0\uACB0(\uCD08\uAE30\uD654/\uB80C\uB354\uB9C1) \uC2DC\uD0B5\uB2C8\uB2E4.\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n \n // 4. \uD074\uB860\uC758 \uB80C\uB354\uB9C1\uC774 \uC644\uC804\uD788 \uB05D\uB098\uBA74, \uAE30\uC874 SSR \uD654\uBA74(this)\uC744 \uC9C0\uC6B0\uACE0 \uD074\uB860\uC744 \uBCF4\uC5EC\uC90D\uB2C8\uB2E4.\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.style.display = '';\n clonedApp.setAttribute('swc-connect-mode', mode);\n \n // \u2605 \uB9E4\uC6B0 \uC911\uC694: \uAD50\uCCB4\uAC00 \uC644\uB8CC\uB418\uC5C8\uC73C\uBBC0\uB85C \uAE30\uC874 \uC571(this)\uC740 \uC5EC\uAE30\uC11C \uC989\uC2DC \uC885\uB8CC\uD558\uC5EC \uBD88\uD544\uC694\uD55C \uB77C\uC6B0\uD130/\uC774\uBCA4\uD2B8 \uAD6C\uB3C5\uC744 \uB9C9\uC544\uC57C \uD569\uB2C8\uB2E4!\n return;\n } catch (e) {\n // \uC2E4\uD328 \uC2DC \uD074\uB860\uC744 \uC9C0\uC6B0\uACE0 \uC6D0\uBCF8\uC744 direct\uB85C \uAC15\uC81C \uC5F0\uACB0\uD569\uB2C8\uB2E4.\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n await this.__swc_engine.connect(swcConfig);\n this.setAttribute('swc-connect-mode', 'direct');\n }\n }\n }\n\n // \uC0AC\uD30C\uB9AC\uC77C\uB584 \uC608\uC678\uC774\uB2E4 is \uC77C\uB54C polyfill\uB418\uB294\uB370 \uC774\uB584 \uBD80\uBAA8\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uB294\uAC8C \uC544\uB2C8\uB77C \uC790\uC2DD\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C4\uB2E4 \uADF8\uB798\uC11C \uBD80\uBAA8\uAC00 \uB9CC\uB4E4\uC5B4\uC9C8\uB54C \uC790\uC2DD\uB4E4\uC774 \uC774\uBBF8 \uB9CC\uB4E4\uC5B4\uC838\uC788\uC5B4\uC11C \uBD80\uBAA8\uAC00 \uC790\uC2DD\uB4E4\uC744 \uB4F1\uB85D\uD574\uC8FC\uB294 \uD615\uD0DC\uB85C \uAC15\uC81C\uB85C \uB4F1\uB85D\uD574\uC900\uB2E4\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 const scis = Array.from(this._swc_connected_instance);\n await Promise.allSettled(scis.map(instance => this._invokeOnConnectedSwcAppStarted(instance)));\n // this._swc_connected_instance.forEach((instance: any) => {\n // this._invokeOnConnectedSwcAppStarted(instance);\n // });\n\n // Subscribe to router changes after connect\n if (!this._routerSubscription && this.router) {\n const config = this.__swc_engine.config;\n this._routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n //@ts-ignore\n // console.log('Route changed:', route, this._swcId);\n this._handleRouteChange(route).then(it => {\n config?.onRouteChanged?.(route, this);\n });\n });\n // Navigate to initial path if specified\n // if (config?.path) {\n // this.router.go(config.path);\n // }\n }\n }\n\n async _invokeOnConnectedSwcAppStarted(instance: any) {\n // \uC774\uBBF8 \uC2DC\uC791\uB41C \uC778\uC2A4\uD134\uC2A4\uB77C\uBA74 \uC2A4\uD0B5 (\uBE44\uB3D9\uAE30 \uBCD1\uB82C \uC911\uBCF5 \uD638\uCD9C \uBC29\uC9C0)\n if (this._swc_started_instances.has(instance)) return;\n this._swc_started_instances.add(instance);\n\n const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n if (startedMethods) {\n const ps = startedMethods.map(m => instance._invokeLifecycleMethod(m));\n return await Promise.allSettled(ps)\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 // \uBA54\uC2DC\uC9C0\uB97C \uBAA8\uB4E0 connected component instances\uB85C \uBD84\uBC30\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 => {\n const methodName = metadata.propertyKey;\n const messageType = metadata.messageType;\n const filter = metadata.filter;\n\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uD655\uC778\n let typeMatched = false;\n if (!messageType) {\n // messageType\uC774 \uC5C6\uC73C\uBA74 \uBAA8\uB4E0 \uBA54\uC2DC\uC9C0 \uB9E4\uCE6D (\uC640\uC77C\uB4DC\uCE74\uB4DC)\n typeMatched = true;\n } else if (message.type === messageType) {\n typeMatched = true;\n }\n\n // \uD544\uD130 \uC801\uC6A9\n let filterMatched = true;\n if (filter && typeMatched) {\n filterMatched = filter(message, instance);\n }\n\n // \uC870\uAC74\uC744 \uB9CC\uC871\uD558\uBA74 \uBA54\uC11C\uB4DC \uD638\uCD9C\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;AAEzD,SAAS,YAA6D,MAAS;AAEpF,SAAO,cAAc,KAAgC;AAAA,IAA9C;AAAA;AACL,0BAAe,IAAI,aAAa,IAAW;AAC3C,qCAA0B,oBAAI,IAAS;AACvC,oCAAyB,oBAAI,QAAa;AAC1C,kCAAuB,oBAAI,QAA8B;AAUzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoB,CAAC;AAAA;AAAA,IACrB,IAAI,oBAAoB;AACtB,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,IAAI,SAAS;AACX,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IAEA,MAAM,8BAA8B,UAAe,IAAqB;AAEtE,UAAI,KAAK,qBAAqB,IAAI,QAAQ,MAAM,GAAI;AACpD,WAAK,qBAAqB,IAAI,UAAU,EAAE;AAE1C,YAAM,yBAAyB,oDAAoD,QAAQ;AAC3F,UAAI,0BAA0B,MAAM,QAAQ,sBAAsB,GAAG;AACnE,cAAM,KAAK,uBAAuB,IAAI,OAAM,aAAY;AACtD,gBAAM,aAAa,SAAS;AAC5B,gBAAM,cAAc,S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BAAsB;AAC3B,WAAK,mBAAmB;AACxB,WAAK,aAAa,WAAW;AAC7B,WAAK,cAAc,QAAQ,iBAAiB,IAAI;AAAA,IAClD;AAAA,IAEA,MAAM,QAAQ,MAAc;AAC1B,YAAM,KAAK,QAAQ,GAAG,IAAI;AAAA,IAC5B;AAAA,IAEA,OAAa;AACX,WAAK,QAAQ,KAAK;AAAA,IACpB;AAAA,IAEA,UAAgB;AACd,WAAK,QAAQ,QAAQ;AAAA,IACvB;AAAA,IAEA,SAAe;AACb,WAAK,QAAQ,OAAO;AAAA,IACtB;AAAA,IAEA,eAAe,SAA8B;AAE3C,WAAK,wBAAwB,QAAQ,CAAC,aAAkB;AACtD,aAAK,0BAA0B,UAAU,OAAO;AAAA,MAClD,CAAC;AAAA,IACH;AAAA,IAEA,0BAA0B,UAAe,SAAwB;AAC/D,YAAM,qBAAqB,gDAAgD,QAAQ;AACnF,UAAI,sBAAsB,MAAM,QAAQ,kBAAkB,GAAG;AAC3D,2BAAmB,QAAQ,cAAY;AACrC,gBAAM,aAAa,SAAS;AAC5B,gBAAM,cAAc,SAAS;AAC7B,gBAAM,SAAS,SAAS;AAGxB,cAAI,cAAc;AAClB,cAAI,CAAC,aAAa;AAEhB,0BAAc;AAAA,UAChB,WAAW,QAAQ,SAAS,aAAa;AACvC,0BAAc;AAAA,UAChB;AAGA,cAAI,gBAAgB;AACpB,cAAI,UAAU,aAAa;AACzB,4BAAgB,OAAO,SAAS,QAAQ;AAAA,UAC1C;AAGA,cAAI,eAAe,iBAAiB,OAAO,SAAS,UAAU,MAAM,YAAY;AAC9E,qBAAS,UAAU,EAAE,OAAO;AAAA,UAC9B;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": ["config"]
7
7
  }
@@ -11,21 +11,28 @@ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
11
11
  import { SwcUtils } from "../utils/Utils.js";
12
12
  import { FunctionUtils, ActionExpression } from "@dooboostore/core";
13
13
  import { ConvertUtils } from "@dooboostore/core-web";
14
- import { attributeHost } from "../decorators/index.js";
14
+ import { attributeHost, getAttributeValue, getElementConfig } from "../decorators/index.js";
15
15
  class SwcChoose extends HTMLTemplateElement {
16
- constructor() {
17
- super(...arguments);
18
- this._nodes = [];
19
- this._previousTemplate = null;
20
- }
21
16
  get value() {
22
17
  return this._value;
23
18
  }
24
19
  set value(nv) {
25
- this.refresh(nv);
20
+ this._value = nv;
21
+ this.refresh(this._value);
26
22
  }
27
- setValue() {
28
- this.refresh();
23
+ constructor() {
24
+ super();
25
+ this._nodes = [];
26
+ this._previousTemplate = null;
27
+ }
28
+ // static get observedAttributes() {
29
+ // return ['value'];
30
+ // }
31
+ attributeChangedCallback(na, o, n) {
32
+ }
33
+ setValue(value, o, n) {
34
+ this._value = value;
35
+ this.refresh(this._value);
29
36
  }
30
37
  setReplaceWrap(replaceWrapAttr) {
31
38
  this.refresh();
@@ -49,11 +56,12 @@ class SwcChoose extends HTMLTemplateElement {
49
56
  }
50
57
  return ae.getUnprocessedTemplate();
51
58
  }
52
- refresh(value = this._value) {
59
+ refresh(value) {
60
+ value = getAttributeValue(this, "value") ?? this._value;
53
61
  const portal = this.parentElement;
54
62
  if (!portal)
55
63
  return;
56
- const win = this.ownerDocument?.defaultView || window;
64
+ const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;
57
65
  const helperSet = SwcUtils.getHelperAndHostSet(win, this);
58
66
  const groupArgs = { ...helperSet, $value: value };
59
67
  const templates = Array.from(this.content.querySelectorAll("template"));
@@ -109,10 +117,6 @@ class SwcChoose extends HTMLTemplateElement {
109
117
  this.cleanup();
110
118
  }
111
119
  }
112
- __decorate([
113
- attributeHost("value"),
114
- __metadata("design:type", Object)
115
- ], SwcChoose.prototype, "_value", void 0);
116
120
  __decorate([
117
121
  attributeHost("replace-wrap"),
118
122
  __metadata("design:type", String)
@@ -120,7 +124,7 @@ __decorate([
120
124
  __decorate([
121
125
  changedAttributeHost("value"),
122
126
  __metadata("design:type", Function),
123
- __metadata("design:paramtypes", []),
127
+ __metadata("design:paramtypes", [Object, String, String]),
124
128
  __metadata("design:returntype", void 0)
125
129
  ], SwcChoose.prototype, "setValue", null);
126
130
  __decorate([
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcChoose.ts"],
4
- "sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ConvertUtils } from '@dooboostore/core-web';\nimport { SwcChooseInterface } from '../types';\nimport { attributeHost } from '../decorators';\n\nclass SwcChoose extends HTMLTemplateElement implements SwcChooseInterface {\n @attributeHost('value')\n _value: any;\n\n @attributeHost('replace-wrap')\n _replaceWrap: string | null;\n\n private _nodes: Node[] = [];\n private _previousTemplate: HTMLTemplateElement | null = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this.refresh(nv);\n }\n\n @changedAttributeHost('value')\n private setValue() {\n this.refresh();\n }\n\n @changedAttributeHost('replace-wrap')\n private setReplaceWrap(replaceWrapAttr?: string | null) {\n this.refresh();\n }\n\n private replaceExpressions(html: string, groupArgs: any, context: any, wrap?: string | null): string {\n const config = wrap ? { wrapExpression: wrap } : undefined;\n const ae = new ActionExpression(html, config);\n const filterOptions = wrap ? { type: 'replace' as const, wrap } : 'replace';\n const win = this.ownerDocument?.defaultView || window;\n\n // @ts-ignore\n for (const expr of ae.getExpressions(filterOptions)) {\n try {\n const value = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),\n context,\n args: groupArgs\n });\n ae.replace(expr, String(value));\n } catch (e) {\n console.error(`[SWC] Failed to execute ${expr.original}:`, e);\n }\n }\n return ae.getUnprocessedTemplate();\n }\n\n refresh(value = this._value) {\n const portal = this.parentElement;\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n const groupArgs = { ...helperSet, $value: value };\n\n const templates = Array.from(this.content.querySelectorAll('template'));\n let selected: HTMLTemplateElement | null = null;\n\n for (const t of templates) {\n if (t.getAttribute('is') === 'swc-when') {\n const attrVal = t.getAttribute('value') || '';\n let matches = false;\n\n // Use ActionExpression to parse and extract script from value attribute\n const ae = new ActionExpression(attrVal);\n const expr = ae.getFirstExpression('replace');\n\n if (expr) {\n const decodedScript = ConvertUtils.decodeHtmlEntity(expr.script, win.document);\n const result = FunctionUtils.executeReturn({\n script: decodedScript,\n context: t,\n args: groupArgs\n });\n matches = !!result;\n } else {\n matches = String(attrVal) === String(value);\n }\n\n if (matches) {\n selected = t;\n break;\n }\n }\n }\n\n const target = selected || (this.content.querySelector('template[is=\"swc-otherwise\"]') as HTMLTemplateElement);\n\n const skipValue = target?.getAttribute?.('skip-if-same');\n const skipValue2 = this._previousTemplate?.getAttribute?.('skip-if-same');\n const hasSkipIfSame = target?.hasAttribute?.('skip-if-same');\n const isSame = this._previousTemplate === target;\n // console.log('---rrrr---', this._previousTemplate, target, hasSkipIfSame, isSame, skipValue, skipValue2);\n if (hasSkipIfSame && isSame) {\n return;\n }\n\n this.cleanup();\n this._previousTemplate = target;\n\n if (target) {\n let htmlString = target.innerHTML;\n htmlString = this.replaceExpressions(htmlString, groupArgs, this, this._replaceWrap);\n\n const result = this.ownerDocument?.createElement('template') || document.createElement('template');\n result.innerHTML = htmlString;\n const processedFragment = result.content;\n\n this._nodes = Array.from(processedFragment.childNodes);\n portal.insertBefore(processedFragment, this.nextSibling);\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,eAAe,wBAAwB;AAChD,SAAS,oBAAoB;AAE7B,SAAS,qBAAqB;AAE9B,MAAM,kB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AAc;;;;;",
4
+ "sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ConvertUtils } from '@dooboostore/core-web';\nimport { SwcChooseInterface } from '../types';\nimport { attributeHost, getAttributeValue, getElementConfig } from '../decorators';\n\nclass SwcChoose extends HTMLTemplateElement implements SwcChooseInterface {\n // @attributeHost('value')\n // fetchValue: any;\n\n _value: any;\n\n @attributeHost('replace-wrap')\n _replaceWrap: string | null;\n\n private _nodes: Node[] = [];\n private _previousTemplate: HTMLTemplateElement | null = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this._value = nv;\n this.refresh(this._value);\n }\n\n constructor() {\n super();\n // console.log('swc chooooooooooooooooooooooooose constructor called!');\n // console.log('swc cccccccss', this.getAttribute('value'));\n }\n\n // static get observedAttributes() {\n // return ['value'];\n // }\n\n attributeChangedCallback(na, o, n) {\n // console.log('-----------------choooooooose attr origin', na, o, n);\n }\n\n @changedAttributeHost('value')\n private setValue(value: any, o: string, n: string) {\n // console.log('-----------------choooooooose attr setValue', value, o, n);\n this._value = value;\n this.refresh(this._value);\n }\n\n @changedAttributeHost('replace-wrap')\n private setReplaceWrap(replaceWrapAttr?: string | null) {\n this.refresh();\n }\n\n private replaceExpressions(html: string, groupArgs: any, context: any, wrap?: string | null): string {\n const config = wrap ? { wrapExpression: wrap } : undefined;\n const ae = new ActionExpression(html, config);\n const filterOptions = wrap ? { type: 'replace' as const, wrap } : 'replace';\n const win = this.ownerDocument?.defaultView || window;\n\n // @ts-ignore\n for (const expr of ae.getExpressions(filterOptions)) {\n try {\n const value = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),\n context,\n args: groupArgs\n });\n ae.replace(expr, String(value));\n } catch (e) {\n console.error(`[SWC] Failed to execute ${expr.original}:`, e);\n }\n }\n return ae.getUnprocessedTemplate();\n }\n\n refresh(value?: any) {\n value = getAttributeValue(this, 'value') ?? this._value;\n // console.log('chooooooooo refresh->', value);\n const portal = this.parentElement;\n if (!portal) return;\n\n const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n const groupArgs = { ...helperSet, $value: value };\n\n const templates = Array.from(this.content.querySelectorAll('template'));\n let selected: HTMLTemplateElement | null = null;\n\n for (const t of templates) {\n if (t.getAttribute('is') === 'swc-when') {\n const attrVal = t.getAttribute('value') || '';\n let matches = false;\n\n // Use ActionExpression to parse and extract script from value attribute\n const ae = new ActionExpression(attrVal);\n const expr = ae.getFirstExpression('replace');\n\n if (expr) {\n const decodedScript = ConvertUtils.decodeHtmlEntity(expr.script, win.document);\n const result = FunctionUtils.executeReturn({\n script: decodedScript,\n context: t,\n args: groupArgs\n });\n matches = !!result;\n } else {\n matches = String(attrVal) === String(value);\n }\n\n if (matches) {\n selected = t;\n break;\n }\n }\n }\n\n const target = selected || (this.content.querySelector('template[is=\"swc-otherwise\"]') as HTMLTemplateElement);\n\n const skipValue = target?.getAttribute?.('skip-if-same');\n const skipValue2 = this._previousTemplate?.getAttribute?.('skip-if-same');\n const hasSkipIfSame = target?.hasAttribute?.('skip-if-same');\n const isSame = this._previousTemplate === target;\n // console.log('---rrrr---', this._previousTemplate, target, hasSkipIfSame, isSame, skipValue, skipValue2);\n if (hasSkipIfSame && isSame) {\n return;\n }\n\n this.cleanup();\n this._previousTemplate = target;\n\n if (target) {\n let htmlString = target.innerHTML;\n htmlString = this.replaceExpressions(htmlString, groupArgs, this, this._replaceWrap);\n\n const result = this.ownerDocument?.createElement('template') || document.createElement('template');\n result.innerHTML = htmlString;\n const processedFragment = result.content;\n\n this._nodes = Array.from(processedFragment.childNodes);\n portal.insertBefore(processedFragment, this.nextSibling);\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"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SAAS,MAAM,KAAK,kBAAkB,UAAU;AACrD,aAAO,aAAa,mBAAmB,KAAK,WAAW;IACzD;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AAzIA,WAAA;EADC,cAAc,cAAc;;;AA8BrB,WAAA;EADP,qBAAqB,OAAO;;;;;AAQrB,WAAA;EADP,qBAAqB,cAAc;;;;;",
6
6
  "names": []
7
7
  }
@@ -7,7 +7,7 @@ var __decorate = function(decorators, target, key, desc) {
7
7
  var __metadata = function(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { elementDefine, attributeHost, changedAttributeHost } from "../decorators/index.js";
10
+ import { getElementConfig, elementDefine, attributeHost, changedAttributeHost, getAttributeValue } from "../decorators/index.js";
11
11
  import { SwcAppMixin } from "./SwcAppMixin.js";
12
12
  import { SwcUtils } from "../utils/Utils.js";
13
13
  import { FunctionUtils, ActionExpression } from "@dooboostore/core";
@@ -284,19 +284,26 @@ const registerAllElements = (w) => {
284
284
  elementDefine("swc-loop", { extends: "template", window: w })
285
285
  ], SwcLoop);
286
286
  let SwcChoose = class SwcChoose extends HTMLTemplateElement {
287
- constructor() {
288
- super(...arguments);
289
- this._nodes = [];
290
- this._previousTemplate = null;
291
- }
292
287
  get value() {
293
288
  return this._value;
294
289
  }
295
290
  set value(nv) {
296
- this.refresh(nv);
291
+ this._value = nv;
292
+ this.refresh(this._value);
297
293
  }
298
- setValue() {
299
- this.refresh();
294
+ constructor() {
295
+ super();
296
+ this._nodes = [];
297
+ this._previousTemplate = null;
298
+ }
299
+ // static get observedAttributes() {
300
+ // return ['value'];
301
+ // }
302
+ attributeChangedCallback(na, o, n) {
303
+ }
304
+ setValue(value, o, n) {
305
+ this._value = value;
306
+ this.refresh(this._value);
300
307
  }
301
308
  setReplaceWrap(replaceWrapAttr) {
302
309
  this.refresh();
@@ -320,11 +327,12 @@ const registerAllElements = (w) => {
320
327
  }
321
328
  return ae.getUnprocessedTemplate();
322
329
  }
323
- refresh(value = this._value) {
330
+ refresh(value) {
331
+ value = getAttributeValue(this, "value") ?? this._value;
324
332
  const portal = this.parentElement;
325
333
  if (!portal)
326
334
  return;
327
- const win = this.ownerDocument?.defaultView || window;
335
+ const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;
328
336
  const helperSet = SwcUtils.getHelperAndHostSet(win, this);
329
337
  const groupArgs = { ...helperSet, $value: value };
330
338
  const templates = Array.from(this.content.querySelectorAll("template"));
@@ -380,10 +388,6 @@ const registerAllElements = (w) => {
380
388
  this.cleanup();
381
389
  }
382
390
  };
383
- __decorate([
384
- attributeHost("value"),
385
- __metadata("design:type", Object)
386
- ], SwcChoose.prototype, "_value", void 0);
387
391
  __decorate([
388
392
  attributeHost("replace-wrap"),
389
393
  __metadata("design:type", String)
@@ -391,7 +395,7 @@ const registerAllElements = (w) => {
391
395
  __decorate([
392
396
  changedAttributeHost("value"),
393
397
  __metadata("design:type", Function),
394
- __metadata("design:paramtypes", []),
398
+ __metadata("design:paramtypes", [Object, String, String]),
395
399
  __metadata("design:returntype", void 0)
396
400
  ], SwcChoose.prototype, "setValue", null);
397
401
  __decorate([
@@ -401,7 +405,8 @@ const registerAllElements = (w) => {
401
405
  __metadata("design:returntype", void 0)
402
406
  ], SwcChoose.prototype, "setReplaceWrap", null);
403
407
  SwcChoose = __decorate([
404
- elementDefine("swc-choose", { extends: "template", window: w })
408
+ elementDefine("swc-choose", { extends: "template", window: w }),
409
+ __metadata("design:paramtypes", [])
405
410
  ], SwcChoose);
406
411
  let SwcAsync = class SwcAsync extends HTMLTemplateElement {
407
412
  constructor() {