@milaboratories/pl-tree 1.4.1 → 1.4.3

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.mjs CHANGED
@@ -1,32 +1,32 @@
1
- var J = Object.defineProperty;
2
- var q = (n, e, t) => e in n ? J(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var d = (n, e, t) => q(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { resourceIdToString as C, resourceTypeToString as A, resourceTypesEqual as $, isNotNullResourceId as g, NullResourceId as F, isNullResourceId as b, stringifyWithResourceId as L, isTimeoutOrCancelError as B } from "@milaboratories/pl-client";
5
- import { ChangeSource as m, PollingComputableHooks as M } from "@milaboratories/computable";
1
+ var U = Object.defineProperty;
2
+ var J = (a, e, t) => e in a ? U(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var d = (a, e, t) => J(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import { resourceIdToString as C, resourceTypeToString as A, resourceTypesEqual as $, isNotNullResourceId as g, NullResourceId as D, isNullResourceId as P, stringifyWithResourceId as L, isTimeoutOrCancelError as q } from "@milaboratories/pl-client";
5
+ import { ChangeSource as m, PollingComputableHooks as B } from "@milaboratories/computable";
6
6
  import { notEmpty as y, msToHumanReadable as z } from "@milaboratories/ts-helpers";
7
7
  import H from "denque";
8
8
  import * as j from "node:timers/promises";
9
- function se(n, e) {
10
- if (n !== void 0)
11
- return P(n, e);
9
+ function se(a, e) {
10
+ if (a !== void 0)
11
+ return b(a, e);
12
12
  }
13
- function P(n, e) {
13
+ function b(a, e) {
14
14
  const t = {};
15
- return n.value !== void 0 && (t.value = e(n.value)), n.error !== void 0 && (t.error = e(n.error)), t;
15
+ return a.value !== void 0 && (t.value = e(a.value)), a.error !== void 0 && (t.error = e(a.error)), t;
16
16
  }
17
17
  class N extends Error {
18
18
  constructor(e) {
19
19
  super(e);
20
20
  }
21
21
  }
22
- function ne(n) {
23
- return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeEntry";
22
+ function ae(a) {
23
+ return typeof a == "object" && a !== null && a.__pl_tree_type_marker__ === "PlTreeEntry";
24
24
  }
25
- function oe(n) {
26
- return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeEntryAccessor";
25
+ function ne(a) {
26
+ return typeof a == "object" && a !== null && a.__pl_tree_type_marker__ === "PlTreeEntryAccessor";
27
27
  }
28
- function ae(n) {
29
- return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeNodeAccessor";
28
+ function oe(a) {
29
+ return typeof a == "object" && a !== null && a.__pl_tree_type_marker__ === "PlTreeNodeAccessor";
30
30
  }
31
31
  class R {
32
32
  constructor(e, t) {
@@ -46,45 +46,45 @@ class R {
46
46
  return `[ENTRY:${C(this.rid)}]`;
47
47
  }
48
48
  }
49
- function K(n, e, t, r, s) {
50
- const a = new Y(
51
- n,
49
+ function K(a, e, t, i, s) {
50
+ const o = new Y(
51
+ a,
52
52
  e,
53
- e.get(t.ctx.watcher, r),
53
+ e.get(t.ctx.watcher, i),
54
54
  t
55
55
  );
56
56
  if (!s.ignoreError) {
57
- const o = a.getError();
58
- if (o !== void 0)
57
+ const n = o.getError();
58
+ if (n !== void 0)
59
59
  throw new N(
60
- `error encountered on resource ${C(a.id)} (${A(a.resourceType)}): ${o.getDataAsString()}`
60
+ `error encountered on resource ${C(o.id)} (${A(o.resourceType)}): ${n.getDataAsString()}`
61
61
  );
62
62
  }
63
- if (s.assertResourceType !== void 0 && (Array.isArray(s.assertResourceType) ? s.assertResourceType.findIndex((o) => $(o, a.resourceType)) === -1 : !$(s.assertResourceType, a.resourceType)))
63
+ if (s.assertResourceType !== void 0 && (Array.isArray(s.assertResourceType) ? s.assertResourceType.findIndex((n) => $(n, o.resourceType)) === -1 : !$(s.assertResourceType, o.resourceType)))
64
64
  throw new Error(
65
- `wrong resource type ${A(a.resourceType)} but expected ${s.assertResourceType}`
65
+ `wrong resource type ${A(o.resourceType)} but expected ${s.assertResourceType}`
66
66
  );
67
- return a;
67
+ return o;
68
68
  }
69
69
  class E {
70
- constructor(e, t, r, s) {
70
+ constructor(e, t, i, s) {
71
71
  d(this, "__pl_tree_type_marker__", "PlTreeEntryAccessor");
72
- this.accessorData = e, this.tree = t, this.rid = r, this.instanceData = s;
72
+ this.accessorData = e, this.tree = t, this.rid = i, this.instanceData = s;
73
73
  }
74
74
  node(e = {}) {
75
75
  return this.instanceData.guard(), this.accessorData.hooks !== void 0 && this.instanceData.ctx.attacheHooks(this.accessorData.hooks), K(this.accessorData, this.tree, this.instanceData, this.rid, e);
76
76
  }
77
77
  }
78
- function ue(n, e) {
79
- return n instanceof R ? e.accessor(n).node().resourceInfo : n;
78
+ function ue(a, e) {
79
+ return a instanceof R ? e.accessor(a).node().resourceInfo : a;
80
80
  }
81
81
  class Y {
82
- constructor(e, t, r, s) {
82
+ constructor(e, t, i, s) {
83
83
  d(this, "__pl_tree_type_marker__", "PlTreeNodeAccessor");
84
84
  d(this, "onUnstableLambda", (e) => {
85
85
  this.instanceData.ctx.markUnstable(e);
86
86
  });
87
- this.accessorData = e, this.tree = t, this.resource = r, this.instanceData = s;
87
+ this.accessorData = e, this.tree = t, this.resource = i, this.instanceData = s;
88
88
  }
89
89
  get id() {
90
90
  return this.instanceData.guard(), this.resource.id;
@@ -108,44 +108,44 @@ class Y {
108
108
  return this.traverseOrErrorWithCommon({}, ...e);
109
109
  }
110
110
  traverseWithCommon(e, ...t) {
111
- const r = this.traverseOrErrorWithCommon(e, ...t);
112
- if (r !== void 0) {
113
- if (!r.ok) throw new N(r.error);
114
- return r.value;
111
+ const i = this.traverseOrErrorWithCommon(e, ...t);
112
+ if (i !== void 0) {
113
+ if (!i.ok) throw new N(i.error);
114
+ return i.value;
115
115
  }
116
116
  }
117
117
  traverseOrErrorWithCommon(e, ...t) {
118
- let r = this;
118
+ let i = this;
119
119
  for (const s of t) {
120
- const a = typeof s == "string" ? {
120
+ const o = typeof s == "string" ? {
121
121
  ...e,
122
122
  field: s
123
- } : { ...e, ...s }, o = r.getField(s);
124
- if (o === void 0 || a.pureFieldErrorToUndefined && o.value === void 0 && o.error !== void 0)
123
+ } : { ...e, ...s }, n = i.getField(s);
124
+ if (n === void 0 || o.pureFieldErrorToUndefined && n.value === void 0 && n.error !== void 0)
125
125
  return;
126
- if ((!a.ignoreError || o.value === void 0) && o.error !== void 0)
126
+ if ((!o.ignoreError || n.value === void 0) && n.error !== void 0)
127
127
  return {
128
128
  ok: !1,
129
- error: `error in field ${a.field} of ${C(r.id)}: ${o.error.getDataAsString()}`
129
+ error: `error in field ${o.field} of ${C(i.id)}: ${n.error.getDataAsString()}`
130
130
  };
131
- if (o.value === void 0) {
132
- if (a.errorIfFieldNotSet)
131
+ if (n.value === void 0) {
132
+ if (o.errorIfFieldNotSet)
133
133
  return {
134
134
  ok: !1,
135
- error: `field have no assigned value ${a.field} of ${C(r.id)}`
135
+ error: `field have no assigned value ${o.field} of ${C(i.id)}`
136
136
  };
137
- this.onUnstableLambda("unpopulated_field:" + a.field);
137
+ this.onUnstableLambda("unpopulated_field:" + o.field);
138
138
  return;
139
139
  }
140
- r = o.value;
140
+ i = n.value;
141
141
  }
142
- return { ok: !0, value: r };
142
+ return { ok: !0, value: i };
143
143
  }
144
144
  getField(e) {
145
145
  this.instanceData.guard();
146
- const t = typeof e == "string" ? { field: e } : e, r = this.resource.getField(this.instanceData.ctx.watcher, t, this.onUnstableLambda);
147
- if (r !== void 0)
148
- return P(r, (s) => this.getResourceFromTree(s, { ignoreError: !0 }));
146
+ const t = typeof e == "string" ? { field: e } : e, i = this.resource.getField(this.instanceData.ctx.watcher, t, this.onUnstableLambda);
147
+ if (i !== void 0)
148
+ return b(i, (s) => this.getResourceFromTree(s, { ignoreError: !0 }));
149
149
  }
150
150
  getInputsLocked() {
151
151
  this.instanceData.guard();
@@ -191,8 +191,8 @@ class Y {
191
191
  }
192
192
  getKeyValue(e, t = !1) {
193
193
  this.instanceData.guard();
194
- const r = this.resource.getKeyValue(this.instanceData.ctx.watcher, e);
195
- return r === void 0 && t && this.instanceData.ctx.markUnstable("key_not_found_b:" + e), r;
194
+ const i = this.resource.getKeyValue(this.instanceData.ctx.watcher, e);
195
+ return i === void 0 && t && this.instanceData.ctx.markUnstable("key_not_found_b:" + e), i;
196
196
  }
197
197
  /** @deprecated */
198
198
  getKeyValueString(e) {
@@ -200,16 +200,16 @@ class Y {
200
200
  }
201
201
  getKeyValueAsString(e, t = !1) {
202
202
  this.instanceData.guard();
203
- const r = this.resource.getKeyValueString(this.instanceData.ctx.watcher, e);
204
- return r === void 0 && t && this.instanceData.ctx.markUnstable("key_not_found_s:" + e), r;
203
+ const i = this.resource.getKeyValueString(this.instanceData.ctx.watcher, e);
204
+ return i === void 0 && t && this.instanceData.ctx.markUnstable("key_not_found_s:" + e), i;
205
205
  }
206
206
  getKeyValueAsJson(e, t = !1) {
207
- const r = this.resource.getKeyValueString(this.instanceData.ctx.watcher, e);
208
- if (r === void 0) {
207
+ const i = this.resource.getKeyValueString(this.instanceData.ctx.watcher, e);
208
+ if (i === void 0) {
209
209
  t && this.instanceData.ctx.markUnstable("key_not_found_j:" + e);
210
210
  return;
211
211
  }
212
- return JSON.parse(r);
212
+ return JSON.parse(i);
213
213
  }
214
214
  /**
215
215
  * Can be used to passe a higher level accessor that will wrap the resource and throw its
@@ -229,9 +229,9 @@ class S extends Error {
229
229
  }
230
230
  }
231
231
  class x {
232
- constructor(e, t, r, s) {
232
+ constructor(e, t, i, s, o, n, r) {
233
233
  d(this, "change", new m());
234
- this.type = e, this.value = t, this.error = r, this.resourceVersion = s;
234
+ this.name = e, this.type = t, this.value = i, this.error = s, this.status = o, this.valueIsFinal = n, this.resourceVersion = r;
235
235
  }
236
236
  }
237
237
  const T = 0, O = new TextDecoder();
@@ -243,7 +243,7 @@ class G {
243
243
  d(this, "version", T);
244
244
  /** Set to resource version when resource state, or it's fields have changed */
245
245
  d(this, "dataVersion", T);
246
- d(this, "fields", /* @__PURE__ */ new Map());
246
+ d(this, "fieldsMap", /* @__PURE__ */ new Map());
247
247
  d(this, "kv", /* @__PURE__ */ new Map());
248
248
  d(this, "resourceRemoved", new m());
249
249
  // following change source are removed when resource is marked as final
@@ -266,8 +266,8 @@ class G {
266
266
  d(this, "outputsLocked");
267
267
  d(this, "resourceReady");
268
268
  d(this, "finalFlag");
269
- /** Set externally by the tree, using {@link FinalPredicate} */
270
- d(this, "_final", !1);
269
+ /** Set externally by the tree, using {@link FinalResourceDataPredicate} */
270
+ d(this, "_finalState", !1);
271
271
  d(this, "logger");
272
272
  this.id = e.id, this.originalResourceId = e.originalResourceId, this.kind = e.kind, this.type = e.type, this.data = e.data, this.error = e.error, this.inputsLocked = e.inputsLocked, this.outputsLocked = e.outputsLocked, this.resourceReady = e.resourceReady, this.finalFlag = e.final, this.logger = t;
273
273
  }
@@ -279,38 +279,44 @@ class G {
279
279
  this.logger !== void 0 && this.logger.warn(e);
280
280
  }
281
281
  get final() {
282
- return this._final;
282
+ return this.finalFlag;
283
+ }
284
+ get finalState() {
285
+ return this._finalState;
283
286
  }
284
- getField(e, t, r = () => {
287
+ get fields() {
288
+ return [...this.fieldsMap.values()];
289
+ }
290
+ getField(e, t, i = () => {
285
291
  }) {
286
- var o, i, l;
287
- const s = typeof t == "string" ? { field: t } : t, a = this.fields.get(s.field);
288
- if (a === void 0) {
292
+ var n, r, f;
293
+ const s = typeof t == "string" ? { field: t } : t, o = this.fieldsMap.get(s.field);
294
+ if (o === void 0) {
289
295
  if (s.errorIfFieldNotFound || s.errorIfFieldNotSet)
290
296
  throw new Error(
291
297
  `Field "${s.field}" not found in resource ${C(this.id)}`
292
298
  );
293
- if (!this.inputsLocked) (o = this.inputAndServiceFieldListChanged) == null || o.attachWatcher(e);
299
+ if (!this.inputsLocked) (n = this.inputAndServiceFieldListChanged) == null || n.attachWatcher(e);
294
300
  else if (s.assertFieldType === "Service" || s.assertFieldType === "Input") {
295
301
  if (s.allowPermanentAbsence)
296
302
  return;
297
303
  throw new Error(`Service or input field not found ${s.field}.`);
298
304
  }
299
- if (!this.outputsLocked) (i = this.outputFieldListChanged) == null || i.attachWatcher(e);
305
+ if (!this.outputsLocked) (r = this.outputFieldListChanged) == null || r.attachWatcher(e);
300
306
  else if (s.assertFieldType === "Output") {
301
307
  if (s.allowPermanentAbsence)
302
308
  return;
303
309
  throw new Error(`Output field not found ${s.field}.`);
304
310
  }
305
- (l = this.dynamicFieldListChanged) == null || l.attachWatcher(e), !this._final && !s.stableIfNotFound && r("field_not_found:" + s.field);
311
+ (f = this.dynamicFieldListChanged) == null || f.attachWatcher(e), !this._finalState && !s.stableIfNotFound && i("field_not_found:" + s.field);
306
312
  return;
307
313
  } else {
308
- if (s.assertFieldType !== void 0 && a.type !== s.assertFieldType)
314
+ if (s.assertFieldType !== void 0 && o.type !== s.assertFieldType)
309
315
  throw new Error(
310
- `Unexpected field type: expected ${s.assertFieldType} but got ${a.type} for the field name ${s.field}`
316
+ `Unexpected field type: expected ${s.assertFieldType} but got ${o.type} for the field name ${s.field}`
311
317
  );
312
- const c = {};
313
- return g(a.value) && (c.value = a.value), g(a.error) && (c.error = a.error), c.value === void 0 && c.error === void 0 && r("field_not_resolved:" + s.field), a.change.attachWatcher(e), c;
318
+ const l = {};
319
+ return g(o.value) && (l.value = o.value), g(o.error) && (l.error = o.error), l.value === void 0 && l.error === void 0 && i("field_not_resolved:" + s.field), o.change.attachWatcher(e), l;
314
320
  }
315
321
  }
316
322
  getInputsLocked(e) {
@@ -322,11 +328,11 @@ class G {
322
328
  return this.outputsLocked || (t = this.resourceStateChange) == null || t.attachWatcher(e), this.outputsLocked;
323
329
  }
324
330
  get isReadyOrError() {
325
- return this.error !== F || this.resourceReady || this.originalResourceId !== F;
331
+ return this.error !== D || this.resourceReady || this.originalResourceId !== D;
326
332
  }
327
333
  getIsFinal(e) {
328
334
  var t;
329
- return (t = this.finalChanged) == null || t.attachWatcher(e), this._final;
335
+ return (t = this.finalChanged) == null || t.attachWatcher(e), this._finalState;
330
336
  }
331
337
  getIsReadyOrError(e) {
332
338
  var t;
@@ -334,41 +340,41 @@ class G {
334
340
  }
335
341
  getError(e) {
336
342
  var t;
337
- if (b(this.error)) {
343
+ if (P(this.error)) {
338
344
  (t = this.resourceStateChange) == null || t.attachWatcher(e);
339
345
  return;
340
346
  } else
341
347
  return this.error;
342
348
  }
343
349
  listInputFields(e) {
344
- var r;
350
+ var i;
345
351
  const t = [];
346
- return this.fields.forEach((s, a) => {
347
- (s.type === "Input" || s.type === "Service") && t.push(a);
348
- }), this.inputsLocked || (r = this.inputAndServiceFieldListChanged) == null || r.attachWatcher(e), t;
352
+ return this.fieldsMap.forEach((s, o) => {
353
+ (s.type === "Input" || s.type === "Service") && t.push(o);
354
+ }), this.inputsLocked || (i = this.inputAndServiceFieldListChanged) == null || i.attachWatcher(e), t;
349
355
  }
350
356
  listOutputFields(e) {
351
- var r;
357
+ var i;
352
358
  const t = [];
353
- return this.fields.forEach((s, a) => {
354
- s.type === "Output" && t.push(a);
355
- }), this.outputsLocked || (r = this.outputFieldListChanged) == null || r.attachWatcher(e), t;
359
+ return this.fieldsMap.forEach((s, o) => {
360
+ s.type === "Output" && t.push(o);
361
+ }), this.outputsLocked || (i = this.outputFieldListChanged) == null || i.attachWatcher(e), t;
356
362
  }
357
363
  listDynamicFields(e) {
358
- var r;
364
+ var i;
359
365
  const t = [];
360
- return this.fields.forEach((s, a) => {
361
- s.type !== "Input" && s.type !== "Output" && t.push(a);
362
- }), (r = this.dynamicFieldListChanged) == null || r.attachWatcher(e), t;
366
+ return this.fieldsMap.forEach((s, o) => {
367
+ s.type !== "Input" && s.type !== "Output" && t.push(o);
368
+ }), (i = this.dynamicFieldListChanged) == null || i.attachWatcher(e), t;
363
369
  }
364
370
  getKeyValue(e, t) {
365
- var r;
366
- return (r = this.kvChanged) == null || r.attachWatcher(e), this.kv.get(t);
371
+ var i;
372
+ return (i = this.kvChanged) == null || i.attachWatcher(e), this.kv.get(t);
367
373
  }
368
374
  getKeyValueString(e, t) {
369
- const r = this.getKeyValue(e, t);
370
- if (r !== void 0)
371
- return O.decode(r);
375
+ const i = this.getKeyValue(e, t);
376
+ if (i !== void 0)
377
+ return O.decode(i);
372
378
  }
373
379
  getDataAsString() {
374
380
  if (this.data !== void 0)
@@ -396,17 +402,18 @@ class G {
396
402
  final: this.finalFlag
397
403
  };
398
404
  }
405
+ /** Called when {@link FinalResourceDataPredicate} returns true for the state. */
399
406
  markFinal() {
400
- this._final || (this._final = !0, y(this.finalChanged).markChanged(), this.finalChanged = void 0, this.resourceStateChange = void 0, this.dynamicFieldListChanged = void 0, this.inputAndServiceFieldListChanged = void 0, this.outputFieldListChanged = void 0, this.lockedChange = void 0);
407
+ this._finalState || (this._finalState = !0, y(this.finalChanged).markChanged(), this.finalChanged = void 0, this.resourceStateChange = void 0, this.dynamicFieldListChanged = void 0, this.inputAndServiceFieldListChanged = void 0, this.outputFieldListChanged = void 0, this.lockedChange = void 0);
401
408
  }
402
409
  /** Used for invalidation */
403
410
  markAllChanged() {
404
- var e, t, r, s, a, o, i;
405
- this.fields.forEach((l) => l.change.markChanged()), (e = this.finalChanged) == null || e.markChanged(), (t = this.resourceStateChange) == null || t.markChanged(), (r = this.lockedChange) == null || r.markChanged(), (s = this.inputAndServiceFieldListChanged) == null || s.markChanged(), (a = this.outputFieldListChanged) == null || a.markChanged(), (o = this.dynamicFieldListChanged) == null || o.markChanged(), (i = this.kvChanged) == null || i.markChanged(), this.resourceRemoved.markChanged();
411
+ var e, t, i, s, o, n, r;
412
+ this.fieldsMap.forEach((f) => f.change.markChanged()), (e = this.finalChanged) == null || e.markChanged(), (t = this.resourceStateChange) == null || t.markChanged(), (i = this.lockedChange) == null || i.markChanged(), (s = this.inputAndServiceFieldListChanged) == null || s.markChanged(), (o = this.outputFieldListChanged) == null || o.markChanged(), (n = this.dynamicFieldListChanged) == null || n.markChanged(), (r = this.kvChanged) == null || r.markChanged(), this.resourceRemoved.markChanged();
406
413
  }
407
414
  }
408
415
  class V {
409
- constructor(e, t = (r) => !1) {
416
+ constructor(e, t) {
410
417
  /** resource heap */
411
418
  d(this, "resources", /* @__PURE__ */ new Map());
412
419
  d(this, "resourcesAdded", new m());
@@ -424,93 +431,109 @@ class V {
424
431
  }
425
432
  get(e, t) {
426
433
  this.checkValid();
427
- const r = this.resources.get(t);
428
- if (r === void 0)
434
+ const i = this.resources.get(t);
435
+ if (i === void 0)
429
436
  throw this.resourcesAdded.attachWatcher(e), new Error(`resource ${C(t)} not found in the tree`);
430
- return r.resourceRemoved.attachWatcher(e), r;
437
+ return i.resourceRemoved.attachWatcher(e), i;
431
438
  }
432
439
  updateFromResourceData(e, t = !1) {
433
440
  this.checkValid();
434
- const r = [], s = [];
435
- for (const o of e) {
436
- let i = this.resources.get(o.id);
437
- const l = i == null ? void 0 : i.state, c = (f) => {
438
- const { fields: k, ...u } = o;
441
+ const i = [], s = [];
442
+ for (const n of e) {
443
+ let r = this.resources.get(n.id);
444
+ const f = r == null ? void 0 : r.state, l = (h) => {
445
+ const { fields: k, ...u } = n;
439
446
  throw this.invalidateTree(), new S(
440
- `Unexpected resource state transition (${f}): ${L(
447
+ `Unexpected resource state transition (${h}): ${L(
441
448
  u
442
- )} -> ${L(l)}`
449
+ )} -> ${L(f)}`
443
450
  );
444
451
  };
445
- if (i !== void 0) {
446
- i.final && c("resource state can be updated after it is marked as final");
447
- let f = !1;
448
- i.version += 1, i.originalResourceId !== o.originalResourceId && (i.originalResourceId !== F && c("originalResourceId can't change after it is set"), i.originalResourceId = o.originalResourceId, y(i.resourceStateChange).markChanged(), f = !0), i.error !== o.error && (g(i.error) && c("resource can't change attached error after it is set"), i.error = o.error, r.push(i.error), y(i.resourceStateChange).markChanged(), f = !0);
449
- for (const u of o.fields) {
450
- let h = i.fields.get(u.name);
451
- h ? (h.type !== u.type && (h.type !== "Dynamic" && c(`field changed type ${h.type} -> ${u.type}`), y(i.dynamicFieldListChanged).markChanged(), (h.type === "Input" || h.type === "Service") && (i.inputsLocked && c(
452
+ if (r !== void 0) {
453
+ r.finalState && l("resource state can be updated after it is marked as final");
454
+ let h = !1;
455
+ r.version += 1, r.originalResourceId !== n.originalResourceId && (r.originalResourceId !== D && l("originalResourceId can't change after it is set"), r.originalResourceId = n.originalResourceId, y(r.resourceStateChange).markChanged(), h = !0), r.error !== n.error && (g(r.error) && l("resource can't change attached error after it is set"), r.error = n.error, i.push(r.error), y(r.resourceStateChange).markChanged(), h = !0);
456
+ for (const u of n.fields) {
457
+ let c = r.fieldsMap.get(u.name);
458
+ c ? (c.type !== u.type && (c.type !== "Dynamic" && l(`field changed type ${c.type} -> ${u.type}`), y(r.dynamicFieldListChanged).markChanged(), (c.type === "Input" || c.type === "Service") && (r.inputsLocked && l(
452
459
  `adding input field "${u.name}", while corresponding list is locked`
453
- ), y(i.inputAndServiceFieldListChanged).markChanged()), h.type === "Output" && (i.outputsLocked && c(
460
+ ), y(r.inputAndServiceFieldListChanged).markChanged()), c.type === "Output" && (r.outputsLocked && l(
454
461
  `adding output field "${u.name}", while corresponding list is locked`
455
- ), y(i.outputFieldListChanged).markChanged()), h.type = u.type, h.change.markChanged(), f = !0), h.value !== u.value && (g(h.value) && s.push(h.value), h.value = u.value, g(u.value) && r.push(u.value), h.change.markChanged(), f = !0), h.error !== u.error && (g(h.error) && s.push(h.error), h.error = u.error, g(u.error) && r.push(u.error), h.change.markChanged(), f = !0), h.resourceVersion = i.version) : (h = new x(u.type, u.value, u.error, i.version), g(u.value) && r.push(u.value), g(u.error) && r.push(u.error), u.type === "Input" || u.type === "Service" ? (i.inputsLocked && c(
462
+ ), y(r.outputFieldListChanged).markChanged()), c.type = u.type, c.change.markChanged(), h = !0), c.value !== u.value && (g(c.value) && s.push(c.value), c.value = u.value, g(u.value) && i.push(u.value), c.change.markChanged(), h = !0), c.error !== u.error && (g(c.error) && s.push(c.error), c.error = u.error, g(u.error) && i.push(u.error), c.change.markChanged(), h = !0), c.status !== u.status && (c.status = u.status, c.change.markChanged(), h = !0), c.valueIsFinal !== u.valueIsFinal && (c.valueIsFinal = u.valueIsFinal, c.change.markChanged(), h = !0), c.resourceVersion = r.version) : (c = new x(
463
+ u.name,
464
+ u.type,
465
+ u.value,
466
+ u.error,
467
+ u.status,
468
+ u.valueIsFinal,
469
+ r.version
470
+ ), g(u.value) && i.push(u.value), g(u.error) && i.push(u.error), u.type === "Input" || u.type === "Service" ? (r.inputsLocked && l(
456
471
  `adding ${u.type} (${u.name}) field while inputs locked`
457
- ), y(i.inputAndServiceFieldListChanged).markChanged()) : u.type === "Output" ? (i.outputsLocked && c(
472
+ ), y(r.inputAndServiceFieldListChanged).markChanged()) : u.type === "Output" ? (r.outputsLocked && l(
458
473
  `adding ${u.type} (${u.name}) field while outputs locked`
459
- ), y(i.outputFieldListChanged).markChanged()) : y(i.dynamicFieldListChanged).markChanged(), i.fields.set(u.name, h), f = !0);
474
+ ), y(r.outputFieldListChanged).markChanged()) : y(r.dynamicFieldListChanged).markChanged(), r.fieldsMap.set(u.name, c), h = !0);
460
475
  }
461
- if (i.fields.forEach((u, h, p) => {
462
- u.resourceVersion !== i.version && ((u.type === "Input" || u.type === "Service" || u.type === "Output") && c(`removal of ${u.type} field ${h}`), u.change.markChanged(), p.delete(h), g(u.value) && s.push(u.value), g(u.error) && s.push(u.error), y(i.dynamicFieldListChanged).markChanged());
463
- }), i.inputsLocked !== o.inputsLocked && (i.inputsLocked && c("inputs unlocking is not permitted"), i.inputsLocked = o.inputsLocked, y(i.lockedChange).markChanged(), f = !0), i.outputsLocked !== o.outputsLocked && (i.outputsLocked && c("outputs unlocking is not permitted"), i.outputsLocked = o.outputsLocked, y(i.lockedChange).markChanged(), f = !0), i.resourceReady !== o.resourceReady) {
464
- const u = i.resourceReady;
465
- i.resourceReady = o.resourceReady, i.verifyReadyState(), i.isReadyOrError || c(
476
+ if (r.fieldsMap.forEach((u, c, p) => {
477
+ u.resourceVersion !== r.version && ((u.type === "Input" || u.type === "Service" || u.type === "Output") && l(`removal of ${u.type} field ${c}`), u.change.markChanged(), p.delete(c), g(u.value) && s.push(u.value), g(u.error) && s.push(u.error), y(r.dynamicFieldListChanged).markChanged());
478
+ }), r.inputsLocked !== n.inputsLocked && (r.inputsLocked && l("inputs unlocking is not permitted"), r.inputsLocked = n.inputsLocked, y(r.lockedChange).markChanged(), h = !0), r.outputsLocked !== n.outputsLocked && (r.outputsLocked && l("outputs unlocking is not permitted"), r.outputsLocked = n.outputsLocked, y(r.lockedChange).markChanged(), h = !0), r.resourceReady !== n.resourceReady) {
479
+ const u = r.resourceReady;
480
+ r.resourceReady = n.resourceReady, r.verifyReadyState(), r.isReadyOrError || l(
466
481
  `resource can't lose it's ready or error state (ready state before ${u})`
467
- ), y(i.resourceStateChange).markChanged(), f = !0;
482
+ ), y(r.resourceStateChange).markChanged(), h = !0;
468
483
  }
469
484
  let k = !1;
470
- for (const u of o.kv) {
471
- const h = i.kv.get(u.key);
472
- (h === void 0 || Buffer.compare(h, u.value) !== 0) && (i.kv.set(u.key, u.value), k = !0);
485
+ for (const u of n.kv) {
486
+ const c = r.kv.get(u.key);
487
+ (c === void 0 || Buffer.compare(c, u.value) !== 0) && (r.kv.set(u.key, u.value), k = !0);
473
488
  }
474
- if (i.kv.size > o.kv.length) {
475
- const u = new Set(o.kv.map((h) => h.key));
476
- i.kv.forEach((h, p, v) => {
489
+ if (r.kv.size > n.kv.length) {
490
+ const u = new Set(n.kv.map((c) => c.key));
491
+ r.kv.forEach((c, p, v) => {
477
492
  u.has(p) || v.delete(p);
478
493
  }), k = !0;
479
494
  }
480
- k && y(i.kvChanged).markChanged(), f && (i.dataVersion = i.version, this.isFinalPredicate(i) && i.markFinal());
495
+ k && y(r.kvChanged).markChanged(), h && (r.dataVersion = r.version, this.isFinalPredicate(r) && r.markFinal());
481
496
  } else {
482
- i = new G(o), i.verifyReadyState(), g(i.error) && r.push(i.error);
483
- for (const f of o.fields) {
484
- const k = new x(f.type, f.value, f.error, T);
485
- g(f.value) && r.push(f.value), g(f.error) && r.push(f.error), i.fields.set(f.name, k);
497
+ r = new G(n), r.verifyReadyState(), g(r.error) && i.push(r.error);
498
+ for (const h of n.fields) {
499
+ const k = new x(
500
+ h.name,
501
+ h.type,
502
+ h.value,
503
+ h.error,
504
+ h.status,
505
+ h.valueIsFinal,
506
+ T
507
+ );
508
+ g(h.value) && i.push(h.value), g(h.error) && i.push(h.error), r.fieldsMap.set(h.name, k);
486
509
  }
487
- for (const f of o.kv) i.kv.set(f.key, f.value);
488
- this.isFinalPredicate(i) && i.markFinal(), this.resources.set(i.id, i), this.resourcesAdded.markChanged();
510
+ for (const h of n.kv) r.kv.set(h.key, h.value);
511
+ this.isFinalPredicate(r) && r.markFinal(), this.resources.set(r.id, r), this.resourcesAdded.markChanged();
489
512
  }
490
513
  }
491
- for (const o of r) {
492
- const i = this.resources.get(o);
493
- if (!i)
494
- throw this.invalidateTree(), new S(`orphan resource ${o}`);
495
- i.refCount++;
514
+ for (const n of i) {
515
+ const r = this.resources.get(n);
516
+ if (!r)
517
+ throw this.invalidateTree(), new S(`orphan resource ${n}`);
518
+ r.refCount++;
496
519
  }
497
- let a = s;
498
- for (; a.length > 0; ) {
499
- const o = [];
500
- for (const i of a) {
501
- const l = this.resources.get(i);
502
- if (!l)
503
- throw this.invalidateTree(), new S(`orphan resource ${i}`);
504
- l.refCount--, l.refCount === 0 && l.id !== this.root && (l.fields.forEach((c) => {
505
- g(c.value) && o.push(c.value), g(c.error) && o.push(c.error), c.change.markChanged();
506
- }), g(l.error) && o.push(l.error), l.resourceRemoved.markChanged(), this.resources.delete(i));
520
+ let o = s;
521
+ for (; o.length > 0; ) {
522
+ const n = [];
523
+ for (const r of o) {
524
+ const f = this.resources.get(r);
525
+ if (!f)
526
+ throw this.invalidateTree(), new S(`orphan resource ${r}`);
527
+ f.refCount--, f.refCount === 0 && f.id !== this.root && (f.fieldsMap.forEach((l) => {
528
+ g(l.value) && n.push(l.value), g(l.error) && n.push(l.error), l.change.markChanged();
529
+ }), g(f.error) && n.push(f.error), f.resourceRemoved.markChanged(), this.resources.delete(r));
507
530
  }
508
- a = o;
531
+ o = n;
509
532
  }
510
533
  if (!t) {
511
- for (const o of e)
512
- if (!this.resources.has(o.id))
513
- throw this.invalidateTree(), new S(`orphan input resource ${o.id}`);
534
+ for (const n of e)
535
+ if (!this.resources.has(n.id))
536
+ throw this.invalidateTree(), new S(`orphan input resource ${n.id}`);
514
537
  }
515
538
  }
516
539
  /** @deprecated use "entry" instead */
@@ -526,59 +549,59 @@ class V {
526
549
  });
527
550
  }
528
551
  }
529
- function Q(n, e) {
530
- const t = [], r = /* @__PURE__ */ new Set();
531
- return n.forEachResource((s) => {
532
- s.final ? r.add(s.id) : t.push(s.id);
533
- }), t.length === 0 && r.size === 0 && t.push(n.root), { seedResources: t, finalResources: r, pruningFunction: e };
552
+ function Q(a, e) {
553
+ const t = [], i = /* @__PURE__ */ new Set();
554
+ return a.forEachResource((s) => {
555
+ s.finalState ? i.add(s.id) : t.push(s.id);
556
+ }), t.length === 0 && i.size === 0 && t.push(a.root), { seedResources: t, finalResources: i, pruningFunction: e };
534
557
  }
535
- function D() {
558
+ function F() {
536
559
  return {
537
560
  requests: 0,
538
- roundtrips: 0,
561
+ roundTrips: 0,
539
562
  retrievedResources: 0,
540
563
  retrievedFields: 0,
541
564
  retrievedKeyValues: 0,
542
565
  retrievedResourceDataBytes: 0,
543
566
  retrievedKeyValueBytes: 0,
544
- prunnedFields: 0,
567
+ prunedFields: 0,
545
568
  finalResourcesSkipped: 0,
546
569
  millisSpent: 0
547
570
  };
548
571
  }
549
- function de(n) {
550
- let e = `Requests: ${n.requests}
572
+ function de(a) {
573
+ let e = `Requests: ${a.requests}
551
574
  `;
552
- return e += `Total time: ${z(n.millisSpent)}
553
- `, e += `Roundtrips: ${n.roundtrips}
554
- `, e += `Resources: ${n.retrievedResources}
555
- `, e += `Fields: ${n.retrievedFields}
556
- `, e += `KV: ${n.retrievedKeyValues}
557
- `, e += `Data Bytes: ${n.retrievedResourceDataBytes}
558
- `, e += `KV Bytes: ${n.retrievedKeyValueBytes}
559
- `, e += `Pruned fields: ${n.prunnedFields}
560
- `, e += `Final resources skipped: ${n.finalResourcesSkipped}`, e;
575
+ return e += `Total time: ${z(a.millisSpent)}
576
+ `, e += `Round-trips: ${a.roundTrips}
577
+ `, e += `Resources: ${a.retrievedResources}
578
+ `, e += `Fields: ${a.retrievedFields}
579
+ `, e += `KV: ${a.retrievedKeyValues}
580
+ `, e += `Data Bytes: ${a.retrievedResourceDataBytes}
581
+ `, e += `KV Bytes: ${a.retrievedKeyValueBytes}
582
+ `, e += `Pruned fields: ${a.prunedFields}
583
+ `, e += `Final resources skipped: ${a.finalResourcesSkipped}`, e;
561
584
  }
562
- async function X(n, e, t) {
563
- var h;
564
- const r = Date.now();
585
+ async function X(a, e, t) {
586
+ var c;
587
+ const i = Date.now();
565
588
  t && t.requests++;
566
- const { seedResources: s, finalResources: a, pruningFunction: o } = e, i = new H();
567
- let l = !0, c = 0;
568
- const f = /* @__PURE__ */ new Set(), k = (p) => {
569
- if (b(p) || f.has(p)) return;
570
- if (a.has(p)) {
589
+ const { seedResources: s, finalResources: o, pruningFunction: n } = e, r = new H();
590
+ let f = !0, l = 0;
591
+ const h = /* @__PURE__ */ new Set(), k = (p) => {
592
+ if (P(p) || h.has(p)) return;
593
+ if (o.has(p)) {
571
594
  t && t.finalResourcesSkipped++;
572
595
  return;
573
596
  }
574
- f.add(p);
575
- const v = n.getResourceDataIfExists(p, !0), w = n.listKeyValuesIfResourceExists(p), U = l;
576
- l && (l = !1), i.push(
597
+ h.add(p);
598
+ const v = a.getResourceDataIfExists(p, !0), w = a.listKeyValuesIfResourceExists(p), M = f;
599
+ f && (f = !1), r.push(
577
600
  (async () => {
578
- const [_, I] = await Promise.all([v, w]);
579
- if (U && (c++, l = !0), _ !== void 0) {
580
- if (I === void 0) throw new Error("Inconsistent replies");
581
- return { ..._, kv: I };
601
+ const [I, _] = await Promise.all([v, w]);
602
+ if (M && (l++, f = !0), I !== void 0) {
603
+ if (_ === void 0) throw new Error("Inconsistent replies");
604
+ return { ...I, kv: _ };
582
605
  }
583
606
  })()
584
607
  );
@@ -586,82 +609,82 @@ async function X(n, e, t) {
586
609
  s.forEach((p) => k(p));
587
610
  const u = [];
588
611
  for (; ; ) {
589
- const p = i.shift();
612
+ const p = r.shift();
590
613
  if (p === void 0)
591
614
  break;
592
615
  let v = await p;
593
616
  if (v !== void 0) {
594
- if (o !== void 0) {
595
- const w = o(v);
596
- t && (t.prunnedFields += v.fields.length - w.length), v = { ...v, fields: w };
617
+ if (n !== void 0) {
618
+ const w = n(v);
619
+ t && (t.prunedFields += v.fields.length - w.length), v = { ...v, fields: w };
597
620
  }
598
621
  k(v.error);
599
622
  for (const w of v.fields)
600
623
  k(w.value), k(w.error);
601
624
  if (t) {
602
- t.retrievedResources++, t.retrievedFields += v.fields.length, t.retrievedKeyValues += v.kv.length, t.retrievedResourceDataBytes += ((h = v.data) == null ? void 0 : h.length) ?? 0;
625
+ t.retrievedResources++, t.retrievedFields += v.fields.length, t.retrievedKeyValues += v.kv.length, t.retrievedResourceDataBytes += ((c = v.data) == null ? void 0 : c.length) ?? 0;
603
626
  for (const w of v.kv) t.retrievedKeyValueBytes += w.value.length;
604
627
  }
605
628
  u.push(v);
606
629
  }
607
630
  }
608
- return t && (t.millisSpent += Date.now() - r, t.roundtrips += c), u;
631
+ return t && (t.millisSpent += Date.now() - i, t.roundTrips += l), u;
609
632
  }
610
- function ce(n) {
611
- return n;
633
+ function ce(a) {
634
+ return a;
612
635
  }
613
- function he(n, e, t) {
614
- var o;
615
- const r = n instanceof R ? y(t).accessor(n).node() : n instanceof E ? n.node() : n, a = { ...r.resourceInfo };
616
- if (e.data !== void 0 && (e.data === "raw" ? a.data = r.getData() : a.data = e.data.parse(r.getDataAsJson())), e.fields !== void 0) {
617
- const i = {};
618
- for (const [l, c] of Object.entries(e.fields))
619
- i[l] = (o = r.traverse({
620
- field: l,
621
- errorIfFieldNotSet: c,
622
- stableIfNotFound: !c
623
- })) == null ? void 0 : o.id;
624
- a.fields = i;
636
+ function he(a, e, t) {
637
+ var n;
638
+ const i = a instanceof R ? y(t).accessor(a).node() : a instanceof E ? a.node() : a, o = { ...i.resourceInfo };
639
+ if (e.data !== void 0 && (e.data === "raw" ? o.data = i.getData() : o.data = e.data.parse(i.getDataAsJson())), e.fields !== void 0) {
640
+ const r = {};
641
+ for (const [f, l] of Object.entries(e.fields))
642
+ r[f] = (n = i.traverse({
643
+ field: f,
644
+ errorIfFieldNotSet: l,
645
+ stableIfNotFound: !l
646
+ })) == null ? void 0 : n.id;
647
+ o.fields = r;
625
648
  }
626
649
  if (e.kv !== void 0) {
627
- const i = {};
628
- for (const [l, c] of Object.entries(e.kv)) {
629
- const f = r.getKeyValue(l);
630
- if (f === void 0)
631
- throw new Error(`Key not found ${l}`);
632
- c === "raw" ? i[l] = f : i[l] = c.parse(JSON.parse(Buffer.from(f).toString("utf-8")));
650
+ const r = {};
651
+ for (const [f, l] of Object.entries(e.kv)) {
652
+ const h = i.getKeyValue(f);
653
+ if (h === void 0)
654
+ throw new Error(`Key not found ${f}`);
655
+ l === "raw" ? r[f] = h : r[f] = l.parse(JSON.parse(Buffer.from(h).toString("utf-8")));
633
656
  }
634
- a.kv = i;
657
+ o.kv = r;
635
658
  }
636
- return a;
659
+ return o;
637
660
  }
638
- function le(n, e, t) {
639
- if (n instanceof R) {
640
- const r = t.accessor(n).node(), s = r.resourceInfo, a = e.map((o) => {
641
- var i, l;
661
+ function le(a, e, t) {
662
+ if (a instanceof R) {
663
+ const i = t.accessor(a).node(), s = i.resourceInfo, o = e.map((n) => {
664
+ var r, f;
642
665
  return [
643
- o,
644
- (l = (i = r.getField(o)) == null ? void 0 : i.value) == null ? void 0 : l.id
666
+ n,
667
+ (f = (r = i.getField(n)) == null ? void 0 : r.value) == null ? void 0 : f.id
645
668
  ];
646
669
  });
647
670
  return {
648
671
  ...s,
649
- fields: new Map(a),
650
- data: r.getData() ?? new Uint8Array()
672
+ fields: new Map(o),
673
+ data: i.getData() ?? new Uint8Array()
651
674
  };
652
675
  }
653
- return n;
676
+ return a;
654
677
  }
655
- function fe(n, e, t) {
656
- if (!(n instanceof R)) return n;
657
- const r = t.accessor(n).node(), s = r.resourceInfo, a = e.map((o) => [o, r.getKeyValue(o)]);
678
+ function fe(a, e, t) {
679
+ if (!(a instanceof R)) return a;
680
+ const i = t.accessor(a).node(), s = i.resourceInfo, o = e.map((n) => [n, i.getKeyValue(n)]);
658
681
  return {
659
682
  ...s,
660
- metadata: Object.fromEntries(a)
683
+ metadata: Object.fromEntries(o)
661
684
  };
662
685
  }
663
686
  class W {
664
- constructor(e, t, r, s) {
687
+ constructor(e, t, i, s) {
665
688
  d(this, "finalPredicate");
666
689
  d(this, "state");
667
690
  d(this, "pollingInterval");
@@ -677,12 +700,12 @@ class W {
677
700
  /** If true this tree state is permanently terminaed. */
678
701
  d(this, "terminated", !1);
679
702
  this.pl = e, this.root = t, this.logger = s;
680
- const { finalPredicate: a, pruning: o, pollingInterval: i, stopPollingDelay: l, logStat: c } = r;
681
- this.pruning = o, this.pollingInterval = i, this.finalPredicate = a, this.logStat = c, this.state = new V(t, a), this.hooks = new M(
703
+ const { finalPredicateOverride: o, pruning: n, pollingInterval: r, stopPollingDelay: f, logStat: l } = i;
704
+ this.pruning = n, this.pollingInterval = r, this.finalPredicate = o ?? e.finalPredicate, this.logStat = l, this.state = new V(t, this.finalPredicate), this.hooks = new B(
682
705
  () => this.startUpdating(),
683
706
  () => this.stopUpdating(),
684
- { stopDebounce: l },
685
- (f, k) => this.scheduleOnNextState(f, k)
707
+ { stopDebounce: f },
708
+ (h, k) => this.scheduleOnNextState(h, k)
686
709
  );
687
710
  }
688
711
  /** @deprecated use "entry" instead */
@@ -714,29 +737,29 @@ class W {
714
737
  /** Executed from the main loop, and initialization procedure. */
715
738
  async refresh(e) {
716
739
  if (this.terminated) throw new Error("tree synchronization is terminated");
717
- const t = Q(this.state, this.pruning), r = await this.pl.withReadTx("ReadingTree", async (s) => await X(s, t, e));
718
- this.state.updateFromResourceData(r, !0);
740
+ const t = Q(this.state, this.pruning), i = await this.pl.withReadTx("ReadingTree", async (s) => await X(s, t, e));
741
+ this.state.updateFromResourceData(i, !0);
719
742
  }
720
743
  async mainLoop() {
721
- var t, r;
722
- let e = this.logStat ? D() : void 0;
744
+ var t, i;
745
+ let e = this.logStat ? F() : void 0;
723
746
  for (; this.keepRunning; ) {
724
747
  let s;
725
748
  this.scheduledOnNextState.length > 0 && (s = this.scheduledOnNextState, this.scheduledOnNextState = []);
726
749
  try {
727
- if (this.logStat === "per-request" && (e = D()), await this.refresh(e), e && this.logger && this.logger.info(`Tree stat (success): ${JSON.stringify(e)}`), s !== void 0) for (const a of s) a.resolve();
728
- } catch (a) {
729
- if (e && this.logger && this.logger.info(`Tree stat (error): ${JSON.stringify(e)}`), s !== void 0) for (const o of s) o.reject(a);
730
- if (a instanceof S) {
731
- (t = this.logger) == null || t.error(a), this.state.invalidateTree("stat update error"), this.state = new V(this.root, this.finalPredicate);
750
+ if (this.logStat === "per-request" && (e = F()), await this.refresh(e), e && this.logger && this.logger.info(`Tree stat (success): ${JSON.stringify(e)}`), s !== void 0) for (const o of s) o.resolve();
751
+ } catch (o) {
752
+ if (e && this.logger && this.logger.info(`Tree stat (error): ${JSON.stringify(e)}`), s !== void 0) for (const n of s) n.reject(o);
753
+ if (o instanceof S) {
754
+ (t = this.logger) == null || t.error(o), this.state.invalidateTree("stat update error"), this.state = new V(this.root, this.finalPredicate);
732
755
  continue;
733
- } else (r = this.logger) == null || r.warn(a);
756
+ } else (i = this.logger) == null || i.warn(o);
734
757
  }
735
758
  if (!this.keepRunning || this.terminated) break;
736
759
  try {
737
760
  await j.setTimeout(this.pollingInterval, this.abortController.signal);
738
- } catch (a) {
739
- if (!B(a)) throw new Error("Unexpected error", { cause: a });
761
+ } catch (o) {
762
+ if (!q(o)) throw new Error("Unexpected error", { cause: o });
740
763
  break;
741
764
  }
742
765
  }
@@ -753,10 +776,10 @@ class W {
753
776
  async awaitSyncLoopTermination() {
754
777
  this.currentLoop !== void 0 && await this.currentLoop;
755
778
  }
756
- static async init(e, t, r, s) {
757
- const a = new W(e, t, r, s);
758
- let o = r.logStat ? D() : void 0;
759
- return await a.refresh(o), o && s && s.info(`Tree stat (initial load): ${JSON.stringify(o)}`), a;
779
+ static async init(e, t, i, s) {
780
+ const o = new W(e, t, i, s);
781
+ let n = i.logStat ? F() : void 0;
782
+ return await o.refresh(n), n && s && s.info(`Tree stat (initial load): ${JSON.stringify(n)}`), o;
760
783
  }
761
784
  }
762
785
  export {
@@ -770,13 +793,13 @@ export {
770
793
  S as TreeStateUpdateError,
771
794
  Q as constructTreeLoadingRequest,
772
795
  de as formatTreeLoadingStat,
773
- D as initialTreeLoadingStat,
774
- ne as isPlTreeEntry,
775
- oe as isPlTreeEntryAccessor,
776
- ae as isPlTreeNodeAccessor,
796
+ F as initialTreeLoadingStat,
797
+ ae as isPlTreeEntry,
798
+ ne as isPlTreeEntryAccessor,
799
+ oe as isPlTreeNodeAccessor,
777
800
  X as loadTreeState,
778
801
  he as makeResourceSnapshot,
779
- P as mapValueAndError,
802
+ b as mapValueAndError,
780
803
  se as mapValueAndErrorIfDefined,
781
804
  ce as rsSchema,
782
805
  ue as treeEntryToResourceInfo,