@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,126 @@
1
+ import { Service } from "../DI/decorators/service.js";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
6
+ var __typeError = (msg) => {
7
+ throw TypeError(msg);
8
+ };
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ var __decoratorStart = (base) => [, , , __create(null)];
12
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
13
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
14
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
15
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
16
+ var __runInitializers = (array, flags, self, value) => {
17
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) fns[i].call(self);
18
+ return value;
19
+ };
20
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
21
+ var it, done, ctx, k = flags & 7, p = false;
22
+ var j = 0;
23
+ var extraInitializers = array[j] || (array[j] = []);
24
+ var desc = k && (target = target.prototype, k < 5 && (k > 3 || !p) && __getOwnPropDesc(target, name));
25
+ __name(target, name);
26
+ for (var i = decorators.length - 1; i >= 0; i--) {
27
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
28
+ it = (0, decorators[i])(target, ctx), done._ = 1;
29
+ __expectFn(it) && (target = it);
30
+ }
31
+ return __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
32
+ };
33
+ var _Trie_decorators, _init;
34
+ _Trie_decorators = [Service];
35
+ class Trie {
36
+ constructor() {
37
+ this.root = this.createNode();
38
+ this._maxDepth = 0;
39
+ }
40
+ // 'insert' ahora acepta un id, loader, metadata, policies y slot.
41
+ insert(id, path, loader, metadata, policies, slot) {
42
+ const segments = path.split("/").filter(Boolean);
43
+ let currentNode = this.root;
44
+ this._maxDepth = Math.max(this._maxDepth, segments.length + 1);
45
+ for (const segment of segments) {
46
+ if (segment.startsWith(":")) {
47
+ const paramName = segment.slice(1);
48
+ if (!currentNode.dynamicChild) {
49
+ currentNode.dynamicChild = this.createNode();
50
+ currentNode.dynamicChild.paramName = paramName;
51
+ }
52
+ currentNode = currentNode.dynamicChild;
53
+ } else {
54
+ if (!currentNode.staticChildren.has(segment)) {
55
+ currentNode.staticChildren.set(segment, this.createNode());
56
+ }
57
+ currentNode = currentNode.staticChildren.get(segment);
58
+ }
59
+ }
60
+ const candidate = {
61
+ id,
62
+ // UUID único de la ruta
63
+ path,
64
+ // Guardar el path original de la ruta
65
+ loader,
66
+ metadata,
67
+ policies,
68
+ slot
69
+ };
70
+ if (!currentNode.candidates) {
71
+ currentNode.candidates = [];
72
+ }
73
+ currentNode.candidates.push(candidate);
74
+ }
75
+ find(path) {
76
+ const segments = path.split("/").filter(Boolean);
77
+ const params = {};
78
+ const candidatesByLevel = [];
79
+ let currentNode = this.root;
80
+ if (currentNode.candidates && currentNode.candidates.length > 0) {
81
+ candidatesByLevel.push([...currentNode.candidates]);
82
+ }
83
+ if (segments.length === 0) {
84
+ if (candidatesByLevel.length > 0) {
85
+ return { candidatesByLevel, params };
86
+ }
87
+ return null;
88
+ }
89
+ for (const segment of segments) {
90
+ if (currentNode.staticChildren.has(segment)) {
91
+ currentNode = currentNode.staticChildren.get(segment);
92
+ } else if (currentNode.dynamicChild) {
93
+ currentNode = currentNode.dynamicChild;
94
+ params[currentNode.paramName] = segment;
95
+ } else {
96
+ return null;
97
+ }
98
+ if (currentNode.candidates && currentNode.candidates.length > 0) {
99
+ candidatesByLevel.push([...currentNode.candidates]);
100
+ }
101
+ }
102
+ if (candidatesByLevel.length > 0) {
103
+ return {
104
+ candidatesByLevel,
105
+ params
106
+ };
107
+ }
108
+ return null;
109
+ }
110
+ /**
111
+ * Retorna la profundidad máxima de rutas registradas en el Trie
112
+ * @returns Número de niveles (0 = solo root, 1 = un segmento, etc.)
113
+ */
114
+ get maxDepth() {
115
+ return this._maxDepth;
116
+ }
117
+ createNode() {
118
+ return { staticChildren: /* @__PURE__ */ new Map() };
119
+ }
120
+ }
121
+ _init = __decoratorStart();
122
+ Trie = __decorateElement(_init, 0, "Trie", _Trie_decorators, Trie);
123
+ __runInitializers(_init, 1, Trie);
124
+ export {
125
+ Trie
126
+ };
@@ -0,0 +1,36 @@
1
+ import { Constructor } from '../DI/types';
2
+ /**
3
+ * Representa un candidato de ruta (un componente con su configuración)
4
+ */
5
+ export interface RouteCandidate {
6
+ /** ID único de la ruta (UUID generado en build time) */
7
+ id: string;
8
+ /** Path original de la ruta (ej: '/store/:storeId') */
9
+ path: string;
10
+ loader: (signal?: AbortSignal) => Promise<any>;
11
+ metadata?: Record<string, any>;
12
+ policies?: Constructor<any>[];
13
+ /** Nombre del slot donde se renderizará este componente (@main, @sidebar, etc.) */
14
+ slot?: string;
15
+ }
16
+ export interface RouteNode {
17
+ /** Hijos con rutas estáticas. La clave es el segmento de la ruta (ej: 'users'). */
18
+ staticChildren: Map<string, RouteNode>;
19
+ /** Nodo hijo para rutas dinámicas (ej: ':id'). Solo puede haber uno por nivel. */
20
+ dynamicChild?: RouteNode;
21
+ /** Nodo hijo para rutas wildcard (ej: '*'). */
22
+ wildcardChild?: RouteNode;
23
+ /** Si el nodo es dinámico, almacena el nombre del parámetro (ej: 'id'). */
24
+ paramName?: string;
25
+ /** Array de candidatos para este nodo (múltiples componentes pueden compartir el mismo path) */
26
+ candidates?: RouteCandidate[];
27
+ }
28
+ /**
29
+ * Resultado de la búsqueda en el Trie.
30
+ * Los candidatos están agrupados por nivel de anidamiento.
31
+ */
32
+ export interface FindResult {
33
+ /** Candidatos agrupados por nivel: candidatesByLevel[0] = candidatos del nivel raíz, etc. */
34
+ candidatesByLevel: RouteCandidate[][];
35
+ params: Record<string, string>;
36
+ }
@@ -0,0 +1,96 @@
1
+ import { BaseComponent } from '../components/base-component';
2
+ /**
3
+ * BaseStyleSheet - Core styling system for the framework
4
+ *
5
+ * This class provides reactive CSS styling for components using the @Rule decorator.
6
+ * It manages a CSSStyleSheet internally and supports both Shadow DOM and document-level styles.
7
+ *
8
+ * Usage with @Rule decorator:
9
+ * ```typescript
10
+ * class MyStyles extends BaseStyleSheet {
11
+ * @State width = 100;
12
+ *
13
+ * @Rule(':host')
14
+ * get hostStyles() {
15
+ * return {
16
+ * display: 'grid',
17
+ * width: this.width, // Reactive!
18
+ * };
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export declare class BaseStyleSheet {
24
+ protected stylesheet: CSSStyleSheet;
25
+ protected ruleIndexMap: Map<string, number>;
26
+ protected cleanupFunctions: (() => void)[];
27
+ protected selectorSymbolMap: Map<string, symbol>;
28
+ protected documentStyleElement: HTMLStyleElement | null;
29
+ protected documentRuleMap: Map<string, {
30
+ index: number;
31
+ effect: any;
32
+ }>;
33
+ constructor();
34
+ /**
35
+ * Returns the internal CSSStyleSheet
36
+ * Used by @UseStyles decorator to attach styles to components
37
+ */
38
+ getStyleSheet(): CSSStyleSheet;
39
+ /**
40
+ * Sets the host component and initializes styles
41
+ * Called by @UseStyles decorator when attaching styles to a component
42
+ */
43
+ setHost(component: BaseComponent): void;
44
+ /**
45
+ * Applies styles to the document (<head>) instead of Shadow DOM
46
+ * Used by @ForDocument decorator for global styles
47
+ *
48
+ * Creates a <style> element and syncs reactive CSS rules to it
49
+ */
50
+ applyToDocument(): void;
51
+ /**
52
+ * Synchronizes the internal CSSStyleSheet with the document <style> element
53
+ * Called automatically when rules update in @ForDocument mode
54
+ */
55
+ private syncDocumentStyles;
56
+ /**
57
+ * Updates a specific CSS rule in the stylesheet
58
+ * This is the core method used by @Rule decorator to update reactive styles
59
+ *
60
+ * @param selector - The CSS selector for this rule
61
+ * @param cssText - The complete CSS rule text (including selector and braces)
62
+ * @param indexKey - Unique symbol to track this rule's position
63
+ */
64
+ protected updateSpecificRule(selector: string, cssText: string, indexKey: symbol): void;
65
+ /**
66
+ * Adjusts all rule indices after a rule deletion
67
+ * This ensures the index tracking remains correct
68
+ */
69
+ private adjustIndicesAfterDeletion;
70
+ /**
71
+ * Registers a cleanup function to be called on disposal
72
+ * Used by @Rule decorator to clean up reactive effects
73
+ */
74
+ registerCleanup(cleanupFn: () => void): void;
75
+ /**
76
+ * Cleans up all resources
77
+ * Called when the component is destroyed
78
+ */
79
+ dispose(): void;
80
+ /**
81
+ * Returns debug information about the stylesheet
82
+ * Useful for development and debugging
83
+ */
84
+ getDebugInfo(): {
85
+ totalRules: number;
86
+ ruleIndexMap: Map<string, number>;
87
+ };
88
+ /**
89
+ * Optional hook for subclasses to implement
90
+ * Called after setHost() to perform custom initialization
91
+ *
92
+ * Note: With @Rule decorator, this is typically not needed
93
+ * as decorators automatically register rules
94
+ */
95
+ protected styles(): void;
96
+ }
@@ -0,0 +1,149 @@
1
+ import { HOST_KEY } from "../behaviors/constants.js";
2
+ class BaseStyleSheet {
3
+ constructor() {
4
+ this.cleanupFunctions = [];
5
+ this.selectorSymbolMap = /* @__PURE__ */ new Map();
6
+ this.documentStyleElement = null;
7
+ this.documentRuleMap = /* @__PURE__ */ new Map();
8
+ this.stylesheet = new CSSStyleSheet();
9
+ this.ruleIndexMap = /* @__PURE__ */ new Map();
10
+ }
11
+ /**
12
+ * Returns the internal CSSStyleSheet
13
+ * Used by @UseStyles decorator to attach styles to components
14
+ */
15
+ getStyleSheet() {
16
+ return this.stylesheet;
17
+ }
18
+ /**
19
+ * Sets the host component and initializes styles
20
+ * Called by @UseStyles decorator when attaching styles to a component
21
+ */
22
+ setHost(component) {
23
+ const hostKey = this.constructor[HOST_KEY];
24
+ if (hostKey) {
25
+ this[hostKey] = component;
26
+ }
27
+ if (typeof this.styles === "function") {
28
+ this.styles();
29
+ }
30
+ }
31
+ /**
32
+ * Applies styles to the document (<head>) instead of Shadow DOM
33
+ * Used by @ForDocument decorator for global styles
34
+ *
35
+ * Creates a <style> element and syncs reactive CSS rules to it
36
+ */
37
+ applyToDocument() {
38
+ if (!this.documentStyleElement) {
39
+ this.documentStyleElement = document.createElement("style");
40
+ this.documentStyleElement.setAttribute("data-framework-document-styles", this.constructor.name);
41
+ document.head.appendChild(this.documentStyleElement);
42
+ }
43
+ this.syncDocumentStyles();
44
+ }
45
+ /**
46
+ * Synchronizes the internal CSSStyleSheet with the document <style> element
47
+ * Called automatically when rules update in @ForDocument mode
48
+ */
49
+ syncDocumentStyles() {
50
+ if (!this.documentStyleElement) return;
51
+ const cssText = Array.from(this.stylesheet.cssRules).map((rule) => rule.cssText).join("\n");
52
+ this.documentStyleElement.textContent = cssText;
53
+ }
54
+ /**
55
+ * Updates a specific CSS rule in the stylesheet
56
+ * This is the core method used by @Rule decorator to update reactive styles
57
+ *
58
+ * @param selector - The CSS selector for this rule
59
+ * @param cssText - The complete CSS rule text (including selector and braces)
60
+ * @param indexKey - Unique symbol to track this rule's position
61
+ */
62
+ updateSpecificRule(selector, cssText, indexKey) {
63
+ try {
64
+ const currentIndex = this[indexKey];
65
+ if (currentIndex !== void 0 && currentIndex < this.stylesheet.cssRules.length) {
66
+ this.stylesheet.deleteRule(currentIndex);
67
+ this.adjustIndicesAfterDeletion(currentIndex);
68
+ this.ruleIndexMap.delete(selector);
69
+ }
70
+ const newIndex = this.stylesheet.insertRule(
71
+ cssText,
72
+ this.stylesheet.cssRules.length
73
+ );
74
+ this[indexKey] = newIndex;
75
+ this.ruleIndexMap.set(selector, newIndex);
76
+ if (this.documentStyleElement) {
77
+ this.syncDocumentStyles();
78
+ }
79
+ } catch (error) {
80
+ console.error("Error updating rule:", error);
81
+ console.error("Problematic CSS:", cssText);
82
+ }
83
+ }
84
+ /**
85
+ * Adjusts all rule indices after a rule deletion
86
+ * This ensures the index tracking remains correct
87
+ */
88
+ adjustIndicesAfterDeletion(deletedIndex) {
89
+ for (const [selector, index] of this.ruleIndexMap.entries()) {
90
+ if (index > deletedIndex) {
91
+ this.ruleIndexMap.set(selector, index - 1);
92
+ }
93
+ }
94
+ const symbolKeys = Object.getOwnPropertySymbols(this);
95
+ for (const symbolKey of symbolKeys) {
96
+ const currentIndex = this[symbolKey];
97
+ if (typeof currentIndex === "number" && currentIndex > deletedIndex) {
98
+ this[symbolKey] = currentIndex - 1;
99
+ }
100
+ }
101
+ }
102
+ /**
103
+ * Registers a cleanup function to be called on disposal
104
+ * Used by @Rule decorator to clean up reactive effects
105
+ */
106
+ registerCleanup(cleanupFn) {
107
+ this.cleanupFunctions.push(cleanupFn);
108
+ }
109
+ /**
110
+ * Cleans up all resources
111
+ * Called when the component is destroyed
112
+ */
113
+ dispose() {
114
+ while (this.stylesheet.cssRules.length > 0) {
115
+ this.stylesheet.deleteRule(0);
116
+ }
117
+ if (this.documentStyleElement && this.documentStyleElement.parentNode) {
118
+ this.documentStyleElement.parentNode.removeChild(this.documentStyleElement);
119
+ this.documentStyleElement = null;
120
+ }
121
+ this.cleanupFunctions.forEach((cleanup) => cleanup());
122
+ this.cleanupFunctions.length = 0;
123
+ this.ruleIndexMap.clear();
124
+ this.selectorSymbolMap.clear();
125
+ this.documentRuleMap.clear();
126
+ }
127
+ /**
128
+ * Returns debug information about the stylesheet
129
+ * Useful for development and debugging
130
+ */
131
+ getDebugInfo() {
132
+ return {
133
+ totalRules: this.stylesheet.cssRules.length,
134
+ ruleIndexMap: new Map(this.ruleIndexMap)
135
+ };
136
+ }
137
+ /**
138
+ * Optional hook for subclasses to implement
139
+ * Called after setHost() to perform custom initialization
140
+ *
141
+ * Note: With @Rule decorator, this is typically not needed
142
+ * as decorators automatically register rules
143
+ */
144
+ styles() {
145
+ }
146
+ }
147
+ export {
148
+ BaseStyleSheet
149
+ };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Creates a decorator for custom DOM events
3
+ * @param eventName Custom event name
4
+ * @example const UserAction = CustomEvent('user-action');
5
+ * @UserAction userActionFired!: boolean;
6
+ */
7
+ declare const CustomEvent: (eventName: string) => () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
8
+ /**
9
+ * Creates a decorator that tracks if a specific element is in viewport
10
+ * @param selector CSS selector for the element to observe
11
+ * @example const HeaderVisible = ElementInView('.header');
12
+ * @HeaderVisible headerInView!: boolean;
13
+ */
14
+ declare const ElementInView: (selector: string) => () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
15
+ export declare const MediaQuery: (queryString: string) => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
16
+ export declare const WindowSize: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, {
17
+ width: number;
18
+ height: number;
19
+ }>) => (this: This, initialValue: {
20
+ width: number;
21
+ height: number;
22
+ }) => {
23
+ width: number;
24
+ height: number;
25
+ };
26
+ export declare const WindowWidth: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number>) => (this: This, initialValue: number) => number;
27
+ export declare const WindowHeight: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number>) => (this: This, initialValue: number) => number;
28
+ export declare const ScrollPosition: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number>) => (this: This, initialValue: number) => number;
29
+ export declare const ScrollXY: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, {
30
+ x: number;
31
+ y: number;
32
+ }>) => (this: This, initialValue: {
33
+ x: number;
34
+ y: number;
35
+ }) => {
36
+ x: number;
37
+ y: number;
38
+ };
39
+ export declare const NetworkStatus: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
40
+ export declare const DeviceOrientation: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, OrientationType>) => (this: This, initialValue: OrientationType) => OrientationType;
41
+ export declare const PageVisibility: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
42
+ export declare const ReducedMotion: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
43
+ export declare const DarkMode: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
44
+ export declare const MousePosition: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, {
45
+ x: number;
46
+ y: number;
47
+ }>) => (this: This, initialValue: {
48
+ x: number;
49
+ y: number;
50
+ }) => {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ export declare const MouseX: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number>) => (this: This, initialValue: number) => number;
55
+ export declare const MouseY: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number>) => (this: This, initialValue: number) => number;
56
+ export declare const KeyPressed: (key: string) => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
57
+ export declare const ModifierKeys: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, {
58
+ ctrl: boolean;
59
+ shift: boolean;
60
+ alt: boolean;
61
+ meta: boolean;
62
+ }>) => (this: This, initialValue: {
63
+ ctrl: boolean;
64
+ shift: boolean;
65
+ alt: boolean;
66
+ meta: boolean;
67
+ }) => {
68
+ ctrl: boolean;
69
+ shift: boolean;
70
+ alt: boolean;
71
+ meta: boolean;
72
+ };
73
+ export declare const WindowFocus: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, boolean>) => (this: This, initialValue: boolean) => boolean;
74
+ export declare const TextSelection: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number | boolean>) => (this: This, initialValue: number | boolean) => number | boolean;
75
+ export declare const FrameRate: () => <This extends object>(target: undefined, context: ClassFieldDecoratorContext<This, number>) => (this: This, initialValue: number) => number;
76
+ export { CustomEvent, ElementInView };
@@ -0,0 +1,11 @@
1
+ import { createEventDecorator } from "../../reactivity/decorators/create-event-decorator.js";
2
+ import { eventListener } from "../../reactivity/signals/event.js";
3
+ const createMediaQuerySignal = (queryString) => eventListener(
4
+ window.matchMedia(queryString),
5
+ "change",
6
+ () => window.matchMedia(queryString).matches
7
+ );
8
+ const MediaQuery = createEventDecorator(createMediaQuerySignal);
9
+ export {
10
+ MediaQuery
11
+ };