@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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;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,yBAAa,eAAe,6DAA6D,WAAW;AAC/G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,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,yBAAa,eAAe,6DAA6D,WAAW;AAC7G;",
6
6
  "names": []
7
7
  }
@@ -22,10 +22,8 @@ __export(SwcAppEngine_exports, {
22
22
  module.exports = __toCommonJS(SwcAppEngine_exports);
23
23
  var import_SimpleApplication = require("@dooboostore/simple-boot/SimpleApplication");
24
24
  var import_core_web = require("@dooboostore/core-web");
25
- var import_core_web2 = require("@dooboostore/core-web");
26
25
  var import_ElementRouter = require("../router/ElementRouter");
27
26
  var import_SimOption = require("@dooboostore/simple-boot/SimOption");
28
- var import_core_web3 = require("@dooboostore/core-web");
29
27
  class SwcAppEngine {
30
28
  constructor(host) {
31
29
  this.host = host;
@@ -39,25 +37,27 @@ class SwcAppEngine {
39
37
  if (this._config.routeType === "path") {
40
38
  this.router = new import_core_web.PathRouter({ window: this._config.window, firstUrl: this._config.path });
41
39
  } else if (this._config.routeType === "hash") {
42
- this.router = new import_core_web2.HashRouter({ window: this._config.window, firstUrl: this._config.path });
40
+ this.router = new import_core_web.HashRouter({ window: this._config.window, firstUrl: this._config.path });
43
41
  } else if (this._config.routeType === "element") {
44
42
  this.router = new import_ElementRouter.ElementRouter({ window: this._config.window, firstUrl: this._config.path });
45
43
  }
46
- const containerSymbol = this._config.container || this.host.getContainerSymbol?.();
47
44
  this.simpleApplication = new import_SimpleApplication.SimpleApplication(
48
45
  new import_SimOption.SimOption({
49
46
  excludeProxys: [Node],
50
- container: containerSymbol
47
+ container: this._config.container
51
48
  })
52
49
  );
53
50
  const otherInstanceSim = /* @__PURE__ */ new Map();
54
- if (this.router) otherInstanceSim.set(import_core_web3.Router, this.router);
51
+ this.config.otherInstanceSim?.forEach((v, k) => {
52
+ otherInstanceSim.set(k, v);
53
+ });
54
+ if (this.router) otherInstanceSim.set(import_core_web.Router, this.router);
55
55
  this.simpleApplication.run(otherInstanceSim);
56
56
  if (this._config.onEngineStarted) {
57
57
  this._config.onEngineStarted(this.simpleApplication, this.host);
58
58
  }
59
59
  } catch (e) {
60
- console.error("[SWC-APP-ENGINE] Init failed:", e);
60
+ console.error("[SWC-APP-ENGINE] Init failed:", e, this._config);
61
61
  }
62
62
  }
63
63
  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;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAkC;AAClC,sBAA2B;AAC3B,IAAAA,mBAA2B;AAC3B,2BAA8B;AAC9B,uBAA0B;AAC1B,IAAAA,mBAAwC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ooboostore/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;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAkC;AAClC,sBAAgE;AAChE,2BAA8B;AAC9B,uBAA0B;AAqBnB,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,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,mCAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,2BAAU;AAAA,UACZ,eAAe,CAAC,IAAI;AAAA,UACpB,WAAW,KAAK,QAAQ;AAAA,QAC1B,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,WAAK,OAAO,kBAAkB,QAAQ,CAAC,GAAG,MAAM;AAC9C,yBAAiB,IAAI,GAAG,CAAC;AAAA,MAC3B,CAAC;AACD,UAAI,KAAK,OAAQ,kBAAiB,IAAI,wBAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAE3C,UAAI,KAAK,QAAQ,iBAAiB;AAChC,aAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MAC9F;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,GAAG,KAAK,OAAO;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
6
+ "names": []
7
7
  }
@@ -32,6 +32,14 @@ function SwcAppMixin(Base) {
32
32
  super(...arguments);
33
33
  this.__swc_engine = new import_SwcAppEngine.SwcAppEngine(this);
34
34
  this._swc_connected_instance = /* @__PURE__ */ new Set();
35
+ this._swc_started_instances = /* @__PURE__ */ new WeakSet();
36
+ this._swc_notified_routes = /* @__PURE__ */ new WeakMap();
37
+ /*
38
+ 사파리 is 일경우
39
+ <script src="https://unpkg.com/@ungap/custom-elements"><\/script>
40
+ 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
41
+ 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
42
+ */
35
43
  this._connected_safari = [];
36
44
  }
37
45
  get simpleApplication() {
@@ -40,11 +48,13 @@ function SwcAppMixin(Base) {
40
48
  get router() {
41
49
  return this.__swc_engine.router;
42
50
  }
43
- _invokeRouteChangeSubscribers(instance, re) {
51
+ async _invokeRouteChangeSubscribers(instance, re) {
52
+ if (this._swc_notified_routes.get(instance) === re) return;
53
+ this._swc_notified_routes.set(instance, re);
44
54
  const routeChangeSubscribers = (0, import_subscribeSwcAppRouteChangeWhileConnected.getSubscribeSwcAppRouteChangeWhileConnectedMetadata)(instance);
45
55
  if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
46
- routeChangeSubscribers.forEach((metadata) => {
47
- const methodName = metadata.propertyKey || metadata;
56
+ const ps = routeChangeSubscribers.map(async (metadata) => {
57
+ const methodName = metadata.propertyKey;
48
58
  const pathPattern = metadata.pathPattern;
49
59
  const filter = metadata.filter;
50
60
  let pathMatched = false;
@@ -65,11 +75,12 @@ function SwcAppMixin(Base) {
65
75
  pathData = import_Utils.SwcUtils.parsePathPattern(pathPattern, re.path || "/");
66
76
  pathMatched = pathData !== null;
67
77
  }
68
- const filterPassed = !filter || filter(this.router);
69
- if (pathMatched && filterPassed) {
70
- instance[methodName]?.({ ...re, pathData });
78
+ const filterPassed = !filter || filter(this.router, instance);
79
+ if (pathMatched && filterPassed && instance[methodName]) {
80
+ await instance[methodName]({ ...re, pathData });
71
81
  }
72
82
  });
83
+ return await Promise.allSettled(ps);
73
84
  }
74
85
  }
75
86
  _connected(instance) {
@@ -86,15 +97,17 @@ function SwcAppMixin(Base) {
86
97
  _disconnected(instance) {
87
98
  if (instance) {
88
99
  this._swc_connected_instance.delete(instance);
100
+ this._swc_started_instances.delete(instance);
101
+ this._swc_notified_routes.delete(instance);
89
102
  }
90
103
  }
91
- _handleRouteChange(route) {
104
+ async _handleRouteChange(route) {
105
+ this._lastRouterEvent = route;
92
106
  if (route.triggerPoint === "end") {
93
- this._swc_connected_instance.forEach((instance) => {
94
- this._invokeRouteChangeSubscribers(instance, route);
95
- });
107
+ const swcConnectedInstance = Array.from(this._swc_connected_instance);
108
+ const ps = swcConnectedInstance.map((instance) => this._invokeRouteChangeSubscribers(instance, route));
109
+ await Promise.allSettled(ps);
96
110
  }
97
- this._lastRouterEvent = route;
98
111
  }
99
112
  async connect(config) {
100
113
  const swcConfig = {
@@ -106,50 +119,56 @@ function SwcAppMixin(Base) {
106
119
  if (mode === "direct") {
107
120
  await this.__swc_engine.connect(swcConfig);
108
121
  this.setAttribute("swc-connect-mode", "direct");
109
- } else if (mode === "swap" && !this.parentNode) {
110
- await this.__swc_engine.connect(swcConfig);
111
- this.setAttribute("swc-connect-mode", "direct");
112
- const clonedApp = this.cloneNode(true);
113
- clonedApp.style.display = "none";
114
- this.parentNode.insertBefore(clonedApp, this.nextSibling);
115
- try {
116
- await clonedApp.connect({ ...config || {}, connectMode: "direct" });
117
- if (this.parentNode) {
118
- this.parentNode.removeChild(this);
119
- }
120
- clonedApp.setAttribute("swc-connect-mode", "swap");
121
- clonedApp.style.display = "";
122
- } catch (e) {
123
- if (clonedApp.parentNode) {
124
- clonedApp.parentNode.removeChild(clonedApp);
122
+ } else if (mode === "swap" || mode === "clear-swap") {
123
+ if (!this.parentNode) {
124
+ await this.__swc_engine.connect(swcConfig);
125
+ this.setAttribute("swc-connect-mode", "direct");
126
+ } else {
127
+ const clonedApp = this.cloneNode(mode === "swap");
128
+ clonedApp.style.display = "none";
129
+ this.parentNode.insertBefore(clonedApp, this.nextSibling);
130
+ try {
131
+ await clonedApp.connect({ ...config || {}, connectMode: "direct" });
132
+ if (this.parentNode) {
133
+ this.parentNode.removeChild(this);
134
+ }
135
+ clonedApp.style.display = "";
136
+ clonedApp.setAttribute("swc-connect-mode", mode);
137
+ return;
138
+ } catch (e) {
139
+ if (clonedApp.parentNode) {
140
+ clonedApp.parentNode.removeChild(clonedApp);
141
+ }
142
+ await this.__swc_engine.connect(swcConfig);
143
+ this.setAttribute("swc-connect-mode", "direct");
125
144
  }
126
- throw e;
127
145
  }
128
146
  }
129
147
  this._connected_safari.forEach((instance) => {
130
148
  this._swc_connected_instance.add(instance);
131
149
  });
132
- this._swc_connected_instance.forEach((instance) => {
133
- this._invokeOnConnectedSwcAppStarted(instance);
134
- });
150
+ const scis = Array.from(this._swc_connected_instance);
151
+ await Promise.allSettled(scis.map((instance) => this._invokeOnConnectedSwcAppStarted(instance)));
135
152
  if (!this._routerSubscription && this.router) {
153
+ const config2 = this.__swc_engine.config;
136
154
  this._routerSubscription = this.router.observable.subscribe((route) => {
137
- this._handleRouteChange(route);
155
+ this._handleRouteChange(route).then((it) => {
156
+ config2?.onRouteChanged?.(route, this);
157
+ });
138
158
  });
139
- const config2 = this.__swc_engine.config;
140
159
  }
141
160
  }
142
- _invokeOnConnectedSwcAppStarted(instance) {
161
+ async _invokeOnConnectedSwcAppStarted(instance) {
162
+ if (this._swc_started_instances.has(instance)) return;
163
+ this._swc_started_instances.add(instance);
143
164
  const startedMethods = (0, import_lifecycles.findAllLifecycleMetadata)(instance, import_lifecycles.ON_CONNECTED_SWC_APP_METADATA_KEY);
144
165
  if (startedMethods) {
145
- for (const m of startedMethods) {
146
- instance._invokeLifecycleMethod(m);
147
- }
166
+ const ps = startedMethods.map((m) => instance._invokeLifecycleMethod(m));
167
+ return await Promise.allSettled(ps);
148
168
  }
149
169
  }
150
170
  connectedCallback() {
151
- if (super.connectedCallback)
152
- super.connectedCallback();
171
+ if (super.connectedCallback) super.connectedCallback();
153
172
  const configStr = this.getAttribute("swc-get-application-config");
154
173
  const win = this.ownerDocument?.defaultView || window;
155
174
  if (configStr && win) {
@@ -167,8 +186,7 @@ function SwcAppMixin(Base) {
167
186
  this.__swc_engine?.config?.onConnected?.(this);
168
187
  }
169
188
  disconnectedCallback() {
170
- if (super.disconnectedCallback)
171
- super.disconnectedCallback();
189
+ if (super.disconnectedCallback) super.disconnectedCallback();
172
190
  this._routerSubscription?.unsubscribe();
173
191
  this._routerSubscription = void 0;
174
192
  this._lastRouterEvent = void 0;
@@ -207,7 +225,7 @@ function SwcAppMixin(Base) {
207
225
  }
208
226
  let filterMatched = true;
209
227
  if (filter && typeMatched) {
210
- filterMatched = filter(message);
228
+ filterMatched = filter(message, instance);
211
229
  }
212
230
  if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
213
231
  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;;;;;0BAAoE;AAEpE,mBAAyB;AACzB,kBAA4C;AAE5C,wBAA4E;AAC5E,sDAAoE;AACpE,kDAAgE;AAE1D,SAAU,YAA6D,MAAO;AAElF,SAAO,cAAc,KAAI;IAAlB,cAAA;;AACL,WAAA,eAAe,IAAI,iCAAa,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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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;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoE;AAEpE,mBAAyB;AACzB,kBAA4C;AAE5C,wBAA4E;AAC5E,sDAAoE;AACpE,kDAAgE;AAEzD,SAAS,YAA6D,MAAS;AAEpF,SAAO,cAAc,KAAgC;AAAA,IAA9C;AAAA;AACL,0BAAe,IAAI,iCAAa,IAAW;AAC3C,qCAA0B,oBAAI,IAAS;AACvC,oCAAyB,oBAAI,QAAa;AAC1C,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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
  }
@@ -13,19 +13,26 @@ var __metadata = function(k, v) {
13
13
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
14
14
  };
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 = (0, import_decorators.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 = ((0, import_decorators.getElementConfig)(this).window ?? this.ownerDocument?.defaultView) || window;
57
65
  const helperSet = import_Utils.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
- (0, import_decorators.attributeHost)("value"),
114
- __metadata("design:type", Object)
115
- ], SwcChoose.prototype, "_value", void 0);
116
120
  __decorate([
117
121
  (0, import_decorators.attributeHost)("replace-wrap"),
118
122
  __metadata("design:type", String)
@@ -120,7 +124,7 @@ __decorate([
120
124
  __decorate([
121
125
  (0, import_changedAttributeHost.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,kCAAqC;AACrC,mBAAyB;AACzB,kBAAgD;AAChD,sBAA6B;AAE7B,wBAA8B;;;;;;;;;;AAE9B,MAAM,kBAAkB,oBAAmB;EAA3C,cAAA;;AAOU,SAAA,SAAiB,CAAA;AACjB,SAAA,oBAAgD;EAoH1D;EAlHE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EAEA,IAAI,MAAM,IAAO;AACf,SAAK,QAAQ,EAAE;EACjB;EAGQ,WAAQ;AACd,SAAK,QAAO;EACd;EAGQ,eAAe,iBAA+B;AACpD,SAAK,QAAO;EACd;EAEQ,mBAAmB,MAAc,WAAgB,SAAc,MAAoB;AACzF,UAAM,SAAS,OAAO,EAAE,gBAAgB,KAAI,IAAK;AACjD,UAAM,KAAK,IAAI,6BAAiB,MAAM,MAAM;AAC5C,UAAM,gBAAgB,OAAO,EAAE,MAAM,WAAoB,KAAI,IAAK;AAClE,UAAM,MAAM,KAAK,eAAe,eAAe;AAG/C,eAAW,QAAQ,GAAG,eAAe,aAAa,GAAG;AACnD,UAAI;AACF,cAAM,QAAQ,0BAAc,cAAc;UACxC,QAAQ,6BAAa,iBAAiB,KAAK,QAAQ,IAAI,QAAQ;UAC/D;UACA,MAAM;SACP;AACD,WAAG,QAAQ,MAAM,OAAO,KAAK,CAAC;MAChC,SAAS,GAAG;AACV,gBAAQ,MAAM,2BAA2B,KAAK,QAAQ,KAAK,CAAC;MAC9D;IACF;AACA,WAAO,GAAG,uBAAsB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AAK,SAAS,cAAc,UAAU;AACjG,aAAO,YAAY;AACnB,YAAM,oBAAoB,OAAO;AAEjC,WAAK,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;;AAzHA,WAAA;MADC,iCAAc,OAAO;;;AAItB,WAAA;MADC,iCAAc,cAAc;;;AAerB,WAAA;MADP,kDAAqB,OAAO;;;;;AAMrB,WAAA;MADP,kDAAqB,cAAc;;;;;",
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"],
5
+ "mappings": "AAAA,kCAAqC;AACrC,mBAAyB;AACzB,kBAAgD;AAChD,sBAA6B;AAE7B,wBAAmE;;;;;;;;;;AAEnE,MAAM,kBAAkB,oBAAmB;EAYzC,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EAEA,IAAI,MAAM,IAAO;AACf,SAAK,SAAS;AACd,SAAK,QAAQ,KAAK,MAAM;EAC1B;EAEA,cAAA;AACE,UAAK;AAbC,SAAA,SAAiB,CAAA;AACjB,SAAA,oBAAgD;EAexD;;;;EAMA,yBAAyB,IAAI,GAAG,GAAC;EAEjC;EAGQ,SAAS,OAAY,GAAW,GAAS;AAE/C,SAAK,SAAS;AACd,SAAK,QAAQ,KAAK,MAAM;EAC1B;EAGQ,eAAe,iBAA+B;AACpD,SAAK,QAAO;EACd;EAEQ,mBAAmB,MAAc,WAAgB,SAAc,MAAoB;AACzF,UAAM,SAAS,OAAO,EAAE,gBAAgB,KAAI,IAAK;AACjD,UAAM,KAAK,IAAI,6BAAiB,MAAM,MAAM;AAC5C,UAAM,gBAAgB,OAAO,EAAE,MAAM,WAAoB,KAAI,IAAK;AAClE,UAAM,MAAM,KAAK,eAAe,eAAe;AAG/C,eAAW,QAAQ,GAAG,eAAe,aAAa,GAAG;AACnD,UAAI;AACF,cAAM,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eAAe,cAAc;AACxE,UAAM,gBAAgB,QAAQ,eAAe,cAAc;AAC3D,UAAM,SAAS,KAAK,sBAAsB;AAE1C,QAAI,iBAAiB,QAAQ;AAC3B;IACF;AAEA,SAAK,QAAO;AACZ,SAAK,oBAAoB;AAEzB,QAAI,QAAQ;AACV,UAAI,aAAa,OAAO;AACxB,mBAAa,KAAK,mBAAmB,YAAY,WAAW,MAAM,KAAK,YAAY;AAEnF,YAAM,SAAS,KAAK,eAAe,cAAc,UAAU,KAAK,SAAS,cAAc,UAAU;AACjG,aAAO,YAAY;AACnB,YAAM,oBAAoB,OAAO;AAEjC,WAAK,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;MADC,iCAAc,cAAc;;;AA8BrB,WAAA;MADP,kDAAqB,OAAO;;;;;AAQrB,WAAA;MADP,kDAAqB,cAAc;;;;;",
6
6
  "names": []
7
7
  }
@@ -306,19 +306,26 @@ const registerAllElements = (w) => {
306
306
  (0, import_decorators.elementDefine)("swc-loop", { extends: "template", window: w })
307
307
  ], SwcLoop);
308
308
  let SwcChoose = class SwcChoose extends HTMLTemplateElement {
309
- constructor() {
310
- super(...arguments);
311
- this._nodes = [];
312
- this._previousTemplate = null;
313
- }
314
309
  get value() {
315
310
  return this._value;
316
311
  }
317
312
  set value(nv) {
318
- this.refresh(nv);
313
+ this._value = nv;
314
+ this.refresh(this._value);
319
315
  }
320
- setValue() {
321
- this.refresh();
316
+ constructor() {
317
+ super();
318
+ this._nodes = [];
319
+ this._previousTemplate = null;
320
+ }
321
+ // static get observedAttributes() {
322
+ // return ['value'];
323
+ // }
324
+ attributeChangedCallback(na, o, n) {
325
+ }
326
+ setValue(value, o, n) {
327
+ this._value = value;
328
+ this.refresh(this._value);
322
329
  }
323
330
  setReplaceWrap(replaceWrapAttr) {
324
331
  this.refresh();
@@ -342,11 +349,12 @@ const registerAllElements = (w) => {
342
349
  }
343
350
  return ae.getUnprocessedTemplate();
344
351
  }
345
- refresh(value = this._value) {
352
+ refresh(value) {
353
+ value = (0, import_decorators.getAttributeValue)(this, "value") ?? this._value;
346
354
  const portal = this.parentElement;
347
355
  if (!portal)
348
356
  return;
349
- const win = this.ownerDocument?.defaultView || window;
357
+ const win = ((0, import_decorators.getElementConfig)(this).window ?? this.ownerDocument?.defaultView) || window;
350
358
  const helperSet = import_Utils.SwcUtils.getHelperAndHostSet(win, this);
351
359
  const groupArgs = { ...helperSet, $value: value };
352
360
  const templates = Array.from(this.content.querySelectorAll("template"));
@@ -402,10 +410,6 @@ const registerAllElements = (w) => {
402
410
  this.cleanup();
403
411
  }
404
412
  };
405
- __decorate([
406
- (0, import_decorators.attributeHost)("value"),
407
- __metadata("design:type", Object)
408
- ], SwcChoose.prototype, "_value", void 0);
409
413
  __decorate([
410
414
  (0, import_decorators.attributeHost)("replace-wrap"),
411
415
  __metadata("design:type", String)
@@ -413,7 +417,7 @@ const registerAllElements = (w) => {
413
417
  __decorate([
414
418
  (0, import_decorators.changedAttributeHost)("value"),
415
419
  __metadata("design:type", Function),
416
- __metadata("design:paramtypes", []),
420
+ __metadata("design:paramtypes", [Object, String, String]),
417
421
  __metadata("design:returntype", void 0)
418
422
  ], SwcChoose.prototype, "setValue", null);
419
423
  __decorate([
@@ -423,7 +427,8 @@ const registerAllElements = (w) => {
423
427
  __metadata("design:returntype", void 0)
424
428
  ], SwcChoose.prototype, "setReplaceWrap", null);
425
429
  SwcChoose = __decorate([
426
- (0, import_decorators.elementDefine)("swc-choose", { extends: "template", window: w })
430
+ (0, import_decorators.elementDefine)("swc-choose", { extends: "template", window: w }),
431
+ __metadata("design:paramtypes", [])
427
432
  ], SwcChoose);
428
433
  let SwcAsync = class SwcAsync extends HTMLTemplateElement {
429
434
  constructor() {