@pravosleva/reactive-engine 1.8.3-beta → 2.0.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 (254) hide show
  1. package/README.md +271 -0
  2. package/dist/AbstractService.cjs.map +1 -1
  3. package/dist/AbstractService.mjs.map +1 -1
  4. package/dist/BaseREServiceEnhanced.cjs.map +1 -1
  5. package/dist/BaseREServiceEnhanced.mjs.map +1 -1
  6. package/dist/_react-bindings.d.ts +1 -1
  7. package/dist/_react-bindings.d.ts.map +1 -1
  8. package/dist/angular/core.angular-adapter.cjs +2 -0
  9. package/dist/angular/core.angular-adapter.cjs.map +1 -0
  10. package/dist/angular/core.angular-adapter.d.ts +15 -0
  11. package/dist/angular/core.angular-adapter.d.ts.map +1 -0
  12. package/dist/angular/core.angular-adapter.mjs +28 -0
  13. package/dist/angular/core.angular-adapter.mjs.map +1 -0
  14. package/dist/angular/core.angular-adapter.test.d.ts +2 -0
  15. package/dist/angular/core.angular-adapter.test.d.ts.map +1 -0
  16. package/dist/angular/index.cjs +2 -1
  17. package/dist/angular/index.cjs.map +1 -0
  18. package/dist/angular/index.d.ts +19 -2
  19. package/dist/angular/index.d.ts.map +1 -1
  20. package/dist/angular/index.mjs +28 -2
  21. package/dist/angular/index.mjs.map +1 -0
  22. package/dist/core/AbstractService.d.ts +3 -3
  23. package/dist/core/AbstractService.d.ts.map +1 -1
  24. package/dist/core/BaseREServiceEnhanced.d.ts +3 -3
  25. package/dist/core/BaseREServiceEnhanced.d.ts.map +1 -1
  26. package/dist/core/_draft.core.methods.d.ts +13 -0
  27. package/dist/core/_draft.core.methods.d.ts.map +1 -0
  28. package/dist/core/core.advanced.reactive-framework-test-suite.p2.test.d.ts +2 -0
  29. package/dist/core/core.advanced.reactive-framework-test-suite.p2.test.d.ts.map +1 -0
  30. package/dist/core/core.advanced.test.d.ts +2 -0
  31. package/dist/core/core.advanced.test.d.ts.map +1 -0
  32. package/dist/core/core.autolog.d.ts +15 -0
  33. package/dist/core/core.autolog.d.ts.map +1 -0
  34. package/dist/core/core.automatic.d.ts +23 -0
  35. package/dist/core/core.automatic.d.ts.map +1 -0
  36. package/dist/core/core.automatic.test.d.ts +2 -0
  37. package/dist/core/core.automatic.test.d.ts.map +1 -0
  38. package/dist/core/core.d.ts +38 -158
  39. package/dist/core/core.d.ts.map +1 -1
  40. package/dist/core/core.method.batch.d.ts +6 -0
  41. package/dist/core/core.method.batch.d.ts.map +1 -0
  42. package/dist/core/core.method.computed.d.ts +7 -0
  43. package/dist/core/core.method.computed.d.ts.map +1 -0
  44. package/dist/core/core.method.effect.d.ts +7 -0
  45. package/dist/core/core.method.effect.d.ts.map +1 -0
  46. package/dist/core/core.method.reactive.d.ts +6 -0
  47. package/dist/core/core.method.reactive.d.ts.map +1 -0
  48. package/dist/core/core.method.signal.d.ts +7 -0
  49. package/dist/core/core.method.signal.d.ts.map +1 -0
  50. package/dist/core/core.method.untrack.d.ts +6 -0
  51. package/dist/core/core.method.untrack.d.ts.map +1 -0
  52. package/dist/core/core.propagation.test.d.ts +2 -0
  53. package/dist/core/core.propagation.test.d.ts.map +1 -0
  54. package/dist/core/core.test.d.ts +2 -0
  55. package/dist/core/core.test.d.ts.map +1 -0
  56. package/dist/core/index.d.ts +4 -1
  57. package/dist/core/index.d.ts.map +1 -1
  58. package/dist/core/types.d.ts +31 -4
  59. package/dist/core/types.d.ts.map +1 -1
  60. package/dist/core.autolog.cjs +2 -0
  61. package/dist/core.autolog.cjs.map +1 -0
  62. package/dist/core.autolog.mjs +41 -0
  63. package/dist/core.autolog.mjs.map +1 -0
  64. package/dist/core.automatic.cjs +2 -0
  65. package/dist/core.automatic.cjs.map +1 -0
  66. package/dist/core.automatic.mjs +26 -0
  67. package/dist/core.automatic.mjs.map +1 -0
  68. package/dist/core.cjs +1 -1
  69. package/dist/core.cjs.map +1 -1
  70. package/dist/core.method.batch.cjs +2 -0
  71. package/dist/core.method.batch.cjs.map +1 -0
  72. package/dist/core.method.batch.mjs +13 -0
  73. package/dist/core.method.batch.mjs.map +1 -0
  74. package/dist/core.method.computed.cjs +2 -0
  75. package/dist/core.method.computed.cjs.map +1 -0
  76. package/dist/core.method.computed.mjs +122 -0
  77. package/dist/core.method.computed.mjs.map +1 -0
  78. package/dist/core.method.effect.cjs +2 -0
  79. package/dist/core.method.effect.cjs.map +1 -0
  80. package/dist/core.method.effect.mjs +49 -0
  81. package/dist/core.method.effect.mjs.map +1 -0
  82. package/dist/core.method.reactive.cjs +2 -0
  83. package/dist/core.method.reactive.cjs.map +1 -0
  84. package/dist/core.method.reactive.mjs +39 -0
  85. package/dist/core.method.reactive.mjs.map +1 -0
  86. package/dist/core.method.signal.cjs +2 -0
  87. package/dist/core.method.signal.cjs.map +1 -0
  88. package/dist/core.method.signal.mjs +75 -0
  89. package/dist/core.method.signal.mjs.map +1 -0
  90. package/dist/core.method.untrack.cjs +2 -0
  91. package/dist/core.method.untrack.cjs.map +1 -0
  92. package/dist/core.method.untrack.mjs +14 -0
  93. package/dist/core.method.untrack.mjs.map +1 -0
  94. package/dist/core.mjs +268 -592
  95. package/dist/core.mjs.map +1 -1
  96. package/dist/decorators/index.d.ts +1 -0
  97. package/dist/decorators/index.d.ts.map +1 -1
  98. package/dist/decorators/withCache/types.d.ts +29 -0
  99. package/dist/decorators/withCache/types.d.ts.map +1 -0
  100. package/dist/decorators/withCache/withCache.cjs +1 -1
  101. package/dist/decorators/withCache/withCache.cjs.map +1 -1
  102. package/dist/decorators/withCache/withCache.d.ts +4 -61
  103. package/dist/decorators/withCache/withCache.d.ts.map +1 -1
  104. package/dist/decorators/withCache/withCache.mjs +29 -9
  105. package/dist/decorators/withCache/withCache.mjs.map +1 -1
  106. package/dist/decorators/withValidation/index.d.ts +2 -0
  107. package/dist/decorators/withValidation/index.d.ts.map +1 -0
  108. package/dist/decorators/withValidation/withValidation.cjs +2 -0
  109. package/dist/decorators/withValidation/withValidation.cjs.map +1 -0
  110. package/dist/decorators/withValidation/withValidation.d.ts +18 -0
  111. package/dist/decorators/withValidation/withValidation.d.ts.map +1 -0
  112. package/dist/decorators/withValidation/withValidation.mjs +27 -0
  113. package/dist/decorators/withValidation/withValidation.mjs.map +1 -0
  114. package/dist/index.cjs +1 -1
  115. package/dist/index.d.ts +7 -1
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.mjs +14 -11
  118. package/dist/react/core.react-adapter.test.d.ts +2 -0
  119. package/dist/react/core.react-adapter.test.d.ts.map +1 -0
  120. package/dist/react/hooks/_draft.useReactiveValue.v2.d.ts +9 -0
  121. package/dist/react/hooks/_draft.useReactiveValue.v2.d.ts.map +1 -0
  122. package/dist/react/hooks/useReactiveSubscription.cjs +2 -0
  123. package/dist/react/hooks/useReactiveSubscription.cjs.map +1 -0
  124. package/dist/react/hooks/useReactiveSubscription.d.ts +7 -0
  125. package/dist/react/hooks/useReactiveSubscription.d.ts.map +1 -0
  126. package/dist/react/hooks/useReactiveSubscription.mjs +21 -0
  127. package/dist/react/hooks/useReactiveSubscription.mjs.map +1 -0
  128. package/dist/react/hooks/useReactiveValue.cjs +2 -0
  129. package/dist/react/hooks/useReactiveValue.cjs.map +1 -0
  130. package/dist/react/hooks/useReactiveValue.d.ts +3 -0
  131. package/dist/react/hooks/useReactiveValue.d.ts.map +1 -0
  132. package/dist/react/hooks/useReactiveValue.mjs +25 -0
  133. package/dist/react/hooks/useReactiveValue.mjs.map +1 -0
  134. package/dist/react/index.cjs +2 -1
  135. package/dist/react/index.cjs.map +1 -0
  136. package/dist/react/index.d.ts +9 -3
  137. package/dist/react/index.d.ts.map +1 -1
  138. package/dist/react/index.mjs +13 -6
  139. package/dist/react/index.mjs.map +1 -0
  140. package/dist/react/types.d.ts +0 -1
  141. package/dist/react/types.d.ts.map +1 -1
  142. package/dist/reactive-engine.umd.js +2 -2
  143. package/dist/reactive-engine.umd.js.map +1 -1
  144. package/dist/utils/getExtractedValues.cjs +2 -0
  145. package/dist/utils/getExtractedValues.cjs.map +1 -0
  146. package/dist/utils/getExtractedValues.mjs +24 -0
  147. package/dist/utils/getExtractedValues.mjs.map +1 -0
  148. package/dist/vue/core.vue-adapter.cjs +2 -0
  149. package/dist/vue/core.vue-adapter.cjs.map +1 -0
  150. package/dist/vue/core.vue-adapter.d.ts +8 -0
  151. package/dist/vue/core.vue-adapter.d.ts.map +1 -0
  152. package/dist/vue/core.vue-adapter.mjs +22 -0
  153. package/dist/vue/core.vue-adapter.mjs.map +1 -0
  154. package/dist/vue/core.vue-adapter.test.d.ts +2 -0
  155. package/dist/vue/core.vue-adapter.test.d.ts.map +1 -0
  156. package/dist/vue/index.cjs +2 -1
  157. package/dist/vue/index.cjs.map +1 -0
  158. package/dist/vue/index.d.ts +14 -2
  159. package/dist/vue/index.d.ts.map +1 -1
  160. package/dist/vue/index.mjs +54 -3
  161. package/dist/vue/index.mjs.map +1 -0
  162. package/package.json +4 -3
  163. package/dist/angular/ReactiveEngine4Angular.cjs +0 -2
  164. package/dist/angular/ReactiveEngine4Angular.cjs.map +0 -1
  165. package/dist/angular/ReactiveEngine4Angular.d.ts +0 -37
  166. package/dist/angular/ReactiveEngine4Angular.d.ts.map +0 -1
  167. package/dist/angular/ReactiveEngine4Angular.mjs +0 -45
  168. package/dist/angular/ReactiveEngine4Angular.mjs.map +0 -1
  169. package/dist/angular/core.angular.auto.test.d.ts +0 -2
  170. package/dist/angular/core.angular.auto.test.d.ts.map +0 -1
  171. package/dist/angular/core.angular.test.d.ts +0 -2
  172. package/dist/angular/core.angular.test.d.ts.map +0 -1
  173. package/dist/core/core.auto.test.d.ts +0 -2
  174. package/dist/core/core.auto.test.d.ts.map +0 -1
  175. package/dist/react/ReactiveEngine4React.cjs +0 -2
  176. package/dist/react/ReactiveEngine4React.cjs.map +0 -1
  177. package/dist/react/ReactiveEngine4React.d.ts +0 -34
  178. package/dist/react/ReactiveEngine4React.d.ts.map +0 -1
  179. package/dist/react/ReactiveEngine4React.mjs +0 -51
  180. package/dist/react/ReactiveEngine4React.mjs.map +0 -1
  181. package/dist/react/core.react.auto.test.d.ts +0 -2
  182. package/dist/react/core.react.auto.test.d.ts.map +0 -1
  183. package/dist/react/core.react.test.d.ts +0 -2
  184. package/dist/react/core.react.test.d.ts.map +0 -1
  185. package/dist/react/hooks/FilteredCatalog.auto.test.d.ts +0 -2
  186. package/dist/react/hooks/FilteredCatalog.auto.test.d.ts.map +0 -1
  187. package/dist/react/hooks/FilteredCatalog.test.d.ts +0 -2
  188. package/dist/react/hooks/FilteredCatalog.test.d.ts.map +0 -1
  189. package/dist/react/hooks/index.cjs +0 -1
  190. package/dist/react/hooks/index.d.ts +0 -4
  191. package/dist/react/hooks/index.d.ts.map +0 -1
  192. package/dist/react/hooks/index.mjs +0 -7
  193. package/dist/react/hooks/types.d.ts +0 -20
  194. package/dist/react/hooks/types.d.ts.map +0 -1
  195. package/dist/react/hooks/useReactiveSubscription/index.cjs +0 -1
  196. package/dist/react/hooks/useReactiveSubscription/index.d.ts +0 -2
  197. package/dist/react/hooks/useReactiveSubscription/index.d.ts.map +0 -1
  198. package/dist/react/hooks/useReactiveSubscription/index.mjs +0 -2
  199. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.auto.test.d.ts +0 -2
  200. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.auto.test.d.ts.map +0 -1
  201. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.cjs +0 -2
  202. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.cjs.map +0 -1
  203. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.d.ts +0 -7
  204. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.d.ts.map +0 -1
  205. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.mjs +0 -27
  206. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.mjs.map +0 -1
  207. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.test.d.ts +0 -2
  208. package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.test.d.ts.map +0 -1
  209. package/dist/react/hooks/useReactiveValue/index.cjs +0 -1
  210. package/dist/react/hooks/useReactiveValue/index.d.ts +0 -2
  211. package/dist/react/hooks/useReactiveValue/index.d.ts.map +0 -1
  212. package/dist/react/hooks/useReactiveValue/index.mjs +0 -2
  213. package/dist/react/hooks/useReactiveValue/useReactiveValue.auto.test.d.ts +0 -2
  214. package/dist/react/hooks/useReactiveValue/useReactiveValue.auto.test.d.ts.map +0 -1
  215. package/dist/react/hooks/useReactiveValue/useReactiveValue.cjs +0 -2
  216. package/dist/react/hooks/useReactiveValue/useReactiveValue.cjs.map +0 -1
  217. package/dist/react/hooks/useReactiveValue/useReactiveValue.d.ts +0 -18
  218. package/dist/react/hooks/useReactiveValue/useReactiveValue.d.ts.map +0 -1
  219. package/dist/react/hooks/useReactiveValue/useReactiveValue.mjs +0 -25
  220. package/dist/react/hooks/useReactiveValue/useReactiveValue.mjs.map +0 -1
  221. package/dist/react/hooks/useReactiveValue/useReactiveValue.test.d.ts +0 -2
  222. package/dist/react/hooks/useReactiveValue/useReactiveValue.test.d.ts.map +0 -1
  223. package/dist/react/hooks/useReactiveValue0/index.cjs +0 -1
  224. package/dist/react/hooks/useReactiveValue0/index.d.ts +0 -2
  225. package/dist/react/hooks/useReactiveValue0/index.d.ts.map +0 -1
  226. package/dist/react/hooks/useReactiveValue0/index.mjs +0 -2
  227. package/dist/react/hooks/useReactiveValue0/useReactiveValue0.cjs +0 -2
  228. package/dist/react/hooks/useReactiveValue0/useReactiveValue0.cjs.map +0 -1
  229. package/dist/react/hooks/useReactiveValue0/useReactiveValue0.d.ts +0 -51
  230. package/dist/react/hooks/useReactiveValue0/useReactiveValue0.d.ts.map +0 -1
  231. package/dist/react/hooks/useReactiveValue0/useReactiveValue0.mjs +0 -23
  232. package/dist/react/hooks/useReactiveValue0/useReactiveValue0.mjs.map +0 -1
  233. package/dist/vue/ReactiveEngine4Vue.cjs +0 -2
  234. package/dist/vue/ReactiveEngine4Vue.cjs.map +0 -1
  235. package/dist/vue/ReactiveEngine4Vue.d.ts +0 -37
  236. package/dist/vue/ReactiveEngine4Vue.d.ts.map +0 -1
  237. package/dist/vue/ReactiveEngine4Vue.mjs +0 -53
  238. package/dist/vue/ReactiveEngine4Vue.mjs.map +0 -1
  239. package/dist/vue/composables/index.d.ts +0 -2
  240. package/dist/vue/composables/index.d.ts.map +0 -1
  241. package/dist/vue/composables/useReactiveValue.auto.test.d.ts +0 -2
  242. package/dist/vue/composables/useReactiveValue.auto.test.d.ts.map +0 -1
  243. package/dist/vue/composables/useReactiveValue.cjs +0 -2
  244. package/dist/vue/composables/useReactiveValue.cjs.map +0 -1
  245. package/dist/vue/composables/useReactiveValue.d.ts +0 -12
  246. package/dist/vue/composables/useReactiveValue.d.ts.map +0 -1
  247. package/dist/vue/composables/useReactiveValue.mjs +0 -19
  248. package/dist/vue/composables/useReactiveValue.mjs.map +0 -1
  249. package/dist/vue/composables/useReactiveValue.test.d.ts +0 -2
  250. package/dist/vue/composables/useReactiveValue.test.d.ts.map +0 -1
  251. package/dist/vue/core.vue.auto.test.d.ts +0 -2
  252. package/dist/vue/core.vue.auto.test.d.ts.map +0 -1
  253. package/dist/vue/core.vue.test.d.ts +0 -2
  254. package/dist/vue/core.vue.test.d.ts.map +0 -1
