@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,299 @@
1
+ import { CompositeSignal } from "./composite.js";
2
+ import { ReactiveArray } from "./reactive-array.js";
3
+ import { getOrCreateReactive } from "../reactive-cache.js";
4
+ const proxyCache = /* @__PURE__ */ new WeakMap();
5
+ function createObjectProxy(composite) {
6
+ if (proxyCache.has(composite)) {
7
+ return proxyCache.get(composite);
8
+ }
9
+ const proxy = new Proxy(composite, {
10
+ get(target, prop) {
11
+ if (prop === "__isReactive") return true;
12
+ if (prop === "__getCompositeSignal") return composite;
13
+ if (typeof prop === "symbol") {
14
+ return target[prop];
15
+ }
16
+ const value = composite.get(prop);
17
+ if (value instanceof CompositeSignal) {
18
+ return createObjectProxy(value);
19
+ }
20
+ if (value instanceof ReactiveArray) {
21
+ return createArrayProxy(value);
22
+ }
23
+ return value;
24
+ },
25
+ set(target, prop, value) {
26
+ if (typeof prop === "symbol") {
27
+ target[prop] = value;
28
+ return true;
29
+ }
30
+ const reactiveValue = getOrCreateReactive(value);
31
+ composite.set(prop, reactiveValue);
32
+ return true;
33
+ },
34
+ has(target, prop) {
35
+ if (prop === "__isReactive" || prop === "__getCompositeSignal") return true;
36
+ if (typeof prop === "symbol") return prop in target;
37
+ return composite.get(prop) !== void 0;
38
+ },
39
+ ownKeys(target) {
40
+ composite.trackShallow();
41
+ const plainValue = composite.getPlainValue();
42
+ return Reflect.ownKeys(plainValue);
43
+ },
44
+ getOwnPropertyDescriptor(target, prop) {
45
+ if (prop === "__isReactive" || prop === "__getCompositeSignal") {
46
+ return {
47
+ configurable: true,
48
+ enumerable: false,
49
+ value: prop === "__isReactive" ? true : composite,
50
+ writable: false
51
+ };
52
+ }
53
+ if (typeof prop === "symbol") {
54
+ return Object.getOwnPropertyDescriptor(target, prop);
55
+ }
56
+ const plainValue = composite.getPlainValue();
57
+ if (!(prop in plainValue)) return void 0;
58
+ return {
59
+ configurable: true,
60
+ enumerable: true,
61
+ writable: true,
62
+ value: this.get(target, prop, proxy)
63
+ };
64
+ },
65
+ deleteProperty(target, prop) {
66
+ if (typeof prop === "symbol") {
67
+ return delete target[prop];
68
+ }
69
+ const plainValue = composite.getPlainValue();
70
+ if (!(prop in plainValue)) {
71
+ return true;
72
+ }
73
+ const deleted = delete plainValue[prop];
74
+ if (deleted) {
75
+ composite.set(prop, void 0);
76
+ }
77
+ return deleted;
78
+ }
79
+ });
80
+ proxyCache.set(composite, proxy);
81
+ return proxy;
82
+ }
83
+ function createArrayProxy(reactiveArray) {
84
+ if (proxyCache.has(reactiveArray)) {
85
+ return proxyCache.get(reactiveArray);
86
+ }
87
+ const proxy = new Proxy(reactiveArray, {
88
+ get(target, prop) {
89
+ if (prop === "__isReactive") return true;
90
+ if (prop === "__getReactiveArray") return reactiveArray;
91
+ if (typeof prop === "symbol") {
92
+ if (prop === Symbol.iterator) {
93
+ const iterator = reactiveArray[Symbol.iterator]();
94
+ return function* () {
95
+ for (const value2 of iterator) {
96
+ if (value2 instanceof CompositeSignal) {
97
+ yield createObjectProxy(value2);
98
+ } else if (value2 instanceof ReactiveArray) {
99
+ yield createArrayProxy(value2);
100
+ } else {
101
+ yield value2;
102
+ }
103
+ }
104
+ };
105
+ }
106
+ const value = target[prop];
107
+ if (typeof value === "function") {
108
+ return value.bind(target);
109
+ }
110
+ return value;
111
+ }
112
+ if (prop === "length") {
113
+ return reactiveArray.length;
114
+ }
115
+ const methodNames = [
116
+ "push",
117
+ "pop",
118
+ "shift",
119
+ "unshift",
120
+ "splice",
121
+ "sort",
122
+ "reverse",
123
+ "fill",
124
+ "map",
125
+ "filter",
126
+ "reduce",
127
+ "reduceRight",
128
+ "find",
129
+ "findIndex",
130
+ "indexOf",
131
+ "lastIndexOf",
132
+ "some",
133
+ "every",
134
+ "forEach",
135
+ "slice",
136
+ "concat",
137
+ "join",
138
+ "includes",
139
+ "at",
140
+ "entries",
141
+ "keys",
142
+ "values"
143
+ ];
144
+ if (methodNames.includes(prop)) {
145
+ const method = target[prop];
146
+ if (typeof method === "function") {
147
+ return function(...args) {
148
+ const callbackMethods = ["map", "filter", "find", "findIndex", "some", "every", "forEach", "reduce", "reduceRight"];
149
+ if (callbackMethods.includes(prop) && typeof args[0] === "function") {
150
+ const originalCallback = args[0];
151
+ const wrappedCallback = function(...callbackArgs) {
152
+ const wrappedArgs = callbackArgs.map((arg, index2) => {
153
+ if (index2 === 0) {
154
+ if (arg instanceof CompositeSignal) {
155
+ return createObjectProxy(arg);
156
+ }
157
+ if (arg instanceof ReactiveArray) {
158
+ return createArrayProxy(arg);
159
+ }
160
+ }
161
+ return arg;
162
+ });
163
+ return originalCallback.apply(this, wrappedArgs);
164
+ };
165
+ args = [wrappedCallback, ...args.slice(1)];
166
+ }
167
+ const result = method.apply(target, args);
168
+ if (result instanceof ReactiveArray) {
169
+ return createArrayProxy(result);
170
+ }
171
+ if (Array.isArray(result)) {
172
+ return result.map((item) => {
173
+ if (item instanceof CompositeSignal) {
174
+ return createObjectProxy(item);
175
+ }
176
+ if (item instanceof ReactiveArray) {
177
+ return createArrayProxy(item);
178
+ }
179
+ return item;
180
+ });
181
+ }
182
+ if (result instanceof CompositeSignal) {
183
+ return createObjectProxy(result);
184
+ }
185
+ if (result instanceof ReactiveArray) {
186
+ return createArrayProxy(result);
187
+ }
188
+ return result;
189
+ };
190
+ }
191
+ }
192
+ const index = Number(prop);
193
+ if (!isNaN(index) && index >= 0 && Number.isInteger(index)) {
194
+ const value = reactiveArray.at(index);
195
+ if (value instanceof CompositeSignal) {
196
+ return createObjectProxy(value);
197
+ }
198
+ if (value instanceof ReactiveArray) {
199
+ return createArrayProxy(value);
200
+ }
201
+ return value;
202
+ }
203
+ return target[prop];
204
+ },
205
+ set(target, prop, value) {
206
+ if (typeof prop === "symbol") {
207
+ target[prop] = value;
208
+ return true;
209
+ }
210
+ if (prop === "length") {
211
+ const newLength = Number(value);
212
+ if (!isNaN(newLength) && newLength >= 0 && Number.isInteger(newLength)) {
213
+ const currentLength = reactiveArray.length;
214
+ if (newLength < currentLength) {
215
+ reactiveArray.splice(newLength, currentLength - newLength);
216
+ }
217
+ }
218
+ return true;
219
+ }
220
+ const index = Number(prop);
221
+ if (!isNaN(index) && index >= 0 && Number.isInteger(index)) {
222
+ const reactiveValue = getOrCreateReactive(value);
223
+ if (index < reactiveArray.length) {
224
+ reactiveArray.splice(index, 1, reactiveValue);
225
+ } else {
226
+ const currentLength = reactiveArray.length;
227
+ for (let i = currentLength; i < index; i++) {
228
+ reactiveArray.push(void 0);
229
+ }
230
+ reactiveArray.push(reactiveValue);
231
+ }
232
+ return true;
233
+ }
234
+ target[prop] = value;
235
+ return true;
236
+ },
237
+ has(target, prop) {
238
+ if (prop === "__isReactive" || prop === "__getReactiveArray") return true;
239
+ if (typeof prop === "symbol") return prop in target;
240
+ if (prop === "length") return true;
241
+ const index = Number(prop);
242
+ if (!isNaN(index) && index >= 0 && Number.isInteger(index)) {
243
+ return index < reactiveArray.length;
244
+ }
245
+ return prop in target;
246
+ },
247
+ ownKeys(target) {
248
+ const keys = ["length"];
249
+ for (let i = 0; i < reactiveArray.length; i++) {
250
+ keys.push(String(i));
251
+ }
252
+ return keys;
253
+ },
254
+ getOwnPropertyDescriptor(target, prop) {
255
+ if (prop === "__isReactive" || prop === "__getReactiveArray") {
256
+ return {
257
+ configurable: true,
258
+ enumerable: false,
259
+ value: prop === "__isReactive" ? true : reactiveArray,
260
+ writable: false
261
+ };
262
+ }
263
+ if (prop === "length") {
264
+ return {
265
+ configurable: true,
266
+ enumerable: false,
267
+ writable: true,
268
+ value: reactiveArray.length
269
+ };
270
+ }
271
+ const index = Number(prop);
272
+ if (!isNaN(index) && index >= 0 && Number.isInteger(index) && index < reactiveArray.length) {
273
+ return {
274
+ configurable: true,
275
+ enumerable: true,
276
+ writable: true,
277
+ value: this.get(target, prop, proxy)
278
+ };
279
+ }
280
+ return Object.getOwnPropertyDescriptor(target, prop);
281
+ }
282
+ });
283
+ proxyCache.set(reactiveArray, proxy);
284
+ return proxy;
285
+ }
286
+ function createStore(initialState) {
287
+ if (Array.isArray(initialState)) {
288
+ const reactiveArray = new ReactiveArray(initialState);
289
+ return createArrayProxy(reactiveArray);
290
+ } else {
291
+ const composite = new CompositeSignal(initialState);
292
+ return createObjectProxy(composite);
293
+ }
294
+ }
295
+ export {
296
+ createArrayProxy,
297
+ createObjectProxy,
298
+ createStore
299
+ };
@@ -0,0 +1,9 @@
1
+ type ResourceState = "pending" | "ready" | "error";
2
+ export interface IResource<T> {
3
+ readonly isSignal: true;
4
+ get(): T | undefined;
5
+ state: ResourceState;
6
+ error?: Error;
7
+ }
8
+ export declare function createResource<T>(source: (signal: AbortSignal) => Promise<T>): IResource<T>;
9
+ export {};
@@ -0,0 +1,58 @@
1
+ import { Signal } from "./signal.js";
2
+ import { effect } from "./effect.js";
3
+ class Resource {
4
+ constructor(source) {
5
+ this.isSignal = true;
6
+ this._currentAbortController = null;
7
+ this._dataSignal = new Signal(void 0);
8
+ this._stateSignal = new Signal("pending");
9
+ this._errorSignal = new Signal(void 0);
10
+ effect((onCleanup) => {
11
+ const abortController = new AbortController();
12
+ if (this._currentAbortController) {
13
+ this._currentAbortController.abort();
14
+ }
15
+ this._currentAbortController = abortController;
16
+ this._stateSignal.set("pending");
17
+ let isStale = false;
18
+ onCleanup(() => {
19
+ isStale = true;
20
+ abortController.abort();
21
+ });
22
+ const promise = source(abortController.signal);
23
+ promise.then((data) => {
24
+ if (!isStale) {
25
+ this._dataSignal.set(data);
26
+ this._stateSignal.set("ready");
27
+ this._errorSignal.set(void 0);
28
+ }
29
+ }).catch((err) => {
30
+ if (isStale) {
31
+ return;
32
+ }
33
+ if (err.name === "AbortError") {
34
+ return;
35
+ }
36
+ const error = err instanceof Error ? err : new Error(String(err));
37
+ this._dataSignal.set(void 0);
38
+ this._stateSignal.set("error");
39
+ this._errorSignal.set(error);
40
+ });
41
+ });
42
+ }
43
+ get() {
44
+ return this._dataSignal.get();
45
+ }
46
+ get state() {
47
+ return this._stateSignal.get();
48
+ }
49
+ get error() {
50
+ return this._errorSignal.get();
51
+ }
52
+ }
53
+ function createResource(source) {
54
+ return new Resource(source);
55
+ }
56
+ export {
57
+ createResource
58
+ };
@@ -0,0 +1,39 @@
1
+ import { Subscriber } from '../types.js';
2
+ export interface ISignal<T> {
3
+ readonly isSignal: true;
4
+ get(): T;
5
+ set(newValue: T): void;
6
+ update(updater: (currentValue: T) => T): void;
7
+ }
8
+ /**
9
+ * Signal con sistema de fases
10
+ *
11
+ * Diferencias clave vs sistema de prioridades:
12
+ * - notify() marca subscribers como dirty en lugar de ejecutarlos
13
+ * - El phase-scheduler maneja el ordenamiento topológico
14
+ * - Garantiza consistencia eliminando glitches
15
+ */
16
+ export declare class Signal<T> implements ISignal<T> {
17
+ readonly isSignal = true;
18
+ private _value;
19
+ private _subscribers;
20
+ constructor(initialValue: T);
21
+ get(): T;
22
+ set(newValue: T): void;
23
+ update(updater: (currentValue: T) => T): void;
24
+ private _notify;
25
+ /**
26
+ * Permite que un computed se des-suscriba de esta signal.
27
+ * Usado cuando el computed hace cleanup de sus dependencias.
28
+ */
29
+ _unsubscribe(subscriber: Subscriber): void;
30
+ /**
31
+ * Método interno para obtener todos los subscribers (útil para debugging)
32
+ */
33
+ _getSubscribers(): Set<Subscriber>;
34
+ }
35
+ /**
36
+ * Helper para verificar si algo implementa ISignal
37
+ * Verifica la propiedad pública isSignal y el método get()
38
+ */
39
+ export declare function isSignal<T>(value: unknown): value is ISignal<T>;
@@ -0,0 +1,56 @@
1
+ import { reactiveContext } from "../reactive-context.js";
2
+ import { phaseScheduler } from "../phase-scheduler.js";
3
+ class Signal {
4
+ constructor(initialValue) {
5
+ this.isSignal = true;
6
+ this._subscribers = /* @__PURE__ */ new Set();
7
+ this._value = initialValue;
8
+ }
9
+ get() {
10
+ if (reactiveContext.currentComputation && reactiveContext.isTracking) {
11
+ this._subscribers.add(reactiveContext.currentComputation);
12
+ reactiveContext.onTrack?.(this);
13
+ }
14
+ return this._value;
15
+ }
16
+ set(newValue) {
17
+ if (!Object.is(this._value, newValue)) {
18
+ this._value = newValue;
19
+ this._notify();
20
+ }
21
+ }
22
+ update(updater) {
23
+ const currentValue = this.get();
24
+ const newValue = updater(currentValue);
25
+ this.set(newValue);
26
+ }
27
+ _notify() {
28
+ this._subscribers.forEach((subscriber) => {
29
+ if (subscriber._isComputation) {
30
+ subscriber();
31
+ } else {
32
+ phaseScheduler.schedule(subscriber);
33
+ }
34
+ });
35
+ }
36
+ /**
37
+ * Permite que un computed se des-suscriba de esta signal.
38
+ * Usado cuando el computed hace cleanup de sus dependencias.
39
+ */
40
+ _unsubscribe(subscriber) {
41
+ this._subscribers.delete(subscriber);
42
+ }
43
+ /**
44
+ * Método interno para obtener todos los subscribers (útil para debugging)
45
+ */
46
+ _getSubscribers() {
47
+ return this._subscribers;
48
+ }
49
+ }
50
+ function isSignal(value) {
51
+ return typeof value === "object" && value !== null && "isSignal" in value && value.isSignal === true && typeof value.get === "function";
52
+ }
53
+ export {
54
+ Signal,
55
+ isSignal
56
+ };
@@ -0,0 +1,12 @@
1
+ export type EffectPriority = "Sync" | "Frame" | "Idle";
2
+ export interface Subscriber extends Function {
3
+ priority?: EffectPriority;
4
+ /**
5
+ * Marca que indica si este subscriber es una computación (Computed)
6
+ * que debe ejecutarse síncronamente para evitar glitches.
7
+ *
8
+ * - true: Es un Computed, ejecutar síncronamente
9
+ * - false/undefined: Es un Effect, agendar en scheduler
10
+ */
11
+ _isComputation?: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,141 @@
1
+ import { Constructor } from '../../DI/types';
2
+ /**
3
+ * Tipos de decisiones que una política puede tomar sobre una navegación.
4
+ * Cada decorador corresponde a uno de estos tipos.
5
+ */
6
+ export type PolicyDecisionType = 'allow' | 'block' | 'redirect' | 'skip';
7
+ /**
8
+ * Representa una regla individual dentro de una política.
9
+ * Una regla es un método decorado que puede tomar decisiones sobre navegación.
10
+ */
11
+ export interface PolicyRule {
12
+ /** Nombre del método (útil para debugging) */
13
+ methodName: string | symbol;
14
+ /** La función del método que se ejecutará */
15
+ handler: Function;
16
+ /** Qué tipo de decisión toma este método cuando retorna true */
17
+ type: PolicyDecisionType;
18
+ }
19
+ /**
20
+ * El resultado de evaluar una política.
21
+ * Contiene información sobre qué se decidió y por qué.
22
+ */
23
+ export interface PolicyDecision {
24
+ /** Qué tipo de acción debe tomarse */
25
+ type: PolicyDecisionType;
26
+ /** Si alguna regla coincidió (retornó true) */
27
+ matched: boolean;
28
+ /** Nombre del método que tomó la decisión (si matched es true) */
29
+ matchedRule?: string | symbol;
30
+ }
31
+ /**
32
+ * Helper para obtener las reglas almacenadas en una clase de política.
33
+ * Este método es usado internamente por el evaluador de políticas.
34
+ *
35
+ * @param policyClass El constructor de cualquier clase con métodos decorados
36
+ * @returns Array de reglas en el orden que fueron declaradas
37
+ */
38
+ export declare function getPolicyRules(policyClass: Constructor<any>): PolicyRule[];
39
+ /**
40
+ * Decorador @Allow()
41
+ *
42
+ * Marca un método que, cuando retorna true, indica que la navegación
43
+ * debe ser permitida. El componente se cargará y la ruta se activará.
44
+ *
45
+ * El método puede ser síncrono o asíncrono.
46
+ * Si retorna false o undefined, se considera que este método no tiene
47
+ * opinión sobre la navegación y se continuará evaluando otros métodos.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * @Allow()
52
+ * publicRoute() {
53
+ * return this.route.meta?.public === true;
54
+ * }
55
+ * ```
56
+ */
57
+ export declare function Allow(): (target: Function, context: ClassMethodDecoratorContext) => void;
58
+ /**
59
+ * Decorador @Block()
60
+ *
61
+ * Marca un método que, cuando retorna true, indica que la navegación
62
+ * debe ser bloqueada completamente. El componente no se cargará y el
63
+ * router intentará el siguiente candidato si existe.
64
+ *
65
+ * A diferencia de @Redirect(), este decorador no navega a ninguna otra ruta.
66
+ * Simplemente detiene la navegación actual.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * @Block()
71
+ * maintenanceMode() {
72
+ * return this.configService.isMaintenanceMode();
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function Block(): (target: Function, context: ClassMethodDecoratorContext) => void;
77
+ /**
78
+ * Decorador @Redirect()
79
+ *
80
+ * Marca un método que, cuando retorna true, indica que ya ha manejado
81
+ * la navegación mediante un redirect a otra ruta. El método debe llamar
82
+ * a router.navigate() antes de retornar true.
83
+ *
84
+ * El router detectará que el currentPath cambió durante la ejecución
85
+ * y cancelará la navegación original.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * @Redirect()
90
+ * redirectToLogin() {
91
+ * if (!this.authService.isAuthenticated()) {
92
+ * sessionStorage.setItem('return_url', this.router.currentPath);
93
+ * this.router.navigate('/login');
94
+ * return true;
95
+ * }
96
+ * return false;
97
+ * }
98
+ * ```
99
+ */
100
+ export declare function Redirect(): (target: Function, context: ClassMethodDecoratorContext) => void;
101
+ /**
102
+ * Decorador @Skip()
103
+ *
104
+ * Marca un método que puede explícitamente declarar que TODA LA POLÍTICA
105
+ * no tiene opinión sobre una navegación particular retornando true.
106
+ *
107
+ * Esto es diferente de simplemente retornar false (que continúa evaluando
108
+ * otros métodos de la misma política). Cuando @Skip retorna true, se detiene
109
+ * la evaluación de esta política completa y se pasa a la siguiente política
110
+ * en la cadena.
111
+ *
112
+ * Esto es crítico para la composición de políticas. Permite que una política
113
+ * declare "yo no soy responsable de esta navegación, pregúntenle a otra política".
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * @Skip()
118
+ * onlyForAdminRoutes() {
119
+ * // Esta política solo se preocupa de rutas /admin/*
120
+ * // Para cualquier otra ruta, explícitamente nos abstenemos
121
+ * if (!this.router.currentPath.startsWith('/admin/')) {
122
+ * return true; // SKIP - no somos responsables de esto
123
+ * }
124
+ *
125
+ * // Si llegamos aquí, estamos en una ruta admin
126
+ * // Retornar false para continuar evaluando otros métodos de esta política
127
+ * return false;
128
+ * }
129
+ *
130
+ * @Allow()
131
+ * adminWithPermission() {
132
+ * // Este método solo se ejecutará si onlyForAdminRoutes retornó false
133
+ * return this.user.hasPermission('admin');
134
+ * }
135
+ * ```
136
+ *
137
+ * Caso de uso común: Políticas especializadas que solo aplican a ciertas rutas.
138
+ * Por ejemplo, una AdminPolicy que solo se preocupa de rutas /admin/*, o una
139
+ * ApiPolicy que solo se preocupa de rutas /api/*.
140
+ */
141
+ export declare function Skip(): (target: Function, context: ClassMethodDecoratorContext) => void;