@milaboratories/pl-drivers 1.5.52 → 1.5.54

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 (41) hide show
  1. package/dist/clients/download.d.ts +4 -2
  2. package/dist/clients/download.d.ts.map +1 -1
  3. package/dist/clients/helpers.d.ts +1 -1
  4. package/dist/clients/helpers.d.ts.map +1 -1
  5. package/dist/drivers/{download_blob.d.ts → download_blob/download_blob.d.ts} +7 -8
  6. package/dist/drivers/download_blob/download_blob.d.ts.map +1 -0
  7. package/dist/drivers/{download_blob_task.d.ts → download_blob/download_blob_task.d.ts} +1 -1
  8. package/dist/drivers/download_blob/download_blob_task.d.ts.map +1 -0
  9. package/dist/drivers/helpers/files_cache.d.ts.map +1 -1
  10. package/dist/drivers/logs.d.ts +1 -1
  11. package/dist/drivers/logs.d.ts.map +1 -1
  12. package/dist/drivers/ls.d.ts +10 -1
  13. package/dist/drivers/ls.d.ts.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +728 -708
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +8 -11
  21. package/src/clients/download.test.ts +1 -1
  22. package/src/clients/download.ts +14 -5
  23. package/src/clients/helpers.ts +11 -2
  24. package/src/clients/upload.test.ts +2 -1
  25. package/src/drivers/{download_blob.test.ts → download_blob/download_blob.test.ts} +3 -3
  26. package/src/drivers/{download_blob.ts → download_blob/download_blob.ts} +59 -42
  27. package/src/drivers/{download_blob_task.ts → download_blob/download_blob_task.ts} +3 -3
  28. package/src/drivers/download_blob_url/driver.ts +1 -1
  29. package/src/drivers/download_blob_url/url.test.ts +1 -1
  30. package/src/drivers/download_url.test.ts +1 -1
  31. package/src/drivers/helpers/files_cache.test.ts +1 -1
  32. package/src/drivers/helpers/files_cache.ts +10 -3
  33. package/src/drivers/logs.test.ts +2 -2
  34. package/src/drivers/logs.ts +1 -1
  35. package/src/drivers/ls.test.ts +1 -1
  36. package/src/drivers/ls.ts +33 -0
  37. package/src/drivers/upload.test.ts +1 -1
  38. package/src/helpers/download.ts +1 -1
  39. package/src/index.ts +1 -1
  40. package/dist/drivers/download_blob.d.ts.map +0 -1
  41. package/dist/drivers/download_blob_task.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,35 +1,35 @@
