@milaboratories/pl-tree 1.5.5 → 1.5.7
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/state.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ var d = (n, e, t) => M(n, typeof e != "symbol" ? e + "" : e, t);
|
|
|
4
4
|
import { resourceIdToString as R, resourceTypesEqual as A, resourceTypeToString as U, isNotNullResourceId as g, NullResourceId as T, isNullResourceId as b, stringifyWithResourceId as D, isTimeoutOrCancelError as J } from "@milaboratories/pl-client";
|
|
5
5
|
import { ChangeSource as m, PollingComputableHooks as q } from "@milaboratories/computable";
|
|
6
6
|
import { parsePlError as V } from "@milaboratories/pl-errors";
|
|
7
|
-
import { notEmpty as p,
|
|
8
|
-
import
|
|
9
|
-
import * as
|
|
10
|
-
function
|
|
7
|
+
import { notEmpty as p, deepFreeze as z, msToHumanReadable as H } from "@milaboratories/ts-helpers";
|
|
8
|
+
import j from "denque";
|
|
9
|
+
import * as Y from "node:timers/promises";
|
|
10
|
+
function ne(n, e) {
|
|
11
11
|
if (n !== void 0)
|
|
12
12
|
return P(n, e);
|
|
13
13
|
}
|
|
@@ -15,18 +15,18 @@ function P(n, e) {
|
|
|
15
15
|
const t = {};
|
|
16
16
|
return n.value !== void 0 && (t.value = e(n.value)), n.error !== void 0 && (t.error = e(n.error)), t;
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class oe extends Error {
|
|
19
19
|
constructor(e) {
|
|
20
20
|
super(e);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function ue(n) {
|
|
24
24
|
return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeEntry";
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function de(n) {
|
|
27
27
|
return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeEntryAccessor";
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function ce(n) {
|
|
30
30
|
return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeNodeAccessor";
|
|
31
31
|
}
|
|
32
32
|
class C {
|
|
@@ -48,7 +48,7 @@ class C {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
function N(n, e, t, r, s) {
|
|
51
|
-
const o = new
|
|
51
|
+
const o = new G(
|
|
52
52
|
n,
|
|
53
53
|
e,
|
|
54
54
|
e.get(t.ctx.watcher, r),
|
|
@@ -75,10 +75,10 @@ class E {
|
|
|
75
75
|
return this.instanceData.guard(), this.accessorData.hooks !== void 0 && this.instanceData.ctx.attacheHooks(this.accessorData.hooks), N(this.accessorData, this.tree, this.instanceData, this.rid, e);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function he(n, e) {
|
|
79
79
|
return n instanceof C ? e.accessor(n).node().resourceInfo : n;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class G {
|
|
82
82
|
constructor(e, t, r, s) {
|
|
83
83
|
d(this, "__pl_tree_type_marker__", "PlTreeNodeAccessor");
|
|
84
84
|
d(this, "onUnstableLambda", (e) => {
|
|
@@ -251,7 +251,7 @@ class $ {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
const L = 0, x = new TextDecoder();
|
|
254
|
-
class
|
|
254
|
+
class Q {
|
|
255
255
|
constructor(e, t) {
|
|
256
256
|
/** Tracks number of other resources referencing this resource. Used to perform garbage collection in tree patching procedure */
|
|
257
257
|
d(this, "refCount", 0);
|
|
@@ -398,7 +398,7 @@ class G {
|
|
|
398
398
|
}
|
|
399
399
|
getDataAsJson() {
|
|
400
400
|
if (this.data !== void 0)
|
|
401
|
-
return this.dataAsJson === void 0 && (this.dataAsJson = JSON.parse(this.getDataAsString())), this.dataAsJson;
|
|
401
|
+
return this.dataAsJson === void 0 && (this.dataAsJson = z(JSON.parse(this.getDataAsString()))), this.dataAsJson;
|
|
402
402
|
}
|
|
403
403
|
verifyReadyState() {
|
|
404
404
|
if (this.resourceReady && !this.inputsLocked)
|
|
@@ -517,7 +517,7 @@ class O {
|
|
|
517
517
|
}
|
|
518
518
|
k && p(i.kvChanged).markChanged(), h && (i.dataVersion = i.version, this.isFinalPredicate(i) && i.markFinal());
|
|
519
519
|
} else {
|
|
520
|
-
i = new
|
|
520
|
+
i = new Q(a), i.verifyReadyState(), g(i.error) && r.push(i.error);
|
|
521
521
|
for (const h of a.fields) {
|
|
522
522
|
const k = new $(
|
|
523
523
|
h.name,
|
|
@@ -575,7 +575,7 @@ class O {
|
|
|
575
575
|
return Array.from(this.resources.values()).map((e) => e.extendedState);
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function X(n, e) {
|
|
579
579
|
const t = [], r = /* @__PURE__ */ new Set();
|
|
580
580
|
return n.forEachResource((s) => {
|
|
581
581
|
s.finalState ? r.add(s.id) : t.push(s.id);
|
|
@@ -595,10 +595,10 @@ function F() {
|
|
|
595
595
|
millisSpent: 0
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
|
-
function
|
|
598
|
+
function le(n) {
|
|
599
599
|
let e = `Requests: ${n.requests}
|
|
600
600
|
`;
|
|
601
|
-
return e += `Total time: ${
|
|
601
|
+
return e += `Total time: ${H(n.millisSpent)}
|
|
602
602
|
`, e += `Round-trips: ${n.roundTrips}
|
|
603
603
|
`, e += `Resources: ${n.retrievedResources}
|
|
604
604
|
`, e += `Fields: ${n.retrievedFields}
|
|
@@ -608,11 +608,11 @@ function he(n) {
|
|
|
608
608
|
`, e += `Pruned fields: ${n.prunedFields}
|
|
609
609
|
`, e += `Final resources skipped: ${n.finalResourcesSkipped}`, e;
|
|
610
610
|
}
|
|
611
|
-
async function
|
|
611
|
+
async function Z(n, e, t) {
|
|
612
612
|
var c;
|
|
613
613
|
const r = Date.now();
|
|
614
614
|
t && t.requests++;
|
|
615
|
-
const { seedResources: s, finalResources: o, pruningFunction: a } = e, i = new
|
|
615
|
+
const { seedResources: s, finalResources: o, pruningFunction: a } = e, i = new j();
|
|
616
616
|
let f = !0, l = 0;
|
|
617
617
|
const h = /* @__PURE__ */ new Set(), k = (v) => {
|
|
618
618
|
if (b(v) || h.has(v)) return;
|
|
@@ -656,10 +656,10 @@ async function X(n, e, t) {
|
|
|
656
656
|
}
|
|
657
657
|
return t && (t.millisSpent += Date.now() - r, t.roundTrips += l), u;
|
|
658
658
|
}
|
|
659
|
-
function
|
|
659
|
+
function fe(n) {
|
|
660
660
|
return n;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function ge(n, e, t) {
|
|
663
663
|
var a;
|
|
664
664
|
const r = n instanceof C ? p(t).accessor(n).node() : n instanceof E ? n.node() : n, o = { ...r.resourceInfo };
|
|
665
665
|
if (e.data !== void 0 && (e.data === "raw" ? o.data = r.getData() : o.data = e.data.parse(r.getDataAsJson())), e.fields !== void 0) {
|
|
@@ -684,7 +684,7 @@ function fe(n, e, t) {
|
|
|
684
684
|
}
|
|
685
685
|
return o;
|
|
686
686
|
}
|
|
687
|
-
function
|
|
687
|
+
function pe(n, e, t) {
|
|
688
688
|
if (n instanceof C) {
|
|
689
689
|
const r = t.accessor(n).node(), s = r.resourceInfo, o = e.map((a) => {
|
|
690
690
|
var i, f;
|
|
@@ -701,7 +701,7 @@ function ge(n, e, t) {
|
|
|
701
701
|
}
|
|
702
702
|
return n;
|
|
703
703
|
}
|
|
704
|
-
function
|
|
704
|
+
function ve(n, e, t) {
|
|
705
705
|
if (!(n instanceof C)) return n;
|
|
706
706
|
const r = t.accessor(n).node(), s = r.resourceInfo, o = e.map((a) => [a, r.getKeyValue(a)]);
|
|
707
707
|
return {
|
|
@@ -763,7 +763,7 @@ class K {
|
|
|
763
763
|
/** Executed from the main loop, and initialization procedure. */
|
|
764
764
|
async refresh(e, t) {
|
|
765
765
|
if (this.terminated) throw new Error("tree synchronization is terminated");
|
|
766
|
-
const r =
|
|
766
|
+
const r = X(this.state, this.pruning), s = await this.pl.withReadTx("ReadingTree", async (o) => await Z(o, r, e), t);
|
|
767
767
|
this.state.updateFromResourceData(s, !0);
|
|
768
768
|
}
|
|
769
769
|
async mainLoop() {
|
|
@@ -783,7 +783,7 @@ class K {
|
|
|
783
783
|
}
|
|
784
784
|
if (!this.keepRunning || this.terminated) break;
|
|
785
785
|
try {
|
|
786
|
-
await
|
|
786
|
+
await Y.setTimeout(this.pollingInterval, this.abortController.signal);
|
|
787
787
|
} catch (o) {
|
|
788
788
|
if (!J(o)) throw new Error("Unexpected error", { cause: o });
|
|
789
789
|
break;
|
|
@@ -824,7 +824,7 @@ class K {
|
|
|
824
824
|
return o;
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function ye(n) {
|
|
828
828
|
var t;
|
|
829
829
|
const e = {
|
|
830
830
|
total: {
|
|
@@ -864,28 +864,28 @@ function ve(n) {
|
|
|
864
864
|
return e;
|
|
865
865
|
}
|
|
866
866
|
export {
|
|
867
|
-
|
|
867
|
+
oe as PlError,
|
|
868
868
|
C as PlTreeEntry,
|
|
869
869
|
E as PlTreeEntryAccessor,
|
|
870
|
-
|
|
871
|
-
|
|
870
|
+
G as PlTreeNodeAccessor,
|
|
871
|
+
Q as PlTreeResource,
|
|
872
872
|
O as PlTreeState,
|
|
873
873
|
K as SynchronizedTreeState,
|
|
874
874
|
S as TreeStateUpdateError,
|
|
875
|
-
|
|
876
|
-
|
|
875
|
+
X as constructTreeLoadingRequest,
|
|
876
|
+
le as formatTreeLoadingStat,
|
|
877
877
|
F as initialTreeLoadingStat,
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
878
|
+
ue as isPlTreeEntry,
|
|
879
|
+
de as isPlTreeEntryAccessor,
|
|
880
|
+
ce as isPlTreeNodeAccessor,
|
|
881
|
+
Z as loadTreeState,
|
|
882
|
+
ge as makeResourceSnapshot,
|
|
883
883
|
P as mapValueAndError,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
884
|
+
ne as mapValueAndErrorIfDefined,
|
|
885
|
+
fe as rsSchema,
|
|
886
|
+
ye as treeDumpStats,
|
|
887
|
+
he as treeEntryToResourceInfo,
|
|
888
|
+
pe as treeEntryToResourceWithData,
|
|
889
|
+
ve as treeEntryToResourceWithMetadata
|
|
890
890
|
};
|
|
891
891
|
//# sourceMappingURL=index.mjs.map
|