package/dist/core.mjs CHANGED
@@ -1,650 +1,326 @@
1
+ import { getExtractedValues as e } from "./utils/getExtractedValues.mjs";
2
+ import { createComputed as t } from "./core.method.computed.mjs";
3
+ import { createSignal as n } from "./core.method.signal.mjs";
4
+ import { executeBatch as r } from "./core.method.batch.mjs";
5
+ import { executeUntrack as i } from "./core.method.untrack.mjs";
6
+ import { createReactive as a } from "./core.method.reactive.mjs";
7
+ import { createEffect as o } from "./core.method.effect.mjs";
1
8
  //#region src/core/core.ts
2
- var e = class {
9
+ var s = {
10
+ signal: "background: #007acc; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
11
+ computed: "background: #42b883; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
12
+ effect: "background: #e01e5a; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
13
+ batch: "background: #7952b3; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
14
+ resource: "background: #d97706; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
15
+ reactive: "background: #007acc; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;"
16
+ }, c = null;
17
+ function l(e) {
18
+ if (e === null) return "null";
19
+ if (e === void 0) return "undefined";
20
+ if (typeof e == "object") try {
21
+ return JSON.stringify(e);
22
+ } catch {
23
+ return "[Cyclic Object or Layer]";
24
+ }
25
+ return String(e);
26
+ }
27
+ function u(e, t, n) {
28
+ c || (c = {
29
+ id: Math.random().toString(36).substring(2, 9),
30
+ pendingLogQueue: [],
31
+ isFlushing: !1
32
+ }, queueMicrotask(() => d())), c.pendingLogQueue.push({
33
+ type: e,
34
+ label: t,
35
+ from: n?.from,
36
+ to: n?.to,
37
+ payload: n?.payload,
38
+ timestamp: Date.now()
39
+ });
40
+ }
41
+ function d() {
42
+ if (!c || c.isFlushing) return;
43
+ c.isFlushing = !0;
44
+ let e = c.pendingLogQueue;
45
+ if (e.length === 0) {
46
+ c = null;
47
+ return;
48
+ }
49
+ console.groupCollapsed(`%cREACTIVE TRANSACTION%c [id: ${c.id}] (${e.length} operations)`, "background: #7952b3; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;", "color: #888; font-weight: normal;");
50
+ for (let t of e) {
51
+ let e = s[t.type], n = t.from !== void 0 || t.to !== void 0, r = `%c${t.type.toUpperCase()}%c ${t.label}`;
52
+ n && (t.from ? r += `(${l(t.from)} → ${l(t.to)})` : r += `(${l(t.to)})`), t.payload === void 0 ? console.log(r, e, "color: inherit;") : (console.groupCollapsed(r, e, "color: inherit;"), console.log("Payload:", t.payload), console.groupEnd());
53
+ }
54
+ console.groupEnd(), c = null;
55
+ }
56
+ var f = class {
3
57
  frameworkPrefix = "core";
58
+ logger;
59
+ epoch = 0;
4
60
  activeConsumer = null;
5
- subscriberId = 0;
6
61
  batchDepth = 0;
62
+ subscriberId = 0;
7
63
  pendingEffects = /* @__PURE__ */ new Set();
8
- allEffects = /* @__PURE__ */ new Set();
9
64
  computedCache = /* @__PURE__ */ new Map();
10
- computed(e, t) {
11
- let n = this;
12
- if (n.computedCache.has(e)) {
13
- let t = n.computedCache.get(e)?.deref();
14
- if (t) return t;
15
- }
16
- let r = t || "unnamed_computed", i, a = /* @__PURE__ */ new Set(), o = {
17
- id: ++n.subscriberId,
18
- isDirty: !0,
19
- cleanups: /* @__PURE__ */ new Set(),
20
- markDirty() {
21
- this.isDirty || (this.isDirty = !0, Array.from(a).forEach((e) => {
22
- e !== n.activeConsumer && e.markDirty();
23
- }));
24
- }
25
- }, s = {
26
- get value() {
27
- if (n.activeConsumer) {
28
- let e = n.activeConsumer;
29
- a.has(e) || (a.add(e), e.cleanups.add(() => a.delete(e)));
30
- }
31
- if (o.isDirty) {
32
- let t = Array.from(o.cleanups);
33
- o.cleanups.clear(), t.forEach((e) => e());
34
- let r = n.activeConsumer;
35
- n.activeConsumer = o;
36
- try {
37
- i = e(), o.isDirty = !1;
38
- } finally {
39
- n.activeConsumer = r;
40
- }
41
- }
42
- return i;
43
- },
44
- subscribe: (e) => n.effect(() => e(s.value), `computed:use:${r}`),
45
- destroy() {
46
- let t = Array.from(o.cleanups);
47
- o.cleanups.clear(), t.forEach((e) => e()), a.clear(), n.computedCache.delete(e);
48
- for (let [e, t] of n.computedCache.entries()) t.deref() === s && n.computedCache.delete(e);
49
- }
50
- };
51
- return n.cleanupRegistry && n.cleanupRegistry.register(s, () => s.destroy()), n.computedCache.set(e, new WeakRef(s)), s;
65
+ diRegistry = /* @__PURE__ */ new Map();
66
+ diCache = /* @__PURE__ */ new Map();
67
+ proxyCache = /* @__PURE__ */ new WeakMap();
68
+ proxyTargets = /* @__PURE__ */ new WeakSet();
69
+ reactiveSignals = /* @__PURE__ */ new WeakMap();
70
+ cycleDetectionStack = /* @__PURE__ */ new Set();
71
+ constructor(e) {
72
+ this.logger = e?.logger || { isEnabled: !1 };
52
73
  }
53
- effect(e, t) {
54
- let n = this, r = {
55
- id: ++n.subscriberId,
56
- label: t,
57
- cleanups: /* @__PURE__ */ new Set(),
58
- markDirty() {
59
- n.pendingEffects.add(r), n.batchDepth === 0 && n.flushEffects();
60
- },
61
- run() {
62
- let t = Array.from(r.cleanups);
63
- r.cleanups.clear(), t.forEach((e) => {
64
- try {
65
- e();
74
+ queueLog(e, t, n) {
75
+ u(e, t, n);
76
+ }
77
+ flushEffects() {
78
+ if (this.batchDepth > 0) return;
79
+ let e = Array.from(this.pendingEffects);
80
+ this.pendingEffects.clear(), e.sort((e, t) => (e.depth || 0) - (t.depth || 0) || e.id - t.id);
81
+ let t = this.activeConsumer;
82
+ try {
83
+ for (let t of e) if (!t.isDisposed) {
84
+ if (t.dependencies && t.dependencies.size > 0) for (let e of t.dependencies) {
85
+ let t = e._node || e;
86
+ if (t.type === "computed" && t._isDirty && t._isDirty()) try {
87
+ t.run();
66
88
  } catch (e) {
67
- console.error("[Reactive Engine:Cleanup Error]", e);
89
+ if (this.batchDepth === 0) throw e;
68
90
  }
69
- });
70
- let i = n.activeConsumer;
71
- n.activeConsumer = r;
72
- try {
73
- let t = e();
74
- typeof t == "function" && r.cleanups.add(t);
75
- } catch (e) {
76
- console.error("[Reactive Error] Ошибка при выполнении тела эффекта:", e);
77
- } finally {
78
- n.activeConsumer = i;
79
91
  }
80
- }
81
- };
82
- return n.allEffects.add(r), r.run(), () => {
83
- Array.from(r.cleanups).forEach((e) => {
84
- try {
85
- e();
92
+ if (t.isDirty) try {
93
+ t.run();
86
94
  } catch (e) {
87
- console.error("[Reactive Engine:Dispose Cleanup Error]", e);
95
+ if (this.batchDepth === 0) throw e;
88
96
  }
89
- }), r.cleanups.clear(), n.pendingEffects.delete(r), n.allEffects.delete(r);
90
- };
91
- }
92
- signal(e, t) {
93
- let n = this, r = e, i = /* @__PURE__ */ new Set(), a = typeof t == "string" ? { name: t } : t || {}, o = a.name || "unnamed_signal", s = { version: 0 };
94
- return {
95
- get value() {
96
- if (n.activeConsumer) {
97
- let e = n.activeConsumer;
98
- if (!i.has(e)) {
99
- i.add(e);
100
- let t = () => {
101
- i.delete(e);
102
- };
103
- t._sourceNode = s, e.cleanups.add(t);
104
- }
105
- }
106
- return r;
107
- },
108
- set value(e) {
109
- if (a?.validate) {
110
- let t = a.validate(e);
111
- if (t !== !0) {
112
- console.error(`[Reactive Engine: Validation Error] ${t}`);
113
- return;
114
- }
115
- }
116
- if ((e === null || typeof e != "object" && typeof e != "function") && r === e) return;
117
- let t = r;
118
- r = e, s.version++, n.onSignalChange?.(o, e, t), Array.from(i).forEach((e) => {
119
- e !== n.activeConsumer && e.markDirty();
120
- });
121
- },
122
- subscribe(e) {
123
- return n.effect(() => e(this.value), `use:${o}`);
124
97
  }
125
- };
126
- }
127
- batch(e) {
128
- this.batchDepth++;
129
- try {
130
- e();
131
98
  } finally {
132
- this.batchDepth--, this.batchDepth === 0 && this.flushEffects();
99
+ this.activeConsumer = t;
133
100
  }
134
101
  }
135
- flushEffects() {
136
- let e = Array.from(this.pendingEffects);
137
- this.pendingEffects.clear(), e.forEach((e) => {
138
- try {
139
- e.run();
140
- } catch (e) {
141
- console.error("[Reactive Engine: Effect Execution Error]", e);
142
- }
143
- });
102
+ batch(e) {
103
+ return r(this, e);
144
104
  }
145
- untrack(e) {
146
- let t = this.activeConsumer;
147
- this.activeConsumer = null;
148
- try {
149
- return e();
150
- } finally {
151
- this.activeConsumer = t;
152
- }
105
+ log({ type: e, label: t, details: n, isInternalCoreSignal: r = !1 }) {
106
+ let i = this.logger.isEnabled, a = this.logger.isCoreOptimizationDebugEnabled;
107
+ i && (r ? a && u(e, t, n) : u(e, t, n));
153
108
  }
154
- }, t = class extends e {
155
- services = /* @__PURE__ */ new Map();
156
- factories = /* @__PURE__ */ new Map();
157
- proxyCache = /* @__PURE__ */ new WeakMap();
158
- loggerOptions;
159
- pendingLogQueue = [];
160
- signalMutationCounts = /* @__PURE__ */ new Map();
161
- lastComputedDurations = /* @__PURE__ */ new Map();
162
- effectExecutionCounts = /* @__PURE__ */ new Map();
163
- batchTickCounts = 0;
164
- lastTransactionDuration = null;
165
- constructor(e) {
166
- super(), this.loggerOptions = e?.logger;
109
+ signal(e, t) {
110
+ return n(this, e, t);
167
111
  }
168
- reactive(e, t = "reactive") {
169
- if (this.proxyCache.has(e)) return this.proxyCache.get(e);
170
- let n = this, r = /* @__PURE__ */ new Map(), i = !1, a = new Proxy(e, {
171
- get(e, o, s) {
172
- if (o === "__subscribe") return (e) => {
173
- let t = !1;
174
- return n.effect(() => {
175
- try {
176
- JSON.stringify(a);
177
- } catch {
178
- Object.values(a);
179
- }
180
- typeof window < "u" && (window.__VUE__ || globalThis.__VUE__ || e.toString().includes("triggerRef")) ? t || (t = !0, queueMicrotask(() => {
181
- t = !1, e();
182
- })) : e();
183
- }, "framework-proxy-internal-subscription");
184
- };
185
- if (n.activeConsumer) {
186
- let e = n.activeConsumer;
187
- r.has(o) || r.set(o, /* @__PURE__ */ new Map());
188
- let t = r.get(o);
189
- if (!t.has(e)) {
190
- let n = () => {
191
- t.delete(e);
192
- };
193
- t.set(e, n), e.cleanups.add(n);
194
- }
195
- }
196
- if (Array.isArray(e) && typeof o == "string" && [
197
- "push",
198
- "pop",
199
- "shift",
200
- "unshift",
201
- "splice",
202
- "sort",
203
- "reverse"
204
- ].includes(o)) {
205
- let t = e[o];
206
- return function(...a) {
207
- n.batchDepth++, i = !0;
208
- let s = t.apply(e, a);
209
- return i = !1, r.forEach((e, t) => {
210
- t !== o && Array.from(e.keys()).forEach((e) => {
211
- e !== n.activeConsumer && e.markDirty();
212
- });
213
- }), n.batchDepth--, n.batchDepth === 0 && n.flushEffects(), s;
214
- };
215
- }
216
- let c = Reflect.get(e, o, s);
217
- return typeof c == "object" && c ? n.reactive(c, `${t}.${String(o)}`) : c;
218
- },
219
- set(e, a, o, s) {
220
- let c = Reflect.get(e, a, s);
221
- if (c === o || (Reflect.set(e, a, o, s), n.onSignalChange?.(`${t}.${String(a)}`, o, c), i)) return !0;
222
- let l = r.get(a), u = l ? Array.from(l.keys()) : [];
223
- if (Array.isArray(e)) {
224
- let e = r.get("length");
225
- e && u.push(...Array.from(e.keys()));
226
- }
227
- return u.forEach((e) => {
228
- e !== n.activeConsumer && e.markDirty();
229
- }), typeof n.queueLog == "function" && n.queueLog("reactive", `${t}.${String(a)}`, {
230
- action: "set",
231
- property: String(a),
232
- oldValue: c,
233
- newValue: o
234
- }), !0;
235
- }
236
- });
237
- return this.proxyCache.set(e, a), a;
112
+ computed(e, n) {
113
+ return t(this, e, n);
114
+ }
115
+ effect(e, t) {
116
+ return o(this, e, t);
117
+ }
118
+ untrack(e) {
119
+ return i(this, e);
120
+ }
121
+ reactive(e, t) {
122
+ return a(this, e, t);
238
123
  }
239
124
  provide(e, t) {
240
- typeof t == "function" && (!t.prototype || t.name === "mockConstructor" || t._isMockFunction) ? this.factories.set(e, t) : this.services.set(e, t);
125
+ this.diRegistry.set(e, t), this.diCache.delete(e);
241
126
  }
242
127
  inject(e) {
243
- if (!e) throw Error("[DI Error]: Вы пытаетесь внедрить пустой токен.");
244
- let t = e;
245
- if (this.services.has(t)) return this.services.get(t);
128
+ if (e == null) throw Error("[DI Error] Token is empty");
129
+ if (this.diCache.has(e)) return this.diCache.get(e);
130
+ if (this.cycleDetectionStack.has(e)) throw Error("[DI Error] Cyclic dependency detected");
131
+ this.cycleDetectionStack.add(e);
246
132
  try {
247
- let n = this.factories.get(t);
248
- if (n) {
249
- let e = n(this);
250
- return this.services.set(t, e), e;
133
+ if (this.diRegistry.has(e)) {
134
+ let t = this.diRegistry.get(e);
135
+ if (typeof t == "function") {
136
+ if (t._isMockFunction) {
137
+ let n = t(this);
138
+ return n === void 0 ? t : (this.diCache.set(e, n), n);
139
+ }
140
+ let n = t.toString();
141
+ if (!(n.startsWith("class ") || n.startsWith("class{") || t.prototype && t.prototype.constructor === t && !n.startsWith("function") && !n.includes("=>"))) {
142
+ let n = t(this);
143
+ return this.diCache.set(e, n), n;
144
+ }
145
+ return t;
146
+ }
147
+ return t;
251
148
  }
252
- if (typeof e == "function" && e.prototype) {
253
- let n = new e(this);
254
- return this.services.set(t, n), n;
149
+ if (typeof e == "function") {
150
+ let t = new e(this);
151
+ return this.diCache.set(e, t), t;
255
152
  }
256
- throw Error(`Service not found: ${String(e)}`);
257
- } catch {
258
- throw Error(`[DI Error]: Не удалось создать сервис ${String(e)}.`);
153
+ throw Error("[DI Error] Token not found");
154
+ } finally {
155
+ this.cycleDetectionStack.delete(e);
259
156
  }
260
157
  }
261
- queueLog(e, t, n) {
262
- this.loggerOptions?.isEnabled && (this.pendingLogQueue.push({
263
- type: e,
264
- name: t,
265
- detail: n
266
- }), this.batchDepth === 0 && this.flushLogs());
267
- }
268
- flushLogs() {
269
- !this.loggerOptions?.isEnabled || this.pendingLogQueue.length === 0 || (this.pendingLogQueue = []);
158
+ delay(e, t) {
159
+ return new Promise((n, r) => {
160
+ if (t.aborted) return r(new DOMException("Aborted", "AbortError"));
161
+ let i = setTimeout(() => {
162
+ t.removeEventListener("abort", a), n();
163
+ }, e), a = () => {
164
+ clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
165
+ };
166
+ t.addEventListener("abort", a, { once: !0 });
167
+ });
270
168
  }
271
- resource(e, t, n) {
272
- let r = n && typeof n == "object" ? n.name : n || "unnamed_resource", i = this.signal({
169
+ resource(t, n, r) {
170
+ let i = r && typeof r == "object", a = i ? r.name || "unnamed_resource" : r || "unnamed_resource", o = i ? r : {}, s = o.resetDataOnSourceChange ?? !0, c = o.responseValidate, l = o.validateBeforeFetch, u = this.signal({
273
171
  data: null,
274
172
  loading: !0,
275
173
  error: null,
276
174
  isRetrying: !1
277
- }, `resource:state:${r}`), a = this, o = null, s = async (t, n) => {
278
- if (!n.aborted) {
279
- a.untrack(() => {
280
- i.value = {
281
- data: i.value.data,
282
- loading: !0,
283
- error: null,
175
+ }, `[CORE_INTERNAL_SIGNAL=1]:resource:state:${a}`), d = (e) => {
176
+ this.log({
177
+ type: "resource",
178
+ label: a,
179
+ details: {
180
+ to: e,
181
+ from: u.value
182
+ }
183
+ }), u.value = e;
184
+ }, f = async (n, r, i = !1) => {
185
+ if (r.aborted) return;
186
+ let f = o.validateBeforeFetch ? o.validateBeforeFetch(n) : !0;
187
+ if (f === !1) {
188
+ u.value = {
189
+ loading: !1,
190
+ data: null,
191
+ error: null,
192
+ isRetrying: !1
193
+ };
194
+ return;
195
+ }
196
+ if (typeof f == "string") {
197
+ u.value = {
198
+ loading: !1,
199
+ data: null,
200
+ error: "Core internal stopper",
201
+ isRetrying: !1
202
+ };
203
+ return;
204
+ }
205
+ if (l) {
206
+ let e = l(n);
207
+ if (e === !1 || typeof e == "string") {
208
+ if (r.aborted) return;
209
+ let t = typeof e == "string" ? e : "Pre-fetch validation failed for resource", n = i ? null : this.untrack(() => u.value.data);
210
+ d({
211
+ data: n,
212
+ loading: !1,
213
+ error: t,
284
214
  isRetrying: !1
285
- };
286
- });
215
+ });
216
+ return;
217
+ }
218
+ }
219
+ let p = i && s ? null : this.untrack(() => u.value.data);
220
+ d({
221
+ data: p,
222
+ loading: !0,
223
+ error: null,
224
+ isRetrying: !1
225
+ });
226
+ for (let i = 0; i <= 0; i++) {
227
+ if (r.aborted) return;
228
+ let o = r;
287
229
  try {
288
- let r = await e(t, n);
289
- n.aborted || a.untrack(() => {
290
- i.value = {
291
- data: r,
292
- loading: !1,
293
- error: null,
294
- isRetrying: !1
295
- };
230
+ let e = await t(n, o);
231
+ if (r.aborted) return;
232
+ if (o.aborted) throw new DOMException("The operation timed out.", "TimeoutError");
233
+ if (c) {
234
+ let t = c(e);
235
+ if (t === !1 || typeof t == "string") {
236
+ if (r.aborted) return;
237
+ d({
238
+ data: null,
239
+ loading: !1,
240
+ error: typeof t == "string" ? t : "Validation failed",
241
+ isRetrying: !1
242
+ });
243
+ return;
244
+ }
245
+ }
246
+ if (r.aborted) return;
247
+ d({
248
+ data: e,
249
+ loading: !1,
250
+ error: null,
251
+ isRetrying: !1
296
252
  });
297
- } catch (e) {
298
- n.aborted || a.untrack(() => {
299
- i.value = {
253
+ return;
254
+ } catch (t) {
255
+ if (r.aborted || t.name === "AbortError" && r.aborted) return;
256
+ let n = t.name === "TimeoutError" || t.name === "AbortError" || t.message?.includes("timeout"), o = e({
257
+ tested: [t.message],
258
+ expectedKey: "THROW_CUSTOM_VALIDATION_ERROR_NO_RETRY",
259
+ valueType: "number"
260
+ })?.[0] === "1" || !1, s = o && e({
261
+ tested: [t.message],
262
+ expectedKey: "MESSAGE",
263
+ valueType: "string"
264
+ })?.[0] || "Custom validation error", c = o || t.name === "ValidationError";
265
+ if (i === 0 || c) {
266
+ if (r.aborted) return;
267
+ let e = n ? Error("Request timed out after 1000ms", { cause: t }) : o ? Error(s, { cause: t }) : t;
268
+ d({
300
269
  data: null,
301
270
  loading: !1,
302
- error: e,
271
+ error: e instanceof Error ? e.message : typeof e == "string" ? e : `typeof finalError is ${typeof e}`,
303
272
  isRetrying: !1
304
- };
305
- });
273
+ });
274
+ return;
275
+ } else {
276
+ if (r.aborted) return;
277
+ let e = 1e3 * 2 ** i;
278
+ e = Math.min(e, 3e5);
279
+ let t = Math.random() * 200;
280
+ e += t, d({
281
+ data: u.value.data,
282
+ loading: !0,
283
+ error: null,
284
+ isRetrying: !0
285
+ }), console.warn(`[Resource Retry] "${a}" сбой по ${n ? "таймауту" : "ошибке сети"}. Попытка ${i + 1}/${i + 1}...`);
286
+ try {
287
+ if (await this.delay(e, r), r.aborted) return;
288
+ } catch {
289
+ return;
290
+ }
291
+ }
306
292
  }
307
293
  }
308
- };
294
+ }, p = null;
309
295
  return this.effect(() => {
310
- let e = t ? t.value : void 0;
311
- return o && o.abort(), o = new AbortController(), s(e, o.signal), () => {
312
- o && o.abort();
313
- };
314
- }), {
296
+ let e = n ? n.value : void 0, t = new AbortController();
297
+ return p = t, this.untrack(() => {
298
+ f(e, t.signal, !0);
299
+ }), () => t.abort();
300
+ }, "[CORE_INTERNAL_SIGNAL=1]:effect"), {
315
301
  get data() {
316
- return i.value.data;
302
+ return u.value.data;
317
303
  },
318
304
  get loading() {
319
- return i.value.loading;
305
+ return u.value.loading;
320
306
  },
321
307
  get error() {
322
- return i.value.error;
323
- },
324
- get value() {
325
- return i.value;
308
+ return u.value.error;
326
309
  },
327
- refetch: () => {
328
- o && o.abort(), o = new AbortController(), s(t ? t.value : void 0, o.signal);
310
+ get isRetrying() {
311
+ return u.value.isRetrying;
329
312
  },
330
- subscribe: (e) => i.subscribe(e)
331
- };
332
- }
333
- }, n = class extends t {
334
- isFlushScheduled = !1;
335
- nodeDepths = /* @__PURE__ */ new WeakMap();
336
- constructor(e) {
337
- super(e), this.frameworkPrefix = "auto-core";
338
- }
339
- computed(e, t) {
340
- let n = this;
341
- if (n.computedCache.has(e)) {
342
- let t = n.computedCache.get(e)?.deref();
343
- if (t) return t;
344
- }
345
- let r = t || "unnamed_auto_computed", i, a = !1, o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), c = {
346
- id: ++n.subscriberId,
347
- isDirty: !0,
348
- cleanups: /* @__PURE__ */ new Set(),
349
- markDirty() {
350
- this.isDirty || (this.isDirty = !0, Array.from(o).forEach((e) => {
351
- e !== n.activeConsumer && e.markDirty();
352
- }));
353
- }
354
- }, l = {
355
313
  get value() {
356
- if (n.activeConsumer) {
357
- let e = n.activeConsumer;
358
- o.has(e) || (o.add(e), e.cleanups.add(() => o.delete(e)));
359
- }
360
- if (c.isDirty && a) {
361
- let e = !1;
362
- for (let [t, n] of s.entries()) if (t.version !== n) {
363
- e = !0;
364
- break;
365
- }
366
- e || (c.isDirty = !1);
367
- }
368
- if (c.isDirty || !a) {
369
- let t = Array.from(c.cleanups);
370
- c.cleanups.clear(), t.forEach((e) => e());
371
- let r = n.activeConsumer;
372
- n.activeConsumer = c;
373
- try {
374
- i = e(), c.isDirty = !1, a = !0, s.clear(), c.cleanups.forEach((e) => {
375
- if (e && typeof e == "function") {
376
- let t = n.allEffects?.has(e) || e._sourceNode;
377
- t && s.set(t, t.version || 0);
378
- }
379
- });
380
- } finally {
381
- n.activeConsumer = r;
382
- }
383
- }
384
- return i;
314
+ return u.value;
385
315
  },
386
- subscribe: (e) => n.effect(() => e(l.value), `computed:auto:${r}`),
387
- destroy() {
388
- let t = Array.from(c.cleanups);
389
- c.cleanups.clear(), t.forEach((e) => e()), o.clear(), s.clear(), n.computedCache.delete(e);
390
- }
391
- };
392
- return n.computedCache.set(e, new WeakRef(l)), l;
393
- }
394
- getNodeDepth(e) {
395
- return e ? this.nodeDepths.has(e) ? this.nodeDepths.get(e) : 1 : 0;
396
- }
397
- effect(e, t) {
398
- let n = this, r = n.activeConsumer, i = {
399
- id: ++n.subscriberId,
400
- label: t,
401
- cleanups: /* @__PURE__ */ new Set(),
402
- markDirty() {
403
- n.pendingEffects.add(i), n.flushEffects();
404
- },
405
- run() {
406
- let t = Array.from(i.cleanups);
407
- i.cleanups.clear(), t.forEach((e) => {
408
- try {
409
- e();
410
- } catch (e) {
411
- console.error("[Reactive Engine:Cleanup Error]", e);
412
- }
413
- });
414
- let r = n.activeConsumer;
415
- n.activeConsumer = i;
416
- let a = n.getNodeDepth(r) + 1;
417
- n.nodeDepths.set(i, a);
418
- try {
419
- let t = e();
420
- typeof t == "function" && i.cleanups.add(t);
421
- } finally {
422
- n.activeConsumer = r;
423
- }
424
- }
425
- };
426
- return r && r.cleanups.add(() => {
427
- Array.from(i.cleanups).forEach((e) => {
428
- try {
429
- e();
430
- } catch {}
431
- }), i.cleanups.clear(), n.pendingEffects.delete(i), n.allEffects.delete(i);
432
- }), n.allEffects.add(i), i.run(), () => {
433
- Array.from(i.cleanups).forEach((e) => {
434
- try {
435
- e();
436
- } catch {}
437
- }), i.cleanups.clear(), n.pendingEffects.delete(i), n.allEffects.delete(i);
438
- };
439
- }
440
- flushEffects() {
441
- this.batchDepth > 0 || this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => {
442
- this.isFlushScheduled = !1;
443
- let e = 0;
444
- for (; this.pendingEffects.size > 0 && e < 100;) {
445
- e++;
446
- let t = Array.from(this.pendingEffects).sort((e, t) => this.getNodeDepth(e) - this.getNodeDepth(t) || e.id - t.id);
447
- this.pendingEffects.clear(), t.forEach((e) => {
448
- try {
449
- e.run();
450
- } catch (e) {
451
- console.error("[Reactive Engine Automatic: Effect Error]", e);
452
- }
453
- });
454
- }
455
- e >= 100 && console.warn("[Reactive Engine Automatic] Превышен лимит схождения графа. Обнаружен бесконечный цикл мутаций.");
456
- }));
457
- }
458
- }, r = class extends n {
459
- autoLogQueue = [];
460
- isHardFlushScheduled = !1;
461
- constructor(e) {
462
- let t = {
463
- ...e,
464
- logger: {
465
- isEnabled: !0,
466
- traceTime: !0,
467
- isCoreOptimizationDebugEnabled: !0,
468
- instanceName: e?.logger?.instanceName || "AUTOMATIC_HARD_CORE",
469
- filter: e?.logger?.filter
470
- }
471
- };
472
- super(t), this.frameworkPrefix = "auto-hard-core";
473
- }
474
- queueLog(e, t, n) {
475
- this.autoLogQueue.push({
476
- type: e,
477
- name: t,
478
- detail: n
479
- });
480
- }
481
- flushLogs() {
482
- if (this.autoLogQueue.length === 0) return;
483
- let e = {
484
- signal: "background: #007acc; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
485
- computed: "background: #42b883; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
486
- effect: "background: #e01e5a; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
487
- batch: "background: #7952b3; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
488
- resource: "background: #d97706; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;",
489
- reactive: "background: #007acc; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;"
490
- };
491
- console.groupCollapsed(`%cREACTIVE TRANSACTION [${this.frameworkPrefix.toUpperCase()}]%c Microtask Tick (Size: ${this.autoLogQueue.length})`, "background: #7952b3; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: bold;", "color: #aaa; font-weight: normal;"), this.autoLogQueue.forEach((t) => {
492
- let n = "";
493
- if (t.type === "signal") {
494
- let e = t.detail;
495
- n = ` 🔄 Изменение: [${String(e.from)} -> ${String(e.to)}]`;
496
- } else if (t.type === "computed") n = ` 🧮 Расчет кэша (${t.detail.duration})`;
497
- else if (t.type === "effect") {
498
- let e = t.detail;
499
- n = e?.isTriggered ? ` ⚡️ Ререндер/Вызов (${e.duration || "0ms"})` : " 🟢 Инициализация подписки";
500
- } else if (t.type === "resource") {
501
- let e = t.detail;
502
- n = e.loading ? " ⏳ ЗАГРУЗКА СЕТИ" : e.error ? " 🔴 ОШИБКА" : " 🟢 УСПЕШНО ОТВЕТИЛ";
503
- }
504
- console.groupCollapsed(`%c${t.type.toUpperCase()}%c [${t.name}]%c${n}`, e[t.type] || e.signal, "color: #aaa; font-weight: bold;", "color: #42b883; font-weight: bold;"), console.log("Детали операции:", t.detail), console.groupEnd();
505
- }), console.groupEnd(), this.autoLogQueue = [];
506
- }
507
- flushEffects() {
508
- this.batchDepth > 0 || this.isHardFlushScheduled || (this.isHardFlushScheduled = !0, queueMicrotask(() => {
509
- this.isHardFlushScheduled = !1, this.flushLogs(), super.flushEffects();
510
- }));
511
- }
512
- effect(e, t) {
513
- let n = this, r = t || "unnamed_effect", i = !0;
514
- n.queueLog("effect", r, {
515
- isTriggered: !1,
516
- phase: "mount"
517
- });
518
- let a = {
519
- id: ++n.subscriberId,
520
- label: r,
521
- cleanups: /* @__PURE__ */ new Set(),
522
- markDirty() {
523
- n.pendingEffects.add(a), n.flushEffects();
524
- },
525
- run() {
526
- let t = typeof performance < "u" ? performance.now() : 0, o = Array.from(a.cleanups);
527
- a.cleanups.clear(), o.forEach((e) => {
528
- try {
529
- e();
530
- } catch (e) {
531
- console.error("[Reactive Engine:Cleanup Error]", e);
532
- }
533
- });
534
- let s = n.activeConsumer;
535
- n.activeConsumer = a;
536
- try {
537
- let t = e();
538
- typeof t == "function" && a.cleanups.add(t);
539
- } finally {
540
- if (n.activeConsumer = s, !i && t && typeof n.queueLog == "function") {
541
- let e = performance.now() - t;
542
- n.queueLog("effect", r, {
543
- isTriggered: !0,
544
- phase: "update",
545
- duration: `${e.toFixed(3)}ms`
546
- });
547
- }
548
- i = !1;
549
- }
550
- }
551
- };
552
- return n.allEffects.add(a), a.run(), () => {
553
- Array.from(a.cleanups).forEach((e) => {
554
- try {
555
- e();
556
- } catch (e) {
557
- console.error("[Reactive Engine:Dispose Cleanup Error]", e);
558
- }
559
- }), a.cleanups.clear(), n.pendingEffects.delete(a), n.allEffects.delete(a), n.queueLog("effect", r, { phase: "unmount" });
560
- };
561
- }
562
- resource(e, t, n) {
563
- let r = n && typeof n == "object" ? n.name : n || "unnamed_resource", i = this;
564
- return super.resource(async (t, n) => {
565
- i.queueLog("resource", r, {
566
- loading: !0,
567
- error: null,
568
- data: null
569
- });
570
- try {
571
- let a = await e(t, n);
572
- return i.queueLog("resource", r, {
573
- loading: !1,
574
- error: null,
575
- data: a
576
- }), a;
577
- } catch (e) {
578
- throw i.queueLog("resource", r, {
579
- loading: !1,
580
- error: e,
581
- data: null
582
- }), e;
583
- }
584
- }, t, n);
585
- }
586
- reactive(e, t = "reactive") {
587
- let n = this, r = super.reactive(e, t);
588
- return new Proxy(r, {
589
- get(e, r, i) {
590
- let a = Reflect.get(e, r, i);
591
- return typeof a == "object" && a ? n.reactive(a, `${t}.${String(r)}`) : a;
592
- },
593
- set(e, r, i, a) {
594
- let o = Reflect.get(e, r, a);
595
- return o === i ? !0 : (n.queueLog("signal", `${t}.${String(r)}`, {
596
- from: o,
597
- to: i,
598
- subscribersCount: 0,
599
- subscribers: ["framework-reactive-proxy-subscriber"]
600
- }), Reflect.set(e, r, i, a));
601
- }
602
- });
603
- }
604
- signal(e, t) {
605
- let n = this, r = (typeof t == "string" ? { name: t } : t || {}).name || "unnamed_signal", i = super.signal(e, t);
606
- return {
607
- get value() {
608
- return i.value;
609
- },
610
- set value(e) {
611
- let t = i.value;
612
- if ((e === null || typeof e != "object" && typeof e != "function") && t === e) return;
613
- let a = n.activeConsumer, o = a && "label" in a && typeof a.label == "string" ? a.label : "unnamed_effect";
614
- n.queueLog("signal", r, {
615
- from: t,
616
- to: e,
617
- subscribersCount: 0,
618
- subscribers: [o]
619
- }), i.value = e;
620
- },
621
- subscribe(e) {
622
- return i.subscribe(e);
623
- }
624
- };
625
- }
626
- computed(e, t) {
627
- let n = this, r = t || "unnamed_computed", i = super.computed(e, t);
628
- return {
629
- get value() {
630
- let e = typeof performance < "u" ? performance.now() : 0, t = i.value;
631
- if (e) {
632
- let i = performance.now() - e;
633
- n.queueLog("computed", r, {
634
- value: t,
635
- duration: `${i.toFixed(3)}ms`
636
- });
637
- }
638
- return t;
316
+ refetch: () => {
317
+ p?.abort(), p = new AbortController(), f(n ? n.value : void 0, p.signal, !1);
639
318
  },
640
- subscribe: (e) => i.subscribe(e),
641
- destroy() {
642
- i.destroy();
643
- }
319
+ subscribe: (e) => u.subscribe(e)
644
320
  };
645
321
  }
646
322
  };
647
323
  //#endregion
648
- export { t as ReactiveEngine, n as ReactiveEngineAutomatic, r as ReactiveEngineAutomaticHard, e as ReactiveEngineCore };
324
+ export { f as ReactiveEngine, f as ReactiveEngineAutomatic, f as ReactiveEngineCore, d as flushLogs, u as queueLog };
649
325
 
650
326
  //# sourceMappingURL=core.mjs.map