@pravosleva/reactive-engine 0.3.5-beta → 0.3.7-beta
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.
- package/README.md +12 -12
- package/dist/index.cjs +2 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +41 -7
- package/dist/index.iife.js +2 -7
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +78 -223
- package/dist/index.mjs.map +1 -1
- package/dist/mockServiceWorker.js +361 -0
- package/package.json +9 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import e, { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a, useSyncExternalStore as o } from "react";
|
|
2
|
-
//#region
|
|
3
|
-
var s =
|
|
4
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
5
|
-
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
6
|
-
}), l = class {
|
|
2
|
+
//#region src/BaseREService.ts
|
|
3
|
+
var s = class {
|
|
7
4
|
engine;
|
|
8
5
|
constructor(e) {
|
|
9
6
|
this.engine = e;
|
|
@@ -14,13 +11,13 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
14
11
|
validate: (e) => typeof e == "number" && !isNaN(e)
|
|
15
12
|
});
|
|
16
13
|
}
|
|
17
|
-
},
|
|
14
|
+
}, c = class {
|
|
18
15
|
engine;
|
|
19
16
|
constructor(e) {
|
|
20
17
|
this.engine = e, setTimeout(() => this.onInit(), 0);
|
|
21
18
|
}
|
|
22
19
|
onInit() {}
|
|
23
|
-
},
|
|
20
|
+
}, l = class {
|
|
24
21
|
activeEffect = null;
|
|
25
22
|
isBatching = !1;
|
|
26
23
|
pendingEffects = /* @__PURE__ */ new Set();
|
|
@@ -87,20 +84,21 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
87
84
|
}
|
|
88
85
|
};
|
|
89
86
|
}
|
|
90
|
-
effect(e) {
|
|
91
|
-
let
|
|
87
|
+
effect(e, t) {
|
|
88
|
+
let n = this, r = {
|
|
89
|
+
label: t,
|
|
92
90
|
cleanups: /* @__PURE__ */ new Set(),
|
|
93
91
|
run() {
|
|
94
92
|
this.cleanups.forEach((e) => e()), this.cleanups.clear();
|
|
95
|
-
let
|
|
96
|
-
|
|
93
|
+
let t = n.activeEffect;
|
|
94
|
+
n.activeEffect = this, n.safeRun(this, () => {
|
|
97
95
|
let t = e();
|
|
98
96
|
typeof t == "function" && this.cleanups.add(t);
|
|
99
|
-
}),
|
|
97
|
+
}), n.activeEffect = t;
|
|
100
98
|
}
|
|
101
99
|
};
|
|
102
|
-
return this.allEffects.add(
|
|
103
|
-
|
|
100
|
+
return this.allEffects.add(r), r.run(), () => {
|
|
101
|
+
r.cleanups.forEach((e) => e()), n.pendingEffects.delete(r), n.allEffects.delete(r);
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
104
|
computedCache = /* @__PURE__ */ new Map();
|
|
@@ -147,27 +145,40 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
147
145
|
e();
|
|
148
146
|
}
|
|
149
147
|
resource(e, t, n) {
|
|
150
|
-
let r = this.signal({
|
|
148
|
+
let r = n && typeof n == "object", i = r ? n.name : n || "unnamed_resource", a = r ? n : {}, o = a.resetDataOnSourceChange ?? !0, s = a.responseValidate, c = this.signal({
|
|
151
149
|
data: null,
|
|
152
150
|
loading: !0,
|
|
153
151
|
error: null
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
data:
|
|
152
|
+
}, i), l = null, u = async (t, n = !1) => {
|
|
153
|
+
l?.abort(), l = new AbortController();
|
|
154
|
+
let r = n && o ? null : this.untrack(() => c.value.data);
|
|
155
|
+
c.value = {
|
|
156
|
+
data: r,
|
|
159
157
|
loading: !0,
|
|
160
158
|
error: null
|
|
161
159
|
};
|
|
162
160
|
try {
|
|
163
|
-
let n = await e(t,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
let n = await e(t, l.signal);
|
|
162
|
+
if (!l.signal.aborted) {
|
|
163
|
+
if (s) {
|
|
164
|
+
let e = s(n);
|
|
165
|
+
if (e === !1 || typeof e == "string") {
|
|
166
|
+
c.value = {
|
|
167
|
+
data: null,
|
|
168
|
+
loading: !1,
|
|
169
|
+
error: Error(typeof e == "string" ? e : "Validation failed for response data")
|
|
170
|
+
};
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
c.value = {
|
|
175
|
+
data: n,
|
|
176
|
+
loading: !1,
|
|
177
|
+
error: null
|
|
178
|
+
};
|
|
179
|
+
}
|
|
169
180
|
} catch (e) {
|
|
170
|
-
e.name !== "AbortError" && (
|
|
181
|
+
e.name !== "AbortError" && (c.value = {
|
|
171
182
|
data: null,
|
|
172
183
|
loading: !1,
|
|
173
184
|
error: e
|
|
@@ -176,22 +187,22 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
176
187
|
};
|
|
177
188
|
return this.effect(() => {
|
|
178
189
|
let e = t ? t.value : void 0;
|
|
179
|
-
return
|
|
190
|
+
return u(e, !0), () => l?.abort();
|
|
180
191
|
}), {
|
|
181
192
|
get data() {
|
|
182
|
-
return
|
|
193
|
+
return c.value.data;
|
|
183
194
|
},
|
|
184
195
|
get loading() {
|
|
185
|
-
return
|
|
196
|
+
return c.value.loading;
|
|
186
197
|
},
|
|
187
198
|
get error() {
|
|
188
|
-
return
|
|
199
|
+
return c.value.error;
|
|
189
200
|
},
|
|
190
201
|
get value() {
|
|
191
|
-
return
|
|
202
|
+
return c.value;
|
|
192
203
|
},
|
|
193
|
-
refetch: () =>
|
|
194
|
-
subscribe: (e) =>
|
|
204
|
+
refetch: () => u(t ? t.value : void 0, !1),
|
|
205
|
+
subscribe: (e) => c.subscribe(e)
|
|
195
206
|
};
|
|
196
207
|
}
|
|
197
208
|
untrack(e) {
|
|
@@ -225,182 +236,7 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
225
236
|
console.error("%c[Reactive Error] %cОшибка в эффекте/computed:", "color: white; background: red; padding: 2px 4px; border-radius: 3px;", "font-weight: bold;", e);
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
|
-
},
|
|
229
|
-
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
230
|
-
function r(e, n, r) {
|
|
231
|
-
var i = null;
|
|
232
|
-
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
233
|
-
else r = n;
|
|
234
|
-
return n = r.ref, {
|
|
235
|
-
$$typeof: t,
|
|
236
|
-
type: e,
|
|
237
|
-
key: i,
|
|
238
|
-
ref: n === void 0 ? null : n,
|
|
239
|
-
props: r
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
243
|
-
})), p = /* @__PURE__ */ s(((e) => {
|
|
244
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
245
|
-
function t(e) {
|
|
246
|
-
if (e == null) return null;
|
|
247
|
-
if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
|
|
248
|
-
if (typeof e == "string") return e;
|
|
249
|
-
switch (e) {
|
|
250
|
-
case v: return "Fragment";
|
|
251
|
-
case b: return "Profiler";
|
|
252
|
-
case y: return "StrictMode";
|
|
253
|
-
case w: return "Suspense";
|
|
254
|
-
case T: return "SuspenseList";
|
|
255
|
-
case O: return "Activity";
|
|
256
|
-
}
|
|
257
|
-
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
258
|
-
case _: return "Portal";
|
|
259
|
-
case S: return e.displayName || "Context";
|
|
260
|
-
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
261
|
-
case C:
|
|
262
|
-
var n = e.render;
|
|
263
|
-
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
264
|
-
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
265
|
-
case D:
|
|
266
|
-
n = e._payload, e = e._init;
|
|
267
|
-
try {
|
|
268
|
-
return t(e(n));
|
|
269
|
-
} catch {}
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
function n(e) {
|
|
274
|
-
return "" + e;
|
|
275
|
-
}
|
|
276
|
-
function r(e) {
|
|
277
|
-
try {
|
|
278
|
-
n(e);
|
|
279
|
-
var t = !1;
|
|
280
|
-
} catch {
|
|
281
|
-
t = !0;
|
|
282
|
-
}
|
|
283
|
-
if (t) {
|
|
284
|
-
t = console;
|
|
285
|
-
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
286
|
-
return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
function i(e) {
|
|
290
|
-
if (e === v) return "<>";
|
|
291
|
-
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
292
|
-
try {
|
|
293
|
-
var n = t(e);
|
|
294
|
-
return n ? "<" + n + ">" : "<...>";
|
|
295
|
-
} catch {
|
|
296
|
-
return "<...>";
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function a() {
|
|
300
|
-
var e = A.A;
|
|
301
|
-
return e === null ? null : e.getOwner();
|
|
302
|
-
}
|
|
303
|
-
function o() {
|
|
304
|
-
return Error("react-stack-top-frame");
|
|
305
|
-
}
|
|
306
|
-
function s(e) {
|
|
307
|
-
if (j.call(e, "key")) {
|
|
308
|
-
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
309
|
-
if (t && t.isReactWarning) return !1;
|
|
310
|
-
}
|
|
311
|
-
return e.key !== void 0;
|
|
312
|
-
}
|
|
313
|
-
function l(e, t) {
|
|
314
|
-
function n() {
|
|
315
|
-
P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
316
|
-
}
|
|
317
|
-
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
318
|
-
get: n,
|
|
319
|
-
configurable: !0
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
function u() {
|
|
323
|
-
var e = t(this.type);
|
|
324
|
-
return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
325
|
-
}
|
|
326
|
-
function d(e, t, n, r, i, a) {
|
|
327
|
-
var o = n.ref;
|
|
328
|
-
return e = {
|
|
329
|
-
$$typeof: g,
|
|
330
|
-
type: e,
|
|
331
|
-
key: t,
|
|
332
|
-
props: n,
|
|
333
|
-
_owner: r
|
|
334
|
-
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
335
|
-
enumerable: !1,
|
|
336
|
-
value: null
|
|
337
|
-
}) : Object.defineProperty(e, "ref", {
|
|
338
|
-
enumerable: !1,
|
|
339
|
-
get: u
|
|
340
|
-
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
341
|
-
configurable: !1,
|
|
342
|
-
enumerable: !1,
|
|
343
|
-
writable: !0,
|
|
344
|
-
value: 0
|
|
345
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
346
|
-
configurable: !1,
|
|
347
|
-
enumerable: !1,
|
|
348
|
-
writable: !0,
|
|
349
|
-
value: null
|
|
350
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
351
|
-
configurable: !1,
|
|
352
|
-
enumerable: !1,
|
|
353
|
-
writable: !0,
|
|
354
|
-
value: i
|
|
355
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
356
|
-
configurable: !1,
|
|
357
|
-
enumerable: !1,
|
|
358
|
-
writable: !0,
|
|
359
|
-
value: a
|
|
360
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
361
|
-
}
|
|
362
|
-
function f(e, n, i, o, c, u) {
|
|
363
|
-
var f = n.children;
|
|
364
|
-
if (f !== void 0) if (o) if (M(f)) {
|
|
365
|
-
for (o = 0; o < f.length; o++) p(f[o]);
|
|
366
|
-
Object.freeze && Object.freeze(f);
|
|
367
|
-
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
368
|
-
else p(f);
|
|
369
|
-
if (j.call(n, "key")) {
|
|
370
|
-
f = t(e);
|
|
371
|
-
var m = Object.keys(n).filter(function(e) {
|
|
372
|
-
return e !== "key";
|
|
373
|
-
});
|
|
374
|
-
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
|
|
375
|
-
}
|
|
376
|
-
if (f = null, i !== void 0 && (r(i), f = "" + i), s(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
377
|
-
else i = n;
|
|
378
|
-
return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), c, u);
|
|
379
|
-
}
|
|
380
|
-
function p(e) {
|
|
381
|
-
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
382
|
-
}
|
|
383
|
-
function m(e) {
|
|
384
|
-
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
385
|
-
}
|
|
386
|
-
var h = c("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
387
|
-
return null;
|
|
388
|
-
};
|
|
389
|
-
h = { react_stack_bottom_frame: function(e) {
|
|
390
|
-
return e();
|
|
391
|
-
} };
|
|
392
|
-
var P, F = {}, I = h.react_stack_bottom_frame.bind(h, o)(), L = N(i(o)), R = {};
|
|
393
|
-
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
394
|
-
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
395
|
-
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
396
|
-
}, e.jsxs = function(e, t, n) {
|
|
397
|
-
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
398
|
-
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
399
|
-
};
|
|
400
|
-
})();
|
|
401
|
-
})), m = (/* @__PURE__ */ s(((e, t) => {
|
|
402
|
-
process.env.NODE_ENV === "production" ? t.exports = f() : t.exports = p();
|
|
403
|
-
})))(), h = (e) => ({ children: t }) => {
|
|
239
|
+
}, u = (e) => ({ children: t }) => {
|
|
404
240
|
let a = i(0), s = i(null), c = i(null), l = i(null), u = r(() => ({
|
|
405
241
|
subscribe(e) {
|
|
406
242
|
return s.current = e, () => {
|
|
@@ -427,16 +263,35 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
427
263
|
e.activeEffect = d;
|
|
428
264
|
}
|
|
429
265
|
return o(u.subscribe, u.getSnapshot), f;
|
|
430
|
-
},
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
266
|
+
}, d = (t) => (n) => {
|
|
267
|
+
let a = (a) => {
|
|
268
|
+
let s = i(0), c = t, l = "activeEffect" in c ? "activeEffect" : "_activeEffect", u = i(null), { subscribe: d, getSnapshot: f } = r(() => ({
|
|
269
|
+
subscribe: (e) => {
|
|
270
|
+
let n = t.effect(() => {
|
|
271
|
+
s.current++, e();
|
|
272
|
+
}), r = Array.from(c.allEffects || []);
|
|
273
|
+
return u.current = r[r.length - 1], () => {
|
|
274
|
+
n(), u.current = null;
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
getSnapshot: () => s.current
|
|
278
|
+
}), []);
|
|
279
|
+
o(d, f, f);
|
|
280
|
+
let p = {
|
|
281
|
+
cleanups: /* @__PURE__ */ new Set(),
|
|
282
|
+
run: () => {}
|
|
283
|
+
}, m = u.current || p, h = c[l];
|
|
284
|
+
c[l] = m;
|
|
285
|
+
let g = null;
|
|
286
|
+
try {
|
|
287
|
+
g = typeof n == "function" && !n.prototype?.isReactComponent ? n(a) : e.createElement(n, a);
|
|
288
|
+
} finally {
|
|
289
|
+
c[l] = h;
|
|
290
|
+
}
|
|
291
|
+
return g;
|
|
438
292
|
};
|
|
439
|
-
|
|
293
|
+
return a.displayName = `Observer(${n.displayName || n.name || "Component"})`, a;
|
|
294
|
+
}, f = (e, t = {}) => {
|
|
440
295
|
let n = t.ttl ?? 300 * 1e3, r = /* @__PURE__ */ new Map();
|
|
441
296
|
return async (t, i) => {
|
|
442
297
|
let a = typeof t == "object" && t ? JSON.stringify(t) : String(t), o = Date.now(), s = r.get(a);
|
|
@@ -447,19 +302,19 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
447
302
|
timestamp: Date.now()
|
|
448
303
|
}), c;
|
|
449
304
|
};
|
|
450
|
-
},
|
|
305
|
+
}, p = (e, t) => {
|
|
451
306
|
let r = i(t);
|
|
452
307
|
n(() => {
|
|
453
308
|
r.current = t;
|
|
454
309
|
}, [t]), n(() => e.subscribe((e) => {
|
|
455
310
|
r.current(e);
|
|
456
311
|
}), [e]);
|
|
457
|
-
},
|
|
312
|
+
}, m = (e) => {
|
|
458
313
|
let i = r(() => typeof e == "function" ? e() : e, [e]), a = t((e) => i.subscribe(e), [i]), s = t(() => i.value, [i]);
|
|
459
314
|
return n(() => () => {
|
|
460
315
|
i && typeof i.destroy == "function" && i.destroy();
|
|
461
316
|
}, [i]), o(a, s);
|
|
462
|
-
},
|
|
317
|
+
}, h = (e) => {
|
|
463
318
|
let t = r(() => typeof e == "function" ? e() : e, [e]), [o, s] = a(t.value), c = i(s);
|
|
464
319
|
return n(() => {
|
|
465
320
|
c.current = s;
|
|
@@ -474,6 +329,6 @@ var s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
474
329
|
}, [t]), o;
|
|
475
330
|
};
|
|
476
331
|
//#endregion
|
|
477
|
-
export {
|
|
332
|
+
export { s as BaseREService, c as BaseREServiceEnhanced, l as ReactiveEngine, d as createObserver, u as createObserverComponent, p as useReactiveSubscription, m as useReactiveValue, h as useReactiveValue0, f as withCache };
|
|
478
333
|
|
|
479
334
|
//# sourceMappingURL=index.mjs.map
|