@dooboostore/simple-web-component 1.0.24 → 1.0.26

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 (130) hide show
  1. package/README.md +162 -33
  2. package/dist/cjs/decorators/addEventListener.js +1 -1
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +148 -0
  5. package/dist/cjs/decorators/applyAttribute.js.map +7 -0
  6. package/dist/cjs/decorators/applyClass.js +164 -0
  7. package/dist/cjs/decorators/applyClass.js.map +7 -0
  8. package/dist/cjs/decorators/applyNode.js +87 -194
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/{style.js → applyStyle.js} +50 -60
  11. package/dist/cjs/decorators/applyStyle.js.map +7 -0
  12. package/dist/cjs/decorators/attribute.js +10 -16
  13. package/dist/cjs/decorators/attribute.js.map +2 -2
  14. package/dist/cjs/decorators/changedAttributeHost.js +1 -1
  15. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  16. package/dist/cjs/decorators/elementDefine.js +14 -23
  17. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  18. package/dist/cjs/decorators/emitCustomEvent.js +5 -2
  19. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  20. package/dist/cjs/decorators/index.js +3 -3
  21. package/dist/cjs/decorators/index.js.map +2 -2
  22. package/dist/cjs/decorators/lifecycles.js +9 -9
  23. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  24. package/dist/cjs/decorators/query.js +1 -1
  25. package/dist/cjs/decorators/query.js.map +2 -2
  26. package/dist/cjs/decorators/queryAll.js +1 -1
  27. package/dist/cjs/decorators/queryAll.js.map +2 -2
  28. package/dist/cjs/elements/SwcAppEngine.js +19 -4
  29. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  30. package/dist/cjs/elements/SwcAppMixin.js +2 -0
  31. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  32. package/dist/cjs/utils/Utils.js +1 -1
  33. package/dist/cjs/utils/Utils.js.map +2 -2
  34. package/dist/esm/decorators/addEventListener.js +1 -1
  35. package/dist/esm/decorators/addEventListener.js.map +2 -2
  36. package/dist/esm/decorators/applyAttribute.js +129 -0
  37. package/dist/esm/decorators/applyAttribute.js.map +7 -0
  38. package/dist/esm/decorators/applyClass.js +145 -0
  39. package/dist/esm/decorators/applyClass.js.map +7 -0
  40. package/dist/esm/decorators/applyNode.js +87 -194
  41. package/dist/esm/decorators/applyNode.js.map +2 -2
  42. package/dist/esm/decorators/{style.js → applyStyle.js} +47 -57
  43. package/dist/esm/decorators/applyStyle.js.map +7 -0
  44. package/dist/esm/decorators/attribute.js +10 -16
  45. package/dist/esm/decorators/attribute.js.map +2 -2
  46. package/dist/esm/decorators/changedAttributeHost.js +1 -1
  47. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  48. package/dist/esm/decorators/elementDefine.js +14 -23
  49. package/dist/esm/decorators/elementDefine.js.map +2 -2
  50. package/dist/esm/decorators/emitCustomEvent.js +5 -2
  51. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  52. package/dist/esm/decorators/index.js +3 -3
  53. package/dist/esm/decorators/index.js.map +1 -1
  54. package/dist/esm/decorators/lifecycles.js +9 -9
  55. package/dist/esm/decorators/lifecycles.js.map +2 -2
  56. package/dist/esm/decorators/query.js +1 -1
  57. package/dist/esm/decorators/query.js.map +2 -2
  58. package/dist/esm/decorators/queryAll.js +1 -1
  59. package/dist/esm/decorators/queryAll.js.map +2 -2
  60. package/dist/esm/elements/SwcAppEngine.js +19 -4
  61. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  62. package/dist/esm/elements/SwcAppMixin.js +2 -0
  63. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  64. package/dist/esm/utils/Utils.js +1 -1
  65. package/dist/esm/utils/Utils.js.map +2 -2
  66. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2853 -574
  67. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  68. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  69. package/dist/types/decorators/applyAttribute.d.ts +22 -0
  70. package/dist/types/decorators/applyAttribute.d.ts.map +1 -0
  71. package/dist/types/decorators/applyClass.d.ts +65 -0
  72. package/dist/types/decorators/applyClass.d.ts.map +1 -0
  73. package/dist/types/decorators/applyNode.d.ts +15 -123
  74. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  75. package/dist/types/decorators/applyStyle.d.ts +21 -0
  76. package/dist/types/decorators/applyStyle.d.ts.map +1 -0
  77. package/dist/types/decorators/attribute.d.ts +10 -19
  78. package/dist/types/decorators/attribute.d.ts.map +1 -1
  79. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  80. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  81. package/dist/types/decorators/emitCustomEvent.d.ts +1 -1
  82. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  83. package/dist/types/decorators/index.d.ts +3 -3
  84. package/dist/types/decorators/index.d.ts.map +1 -1
  85. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  86. package/dist/types/decorators/query.d.ts.map +1 -1
  87. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  88. package/dist/types/elements/SwcAppEngine.d.ts +7 -0
  89. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  90. package/dist/types/elements/SwcAppMixin.d.ts +1 -1
  91. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  92. package/dist/types/utils/Utils.d.ts.map +1 -1
  93. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2853 -574
  94. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  95. package/package.json +2 -2
  96. package/src/decorators/addEventListener.ts +1 -1
  97. package/src/decorators/applyAttribute.ts +147 -0
  98. package/src/decorators/applyClass.ts +158 -0
  99. package/src/decorators/applyNode.ts +112 -330
  100. package/src/decorators/applyStyle.ts +128 -0
  101. package/src/decorators/attribute.ts +21 -55
  102. package/src/decorators/changedAttributeHost.ts +1 -1
  103. package/src/decorators/elementDefine.ts +18 -39
  104. package/src/decorators/emitCustomEvent.ts +6 -3
  105. package/src/decorators/index.ts +3 -3
  106. package/src/decorators/lifecycles.ts +9 -11
  107. package/src/decorators/query.ts +1 -1
  108. package/src/decorators/queryAll.ts +1 -1
  109. package/src/elements/SwcAppEngine.ts +32 -4
  110. package/src/elements/SwcAppMixin.ts +2 -0
  111. package/src/utils/Utils.ts +2 -1
  112. package/dist/cjs/decorators/classList.js +0 -177
  113. package/dist/cjs/decorators/classList.js.map +0 -7
  114. package/dist/cjs/decorators/setAttribute.js +0 -111
  115. package/dist/cjs/decorators/setAttribute.js.map +0 -7
  116. package/dist/cjs/decorators/style.js.map +0 -7
  117. package/dist/esm/decorators/classList.js +0 -158
  118. package/dist/esm/decorators/classList.js.map +0 -7
  119. package/dist/esm/decorators/setAttribute.js +0 -92
  120. package/dist/esm/decorators/setAttribute.js.map +0 -7
  121. package/dist/esm/decorators/style.js.map +0 -7
  122. package/dist/types/decorators/classList.d.ts +0 -71
  123. package/dist/types/decorators/classList.d.ts.map +0 -1
  124. package/dist/types/decorators/setAttribute.d.ts +0 -23
  125. package/dist/types/decorators/setAttribute.d.ts.map +0 -1
  126. package/dist/types/decorators/style.d.ts +0 -58
  127. package/dist/types/decorators/style.d.ts.map +0 -1
  128. package/src/decorators/classList.ts +0 -234
  129. package/src/decorators/setAttribute.ts +0 -114
  130. package/src/decorators/style.ts +0 -185
