@datapos/datapos-tool-file-operators 0.0.11 → 0.0.12

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.
@@ -1,8 +1,8 @@
1
- function F0(i) {
1
+ function _0(i) {
2
2
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
3
3
  }
4
4
  var O = {}, G = {}, n0;
5
- function B0() {
5
+ function A0() {
6
6
  return n0 || (n0 = 1, Object.defineProperty(G, "__esModule", { value: !0 }), G.default = () => {
7
7
  throw new Error("File system is not available");
8
8
  }), G;
@@ -16,7 +16,7 @@ function N() {
16
16
  })), J;
17
17
  }
18
18
  var s0;
19
- function I0() {
19
+ function O0() {
20
20
  if (s0) return R;
21
21
  s0 = 1;
22
22
  var i = R && R.__importDefault || function(t) {
@@ -41,7 +41,7 @@ function I0() {
41
41
  return R.default = x, R;
42
42
  }
43
43
  var P = {}, o0;
44
- function A0() {
44
+ function E0() {
45
45
  if (o0) return P;
46
46
  o0 = 1;
47
47
  var i = P && P.__importDefault || function(t) {
@@ -103,7 +103,7 @@ function A0() {
103
103
  return P.default = x, P;
104
104
  }
105
105
  var A = {}, f0;
106
- function O0() {
106
+ function L0() {
107
107
  if (f0) return A;
108
108
  f0 = 1;
109
109
  var i = A && A.__importDefault || function(m) {
@@ -171,7 +171,7 @@ function O0() {
171
171
  return A.UTF_32LE = s, A;
172
172
  }
173
173
  var _ = {}, d0;
174
- function E0() {
174
+ function T0() {
175
175
  if (d0) return _;
176
176
  d0 = 1;
177
177
  var i = _ && _.__importDefault || function(r) {
@@ -826,7 +826,7 @@ function E0() {
826
826
  return _.gb_18030 = d, _;
827
827
  }
828
828
  var S = {}, l0;
829
- function L0() {
829
+ function M0() {
830
830
  if (l0) return S;
831
831
  l0 = 1;
832
832
  var i = S && S.__importDefault || function(b) {
@@ -5129,7 +5129,7 @@ function L0() {
5129
5129
  return S.KOI8_R = k, S;
5130
5130
  }
5131
5131
  var E = {}, u0;
5132
- function T0() {
5132
+ function z0() {
5133
5133
  if (u0) return E;
5134
5134
  u0 = 1;
5135
5135
  var i = E && E.__importDefault || function(s) {
@@ -5229,14 +5229,14 @@ function T0() {
5229
5229
  return E.ISO_2022_CN = n, E;
5230
5230
  }
5231
5231
  var H = {}, m0;
5232
- function M0() {
5232
+ function U0() {
5233
5233
  if (m0) return H;
5234
5234
  m0 = 1, Object.defineProperty(H, "__esModule", { value: !0 }), H.isByteArray = void 0;
5235
5235
  const i = (e) => e == null || typeof e != "object" ? !1 : isFinite(e.length) && e.length >= 0;
5236
5236
  return H.isByteArray = i, H;
5237
5237
  }
5238
5238
  var p0;
5239
- function z0() {
5239
+ function j0() {
5240
5240
  return p0 || (p0 = 1, (function(i) {
5241
5241
  var e = O && O.__createBinding || (Object.create ? (function(l, p, w, y) {
5242
5242
  y === void 0 && (y = w);
@@ -5268,7 +5268,7 @@ function z0() {
5268
5268
  return l && l.__esModule ? l : { default: l };
5269
5269
  };
5270
5270
  Object.defineProperty(i, "__esModule", { value: !0 }), i.detectFileSync = i.detectFile = i.analyse = i.detect = void 0;
5271
- const n = a(B0()), s = a(I0()), m = a(A0()), o = t(O0()), f = t(E0()), d = t(L0()), r = t(T0()), c = M0(), u = [
5271
+ const n = a(A0()), s = a(O0()), m = a(E0()), o = t(L0()), f = t(T0()), d = t(M0()), r = t(z0()), c = U0(), u = [
5272
5272
  new m.default(),
5273
5273
  new o.UTF_16BE(),
5274
5274
  new o.UTF_16LE(),
@@ -5357,11 +5357,11 @@ function z0() {
5357
5357
  };
5358
5358
  })(O)), O;
5359
5359
  }
5360
- var U0 = z0();
5361
- const j0 = /* @__PURE__ */ F0(U0);
5360
+ var R0 = j0();
5361
+ const P0 = /* @__PURE__ */ _0(R0);
5362
5362
  var K = {};
5363
5363
  var h0;
5364
- function R0() {
5364
+ function q0() {
5365
5365
  return h0 || (h0 = 1, K.read = function(i, e, x, t, a) {
5366
5366
  var n, s, m = a * 8 - t - 1, o = (1 << m) - 1, f = o >> 1, d = -7, r = x ? a - 1 : 0, c = x ? -1 : 1, u = i[e + r];
5367
5367
  for (r += c, n = u & (1 << -d) - 1, u >>= -d, d += m; d > 0; n = n * 256 + i[e + r], r += c, d -= 8)
@@ -5385,7 +5385,7 @@ function R0() {
5385
5385
  i[x + u - h] |= g * 128;
5386
5386
  }), K;
5387
5387
  }
5388
- R0();
5388
+ q0();
5389
5389
  const t0 = {
5390
5390
  128: "€",
5391
5391
  130: "‚",
@@ -5417,25 +5417,25 @@ const t0 = {
5417
5417
  };
5418
5418
  for (const [i, e] of Object.entries(t0))
5419
5419
  ;
5420
- function P0(i, e = "utf-8") {
5420
+ function N0(i, e = "utf-8") {
5421
5421
  switch (e.toLowerCase()) {
5422
5422
  case "utf-8":
5423
5423
  case "utf8":
5424
- return typeof globalThis.TextDecoder < "u" ? new globalThis.TextDecoder("utf-8").decode(i) : q0(i);
5424
+ return typeof globalThis.TextDecoder < "u" ? new globalThis.TextDecoder("utf-8").decode(i) : V0(i);
5425
5425
  case "utf-16le":
5426
- return N0(i);
5426
+ return H0(i);
5427
5427
  case "ascii":
5428
- return V0(i);
5428
+ return W0(i);
5429
5429
  case "latin1":
5430
5430
  case "iso-8859-1":
5431
- return H0(i);
5431
+ return G0(i);
5432
5432
  case "windows-1252":
5433
- return W0(i);
5433
+ return J0(i);
5434
5434
  default:
5435
5435
  throw new RangeError(`Encoding '${e}' not supported`);
5436
5436
  }
5437
5437
  }
5438
- function q0(i) {
5438
+ function V0(i) {
5439
5439
  let e = "", x = 0;
5440
5440
  for (; x < i.length; ) {
5441
5441
  const t = i[x++];
@@ -5455,19 +5455,19 @@ function q0(i) {
5455
5455
  }
5456
5456
  return e;
5457
5457
  }
5458
- function N0(i) {
5458
+ function H0(i) {
5459
5459
  let e = "";
5460
5460
  for (let x = 0; x < i.length; x += 2)
5461
5461
  e += String.fromCharCode(i[x] | i[x + 1] << 8);
5462
5462
  return e;
5463
5463
  }
5464
- function V0(i) {
5464
+ function W0(i) {
5465
5465
  return String.fromCharCode(...i.map((e) => e & 127));
5466
5466
  }
5467
- function H0(i) {
5467
+ function G0(i) {
5468
5468
  return String.fromCharCode(...i);
5469
5469
  }
5470
- function W0(i) {
5470
+ function J0(i) {
5471
5471
  let e = "";
5472
5472
  for (const x of i)
5473
5473
  x >= 128 && x <= 159 && t0[x] ? e += t0[x] : e += String.fromCharCode(x);
@@ -5476,7 +5476,7 @@ function W0(i) {
5476
5476
  function I(i) {
5477
5477
  return new DataView(i.buffer, i.byteOffset);
5478
5478
  }
5479
- const G0 = {
5479
+ const K0 = {
5480
5480
  len: 1,
5481
5481
  get(i, e) {
5482
5482
  return I(i).getUint8(e);
@@ -5508,7 +5508,7 @@ const G0 = {
5508
5508
  put(i, e, x) {
5509
5509
  return I(i).setUint32(e, x, !0), e + 4;
5510
5510
  }
5511
- }, J0 = {
5511
+ }, Z0 = {
5512
5512
  len: 4,
5513
5513
  get(i, e) {
5514
5514
  return I(i).getUint32(e);
@@ -5516,7 +5516,7 @@ const G0 = {
5516
5516
  put(i, e, x) {
5517
5517
  return I(i).setUint32(e, x), e + 4;
5518
5518
  }
5519
- }, K0 = {
5519
+ }, Q0 = {
5520
5520
  len: 4,
5521
5521
  get(i, e) {
5522
5522
  return I(i).getInt32(e);
@@ -5524,7 +5524,7 @@ const G0 = {
5524
5524
  put(i, e, x) {
5525
5525
  return I(i).setInt32(e, x), e + 4;
5526
5526
  }
5527
- }, Z0 = {
5527
+ }, $0 = {
5528
5528
  len: 8,
5529
5529
  get(i, e) {
5530
5530
  return I(i).getBigUint64(e, !0);
@@ -5539,21 +5539,21 @@ class U {
5539
5539
  }
5540
5540
  get(e, x = 0) {
5541
5541
  const t = e.subarray(x, x + this.len);
5542
- return P0(t, this.encoding);
5542
+ return N0(t, this.encoding);
5543
5543
  }
5544
5544
  }
5545
- const Q0 = "End-Of-Stream";
5545
+ const X0 = "End-Of-Stream";
5546
5546
  class B extends Error {
5547
5547
  constructor() {
5548
- super(Q0), this.name = "EndOfStreamError";
5548
+ super(X0), this.name = "EndOfStreamError";
5549
5549
  }
5550
5550
  }
5551
- class $0 extends Error {
5551
+ class Y0 extends Error {
5552
5552
  constructor(e = "The operation was aborted") {
5553
5553
  super(e), this.name = "AbortError";
5554
5554
  }
5555
5555
  }
5556
- class D0 {
5556
+ class B0 {
5557
5557
  constructor() {
5558
5558
  this.endOfStream = !1, this.interrupted = !1, this.peekQueue = [];
5559
5559
  }
@@ -5589,7 +5589,7 @@ class D0 {
5589
5589
  let t = 0;
5590
5590
  for (; t < e.length && !this.endOfStream; ) {
5591
5591
  if (this.interrupted)
5592
- throw new $0();
5592
+ throw new Y0();
5593
5593
  const a = await this.readFromStream(e.subarray(t), x);
5594
5594
  if (a === 0)
5595
5595
  break;
@@ -5600,7 +5600,7 @@ class D0 {
5600
5600
  return t;
5601
5601
  }
5602
5602
  }
5603
- class X0 extends D0 {
5603
+ class ee extends B0 {
5604
5604
  constructor(e) {
5605
5605
  super(), this.reader = e;
5606
5606
  }
@@ -5611,7 +5611,7 @@ class X0 extends D0 {
5611
5611
  this.reader.releaseLock();
5612
5612
  }
5613
5613
  }
5614
- class Y0 extends X0 {
5614
+ class xe extends ee {
5615
5615
  /**
5616
5616
  * Read from stream
5617
5617
  * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
@@ -5625,7 +5625,7 @@ class Y0 extends X0 {
5625
5625
  return t.done && (this.endOfStream = t.done), t.value ? (e.set(t.value), t.value.length) : 0;
5626
5626
  }
5627
5627
  }
5628
- class b0 extends D0 {
5628
+ class b0 extends B0 {
5629
5629
  constructor(e) {
5630
5630
  super(), this.reader = e, this.buffer = null;
5631
5631
  }
@@ -5665,10 +5665,10 @@ class b0 extends D0 {
5665
5665
  await this.abort(), this.reader.releaseLock();
5666
5666
  }
5667
5667
  }
5668
- function ee(i) {
5668
+ function te(i) {
5669
5669
  try {
5670
5670
  const e = i.getReader({ mode: "byob" });
5671
- return e instanceof ReadableStreamDefaultReader ? new b0(e) : new Y0(e);
5671
+ return e instanceof ReadableStreamDefaultReader ? new b0(e) : new xe(e);
5672
5672
  } catch (e) {
5673
5673
  if (e instanceof TypeError)
5674
5674
  return new b0(i.getReader());
@@ -5761,8 +5761,8 @@ class i0 {
5761
5761
  return Promise.resolve();
5762
5762
  }
5763
5763
  }
5764
- const xe = 256e3;
5765
- class te extends i0 {
5764
+ const ie = 256e3;
5765
+ class ae extends i0 {
5766
5766
  /**
5767
5767
  * Constructor
5768
5768
  * @param streamReader stream-reader to read from
@@ -5822,7 +5822,7 @@ class te extends i0 {
5822
5822
  return a;
5823
5823
  }
5824
5824
  async ignore(e) {
5825
- const x = Math.min(xe, e), t = new Uint8Array(x);
5825
+ const x = Math.min(ie, e), t = new Uint8Array(x);
5826
5826
  let a = 0;
5827
5827
  for (; a < e; ) {
5828
5828
  const n = e - a, s = await this.readBuffer(t, { length: Math.min(x, n) });
@@ -5842,7 +5842,7 @@ class te extends i0 {
5842
5842
  return !1;
5843
5843
  }
5844
5844
  }
5845
- class ie extends i0 {
5845
+ class re extends i0 {
5846
5846
  /**
5847
5847
  * Construct BufferTokenizer
5848
5848
  * @param uint8Array - Uint8Array to tokenize
@@ -5884,7 +5884,7 @@ class ie extends i0 {
5884
5884
  this.position = e;
5885
5885
  }
5886
5886
  }
5887
- class ae extends i0 {
5887
+ class ne extends i0 {
5888
5888
  /**
5889
5889
  * Construct BufferTokenizer
5890
5890
  * @param blob - Uint8Array to tokenize
@@ -5927,21 +5927,21 @@ class ae extends i0 {
5927
5927
  this.position = e;
5928
5928
  }
5929
5929
  }
5930
- function re(i, e) {
5931
- const x = ee(i), t = e ?? {}, a = t.onClose;
5930
+ function ce(i, e) {
5931
+ const x = te(i), t = e ?? {}, a = t.onClose;
5932
5932
  return t.onClose = async () => {
5933
5933
  if (await x.close(), a)
5934
5934
  return a();
5935
- }, new te(x, t);
5935
+ }, new ae(x, t);
5936
5936
  }
5937
- function ne(i, e) {
5938
- return new ie(i, e);
5937
+ function se(i, e) {
5938
+ return new re(i, e);
5939
5939
  }
5940
- function ce(i, e) {
5941
- return new ae(i, e);
5940
+ function oe(i, e) {
5941
+ return new ne(i, e);
5942
5942
  }
5943
5943
  var Z = { exports: {} }, $, g0;
5944
- function se() {
5944
+ function fe() {
5945
5945
  if (g0) return $;
5946
5946
  g0 = 1;
5947
5947
  var i = 1e3, e = i * 60, x = e * 60, t = x * 24, a = t * 7, n = t * 365.25;
@@ -6023,11 +6023,11 @@ function se() {
6023
6023
  return $;
6024
6024
  }
6025
6025
  var X, w0;
6026
- function oe() {
6026
+ function de() {
6027
6027
  if (w0) return X;
6028
6028
  w0 = 1;
6029
6029
  function i(e) {
6030
- t.debug = t, t.default = t, t.coerce = f, t.disable = m, t.enable = n, t.enabled = o, t.humanize = se(), t.destroy = d, Object.keys(e).forEach((r) => {
6030
+ t.debug = t, t.default = t, t.coerce = f, t.disable = m, t.enable = n, t.enabled = o, t.humanize = fe(), t.destroy = d, Object.keys(e).forEach((r) => {
6031
6031
  t[r] = e[r];
6032
6032
  }), t.names = [], t.skips = [], t.formatters = {};
6033
6033
  function x(r) {
@@ -6116,7 +6116,7 @@ function oe() {
6116
6116
  return X = i, X;
6117
6117
  }
6118
6118
  var k0;
6119
- function fe() {
6119
+ function le() {
6120
6120
  return k0 || (k0 = 1, (function(i, e) {
6121
6121
  e.formatArgs = t, e.save = a, e.load = n, e.useColors = x, e.storage = s(), e.destroy = /* @__PURE__ */ (() => {
6122
6122
  let o = !1;
@@ -6245,7 +6245,7 @@ function fe() {
6245
6245
  } catch {
6246
6246
  }
6247
6247
  }
6248
- i.exports = oe()(e);
6248
+ i.exports = de()(e);
6249
6249
  const { formatters: m } = i.exports;
6250
6250
  m.j = function(o) {
6251
6251
  try {
@@ -6256,8 +6256,8 @@ function fe() {
6256
6256
  };
6257
6257
  })(Z, Z.exports)), Z.exports;
6258
6258
  }
6259
- var de = fe();
6260
- const le = /* @__PURE__ */ F0(de), q = {
6259
+ var ue = le();
6260
+ const me = /* @__PURE__ */ _0(ue), q = {
6261
6261
  LocalFileHeader: 67324752,
6262
6262
  DataDescriptor: 134695760,
6263
6263
  CentralFileHeader: 33639248,
@@ -6271,7 +6271,7 @@ const le = /* @__PURE__ */ F0(de), q = {
6271
6271
  };
6272
6272
  },
6273
6273
  len: 16
6274
- }, ue = {
6274
+ }, pe = {
6275
6275
  get(i) {
6276
6276
  const e = F.get(i, 6);
6277
6277
  return {
@@ -6287,7 +6287,7 @@ const le = /* @__PURE__ */ F0(de), q = {
6287
6287
  };
6288
6288
  },
6289
6289
  len: 30
6290
- }, me = {
6290
+ }, he = {
6291
6291
  get(i) {
6292
6292
  return {
6293
6293
  signature: D.get(i, 0),
@@ -6301,7 +6301,7 @@ const le = /* @__PURE__ */ F0(de), q = {
6301
6301
  };
6302
6302
  },
6303
6303
  len: 22
6304
- }, pe = {
6304
+ }, be = {
6305
6305
  get(i) {
6306
6306
  const e = F.get(i, 8);
6307
6307
  return {
@@ -6320,11 +6320,11 @@ const le = /* @__PURE__ */ F0(de), q = {
6320
6320
  },
6321
6321
  len: 46
6322
6322
  };
6323
- function _0(i) {
6323
+ function I0(i) {
6324
6324
  const e = new Uint8Array(D.len);
6325
6325
  return D.put(e, 0, i), e;
6326
6326
  }
6327
- const T = le("tokenizer:inflate"), Y = 256 * 1024, he = _0(q.DataDescriptor), Q = _0(q.EndOfCentralDirectory);
6327
+ const T = me("tokenizer:inflate"), Y = 256 * 1024, ge = I0(q.DataDescriptor), Q = I0(q.EndOfCentralDirectory);
6328
6328
  class a0 {
6329
6329
  constructor(e) {
6330
6330
  this.tokenizer = e, this.syncBuffer = new Uint8Array(Y);
@@ -6352,10 +6352,10 @@ class a0 {
6352
6352
  const e = this.tokenizer.position, x = await this.findEndOfCentralDirectoryLocator();
6353
6353
  if (x > 0) {
6354
6354
  T("Central-directory 32-bit signature found");
6355
- const t = await this.tokenizer.readToken(me, x), a = [];
6355
+ const t = await this.tokenizer.readToken(he, x), a = [];
6356
6356
  this.tokenizer.setPosition(t.offsetOfStartOfCd);
6357
6357
  for (let n = 0; n < t.nrOfEntriesOfSize; ++n) {
6358
- const s = await this.tokenizer.readToken(pe);
6358
+ const s = await this.tokenizer.readToken(be);
6359
6359
  if (s.signature !== q.CentralFileHeader)
6360
6360
  throw new Error("Expected Central-File-Header signature");
6361
6361
  s.filename = await this.tokenizer.readToken(new U(s.filenameLength, "utf-8")), await this.tokenizer.ignore(s.extraFieldLength), await this.tokenizer.ignore(s.fileCommentLength), a.push(s), T(`Add central-directory file-entry: n=${n + 1}/${a.length}: filename=${a[n].filename}`);
@@ -6382,7 +6382,7 @@ class a0 {
6382
6382
  T("Compressed-file-size unknown, scanning for next data-descriptor-signature....");
6383
6383
  let f = -1;
6384
6384
  for (; f < 0 && o === Y; ) {
6385
- o = await this.tokenizer.peekBuffer(this.syncBuffer, { mayBeLess: !0 }), f = be(this.syncBuffer.subarray(0, o), he);
6385
+ o = await this.tokenizer.peekBuffer(this.syncBuffer, { mayBeLess: !0 }), f = we(this.syncBuffer.subarray(0, o), ge);
6386
6386
  const d = f >= 0 ? f : o;
6387
6387
  if (n.handler) {
6388
6388
  const r = new Uint8Array(d);
@@ -6390,7 +6390,7 @@ class a0 {
6390
6390
  } else
6391
6391
  await this.tokenizer.ignore(d);
6392
6392
  }
6393
- T(`Found data-descriptor-signature at pos=${this.tokenizer.position}`), n.handler && await this.inflate(a, ge(m), n.handler);
6393
+ T(`Found data-descriptor-signature at pos=${this.tokenizer.position}`), n.handler && await this.inflate(a, ke(m), n.handler);
6394
6394
  } else
6395
6395
  n.handler ? (T(`Reading compressed-file-data: ${a.compressedSize} bytes`), s = new Uint8Array(a.compressedSize), await this.tokenizer.readBuffer(s), await this.inflate(a, s, n.handler)) : (T(`Ignoring compressed-file-data: ${a.compressedSize} bytes`), await this.tokenizer.ignore(a.compressedSize));
6396
6396
  if (T(`Reading data-descriptor at pos=${this.tokenizer.position}`), a.dataDescriptor && (await this.tokenizer.readToken(y0)).signature !== 134695760)
@@ -6439,7 +6439,7 @@ class a0 {
6439
6439
  async readLocalFileHeader() {
6440
6440
  const e = await this.tokenizer.peekToken(D);
6441
6441
  if (e === q.LocalFileHeader) {
6442
- const x = await this.tokenizer.readToken(ue);
6442
+ const x = await this.tokenizer.readToken(pe);
6443
6443
  return x.filename = await this.tokenizer.readToken(new U(x.filenameLength, "utf-8")), x;
6444
6444
  }
6445
6445
  if (e === q.CentralFileHeader)
@@ -6447,7 +6447,7 @@ class a0 {
6447
6447
  throw e === 3759263696 ? new Error("Encrypted ZIP") : new Error("Unexpected signature");
6448
6448
  }
6449
6449
  }
6450
- function be(i, e) {
6450
+ function we(i, e) {
6451
6451
  const x = i.length, t = e.length;
6452
6452
  if (t > x)
6453
6453
  return -1;
@@ -6463,14 +6463,14 @@ function be(i, e) {
6463
6463
  }
6464
6464
  return -1;
6465
6465
  }
6466
- function ge(i) {
6466
+ function ke(i) {
6467
6467
  const e = i.reduce((a, n) => a + n.length, 0), x = new Uint8Array(e);
6468
6468
  let t = 0;
6469
6469
  for (const a of i)
6470
6470
  x.set(a, t), t += a.length;
6471
6471
  return x;
6472
6472
  }
6473
- class we {
6473
+ class ye {
6474
6474
  constructor(e) {
6475
6475
  this.tokenizer = e;
6476
6476
  }
@@ -6506,7 +6506,7 @@ function v0(i) {
6506
6506
  if (e === 1)
6507
6507
  return i.getUint8(0);
6508
6508
  }
6509
- function ke(i, e) {
6509
+ function ve(i, e) {
6510
6510
  if (e === "utf-16le") {
6511
6511
  const x = [];
6512
6512
  for (let t = 0; t < i.length; t++) {
@@ -6525,7 +6525,7 @@ function ke(i, e) {
6525
6525
  }
6526
6526
  return [...i].map((x) => x.charCodeAt(0));
6527
6527
  }
6528
- function ye(i, e = 0) {
6528
+ function Ce(i, e = 0) {
6529
6529
  const x = Number.parseInt(new U(6).get(i, 148).replace(/\0.*$/, "").trim(), 8);
6530
6530
  if (Number.isNaN(x))
6531
6531
  return !1;
@@ -6536,10 +6536,10 @@ function ye(i, e = 0) {
6536
6536
  t += i[a];
6537
6537
  return x === t;
6538
6538
  }
6539
- const ve = {
6539
+ const Se = {
6540
6540
  get: (i, e) => i[e + 3] & 127 | i[e + 2] << 7 | i[e + 1] << 14 | i[e] << 21,
6541
6541
  len: 4
6542
- }, Ce = [
6542
+ }, Fe = [
6543
6543
  "jpg",
6544
6544
  "png",
6545
6545
  "apng",
@@ -6720,7 +6720,7 @@ const ve = {
6720
6720
  "tar.gz",
6721
6721
  "reg",
6722
6722
  "dat"
6723
- ], Se = [
6723
+ ], De = [
6724
6724
  "image/jpeg",
6725
6725
  "image/png",
6726
6726
  "image/gif",
@@ -6904,8 +6904,8 @@ const ve = {
6904
6904
  "application/x-ft-windows-registry-hive",
6905
6905
  "application/x-jmp-data"
6906
6906
  ], e0 = 4100;
6907
- async function Fe(i, e) {
6908
- return new De(e).fromBuffer(i);
6907
+ async function _e(i, e) {
6908
+ return new Be(e).fromBuffer(i);
6909
6909
  }
6910
6910
  function x0(i) {
6911
6911
  switch (i = i.toLowerCase(), i) {
@@ -7049,7 +7049,7 @@ function M(i, e, x) {
7049
7049
  return !1;
7050
7050
  return !0;
7051
7051
  }
7052
- class De {
7052
+ class Be {
7053
7053
  constructor(e) {
7054
7054
  this.options = {
7055
7055
  mpegOffsetTolerance: 0,
@@ -7077,10 +7077,10 @@ class De {
7077
7077
  throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);
7078
7078
  const x = e instanceof Uint8Array ? e : new Uint8Array(e);
7079
7079
  if (x?.length > 1)
7080
- return this.fromTokenizer(ne(x, this.tokenizerOptions));
7080
+ return this.fromTokenizer(se(x, this.tokenizerOptions));
7081
7081
  }
7082
7082
  async fromBlob(e) {
7083
- const x = ce(e, this.tokenizerOptions);
7083
+ const x = oe(e, this.tokenizerOptions);
7084
7084
  try {
7085
7085
  return await this.fromTokenizer(x);
7086
7086
  } finally {
@@ -7088,7 +7088,7 @@ class De {
7088
7088
  }
7089
7089
  }
7090
7090
  async fromStream(e) {
7091
- const x = re(e, this.tokenizerOptions);
7091
+ const x = ce(e, this.tokenizerOptions);
7092
7092
  try {
7093
7093
  return await this.fromTokenizer(x);
7094
7094
  } finally {
@@ -7127,7 +7127,7 @@ class De {
7127
7127
  return M(this.buffer, e, x);
7128
7128
  }
7129
7129
  checkString(e, x) {
7130
- return this.check(ke(e, x?.encoding), x);
7130
+ return this.check(ve(e, x?.encoding), x);
7131
7131
  }
7132
7132
  // Detections with a high degree of certainty in identifying the correct file type
7133
7133
  detectConfident = async (e) => {
@@ -7187,7 +7187,7 @@ class De {
7187
7187
  mime: "image/vnd.ms-photo"
7188
7188
  };
7189
7189
  if (this.check([31, 139, 8])) {
7190
- const t = new we(e).inflate();
7190
+ const t = new ye(e).inflate();
7191
7191
  let a = !0;
7192
7192
  try {
7193
7193
  let n;
@@ -7216,7 +7216,7 @@ class De {
7216
7216
  };
7217
7217
  if (this.checkString("ID3")) {
7218
7218
  await e.ignore(6);
7219
- const x = await e.readToken(ve);
7219
+ const x = await e.readToken(Se);
7220
7220
  return e.position + x > e.fileInfo.size ? {
7221
7221
  ext: "mp3",
7222
7222
  mime: "audio/mpeg"
@@ -7430,7 +7430,7 @@ class De {
7430
7430
  };
7431
7431
  if (this.check([26, 69, 223, 163])) {
7432
7432
  async function x() {
7433
- const m = await e.peekNumber(G0);
7433
+ const m = await e.peekNumber(K0);
7434
7434
  let o = 128, f = 0;
7435
7435
  for (; (m & o) === 0 && o !== 0; )
7436
7436
  ++f, o >>= 1;
@@ -7673,7 +7673,7 @@ class De {
7673
7673
  await e.ignore(8);
7674
7674
  async function x() {
7675
7675
  return {
7676
- length: await e.readToken(K0),
7676
+ length: await e.readToken(Q0),
7677
7677
  type: await e.readToken(new U(4, "latin1"))
7678
7678
  };
7679
7679
  }
@@ -7806,7 +7806,7 @@ class De {
7806
7806
  const t = new Uint8Array(16);
7807
7807
  return await e.readBuffer(t), {
7808
7808
  id: t,
7809
- size: Number(await e.readToken(Z0))
7809
+ size: Number(await e.readToken($0))
7810
7810
  };
7811
7811
  }
7812
7812
  for (await e.ignore(30); e.position + 24 < e.fileInfo.size; ) {
@@ -8006,7 +8006,7 @@ class De {
8006
8006
  ext: "jmp",
8007
8007
  mime: "application/x-jmp-data"
8008
8008
  };
8009
- if (await e.peekBuffer(this.buffer, { length: Math.min(512, e.fileInfo.size), mayBeLess: !0 }), this.checkString("ustar", { offset: 257 }) && (this.checkString("\0", { offset: 262 }) || this.checkString(" ", { offset: 262 })) || this.check([0, 0, 0, 0, 0, 0], { offset: 257 }) && ye(this.buffer))
8009
+ if (await e.peekBuffer(this.buffer, { length: Math.min(512, e.fileInfo.size), mayBeLess: !0 }), this.checkString("ustar", { offset: 257 }) && (this.checkString("\0", { offset: 262 }) || this.checkString(" ", { offset: 262 })) || this.check([0, 0, 0, 0, 0, 0], { offset: 257 }) && Ce(this.buffer))
8010
8010
  return {
8011
8011
  ext: "tar",
8012
8012
  mime: "application/x-tar"
@@ -8084,7 +8084,7 @@ class De {
8084
8084
  }
8085
8085
  }
8086
8086
  async readTiffHeader(e) {
8087
- const x = (e ? W : F).get(this.buffer, 2), t = (e ? J0 : D).get(this.buffer, 4);
8087
+ const x = (e ? W : F).get(this.buffer, 2), t = (e ? Z0 : D).get(this.buffer, 4);
8088
8088
  if (x === 42) {
8089
8089
  if (t >= 6) {
8090
8090
  if (this.checkString("CR", { offset: 8 }))
@@ -8146,34 +8146,34 @@ class De {
8146
8146
  }
8147
8147
  }
8148
8148
  }
8149
- new Set(Ce);
8150
- new Set(Se);
8151
- class _e extends Error {
8149
+ new Set(Fe);
8150
+ new Set(De);
8151
+ class Ie extends Error {
8152
8152
  locator;
8153
8153
  /** Logical source of the error. */
8154
8154
  constructor(e, x, t) {
8155
8155
  super(e, t), this.name = new.target.name, this.locator = x;
8156
8156
  }
8157
8157
  }
8158
- let Be = class extends _e {
8159
- }, Ie = class extends Be {
8158
+ let Ae = class extends Ie {
8159
+ }, Oe = class extends Ae {
8160
8160
  body;
8161
8161
  /** Sanitized HTTP response body. */
8162
8162
  constructor(e, x, t, a) {
8163
- super(e, x, a), this.name = new.target.name, this.body = Ee(t ?? void 0);
8163
+ super(e, x, a), this.name = new.target.name, this.body = Te(t ?? void 0);
8164
8164
  }
8165
8165
  };
8166
- async function Ae(i, e, x) {
8166
+ async function Ee(i, e, x) {
8167
8167
  const t = ` - ${i.statusText}`, a = `${e} Response status '${i.status}${i.statusText ? t : ""}' received.`;
8168
8168
  let n;
8169
8169
  try {
8170
8170
  n = await i.text();
8171
8171
  } catch (s) {
8172
- n = `<body unavailable: ${Oe(s).message}>`;
8172
+ n = `<body unavailable: ${Le(s).message}>`;
8173
8173
  }
8174
- return new Ie(a, x, n);
8174
+ return new Oe(a, x, n);
8175
8175
  }
8176
- function Oe(i) {
8176
+ function Le(i) {
8177
8177
  if (i instanceof Error) return i;
8178
8178
  if (typeof i == "string") return new Error(i);
8179
8179
  if (typeof i == "number" || typeof i == "boolean" || typeof i == "bigint") return new Error(String(i));
@@ -8186,18 +8186,18 @@ function Oe(i) {
8186
8186
  }
8187
8187
  return new Error("Unknown error");
8188
8188
  }
8189
- function Ee(i) {
8189
+ function Te(i) {
8190
8190
  if (!(i == null || i === ""))
8191
8191
  return i.length > 2048 ? `${i.slice(0, 2048)}... [truncated]` : i;
8192
8192
  }
8193
- const Le = { id: "ascii", groupLabel: "", label: "ascii", isDetectable: !1, isDecodable: !0 }, Te = { id: "big5", groupLabel: "Chinese Traditional", label: "Chinese Traditional (big5)", isDetectable: !0, isDecodable: !0 }, Me = { id: "gb18030", groupLabel: "Chinese Simplified", label: "Chinese Simplified (gb18030)", isDetectable: !0, isDecodable: !0 }, ze = { id: "gbk", groupLabel: "Chinese Simplified", label: "Chinese Simplified (gbk)", isDetectable: !1, isDecodable: !0 }, Ue = { id: "ibm866", groupLabel: "Cyrillic", label: "Cyrillic (ibm866)", isDetectable: !1, isDecodable: !0 }, je = { id: "latin1", groupLabel: "Western", label: "Western (latin1)", isDetectable: !1, isDecodable: !0 }, Re = { id: "macintosh", groupLabel: "Western", label: "Western (macintosh)", isDetectable: !1, isDecodable: !0 }, Pe = { id: "shift_jis", groupLabel: "Japanese", label: "Japanese (shift_jis)", isDetectable: !0, isDecodable: !0 }, qe = { id: "utf16", groupLabel: "Unicode 16", label: "Unicode 16 (utf16)", isDetectable: !1, isDecodable: !0 }, Ne = { id: "utf16be", groupLabel: "Unicode 16", label: "Unicode 16 (utf16be)", isDetectable: !0, isDecodable: !0 }, Ve = { id: "utf16le", groupLabel: "Unicode 16", label: "Unicode 16 (utf16le)", isDetectable: !0, isDecodable: !0 }, He = { id: "utf32be", groupLabel: "Unicode 32", label: "Unicode 32 (utf32be)", isDetectable: !0, isDecodable: !1 }, We = { id: "utf32le", groupLabel: "Unicode 32", label: "Unicode 32 (utf32le)", isDetectable: !0, isDecodable: !1 }, Ge = { id: "utf8", groupLabel: "", label: "utf8", isDetectable: !0, isDecodable: !0 }, Je = {
8194
- ascii: Le,
8195
- big5: Te,
8193
+ const Me = { id: "ascii", groupLabel: "", label: "ascii", isDetectable: !1, isDecodable: !0 }, ze = { id: "big5", groupLabel: "Chinese Traditional", label: "Chinese Traditional (big5)", isDetectable: !0, isDecodable: !0 }, Ue = { id: "gb18030", groupLabel: "Chinese Simplified", label: "Chinese Simplified (gb18030)", isDetectable: !0, isDecodable: !0 }, je = { id: "gbk", groupLabel: "Chinese Simplified", label: "Chinese Simplified (gbk)", isDetectable: !1, isDecodable: !0 }, Re = { id: "ibm866", groupLabel: "Cyrillic", label: "Cyrillic (ibm866)", isDetectable: !1, isDecodable: !0 }, Pe = { id: "latin1", groupLabel: "Western", label: "Western (latin1)", isDetectable: !1, isDecodable: !0 }, qe = { id: "macintosh", groupLabel: "Western", label: "Western (macintosh)", isDetectable: !1, isDecodable: !0 }, Ne = { id: "shift_jis", groupLabel: "Japanese", label: "Japanese (shift_jis)", isDetectable: !0, isDecodable: !0 }, Ve = { id: "utf16", groupLabel: "Unicode 16", label: "Unicode 16 (utf16)", isDetectable: !1, isDecodable: !0 }, He = { id: "utf16be", groupLabel: "Unicode 16", label: "Unicode 16 (utf16be)", isDetectable: !0, isDecodable: !0 }, We = { id: "utf16le", groupLabel: "Unicode 16", label: "Unicode 16 (utf16le)", isDetectable: !0, isDecodable: !0 }, Ge = { id: "utf32be", groupLabel: "Unicode 32", label: "Unicode 32 (utf32be)", isDetectable: !0, isDecodable: !1 }, Je = { id: "utf32le", groupLabel: "Unicode 32", label: "Unicode 32 (utf32le)", isDetectable: !0, isDecodable: !1 }, Ke = { id: "utf8", groupLabel: "", label: "utf8", isDetectable: !0, isDecodable: !0 }, Ze = {
8194
+ ascii: Me,
8195
+ big5: ze,
8196
8196
  "euc-jp": { id: "euc-jp", groupLabel: "Japanese", label: "Japanese (euc-jp)", isDetectable: !0, isDecodable: !0 },
8197
8197
  "euc-kr": { id: "euc-kr", groupLabel: "Korean", label: "Korean (euc-kr)", isDetectable: !0, isDecodable: !0 },
8198
- gb18030: Me,
8199
- gbk: ze,
8200
- ibm866: Ue,
8198
+ gb18030: Ue,
8199
+ gbk: je,
8200
+ ibm866: Re,
8201
8201
  "iso-2022-cn": { id: "iso-2022-cn", groupLabel: "Japanese", label: "Japanese (iso-2022-cn)", isDetectable: !0, isDecodable: !1 },
8202
8202
  "iso-2022-jp": { id: "iso-2022-jp", groupLabel: "Japanese", label: "Japanese (iso-2022-jp)", isDetectable: !0, isDecodable: !0 },
8203
8203
  "iso-2022-kr": { id: "iso-2022-kr", groupLabel: "Korean", label: "Korean (iso-2022-kr)", isDetectable: !0, isDecodable: !1 },
@@ -8218,16 +8218,16 @@ const Le = { id: "ascii", groupLabel: "", label: "ascii", isDetectable: !1, isDe
8218
8218
  "iso-8859-16": { id: "iso-8859-16", groupLabel: "Romanian", label: "Romanian (iso-8859-16)", isDetectable: !1, isDecodable: !0 },
8219
8219
  "kOi8-r": { id: "koi8-r", groupLabel: "Cyrillic", label: "Cyrillic (koi8-r)", isDetectable: !0, isDecodable: !0 },
8220
8220
  "kOi8-u": { id: "koi8-u", groupLabel: "Cyrillic", label: "Cyrillic (koi8-u)", isDetectable: !1, isDecodable: !0 },
8221
- latin1: je,
8222
- macintosh: Re,
8223
- shift_jis: Pe,
8221
+ latin1: Pe,
8222
+ macintosh: qe,
8223
+ shift_jis: Ne,
8224
8224
  "tis-620": { id: "tis-620", groupLabel: "Thai", label: "Thai (tis-620)", isDetectable: !1, isDecodable: !0 },
8225
- utf16: qe,
8226
- utf16be: Ne,
8227
- utf16le: Ve,
8228
- utf32be: He,
8229
- utf32le: We,
8230
- utf8: Ge,
8225
+ utf16: Ve,
8226
+ utf16be: He,
8227
+ utf16le: We,
8228
+ utf32be: Ge,
8229
+ utf32le: Je,
8230
+ utf8: Ke,
8231
8231
  "windows-1250": { id: "windows-1250", groupLabel: "Central European", label: "Central European (windows-1250)", isDetectable: !0, isDecodable: !0 },
8232
8232
  "windows-1251": { id: "windows-1251", groupLabel: "Cyrillic", label: "Cyrillic (windows-1251)", isDetectable: !0, isDecodable: !0 },
8233
8233
  "windows-1252": { id: "windows-1252", groupLabel: "Western", label: "Western (windows-1252)", isDetectable: !0, isDecodable: !0 },
@@ -8240,13 +8240,12 @@ const Le = { id: "ascii", groupLabel: "", label: "ascii", isDetectable: !1, isDe
8240
8240
  "windows-874": { id: "windows-874", groupLabel: "Thai", label: "Thai (windows-874)", isDetectable: !1, isDecodable: !0 },
8241
8241
  "x-mac-cyrillic": { id: "x-mac-cyrillic", groupLabel: "Cyrillic", label: "Cyrillic (x-mac-cyrillic)", isDetectable: !1, isDecodable: !0 },
8242
8242
  "x-user-defined": { id: "x-user-defined", groupLabel: "Other", label: "Other (x-user-defined)", isDetectable: !1, isDecodable: !0 }
8243
- }, Ke = Je, Ze = 4096, C0 = { id: "utf8", confidenceLevel: void 0 }, Qe = {
8243
+ }, Qe = Ze, $e = 4096, C0 = { id: "utf8", confidenceLevel: void 0 }, Xe = {
8244
8244
  arrow: { label: "Columnar format for tables of data.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8245
8245
  avro: { label: "Object container file developed by Apache Avro.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8246
8246
  docx: { label: "Microsoft Word document.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8247
8247
  ics: { label: "iCalendar.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8248
8248
  jmp: { label: "JMP data file format by SAS Institute.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8249
- json: { label: "JavaScript object notation.", isAutoDetectable: !1, isSupported: !1, notes: "" },
8250
8249
  ods: { label: "OpenDocument for spreadsheets.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8251
8250
  ots: { label: "OpenDocument for word processing.", isAutoDetectable: !0, isSupported: !1, notes: "" },
8252
8251
  parquet: { label: "Apache Parquet.", isAutoDetectable: !0, isSupported: !1, notes: "" },
@@ -8270,46 +8269,67 @@ class rx {
8270
8269
  * Preview file.
8271
8270
  */
8272
8271
  async previewFile(e, x, t) {
8273
- const a = await fetch(encodeURI(e), { headers: { Range: `bytes=0-${t ?? Ze - 1}` }, signal: x });
8272
+ const a = await fetch(encodeURI(e), { headers: { Range: `bytes=0-${t ?? $e - 1}` }, signal: x });
8274
8273
  if (!a.ok)
8275
- throw await Ae(a, `Failed to fetch '${e}' file.`, "datapos-tool-file-operators.previewRemoteFile");
8274
+ throw await Ee(a, `Failed to fetch '${e}' file.`, "datapos-tool-file-operators.previewRemoteFile");
8276
8275
  const n = new Uint8Array(await a.arrayBuffer());
8277
- return await $e(n);
8276
+ return await Ye(n);
8278
8277
  }
8279
8278
  }
8280
- async function $e(i) {
8279
+ async function Ye(i) {
8281
8280
  if (i.length === 0)
8282
- return { bytes: i, dataFormatId: void 0, encodingId: void 0, encodingConfidenceLevel: void 0, fileTypeConfig: void 0, text: void 0 };
8283
- let e, x = await Fe(i);
8284
- if (x == null)
8285
- e = "dtv", x = { ext: "dtv", mime: "text/plain" };
8286
- else {
8287
- const n = Qe[x.ext];
8288
- n == null ? e = x.mime.startsWith("text/") ? "dtv" : void 0 : n.isSupported ? e = x.ext : e = void 0;
8289
- }
8290
- const t = Xe(i), a = Ye(i, t);
8291
- return e == null && ex(a.text) && (e = "json"), {
8281
+ return {
8282
+ bytes: i,
8283
+ dataFormatId: void 0,
8284
+ encodingId: void 0,
8285
+ encodingConfidenceLevel: void 0,
8286
+ fileTypeConfig: void 0,
8287
+ text: void 0
8288
+ };
8289
+ const e = await _e(i);
8290
+ if (e == null) {
8291
+ const n = S0(i), s = F0(i, n);
8292
+ return {
8293
+ bytes: i,
8294
+ dataFormatId: ex(s.text) ? "json" : "dtv",
8295
+ encodingId: s.encoding.id,
8296
+ encodingConfidenceLevel: s.encoding.confidenceLevel,
8297
+ fileTypeConfig: e,
8298
+ text: s.text
8299
+ };
8300
+ }
8301
+ if (Xe[e.ext]?.isSupported ?? !1)
8302
+ return {
8303
+ bytes: i,
8304
+ dataFormatId: e.ext,
8305
+ encodingId: void 0,
8306
+ encodingConfidenceLevel: void 0,
8307
+ fileTypeConfig: e,
8308
+ text: void 0
8309
+ };
8310
+ const t = S0(i), a = F0(i, t);
8311
+ return {
8292
8312
  bytes: i,
8293
- dataFormatId: e,
8313
+ dataFormatId: e.mime.startsWith("application/json") ? "json" : "dtv",
8294
8314
  encodingId: a.encoding.id,
8295
8315
  encodingConfidenceLevel: a.encoding.confidenceLevel,
8296
- fileTypeConfig: x,
8316
+ fileTypeConfig: e,
8297
8317
  text: a.text
8298
8318
  };
8299
8319
  }
8300
- function Xe(i) {
8320
+ function S0(i) {
8301
8321
  if (i[0] === 239 && i[1] === 187 && i[2] === 191) return { confidenceLevel: 100, id: "utf8" };
8302
8322
  if (i[0] === 254 && i[1] === 255) return { confidenceLevel: 100, id: "utf-16be" };
8303
8323
  if (i[0] === 255 && i[1] === 254) return { confidenceLevel: 100, id: "utf-16le" };
8304
- const x = j0.analyse(i)[0] ?? { confidence: void 0, name: "utf8" }, t = Ke[x.name.toLowerCase()], a = t == null ? "utf8" : t.id;
8324
+ const x = P0.analyse(i)[0] ?? { confidence: void 0, name: "utf8" }, t = Qe[x.name.toLowerCase()], a = t == null ? "utf8" : t.id;
8305
8325
  return { confidenceLevel: x.confidence, id: a };
8306
8326
  }
8307
- function Ye(i, e) {
8327
+ function F0(i, e) {
8308
8328
  try {
8309
- const x = new TextDecoder(e.id).decode(S0(i));
8329
+ const x = new TextDecoder(e.id).decode(D0(i));
8310
8330
  return { encoding: e, text: x };
8311
8331
  } catch {
8312
- const x = new TextDecoder(C0.id, { fatal: !1 }).decode(S0(i));
8332
+ const x = new TextDecoder(C0.id, { fatal: !1 }).decode(D0(i));
8313
8333
  return { encoding: C0, text: x };
8314
8334
  }
8315
8335
  }
@@ -8321,7 +8341,7 @@ function ex(i) {
8321
8341
  }
8322
8342
  return !1;
8323
8343
  }
8324
- function S0(i) {
8344
+ function D0(i) {
8325
8345
  let e = i;
8326
8346
  const x = e.length;
8327
8347
  for (let t = x - 1; t >= 0; t--) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-tool-file-operators",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,