1
- var st = Object.defineProperty;
2
- var it = (s, e, t) => e in s ? st(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var d = (s, e, t) => it(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { addRTypeToMetadata as P, bigintToResourceId as he, stringifyWithResourceId as y, resourceIdToString as at, isNotNullResourceId as lt } from "@milaboratories/pl-client";
1
+ var at = Object.defineProperty;
2
+ var lt = (s, e, t) => e in s ? at(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var d = (s, e, t) => lt(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { addRTypeToMetadata as U, bigintToResourceId as pe, stringifyWithResourceId as b, resourceIdToString as ct, isNotNullResourceId as dt } from "@milaboratories/pl-client";
5
5
  import * as m from "node:fs/promises";
6
- import { request as Ne } from "undici";
7
- import { ServiceType as _, stackIntercept as T } from "@protobuf-ts/runtime-rpc";
8
- import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as D, typeofJsonValue as Be, assertNever as ct } from "@protobuf-ts/runtime";
9
- import { notEmpty as H, CallersCounter as v, ensureDirExists as ue, fileExists as pe, createPathAtomically as ge, mapGet as Pe, mapEntries as dt, TaskProcessor as j, asyncPool as fe, assertNever as ht } from "@milaboratories/ts-helpers";
10
- import * as me from "node:fs";
11
- import ie from "node:fs";
12
- import * as b from "node:path";
13
- import L from "node:path";
14
- import { Readable as we, Writable as S, Transform as $e } from "node:stream";
15
- import { text as ut, buffer as Ce } from "node:stream/consumers";
16
- import { ChangeSource as N, Computable as w, PollingComputableHooks as _e } from "@milaboratories/computable";
17
- import { rsSchema as G, treeEntryToResourceInfo as R, isPlTreeEntry as E, makeResourceSnapshot as x, isPlTreeEntryAccessor as Ee } from "@milaboratories/pl-tree";
18
- import pt from "denque";
19
- import { randomUUID as U, createHash as gt } from "node:crypto";
20
- import * as Ue from "node:os";
21
- import ft from "node:os";
22
- import * as mt from "node:readline/promises";
23
- import { z as k } from "zod";
24
- import * as Oe from "node:zlib";
25
- import * as ae from "tar-fs";
26
- import wt from "decompress";
27
- import { scheduler as Fe } from "node:timers/promises";
28
- import yt from "node:assert";
29
- import { isImportFileHandleIndex as bt } from "@milaboratories/pl-model-common";
30
- import Tt from "node:util";
31
- import { exec as kt } from "node:child_process";
32
- class Lt extends g {
6
+ import { request as Be } from "undici";
7
+ import { ServiceType as E, stackIntercept as k } from "@protobuf-ts/runtime-rpc";
8
+ import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as R, typeofJsonValue as Ce, assertNever as ht } from "@protobuf-ts/runtime";
9
+ import { notEmpty as j, CallersCounter as N, ensureDirExists as ge, fileExists as fe, createPathAtomically as me, mapGet as De, mapEntries as ut, TaskProcessor as G, asyncPool as we, assertNever as pt } from "@milaboratories/ts-helpers";
10
+ import * as ye from "node:fs";
11
+ import le from "node:fs";
12
+ import * as T from "node:path";
13
+ import P from "node:path";
14
+ import { Readable as be, Writable as I, Transform as _e } from "node:stream";
15
+ import { text as gt, buffer as Ee } from "node:stream/consumers";
16
+ import { ChangeSource as $, Computable as y, PollingComputableHooks as Oe } from "@milaboratories/computable";
17
+ import { rsSchema as V, treeEntryToResourceInfo as S, isPlTreeEntry as O, makeResourceSnapshot as A, isPlTreeEntryAccessor as Fe } from "@milaboratories/pl-tree";
18
+ import ft from "denque";
19
+ import { randomUUID as D, createHash as mt } from "node:crypto";
20
+ import * as Re from "node:os";
21
+ import wt from "node:os";
22
+ import * as yt from "node:readline/promises";
23
+ import { z as L } from "zod";
24
+ import * as We from "node:zlib";
25
+ import * as ce from "tar-fs";
26
+ import bt from "decompress";
27
+ import { scheduler as ze } from "node:timers/promises";
28
+ import Tt from "node:assert";
29
+ import { isImportFileHandleIndex as kt } from "@milaboratories/pl-model-common";
30
+ import Lt from "node:util";
31
+ import { exec as Pt } from "node:child_process";
32
+ class Ut extends g {
33
33
  constructor() {
34
34
  super("MiLaboratories.Controller.Shared.uploadapi", []);
35
35
  }
@@ -49,8 +49,8 @@ class Lt extends g {
49
49
  ), t;
50
50
  }
51
51
  }
52
- new Lt();
53
- class Pt extends g {
52
+ new Ut();
53
+ class Dt extends g {
54
54
  constructor() {
55
55
  super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
56
56
  }
@@ -70,8 +70,8 @@ class Pt extends g {
70
70
  ), t;
71
71
  }
72
72
  }
73
- new Pt();
74
- class Ut extends g {
73
+ new Dt();
74
+ class Rt extends g {
75
75
  constructor() {
76
76
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
77
77
  {
@@ -125,8 +125,8 @@ class Ut extends g {
125
125
  ), t;
126
126
  }
127
127
  }
128
- const Dt = new Ut();
129
- class Rt extends g {
128
+ const St = new Rt();
129
+ class It extends g {
130
130
  constructor() {
131
131
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
132
132
  {
@@ -164,7 +164,7 @@ class Rt extends g {
164
164
  case /* repeated uint64 uploaded_parts */
165
165
  2:
166
166
  if (c === h.LengthDelimited)
167
- for (let J = e.int32() + e.pos; e.pos < J; )
167
+ for (let Z = e.int32() + e.pos; e.pos < Z; )
168
168
  r.uploadedParts.push(e.uint64().toBigInt());
169
169
  else r.uploadedParts.push(e.uint64().toBigInt());
170
170
  break;
@@ -201,8 +201,8 @@ class Rt extends g {
201
201
  ), t;
202
202
  }
203
203
  }
204
- const St = new Rt();
205
- class It extends g {
204
+ const vt = new It();
205
+ class Nt extends g {
206
206
  constructor() {
207
207
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
208
208
  }
@@ -222,8 +222,8 @@ class It extends g {
222
222
  ), t;
223
223
  }
224
224
  }
225
- new It();
226
- class vt extends g {
225
+ new Nt();
226
+ class $t extends g {
227
227
  constructor() {
228
228
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
229
229
  {
@@ -293,8 +293,8 @@ class vt extends g {
293
293
  ), t;
294
294
  }
295
295
  }
296
- const Nt = new vt();
297
- class Bt extends g {
296
+ const Bt = new $t();
297
+ class Ct extends g {
298
298
  constructor() {
299
299
  super(
300
300
  "MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
@@ -321,8 +321,8 @@ class Bt extends g {
321
321
  ), t;
322
322
  }
323
323
  }
324
- const $t = new Bt();
325
- class Ct extends g {
324
+ const _t = new Ct();
325
+ class Et extends g {
326
326
  constructor() {
327
327
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
328
328
  }
@@ -342,8 +342,8 @@ class Ct extends g {
342
342
  ), t;
343
343
  }
344
344
  }
345
- new Ct();
346
- class _t extends g {
345
+ new Et();
346
+ class Ot extends g {
347
347
  constructor() {
348
348
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
349
349
  {
@@ -425,8 +425,8 @@ class _t extends g {
425
425
  ), t;
426
426
  }
427
427
  }
428
- const Et = new _t();
429
- class Ot extends g {
428
+ const Ft = new Ot();
429
+ class Wt extends g {
430
430
  constructor() {
431
431
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
432
432
  {
@@ -496,8 +496,8 @@ class Ot extends g {
496
496
  ), t;
497
497
  }
498
498
  }
499
- const Z = new Ot();
500
- class Ft extends g {
499
+ const Q = new Wt();
500
+ class zt extends g {
501
501
  constructor() {
502
502
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
503
503
  {
@@ -519,7 +519,7 @@ class Ft extends g {
519
519
  name: "headers",
520
520
  kind: "message",
521
521
  repeat: 1,
522
- T: () => Z
522
+ T: () => Q
523
523
  },
524
524
  {
525
525
  no: 4,
@@ -563,7 +563,7 @@ class Ft extends g {
563
563
  case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
564
564
  3:
565
565
  r.headers.push(
566
- Z.internalBinaryRead(
566
+ Q.internalBinaryRead(
567
567
  e,
568
568
  e.uint32(),
569
569
  o
@@ -599,7 +599,7 @@ class Ft extends g {
599
599
  internalBinaryWrite(e, t, o) {
600
600
  e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
601
601
  for (let r = 0; r < e.headers.length; r++)
602
- Z.internalBinaryWrite(
602
+ Q.internalBinaryWrite(
603
603
  e.headers[r],
604
604
  t.tag(3, h.LengthDelimited).fork(),
605
605
  o
@@ -613,8 +613,8 @@ class Ft extends g {
613
613
  ), t;
614
614
  }
615
615
  }
616
- const Wt = new Ft();
617
- class zt extends g {
616
+ const xt = new zt();
617
+ class At extends g {
618
618
  constructor() {
619
619
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
620
620
  }
@@ -634,8 +634,8 @@ class zt extends g {
634
634
  ), t;
635
635
  }
636
636
  }
637
- new zt();
638
- class xt extends g {
637
+ new At();
638
+ class Mt extends g {
639
639
  constructor() {
640
640
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
641
641
  {
@@ -689,8 +689,8 @@ class xt extends g {
689
689
  ), t;
690
690
  }
691
691
  }
692
- const At = new xt();
693
- class Mt extends g {
692
+ const Ht = new Mt();
693
+ class jt extends g {
694
694
  constructor() {
695
695
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
696
696
  }
@@ -710,40 +710,40 @@ class Mt extends g {
710
710
  ), t;
711
711
  }
712
712
  }
713
- const Ht = new Mt(), Q = new _(
713
+ const Gt = new jt(), X = new E(
714
714
  "MiLaboratories.Controller.Shared.Upload",
715
715
  [
716
716
  {
717
717
  name: "Init",
718
718
  options: {},
719
- I: Dt,
720
- O: St
719
+ I: St,
720
+ O: vt
721
721
  },
722
722
  {
723
723
  name: "GetPartURL",
724
724
  options: {},
725
- I: Et,
726
- O: Wt
725
+ I: Ft,
726
+ O: xt
727
727
  },
728
728
  {
729
729
  name: "UpdateProgress",
730
730
  options: {},
731
- I: Nt,
732
- O: $t
731
+ I: Bt,
732
+ O: _t
733
733
  },
734
734
  {
735
735
  name: "Finalize",
736
736
  options: {},
737
- I: At,
738
- O: Ht
737
+ I: Ht,
738
+ O: Gt
739
739
  }
740
740
  ]
741
741
  );
742
- class jt {
742
+ class Vt {
743
743
  constructor(e) {
744
- d(this, "typeName", Q.typeName);
745
- d(this, "methods", Q.methods);
746
- d(this, "options", Q.options);
744
+ d(this, "typeName", X.typeName);
745
+ d(this, "methods", X.methods);
746
+ d(this, "options", X.options);
747
747
  this._transport = e;
748
748
  }
749
749
  /**
@@ -755,7 +755,7 @@ class jt {
755
755
  */
756
756
  init(e, t) {
757
757
  const o = this.methods[0], n = this._transport.mergeOptions(t);
758
- return T(
758
+ return k(
759
759
  "unary",
760
760
  this._transport,
761
761
  o,
@@ -773,7 +773,7 @@ class jt {
773
773
  */
774
774
  getPartURL(e, t) {
775
775
  const o = this.methods[1], n = this._transport.mergeOptions(t);
776
- return T("unary", this._transport, o, n, e);
776
+ return k("unary", this._transport, o, n, e);
777
777
  }
778
778
  /**
779
779
  *
@@ -784,7 +784,7 @@ class jt {
784
784
  */
785
785
  updateProgress(e, t) {
786
786
  const o = this.methods[2], n = this._transport.mergeOptions(t);
787
- return T("unary", this._transport, o, n, e);
787
+ return k("unary", this._transport, o, n, e);
788
788
  }
789
789
  /**
790
790
  *
@@ -797,24 +797,25 @@ class jt {
797
797
  */
798
798
  finalize(e, t) {
799
799
  const o = this.methods[3], n = this._transport.mergeOptions(t);
800
- return T("unary", this._transport, o, n, e);
800
+ return k("unary", this._transport, o, n, e);
801
801
  }
802
802
  }
803
- function We(s) {
804
- return Object.fromEntries(s.map(({ name: e, value: t }) => [e, t]));
805
- }
806
- class ze extends Error {
807
- }
808
- class xe extends Error {
803
+ function xe(s, e, t) {
804
+ const o = Object.fromEntries(s.map(({ name: n, value: r }) => [n, r]));
805
+ return e !== void 0 && t !== void 0 && (o.Range = `bytes=${e}-${t}`), o;
809
806
  }
810
807
  class Ae extends Error {
811
808
  }
812
809
  class Me extends Error {
813
810
  }
814
- class Gt {
811
+ class He extends Error {
812
+ }
813
+ class je extends Error {
814
+ }
815
+ class qt {
815
816
  constructor(e, t, o, n) {
816
817
  d(this, "grpcClient");
817
- this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new jt(this.grpcTransport);
818
+ this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Vt(this.grpcTransport);
818
819
  }
819
820
  close() {
820
821
  }
@@ -832,14 +833,14 @@ class Gt {
832
833
  0n,
833
834
  // we update progress as a separate call later.
834
835
  a
835
- ), c = await Vt(o, i.chunkStart, i.chunkEnd);
836
- await Jt(o, n);
836
+ ), c = await Jt(o, i.chunkStart, i.chunkEnd);
837
+ await Qt(o, n);
837
838
  try {
838
839
  const {
839
840
  body: l,
840
841
  statusCode: p,
841
- headers: J
842
- } = await Ne(i.uploadUrl, {
842
+ headers: Z
843
+ } = await Be(i.uploadUrl, {
843
844
  dispatcher: this.httpClient,
844
845
  body: c,
845
846
  // We got headers only after we send
@@ -848,12 +849,12 @@ class Gt {
848
849
  // that's why we got big timeout here.
849
850
  headersTimeout: 6e4,
850
851
  bodyTimeout: 6e4,
851
- headers: We(i.headers),
852
+ headers: xe(i.headers),
852
853
  method: i.method.toUpperCase()
853
- }), rt = await l.text();
854
- Zt(p, rt, J, i);
854
+ }), it = await l.text();
855
+ Xt(p, it, Z, i);
855
856
  } catch (l) {
856
- throw l instanceof Ae ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
857
+ throw l instanceof He ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
857
858
  }
858
859
  await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), a);
859
860
  }
@@ -869,12 +870,12 @@ class Gt {
869
870
  return o;
870
871
  }
871
872
  async grpcInit(e, t, o) {
872
- return await this.grpcClient.init({ resourceId: e }, P(t, o)).response;
873
+ return await this.grpcClient.init({ resourceId: e }, U(t, o)).response;
873
874
  }
874
875
  async grpcGetPartUrl({ id: e, type: t }, o, n, r) {
875
876
  return await this.grpcClient.getPartURL(
876
877
  { resourceId: e, partNumber: o, uploadedPartSize: n },
877
- P(t, r)
878
+ U(t, r)
878
879
  ).response;
879
880
  }
880
881
  async grpcUpdateProgress({ id: e, type: t }, o, n) {
@@ -883,26 +884,26 @@ class Gt {
883
884
  resourceId: e,
884
885
  bytesProcessed: o
885
886
  },
886
- P(t, n)
887
+ U(t, n)
887
888
  ).response;
888
889
  }
889
890
  async grpcFinalize({ id: e, type: t }, o) {
890
- return await this.grpcClient.finalize({ resourceId: e }, P(t, o)).response;
891
+ return await this.grpcClient.finalize({ resourceId: e }, U(t, o)).response;
891
892
  }
892
893
  }
893
- async function Vt(s, e, t) {
894
+ async function Jt(s, e, t) {
894
895
  let o;
895
896
  try {
896
897
  o = await m.open(s);
897
- const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await qt(o, a, n, r);
898
+ const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await Zt(o, a, n, r);
898
899
  return a.subarray(0, i);
899
900
  } catch (n) {
900
- throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new Me(`there is no file ${s} for uploading`) : n;
901
+ throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new je(`there is no file ${s} for uploading`) : n;
901
902
  } finally {
902
903
  await (o == null ? void 0 : o.close());
903
904
  }
904
905
  }
905
- async function qt(s, e, t, o) {
906
+ async function Zt(s, e, t, o) {
906
907
  let n = 0;
907
908
  for (; n < t; ) {
908
909
  const { bytesRead: r } = await s.read(
@@ -912,23 +913,23 @@ async function qt(s, e, t, o) {
912
913
  o + n
913
914
  );
914
915
  if (r === 0)
915
- throw new xe("file ended earlier than expected.");
916
+ throw new Me("file ended earlier than expected.");
916
917
  n += r;
917
918
  }
918
919
  return n;
919
920
  }
920
- async function Jt(s, e) {
921
+ async function Qt(s, e) {
921
922
  const t = BigInt(Math.floor((await m.stat(s)).mtimeMs / 1e3));
922
923
  if (t > e)
923
- throw new ze(`file was modified, expected mtime: ${e}, got: ${t}.`);
924
+ throw new Ae(`file was modified, expected mtime: ${e}, got: ${t}.`);
924
925
  }
925
- function Zt(s, e, t, o) {
926
+ function Xt(s, e, t, o) {
926
927
  if (s != 200)
927
- throw new Ae(
928
+ throw new He(
928
929
  `response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${o.uploadUrl}`
929
930
  );
930
931
  }
931
- class Qt extends g {
932
+ class Kt extends g {
932
933
  constructor() {
933
934
  super("google.protobuf.Duration", [
934
935
  {
@@ -952,7 +953,7 @@ class Qt extends g {
952
953
  * Encode `Duration` to JSON string like "3.000001s".
953
954
  */
954
955
  internalJsonWrite(e, t) {
955
- const o = D.from(e.seconds).toNumber();
956
+ const o = R.from(e.seconds).toNumber();
956
957
  if (o > 315576e6 || o < -315576e6)
957
958
  throw new Error("Duration value out of range.");
958
959
  let n = e.seconds.toString();
@@ -968,7 +969,7 @@ class Qt extends g {
968
969
  internalJsonRead(e, t, o) {
969
970
  if (typeof e != "string")
970
971
  throw new Error(
971
- "Unable to parse Duration from JSON " + Be(e) + ". Expected string."
972
+ "Unable to parse Duration from JSON " + Ce(e) + ". Expected string."
972
973
  );
973
974
  const n = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
974
975
  if (n === null)
@@ -976,7 +977,7 @@ class Qt extends g {
976
977
  "Unable to parse Duration from JSON string. Invalid format."
977
978
  );
978
979
  o || (o = this.create());
979
- const [, r, a, i] = n, c = D.from(r + a);
980
+ const [, r, a, i] = n, c = R.from(r + a);
980
981
  if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
981
982
  throw new Error(
982
983
  "Unable to parse Duration from JSON string. Value out of range."
@@ -1032,8 +1033,8 @@ class Qt extends g {
1032
1033
  ), t;
1033
1034
  }
1034
1035
  }
1035
- const z = new Qt();
1036
- class Xt extends g {
1036
+ const x = new Kt();
1037
+ class Yt extends g {
1037
1038
  constructor() {
1038
1039
  super("MiLaboratories.Controller.Shared.ProgressAPI", []);
1039
1040
  }
@@ -1053,8 +1054,8 @@ class Xt extends g {
1053
1054
  ), t;
1054
1055
  }
1055
1056
  }
1056
- new Xt();
1057
- class Kt extends g {
1057
+ new Yt();
1058
+ class eo extends g {
1058
1059
  constructor() {
1059
1060
  super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
1060
1061
  {
@@ -1153,8 +1154,8 @@ class Kt extends g {
1153
1154
  ), t;
1154
1155
  }
1155
1156
  }
1156
- const I = new Kt();
1157
- class Yt extends g {
1157
+ const v = new eo();
1158
+ class to extends g {
1158
1159
  constructor() {
1159
1160
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
1160
1161
  }
@@ -1174,8 +1175,8 @@ class Yt extends g {
1174
1175
  ), t;
1175
1176
  }
1176
1177
  }
1177
- new Yt();
1178
- class eo extends g {
1178
+ new to();
1179
+ class oo extends g {
1179
1180
  constructor() {
1180
1181
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
1181
1182
  {
@@ -1233,11 +1234,11 @@ class eo extends g {
1233
1234
  ), t;
1234
1235
  }
1235
1236
  }
1236
- const to = new eo();
1237
- class oo extends g {
1237
+ const no = new oo();
1238
+ class ro extends g {
1238
1239
  constructor() {
1239
1240
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
1240
- { no: 1, name: "report", kind: "message", T: () => I }
1241
+ { no: 1, name: "report", kind: "message", T: () => v }
1241
1242
  ]);
1242
1243
  }
1243
1244
  create(e) {
@@ -1255,7 +1256,7 @@ class oo extends g {
1255
1256
  switch (i) {
1256
1257
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1257
1258
  1:
1258
- r.report = I.internalBinaryRead(
1259
+ r.report = v.internalBinaryRead(
1259
1260
  e,
1260
1261
  e.uint32(),
1261
1262
  o,
@@ -1281,7 +1282,7 @@ class oo extends g {
1281
1282
  return r;
1282
1283
  }
1283
1284
  internalBinaryWrite(e, t, o) {
1284
- e.report && I.internalBinaryWrite(
1285
+ e.report && v.internalBinaryWrite(
1285
1286
  e.report,
1286
1287
  t.tag(1, h.LengthDelimited).fork(),
1287
1288
  o
@@ -1294,8 +1295,8 @@ class oo extends g {
1294
1295
  ), t;
1295
1296
  }
1296
1297
  }
1297
- const no = new oo();
1298
- class ro extends g {
1298
+ const so = new ro();
1299
+ class io extends g {
1299
1300
  constructor() {
1300
1301
  super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
1301
1302
  }
@@ -1315,8 +1316,8 @@ class ro extends g {
1315
1316
  ), t;
1316
1317
  }
1317
1318
  }
1318
- new ro();
1319
- class so extends g {
1319
+ new io();
1320
+ class ao extends g {
1320
1321
  constructor() {
1321
1322
  super(
1322
1323
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
@@ -1329,7 +1330,7 @@ class so extends g {
1329
1330
  L: 0
1330
1331
  /* LongType.BIGINT */
1331
1332
  },
1332
- { no: 2, name: "update_interval", kind: "message", T: () => z }
1333
+ { no: 2, name: "update_interval", kind: "message", T: () => x }
1333
1334
  ]
1334
1335
  );
1335
1336
  }
@@ -1352,7 +1353,7 @@ class so extends g {
1352
1353
  break;
1353
1354
  case /* google.protobuf.Duration update_interval */
1354
1355
  2:
1355
- r.updateInterval = z.internalBinaryRead(
1356
+ r.updateInterval = x.internalBinaryRead(
1356
1357
  e,
1357
1358
  e.uint32(),
1358
1359
  o,
@@ -1378,7 +1379,7 @@ class so extends g {
1378
1379
  return r;
1379
1380
  }
1380
1381
  internalBinaryWrite(e, t, o) {
1381
- e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && z.internalBinaryWrite(
1382
+ e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && x.internalBinaryWrite(
1382
1383
  e.updateInterval,
1383
1384
  t.tag(2, h.LengthDelimited).fork(),
1384
1385
  o
@@ -1391,12 +1392,12 @@ class so extends g {
1391
1392
  ), t;
1392
1393
  }
1393
1394
  }
1394
- const io = new so();
1395
- class ao extends g {
1395
+ const lo = new ao();
1396
+ class co extends g {
1396
1397
  constructor() {
1397
1398
  super(
1398
1399
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
1399
- [{ no: 1, name: "report", kind: "message", T: () => I }]
1400
+ [{ no: 1, name: "report", kind: "message", T: () => v }]
1400
1401
  );
1401
1402
  }
1402
1403
  create(e) {
@@ -1414,7 +1415,7 @@ class ao extends g {
1414
1415
  switch (i) {
1415
1416
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1416
1417
  1:
1417
- r.report = I.internalBinaryRead(
1418
+ r.report = v.internalBinaryRead(
1418
1419
  e,
1419
1420
  e.uint32(),
1420
1421
  o,
@@ -1440,7 +1441,7 @@ class ao extends g {
1440
1441
  return r;
1441
1442
  }
1442
1443
  internalBinaryWrite(e, t, o) {
1443
- e.report && I.internalBinaryWrite(
1444
+ e.report && v.internalBinaryWrite(
1444
1445
  e.report,
1445
1446
  t.tag(1, h.LengthDelimited).fork(),
1446
1447
  o
@@ -1453,7 +1454,7 @@ class ao extends g {
1453
1454
  ), t;
1454
1455
  }
1455
1456
  }
1456
- const lo = new ao(), X = new _(
1457
+ const ho = new co(), K = new E(
1457
1458
  "MiLaboratories.Controller.Shared.Progress",
1458
1459
  [
1459
1460
  {
@@ -1461,23 +1462,23 @@ const lo = new ao(), X = new _(
1461
1462
  options: {
1462
1463
  "google.api.http": { get: "/resources/{resource_id}/get-progress" }
1463
1464
  },
1464
- I: to,
1465
- O: no
1465
+ I: no,
1466
+ O: so
1466
1467
  },
1467
1468
  {
1468
1469
  name: "RealtimeStatus",
1469
1470
  serverStreaming: !0,
1470
1471
  options: {},
1471
- I: io,
1472
- O: lo
1472
+ I: lo,
1473
+ O: ho
1473
1474
  }
1474
1475
  ]
1475
1476
  );
1476
- class co {
1477
+ class uo {
1477
1478
  constructor(e) {
1478
- d(this, "typeName", X.typeName);
1479
- d(this, "methods", X.methods);
1480
- d(this, "options", X.options);
1479
+ d(this, "typeName", K.typeName);
1480
+ d(this, "methods", K.methods);
1481
+ d(this, "options", K.options);
1481
1482
  this._transport = e;
1482
1483
  }
1483
1484
  /**
@@ -1485,20 +1486,20 @@ class co {
1485
1486
  */
1486
1487
  getStatus(e, t) {
1487
1488
  const o = this.methods[0], n = this._transport.mergeOptions(t);
1488
- return T("unary", this._transport, o, n, e);
1489
+ return k("unary", this._transport, o, n, e);
1489
1490
  }
1490
1491
  /**
1491
1492
  * @generated from protobuf rpc: RealtimeStatus(MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request) returns (stream MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response);
1492
1493
  */
1493
1494
  realtimeStatus(e, t) {
1494
1495
  const o = this.methods[1], n = this._transport.mergeOptions(t);
1495
- return T("serverStreaming", this._transport, o, n, e);
1496
+ return k("serverStreaming", this._transport, o, n, e);
1496
1497
  }
1497
1498
  }
1498
- class ho {
1499
+ class po {
1499
1500
  constructor(e, t, o, n) {
1500
1501
  d(this, "grpcClient");
1501
- this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new co(this.grpcTransport);
1502
+ this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new uo(this.grpcTransport);
1502
1503
  }
1503
1504
  close() {
1504
1505
  }
@@ -1506,8 +1507,8 @@ class ho {
1506
1507
  async getStatus({ id: e, type: t }, o) {
1507
1508
  const n = await this.grpcClient.getStatus(
1508
1509
  { resourceId: e },
1509
- P(t, o)
1510
- ), r = H(n.response.report);
1510
+ U(t, o)
1511
+ ), r = j(n.response.report);
1511
1512
  return {
1512
1513
  done: r.done,
1513
1514
  progress: r.progress,
@@ -1518,8 +1519,8 @@ class ho {
1518
1519
  // realtimeStatus returns a async generator that takes statuses from
1519
1520
  // GRPC stream every updateIntervalMs milliseconds.
1520
1521
  async *realtimeStatus({ id: e, type: t }, o = 100, n) {
1521
- n = P(t, n);
1522
- const r = Math.floor(o / 1e3), a = (o - r * 1e3) * 1e6, i = z.create({
1522
+ n = U(t, n);
1523
+ const r = Math.floor(o / 1e3), a = (o - r * 1e3) * 1e6, i = x.create({
1523
1524
  seconds: BigInt(r),
1524
1525
  nanos: a
1525
1526
  });
@@ -1537,37 +1538,37 @@ class ho {
1537
1538
  }
1538
1539
  }
1539
1540
  }
1540
- class V extends Error {
1541
+ class q extends Error {
1541
1542
  }
1542
- class He {
1543
+ class Ge {
1543
1544
  constructor(e) {
1544
1545
  this.httpClient = e;
1545
1546
  }
1546
1547
  async download(e, t, o) {
1547
- const { statusCode: n, body: r, headers: a } = await Ne(e, {
1548
+ const { statusCode: n, body: r, headers: a } = await Be(e, {
1548
1549
  dispatcher: this.httpClient,
1549
1550
  headers: t,
1550
1551
  signal: o
1551
- }), i = we.toWeb(r);
1552
- return await uo(n, i, e), {
1552
+ }), i = be.toWeb(r);
1553
+ return await go(n, i, e), {
1553
1554
  content: i,
1554
1555
  size: Number(a["content-length"])
1555
1556
  };
1556
1557
  }
1557
1558
  }
1558
- async function uo(s, e, t) {
1559
- if (s != 200) {
1560
- const o = (await ut(e)).substring(0, 1e3);
1561
- throw 400 <= s && s < 500 ? new V(
1559
+ async function go(s, e, t) {
1560
+ if (s != 200 && s != 206) {
1561
+ const o = (await gt(e)).substring(0, 1e3);
1562
+ throw 400 <= s && s < 500 ? new q(
1562
1563
  `Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${o}`
1563
1564
  ) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
1564
1565
  }
1565
1566
  }
1566
- function C(s) {
1567
- if (!L.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1567
+ function _(s) {
1568
+ if (!P.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1568
1569
  return s;
1569
1570
  }
1570
- class po extends g {
1571
+ class fo extends g {
1571
1572
  constructor() {
1572
1573
  super("MiLaboratories.Controller.Shared.DownloadAPI", []);
1573
1574
  }
@@ -1587,8 +1588,8 @@ class po extends g {
1587
1588
  ), t;
1588
1589
  }
1589
1590
  }
1590
- new po();
1591
- class go extends g {
1591
+ new fo();
1592
+ class mo extends g {
1592
1593
  constructor() {
1593
1594
  super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
1594
1595
  }
@@ -1608,8 +1609,8 @@ class go extends g {
1608
1609
  ), t;
1609
1610
  }
1610
1611
  }
1611
- new go();
1612
- class fo extends g {
1612
+ new mo();
1613
+ class wo extends g {
1613
1614
  constructor() {
1614
1615
  super(
1615
1616
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
@@ -1670,8 +1671,8 @@ class fo extends g {
1670
1671
  ), t;
1671
1672
  }
1672
1673
  }
1673
- const mo = new fo();
1674
- class wo extends g {
1674
+ const yo = new wo();
1675
+ class bo extends g {
1675
1676
  constructor() {
1676
1677
  super(
1677
1678
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
@@ -1744,8 +1745,8 @@ class wo extends g {
1744
1745
  ), t;
1745
1746
  }
1746
1747
  }
1747
- const K = new wo();
1748
- class yo extends g {
1748
+ const Y = new bo();
1749
+ class To extends g {
1749
1750
  constructor() {
1750
1751
  super(
1751
1752
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
@@ -1762,7 +1763,7 @@ class yo extends g {
1762
1763
  name: "headers",
1763
1764
  kind: "message",
1764
1765
  repeat: 1,
1765
- T: () => K
1766
+ T: () => Y
1766
1767
  }
1767
1768
  ]
1768
1769
  );
@@ -1787,7 +1788,7 @@ class yo extends g {
1787
1788
  case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
1788
1789
  2:
1789
1790
  r.headers.push(
1790
- K.internalBinaryRead(
1791
+ Y.internalBinaryRead(
1791
1792
  e,
1792
1793
  e.uint32(),
1793
1794
  o
@@ -1815,7 +1816,7 @@ class yo extends g {
1815
1816
  internalBinaryWrite(e, t, o) {
1816
1817
  e.downloadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.downloadUrl);
1817
1818
  for (let r = 0; r < e.headers.length; r++)
1818
- K.internalBinaryWrite(
1819
+ Y.internalBinaryWrite(
1819
1820
  e.headers[r],
1820
1821
  t.tag(2, h.LengthDelimited).fork(),
1821
1822
  o
@@ -1828,7 +1829,7 @@ class yo extends g {
1828
1829
  ), t;
1829
1830
  }
1830
1831
  }
1831
- const bo = new yo(), Y = new _(
1832
+ const ko = new To(), ee = new E(
1832
1833
  "MiLaboratories.Controller.Shared.Download",
1833
1834
  [
1834
1835
  {
@@ -1836,16 +1837,16 @@ const bo = new yo(), Y = new _(
1836
1837
  options: {
1837
1838
  "google.api.http": { get: "/resources/{resource_id}/get-download-url" }
1838
1839
  },
1839
- I: mo,
1840
- O: bo
1840
+ I: yo,
1841
+ O: ko
1841
1842
  }
1842
1843
  ]
1843
1844
  );
1844
- class To {
1845
+ class Lo {
1845
1846
  constructor(e) {
1846
- d(this, "typeName", Y.typeName);
1847
- d(this, "methods", Y.methods);
1848
- d(this, "options", Y.options);
1847
+ d(this, "typeName", ee.typeName);
1848
+ d(this, "methods", ee.methods);
1849
+ d(this, "options", ee.options);
1849
1850
  this._transport = e;
1850
1851
  }
1851
1852
  /**
@@ -1853,67 +1854,69 @@ class To {
1853
1854
  */
1854
1855
  getDownloadURL(e, t) {
1855
1856
  const o = this.methods[0], n = this._transport.mergeOptions(t);
1856
- return T("unary", this._transport, o, n, e);
1857
+ return k("unary", this._transport, o, n, e);
1857
1858
  }
1858
1859
  }
1859
- class ko {
1860
+ class Po {
1860
1861
  constructor(e, t, o, n) {
1861
1862
  d(this, "grpcClient");
1862
1863
  d(this, "remoteFileDownloader");
1863
1864
  /** Helps to find a storage root directory by a storage id from URL scheme. */
1864
1865
  d(this, "localStorageIdsToRoot");
1865
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new To(this.grpcTransport), this.remoteFileDownloader = new He(t), this.localStorageIdsToRoot = Ro(n);
1866
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Lo(this.grpcTransport), this.remoteFileDownloader = new Ge(t), this.localStorageIdsToRoot = Io(n);
1866
1867
  }
1867
1868
  close() {
1868
1869
  }
1869
- async downloadBlob(e, t, o) {
1870
- const { downloadUrl: n, headers: r } = await this.grpcGetDownloadUrl(e, t, o);
1871
- return this.logger.info(`download blob from url ${n}`), Do(n) ? await this.readLocalFile(n) : await this.remoteFileDownloader.download(n, We(r), o);
1870
+ /** Gets a presign URL and downloads the file.
1871
+ * An optional range with 2 numbers from what byte and to what byte to download can be provided. */
1872
+ async downloadBlob(e, t, o, n, r) {
1873
+ const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, o), c = xe(i, n, r);
1874
+ return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`), So(a) ? await this.readLocalFile(a, n, r) : await this.remoteFileDownloader.download(a, c, o);
1872
1875
  }
1873
- async readLocalFile(e) {
1874
- const { storageId: t, relativePath: o } = Lo(e), n = Po(t, this.localStorageIdsToRoot, o);
1876
+ async readLocalFile(e, t, o) {
1877
+ const { storageId: n, relativePath: r } = Uo(e), a = Do(n, this.localStorageIdsToRoot, r);
1875
1878
  return {
1876
- content: we.toWeb(me.createReadStream(n)),
1877
- size: (await m.stat(n)).size
1879
+ content: be.toWeb(ye.createReadStream(a, { start: t, end: o })),
1880
+ size: (await m.stat(a)).size
1878
1881
  };
1879
1882
  }
1880
1883
  async grpcGetDownloadUrl({ id: e, type: t }, o, n) {
1881
1884
  const r = o ?? {};
1882
1885
  return r.abort = n, await this.grpcClient.getDownloadURL(
1883
1886
  { resourceId: e },
1884
- P(t, r)
1887
+ U(t, r)
1885
1888
  ).response;
1886
1889
  }
1887
1890
  }
1888
- function Lo(s) {
1891
+ function Uo(s) {
1889
1892
  const e = new URL(s);
1890
1893
  if (e.pathname == "")
1891
- throw new ye(`url for local filepath ${s} does not match url scheme`);
1894
+ throw new Te(`url for local filepath ${s} does not match url scheme`);
1892
1895
  return {
1893
1896
  storageId: e.host,
1894
1897
  relativePath: decodeURIComponent(e.pathname.slice(1))
1895
1898
  };
1896
1899
  }
1897
- function Po(s, e, t) {
1900
+ function Do(s, e, t) {
1898
1901
  const o = e.get(s);
1899
- if (o === void 0) throw new be(`Unknown storage location: ${s}`);
1900
- return o === "" ? t : b.join(o, t);
1902
+ if (o === void 0) throw new ke(`Unknown storage location: ${s}`);
1903
+ return o === "" ? t : T.join(o, t);
1901
1904
  }
1902
- const Uo = "storage://";
1903
- function Do(s) {
1904
- return s.startsWith(Uo);
1905
+ const Ro = "storage://";
1906
+ function So(s) {
1907
+ return s.startsWith(Ro);
1905
1908
  }
1906
- class ye extends Error {
1909
+ class Te extends Error {
1907
1910
  }
1908
- class be extends Error {
1911
+ class ke extends Error {
1909
1912
  }
1910
- function Ro(s) {
1913
+ function Io(s) {
1911
1914
  const e = /* @__PURE__ */ new Map();
1912
1915
  for (const t of s)
1913
- t.localPath !== "" && C(t.localPath), e.set(t.storageId, t.localPath);
1916
+ t.localPath !== "" && _(t.localPath), e.set(t.storageId, t.localPath);
1914
1917
  return e;
1915
1918
  }
1916
- class So extends g {
1919
+ class vo extends g {
1917
1920
  constructor() {
1918
1921
  super("google.protobuf.Timestamp", [
1919
1922
  {
@@ -1938,14 +1941,14 @@ class So extends g {
1938
1941
  */
1939
1942
  now() {
1940
1943
  const e = this.create(), t = Date.now();
1941
- return e.seconds = D.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
1944
+ return e.seconds = R.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
1942
1945
  }
1943
1946
  /**
1944
1947
  * Converts a `Timestamp` to a JavaScript Date.
1945
1948
  */
1946
1949
  toDate(e) {
1947
1950
  return new Date(
1948
- D.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
1951
+ R.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
1949
1952
  );
1950
1953
  }
1951
1954
  /**
@@ -1953,14 +1956,14 @@ class So extends g {
1953
1956
  */
1954
1957
  fromDate(e) {
1955
1958
  const t = this.create(), o = e.getTime();
1956
- return t.seconds = D.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
1959
+ return t.seconds = R.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
1957
1960
  }
1958
1961
  /**
1959
1962
  * In JSON format, the `Timestamp` type is encoded as a string
1960
1963
  * in the RFC 3339 format.
1961
1964
  */
1962
1965
  internalJsonWrite(e, t) {
1963
- const o = D.from(e.seconds).toNumber() * 1e3;
1966
+ const o = R.from(e.seconds).toNumber() * 1e3;
1964
1967
  if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
1965
1968
  throw new Error(
1966
1969
  "Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
@@ -1983,7 +1986,7 @@ class So extends g {
1983
1986
  internalJsonRead(e, t, o) {
1984
1987
  if (typeof e != "string")
1985
1988
  throw new Error(
1986
- "Unable to parse Timestamp from JSON " + Be(e) + "."
1989
+ "Unable to parse Timestamp from JSON " + Ce(e) + "."
1987
1990
  );
1988
1991
  const n = e.match(
1989
1992
  /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/
@@ -1999,7 +2002,7 @@ class So extends g {
1999
2002
  throw new globalThis.Error(
2000
2003
  "Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
2001
2004
  );
2002
- return o || (o = this.create()), o.seconds = D.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
2005
+ return o || (o = this.create()), o.seconds = R.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
2003
2006
  }
2004
2007
  create(e) {
2005
2008
  const t = globalThis.Object.create(this.messagePrototype);
@@ -2046,8 +2049,8 @@ class So extends g {
2046
2049
  ), t;
2047
2050
  }
2048
2051
  }
2049
- const ee = new So();
2050
- class Io extends g {
2052
+ const te = new vo();
2053
+ class No extends g {
2051
2054
  constructor() {
2052
2055
  super("MiLaboratories.Controller.Shared.LsAPI", []);
2053
2056
  }
@@ -2067,8 +2070,8 @@ class Io extends g {
2067
2070
  ), t;
2068
2071
  }
2069
2072
  }
2070
- new Io();
2071
- class vo extends g {
2073
+ new No();
2074
+ class $o extends g {
2072
2075
  constructor() {
2073
2076
  super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
2074
2077
  {
@@ -2107,7 +2110,7 @@ class vo extends g {
2107
2110
  T: 9
2108
2111
  /* ScalarType.STRING */
2109
2112
  },
2110
- { no: 12, name: "last_modified", kind: "message", T: () => ee },
2113
+ { no: 12, name: "last_modified", kind: "message", T: () => te },
2111
2114
  {
2112
2115
  no: 13,
2113
2116
  name: "version",
@@ -2148,7 +2151,7 @@ class vo extends g {
2148
2151
  break;
2149
2152
  case /* google.protobuf.Timestamp last_modified */
2150
2153
  12:
2151
- r.lastModified = ee.internalBinaryRead(
2154
+ r.lastModified = te.internalBinaryRead(
2152
2155
  e,
2153
2156
  e.uint32(),
2154
2157
  o,
@@ -2178,7 +2181,7 @@ class vo extends g {
2178
2181
  return r;
2179
2182
  }
2180
2183
  internalBinaryWrite(e, t, o) {
2181
- e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified && ee.internalBinaryWrite(
2184
+ e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified && te.internalBinaryWrite(
2182
2185
  e.lastModified,
2183
2186
  t.tag(12, h.LengthDelimited).fork(),
2184
2187
  o
@@ -2191,8 +2194,8 @@ class vo extends g {
2191
2194
  ), t;
2192
2195
  }
2193
2196
  }
2194
- const te = new vo();
2195
- class No extends g {
2197
+ const oe = new $o();
2198
+ class Bo extends g {
2196
2199
  constructor() {
2197
2200
  super("MiLaboratories.Controller.Shared.LsAPI.List", []);
2198
2201
  }
@@ -2212,8 +2215,8 @@ class No extends g {
2212
2215
  ), t;
2213
2216
  }
2214
2217
  }
2215
- new No();
2216
- class Bo extends g {
2218
+ new Bo();
2219
+ class Co extends g {
2217
2220
  constructor() {
2218
2221
  super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
2219
2222
  {
@@ -2278,8 +2281,8 @@ class Bo extends g {
2278
2281
  ), t;
2279
2282
  }
2280
2283
  }
2281
- const $o = new Bo();
2282
- class Co extends g {
2284
+ const _o = new Co();
2285
+ class Eo extends g {
2283
2286
  constructor() {
2284
2287
  super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
2285
2288
  {
@@ -2287,7 +2290,7 @@ class Co extends g {
2287
2290
  name: "items",
2288
2291
  kind: "message",
2289
2292
  repeat: 1,
2290
- T: () => te
2293
+ T: () => oe
2291
2294
  },
2292
2295
  {
2293
2296
  no: 2,
@@ -2310,7 +2313,7 @@ class Co extends g {
2310
2313
  case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
2311
2314
  1:
2312
2315
  r.items.push(
2313
- te.internalBinaryRead(e, e.uint32(), o)
2316
+ oe.internalBinaryRead(e, e.uint32(), o)
2314
2317
  );
2315
2318
  break;
2316
2319
  case /* string delimiter */
@@ -2337,7 +2340,7 @@ class Co extends g {
2337
2340
  }
2338
2341
  internalBinaryWrite(e, t, o) {
2339
2342
  for (let r = 0; r < e.items.length; r++)
2340
- te.internalBinaryWrite(
2343
+ oe.internalBinaryWrite(
2341
2344
  e.items[r],
2342
2345
  t.tag(1, h.LengthDelimited).fork(),
2343
2346
  o
@@ -2351,14 +2354,14 @@ class Co extends g {
2351
2354
  ), t;
2352
2355
  }
2353
2356
  }
2354
- const _o = new Co(), oe = new _("MiLaboratories.Controller.Shared.LS", [
2355
- { name: "List", options: {}, I: $o, O: _o }
2357
+ const Oo = new Eo(), ne = new E("MiLaboratories.Controller.Shared.LS", [
2358
+ { name: "List", options: {}, I: _o, O: Oo }
2356
2359
  ]);
2357
- class Eo {
2360
+ class Fo {
2358
2361
  constructor(e) {
2359
- d(this, "typeName", oe.typeName);
2360
- d(this, "methods", oe.methods);
2361
- d(this, "options", oe.options);
2362
+ d(this, "typeName", ne.typeName);
2363
+ d(this, "methods", ne.methods);
2364
+ d(this, "options", ne.options);
2362
2365
  this._transport = e;
2363
2366
  }
2364
2367
  /**
@@ -2366,7 +2369,7 @@ class Eo {
2366
2369
  */
2367
2370
  list(e, t) {
2368
2371
  const o = this.methods[0], n = this._transport.mergeOptions(t);
2369
- return T(
2372
+ return k(
2370
2373
  "unary",
2371
2374
  this._transport,
2372
2375
  o,
@@ -2375,10 +2378,10 @@ class Eo {
2375
2378
  );
2376
2379
  }
2377
2380
  }
2378
- class Oo {
2381
+ class Wo {
2379
2382
  constructor(e, t) {
2380
2383
  d(this, "grpcClient");
2381
- this.logger = t, this.grpcClient = new Eo(e);
2384
+ this.logger = t, this.grpcClient = new Fo(e);
2382
2385
  }
2383
2386
  close() {
2384
2387
  }
@@ -2388,11 +2391,11 @@ class Oo {
2388
2391
  resourceId: e.id,
2389
2392
  location: t
2390
2393
  },
2391
- P(e.type, o)
2394
+ U(e.type, o)
2392
2395
  ).response;
2393
2396
  }
2394
2397
  }
2395
- class Fo extends g {
2398
+ class zo extends g {
2396
2399
  constructor() {
2397
2400
  super("MiLaboratories.Controller.Shared.StreamingAPI", []);
2398
2401
  }
@@ -2412,8 +2415,8 @@ class Fo extends g {
2412
2415
  ), t;
2413
2416
  }
2414
2417
  }
2415
- new Fo();
2416
- class Wo extends g {
2418
+ new zo();
2419
+ class xo extends g {
2417
2420
  constructor() {
2418
2421
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
2419
2422
  {
@@ -2504,8 +2507,8 @@ class Wo extends g {
2504
2507
  ), t;
2505
2508
  }
2506
2509
  }
2507
- const zo = new Wo();
2508
- class xo extends g {
2510
+ const Ao = new xo();
2511
+ class Mo extends g {
2509
2512
  constructor() {
2510
2513
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
2511
2514
  {
@@ -2583,8 +2586,8 @@ class xo extends g {
2583
2586
  ), t;
2584
2587
  }
2585
2588
  }
2586
- const Ao = new xo();
2587
- class Mo extends g {
2589
+ const Ho = new Mo();
2590
+ class jo extends g {
2588
2591
  constructor() {
2589
2592
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
2590
2593
  {
@@ -2687,8 +2690,8 @@ class Mo extends g {
2687
2690
  ), t;
2688
2691
  }
2689
2692
  }
2690
- const Ho = new Mo();
2691
- class jo extends g {
2693
+ const Go = new jo();
2694
+ class Vo extends g {
2692
2695
  constructor() {
2693
2696
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
2694
2697
  {
@@ -2791,8 +2794,8 @@ class jo extends g {
2791
2794
  ), t;
2792
2795
  }
2793
2796
  }
2794
- const Go = new jo();
2795
- class Vo extends g {
2797
+ const qo = new Vo();
2798
+ class Jo extends g {
2796
2799
  constructor() {
2797
2800
  super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
2798
2801
  {
@@ -2895,8 +2898,8 @@ class Vo extends g {
2895
2898
  ), t;
2896
2899
  }
2897
2900
  }
2898
- const qo = new Vo();
2899
- class Jo extends g {
2901
+ const Zo = new Jo();
2902
+ class Qo extends g {
2900
2903
  constructor() {
2901
2904
  super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
2902
2905
  {
@@ -2973,48 +2976,48 @@ class Jo extends g {
2973
2976
  ), t;
2974
2977
  }
2975
2978
  }
2976
- const B = new Jo(), ne = new _(
2979
+ const B = new Qo(), re = new E(
2977
2980
  "MiLaboratories.Controller.Shared.Streaming",
2978
2981
  [
2979
2982
  {
2980
2983
  name: "StreamBinary",
2981
2984
  serverStreaming: !0,
2982
2985
  options: {},
2983
- I: zo,
2986
+ I: Ao,
2984
2987
  O: B
2985
2988
  },
2986
2989
  {
2987
2990
  name: "ReadBinary",
2988
2991
  options: {},
2989
- I: Ao,
2992
+ I: Ho,
2990
2993
  O: B
2991
2994
  },
2992
2995
  {
2993
2996
  name: "StreamText",
2994
2997
  serverStreaming: !0,
2995
2998
  options: {},
2996
- I: Ho,
2999
+ I: Go,
2997
3000
  O: B
2998
3001
  },
2999
3002
  {
3000
3003
  name: "ReadText",
3001
3004
  options: {},
3002
- I: Go,
3005
+ I: qo,
3003
3006
  O: B
3004
3007
  },
3005
3008
  {
3006
3009
  name: "LastLines",
3007
3010
  options: {},
3008
- I: qo,
3011
+ I: Zo,
3009
3012
  O: B
3010
3013
  }
3011
3014
  ]
3012
3015
  );
3013
- class Zo {
3016
+ class Xo {
3014
3017
  constructor(e) {
3015
- d(this, "typeName", ne.typeName);
3016
- d(this, "methods", ne.methods);
3017
- d(this, "options", ne.options);
3018
+ d(this, "typeName", re.typeName);
3019
+ d(this, "methods", re.methods);
3020
+ d(this, "options", re.options);
3018
3021
  this._transport = e;
3019
3022
  }
3020
3023
  /**
@@ -3026,7 +3029,7 @@ class Zo {
3026
3029
  */
3027
3030
  streamBinary(e, t) {
3028
3031
  const o = this.methods[0], n = this._transport.mergeOptions(t);
3029
- return T(
3032
+ return k(
3030
3033
  "serverStreaming",
3031
3034
  this._transport,
3032
3035
  o,
@@ -3044,7 +3047,7 @@ class Zo {
3044
3047
  */
3045
3048
  readBinary(e, t) {
3046
3049
  const o = this.methods[1], n = this._transport.mergeOptions(t);
3047
- return T(
3050
+ return k(
3048
3051
  "unary",
3049
3052
  this._transport,
3050
3053
  o,
@@ -3060,7 +3063,7 @@ class Zo {
3060
3063
  */
3061
3064
  streamText(e, t) {
3062
3065
  const o = this.methods[2], n = this._transport.mergeOptions(t);
3063
- return T(
3066
+ return k(
3064
3067
  "serverStreaming",
3065
3068
  this._transport,
3066
3069
  o,
@@ -3078,7 +3081,7 @@ class Zo {
3078
3081
  */
3079
3082
  readText(e, t) {
3080
3083
  const o = this.methods[3], n = this._transport.mergeOptions(t);
3081
- return T(
3084
+ return k(
3082
3085
  "unary",
3083
3086
  this._transport,
3084
3087
  o,
@@ -3100,7 +3103,7 @@ class Zo {
3100
3103
  */
3101
3104
  lastLines(e, t) {
3102
3105
  const o = this.methods[4], n = this._transport.mergeOptions(t);
3103
- return T(
3106
+ return k(
3104
3107
  "unary",
3105
3108
  this._transport,
3106
3109
  o,
@@ -3109,10 +3112,10 @@ class Zo {
3109
3112
  );
3110
3113
  }
3111
3114
  }
3112
- class Qo {
3115
+ class Ko {
3113
3116
  constructor(e, t, o) {
3114
3117
  d(this, "grpcClient");
3115
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Zo(this.grpcTransport);
3118
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Xo(this.grpcTransport);
3116
3119
  }
3117
3120
  close() {
3118
3121
  }
@@ -3127,7 +3130,7 @@ class Qo {
3127
3130
  offset: n,
3128
3131
  search: r
3129
3132
  },
3130
- P(t, a)
3133
+ U(t, a)
3131
3134
  )).response;
3132
3135
  }
3133
3136
  /** Reads the file forward and returns the text,
@@ -3136,49 +3139,49 @@ class Qo {
3136
3139
  async readText({ id: e, type: t }, o, n = 0n, r, a) {
3137
3140
  return (await this.grpcClient.readText(
3138
3141
  {
3139
- resourceId: H(e),
3142
+ resourceId: j(e),
3140
3143
  readLimit: BigInt(o),
3141
3144
  offset: n,
3142
3145
  search: r
3143
3146
  },
3144
- P(t, a)
3147
+ U(t, a)
3145
3148
  )).response;
3146
3149
  }
3147
3150
  }
3148
- function Tr(s, e, t) {
3151
+ function kr(s, e, t) {
3149
3152
  return e.getDriver({
3150
3153
  name: "DownloadBlob",
3151
- init: (o, n, r) => new ko(n, r, s, t)
3154
+ init: (o, n, r) => new Po(n, r, s, t)
3152
3155
  });
3153
3156
  }
3154
- function kr(s, e) {
3157
+ function Lr(s, e) {
3155
3158
  return s.getDriver({
3156
3159
  name: "StreamLogs",
3157
- init: (t, o, n) => new Qo(o, n, e)
3160
+ init: (t, o, n) => new Ko(o, n, e)
3158
3161
  });
3159
3162
  }
3160
- function Lr(s, e) {
3163
+ function Pr(s, e) {
3161
3164
  return s.getDriver({
3162
3165
  name: "UploadProgress",
3163
- init: (t, o, n) => new ho(o, n, s, e)
3166
+ init: (t, o, n) => new po(o, n, s, e)
3164
3167
  });
3165
3168
  }
3166
- function Pr(s, e) {
3169
+ function Ur(s, e) {
3167
3170
  return s.getDriver({
3168
3171
  name: "UploadBlob",
3169
- init: (t, o, n) => new Gt(o, n, s, e)
3172
+ init: (t, o, n) => new qt(o, n, s, e)
3170
3173
  });
3171
3174
  }
3172
- function Xo(s, e) {
3175
+ function Yo(s, e) {
3173
3176
  return s.getDriver({
3174
3177
  name: "LsFiles",
3175
- init: (t, o, n) => new Oo(o, e)
3178
+ init: (t, o, n) => new Wo(o, e)
3176
3179
  });
3177
3180
  }
3178
- class Ko {
3181
+ class en {
3179
3182
  constructor(e, t, o, n, r) {
3180
- d(this, "counter", new v());
3181
- d(this, "change", new N());
3183
+ d(this, "counter", new N());
3184
+ d(this, "change", new $());
3182
3185
  d(this, "signalCtl", new AbortController());
3183
3186
  d(this, "error");
3184
3187
  d(this, "done", !1);
@@ -3204,20 +3207,20 @@ class Ko {
3204
3207
  const e = await this.ensureDownloaded();
3205
3208
  this.setDone(e), this.change.markChanged();
3206
3209
  } catch (e) {
3207
- throw Te(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
3210
+ throw Le(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
3208
3211
  }
3209
3212
  }
3210
3213
  async ensureDownloaded() {
3211
- if (await ue(b.dirname(this.path)), await pe(this.path))
3214
+ if (await ge(T.dirname(this.path)), await fe(this.path))
3212
3215
  return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
3213
3216
  const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
3214
- return await ge(this.logger, this.path, async (o) => {
3215
- const n = S.toWeb(ie.createWriteStream(o, { flags: "wx" }));
3217
+ return await me(this.logger, this.path, async (o) => {
3218
+ const n = I.toWeb(le.createWriteStream(o, { flags: "wx" }));
3216
3219
  await e.pipeTo(n);
3217
3220
  }), t;
3218
3221
  }
3219
3222
  abort(e) {
3220
- this.signalCtl.abort(new je(e));
3223
+ this.signalCtl.abort(new Ve(e));
3221
3224
  }
3222
3225
  getBlob() {
3223
3226
  return this.done ? this.error ? {
@@ -3241,12 +3244,12 @@ class Ko {
3241
3244
  this.done = !0, this.error = e;
3242
3245
  }
3243
3246
  }
3244
- function Te(s) {
3245
- return s instanceof je || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3247
+ function Le(s) {
3248
+ return s instanceof Ve || s instanceof q || s instanceof ke || s instanceof Te || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3246
3249
  }
3247
- class je extends Error {
3250
+ class Ve extends Error {
3248
3251
  }
3249
- class ke {
3252
+ class Pe {
3250
3253
  constructor(e) {
3251
3254
  d(this, "cache", /* @__PURE__ */ new Map());
3252
3255
  d(this, "totalSizeBytes", 0);
@@ -3262,124 +3265,126 @@ class ke {
3262
3265
  /** Decrements a counter in a cache and if we exceeds
3263
3266
  * a soft limit, removes files with zero counters. */
3264
3267
  removeFile(e, t) {
3265
- return Pe(this.cache, e).counter.dec(t), this.toDelete();
3268
+ return De(this.cache, e).counter.dec(t), this.toDelete();
3266
3269
  }
3267
3270
  /** Returns what results should be deleted to comply with the soft limit. */
3268
3271
  toDelete() {
3269
3272
  if (this.totalSizeBytes <= this.softSizeBytes) return [];
3270
3273
  const e = [];
3271
3274
  let t = 0;
3272
- return dt(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3273
- if (this.totalSizeBytes - t <= this.softSizeBytes) return;
3274
- const r = Pe(this.cache, o);
3275
+ return ut(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3276
+ if (this.totalSizeBytes - t <= this.softSizeBytes)
3277
+ return;
3278
+ const r = De(this.cache, o);
3275
3279
  t += r.size, e.push(r);
3276
3280
  }), e;
3277
3281
  }
3278
3282
  addCache(e, t) {
3279
3283
  const o = this.cache.get(e.path) == null;
3280
- if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0) throw new Error(`empty sizeBytes: ${e}`);
3284
+ if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0)
3285
+ throw new Error(`empty sizeBytes: ${e}`);
3281
3286
  o && (this.totalSizeBytes += e.size);
3282
3287
  }
3283
3288
  removeCache(e) {
3284
3289
  this.cache.delete(e.path), this.totalSizeBytes -= e.size;
3285
3290
  }
3286
3291
  }
3287
- const Ge = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3288
- function Yo(s, e) {
3292
+ const qe = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3293
+ function tn(s, e) {
3289
3294
  return `blob+local://download/${s}#${e.sign(s)}`;
3290
3295
  }
3291
- function en(s) {
3292
- return !!s.match(Ge);
3296
+ function on(s) {
3297
+ return !!s.match(qe);
3293
3298
  }
3294
- function re(s, e) {
3295
- const t = s.match(Ge);
3299
+ function se(s, e) {
3300
+ const t = s.match(qe);
3296
3301
  if (t === null)
3297
3302
  throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
3298
3303
  const { path: o, signature: n } = t.groups;
3299
3304
  return e.verify(o, n, `Signature verification failed for: ${s}`), { path: o, signature: n };
3300
3305
  }
3301
- const tn = G({
3306
+ const nn = V({
3302
3307
  kv: {
3303
- "ctl/file/blobInfo": k.object({
3304
- sizeBytes: k.coerce.number()
3308
+ "ctl/file/blobInfo": L.object({
3309
+ sizeBytes: L.coerce.number()
3305
3310
  })
3306
3311
  }
3307
3312
  });
3308
- function on(s) {
3313
+ function rn(s) {
3309
3314
  return s.kv["ctl/file/blobInfo"].sizeBytes;
3310
3315
  }
3311
- const q = k.object({
3316
+ const J = L.object({
3312
3317
  /** Local file path, to take data for upload */
3313
- localPath: k.string(),
3318
+ localPath: L.string(),
3314
3319
  /** Path signature, to check this data was generated by us */
3315
- pathSignature: k.string(),
3320
+ pathSignature: L.string(),
3316
3321
  /** File size in bytes */
3317
- sizeBytes: k.string(),
3322
+ sizeBytes: L.string(),
3318
3323
  /** Modification time unix timestamp in seconds */
3319
- modificationTime: k.string()
3320
- }), Ve = k.object({
3324
+ modificationTime: L.string()
3325
+ }), Je = L.object({
3321
3326
  /** Pl storage id */
3322
- storageId: k.string(),
3327
+ storageId: L.string(),
3323
3328
  /** Path inside storage */
3324
- path: k.string()
3325
- }), Ur = k.union([
3326
- q,
3327
- Ve
3328
- ]), nn = G({
3329
- data: q,
3329
+ path: L.string()
3330
+ }), Dr = L.union([
3331
+ J,
3332
+ Je
3333
+ ]), sn = V({
3334
+ data: J,
3330
3335
  fields: {
3331
3336
  blob: !1
3332
3337
  }
3333
- }), rn = G({
3338
+ }), an = V({
3334
3339
  fields: {
3335
3340
  incarnation: !1
3336
3341
  }
3337
- }), qe = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3338
- function sn(s, e) {
3342
+ }), Ze = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3343
+ function ln(s, e) {
3339
3344
  const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
3340
3345
  return `blob+remote://download/${t}#${e.sign(t)}`;
3341
3346
  }
3342
- function an(s) {
3343
- return !!s.match(qe);
3347
+ function cn(s) {
3348
+ return !!s.match(Ze);
3344
3349
  }
3345
- function ln(s, e) {
3346
- const t = s.match(qe);
3350
+ function dn(s, e) {
3351
+ const t = s.match(Ze);
3347
3352
  if (t === null)
3348
3353
  throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
3349
3354
  const { content: o, resourceType: n, resourceVersion: r, resourceId: a, signature: i } = t.groups;
3350
3355
  return e.verify(o, i, `Signature verification failed for ${s}`), {
3351
- id: he(BigInt(a)),
3356
+ id: pe(BigInt(a)),
3352
3357
  type: { name: n, version: r }
3353
3358
  };
3354
3359
  }
3355
- function Je(s, e) {
3360
+ function Qe(s, e) {
3356
3361
  return s ? `log+live://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}` : `log+ready://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}`;
3357
3362
  }
3358
- const Ze = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3359
- function A(s) {
3360
- return Ze.test(s);
3363
+ const Xe = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3364
+ function M(s) {
3365
+ return Xe.test(s);
3361
3366
  }
3362
- const Qe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3363
- function cn(s) {
3364
- return Qe.test(s);
3367
+ const Ke = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3368
+ function hn(s) {
3369
+ return Ke.test(s);
3365
3370
  }
3366
- function M(s) {
3371
+ function H(s) {
3367
3372
  let e;
3368
- if (A(s))
3369
- e = s.match(Ze);
3370
- else if (cn(s))
3371
- e = s.match(Qe);
3373
+ if (M(s))
3374
+ e = s.match(Xe);
3375
+ else if (hn(s))
3376
+ e = s.match(Ke);
3372
3377
  else throw new Error(`Log handle is malformed: ${s}`);
3373
3378
  if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
3374
3379
  const { resourceType: t, resourceVersion: o, resourceId: n } = e.groups;
3375
3380
  return {
3376
- id: he(BigInt(n)),
3381
+ id: pe(BigInt(n)),
3377
3382
  type: { name: t, version: o }
3378
3383
  };
3379
3384
  }
3380
- class Le extends Error {
3385
+ class Ue extends Error {
3381
3386
  }
3382
- class dn {
3387
+ class un {
3383
3388
  constructor(e) {
3384
3389
  d(this, "updating");
3385
3390
  this.onUpdate = e;
@@ -3396,9 +3401,9 @@ class dn {
3396
3401
  })());
3397
3402
  }
3398
3403
  }
3399
- class Dr {
3404
+ class Rr {
3400
3405
  constructor(e, t, o, n, r, a) {
3401
- /** Represents a Resource Id to the path of a blob as a map. */
3406
+ /** Represents a unique key to the path of a blob as a map. */
3402
3407
  d(this, "idToDownload", /* @__PURE__ */ new Map());
3403
3408
  /** Writes and removes files to a hard drive and holds a counter for every
3404
3409
  * file that should be kept. */
@@ -3409,41 +3414,42 @@ class Dr {
3409
3414
  d(this, "idToLastLines", /* @__PURE__ */ new Map());
3410
3415
  d(this, "idToProgressLog", /* @__PURE__ */ new Map());
3411
3416
  d(this, "saveDir");
3412
- this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new ke(a.cacheSoftSizeBytes), this.downloadQueue = new j(this.logger, a.nConcurrentDownloads), this.saveDir = b.resolve(n);
3413
- }
3414
- getDownloadedBlob(e, t) {
3415
- if (t === void 0) return w.make((a) => this.getDownloadedBlob(e, a));
3416
- const o = R(e, t), n = U();
3417
- t.addOnDestroy(() => this.releaseBlob(o.id, n));
3418
- const r = this.getDownloadedBlobNoCtx(t.watcher, o, n);
3419
- return r == null && t.markUnstable("download blob is still undefined"), r;
3420
- }
3421
- getDownloadedBlobNoCtx(e, t, o) {
3422
- $("getDownloadedBlob", t.type);
3423
- let n = this.idToDownload.get(t.id);
3424
- if (n === void 0) {
3425
- const a = this.setNewDownloadTask(t);
3417
+ this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new Pe(a.cacheSoftSizeBytes), this.downloadQueue = new G(this.logger, a.nConcurrentDownloads), this.saveDir = T.resolve(n);
3418
+ }
3419
+ getDownloadedBlob(e, t, o, n) {
3420
+ if (t === void 0)
3421
+ return y.make((l) => this.getDownloadedBlob(e, l, o, n));
3422
+ const r = S(e, t), a = w(r.id, o, n), i = D();
3423
+ t.addOnDestroy(() => this.releaseBlob(a, i));
3424
+ const c = this.getDownloadedBlobNoCtx(t.watcher, r, i, o, n);
3425
+ return c == null && t.markUnstable("download blob is still undefined"), c;
3426
+ }
3427
+ getDownloadedBlobNoCtx(e, t, o, n, r) {
3428
+ C("getDownloadedBlob", t.type);
3429
+ let a = this.idToDownload.get(w(t.id, n, r));
3430
+ if (a === void 0) {
3431
+ const c = this.setNewDownloadTask(t);
3426
3432
  this.downloadQueue.push({
3427
- fn: () => this.downloadBlob(a, o),
3428
- recoverableErrorPredicate: (i) => !Te(i)
3429
- }), n = a;
3433
+ fn: () => this.downloadBlob(c, o),
3434
+ recoverableErrorPredicate: (l) => !Le(l)
3435
+ }), a = c;
3430
3436
  }
3431
- n.attach(e, o);
3432
- const r = n.getBlob();
3433
- if (r.done) {
3434
- if (r.result.ok) return r.result.value;
3435
- throw r.result.error;
3437
+ a.attach(e, o);
3438
+ const i = a.getBlob();
3439
+ if (i.done) {
3440
+ if (i.result.ok) return i.result.value;
3441
+ throw i.result.error;
3436
3442
  }
3437
3443
  }
3438
- setNewDownloadTask(e) {
3439
- const t = this.getFilePath(e.id), o = new Ko(
3444
+ setNewDownloadTask(e, t, o) {
3445
+ const n = T.resolve(this.saveDir, w(e.id, t, o)), r = new en(
3440
3446
  this.logger,
3441
3447
  this.clientDownload,
3442
3448
  e,
3443
- t,
3444
- Yo(t, this.signer)
3449
+ n,
3450
+ tn(n, this.signer)
3445
3451
  );
3446
- return this.idToDownload.set(e.id, o), o;
3452
+ return this.idToDownload.set(w(e.id, t, o), r), r;
3447
3453
  }
3448
3454
  async downloadBlob(e, t) {
3449
3455
  await e.download();
@@ -3451,27 +3457,27 @@ class Dr {
3451
3457
  o.done && o.result.ok && this.cache.addCache(e, t);
3452
3458
  }
3453
3459
  getOnDemandBlob(e, t) {
3454
- if (t === void 0) return w.make((a) => this.getOnDemandBlob(e, a));
3455
- const o = E(e) ? x(e, tn, t) : e, n = U();
3460
+ if (t === void 0) return y.make((a) => this.getOnDemandBlob(e, a));
3461
+ const o = O(e) ? A(e, nn, t) : e, n = D();
3456
3462
  return t.addOnDestroy(() => this.releaseOnDemandBlob(o.id, n)), this.getOnDemandBlobNoCtx(o, n);
3457
3463
  }
3458
3464
  getOnDemandBlobNoCtx(e, t) {
3459
- $("getOnDemandBlob", e.type);
3460
- let o = this.idToOnDemand.get(e.id);
3461
- return o === void 0 && (o = new hn(on(e), sn(e, this.signer)), this.idToOnDemand.set(e.id, o)), o.attach(t), o.getHandle();
3465
+ C("getOnDemandBlob", e.type);
3466
+ let o = this.idToOnDemand.get(w(e.id));
3467
+ return o === void 0 && (o = new pn(rn(e), ln(e, this.signer)), this.idToOnDemand.set(w(e.id), o)), o.attach(t), o.getHandle();
3462
3468
  }
3463
3469
  /** Gets a path from a handle. */
3464
3470
  getLocalPath(e) {
3465
- const { path: t } = re(e, this.signer);
3471
+ const { path: t } = se(e, this.signer);
3466
3472
  return t;
3467
3473
  }
3468
3474
  /** Gets a content of a blob by a handle. */
3469
3475
  async getContent(e) {
3470
- if (en(e))
3471
- return await pn(this.getLocalPath(e));
3472
- if (an(e)) {
3473
- const t = ln(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3474
- return await Ce(o);
3476
+ if (on(e))
3477
+ return await fn(this.getLocalPath(e));
3478
+ if (cn(e)) {
3479
+ const t = dn(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3480
+ return await Ee(o);
3475
3481
  }
3476
3482
  throw new Error("Malformed remote handle");
3477
3483
  }
@@ -3480,7 +3486,7 @@ class Dr {
3480
3486
  * Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
3481
3487
  */
3482
3488
  getComputableContent(e) {
3483
- return w.make(
3489
+ return y.make(
3484
3490
  (t) => this.getDownloadedBlob(e, t),
3485
3491
  {
3486
3492
  postprocessValue: (t) => t ? this.getContent(t.handle) : void 0
@@ -3488,21 +3494,21 @@ class Dr {
3488
3494
  ).withStableType();
3489
3495
  }
3490
3496
  getLastLogs(e, t, o) {
3491
- if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
3492
- const n = R(e, o), r = U();
3493
- o.addOnDestroy(() => this.releaseBlob(n.id, r));
3497
+ if (o == null) return y.make((i) => this.getLastLogs(e, t, i));
3498
+ const n = S(e, o), r = D();
3499
+ o.addOnDestroy(() => this.releaseBlob(w(n.id), r));
3494
3500
  const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
3495
3501
  return a == null && o.markUnstable("either a file was not downloaded or logs was not read"), a;
3496
3502
  }
3497
3503
  getLastLogsNoCtx(e, t, o, n) {
3498
- $("getLastLogs", t.type);
3504
+ C("getLastLogs", t.type);
3499
3505
  const r = this.getDownloadedBlobNoCtx(e, t, n);
3500
3506
  if (r == null) return;
3501
- const { path: a } = re(r.handle, this.signer);
3502
- let i = this.idToLastLines.get(t.id);
3507
+ const { path: a } = se(r.handle, this.signer);
3508
+ let i = this.idToLastLines.get(w(t.id));
3503
3509
  if (i == null) {
3504
- const l = new De(a, o);
3505
- this.idToLastLines.set(t.id, l), i = l;
3510
+ const l = new Se(a, o);
3511
+ this.idToLastLines.set(w(t.id), l), i = l;
3506
3512
  }
3507
3513
  const c = i.getOrSchedule(e);
3508
3514
  if (c.error) throw c.error;
@@ -3510,9 +3516,9 @@ class Dr {
3510
3516
  }
3511
3517
  getProgressLog(e, t, o) {
3512
3518
  if (o == null)
3513
- return w.make((i) => this.getProgressLog(e, t, i));
3514
- const n = R(e, o), r = U();
3515
- o.addOnDestroy(() => this.releaseBlob(n.id, r));
3519
+ return y.make((i) => this.getProgressLog(e, t, i));
3520
+ const n = S(e, o), r = D();
3521
+ o.addOnDestroy(() => this.releaseBlob(w(n.id), r));
3516
3522
  const a = this.getProgressLogNoCtx(
3517
3523
  o.watcher,
3518
3524
  n,
@@ -3522,30 +3528,30 @@ class Dr {
3522
3528
  return a === void 0 && o.markUnstable("either a file was not downloaded or a progress log was not read"), a;
3523
3529
  }
3524
3530
  getProgressLogNoCtx(e, t, o, n) {
3525
- $("getProgressLog", t.type);
3531
+ C("getProgressLog", t.type);
3526
3532
  const r = this.getDownloadedBlobNoCtx(e, t, n);
3527
3533
  if (r == null) return;
3528
- const { path: a } = re(r.handle, this.signer);
3529
- let i = this.idToProgressLog.get(t.id);
3534
+ const { path: a } = se(r.handle, this.signer);
3535
+ let i = this.idToProgressLog.get(w(t.id));
3530
3536
  if (i == null) {
3531
- const l = new De(a, 1, o);
3532
- this.idToProgressLog.set(t.id, l), i = l;
3537
+ const l = new Se(a, 1, o);
3538
+ this.idToProgressLog.set(w(t.id), l), i = l;
3533
3539
  }
3534
3540
  const c = i.getOrSchedule(e);
3535
3541
  if (c.error) throw c.error;
3536
3542
  return c.log;
3537
3543
  }
3538
3544
  getLogHandle(e, t) {
3539
- if (t == null) return w.make((n) => this.getLogHandle(e, n));
3540
- const o = R(e, t);
3545
+ if (t == null) return y.make((n) => this.getLogHandle(e, n));
3546
+ const o = S(e, t);
3541
3547
  return this.getLogHandleNoCtx(o);
3542
3548
  }
3543
3549
  getLogHandleNoCtx(e) {
3544
- return $("getLogHandle", e.type), Je(!1, e);
3550
+ return C("getLogHandle", e.type), Qe(!1, e);
3545
3551
  }
3546
3552
  async lastLines(e, t, o, n) {
3547
3553
  const r = await this.clientLogs.lastLines(
3548
- M(e),
3554
+ H(e),
3549
3555
  t,
3550
3556
  BigInt(o ?? 0),
3551
3557
  n
@@ -3560,7 +3566,7 @@ class Dr {
3560
3566
  }
3561
3567
  async readText(e, t, o, n) {
3562
3568
  const r = await this.clientLogs.readText(
3563
- M(e),
3569
+ H(e),
3564
3570
  t,
3565
3571
  BigInt(o ?? 0),
3566
3572
  n
@@ -3582,22 +3588,22 @@ class Dr {
3582
3588
  n.map(async (r) => {
3583
3589
  await m.rm(r.path), this.cache.removeCache(r), this.removeTask(
3584
3590
  r,
3585
- `the task ${y(r.info())} was removedfrom cache along with ${y(n.map((a) => a.info()))}`
3591
+ `the task ${b(r.info())} was removedfrom cache along with ${b(n.map((a) => a.info()))}`
3586
3592
  );
3587
3593
  })
3588
3594
  );
3589
3595
  } else
3590
3596
  o.counter.dec(t) && this.removeTask(
3591
3597
  o,
3592
- `the task ${y(o.info())} was removed from cache`
3598
+ `the task ${b(o.info())} was removed from cache`
3593
3599
  );
3594
3600
  }
3595
3601
  removeTask(e, t) {
3596
- e.abort(t), e.change.markChanged(), this.idToDownload.delete(e.rInfo.id), this.idToLastLines.delete(e.rInfo.id), this.idToProgressLog.delete(e.rInfo.id);
3602
+ e.abort(t), e.change.markChanged(), this.idToDownload.delete(w(e.rInfo.id)), this.idToLastLines.delete(w(e.rInfo.id)), this.idToProgressLog.delete(w(e.rInfo.id));
3597
3603
  }
3598
3604
  async releaseOnDemandBlob(e, t) {
3599
3605
  var n;
3600
- (((n = this.idToOnDemand.get(e)) == null ? void 0 : n.release(t)) ?? !1) && this.idToOnDemand.delete(e);
3606
+ (((n = this.idToOnDemand.get(w(e))) == null ? void 0 : n.release(t)) ?? !1) && this.idToOnDemand.delete(w(e));
3601
3607
  }
3602
3608
  /** Removes all files from a hard drive. */
3603
3609
  async releaseAll() {
@@ -3605,13 +3611,10 @@ class Dr {
3605
3611
  this.idToDownload.delete(t), e.change.markChanged();
3606
3612
  });
3607
3613
  }
3608
- getFilePath(e) {
3609
- return b.resolve(this.saveDir, String(BigInt(e)));
3610
- }
3611
3614
  }
3612
- class hn {
3615
+ class pn {
3613
3616
  constructor(e, t) {
3614
- d(this, "counter", new v());
3617
+ d(this, "counter", new N());
3615
3618
  this.size = e, this.handle = t;
3616
3619
  }
3617
3620
  getHandle() {
@@ -3624,13 +3627,13 @@ class hn {
3624
3627
  return this.counter.dec(e);
3625
3628
  }
3626
3629
  }
3627
- class De {
3630
+ class Se {
3628
3631
  constructor(e, t, o) {
3629
3632
  d(this, "updater");
3630
3633
  d(this, "log");
3631
- d(this, "change", new N());
3634
+ d(this, "change", new $());
3632
3635
  d(this, "error");
3633
- this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new dn(async () => this.update());
3636
+ this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new un(async () => this.update());
3634
3637
  }
3635
3638
  getOrSchedule(e) {
3636
3639
  return this.change.attachWatcher(e), this.updater.schedule(), {
@@ -3640,7 +3643,7 @@ class De {
3640
3643
  }
3641
3644
  async update() {
3642
3645
  try {
3643
- const e = await un(this.path, this.lines, this.patternToSearch);
3646
+ const e = await gn(this.path, this.lines, this.patternToSearch);
3644
3647
  this.log != e && this.change.markChanged(), this.log = e;
3645
3648
  } catch (e) {
3646
3649
  if (e.name == "RpcError" && e.code == "NOT_FOUND") {
@@ -3651,54 +3654,57 @@ class De {
3651
3654
  }
3652
3655
  }
3653
3656
  }
3654
- function un(s, e, t) {
3655
- const o = me.createReadStream(s), n = new S();
3657
+ function gn(s, e, t) {
3658
+ const o = ye.createReadStream(s), n = new I();
3656
3659
  return new Promise((r, a) => {
3657
- const i = mt.createInterface(o, n), c = new pt();
3660
+ const i = yt.createInterface(o, n), c = new ft();
3658
3661
  i.on("line", function(l) {
3659
3662
  t != null && !l.includes(t) || (c.push(l), c.length > e && c.shift());
3660
3663
  }), i.on("error", a), i.on("close", function() {
3661
- r(c.toArray().join(Ue.EOL) + Ue.EOL);
3664
+ r(c.toArray().join(Re.EOL) + Re.EOL);
3662
3665
  });
3663
3666
  });
3664
3667
  }
3665
- async function pn(s) {
3666
- return await Ce(we.toWeb(me.createReadStream(s)));
3668
+ async function fn(s) {
3669
+ return await Ee(be.toWeb(ye.createReadStream(s)));
3667
3670
  }
3668
- function $(s, e) {
3671
+ function C(s, e) {
3669
3672
  if (!e.name.startsWith("Blob/")) {
3670
3673
  let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
3671
- throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Le(t);
3674
+ throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Ue(t);
3672
3675
  }
3673
3676
  }
3674
- const gn = G({});
3675
- function fn(s, e) {
3676
- const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
3677
- return x(t, gn);
3677
+ function w(s, e, t) {
3678
+ return e !== void 0 && t !== void 0 ? `${BigInt(s)}_${e}-${t}` : `${BigInt(s)}`;
3679
+ }
3680
+ const mn = V({});
3681
+ function wn(s, e) {
3682
+ const t = O(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
3683
+ return A(t, mn);
3678
3684
  }
3679
- function mn(s, e, t) {
3680
- const o = L.relative(e, t);
3685
+ function yn(s, e, t) {
3686
+ const o = P.relative(e, t);
3681
3687
  return `plblob+folder://${s.sign(o)}.${o}.blob`;
3682
3688
  }
3683
- function wn(s) {
3689
+ function bn(s) {
3684
3690
  return new URL(s).protocol == "plblob+folder:";
3685
3691
  }
3686
- function yn(s, e, t) {
3692
+ function Tn(s, e, t) {
3687
3693
  const o = new URL(e), [n, r, a] = o.host.split(".");
3688
3694
  s.verify(r, n, `signature verification failed for url: ${e}, subfolder: ${r}`);
3689
- let i = bn(L.join(t, `${r}`), o.pathname.slice(1));
3690
- return (o.pathname == "" || o.pathname == "/") && (i = L.join(i, "index.html")), L.resolve(i);
3695
+ let i = kn(P.join(t, `${r}`), o.pathname.slice(1));
3696
+ return (o.pathname == "" || o.pathname == "/") && (i = P.join(i, "index.html")), P.resolve(i);
3691
3697
  }
3692
- function bn(s, e) {
3693
- const t = L.resolve(s, e), o = L.resolve(s);
3698
+ function kn(s, e) {
3699
+ const t = P.resolve(s, e), o = P.resolve(s);
3694
3700
  if (!t.startsWith(o))
3695
3701
  throw new Error("Path validation failed.");
3696
3702
  return t;
3697
3703
  }
3698
- class Tn {
3704
+ class Ln {
3699
3705
  constructor(e, t, o, n, r, a, i) {
3700
- d(this, "counter", new v());
3701
- d(this, "change", new N());
3706
+ d(this, "counter", new N());
3707
+ d(this, "change", new $());
3702
3708
  d(this, "signalCtl", new AbortController());
3703
3709
  d(this, "error");
3704
3710
  d(this, "done", !1);
@@ -3725,10 +3731,10 @@ class Tn {
3725
3731
  async download() {
3726
3732
  try {
3727
3733
  const e = await this.downloadAndDecompress(this.signalCtl.signal);
3728
- this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${y(this.info())}`);
3734
+ this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${b(this.info())}`);
3729
3735
  } catch (e) {
3730
- if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${y(this.info())}`), kn(e)) {
3731
- this.setError(e), this.change.markChanged(), await le(this.path);
3736
+ if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${b(this.info())}`), Pn(e)) {
3737
+ this.setError(e), this.change.markChanged(), await de(this.path);
3732
3738
  return;
3733
3739
  }
3734
3740
  throw e;
@@ -3736,72 +3742,72 @@ class Tn {
3736
3742
  }
3737
3743
  /** Does the download part and keeps a state of the process. */
3738
3744
  async downloadAndDecompress(e) {
3739
- if (this.state = {}, this.state.parentDir = L.dirname(this.path), await ue(this.state.parentDir), this.state.fileExisted = await pe(this.path), this.state.fileExisted)
3740
- return await Xe(this.path);
3745
+ if (this.state = {}, this.state.parentDir = P.dirname(this.path), await ge(this.state.parentDir), this.state.fileExisted = await fe(this.path), this.state.fileExisted)
3746
+ return await Ye(this.path);
3741
3747
  const { content: t, size: o } = await this.clientDownload.downloadBlob(
3742
3748
  this.rInfo,
3743
3749
  {},
3744
3750
  e
3745
3751
  );
3746
- return this.state.downloaded = !0, await ge(this.logger, this.path, async (n) => {
3752
+ return this.state.downloaded = !0, await me(this.logger, this.path, async (n) => {
3747
3753
  switch (this.state.tempPath = n, this.state.archiveFormat = this.format, this.format) {
3748
3754
  case "tar":
3749
3755
  await m.mkdir(n);
3750
- const r = S.toWeb(ae.extract(n));
3756
+ const r = I.toWeb(ce.extract(n));
3751
3757
  await t.pipeTo(r, { signal: e });
3752
3758
  return;
3753
3759
  case "tgz":
3754
3760
  await m.mkdir(n);
3755
- const a = $e.toWeb(Oe.createGunzip()), i = S.toWeb(ae.extract(n));
3761
+ const a = _e.toWeb(We.createGunzip()), i = I.toWeb(ce.extract(n));
3756
3762
  await t.pipeThrough(a, { signal: e }).pipeTo(i, { signal: e });
3757
3763
  return;
3758
3764
  case "zip":
3759
3765
  this.state.zipPath = this.path + ".zip";
3760
- const c = S.toWeb(ie.createWriteStream(this.state.zipPath));
3761
- await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await wt(this.state.zipPath, n, {
3766
+ const c = I.toWeb(le.createWriteStream(this.state.zipPath));
3767
+ await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await bt(this.state.zipPath, n, {
3762
3768
  filter: (l) => !l.path.endsWith("/")
3763
- }), this.state.zipDecompressed = !0, await ie.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3769
+ }), this.state.zipDecompressed = !0, await le.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3764
3770
  return;
3765
3771
  default:
3766
- ct(this.format);
3772
+ ht(this.format);
3767
3773
  }
3768
3774
  }), this.state.pathCreated = !0, o;
3769
3775
  }
3770
3776
  getURL() {
3771
- if (this.done) return { url: H(this.url) };
3777
+ if (this.done) return { url: j(this.url) };
3772
3778
  if (this.error) return { error: this.error };
3773
3779
  }
3774
3780
  setDone(e) {
3775
- this.done = !0, this.size = e, this.url = mn(this.signer, this.saveDir, this.path);
3781
+ this.done = !0, this.size = e, this.url = yn(this.signer, this.saveDir, this.path);
3776
3782
  }
3777
3783
  setError(e) {
3778
3784
  this.error = String(e);
3779
3785
  }
3780
3786
  abort(e) {
3781
- this.signalCtl.abort(new Ke(e));
3787
+ this.signalCtl.abort(new et(e));
3782
3788
  }
3783
3789
  }
3784
- async function Xe(s) {
3790
+ async function Ye(s) {
3785
3791
  const e = await m.readdir(s, { withFileTypes: !0 });
3786
3792
  return (await Promise.all(
3787
3793
  e.map(async (o) => {
3788
- const n = L.join(s, o.name);
3789
- return o.isDirectory() ? await Xe(n) : (await m.stat(n)).size;
3794
+ const n = P.join(s, o.name);
3795
+ return o.isDirectory() ? await Ye(n) : (await m.stat(n)).size;
3790
3796
  })
3791
3797
  )).reduce((o, n) => o + n, 0);
3792
3798
  }
3793
- async function le(s) {
3799
+ async function de(s) {
3794
3800
  await m.rm(s, { recursive: !0, force: !0 });
3795
3801
  }
3796
- let Ke = class extends Error {
3802
+ let et = class extends Error {
3797
3803
  };
3798
- function kn(s) {
3799
- return s instanceof Ke || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3804
+ function Pn(s) {
3805
+ return s instanceof et || s instanceof q || s instanceof ke || s instanceof Te || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3800
3806
  }
3801
- function O(s, e) {
3807
+ function F(s, e) {
3802
3808
  return `id:${String(BigInt(s))}-${e}`;
3803
3809
  }
3804
- class Sr {
3810
+ class Ir {
3805
3811
  constructor(e, t, o, n, r = {
3806
3812
  cacheSoftSizeBytes: 50 * 1024 * 1024,
3807
3813
  nConcurrentDownloads: 50
@@ -3811,13 +3817,13 @@ class Sr {
3811
3817
  /** Writes and removes files to a hard drive and holds a counter for every
3812
3818
  * file that should be kept. */
3813
3819
  d(this, "cache");
3814
- this.logger = e, this.signer = t, this.clientDownload = o, this.saveDir = n, this.opts = r, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads, {
3820
+ this.logger = e, this.signer = t, this.clientDownload = o, this.saveDir = n, this.opts = r, this.downloadQueue = new G(this.logger, this.opts.nConcurrentDownloads, {
3815
3821
  type: "exponentialWithMaxDelayBackoff",
3816
3822
  initialDelay: 1e4,
3817
3823
  maxDelay: 3e4,
3818
3824
  backoffMultiplier: 1.5,
3819
3825
  jitter: 0.5
3820
- }), this.cache = new ke(this.opts.cacheSoftSizeBytes);
3826
+ }), this.cache = new Pe(this.opts.cacheSoftSizeBytes);
3821
3827
  }
3822
3828
  info() {
3823
3829
  return {
@@ -3832,14 +3838,14 @@ class Sr {
3832
3838
  * @returns full path to the referenced file
3833
3839
  */
3834
3840
  getPathForCustomProtocol(e) {
3835
- if (wn(e))
3836
- return yn(this.signer, e, this.saveDir);
3841
+ if (bn(e))
3842
+ return Tn(this.signer, e, this.saveDir);
3837
3843
  throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
3838
3844
  }
3839
3845
  extractArchiveAndGetURL(e, t, o) {
3840
3846
  if (o === void 0)
3841
- return w.make((i) => this.extractArchiveAndGetURL(e, t, i));
3842
- const n = E(e) ? fn(e, o) : e, r = U();
3847
+ return y.make((i) => this.extractArchiveAndGetURL(e, t, i));
3848
+ const n = O(e) ? wn(e, o) : e, r = D();
3843
3849
  o.addOnDestroy(() => this.releasePath(n.id, t, r));
3844
3850
  const a = this.extractArchiveAndGetURLNoCtx(n, t, o.watcher, r);
3845
3851
  if ((a == null ? void 0 : a.url) === void 0 && o.markUnstable(
@@ -3849,13 +3855,13 @@ class Sr {
3849
3855
  return a == null ? void 0 : a.url;
3850
3856
  }
3851
3857
  extractArchiveAndGetURLNoCtx(e, t, o, n) {
3852
- const r = this.idToDownload.get(O(e.id, t));
3858
+ const r = this.idToDownload.get(F(e.id, t));
3853
3859
  if (r != null)
3854
3860
  return r.attach(o, n), r.getURL();
3855
3861
  const a = this.setNewTask(o, e, t, n);
3856
3862
  return this.downloadQueue.push({
3857
3863
  fn: async () => this.downloadUrl(a, n),
3858
- recoverableErrorPredicate: (i) => !Te(i)
3864
+ recoverableErrorPredicate: (i) => !Le(i)
3859
3865
  }), a.getURL();
3860
3866
  }
3861
3867
  /** Downloads and extracts a tar archive if it wasn't downloaded yet. */
@@ -3866,37 +3872,37 @@ class Sr {
3866
3872
  /** Removes a directory and aborts a downloading task when all callers
3867
3873
  * are not interested in it. */
3868
3874
  async releasePath(e, t, o) {
3869
- const n = this.idToDownload.get(O(e, t));
3875
+ const n = this.idToDownload.get(F(e, t));
3870
3876
  if (n != null)
3871
3877
  if (this.cache.existsFile(n.path)) {
3872
3878
  const r = this.cache.removeFile(n.path, o);
3873
3879
  await Promise.all(
3874
3880
  r.map(async (a) => {
3875
- await le(a.path), this.cache.removeCache(a), this.removeTask(
3881
+ await de(a.path), this.cache.removeCache(a), this.removeTask(
3876
3882
  a,
3877
- `the task ${y(a.info())} was removedfrom cache along with ${y(r.map((i) => i.info()))}`
3883
+ `the task ${b(a.info())} was removedfrom cache along with ${b(r.map((i) => i.info()))}`
3878
3884
  );
3879
3885
  })
3880
3886
  );
3881
3887
  } else
3882
3888
  n.counter.dec(o) && this.removeTask(
3883
3889
  n,
3884
- `the task ${y(n.info())} was removed from cache`
3890
+ `the task ${b(n.info())} was removed from cache`
3885
3891
  );
3886
3892
  }
3887
3893
  /** Removes all files from a hard drive. */
3888
3894
  async releaseAll() {
3889
3895
  this.downloadQueue.stop(), await Promise.all(
3890
3896
  Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
3891
- await le(t.path), this.cache.removeCache(t), this.removeTask(
3897
+ await de(t.path), this.cache.removeCache(t), this.removeTask(
3892
3898
  t,
3893
- `the task ${y(t.info())} was released when the driver was closed`
3899
+ `the task ${b(t.info())} was released when the driver was closed`
3894
3900
  );
3895
3901
  })
3896
3902
  );
3897
3903
  }
3898
3904
  setNewTask(e, t, o, n) {
3899
- const r = new Tn(
3905
+ const r = new Ln(
3900
3906
  this.logger,
3901
3907
  this.signer,
3902
3908
  this.saveDir,
@@ -3905,19 +3911,19 @@ class Sr {
3905
3911
  o,
3906
3912
  this.clientDownload
3907
3913
  );
3908
- return r.attach(e, n), this.idToDownload.set(O(t.id, o), r), r;
3914
+ return r.attach(e, n), this.idToDownload.set(F(t.id, o), r), r;
3909
3915
  }
3910
3916
  removeTask(e, t) {
3911
- e.abort(t), e.change.markChanged(), this.idToDownload.delete(O(e.rInfo.id, e.format));
3917
+ e.abort(t), e.change.markChanged(), this.idToDownload.delete(F(e.rInfo.id, e.format));
3912
3918
  }
3913
3919
  getFilePath(e, t) {
3914
- return b.join(this.saveDir, `${String(BigInt(e))}_${t}`);
3920
+ return T.join(this.saveDir, `${String(BigInt(e))}_${t}`);
3915
3921
  }
3916
3922
  }
3917
- class Ln {
3923
+ class Un {
3918
3924
  constructor(e, t, o, n, r, a) {
3919
- d(this, "change", new N());
3920
- d(this, "counter", new v());
3925
+ d(this, "change", new $());
3926
+ d(this, "counter", new N());
3921
3927
  d(this, "nMaxUploads");
3922
3928
  d(this, "nPartsWithThisUploadSpeed", 0);
3923
3929
  d(this, "nPartsToIncreaseUpload", 10);
@@ -3931,21 +3937,21 @@ class Ln {
3931
3937
  * At this case, the task will show progress == 1.0. */
3932
3938
  d(this, "alreadyExisted", !1);
3933
3939
  this.logger = e, this.clientBlob = t, this.clientProgress = o, this.maxNConcurrentPartsUpload = n, this.res = a, this.nMaxUploads = this.maxNConcurrentPartsUpload;
3934
- const { uploadData: i, progress: c } = Un(a, r);
3940
+ const { uploadData: i, progress: c } = Rn(a, r);
3935
3941
  this.uploadData = i, this.progress = c;
3936
3942
  }
3937
3943
  getProgress(e, t) {
3938
3944
  if (this.incCounter(e, t), this.failed)
3939
3945
  throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
3940
- return Rn(this.progress);
3946
+ return In(this.progress);
3941
3947
  }
3942
3948
  shouldScheduleUpload() {
3943
- return Dn(this.progress);
3949
+ return Sn(this.progress);
3944
3950
  }
3945
3951
  /** Uploads a blob if it's not BlobIndex. */
3946
3952
  async uploadBlobTask() {
3947
3953
  try {
3948
- await Pn(
3954
+ await Dn(
3949
3955
  this.logger,
3950
3956
  this.clientBlob,
3951
3957
  this.res,
@@ -3959,30 +3965,30 @@ class Ln {
3959
3965
  }
3960
3966
  ), this.change.markChanged();
3961
3967
  } catch (e) {
3962
- if (this.setRetriableError(e), Re(e)) {
3968
+ if (this.setRetriableError(e), Ie(e)) {
3963
3969
  this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
3964
3970
  return;
3965
3971
  }
3966
- if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Ye(e)) {
3972
+ if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), tt(e)) {
3967
3973
  this.setTerminalError(e);
3968
3974
  return;
3969
3975
  }
3970
- throw Bn(e) && (this.nMaxUploads = Cn(this.logger, this.nMaxUploads, 1)), e;
3976
+ throw Cn(e) && (this.nMaxUploads = En(this.logger, this.nMaxUploads, 1)), e;
3971
3977
  }
3972
3978
  }
3973
3979
  async updateStatus() {
3974
3980
  var e;
3975
3981
  try {
3976
- const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Nn(this.alreadyExisted, vn(t));
3982
+ const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Bn(this.alreadyExisted, $n(t));
3977
3983
  this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (o == null ? void 0 : o.progress)) && this.change.markChanged();
3978
3984
  } catch (t) {
3979
3985
  if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
3980
3986
  this.logger.warn("deadline exceeded while getting a status of BlobImport");
3981
3987
  return;
3982
3988
  }
3983
- if (Re(t)) {
3989
+ if (Ie(t)) {
3984
3990
  this.logger.warn(
3985
- `resource was not found while updating a status of BlobImport: ${t}, ${y(this.res)}`
3991
+ `resource was not found while updating a status of BlobImport: ${t}, ${b(this.res)}`
3986
3992
  ), this.change.markChanged(), this.setDone(!0);
3987
3993
  return;
3988
3994
  }
@@ -3998,7 +4004,7 @@ class Ln {
3998
4004
  this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
3999
4005
  }
4000
4006
  setDoneIfOutputSet(e) {
4001
- Sn(e) && (this.setDone(!0), this.alreadyExisted = !0);
4007
+ vn(e) && (this.setDone(!0), this.alreadyExisted = !0);
4002
4008
  }
4003
4009
  setDone(e) {
4004
4010
  this.progress.done = e, e && (this.progress.lastError = void 0);
@@ -4013,8 +4019,8 @@ class Ln {
4013
4019
  return this.counter.isZero();
4014
4020
  }
4015
4021
  }
4016
- async function Pn(s, e, t, o, n, r) {
4017
- yt(ce(t), "the upload operation can be done only for BlobUploads");
4022
+ async function Dn(s, e, t, o, n, r) {
4023
+ Tt(he(t), "the upload operation can be done only for BlobUploads");
4018
4024
  const a = 1e4;
4019
4025
  if (n()) return;
4020
4026
  const i = await e.initUpload(t, { timeout: a });
@@ -4028,78 +4034,78 @@ async function Pn(s, e, t, o, n, r) {
4028
4034
  BigInt(o.modificationTime),
4029
4035
  l,
4030
4036
  { timeout: a }
4031
- ), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = $n(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
4037
+ ), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = _n(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
4032
4038
  };
4033
- await fe(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
4039
+ await we(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
4034
4040
  }
4035
- function Un(s, e) {
4041
+ function Rn(s, e) {
4036
4042
  let t, o;
4037
- return ce(s) && (o = q.parse(s.data), t = In(e, o.localPath, o.pathSignature)), {
4043
+ return he(s) && (o = J.parse(s.data), t = Nn(e, o.localPath, o.pathSignature)), {
4038
4044
  uploadData: o,
4039
4045
  progress: {
4040
4046
  done: !1,
4041
4047
  status: void 0,
4042
- isUpload: ce(s),
4048
+ isUpload: he(s),
4043
4049
  isUploadSignMatch: t,
4044
4050
  lastError: void 0
4045
4051
  }
4046
4052
  };
4047
4053
  }
4048
- function Dn(s) {
4054
+ function Sn(s) {
4049
4055
  return s.isUpload && (s.isUploadSignMatch ?? !1);
4050
4056
  }
4051
- function Rn(s) {
4057
+ function In(s) {
4052
4058
  return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
4053
4059
  }
4054
- function Sn(s) {
4060
+ function vn(s) {
4055
4061
  return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
4056
4062
  }
4057
- function ce(s) {
4063
+ function he(s) {
4058
4064
  return s.type.name.startsWith("BlobUpload");
4059
4065
  }
4060
- function In(s, e, t) {
4066
+ function Nn(s, e, t) {
4061
4067
  try {
4062
4068
  return s.verify(e, t), !0;
4063
4069
  } catch {
4064
4070
  return !1;
4065
4071
  }
4066
4072
  }
4067
- function vn(s) {
4073
+ function $n(s) {
4068
4074
  return {
4069
4075
  progress: s.progress ?? 0,
4070
4076
  bytesProcessed: Number(s.bytesProcessed),
4071
4077
  bytesTotal: Number(s.bytesTotal)
4072
4078
  };
4073
4079
  }
4074
- function Nn(s, e) {
4080
+ function Bn(s, e) {
4075
4081
  return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
4076
4082
  progress: 1,
4077
4083
  bytesProcessed: Number(e.bytesTotal),
4078
4084
  bytesTotal: Number(e.bytesTotal)
4079
4085
  } : e;
4080
4086
  }
4081
- function Re(s) {
4087
+ function Ie(s) {
4082
4088
  return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
4083
4089
  }
4084
- function Ye(s) {
4085
- return s instanceof ze || s instanceof xe || s instanceof Me;
4090
+ function tt(s) {
4091
+ return s instanceof Ae || s instanceof Me || s instanceof je;
4086
4092
  }
4087
- function Bn(s) {
4093
+ function Cn(s) {
4088
4094
  return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
4089
4095
  }
4090
- function $n(s, e, t) {
4096
+ function _n(s, e, t) {
4091
4097
  const o = Math.min(e + 2, t);
4092
4098
  return o != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${o}`), o;
4093
4099
  }
4094
- function Cn(s, e, t) {
4100
+ function En(s, e, t) {
4095
4101
  const o = Math.max(Math.round(e / 2), t);
4096
4102
  return o != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${o}`), o;
4097
4103
  }
4098
- function _n(s, e) {
4099
- const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
4100
- return t.resourceType.name.startsWith("BlobUpload") ? x(t, nn) : x(t, rn);
4104
+ function On(s, e) {
4105
+ const t = O(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
4106
+ return t.resourceType.name.startsWith("BlobUpload") ? A(t, sn) : A(t, an);
4101
4107
  }
4102
- class Ir {
4108
+ class vr {
4103
4109
  constructor(e, t, o, n, r = {
4104
4110
  nConcurrentPartUploads: 10,
4105
4111
  nConcurrentGetProgresses: 10,
@@ -4115,14 +4121,14 @@ class Ir {
4115
4121
  d(this, "keepRunning", !1);
4116
4122
  /** Actual state of main loop. */
4117
4123
  d(this, "currentLoop");
4118
- this.logger = e, this.signer = t, this.clientBlob = o, this.clientProgress = n, this.opts = r, this.uploadQueue = new j(this.logger, 1, {
4124
+ this.logger = e, this.signer = t, this.clientBlob = o, this.clientProgress = n, this.opts = r, this.uploadQueue = new G(this.logger, 1, {
4119
4125
  type: "exponentialWithMaxDelayBackoff",
4120
4126
  initialDelay: 20,
4121
4127
  maxDelay: 15e3,
4122
4128
  // 15 seconds
4123
4129
  backoffMultiplier: 1.5,
4124
4130
  jitter: 0.5
4125
- }), this.hooks = new _e(
4131
+ }), this.hooks = new Oe(
4126
4132
  () => this.startUpdating(),
4127
4133
  () => this.stopUpdating(),
4128
4134
  { stopDebounce: r.stopPollingDelay },
@@ -4130,16 +4136,16 @@ class Ir {
4130
4136
  );
4131
4137
  }
4132
4138
  getProgressId(e, t) {
4133
- if (t == null) return w.make((a) => this.getProgressId(e, a));
4134
- const o = E(e) ? _n(e, t) : e, n = U();
4139
+ if (t == null) return y.make((a) => this.getProgressId(e, a));
4140
+ const o = O(e) ? On(e, t) : e, n = D();
4135
4141
  return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(o.id, n)), this.getProgressIdNoCtx(t.watcher, o, n);
4136
4142
  }
4137
4143
  getProgressIdNoCtx(e, t, o) {
4138
- On("getProgressId", t.type);
4144
+ Wn("getProgressId", t.type);
4139
4145
  const n = this.idToProgress.get(t.id);
4140
4146
  if (n != null)
4141
4147
  return n.setDoneIfOutputSet(t), n.getProgress(e, o);
4142
- const r = new Ln(
4148
+ const r = new Un(
4143
4149
  this.logger,
4144
4150
  this.clientBlob,
4145
4151
  this.clientProgress,
@@ -4149,7 +4155,7 @@ class Ir {
4149
4155
  );
4150
4156
  return this.idToProgress.set(t.id, r), r.shouldScheduleUpload() && this.uploadQueue.push({
4151
4157
  fn: () => r.uploadBlobTask(),
4152
- recoverableErrorPredicate: (a) => !Ye(a)
4158
+ recoverableErrorPredicate: (a) => !tt(a)
4153
4159
  }), r.setDoneIfOutputSet(t), r.getProgress(e, o);
4154
4160
  }
4155
4161
  /** Decrement counters for the file and remove an uploading if counter == 0. */
@@ -4178,7 +4184,7 @@ class Ir {
4178
4184
  const e = this.scheduledOnNextState;
4179
4185
  this.scheduledOnNextState = [];
4180
4186
  try {
4181
- await fe(
4187
+ await we(
4182
4188
  this.opts.nConcurrentGetProgresses,
4183
4189
  this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
4184
4190
  ), e.forEach((t) => t.resolve());
@@ -4186,25 +4192,25 @@ class Ir {
4186
4192
  console.error(t), e.forEach((o) => o.reject(t));
4187
4193
  }
4188
4194
  if (!this.keepRunning) break;
4189
- await Fe.wait(this.opts.pollingInterval);
4195
+ await ze.wait(this.opts.pollingInterval);
4190
4196
  }
4191
4197
  this.currentLoop = void 0;
4192
4198
  }
4193
4199
  getAllNotDoneProgresses() {
4194
- return Array.from(this.idToProgress.entries()).filter(([e, t]) => !En(t.progress)).map(([e, t]) => t);
4200
+ return Array.from(this.idToProgress.entries()).filter(([e, t]) => !Fn(t.progress)).map(([e, t]) => t);
4195
4201
  }
4196
4202
  }
4197
- function En(s) {
4203
+ function Fn(s) {
4198
4204
  var e;
4199
4205
  return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
4200
4206
  }
4201
- function On(s, e) {
4207
+ function Wn(s, e) {
4202
4208
  if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
4203
- throw new Le(
4209
+ throw new Ue(
4204
4210
  `${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
4205
4211
  );
4206
4212
  }
4207
- class vr {
4213
+ class Nr {
4208
4214
  constructor(e, t, o = {
4209
4215
  nConcurrentGetLogs: 10,
4210
4216
  pollingInterval: 1e3,
@@ -4221,7 +4227,7 @@ class vr {
4221
4227
  d(this, "keepRunning", !1);
4222
4228
  /** Actual state of main loop. */
4223
4229
  d(this, "currentLoop");
4224
- this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new _e(
4230
+ this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new Oe(
4225
4231
  () => this.startUpdating(),
4226
4232
  () => this.stopUpdating(),
4227
4233
  { stopDebounce: o.stopPollingDelay },
@@ -4229,8 +4235,8 @@ class vr {
4229
4235
  );
4230
4236
  }
4231
4237
  getLastLogs(e, t, o) {
4232
- if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
4233
- const n = R(e, o), r = U();
4238
+ if (o == null) return y.make((i) => this.getLastLogs(e, t, i));
4239
+ const n = S(e, o), r = D();
4234
4240
  o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseLastLogs(n.id, r));
4235
4241
  const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
4236
4242
  return o.markUnstable(
@@ -4238,10 +4244,10 @@ class vr {
4238
4244
  ), a;
4239
4245
  }
4240
4246
  getLastLogsNoCtx(e, t, o, n) {
4241
- se("getLastLogs", t.type);
4247
+ ie("getLastLogs", t.type);
4242
4248
  let r = this.idToLastLines.get(t.id);
4243
4249
  if (r == null) {
4244
- const i = new Se(this.logger, this.clientLogs, t, o);
4250
+ const i = new ve(this.logger, this.clientLogs, t, o);
4245
4251
  this.idToLastLines.set(t.id, i), r = i;
4246
4252
  }
4247
4253
  r.attach(e, n);
@@ -4251,8 +4257,8 @@ class vr {
4251
4257
  }
4252
4258
  getProgressLog(e, t, o) {
4253
4259
  if (o == null)
4254
- return w.make((i) => this.getProgressLog(e, t, i));
4255
- const n = R(e, o), r = U();
4260
+ return y.make((i) => this.getProgressLog(e, t, i));
4261
+ const n = S(e, o), r = D();
4256
4262
  o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseProgressLog(n.id, r));
4257
4263
  const a = this.getProgressLogNoCtx(o.watcher, n, t, r);
4258
4264
  return o.markUnstable(
@@ -4260,10 +4266,10 @@ class vr {
4260
4266
  ), a;
4261
4267
  }
4262
4268
  getProgressLogNoCtx(e, t, o, n) {
4263
- se("getProgressLog", t.type);
4269
+ ie("getProgressLog", t.type);
4264
4270
  let r = this.idToProgressLog.get(t.id);
4265
4271
  if (r == null) {
4266
- const i = new Se(this.logger, this.clientLogs, t, 1, o);
4272
+ const i = new ve(this.logger, this.clientLogs, t, 1, o);
4267
4273
  this.idToProgressLog.set(t.id, i), r = i;
4268
4274
  }
4269
4275
  r.attach(e, n);
@@ -4272,18 +4278,18 @@ class vr {
4272
4278
  return a.log;
4273
4279
  }
4274
4280
  getLogHandle(e, t) {
4275
- if (t == null) return w.make((r) => this.getLogHandle(e, r));
4276
- const o = R(e, t), n = this.getLogHandleNoCtx(o);
4277
- return t.markUnstable(`live_log:${at(o.id)}`), n;
4281
+ if (t == null) return y.make((r) => this.getLogHandle(e, r));
4282
+ const o = S(e, t), n = this.getLogHandleNoCtx(o);
4283
+ return t.markUnstable(`live_log:${ct(o.id)}`), n;
4278
4284
  }
4279
4285
  getLogHandleNoCtx(e) {
4280
- return se("getLogHandle", e.type), Je(!0, e);
4286
+ return ie("getLogHandle", e.type), Qe(!0, e);
4281
4287
  }
4282
4288
  async lastLines(e, t, o, n) {
4283
4289
  return await this.tryWithNotFound(
4284
4290
  e,
4285
4291
  () => this.clientLogs.lastLines(
4286
- M(e),
4292
+ H(e),
4287
4293
  t,
4288
4294
  BigInt(o ?? 0),
4289
4295
  n
@@ -4294,7 +4300,7 @@ class vr {
4294
4300
  return await this.tryWithNotFound(
4295
4301
  e,
4296
4302
  () => this.clientLogs.readText(
4297
- M(e),
4303
+ H(e),
4298
4304
  t,
4299
4305
  BigInt(o ?? 0),
4300
4306
  n
@@ -4302,7 +4308,7 @@ class vr {
4302
4308
  );
4303
4309
  }
4304
4310
  async tryWithNotFound(e, t) {
4305
- if (!A(e))
4311
+ if (!M(e))
4306
4312
  throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
4307
4313
  try {
4308
4314
  const o = await t();
@@ -4346,7 +4352,7 @@ class vr {
4346
4352
  this.scheduledOnNextState = [];
4347
4353
  try {
4348
4354
  const t = this.getAllLogs();
4349
- await fe(
4355
+ await we(
4350
4356
  this.opts.nConcurrentGetLogs,
4351
4357
  t.map((o) => async () => await o.update())
4352
4358
  ), e.forEach((o) => o.resolve());
@@ -4354,7 +4360,7 @@ class vr {
4354
4360
  console.error(t), e.forEach((o) => o.reject(t));
4355
4361
  }
4356
4362
  if (!this.keepRunning) break;
4357
- await Fe.wait(this.opts.pollingInterval);
4363
+ await ze.wait(this.opts.pollingInterval);
4358
4364
  }
4359
4365
  this.currentLoop = void 0;
4360
4366
  }
@@ -4362,12 +4368,12 @@ class vr {
4362
4368
  return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
4363
4369
  }
4364
4370
  }
4365
- class Se {
4371
+ class ve {
4366
4372
  constructor(e, t, o, n, r) {
4367
4373
  d(this, "logs");
4368
4374
  d(this, "error");
4369
- d(this, "change", new N());
4370
- d(this, "counter", new v());
4375
+ d(this, "change", new $());
4376
+ d(this, "counter", new N());
4371
4377
  this.logger = e, this.clientLogs = t, this.rInfo = o, this.lines = n, this.patternToSearch = r;
4372
4378
  }
4373
4379
  getLog() {
@@ -4398,29 +4404,29 @@ class Se {
4398
4404
  return;
4399
4405
  }
4400
4406
  throw this.logger.error(
4401
- `Stream log lines for ${y(this.rInfo.id)} failed, reason: ${e}`
4407
+ `Stream log lines for ${b(this.rInfo.id)} failed, reason: ${e}`
4402
4408
  ), e;
4403
4409
  }
4404
4410
  }
4405
4411
  }
4406
- function se(s, e) {
4412
+ function ie(s, e) {
4407
4413
  if (!e.name.startsWith("StreamWorkdir"))
4408
- throw new Le(
4414
+ throw new Ue(
4409
4415
  `${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
4410
4416
  );
4411
4417
  }
4412
- class Nr {
4418
+ class $r {
4413
4419
  constructor(e, t, o) {
4414
4420
  this.logger = e, this.logsStreamDriver = t, this.downloadDriver = o;
4415
4421
  }
4416
4422
  getLastLogs(e, t, o) {
4417
- if (o === void 0) return w.make((r) => this.getLastLogs(e, t, r));
4418
- const n = W(o, e);
4423
+ if (o === void 0) return y.make((r) => this.getLastLogs(e, t, r));
4424
+ const n = z(o, e);
4419
4425
  if (n === void 0) {
4420
4426
  o.markUnstable("no stream in stream manager");
4421
4427
  return;
4422
4428
  }
4423
- if (F(n)) return this.downloadDriver.getLastLogs(n, t, o);
4429
+ if (W(n)) return this.downloadDriver.getLastLogs(n, t, o);
4424
4430
  try {
4425
4431
  return this.logsStreamDriver.getLastLogs(n, t, o);
4426
4432
  } catch (r) {
@@ -4433,13 +4439,13 @@ class Nr {
4433
4439
  }
4434
4440
  getProgressLog(e, t, o) {
4435
4441
  if (o === void 0)
4436
- return w.make((r) => this.getProgressLog(e, t, r));
4437
- const n = W(o, e);
4442
+ return y.make((r) => this.getProgressLog(e, t, r));
4443
+ const n = z(o, e);
4438
4444
  if (n === void 0) {
4439
4445
  o.markUnstable("no stream in stream manager");
4440
4446
  return;
4441
4447
  }
4442
- if (F(n)) return this.downloadDriver.getProgressLog(n, t, o);
4448
+ if (W(n)) return this.downloadDriver.getProgressLog(n, t, o);
4443
4449
  try {
4444
4450
  return this.logsStreamDriver.getProgressLog(n, t, o);
4445
4451
  } catch (r) {
@@ -4452,13 +4458,13 @@ class Nr {
4452
4458
  }
4453
4459
  getProgressLogWithInfo(e, t, o) {
4454
4460
  if (o === void 0)
4455
- return w.make((r) => this.getProgressLogWithInfo(e, t, r));
4456
- const n = W(o, e);
4461
+ return y.make((r) => this.getProgressLogWithInfo(e, t, r));
4462
+ const n = z(o, e);
4457
4463
  if (n === void 0) {
4458
4464
  o.markUnstable("no stream in stream manager");
4459
4465
  return;
4460
4466
  }
4461
- if (F(n))
4467
+ if (W(n))
4462
4468
  return {
4463
4469
  progressLine: this.downloadDriver.getProgressLog(n, t, o),
4464
4470
  live: !1
@@ -4477,25 +4483,25 @@ class Nr {
4477
4483
  }
4478
4484
  }
4479
4485
  getLogHandle(e, t) {
4480
- if (t === void 0) return w.make((n) => this.getLogHandle(e, n));
4481
- const o = W(t, e);
4486
+ if (t === void 0) return y.make((n) => this.getLogHandle(e, n));
4487
+ const o = z(t, e);
4482
4488
  if (o === void 0) {
4483
4489
  t.markUnstable("no stream in stream manager");
4484
4490
  return;
4485
4491
  }
4486
- return F(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
4492
+ return W(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
4487
4493
  }
4488
4494
  async lastLines(e, t, o, n) {
4489
- return A(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
4495
+ return M(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
4490
4496
  }
4491
4497
  async readText(e, t, o, n) {
4492
- return A(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
4498
+ return M(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
4493
4499
  }
4494
4500
  }
4495
- function F(s) {
4501
+ function W(s) {
4496
4502
  return !s.type.name.startsWith("StreamWorkdir");
4497
4503
  }
4498
- function W(s, e) {
4504
+ function z(s, e) {
4499
4505
  var t;
4500
4506
  return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
4501
4507
  }
@@ -4511,11 +4517,11 @@ class Br {
4511
4517
  /** Writes and removes files to a hard drive and holds a counter for every
4512
4518
  * file that should be kept. */
4513
4519
  d(this, "cache");
4514
- this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads), this.cache = new ke(this.opts.cacheSoftSizeBytes), this.downloadHelper = new He(t);
4520
+ this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new G(this.logger, this.opts.nConcurrentDownloads), this.cache = new Pe(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ge(t);
4515
4521
  }
4516
4522
  getPath(e, t) {
4517
- if (t === void 0) return w.make((r) => this.getPath(e, r));
4518
- const o = U();
4523
+ if (t === void 0) return y.make((r) => this.getPath(e, r));
4524
+ const o = D();
4519
4525
  t.addOnDestroy(() => this.releasePath(e, o));
4520
4526
  const n = this.getPathNoCtx(e, t.watcher, o);
4521
4527
  return (n == null ? void 0 : n.path) === void 0 && t.markUnstable(
@@ -4546,45 +4552,45 @@ class Br {
4546
4552
  const r = this.cache.removeFile(n.path, t);
4547
4553
  await Promise.all(
4548
4554
  r.map(async (a) => {
4549
- await de(a.path), this.cache.removeCache(a), this.removeTask(
4555
+ await ue(a.path), this.cache.removeCache(a), this.removeTask(
4550
4556
  a,
4551
- `the task ${y(a.info())} was removedfrom cache along with ${y(r.map((i) => i.info()))}`
4557
+ `the task ${b(a.info())} was removedfrom cache along with ${b(r.map((i) => i.info()))}`
4552
4558
  );
4553
4559
  })
4554
4560
  );
4555
4561
  } else
4556
4562
  n.counter.dec(t) && this.removeTask(
4557
4563
  n,
4558
- `the task ${y(n.info())} was removed from cache`
4564
+ `the task ${b(n.info())} was removed from cache`
4559
4565
  );
4560
4566
  }
4561
4567
  /** Removes all files from a hard drive. */
4562
4568
  async releaseAll() {
4563
4569
  this.downloadQueue.stop(), await Promise.all(
4564
4570
  Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
4565
- await de(t.path), this.cache.removeCache(t), this.removeTask(
4571
+ await ue(t.path), this.cache.removeCache(t), this.removeTask(
4566
4572
  t,
4567
- `the task ${y(t.info())} was released when the driver was closed`
4573
+ `the task ${b(t.info())} was released when the driver was closed`
4568
4574
  );
4569
4575
  })
4570
4576
  );
4571
4577
  }
4572
4578
  setNewTask(e, t, o) {
4573
- const n = new Fn(this.logger, this.getFilePath(t), t);
4579
+ const n = new zn(this.logger, this.getFilePath(t), t);
4574
4580
  return n.attach(e, o), this.urlToDownload.set(t.toString(), n), n;
4575
4581
  }
4576
4582
  removeTask(e, t) {
4577
4583
  e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
4578
4584
  }
4579
4585
  getFilePath(e) {
4580
- const t = gt("sha256").update(e.toString()).digest("hex");
4581
- return b.join(this.saveDir, t);
4586
+ const t = mt("sha256").update(e.toString()).digest("hex");
4587
+ return T.join(this.saveDir, t);
4582
4588
  }
4583
4589
  }
4584
- class Fn {
4590
+ class zn {
4585
4591
  constructor(e, t, o) {
4586
- d(this, "counter", new v());
4587
- d(this, "change", new N());
4592
+ d(this, "counter", new N());
4593
+ d(this, "change", new $());
4588
4594
  d(this, "signalCtl", new AbortController());
4589
4595
  d(this, "error");
4590
4596
  d(this, "done", !1);
@@ -4608,30 +4614,30 @@ class Fn {
4608
4614
  const o = await this.downloadAndUntar(e, t, this.signalCtl.signal);
4609
4615
  this.setDone(o), this.change.markChanged();
4610
4616
  } catch (o) {
4611
- if (o instanceof Ie || o instanceof V) {
4612
- this.setError(o), this.change.markChanged(), await de(this.path);
4617
+ if (o instanceof Ne || o instanceof q) {
4618
+ this.setError(o), this.change.markChanged(), await ue(this.path);
4613
4619
  return;
4614
4620
  }
4615
4621
  throw o;
4616
4622
  }
4617
4623
  }
4618
4624
  async downloadAndUntar(e, t, o) {
4619
- if (await ue(b.dirname(this.path)), await pe(this.path))
4620
- return await et(this.path);
4625
+ if (await ge(T.dirname(this.path)), await fe(this.path))
4626
+ return await ot(this.path);
4621
4627
  const n = await e.download(this.url.toString(), {}, o);
4622
4628
  let r = n.content;
4623
4629
  if (t) {
4624
- const a = $e.toWeb(Oe.createGunzip());
4630
+ const a = _e.toWeb(We.createGunzip());
4625
4631
  r = r.pipeThrough(a, { signal: o });
4626
4632
  }
4627
- return await ge(this.logger, this.path, async (a) => {
4633
+ return await me(this.logger, this.path, async (a) => {
4628
4634
  await m.mkdir(a);
4629
- const i = S.toWeb(ae.extract(a));
4635
+ const i = I.toWeb(ce.extract(a));
4630
4636
  await r.pipeTo(i, { signal: o });
4631
4637
  }), n.size;
4632
4638
  }
4633
4639
  getPath() {
4634
- if (this.done) return { path: H(this.path) };
4640
+ if (this.done) return { path: j(this.path) };
4635
4641
  if (this.error) return { error: this.error };
4636
4642
  }
4637
4643
  setDone(e) {
@@ -4641,30 +4647,30 @@ class Fn {
4641
4647
  this.error = String(e);
4642
4648
  }
4643
4649
  abort(e) {
4644
- this.signalCtl.abort(new Ie(e));
4650
+ this.signalCtl.abort(new Ne(e));
4645
4651
  }
4646
4652
  }
4647
- class Ie extends Error {
4653
+ class Ne extends Error {
4648
4654
  }
4649
- async function et(s) {
4655
+ async function ot(s) {
4650
4656
  const e = await m.readdir(s, { withFileTypes: !0 });
4651
4657
  return (await Promise.all(
4652
4658
  e.map(async (o) => {
4653
- const n = b.join(s, o.name);
4654
- return o.isDirectory() ? await et(n) : (await m.stat(n)).size;
4659
+ const n = T.join(s, o.name);
4660
+ return o.isDirectory() ? await ot(n) : (await m.stat(n)).size;
4655
4661
  })
4656
4662
  )).reduce((o, n) => o + n, 0);
4657
4663
  }
4658
- async function de(s) {
4664
+ async function ue(s) {
4659
4665
  await m.rm(s, { recursive: !0, force: !0 });
4660
4666
  }
4661
- function ve(s, e) {
4667
+ function ae(s, e) {
4662
4668
  return `index://index/${encodeURIComponent(JSON.stringify({
4663
4669
  storageId: s,
4664
4670
  path: e
4665
4671
  }))}`;
4666
4672
  }
4667
- function Wn(s, e, t, o) {
4673
+ function xn(s, e, t, o) {
4668
4674
  const n = {
4669
4675
  localPath: s,
4670
4676
  pathSignature: e.sign(s),
@@ -4673,32 +4679,32 @@ function Wn(s, e, t, o) {
4673
4679
  };
4674
4680
  return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
4675
4681
  }
4676
- function zn(s) {
4682
+ function An(s) {
4677
4683
  const e = new URL(s);
4678
- return q.parse(
4684
+ return J.parse(
4679
4685
  JSON.parse(decodeURIComponent(e.pathname.substring(1)))
4680
4686
  );
4681
4687
  }
4682
- function xn(s) {
4688
+ function Mn(s) {
4683
4689
  const e = new URL(s);
4684
- return Ve.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4690
+ return Je.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4685
4691
  }
4686
- function An(s) {
4687
- if (Gn(s))
4688
- return qn(s);
4689
- if (Mn(s))
4690
- return jn(s);
4691
- ht(s);
4692
+ function $e(s) {
4693
+ if (Vn(s))
4694
+ return Jn(s);
4695
+ if (Hn(s))
4696
+ return Gn(s);
4697
+ pt(s);
4692
4698
  }
4693
- const tt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4694
- function Mn(s) {
4695
- return tt.test(s);
4699
+ const nt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4700
+ function Hn(s) {
4701
+ return nt.test(s);
4696
4702
  }
4697
- function Hn(s, e) {
4703
+ function jn(s, e) {
4698
4704
  return `local://${s}/${encodeURIComponent(e)}`;
4699
4705
  }
4700
- function jn(s) {
4701
- const e = s.match(tt);
4706
+ function Gn(s) {
4707
+ const e = s.match(nt);
4702
4708
  if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
4703
4709
  const { name: t, path: o } = e.groups;
4704
4710
  return {
@@ -4707,30 +4713,30 @@ function jn(s) {
4707
4713
  isRemote: !1
4708
4714
  };
4709
4715
  }
4710
- const ot = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4711
- function Gn(s) {
4712
- return ot.test(s);
4716
+ const rt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4717
+ function Vn(s) {
4718
+ return rt.test(s);
4713
4719
  }
4714
- function Vn(s, e) {
4720
+ function qn(s, e) {
4715
4721
  return `remote://${s}/${BigInt(e)}`;
4716
4722
  }
4717
- function qn(s) {
4718
- const e = s.match(ot);
4723
+ function Jn(s) {
4724
+ const e = s.match(rt);
4719
4725
  if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
4720
4726
  const { name: t, resourceId: o } = e.groups;
4721
4727
  return {
4722
- id: he(BigInt(o)),
4723
- type: Jn(t),
4728
+ id: pe(BigInt(o)),
4729
+ type: Zn(t),
4724
4730
  name: t,
4725
4731
  isRemote: !0
4726
4732
  };
4727
4733
  }
4728
- function Jn(s) {
4734
+ function Zn(s) {
4729
4735
  return { name: `LS/${s}`, version: "1" };
4730
4736
  }
4731
- async function Zn() {
4732
- const s = ft.homedir();
4733
- if (L.sep == "/")
4737
+ async function Qn() {
4738
+ const s = wt.homedir();
4739
+ if (P.sep == "/")
4734
4740
  return [
4735
4741
  {
4736
4742
  name: "local",
@@ -4739,9 +4745,9 @@ async function Zn() {
4739
4745
  }
4740
4746
  ];
4741
4747
  {
4742
- const t = L.parse(s).root.replaceAll(":\\", "");
4748
+ const t = P.parse(s).root.replaceAll(":\\", "");
4743
4749
  try {
4744
- return (await Tt.promisify(kt)("wmic logicaldisk get name")).stdout.split(`\r
4750
+ return (await Lt.promisify(Pt)("wmic logicaldisk get name")).stdout.split(`\r
4745
4751
  `).filter((r) => r.includes(":")).map((r) => r.trim().replaceAll(":", "")).map((r) => {
4746
4752
  const a = r == t;
4747
4753
  return {
@@ -4761,7 +4767,7 @@ async function Zn() {
4761
4767
  }
4762
4768
  }
4763
4769
  }
4764
- class nt {
4770
+ class st {
4765
4771
  constructor(e, t, o, n, r, a, i) {
4766
4772
  this.logger = e, this.lsClient = t, this.storageIdToResourceId = o, this.signer = n, this.virtualStoragesMap = r, this.localProjectionsMap = a, this.openFileDialogCallback = i;
4767
4773
  }
@@ -4793,13 +4799,13 @@ class nt {
4793
4799
  * @private
4794
4800
  */
4795
4801
  async tryResolveLocalFileHandle(e) {
4796
- if (bt(e)) {
4797
- const t = xn(e), o = this.localProjectionsMap.get(t.storageId);
4802
+ if (kt(e)) {
4803
+ const t = Mn(e), o = this.localProjectionsMap.get(t.storageId);
4798
4804
  if (!o)
4799
4805
  throw new Error(`Storage ${t.storageId} is not mounted locally.`);
4800
- return b.join(o.localPath, t.path);
4806
+ return T.join(o.localPath, t.path);
4801
4807
  } else {
4802
- const t = zn(e);
4808
+ const t = An(e);
4803
4809
  this.signer.verify(
4804
4810
  t.localPath,
4805
4811
  t.pathSignature,
@@ -4812,17 +4818,17 @@ class nt {
4812
4818
  }
4813
4819
  }
4814
4820
  async getLocalFileHandle(e) {
4815
- C(e);
4821
+ _(e);
4816
4822
  for (const o of this.localProjectionsMap.values())
4817
4823
  if (e.startsWith(o.localPath)) {
4818
- const n = o.localPath === "" ? e : b.relative(o.localPath, e);
4819
- return ve(
4824
+ const n = o.localPath === "" ? e : T.relative(o.localPath, e);
4825
+ return ae(
4820
4826
  o.storageId,
4821
4827
  n
4822
4828
  );
4823
4829
  }
4824
4830
  const t = await m.stat(e, { bigint: !0 });
4825
- return Wn(
4831
+ return xn(
4826
4832
  e,
4827
4833
  this.signer,
4828
4834
  t.size,
@@ -4833,12 +4839,12 @@ class nt {
4833
4839
  async getStorageList() {
4834
4840
  const e = [...this.virtualStoragesMap.values()].map((n) => ({
4835
4841
  name: n.name,
4836
- handle: Hn(n.name, n.root),
4842
+ handle: jn(n.name, n.root),
4837
4843
  initialFullPath: n.initialPath
4838
4844
  })), o = Object.entries(this.storageIdToResourceId).map(
4839
4845
  ([n, r]) => ({
4840
4846
  name: n,
4841
- handle: Vn(n, r),
4847
+ handle: qn(n, r),
4842
4848
  initialFullPath: "",
4843
4849
  // we don't have any additional information from where to start browsing remote storages
4844
4850
  isInitialPathHome: !1
@@ -4847,21 +4853,21 @@ class nt {
4847
4853
  return [...e, ...o];
4848
4854
  }
4849
4855
  async listFiles(e, t) {
4850
- const o = An(e);
4856
+ const o = $e(e);
4851
4857
  if (o.isRemote)
4852
4858
  return {
4853
4859
  entries: (await this.lsClient.list(o, t)).items.map((i) => ({
4854
4860
  type: i.isDir ? "dir" : "file",
4855
4861
  name: i.name,
4856
4862
  fullPath: i.fullName,
4857
- handle: ve(o.name, i.fullName)
4863
+ handle: ae(o.name, i.fullName)
4858
4864
  }))
4859
4865
  };
4860
- b.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && C(t);
4861
- const n = b.isAbsolute(t) ? t : b.join(o.rootPath, t), r = [];
4866
+ T.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && _(t);
4867
+ const n = T.isAbsolute(t) ? t : T.join(o.rootPath, t), r = [];
4862
4868
  for await (const a of await m.opendir(n)) {
4863
4869
  if (!a.isFile() && !a.isDirectory()) continue;
4864
- const i = b.join(n, a.name);
4870
+ const i = T.join(n, a.name);
4865
4871
  r.push({
4866
4872
  type: a.isFile() ? "file" : "dir",
4867
4873
  name: a.name,
@@ -4871,25 +4877,39 @@ class nt {
4871
4877
  }
4872
4878
  return { entries: r };
4873
4879
  }
4880
+ async listRemoteFilesWithAdditionalInfo(e, t) {
4881
+ const o = $e(e);
4882
+ if (!o.isRemote)
4883
+ throw new Error(`Storage ${o.name} is not remote`);
4884
+ return {
4885
+ entries: (await this.lsClient.list(o, t)).items.map((r) => ({
4886
+ type: r.isDir ? "dir" : "file",
4887
+ name: r.name,
4888
+ fullPath: r.fullName,
4889
+ handle: ae(o.name, r.fullName),
4890
+ size: Number(r.size)
4891
+ }))
4892
+ };
4893
+ }
4874
4894
  async fileToImportHandle(e) {
4875
4895
  throw new Error(
4876
4896
  "Not implemented. This method must be implemented and intercepted in desktop preload script."
4877
4897
  );
4878
4898
  }
4879
4899
  static async init(e, t, o, n, r, a) {
4880
- const i = Xo(t, e);
4881
- a || (a = await Zn());
4882
- for (const p of a) C(p.root);
4883
- for (const p of n) p.localPath !== "" && C(p.localPath);
4900
+ const i = Yo(t, e);
4901
+ a || (a = await Qn());
4902
+ for (const p of a) _(p.root);
4903
+ for (const p of n) p.localPath !== "" && _(p.localPath);
4884
4904
  const c = new Map(a.map((p) => [p.name, p])), l = new Map(n.map((p) => [p.storageId, p]));
4885
4905
  if ((/* @__PURE__ */ new Set([...c.keys(), ...l.keys()])).size !== c.size + l.size)
4886
4906
  throw new Error(
4887
4907
  "Intersection between local projection storage ids and virtual storages names detected."
4888
4908
  );
4889
- return new nt(
4909
+ return new st(
4890
4910
  e,
4891
4911
  i,
4892
- await Qn(t),
4912
+ await Xn(t),
4893
4913
  o,
4894
4914
  c,
4895
4915
  l,
@@ -4897,62 +4917,62 @@ class nt {
4897
4917
  );
4898
4918
  }
4899
4919
  }
4900
- async function Qn(s) {
4920
+ async function Xn(s) {
4901
4921
  return s.withReadTx("GetAvailableStorageIds", async (e) => {
4902
4922
  const t = await e.getResourceByName("LSProvider"), o = await e.getResourceData(t, !0);
4903
- return Xn(o);
4923
+ return Kn(o);
4904
4924
  });
4905
4925
  }
4906
- function Xn(s) {
4926
+ function Kn(s) {
4907
4927
  return Object.fromEntries(
4908
- s.fields.filter((e) => e.type == "Dynamic" && lt(e.value)).map((e) => [e.name.substring(8), e.value])
4928
+ s.fields.filter((e) => e.type == "Dynamic" && dt(e.value)).map((e) => [e.name.substring(8), e.value])
4909
4929
  );
4910
4930
  }
4911
4931
  export {
4912
- ko as ClientDownload,
4913
- Qo as ClientLogs,
4914
- Oo as ClientLs,
4915
- ho as ClientProgress,
4916
- Gt as ClientUpload,
4917
- Zn as DefaultVirtualLocalStorages,
4918
- Sr as DownloadBlobToURLDriver,
4919
- Dr as DownloadDriver,
4932
+ Po as ClientDownload,
4933
+ Ko as ClientLogs,
4934
+ Wo as ClientLs,
4935
+ po as ClientProgress,
4936
+ qt as ClientUpload,
4937
+ Qn as DefaultVirtualLocalStorages,
4938
+ Ir as DownloadBlobToURLDriver,
4939
+ Rr as DownloadDriver,
4920
4940
  Br as DownloadUrlDriver,
4921
- gn as DownloadableBlobSnapshot,
4922
- Ur as ImportFileHandleData,
4923
- Ve as ImportFileHandleIndexData,
4924
- q as ImportFileHandleUploadData,
4925
- rn as IndexResourceSnapshot,
4926
- Nr as LogsDriver,
4927
- vr as LogsStreamDriver,
4928
- nt as LsDriver,
4929
- ze as MTimeError,
4930
- Ae as NetworkError,
4931
- Me as NoFileForUploading,
4932
- tn as OnDemandBlobResourceSnapshot,
4933
- xe as UnexpectedEOF,
4934
- be as UnknownStorageError,
4935
- dn as Updater,
4936
- Ir as UploadDriver,
4937
- nn as UploadResourceSnapshot,
4938
- Ln as UploadTask,
4939
- ye as WrongLocalFileUrl,
4940
- Le as WrongResourceTypeError,
4941
- Tr as createDownloadClient,
4942
- kr as createLogsClient,
4943
- Xo as createLsFilesClient,
4944
- Pr as createUploadBlobClient,
4945
- Lr as createUploadProgressClient,
4946
- Po as getFullPath,
4947
- on as getSize,
4948
- Dn as isMyUpload,
4949
- Re as isResourceWasDeletedError,
4950
- _n as makeBlobImportSnapshot,
4951
- fn as makeDownloadableBlobSnapshot,
4952
- Ro as newLocalStorageIdsToRoot,
4953
- Ye as nonRecoverableError,
4954
- Lo as parseLocalUrl,
4955
- Pn as uploadBlob,
4956
- C as validateAbsolute
4941
+ mn as DownloadableBlobSnapshot,
4942
+ Dr as ImportFileHandleData,
4943
+ Je as ImportFileHandleIndexData,
4944
+ J as ImportFileHandleUploadData,
4945
+ an as IndexResourceSnapshot,
4946
+ $r as LogsDriver,
4947
+ Nr as LogsStreamDriver,
4948
+ st as LsDriver,
4949
+ Ae as MTimeError,
4950
+ He as NetworkError,
4951
+ je as NoFileForUploading,
4952
+ nn as OnDemandBlobResourceSnapshot,
4953
+ Me as UnexpectedEOF,
4954
+ ke as UnknownStorageError,
4955
+ un as Updater,
4956
+ vr as UploadDriver,
4957
+ sn as UploadResourceSnapshot,
4958
+ Un as UploadTask,
4959
+ Te as WrongLocalFileUrl,
4960
+ Ue as WrongResourceTypeError,
4961
+ kr as createDownloadClient,
4962
+ Lr as createLogsClient,
4963
+ Yo as createLsFilesClient,
4964
+ Ur as createUploadBlobClient,
4965
+ Pr as createUploadProgressClient,
4966
+ Do as getFullPath,
4967
+ rn as getSize,
4968
+ Sn as isMyUpload,
4969
+ Ie as isResourceWasDeletedError,
4970
+ On as makeBlobImportSnapshot,
4971
+ wn as makeDownloadableBlobSnapshot,
4972
+ Io as newLocalStorageIdsToRoot,
4973
+ tt as nonRecoverableError,
4974
+ Uo as parseLocalUrl,
4975
+ Dn as uploadBlob,
4976
+ _ as validateAbsolute
4957
4977
  };
4958
4978
  //# sourceMappingURL=index.mjs.map