@@ -28,11 +28,15 @@ var import_SimOption = require("@dooboostore/simple-boot/SimOption");
28
28
  var import_core_web3 = require("@dooboostore/core-web");
29
29
  var import_core3 = require("@dooboostore/core");
30
30
  var import_Utils = require("../utils/Utils");
31
+ var import_simple_boot = require("@dooboostore/simple-boot");
31
32
  class SwcAppEngine {
32
33
  constructor(host) {
33
34
  this.host = host;
34
35
  this._isInitialized = false;
35
36
  }
37
+ get config() {
38
+ return this._config;
39
+ }
36
40
  async connect(config) {
37
41
  if (this._isInitialized) return;
38
42
  let userConfig = config;
@@ -45,7 +49,7 @@ class SwcAppEngine {
45
49
  userConfig = import_core3.FunctionUtils.executeReturn({
46
50
  script: configStr,
47
51
  context: this.host,
48
- args: import_Utils.SwcUtils.getHelperAndHostSet(win, this.host)
52
+ args: import_Utils.SwcUtils.getHelperAndHostSet(win, import_Utils.SwcUtils.findNearestSwcHost(this.host))
49
53
  });
50
54
  } catch (e) {
51
55
  console.error("[SWC-APP-ENGINE] Script execution failed:", e);
@@ -56,11 +60,12 @@ class SwcAppEngine {
56
60
  this._isInitialized = true;
57
61
  try {
58
62
  if (userConfig.rootRouter) {
59
- const _config = {
63
+ this._config = {
60
64
  routeType: "element",
61
65
  window: win,
62
66
  ...userConfig
63
67
  };
68
+ const _config = this._config;
64
69
  if (_config.routeType === "path") {
65
70
  this.router = new import_core_web.PathRouter({ window: _config.window, firstUrl: _config.path });
66
71
  } else if (_config.routeType === "hash") {
@@ -71,11 +76,18 @@ class SwcAppEngine {
71
76
  if (this.router) {
72
77
  this.routerSubscription = this.router.observable.subscribe((route) => {
73
78
  if (route.triggerPoint === "end") {
74
- this.simpleApplication?.routing(route.path);
79
+ const targetPath = (route.path || "/") + route.search;
80
+ const intent = new import_simple_boot.Intent(targetPath);
81
+ this.simpleApplication?.routing(intent);
75
82
  }
76
83
  });
77
84
  }
78
- this.simpleApplication = new import_SimpleApplication.SimpleApplication(new import_SimOption.SimOption({ excludeProxys: [Node], rootRouter: _config.rootRouter }));
85
+ const containerSymbol = _config.container || this.host.getContainerSymbol?.();
86
+ this.simpleApplication = new import_SimpleApplication.SimpleApplication(new import_SimOption.SimOption({
87
+ excludeProxys: [Node],
88
+ rootRouter: _config.rootRouter,
89
+ container: containerSymbol
90
+ }));
79
91
  const otherInstanceSim = /* @__PURE__ */ new Map();
80
92
  if (this.router) otherInstanceSim.set(import_core_web3.Router, this.router);
81
93
  this.simpleApplication.run(otherInstanceSim);
@@ -85,6 +97,9 @@ class SwcAppEngine {
85
97
  else this.host.replaceChildren(data);
86
98
  }
87
99
  if (_config.path) this.router?.go(_config.path);
100
+ if (_config.onStarted) {
101
+ _config.onStarted(this.host);
102
+ }
88
103
  }
89
104
  } catch (e) {
90
105
  console.error("[SWC-APP-ENGINE] Init failed:", e);
@@ -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\nexport type SwcConfigType = {\n rootRouter: ConstructorType<any> | symbol;\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n path?: string;\n window: Window;\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 _isInitialized = false;\n\n constructor(private host: HTMLElement) {}\n\n async connect(config?: SwcAttributeConfigType) {\n if (this._isInitialized) return;\n\n let userConfig = config;\n const win = this.host.ownerDocument?.defaultView || window;\n const Node = (win as any).Node as typeof globalThis.Node;\n if (!userConfig) {\n const configStr = this.host.getAttribute('swc-get-application-config');\n if (configStr) {\n try {\n userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this.host,\n args: SwcUtils.getHelperAndHostSet(win, this.host)\n });\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n }\n\n if (!userConfig) return;\n this._isInitialized = true;\n\n try {\n if (userConfig.rootRouter) {\n const _config: SwcConfigType = {\n routeType: 'element',\n window: win,\n ...userConfig\n } as SwcConfigType;\n\n // Router Selection\n if (_config.routeType === 'path') {\n this.router = new PathRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'hash') {\n this.router = new HashRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'element') {\n this.router = new ElementRouter({ window: _config.window, firstUrl: _config.path });\n }\n\n // Routing sync\n if (this.router) {\n this.routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n if (route.triggerPoint === 'end') {\n this.simpleApplication?.routing(route.path);\n }\n });\n }\n\n\n // App start\n this.simpleApplication = new SimpleApplication(new SimOption({ excludeProxys: [Node], rootRouter: _config.rootRouter }));\n\n const otherInstanceSim = new Map<any, any>();\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n // Rendering\n const data = this.simpleApplication.sim(_config.rootRouter);\n if (data instanceof Node) {\n // console.warn('[SWC-APP-ENGINE] Rendering failed: Root element is not a DocumentFragment.', data);\n if (this.host.shadowRoot) this.host.shadowRoot.replaceChildren(data);\n else this.host.replaceChildren(data);\n }\n\n if (_config.path) this.router?.go(_config.path);\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;AAGxC,IAAAC,eAA8B;AAC9B,mBAAyB;AAYlB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAFpB,SAAQ,iBAAiB;AAAA,EAEe;AAAA,EAExC,MAAM,QAAQ,QAAiC;AAC7C,QAAI,KAAK,eAAgB;AA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AQ,WAAW,CAAC,CAAC;AAEvH,cAAM,mBAAmB,oBAAI,IAAc;AAC3C,YAAI,KAAK,OAAQ,kBAAiB,IAAI,yBAAQ,KAAK,MAAM;AACzD,aAAK,kBAAkB,IAAI,gBAAgB;AAG3C,cAAM,OAAO,KAAK,kBAAkB,IAAI,QAAQ,UAAU;AAC1D,YAAI,gBAAgB,MAAM;AAExB,cAAI,KAAK,KAAK,WAAY,MAAK,KAAK,WAAW,gBAAgB,IAAI;AAAA,cAC9D,MAAK,KAAK,gBAAgB,IAAI;AAAA,QACrC;AAEA,YAAI,QAAQ,KAAM,MAAK,QAAQ,GAAG,QAAQ,IAAI;AAAA,MAChD;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 { 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 rootRouter: ConstructorType<any> | symbol;\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n container?: symbol;\n path?: string;\n window: Window;\n onStarted?: (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 _isInitialized = false;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n async connect(config?: SwcAttributeConfigType) {\n if (this._isInitialized) return;\n\n let userConfig = config;\n const win = this.host.ownerDocument?.defaultView || window;\n const Node = (win as any).Node as typeof globalThis.Node;\n if (!userConfig) {\n const configStr = this.host.getAttribute('swc-get-application-config');\n if (configStr) {\n try {\n // console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))\n userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this.host,\n args: SwcUtils.getHelperAndHostSet(win, SwcUtils.findNearestSwcHost(this.host))\n });\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n }\n\n if (!userConfig) return;\n this._isInitialized = true;\n\n try {\n if (userConfig.rootRouter) {\n this._config = {\n routeType: 'element',\n window: win,\n ...userConfig\n } as SwcConfigType;\n const _config = this._config;\n\n // Router Selection\n if (_config.routeType === 'path') {\n this.router = new PathRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'hash') {\n this.router = new HashRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'element') {\n this.router = new ElementRouter({ window: _config.window, firstUrl: _config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // Routing sync\n if (this.router) {\n this.routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n if (route.triggerPoint === 'end') {\n const targetPath = (route.path || '/') + route.search;\n const intent = new Intent(targetPath);\n this.simpleApplication?.routing(intent);\n }\n });\n }\n\n\n // App start\n const containerSymbol = _config.container || (this.host as any).getContainerSymbol?.();\n this.simpleApplication = new SimpleApplication(new SimOption({\n excludeProxys: [Node], \n rootRouter: _config.rootRouter,\n container: containerSymbol\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\n\n // Rendering\n const data = this.simpleApplication.sim(_config.rootRouter);\n if (data instanceof Node) {\n // console.warn('[SWC-APP-ENGINE] Rendering failed: Root element is not a DocumentFragment.', data);\n if (this.host.shadowRoot) this.host.shadowRoot.replaceChildren(data);\n else this.host.replaceChildren(data);\n }\n\n if (_config.path) this.router?.go(_config.path);\n if (_config.onStarted) {\n _config.onStarted(this.host as unknown as SwcAppInterface);\n }\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e);\n }\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;AAGxC,IAAAC,eAA8B;AAC9B,mBAAyB;AAGzB,yBAAqB;AAgBd,MAAM,aAAa;AAAA,EAOxB,YAAoB,MAAmB;AAAnB;AAHpB,SAAQ,iBAAiB;AAAA,EAGe;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EACA,MAAM,QAAQ,QAAiC;AAC7C,QAAI,KAAK,eAAgB;AAEzB,QAAI,aAAa;AACjB,UAAM,MAAM,KAAK,KAAK,eAAe,eAAe;AACpD,UAAM,OAAQ,IAAY;AAC1B,QAAI,CAAC,YAAY;AACf,YAAM,YAAY,KAAK,KAAK,aAAa,4BAA4B;AACrE,UAAI,WAAW;AACb,YAAI;AAEF,uBAAa,2BAAc,cAAc;AAAA,YACvC,QAAQ;AAAA,YACR,SAAS,KAAK;AAAA,YACd,MAAM,sBAAS,oBAAoB,KAAK,sBAAS,mBAAmB,KAAK,IAAI,CAAC;AAAA,UAChF,CAAC;AAAA,QACH,SAAS,GAAG;AACV,kB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cAAM,OAAO,KAAK,kBAAkB,IAAI,QAAQ,UAAU;AAC1D,YAAI,gBAAgB,MAAM;AAExB,cAAI,KAAK,KAAK,WAAY,MAAK,KAAK,WAAW,gBAAgB,IAAI;AAAA,cAC9D,MAAK,KAAK,gBAAgB,IAAI;AAAA,QACrC;AAEA,YAAI,QAAQ,KAAM,MAAK,QAAQ,GAAG,QAAQ,IAAI;AAC9C,YAAI,QAAQ,WAAW;AACrB,kBAAQ,UAAU,KAAK,IAAkC;AAAA,QAC3D;AAAA,MACF;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClD;AAAA,EACF;AAAA,EAGA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
6
6
  "names": ["import_core_web", "import_core"]
7
7
  }
@@ -66,10 +66,12 @@ function SwcAppMixin(Base) {
66
66
  connectedCallback() {
67
67
  if (super.connectedCallback) super.connectedCallback();
68
68
  this.connect();
69
+ this.__swc_engine?.config?.onConnected?.(this);
69
70
  }
70
71
  disconnectedCallback() {
71
72
  if (super.disconnectedCallback) super.disconnectedCallback();
72
73
  this.__swc_engine.disconnect();
74
+ this.__swc_engine?.config?.onDisconnected?.(this);
73
75
  }
74
76
  async routing(path) {
75
77
  await this.__swc_engine.router?.go(path);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAppMixin.ts"],
4
- "sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType } from './SwcAppEngine';\nimport {SwcAppInterface} from \"../types\";\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class extends Base implements SwcAppInterface{\n __swc_engine = new SwcAppEngine(this as any);\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const mode = config?.connectMode || 'direct';\n\n if (mode !== 'swap') {\n await this.__swc_engine.connect(config);\n this.setAttribute('swc-connect-mode', 'direct');\n return;\n }\n\n const parent = this.parentNode;\n if (!parent) {\n await this.__swc_engine.connect(config);\n this.setAttribute('swc-connect-mode', 'direct');\n return;\n }\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n parent.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 connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n this.connect();\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this.__swc_engine.disconnect();\n }\n\n async routing(path: string) {\n await this.__swc_engine.router?.go(path);\n }\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAqD;AAG9C,SAAS,YAA6D,MAAS;AACpF,SAAO,cAAc,KAA+B;AAAA,IAA7C;AAAA;AACL,0BAAe,IAAI,iCAAa,IAAW;AAAA;AAAA,IAE3C,IAAI,oBAAoB;AACtB,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,IAAI,SAAS;AACX,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IAEA,MAAM,QAAQ,QAAiC;AAC7C,YAAM,OAAO,QAAQ,eAAe;AAEpC,UAAI,SAAS,QAAQ;AACnB,cAAM,KAAK,aAAa,QAAQ,MAAM;AACtC,aAAK,aAAa,oBAAoB,QAAQ;AAC9C;AAAA,MACF;AAEA,YAAM,SAAS,KAAK;AACpB,UAAI,CAAC,QAAQ;AACX,cAAM,KAAK,aAAa,QAAQ,MAAM;AACtC,aAAK,aAAa,oBAAoB,QAAQ;AAC9C;AAAA,MACF;AAEA,YAAM,YAAY,KAAK,UAAU,IAAI;AACrC,gBAAU,MAAM,UAAU;AAC1B,aAAO,aAAa,WAAW,KAAK,WAAW;AAE/C,UAAI;AACF,cAAM,UAAU,QAAQ,EAAE,GAAI,UAAU,CAAC,GAAI,aAAa,SAAS,CAAC;AACpE,YAAI,KAAK,YAAY;AACnB,eAAK,WAAW,YAAY,IAAI;AAAA,QAClC;AACA,kBAAU,aAAa,oBAAoB,MAAM;AACjD,kBAAU,MAAM,UAAU;AAAA,MAC5B,SAAS,GAAG;AACV,YAAI,UAAU,YAAY;AACxB,oBAAU,WAAW,YAAY,SAAS;AAAA,QAC5C;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,oBAAoB;AAElB,UAAI,MAAM,kBAAmB,OAAM,kBAAkB;AACrD,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,uBAAuB;AAErB,UAAI,MAAM,qBAAsB,OAAM,qBAAqB;AAC3D,WAAK,aAAa,WAAW;AAAA,IAC/B;AAAA,IAEA,MAAM,QAAQ,MAAc;AAC1B,YAAM,KAAK,aAAa,QAAQ,GAAG,IAAI;AAAA,IACzC;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType } from './SwcAppEngine';\nimport {SwcAppInterface} from \"../types\";\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class extends Base implements SwcAppInterface{\n __swc_engine = new SwcAppEngine(this as any);\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const mode = config?.connectMode || 'direct';\n\n if (mode !== 'swap') {\n await this.__swc_engine.connect(config);\n this.setAttribute('swc-connect-mode', 'direct');\n return;\n }\n\n const parent = this.parentNode;\n if (!parent) {\n await this.__swc_engine.connect(config);\n this.setAttribute('swc-connect-mode', 'direct');\n return;\n }\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n parent.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 connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n this.connect();\n this.__swc_engine?.config?.onConnected?.(this);\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n }\n\n async routing(path: string) {\n await this.__swc_engine.router?.go(path);\n }\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAqD;AAG9C,SAAS,YAA6D,MAAS;AACpF,SAAO,cAAc,KAA+B;AAAA,IAA7C;AAAA;AACL,0BAAe,IAAI,iCAAa,IAAW;AAAA;AAAA,IAE3C,IAAI,oBAAoB;AACtB,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,IAAI,SAAS;AACX,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IAEA,MAAM,QAAQ,QAAiC;AAC7C,YAAM,OAAO,QAAQ,eAAe;AAEpC,UAAI,SAAS,QAAQ;AACnB,cAAM,KAAK,aAAa,QAAQ,MAAM;AACtC,aAAK,aAAa,oBAAoB,QAAQ;AAC9C;AAAA,MACF;AAEA,YAAM,SAAS,KAAK;AACpB,UAAI,CAAC,QAAQ;AACX,cAAM,KAAK,aAAa,QAAQ,MAAM;AACtC,aAAK,aAAa,oBAAoB,QAAQ;AAC9C;AAAA,MACF;AAEA,YAAM,YAAY,KAAK,UAAU,IAAI;AACrC,gBAAU,MAAM,UAAU;AAC1B,aAAO,aAAa,WAAW,KAAK,WAAW;AAE/C,UAAI;AACF,cAAM,UAAU,QAAQ,EAAE,GAAI,UAAU,CAAC,GAAI,aAAa,SAAS,CAAC;AACpE,YAAI,KAAK,YAAY;AACnB,eAAK,WAAW,YAAY,IAAI;AAAA,QAClC;AACA,kBAAU,aAAa,oBAAoB,MAAM;AACjD,kBAAU,MAAM,UAAU;AAAA,MAC5B,SAAS,GAAG;AACV,YAAI,UAAU,YAAY;AACxB,oBAAU,WAAW,YAAY,SAAS;AAAA,QAC5C;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,oBAAoB;AAElB,UAAI,MAAM,kBAAmB,OAAM,kBAAkB;AACrD,WAAK,QAAQ;AACb,WAAK,cAAc,QAAQ,cAAc,IAAI;AAAA,IAC/C;AAAA,IAEA,uBAAuB;AAErB,UAAI,MAAM,qBAAsB,OAAM,qBAAqB;AAC3D,WAAK,aAAa,WAAW;AAC7B,WAAK,cAAc,QAAQ,iBAAiB,IAAI;AAAA,IAClD;AAAA,IAEA,MAAM,QAAQ,MAAc;AAC1B,YAAM,KAAK,aAAa,QAAQ,GAAG,IAAI;AAAA,IACzC;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -36,7 +36,7 @@ __export(Utils_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(Utils_exports);
38
38
  var import_decorators = require("../decorators");
39
- const SWC_NOT_FOUND = Symbol("SWC_NOT_FOUND");
39
+ const SWC_NOT_FOUND = Symbol.for("simple-web-component:not-found");
40
40
  const htmlFragment = (html, doc) => {
41
41
  const d = doc || (typeof document !== "undefined" ? document : void 0);
42
42
  if (!d) throw new Error("Document is not available");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/Utils.ts"],
4
- "sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\n\nexport const SWC_NOT_FOUND = Symbol('SWC_NOT_FOUND');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {\n if ((el as any).__swc_host) return (el as any).__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHosts = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHost(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHosts(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHost(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n const hosts = getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const isSwc = !!getElementConfig(el);\n const ancestors = findAllSwcHosts(el); // [root, ..., parent]\n\n let $host: HTMLElement;\n let $parentHost: HTMLElement | null;\n\n if (isSwc) {\n $host = el;\n $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n } else {\n $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;\n $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n }\n\n const $hosts = isSwc ? [...ancestors, el] : ancestors;\n const $firstHost = $hosts.length > 0 ? $hosts[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = $hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAExB,MAAM,gBAAgB,OAAO,eAAe;AAG5C,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,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O,CAAC,IAAI;AAGnD,UAAM,cAAmC,CAAC;AAC1C,QAAI,OAAY;AAChB,UAAM,SAAS,GAAG,eAAe;AACjC,WAAO,QAAQ,SAAS,QAAQ;AAC9B,UAAI,KAAK,oBAAoB;AAC3B,eAAO,OAAO,aAAa,KAAK,kBAAkB;AAAA,MACpD;AACA,aAAO,KAAK,iBAAkB,KAAK,YAAY,EAAU;AAAA,IAC3D;AAEA,UAAM,YAAY,OAAO,OAAO,OAAK,EAAE,QAAQ,YAAY,MAAM,aAAa,EAAE,aAAa,IAAI,GAAG,WAAW,UAAU,CAAC;AAC1H,UAAM,WAAW,UAAU,SAAS,IAAK,UAAU,UAAU,SAAS,CAAC,MAAM,KAAM,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,CAAC,IAAI,OAAQ,UAAU,UAAU,SAAS,CAAC,IAAK;AACvL,UAAM,gBAAgB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAAA,GArIe;",
4
+ "sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\n\nexport const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {\n if ((el as any).__swc_host) return (el as any).__swc_host;\n // if ((el as any).__swc_proto_setup) return (el as any).__swc_proto_setup;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHosts = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHost(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHosts(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHost(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n const hosts = getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const isSwc = !!getElementConfig(el);\n const ancestors = findAllSwcHosts(el); // [root, ..., parent]\n\n let $host: HTMLElement;\n let $parentHost: HTMLElement | null;\n\n if (isSwc) {\n $host = el;\n $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n } else {\n $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;\n $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n }\n\n const $hosts = isSwc ? [...ancestors, el] : ancestors;\n const $firstHost = $hosts.length > 0 ? $hosts[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = $hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAExB,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAGjE,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,QAAM,WAAW,EAAE,cAAc,UAAU;AAC3C,WAAS,YAAY,KAAK,KAAK;AAC/B,SAAO,SAAS;AAClB;AAEO,MAAM,WAAW,CAAC,MAAoB,QAAyB;AACpE,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,eAAe,SAAS,UAAa,SAAS,OAAO,OAAO,IAA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Q,YAAY,MAAM,aAAa,EAAE,aAAa,IAAI,GAAG,WAAW,UAAU,CAAC;AAC1H,UAAM,WAAW,UAAU,SAAS,IAAK,UAAU,UAAU,SAAS,CAAC,MAAM,KAAM,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,CAAC,IAAI,OAAQ,UAAU,UAAU,SAAS,CAAC,IAAK;AACvL,UAAM,gBAAgB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAAA,GAtIe;",
6
6
  "names": ["SwcUtils"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import { ReflectUtils } from "@dooboostore/core";
2
- const ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:add-event-listener");
2
+ const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
3
3
  function addEventListener(selectorOrTarget, type, options = {}) {
4
4
  return (targetObj, propertyKey, descriptor) => {
5
5
  const constructor = targetObj.constructor;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/addEventListener.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n\n/**\n * @addEventListenerHost decorator - simplified version of @addEventListener for :host selector\n * Usage: @addEventListenerHost('click')\n * Usage: @addEventListenerHost('click', { stopPropagation: true })\n */\nexport function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener(':host', type, options);\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAqBtB,MAAM,kCAAkC,OAAO,yCAAyC;AAOxF,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,aAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,mBAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,kBAAkB,MAAM,QAAQ,CAAC;AAAA,EAC3E;AACF;AAEO,MAAM,8BAA8B,CAAC,WAAwD;AAClG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,iCAAiC,WAAW;AAC9E;AAOO,SAAS,qBAAqB,MAAc,SAA0E;AAC3H,SAAO,iBAAiB,SAAS,MAAM,OAAO;AAChD;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n\n/**\n * @addEventListenerHost decorator - simplified version of @addEventListener for :host selector\n * Usage: @addEventListenerHost('click')\n * Usage: @addEventListenerHost('click', { stopPropagation: true })\n */\nexport function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener(':host', type, options);\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAqBtB,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAO5F,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,aAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,mBAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,kBAAkB,MAAM,QAAQ,CAAC;AAAA,EAC3E;AACF;AAEO,MAAM,8BAA8B,CAAC,WAAwD;AAClG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,iCAAiC,WAAW;AAC9E;AAOO,SAAS,qBAAqB,MAAc,SAA0E;AAC3H,SAAO,iBAAiB,SAAS,MAAM,OAAO;AAChD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,129 @@
1
+ import { ReflectUtils } from "@dooboostore/core";
2
+ import { ensureInit } from "./elementDefine.js";
3
+ import { SwcUtils } from "../utils/Utils.js";
4
+ const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
5
+ function createAttributeDecorator(action) {
6
+ return (selector, nameOrOptions, options = {}) => {
7
+ return (target, propertyKey, descriptor) => {
8
+ const constructor = target.constructor;
9
+ let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
10
+ if (!metaList) {
11
+ metaList = /* @__PURE__ */ new Map();
12
+ ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
13
+ }
14
+ let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
15
+ let finalOptions = options;
16
+ if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
17
+ finalOptions = nameOrOptions;
18
+ }
19
+ metaList.set(propertyKey, {
20
+ propertyKey,
21
+ selector,
22
+ action,
23
+ options: { ...finalOptions, name: attributeName }
24
+ });
25
+ const original = descriptor.value;
26
+ descriptor.value = async function(...args) {
27
+ ensureInit(this);
28
+ const res = await original.apply(this, args);
29
+ if (res !== void 0) {
30
+ const win = this.ownerDocument?.defaultView || window;
31
+ const host = this;
32
+ const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
33
+ const r = finalOptions.root || "auto";
34
+ const targetEls = [];
35
+ const applyRoot = (t) => {
36
+ if (!t || !(t instanceof win.HTMLElement)) return;
37
+ targetEls.push(t);
38
+ };
39
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
40
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
41
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
42
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
43
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
44
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
45
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
46
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
47
+ else if (selector === ":host" || !selector) applyRoot(host);
48
+ else {
49
+ const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
50
+ if (targetRoot) {
51
+ const found = targetRoot.querySelectorAll(selector);
52
+ if (found) targetEls.push(...Array.from(found));
53
+ }
54
+ }
55
+ targetEls.forEach((targetEl) => {
56
+ const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
57
+ if (action === "set" || action === "update") {
58
+ if (attributeName) {
59
+ if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
60
+ targetEl.removeAttribute(attributeName);
61
+ } else {
62
+ targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
63
+ }
64
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
65
+ Object.entries(resolvedRes).forEach(([attr, val]) => {
66
+ const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
67
+ if (finalVal === null || finalVal === void 0 || finalVal === false) {
68
+ targetEl.removeAttribute(attr);
69
+ } else {
70
+ targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
71
+ }
72
+ });
73
+ }
74
+ } else if (action === "remove") {
75
+ if (attributeName) {
76
+ targetEl.removeAttribute(attributeName);
77
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
78
+ Object.entries(resolvedRes).forEach(([attr, val]) => {
79
+ const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
80
+ if (shouldRemove) targetEl.removeAttribute(attr);
81
+ });
82
+ } else {
83
+ const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
84
+ attrs.forEach((a) => targetEl.removeAttribute(String(a)));
85
+ }
86
+ }
87
+ });
88
+ }
89
+ return res;
90
+ };
91
+ return descriptor;
92
+ };
93
+ };
94
+ }
95
+ function applyAttribute(selector, action = "update", options = {}) {
96
+ return createAttributeDecorator(action)(selector, options);
97
+ }
98
+ const setAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("set")(selector, nameOrOptions, options);
99
+ const updateAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("update")(selector, nameOrOptions, options);
100
+ const removeAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("remove")(selector, nameOrOptions, options);
101
+ function applyAttributeHost(action = "update", options = {}) {
102
+ return createAttributeDecorator(action)(":host", options);
103
+ }
104
+ const setAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("set")(":host", nameOrOptions, options);
105
+ const updateAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("update")(":host", nameOrOptions, options);
106
+ const removeAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("remove")(":host", nameOrOptions, options);
107
+ const findAllAttributeApplyMetadata = (target) => {
108
+ const result = /* @__PURE__ */ new Map();
109
+ const maps = ReflectUtils.findAllMetadata(ATTRIBUTE_APPLY_METADATA_KEY, target);
110
+ maps.forEach((map) => {
111
+ if (map instanceof Map) {
112
+ map.forEach((v, k) => result.set(k, v));
113
+ }
114
+ });
115
+ return result;
116
+ };
117
+ export {
118
+ ATTRIBUTE_APPLY_METADATA_KEY,
119
+ applyAttribute,
120
+ applyAttributeHost,
121
+ findAllAttributeApplyMetadata,
122
+ removeAttribute,
123
+ removeAttributeHost,
124
+ setAttribute,
125
+ setAttributeHost,
126
+ updateAttribute,
127
+ updateAttributeHost
128
+ };
129
+ //# sourceMappingURL=applyAttribute.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/applyAttribute.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type AttributeAction = 'set' | 'update' | 'remove';\n\nexport interface AttributeApplyOptions extends SwcQueryOptions {\n name?: string;\n}\n\nexport interface AttributeApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: AttributeAction;\n options: AttributeApplyOptions;\n}\n\nexport const ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for('simple-web-component:attribute-apply');\n\nfunction createAttributeDecorator(action: AttributeAction) {\n return (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor) as Map<string | symbol, AttributeApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AttributeApplyMetadata>();\n ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);\n }\n\n let attributeName = typeof nameOrOptions === 'string' ? nameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof nameOrOptions === 'object' && nameOrOptions !== null) {\n finalOptions = nameOrOptions as AttributeApplyOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n action, \n options: { ...finalOptions, name: attributeName } \n });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await (original as any).apply(this, args);\n if (res !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(host);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n const resolvedRes = typeof res === 'function' ? (res as any)(targetEl, hostSet) : res;\n\n if (action === 'set' || action === 'update') {\n if (attributeName) {\n // Case: @setAttribute(selector, 'name')\n if (resolvedRes === null || resolvedRes === undefined || resolvedRes === false) {\n targetEl.removeAttribute(attributeName);\n } else {\n targetEl.setAttribute(attributeName, resolvedRes === true ? '' : String(resolvedRes));\n }\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @applyAttribute(selector) with Object return\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined || finalVal === false) {\n targetEl.removeAttribute(attr);\n } else {\n targetEl.setAttribute(attr, finalVal === true ? '' : String(finalVal));\n }\n });\n }\n } else if (action === 'remove') {\n if (attributeName) {\n targetEl.removeAttribute(attributeName);\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([attr, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) targetEl.removeAttribute(attr);\n });\n } else {\n const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n attrs.forEach(a => targetEl.removeAttribute(String(a)));\n }\n }\n });\n }\n return res;\n };\n return descriptor;\n };\n };\n}\n\nexport function applyAttribute(selector: string, action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)(selector, options);\n}\n\nexport const setAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(selector, nameOrOptions, options);\nexport const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);\nexport const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);\n\n// Host versions\nexport function applyAttributeHost(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {\n return createAttributeDecorator(action)(':host', options);\n}\nexport const setAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(':host', nameOrOptions, options);\nexport const updateAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(':host', nameOrOptions, options);\nexport const removeAttributeHost = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(':host', nameOrOptions, options);\n\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {\n const result = new Map<string | symbol, AttributeApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AttributeApplyMetadata>>(ATTRIBUTE_APPLY_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAgBlB,MAAM,+BAA+B,OAAO,IAAI,sCAAsC;AAE7F,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,UAAkB,eAAgD,UAAiC,CAAC,MAAuB;AACjI,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,aAAa,eAAe,8BAA8B,WAAW;AACpF,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAA6C;AAC5D,qBAAa,eAAe,8BAA8B,UAAU,WAAW;AAAA,MACjF;AAEA,UAAI,gBAAgB,OAAO,kBAAkB,WAAW,gBAAgB;AACxE,UAAI,eAAe;AAEnB,UAAI,OAAO,kBAAkB,YAAY,kBAAkB,MA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F,CAAC;AACD,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,145 @@
1
+ import { ReflectUtils } from "@dooboostore/core";
2
+ import { ensureInit } from "./elementDefine.js";
3
+ import { SwcUtils } from "../utils/Utils.js";
4
+ const CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
5
+ function createClassDecorator(action) {
6
+ return (selector, classMapOrOptions, options = {}) => {
7
+ return (target, propertyKey, descriptor) => {
8
+ const constructor = target.constructor;
9
+ let metaList = ReflectUtils.getOwnMetadata(CLASS_METADATA_KEY, constructor);
10
+ if (!metaList) {
11
+ metaList = /* @__PURE__ */ new Map();
12
+ ReflectUtils.defineMetadata(CLASS_METADATA_KEY, metaList, constructor);
13
+ }
14
+ let classMap = void 0;
15
+ let finalOptions = options;
16
+ if (typeof classMapOrOptions === "string" || typeof classMapOrOptions === "object" && classMapOrOptions !== null && !("root" in classMapOrOptions)) {
17
+ classMap = classMapOrOptions;
18
+ } else if (typeof classMapOrOptions === "object" && classMapOrOptions !== null && "root" in classMapOrOptions) {
19
+ finalOptions = classMapOrOptions;
20
+ }
21
+ metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
22
+ const original = descriptor.value;
23
+ descriptor.value = async function(...args) {
24
+ ensureInit(this);
25
+ const res = await original.apply(this, args);
26
+ if (res !== void 0) {
27
+ const win = this.ownerDocument?.defaultView || window;
28
+ const host = this;
29
+ const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
30
+ const r = finalOptions.root || "auto";
31
+ const targetEls = [];
32
+ const applyRoot = (t) => {
33
+ if (!t || !(t instanceof win.HTMLElement)) return;
34
+ targetEls.push(t);
35
+ };
36
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
37
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
38
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
39
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
40
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
41
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
42
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
43
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
44
+ else if (selector === ":host" || !selector) applyRoot(host);
45
+ else {
46
+ const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
47
+ if (targetRoot) {
48
+ const found = targetRoot.querySelectorAll(selector);
49
+ if (found) targetEls.push(...Array.from(found));
50
+ }
51
+ }
52
+ targetEls.forEach((targetEl) => {
53
+ const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
54
+ if (action === "set") {
55
+ let classes = "";
56
+ if (classMap && typeof classMap === "string") {
57
+ classes = resolvedRes ? classMap : "";
58
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
59
+ classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
60
+ } else {
61
+ classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
62
+ }
63
+ targetEl.className = classes;
64
+ } else if (action === "update" || action === "toggle") {
65
+ if (classMap && typeof classMap === "string") {
66
+ targetEl.classList.toggle(classMap, !!resolvedRes);
67
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
68
+ Object.entries(resolvedRes).forEach(([cls, force]) => {
69
+ const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
70
+ targetEl.classList.toggle(cls, isActive);
71
+ });
72
+ } else {
73
+ const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
74
+ if (action === "update") targetEl.classList.add(...classes);
75
+ else classes.forEach((c) => targetEl.classList.toggle(c));
76
+ }
77
+ } else if (action === "add" || action === "remove") {
78
+ if (classMap && typeof classMap === "string" && !!resolvedRes) {
79
+ if (action === "add") targetEl.classList.add(classMap);
80
+ else targetEl.classList.remove(classMap);
81
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
82
+ Object.entries(resolvedRes).forEach(([cls, force]) => {
83
+ const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
84
+ if (shouldExecute) {
85
+ if (action === "add") targetEl.classList.add(cls);
86
+ else targetEl.classList.remove(cls);
87
+ }
88
+ });
89
+ } else {
90
+ const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
91
+ if (action === "add") targetEl.classList.add(...classes);
92
+ else targetEl.classList.remove(...classes);
93
+ }
94
+ }
95
+ });
96
+ }
97
+ return res;
98
+ };
99
+ return descriptor;
100
+ };
101
+ };
102
+ }
103
+ function applyClass(selector, action = "update", options = {}) {
104
+ return createClassDecorator(action)(selector, options);
105
+ }
106
+ const setClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("set")(selector, classMapOrOptions, options);
107
+ const updateClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("update")(selector, classMapOrOptions, options);
108
+ const addClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("add")(selector, classMapOrOptions, options);
109
+ const removeClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("remove")(selector, classMapOrOptions, options);
110
+ const toggleClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("toggle")(selector, classMapOrOptions, options);
111
+ function applyClassHost(action = "update", options = {}) {
112
+ return createClassDecorator(action)(":host", options);
113
+ }
114
+ const setClassHost = (classMapOrOptions, options = {}) => createClassDecorator("set")(":host", classMapOrOptions, options);
115
+ const updateClassHost = (classMapOrOptions, options = {}) => createClassDecorator("update")(":host", classMapOrOptions, options);
116
+ const addClassHost = (classMapOrOptions, options = {}) => createClassDecorator("add")(":host", classMapOrOptions, options);
117
+ const removeClassHost = (classMapOrOptions, options = {}) => createClassDecorator("remove")(":host", classMapOrOptions, options);
118
+ const toggleClassHost = (classMapOrOptions, options = {}) => createClassDecorator("toggle")(":host", classMapOrOptions, options);
119
+ const findAllClassMetadata = (target) => {
120
+ const result = /* @__PURE__ */ new Map();
121
+ const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
122
+ maps.forEach((map) => {
123
+ if (map instanceof Map) {
124
+ map.forEach((v, k) => result.set(k, v));
125
+ }
126
+ });
127
+ return result;
128
+ };
129
+ export {
130
+ CLASS_METADATA_KEY,
131
+ addClass,
132
+ addClassHost,
133
+ applyClass,
134
+ applyClassHost,
135
+ findAllClassMetadata,
136
+ removeClass,
137
+ removeClassHost,
138
+ setClass,
139
+ setClassHost,
140
+ toggleClass,
141
+ toggleClassHost,
142
+ updateClass,
143
+ updateClassHost
144
+ };
145
+ //# sourceMappingURL=applyClass.js.map