@v-ibe/core 0.1.0

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 (250) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -0
  3. package/dist/DI/__tests__/scoped-container-dependencies.test.d.ts +1 -0
  4. package/dist/DI/bootstrap.d.ts +18 -0
  5. package/dist/DI/decorators/inject.d.ts +37 -0
  6. package/dist/DI/decorators/inject.js +45 -0
  7. package/dist/DI/decorators/service.d.ts +24 -0
  8. package/dist/DI/decorators/service.js +13 -0
  9. package/dist/DI/di-container.d.ts +53 -0
  10. package/dist/DI/di-container.js +158 -0
  11. package/dist/DI/lifecycle.d.ts +37 -0
  12. package/dist/DI/lifecycle.js +6 -0
  13. package/dist/DI/scoped-container.d.ts +68 -0
  14. package/dist/DI/scoped-container.js +193 -0
  15. package/dist/DI/service-metadata.d.ts +32 -0
  16. package/dist/DI/service-metadata.js +31 -0
  17. package/dist/DI/types.d.ts +4 -0
  18. package/dist/behaviors/__tests__/behavior-system.test.d.ts +1 -0
  19. package/dist/behaviors/behavior-manager.d.ts +60 -0
  20. package/dist/behaviors/behavior-manager.js +131 -0
  21. package/dist/behaviors/behavior-registry.d.ts +68 -0
  22. package/dist/behaviors/behavior-registry.js +105 -0
  23. package/dist/behaviors/constants.d.ts +16 -0
  24. package/dist/behaviors/constants.js +8 -0
  25. package/dist/behaviors/decorators.d.ts +87 -0
  26. package/dist/behaviors/decorators.js +46 -0
  27. package/dist/behaviors/index.d.ts +4 -0
  28. package/dist/components/__tests__/host.test.d.ts +1 -0
  29. package/dist/components/app-tree.d.ts +49 -0
  30. package/dist/components/app-tree.js +122 -0
  31. package/dist/components/base-component.d.ts +85 -0
  32. package/dist/components/base-component.js +438 -0
  33. package/dist/components/decorators/component.d.ts +27 -0
  34. package/dist/components/decorators/component.js +47 -0
  35. package/dist/components/decorators/prop.d.ts +14 -0
  36. package/dist/components/decorators/prop.js +37 -0
  37. package/dist/components/types.d.ts +26 -0
  38. package/dist/core.d.ts +23 -0
  39. package/dist/core.js +8 -0
  40. package/dist/custom-components/__tests__/for.test.d.ts +1 -0
  41. package/dist/custom-components/__tests__/show.test.d.ts +1 -0
  42. package/dist/custom-components/for.d.ts +58 -0
  43. package/dist/custom-components/for.js +313 -0
  44. package/dist/custom-components/index.d.ts +2 -0
  45. package/dist/custom-components/show.d.ts +78 -0
  46. package/dist/custom-components/show.js +88 -0
  47. package/dist/data-management/cache/cache-invalidate.decorator.d.ts +35 -0
  48. package/dist/data-management/cache/cache-invalidate.decorator.js +21 -0
  49. package/dist/data-management/cache/cache-metadata.d.ts +15 -0
  50. package/dist/data-management/cache/cache-provider.interface.d.ts +67 -0
  51. package/dist/data-management/cache/cache-tags.decorator.d.ts +52 -0
  52. package/dist/data-management/cache/cache-tags.decorator.js +13 -0
  53. package/dist/data-management/cache/cache-update.decorator.d.ts +28 -0
  54. package/dist/data-management/cache/cache-update.decorator.js +21 -0
  55. package/dist/data-management/cache/cache.decorator.d.ts +28 -0
  56. package/dist/data-management/cache/cache.decorator.js +13 -0
  57. package/dist/data-management/cache/index.d.ts +11 -0
  58. package/dist/data-management/cache/local-storage-cache.d.ts +40 -0
  59. package/dist/data-management/cache/local-storage-cache.js +268 -0
  60. package/dist/data-management/cache/memory-cache.d.ts +37 -0
  61. package/dist/data-management/cache/memory-cache.js +149 -0
  62. package/dist/data-management/cache/session-storage-cache.d.ts +35 -0
  63. package/dist/data-management/cache/session-storage-cache.js +242 -0
  64. package/dist/data-management/cache/ttl.decorator.d.ts +31 -0
  65. package/dist/data-management/cache/ttl.decorator.js +34 -0
  66. package/dist/data-management/decorators/consume.d.ts +29 -0
  67. package/dist/data-management/decorators/consume.js +28 -0
  68. package/dist/data-management/decorators/id.d.ts +28 -0
  69. package/dist/data-management/decorators/id.js +19 -0
  70. package/dist/data-management/decorators/model.d.ts +48 -0
  71. package/dist/data-management/decorators/model.js +24 -0
  72. package/dist/data-management/decorators/prop.d.ts +43 -0
  73. package/dist/data-management/decorators/prop.js +32 -0
  74. package/dist/data-management/index.d.ts +13 -0
  75. package/dist/data-management/store/json-to-model.d.ts +45 -0
  76. package/dist/data-management/store/json-to-model.js +36 -0
  77. package/dist/data-management/store/store.d.ts +108 -0
  78. package/dist/data-management/store/store.js +207 -0
  79. package/dist/data-management/store/types.d.ts +53 -0
  80. package/dist/events-handler/decorators/emit.d.ts +29 -0
  81. package/dist/events-handler/decorators/emit.js +51 -0
  82. package/dist/events-handler/event-decorators.d.ts +1 -0
  83. package/dist/events-handler/event-emitter.service.d.ts +21 -0
  84. package/dist/events-handler/event-emitter.service.js +85 -0
  85. package/dist/events-handler/event-types.d.ts +12 -0
  86. package/dist/index.d.ts +55 -0
  87. package/dist/index.js +121 -0
  88. package/dist/jsx/dynamic/__tests__/granular-array-renderer.test.d.ts +1 -0
  89. package/dist/jsx/dynamic/__tests__/jsx-array-rendering.test.d.ts +1 -0
  90. package/dist/jsx/dynamic/array-renderer.d.ts +2 -0
  91. package/dist/jsx/dynamic/array-renderer.js +133 -0
  92. package/dist/jsx/dynamic/child-renderer.d.ts +1 -0
  93. package/dist/jsx/dynamic/child-renderer.js +180 -0
  94. package/dist/jsx/dynamic/dom-utils.d.ts +5 -0
  95. package/dist/jsx/dynamic/dom-utils.js +22 -0
  96. package/dist/jsx/dynamic/granular-array-renderer.d.ts +16 -0
  97. package/dist/jsx/dynamic/granular-array-renderer.js +153 -0
  98. package/dist/jsx/dynamic/node-renderer.d.ts +2 -0
  99. package/dist/jsx/dynamic/props-handler.d.ts +3 -0
  100. package/dist/jsx/dynamic/props-handler.js +281 -0
  101. package/dist/jsx/dynamic/text-renderer.d.ts +2 -0
  102. package/dist/jsx/jsx-dev-runtime.d.ts +2 -0
  103. package/dist/jsx/jsx-runtime.d.ts +3 -0
  104. package/dist/jsx/types.d.ts +35 -0
  105. package/dist/jsx/types.js +4 -0
  106. package/dist/jsx-dev-runtime.d.ts +2 -0
  107. package/dist/jsx-dev-runtime.js +8 -0
  108. package/dist/jsx-runtime.d.ts +2 -0
  109. package/dist/jsx-runtime.js +11 -0
  110. package/dist/reactivity/__tests__/context-stack.test.d.ts +1 -0
  111. package/dist/reactivity/__tests__/nested-effects-untrack.test.d.ts +22 -0
  112. package/dist/reactivity/context-scope.d.ts +57 -0
  113. package/dist/reactivity/context-scope.js +35 -0
  114. package/dist/reactivity/decorators/__tests__/ctx-integration.test.d.ts +5 -0
  115. package/dist/reactivity/decorators/__tests__/ctx-loop.test.d.ts +10 -0
  116. package/dist/reactivity/decorators/__tests__/state-intelligent.test.d.ts +1 -0
  117. package/dist/reactivity/decorators/computed.d.ts +6 -0
  118. package/dist/reactivity/decorators/computed.js +17 -0
  119. package/dist/reactivity/decorators/create-event-decorator.d.ts +5 -0
  120. package/dist/reactivity/decorators/create-event-decorator.js +28 -0
  121. package/dist/reactivity/decorators/ctx.d.ts +9 -0
  122. package/dist/reactivity/decorators/ctx.js +91 -0
  123. package/dist/reactivity/decorators/effect.d.ts +9 -0
  124. package/dist/reactivity/decorators/effect.js +24 -0
  125. package/dist/reactivity/decorators/resource.d.ts +48 -0
  126. package/dist/reactivity/decorators/resource.js +20 -0
  127. package/dist/reactivity/decorators/state.d.ts +8 -0
  128. package/dist/reactivity/decorators/state.js +68 -0
  129. package/dist/reactivity/decorators/store.d.ts +6 -0
  130. package/dist/reactivity/decorators/store.js +25 -0
  131. package/dist/reactivity/phase-scheduler.d.ts +81 -0
  132. package/dist/reactivity/phase-scheduler.js +88 -0
  133. package/dist/reactivity/phase-scheduler.test.d.ts +1 -0
  134. package/dist/reactivity/reactive-cache.d.ts +21 -0
  135. package/dist/reactivity/reactive-cache.js +31 -0
  136. package/dist/reactivity/reactive-cache.test.d.ts +1 -0
  137. package/dist/reactivity/reactive-context.d.ts +152 -0
  138. package/dist/reactivity/reactive-context.js +184 -0
  139. package/dist/reactivity/signals/__tests__/composicion-automatica.test.d.ts +1 -0
  140. package/dist/reactivity/signals/__tests__/composite/nivel-1-estructura-basica.test.d.ts +1 -0
  141. package/dist/reactivity/signals/__tests__/composite/nivel-2-registro-subscribers.test.d.ts +1 -0
  142. package/dist/reactivity/signals/__tests__/composite/nivel-3-notificaciones-basicas.test.d.ts +1 -0
  143. package/dist/reactivity/signals/__tests__/composite/nivel-4-comparacion-valores.test.d.ts +1 -0
  144. package/dist/reactivity/signals/__tests__/composite/nivel-5-tracking-automatico.test.d.ts +1 -0
  145. package/dist/reactivity/signals/__tests__/composite/nivel-6-anti-glitch.test.d.ts +1 -0
  146. package/dist/reactivity/signals/__tests__/composite/nivel-7-objetos-anidados.test.d.ts +1 -0
  147. package/dist/reactivity/signals/__tests__/composite/nivel-8-observable-array-support.test.d.ts +1 -0
  148. package/dist/reactivity/signals/__tests__/composite-shallow-tracking.test.d.ts +1 -0
  149. package/dist/reactivity/signals/__tests__/effect.test.d.ts +1 -0
  150. package/dist/reactivity/signals/__tests__/reactive-array/nivel-1-estructura-basica.test.d.ts +1 -0
  151. package/dist/reactivity/signals/__tests__/reactive-array/nivel-2-metodos-mutadores.test.d.ts +1 -0
  152. package/dist/reactivity/signals/__tests__/reactive-array/nivel-3-tracking-por-indice.test.d.ts +1 -0
  153. package/dist/reactivity/signals/__tests__/reactive-array/nivel-4-tracking-length.test.d.ts +1 -0
  154. package/dist/reactivity/signals/__tests__/reactive-array/nivel-5-tracking-mutation.test.d.ts +1 -0
  155. package/dist/reactivity/signals/__tests__/reactive-array/nivel-6-metodos-no-mutadores.test.d.ts +1 -0
  156. package/dist/reactivity/signals/__tests__/reactive-array/nivel-7-composicion-bidireccional.test.d.ts +1 -0
  157. package/dist/reactivity/signals/__tests__/reactive-array/nivel-8-proxies.test.d.ts +1 -0
  158. package/dist/reactivity/signals/__tests__/reactive-array/nivel-9-derived-cache-optimization.test.d.ts +1 -0
  159. package/dist/reactivity/signals/__tests__/resource.test.d.ts +1 -0
  160. package/dist/reactivity/signals/__tests__/signal.test.d.ts +1 -0
  161. package/dist/reactivity/signals/array-strategies.d.ts +120 -0
  162. package/dist/reactivity/signals/array-strategies.js +261 -0
  163. package/dist/reactivity/signals/composite.d.ts +89 -0
  164. package/dist/reactivity/signals/composite.js +145 -0
  165. package/dist/reactivity/signals/computed.d.ts +61 -0
  166. package/dist/reactivity/signals/computed.js +107 -0
  167. package/dist/reactivity/signals/computed.test.d.ts +1 -0
  168. package/dist/reactivity/signals/derived.d.ts +10 -0
  169. package/dist/reactivity/signals/derived.js +24 -0
  170. package/dist/reactivity/signals/effect.d.ts +27 -0
  171. package/dist/reactivity/signals/effect.js +46 -0
  172. package/dist/reactivity/signals/event.d.ts +9 -0
  173. package/dist/reactivity/signals/event.js +15 -0
  174. package/dist/reactivity/signals/reactive-array.d.ts +133 -0
  175. package/dist/reactivity/signals/reactive-array.js +490 -0
  176. package/dist/reactivity/signals/reactive-proxy.d.ts +54 -0
  177. package/dist/reactivity/signals/reactive-proxy.js +299 -0
  178. package/dist/reactivity/signals/reactive-tracking.test.d.ts +1 -0
  179. package/dist/reactivity/signals/resource.d.ts +9 -0
  180. package/dist/reactivity/signals/resource.js +58 -0
  181. package/dist/reactivity/signals/signal.d.ts +39 -0
  182. package/dist/reactivity/signals/signal.js +56 -0
  183. package/dist/reactivity/signals/subscription-management.test.d.ts +1 -0
  184. package/dist/reactivity/types.d.ts +12 -0
  185. package/dist/router/__tests__/link-behavior-active-class.test.d.ts +1 -0
  186. package/dist/router/__tests__/loop-detector.test.d.ts +1 -0
  187. package/dist/router/__tests__/params-container-resolution.test.d.ts +1 -0
  188. package/dist/router/__tests__/router-generated-routes.test.d.ts +1 -0
  189. package/dist/router/__tests__/router-params-granular.test.d.ts +1 -0
  190. package/dist/router/__tests__/router-params-simple.test.d.ts +1 -0
  191. package/dist/router/__tests__/router-query-params.test.d.ts +1 -0
  192. package/dist/router/__tests__/router-route-candidates.test.d.ts +1 -0
  193. package/dist/router/__tests__/routeview-app-articles.test.d.ts +1 -0
  194. package/dist/router/__tests__/routeview-debug.test.d.ts +1 -0
  195. package/dist/router/__tests__/routeview-integration.test.d.ts +1 -0
  196. package/dist/router/__tests__/routeview-this.test.d.ts +1 -0
  197. package/dist/router/decorators/base-policy.d.ts +141 -0
  198. package/dist/router/decorators/base-policy.js +63 -0
  199. package/dist/router/decorators/index.d.ts +6 -0
  200. package/dist/router/decorators/params.d.ts +31 -0
  201. package/dist/router/decorators/params.js +97 -0
  202. package/dist/router/decorators/route-metadata.d.ts +11 -0
  203. package/dist/router/decorators/route-metadata.js +23 -0
  204. package/dist/router/decorators/route.d.ts +39 -0
  205. package/dist/router/decorators/route.js +7 -0
  206. package/dist/router/link.behavior.d.ts +87 -0
  207. package/dist/router/link.behavior.js +227 -0
  208. package/dist/router/policy-evaluator.d.ts +81 -0
  209. package/dist/router/policy-evaluator.js +209 -0
  210. package/dist/router/route-view.d.ts +56 -0
  211. package/dist/router/route-view.js +156 -0
  212. package/dist/router/router.d.ts +67 -0
  213. package/dist/router/router.js +308 -0
  214. package/dist/router/static-analysis/index.d.ts +37 -0
  215. package/dist/router/static-analysis/parser.d.ts +14 -0
  216. package/dist/router/static-analysis/parser.js +147 -0
  217. package/dist/router/static-analysis/scanner.d.ts +27 -0
  218. package/dist/router/static-analysis/scanner.js +91 -0
  219. package/dist/router/trie.d.ts +14 -0
  220. package/dist/router/trie.js +126 -0
  221. package/dist/router/trie.types.d.ts +36 -0
  222. package/dist/styles/base-style-sheet.d.ts +96 -0
  223. package/dist/styles/base-style-sheet.js +149 -0
  224. package/dist/styles/decorators/factories.d.ts +76 -0
  225. package/dist/styles/decorators/factories.js +11 -0
  226. package/dist/styles/decorators/keyframes.d.ts +238 -0
  227. package/dist/styles/decorators/keyframes.js +79 -0
  228. package/dist/styles/decorators/rule.d.ts +177 -0
  229. package/dist/styles/decorators/rule.js +72 -0
  230. package/dist/styles/decorators/scope.d.ts +66 -0
  231. package/dist/styles/decorators/scope.js +17 -0
  232. package/dist/styles/decorators/style.d.ts +1 -0
  233. package/dist/styles/decorators/style.js +20 -0
  234. package/dist/styles/decorators/useStyles.d.ts +5 -0
  235. package/dist/styles/decorators/useStyles.js +29 -0
  236. package/dist/styles/global-styles-registry.d.ts +72 -0
  237. package/dist/styles/global-styles-registry.js +155 -0
  238. package/dist/types.d.ts +1 -0
  239. package/dist/vite-plugins/__tests__/jsx-control-flow-transform.test.d.ts +1 -0
  240. package/dist/vite-plugins/index.d.ts +4 -0
  241. package/dist/vite-plugins/index.js +10 -0
  242. package/dist/vite-plugins/jsx-contextual.d.ts +7 -0
  243. package/dist/vite-plugins/jsx-contextual.js +53 -0
  244. package/dist/vite-plugins/jsx-control-flow-transform.d.ts +60 -0
  245. package/dist/vite-plugins/jsx-control-flow-transform.js +180 -0
  246. package/dist/vite-plugins/jsx-signals.d.ts +2 -0
  247. package/dist/vite-plugins/jsx-signals.js +124 -0
  248. package/dist/vite-plugins/router/route-generator-plugin.d.ts +63 -0
  249. package/dist/vite-plugins/router/route-generator-plugin.js +310 -0
  250. package/package.json +85 -0
@@ -0,0 +1,29 @@
1
+ function UseStyles(StylesConstructor) {
2
+ return function(target, context) {
3
+ if (context.kind !== "class") {
4
+ throw new Error(
5
+ "@UseStyles solo puede aplicarse a clases de componentes."
6
+ );
7
+ }
8
+ return class extends target {
9
+ constructor(...args) {
10
+ super(...args);
11
+ try {
12
+ const stylesInstance = new StylesConstructor();
13
+ stylesInstance.setHost(this);
14
+ Object.defineProperty(this, "styles", {
15
+ value: stylesInstance,
16
+ writable: false,
17
+ enumerable: true,
18
+ configurable: false
19
+ });
20
+ } catch (error) {
21
+ console.error("❌ [UseStyles] Error inicializando estilos:", error);
22
+ }
23
+ }
24
+ };
25
+ };
26
+ }
27
+ export {
28
+ UseStyles
29
+ };
@@ -0,0 +1,72 @@
1
+ import { BaseComponent } from '../components/base-component';
2
+ import { Constructor } from '../components/types';
3
+ declare class GlobalStylesheetsRegistry {
4
+ /**
5
+ * Array de estilos @Shared para shadow roots.
6
+ * El orden es importante: las primeras en el array son las primeras
7
+ * en aplicarse (menor especificidad en la cascada CSS).
8
+ */
9
+ private sharedEntries;
10
+ /**
11
+ * Array de estilos @ForDocument para el documento.
12
+ */
13
+ private documentEntries;
14
+ /**
15
+ * NUEVO: Registra estilos @Shared (para shadow roots).
16
+ * Este método es llamado cuando un componente con estilos @Shared se inicializa.
17
+ *
18
+ * @param styleClasses Array de clases decoradas con @Shared
19
+ * @param ownerComponent El componente que está registrando estos estilos
20
+ * @returns Array de símbolos que identifican cada registro
21
+ */
22
+ registerShared(styleClasses: Constructor<any>[], ownerComponent: BaseComponent): symbol[];
23
+ /**
24
+ * NUEVO: Registra estilos @ForDocument (para el documento real).
25
+ *
26
+ * @param styleClasses Array de clases decoradas con @ForDocument
27
+ * @param ownerComponent El componente que está registrando estos estilos
28
+ * @returns Array de símbolos que identifican cada registro
29
+ */
30
+ registerDocument(styleClasses: Constructor<any>[], ownerComponent: BaseComponent): symbol[];
31
+ /**
32
+ * Método universal de registro que categoriza automáticamente por scope.
33
+ *
34
+ * @param styleClasses Array de clases de estilos (pueden tener diferentes scopes)
35
+ * @param ownerComponent El componente que está registrando estos estilos
36
+ * @returns Array de símbolos que identifican cada registro
37
+ */
38
+ register(styleClasses: Constructor<any>[], ownerComponent: BaseComponent): symbol[];
39
+ /**
40
+ * Elimina estilos globales registrados por un componente.
41
+ *
42
+ * @param ids Array de símbolos que identifican qué registros eliminar
43
+ */
44
+ unregister(ids: symbol[]): void;
45
+ /**
46
+ * Alias para unregister - mantiene compatibilidad con código antiguo
47
+ */
48
+ unregisterDocumentStyles(ids: symbol[]): void;
49
+ /**
50
+ * Obtiene todas las stylesheets @Shared activas.
51
+ * Este método es llamado por cada componente para adoptar estilos compartidos.
52
+ *
53
+ * @returns Array de CSSStyleSheet instances listas para ser adoptadas
54
+ */
55
+ getSharedStylesheets(): CSSStyleSheet[];
56
+ /**
57
+ * DEPRECATED: Usa getSharedStylesheets() en su lugar.
58
+ * Mantenido por compatibilidad temporal.
59
+ */
60
+ getStylesheets(): CSSStyleSheet[];
61
+ /**
62
+ * Información de debug para desarrollo.
63
+ */
64
+ getDebugInfo(): {
65
+ sharedCount: number;
66
+ documentCount: number;
67
+ sharedOwners: string[];
68
+ documentOwners: string[];
69
+ };
70
+ }
71
+ export declare const globalStylesheets: GlobalStylesheetsRegistry;
72
+ export {};
@@ -0,0 +1,155 @@
1
+ import { getStyleScope } from "./decorators/scope.js";
2
+ class GlobalStylesheetsRegistry {
3
+ constructor() {
4
+ this.sharedEntries = [];
5
+ this.documentEntries = [];
6
+ }
7
+ /**
8
+ * NUEVO: Registra estilos @Shared (para shadow roots).
9
+ * Este método es llamado cuando un componente con estilos @Shared se inicializa.
10
+ *
11
+ * @param styleClasses Array de clases decoradas con @Shared
12
+ * @param ownerComponent El componente que está registrando estos estilos
13
+ * @returns Array de símbolos que identifican cada registro
14
+ */
15
+ registerShared(styleClasses, ownerComponent) {
16
+ const registeredIds = [];
17
+ for (const StyleClass of styleClasses) {
18
+ const styleInstance = new StyleClass();
19
+ styleInstance.setHost(ownerComponent);
20
+ const stylesheet = styleInstance.getStyleSheet();
21
+ const id = Symbol(`shared-stylesheet-${StyleClass.name}`);
22
+ const entry = {
23
+ stylesheet,
24
+ ownerComponent,
25
+ styleClass: StyleClass,
26
+ id,
27
+ styleInstance
28
+ };
29
+ this.sharedEntries.push(entry);
30
+ registeredIds.push(id);
31
+ }
32
+ return registeredIds;
33
+ }
34
+ /**
35
+ * NUEVO: Registra estilos @ForDocument (para el documento real).
36
+ *
37
+ * @param styleClasses Array de clases decoradas con @ForDocument
38
+ * @param ownerComponent El componente que está registrando estos estilos
39
+ * @returns Array de símbolos que identifican cada registro
40
+ */
41
+ registerDocument(styleClasses, ownerComponent) {
42
+ const registeredIds = [];
43
+ for (const StyleClass of styleClasses) {
44
+ const styleInstance = new StyleClass();
45
+ styleInstance.setHost(ownerComponent);
46
+ styleInstance.applyToDocument();
47
+ const id = Symbol(`document-stylesheet-${StyleClass.name}`);
48
+ const entry = {
49
+ styleInstance,
50
+ ownerComponent,
51
+ styleClass: StyleClass,
52
+ id
53
+ };
54
+ this.documentEntries.push(entry);
55
+ registeredIds.push(id);
56
+ }
57
+ return registeredIds;
58
+ }
59
+ /**
60
+ * Método universal de registro que categoriza automáticamente por scope.
61
+ *
62
+ * @param styleClasses Array de clases de estilos (pueden tener diferentes scopes)
63
+ * @param ownerComponent El componente que está registrando estos estilos
64
+ * @returns Array de símbolos que identifican cada registro
65
+ */
66
+ register(styleClasses, ownerComponent) {
67
+ const categorized = {
68
+ shared: [],
69
+ document: []
70
+ };
71
+ for (const StyleClass of styleClasses) {
72
+ const scope = getStyleScope(StyleClass);
73
+ if (scope === "shared") {
74
+ categorized.shared.push(StyleClass);
75
+ } else if (scope === "document") {
76
+ categorized.document.push(StyleClass);
77
+ } else {
78
+ console.warn(
79
+ `[GlobalStyles] ⚠️ ${StyleClass.name} no tiene decorador @Shared ni @ForDocument. Los estilos globales deben usar uno de estos decoradores.`
80
+ );
81
+ }
82
+ }
83
+ const ids = [];
84
+ if (categorized.shared.length > 0) {
85
+ ids.push(...this.registerShared(categorized.shared, ownerComponent));
86
+ }
87
+ if (categorized.document.length > 0) {
88
+ ids.push(...this.registerDocument(categorized.document, ownerComponent));
89
+ }
90
+ return ids;
91
+ }
92
+ /**
93
+ * Elimina estilos globales registrados por un componente.
94
+ *
95
+ * @param ids Array de símbolos que identifican qué registros eliminar
96
+ */
97
+ unregister(ids) {
98
+ for (const id of ids) {
99
+ const sharedIndex = this.sharedEntries.findIndex((entry) => entry.id === id);
100
+ if (sharedIndex !== -1) {
101
+ const entry = this.sharedEntries[sharedIndex];
102
+ if (entry.styleInstance && typeof entry.styleInstance.dispose === "function") {
103
+ entry.styleInstance.dispose();
104
+ }
105
+ this.sharedEntries.splice(sharedIndex, 1);
106
+ continue;
107
+ }
108
+ const docIndex = this.documentEntries.findIndex((entry) => entry.id === id);
109
+ if (docIndex !== -1) {
110
+ const entry = this.documentEntries[docIndex];
111
+ if (entry.styleInstance && typeof entry.styleInstance.dispose === "function") {
112
+ entry.styleInstance.dispose();
113
+ }
114
+ this.documentEntries.splice(docIndex, 1);
115
+ }
116
+ }
117
+ }
118
+ /**
119
+ * Alias para unregister - mantiene compatibilidad con código antiguo
120
+ */
121
+ unregisterDocumentStyles(ids) {
122
+ this.unregister(ids);
123
+ }
124
+ /**
125
+ * Obtiene todas las stylesheets @Shared activas.
126
+ * Este método es llamado por cada componente para adoptar estilos compartidos.
127
+ *
128
+ * @returns Array de CSSStyleSheet instances listas para ser adoptadas
129
+ */
130
+ getSharedStylesheets() {
131
+ return this.sharedEntries.map((entry) => entry.stylesheet);
132
+ }
133
+ /**
134
+ * DEPRECATED: Usa getSharedStylesheets() en su lugar.
135
+ * Mantenido por compatibilidad temporal.
136
+ */
137
+ getStylesheets() {
138
+ return this.getSharedStylesheets();
139
+ }
140
+ /**
141
+ * Información de debug para desarrollo.
142
+ */
143
+ getDebugInfo() {
144
+ return {
145
+ sharedCount: this.sharedEntries.length,
146
+ documentCount: this.documentEntries.length,
147
+ sharedOwners: this.sharedEntries.map((e) => e.ownerComponent.constructor.name),
148
+ documentOwners: this.documentEntries.map((e) => e.ownerComponent.constructor.name)
149
+ };
150
+ }
151
+ }
152
+ const globalStylesheets = new GlobalStylesheetsRegistry();
153
+ export {
154
+ globalStylesheets
155
+ };
@@ -0,0 +1 @@
1
+ type Constructor<T = {}> = new (...args: any[]) => T;
@@ -0,0 +1,4 @@
1
+ export { jsxContextualPlugin } from './jsx-contextual';
2
+ export { jsxControlFlowPlugin } from './jsx-control-flow-transform';
3
+ export { jsxSignalsPlugin } from './jsx-signals';
4
+ export { routeGeneratorPlugin, type RouteGeneratorPluginOptions } from './router/route-generator-plugin';
@@ -0,0 +1,10 @@
1
+ import { jsxContextualPlugin } from "./jsx-contextual.js";
2
+ import { jsxControlFlowPlugin } from "./jsx-control-flow-transform.js";
3
+ import { jsxSignalsPlugin } from "./jsx-signals.js";
4
+ import { routeGeneratorPlugin } from "./router/route-generator-plugin.js";
5
+ export {
6
+ jsxContextualPlugin,
7
+ jsxControlFlowPlugin,
8
+ jsxSignalsPlugin,
9
+ routeGeneratorPlugin
10
+ };
@@ -0,0 +1,7 @@
1
+ import { Plugin } from 'vite';
2
+ /**
3
+ * Transforma TODAS las llamadas a `jsx`, `jsxs`, `jsxDEV`
4
+ * en `this.jsx`, `this.jsxs`, `this.jsxDEV`
5
+ * incluso si están anidadas.
6
+ */
7
+ export declare function jsxContextualPlugin(): Plugin;
@@ -0,0 +1,53 @@
1
+ import ts__default from "typescript";
2
+ function jsxContextualPlugin() {
3
+ return {
4
+ name: "vite-plugin-jsx-contextual",
5
+ enforce: "post",
6
+ // Run AFTER esbuild transforms JSX
7
+ transform(code, id) {
8
+ if (!id.endsWith(".tsx") && !id.endsWith(".jsx")) return;
9
+ const sourceFile = ts__default.createSourceFile(
10
+ id,
11
+ code,
12
+ ts__default.ScriptTarget.Latest,
13
+ true,
14
+ ts__default.ScriptKind.TSX
15
+ );
16
+ const transformerFactory = (context) => {
17
+ const visitor = (node) => {
18
+ if (ts__default.isCallExpression(node)) {
19
+ if (ts__default.isIdentifier(node.expression) && ["jsx", "jsxs", "jsxDEV"].includes(node.expression.text)) {
20
+ const newExpr = ts__default.factory.createPropertyAccessExpression(
21
+ ts__default.factory.createThis(),
22
+ ts__default.factory.createIdentifier(node.expression.text)
23
+ );
24
+ const newArgs = node.arguments.map(
25
+ (arg) => ts__default.visitNode(arg, visitor)
26
+ );
27
+ return ts__default.factory.updateCallExpression(
28
+ node,
29
+ newExpr,
30
+ node.typeArguments,
31
+ newArgs
32
+ );
33
+ }
34
+ }
35
+ return ts__default.visitEachChild(node, visitor, context);
36
+ };
37
+ return (sf) => ts__default.visitEachChild(sf, visitor, context);
38
+ };
39
+ const result = ts__default.transform(sourceFile, [transformerFactory]);
40
+ const transformed = result.transformed[0];
41
+ const printer = ts__default.createPrinter({ newLine: ts__default.NewLineKind.LineFeed });
42
+ const newCode = printer.printFile(transformed);
43
+ result.dispose();
44
+ return {
45
+ code: newCode,
46
+ map: null
47
+ };
48
+ }
49
+ };
50
+ }
51
+ export {
52
+ jsxContextualPlugin
53
+ };
@@ -0,0 +1,60 @@
1
+ import { Plugin } from 'vite';
2
+ export declare function jsxControlFlowPlugin(): Plugin;
3
+ /**
4
+ * EJEMPLO DE TRANSFORMACIÓN
5
+ *
6
+ * INPUT:
7
+ * ```tsx
8
+ * <For each={this.items}>
9
+ * {(item, index) => (
10
+ * <div key={item.id}>{item.name}</div>
11
+ * )}
12
+ * </For>
13
+ * ```
14
+ *
15
+ * OUTPUT:
16
+ * ```tsx
17
+ * For({
18
+ * each: this.items,
19
+ * children: (item, index) => (
20
+ * <div key={item.id}>{item.name}</div>
21
+ * )
22
+ * })
23
+ * ```
24
+ *
25
+ * ---
26
+ *
27
+ * INPUT:
28
+ * ```tsx
29
+ * <Show when={this.isVisible} fallback={<Loading />}>
30
+ * <Content />
31
+ * </Show>
32
+ * ```
33
+ *
34
+ * OUTPUT:
35
+ * ```tsx
36
+ * Show({
37
+ * when: this.isVisible,
38
+ * fallback: <Loading />,
39
+ * children: <Content />
40
+ * })
41
+ * ```
42
+ *
43
+ * ---
44
+ *
45
+ * INPUT:
46
+ * ```tsx
47
+ * <For each={[]} fallback={<p>Empty</p>}>
48
+ * {(item) => <div>{item}</div>}
49
+ * </For>
50
+ * ```
51
+ *
52
+ * OUTPUT:
53
+ * ```tsx
54
+ * For({
55
+ * each: [],
56
+ * fallback: <p>Empty</p>,
57
+ * children: (item) => <div>{item}</div>
58
+ * })
59
+ * ```
60
+ */
@@ -0,0 +1,180 @@
1
+ import ts__default from "typescript";
2
+ const CONTROL_FLOW_COMPONENTS = /* @__PURE__ */ new Set([
3
+ "For",
4
+ "ForEach",
5
+ "IndexFor",
6
+ "Show",
7
+ "Switch"
8
+ ]);
9
+ function jsxControlFlowPlugin() {
10
+ return {
11
+ name: "jsx-control-flow-transform",
12
+ enforce: "pre",
13
+ // Debe ejecutarse ANTES del transform de React/JSX
14
+ transform(code, id) {
15
+ if (!id.endsWith(".tsx") && !id.endsWith(".jsx")) {
16
+ return null;
17
+ }
18
+ const hasControlFlow = Array.from(CONTROL_FLOW_COMPONENTS).some(
19
+ (name) => {
20
+ const regex = new RegExp(`<${name}(?:\\s|>|/)`, "g");
21
+ return regex.test(code);
22
+ }
23
+ );
24
+ if (!hasControlFlow) {
25
+ return null;
26
+ }
27
+ const sourceFile = ts__default.createSourceFile(
28
+ id,
29
+ code,
30
+ ts__default.ScriptTarget.Latest,
31
+ true,
32
+ ts__default.ScriptKind.TSX
33
+ );
34
+ const transformer = (context) => {
35
+ const visit = (node) => {
36
+ if (ts__default.isJsxElement(node) || ts__default.isJsxSelfClosingElement(node)) {
37
+ const tagName = getJsxTagName(node);
38
+ if (CONTROL_FLOW_COMPONENTS.has(tagName)) {
39
+ const functionCall = transformControlFlowToFunctionCall(node);
40
+ if (isInsideJsx(node)) {
41
+ return ts__default.factory.createJsxExpression(void 0, functionCall);
42
+ }
43
+ return functionCall;
44
+ }
45
+ }
46
+ return ts__default.visitEachChild(node, visit, context);
47
+ };
48
+ return (sf) => ts__default.visitNode(sf, visit);
49
+ };
50
+ const result = ts__default.transform(sourceFile, [transformer]);
51
+ const transformedFile = result.transformed[0];
52
+ const printer = ts__default.createPrinter({
53
+ newLine: ts__default.NewLineKind.LineFeed,
54
+ removeComments: false
55
+ });
56
+ const newCode = printer.printFile(transformedFile);
57
+ result.dispose();
58
+ return {
59
+ code: newCode,
60
+ map: null
61
+ };
62
+ }
63
+ };
64
+ }
65
+ function isInsideJsx(node) {
66
+ let parent = node.parent;
67
+ if (parent && ts__default.isJsxElement(parent)) {
68
+ return true;
69
+ }
70
+ while (parent) {
71
+ if (ts__default.isJsxElement(parent) || ts__default.isJsxFragment(parent)) {
72
+ return true;
73
+ }
74
+ parent = parent.parent;
75
+ }
76
+ return false;
77
+ }
78
+ function getJsxTagName(node) {
79
+ if (ts__default.isJsxElement(node)) {
80
+ const openingElement = node.openingElement;
81
+ const tagNameNode = openingElement.tagName;
82
+ if (ts__default.isIdentifier(tagNameNode)) {
83
+ return tagNameNode.text;
84
+ }
85
+ } else if (ts__default.isJsxSelfClosingElement(node)) {
86
+ const tagNameNode = node.tagName;
87
+ if (ts__default.isIdentifier(tagNameNode)) {
88
+ return tagNameNode.text;
89
+ }
90
+ }
91
+ return "";
92
+ }
93
+ function transformControlFlowToFunctionCall(node, context) {
94
+ const tagName = getJsxTagName(node);
95
+ const attributes = ts__default.isJsxElement(node) ? node.openingElement.attributes : node.attributes;
96
+ let childrenExpression;
97
+ if (ts__default.isJsxElement(node)) {
98
+ const children = node.children;
99
+ if (children.length > 0) {
100
+ const validChildren = children.filter(
101
+ (child) => !ts__default.isJsxText(child) || child.text.trim().length > 0
102
+ );
103
+ if (validChildren.length === 1) {
104
+ const child = validChildren[0];
105
+ if (ts__default.isJsxExpression(child) && child.expression) {
106
+ childrenExpression = child.expression;
107
+ } else if (ts__default.isJsxElement(child) || ts__default.isJsxSelfClosingElement(child)) {
108
+ childrenExpression = child;
109
+ } else if (ts__default.isJsxText(child)) {
110
+ childrenExpression = ts__default.factory.createStringLiteral(child.text.trim());
111
+ }
112
+ } else if (validChildren.length > 1) {
113
+ const childElements = validChildren.map((child) => {
114
+ if (ts__default.isJsxExpression(child) && child.expression) {
115
+ return child.expression;
116
+ }
117
+ if (ts__default.isJsxElement(child) || ts__default.isJsxSelfClosingElement(child)) {
118
+ return child;
119
+ }
120
+ if (ts__default.isJsxText(child)) {
121
+ return ts__default.factory.createStringLiteral(child.text.trim());
122
+ }
123
+ return ts__default.factory.createNull();
124
+ });
125
+ childrenExpression = ts__default.factory.createArrayLiteralExpression(
126
+ childElements,
127
+ false
128
+ );
129
+ }
130
+ }
131
+ }
132
+ const propsProperties = [];
133
+ attributes.properties.forEach((prop) => {
134
+ if (ts__default.isJsxAttribute(prop)) {
135
+ const propName = ts__default.isIdentifier(prop.name) ? prop.name.text : prop.name.getText();
136
+ let propValue;
137
+ if (prop.initializer) {
138
+ if (ts__default.isJsxExpression(prop.initializer) && prop.initializer.expression) {
139
+ propValue = prop.initializer.expression;
140
+ } else if (ts__default.isStringLiteral(prop.initializer)) {
141
+ propValue = prop.initializer;
142
+ } else {
143
+ propValue = ts__default.factory.createTrue();
144
+ }
145
+ } else {
146
+ propValue = ts__default.factory.createTrue();
147
+ }
148
+ propsProperties.push(
149
+ ts__default.factory.createPropertyAssignment(
150
+ ts__default.factory.createIdentifier(propName),
151
+ propValue
152
+ )
153
+ );
154
+ }
155
+ });
156
+ if (childrenExpression) {
157
+ propsProperties.push(
158
+ ts__default.factory.createPropertyAssignment(
159
+ ts__default.factory.createIdentifier("children"),
160
+ childrenExpression
161
+ )
162
+ );
163
+ }
164
+ const propsObject = ts__default.factory.createObjectLiteralExpression(
165
+ propsProperties,
166
+ true
167
+ );
168
+ const functionCall = ts__default.factory.createCallExpression(
169
+ ts__default.factory.createIdentifier(tagName),
170
+ // Function name
171
+ void 0,
172
+ // Type arguments
173
+ [propsObject]
174
+ // Arguments
175
+ );
176
+ return functionCall;
177
+ }
178
+ export {
179
+ jsxControlFlowPlugin
180
+ };
@@ -0,0 +1,2 @@
1
+ import { Plugin } from 'vite';
2
+ export declare function jsxSignalsPlugin(): Plugin;