@dpuse/dpuse-tool-file-previewer 1.0.118 → 1.0.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -105,7 +105,7 @@ _Note: Sonda's Vite reports currently exclude CSS files, since Vite does not gen
105
105
 
106
106
  | Chunk/Module/File | Composition |
107
107
  | :---------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------ |
108
- | **dist/dpuse-tool-file-previewer.es.js** | 1238.3 kB · gzip 717.9 kB · 100.0% of the build |
108
+ | **dist/dpuse-tool-file-previewer.es.js** | 1238.6 kB · gzip 718.0 kB · 100.0% of the build |
109
109
  |     jschardet → dist/jschardet.esm.min.js | `██████████████████░░` 90.6% · 1122.3 kB |
110
110
  |     file-type → source/index.js + 7 more | `█░░░░░░░░░░░░░░░░░░░` 3.7% · 45.3 kB |
111
111
  |         ↳ 8 smaller files | `▒░░░░░░░░░░░░░░░░░░░` 3.7% · 45.3 kB |
@@ -114,14 +114,14 @@ _Note: Sonda's Vite reports currently exclude CSS files, since Vite does not gen
114
114
  |         ↳ 13 smaller files | `░░░░░░░░░░░░░░░░░░░░` 0.8% · 9.4 kB |
115
115
  |     @tokenizer/inflate → lib/ZipHandler.js + 3 more | `░░░░░░░░░░░░░░░░░░░░` 0.7% · 8.4 kB |
116
116
  |         ↳ 4 smaller files | `░░░░░░░░░░░░░░░░░░░░` 0.7% · 8.4 kB |
117
- |     src → index.ts | `░░░░░░░░░░░░░░░░░░░░` 0.5% · 6.3 kB |
117
+ |     src → index.ts | `░░░░░░░░░░░░░░░░░░░░` 0.5% · 6.6 kB |
118
118
  |     debug → src/browser.js + 1 more | `░░░░░░░░░░░░░░░░░░░░` 0.4% · 5.1 kB |
119
119
  |         ↳ 2 smaller files | `░░░░░░░░░░░░░░░░░░░░` 0.4% · 5.1 kB |
120
120
  |     @borewit/text-codec → lib/index.js | `░░░░░░░░░░░░░░░░░░░░` 0.3% · 3.3 kB |
121
121
  |     ms → index.js | `░░░░░░░░░░░░░░░░░░░░` 0.1% · 1.6 kB |
122
122
  |     uint8array-extras → index.js | `░░░░░░░░░░░░░░░░░░░░` 0.1% · 1.2 kB |
123
123
  |     token-types → lib/index.js | `░░░░░░░░░░░░░░░░░░░░` 0.1% · 1018 B |
124
- |     (bundler output, whitespace & JSON) | `░░░░░░░░░░░░░░░░░░░░` 1.5% · 19.2 kB |
124
+ |     (bundler output, whitespace & JSON) | `░░░░░░░░░░░░░░░░░░░░` 1.6% · 19.2 kB |
125
125
 
126
126
  Bars show each row's share of its output file. ↳ rows are part of the row above.
127
127
 
@@ -9010,16 +9010,27 @@ var Nc = .2, Pc = 4096, Fc = {
9010
9010
  }
9011
9011
  }, Hc = class {
9012
9012
  async previewFile(e, t, n, r = Nc) {
9013
- let i = await fetch(encodeURI(e), {
9014
- headers: { Range: `bytes=0-${String((n ?? Pc) - 1)}` },
9013
+ let i = n ?? Pc, a = await fetch(encodeURI(e), {
9014
+ headers: { Range: `bytes=0-${String(i - 1)}` },
9015
9015
  signal: t
9016
- }), a = jc(new URL(e).pathname)?.toLowerCase();
9017
- if (i.status === 416) return await Uc(/* @__PURE__ */ new Uint8Array(), a, r);
9018
- if (!i.ok) throw await Tc(i, `Failed to fetch '${e}' file.`, "dpuse-tool-file-previewer.previewRemoteFile");
9019
- return await Uc(new Uint8Array(await i.arrayBuffer()), a, r);
9016
+ }), o = jc(new URL(e).pathname)?.toLowerCase();
9017
+ if (a.status === 416) return {
9018
+ ...await Wc(/* @__PURE__ */ new Uint8Array(), o, r, !0),
9019
+ isComplete: !0
9020
+ };
9021
+ if (!a.ok) throw await Tc(a, `Failed to fetch '${e}' file.`, "dpuse-tool-file-previewer.previewRemoteFile");
9022
+ let s = new Uint8Array(await a.arrayBuffer()), c = Uc(a, s.length, i);
9023
+ return {
9024
+ ...await Wc(s, o, r, c),
9025
+ isComplete: c
9026
+ };
9020
9027
  }
9021
9028
  };
9022
- async function Uc(e, t, n) {
9029
+ function Uc(e, t, n) {
9030
+ let r = /\/(\d+)$/.exec(e.headers.get("content-range") ?? "")?.[1];
9031
+ return r == null ? e.status !== 206 || t < n : t >= Number(r);
9032
+ }
9033
+ async function Wc(e, t, n, r) {
9023
9034
  if (e.length === 0) return {
9024
9035
  bytes: e,
9025
9036
  dataFormatId: void 0,
@@ -9029,54 +9040,54 @@ async function Uc(e, t, n) {
9029
9040
  fileTypeConfig: void 0,
9030
9041
  text: void 0
9031
9042
  };
9032
- let r = await Qs(e);
9033
- if (r != null) return Wc(e, r);
9034
- let i = Kc(e, n), a = Yc(e, i[0] ?? Fc);
9043
+ let i = await Qs(e);
9044
+ if (i != null) return Gc(e, i, r);
9045
+ let a = qc(e, n), o = Xc(e, a[0] ?? Fc, r);
9035
9046
  return {
9036
9047
  bytes: e,
9037
- dataFormatId: Xc(a.text, t),
9038
- encodingId: a.encoding.id,
9039
- encodingConfidenceLevel: a.encoding.confidenceLevel,
9040
- encodingCandidates: i,
9041
- fileTypeConfig: r,
9042
- text: a.text
9048
+ dataFormatId: Zc(o.text, t),
9049
+ encodingId: o.encoding.id,
9050
+ encodingConfidenceLevel: o.encoding.confidenceLevel,
9051
+ encodingCandidates: a,
9052
+ fileTypeConfig: i,
9053
+ text: o.text
9043
9054
  };
9044
9055
  }
9045
- function Wc(e, t) {
9046
- let n = Vc[t.ext]?.isSupported === !0 ? t.ext : void 0;
9056
+ function Gc(e, t, n) {
9057
+ let r = Vc[t.ext]?.isSupported === !0 ? t.ext : void 0;
9047
9058
  if (t.ext === "xml") {
9048
- let r = Yc(e, {
9049
- id: Jc(e),
9059
+ let i = Xc(e, {
9060
+ id: Yc(e),
9050
9061
  confidenceLevel: 1
9051
- });
9062
+ }, n);
9052
9063
  return {
9053
9064
  bytes: e,
9054
- dataFormatId: n,
9055
- encodingId: r.encoding.id,
9056
- encodingConfidenceLevel: r.encoding.confidenceLevel,
9065
+ dataFormatId: r,
9066
+ encodingId: i.encoding.id,
9067
+ encodingConfidenceLevel: i.encoding.confidenceLevel,
9057
9068
  encodingCandidates: void 0,
9058
9069
  fileTypeConfig: t,
9059
- text: r.text
9070
+ text: i.text
9060
9071
  };
9061
9072
  }
9062
9073
  return {
9063
9074
  bytes: e,
9064
- dataFormatId: n,
9075
+ dataFormatId: r,
9065
9076
  encodingId: void 0,
9066
9077
  encodingConfidenceLevel: void 0,
9067
9078
  encodingCandidates: void 0,
9068
9079
  fileTypeConfig: t,
9069
- text: Gc(e)
9080
+ text: Kc(e)
9070
9081
  };
9071
9082
  }
9072
- function Gc(e) {
9083
+ function Kc(e) {
9073
9084
  return Array.from(new TextDecoder("windows-1252").decode(e), (e) => {
9074
9085
  let t = e.codePointAt(0) ?? 0;
9075
9086
  return t < 32 && e !== " " && e !== "\n" && e !== "\r" || t >= 127 && t <= 159 ? "·" : e;
9076
9087
  }).join("");
9077
9088
  }
9078
- function Kc(e, t) {
9079
- let n = qc(e);
9089
+ function qc(e, t) {
9090
+ let n = Jc(e);
9080
9091
  if (n != null) return [n];
9081
9092
  let r = Oa(e, { minimumThreshold: 0 }), i = [];
9082
9093
  for (let { confidence: e, encoding: t } of r) t != null && kc(t) && i.push({
@@ -9085,7 +9096,7 @@ function Kc(e, t) {
9085
9096
  });
9086
9097
  return i.filter(({ confidenceLevel: e = 0 }, n) => n === 0 || e >= t);
9087
9098
  }
9088
- function qc(e) {
9099
+ function Jc(e) {
9089
9100
  return e[0] === 239 && e[1] === 187 && e[2] === 191 ? {
9090
9101
  confidenceLevel: 1,
9091
9102
  id: "UTF-8-SIG"
@@ -9097,41 +9108,42 @@ function qc(e) {
9097
9108
  id: "utf-16-le"
9098
9109
  } : void 0;
9099
9110
  }
9100
- function Jc(e) {
9111
+ function Yc(e) {
9101
9112
  let t = new TextDecoder("ascii").decode(e.subarray(0, Ic));
9102
- return qc(e)?.id ?? Lc.exec(t)?.[2] ?? "utf-8";
9113
+ return Jc(e)?.id ?? Lc.exec(t)?.[2] ?? "utf-8";
9103
9114
  }
9104
- function Yc(e, t) {
9115
+ function Xc(e, t, n) {
9116
+ let r = n ? e : ll(e);
9105
9117
  try {
9106
9118
  return {
9107
9119
  encoding: t,
9108
- text: new TextDecoder(Ac(t.id)).decode(cl(e))
9120
+ text: new TextDecoder(Ac(t.id)).decode(r)
9109
9121
  };
9110
9122
  } catch {
9111
9123
  return {
9112
9124
  encoding: Fc,
9113
- text: new TextDecoder(Fc.id, { fatal: !1 }).decode(cl(e))
9125
+ text: new TextDecoder(Fc.id, { fatal: !1 }).decode(r)
9114
9126
  };
9115
9127
  }
9116
9128
  }
9117
- function Xc(e, t) {
9118
- return Zc(e) ? "json" : Qc(e) ? "jsonl" : (t == null ? void 0 : Bc[t]) ?? "dtv";
9129
+ function Zc(e, t) {
9130
+ return Qc(e) ? "json" : $c(e) ? "jsonl" : (t == null ? void 0 : Bc[t]) ?? "dtv";
9119
9131
  }
9120
- function Zc(e) {
9132
+ function Qc(e) {
9121
9133
  let t = [], n = e.search(/\S/);
9122
9134
  if (e[n] !== "{" && e[n] !== "[") return !1;
9123
9135
  let r = {
9124
9136
  expectation: "value",
9125
9137
  index: n
9126
9138
  };
9127
- for (; r != null && r.index < e.length;) r = el(e, r, t);
9139
+ for (; r != null && r.index < e.length;) r = tl(e, r, t);
9128
9140
  return r != null;
9129
9141
  }
9130
- function Qc(e) {
9142
+ function $c(e) {
9131
9143
  let t = e.split(/\r\n|\n|\r/).filter((e) => e.trim() !== "");
9132
- return t.length > 1 && t.every((e) => $c(e));
9144
+ return t.length > 1 && t.every((e) => el(e));
9133
9145
  }
9134
- function $c(e) {
9146
+ function el(e) {
9135
9147
  try {
9136
9148
  let t = JSON.parse(e);
9137
9149
  return typeof t == "object" && !!t;
@@ -9139,15 +9151,15 @@ function $c(e) {
9139
9151
  return !1;
9140
9152
  }
9141
9153
  }
9142
- function el(e, { expectation: t, index: n }, r) {
9154
+ function tl(e, { expectation: t, index: n }, r) {
9143
9155
  let i = e.charAt(n);
9144
9156
  if (zc.has(i)) return {
9145
9157
  expectation: t,
9146
9158
  index: n + 1
9147
9159
  };
9148
9160
  switch (t) {
9149
- case "closeOrKey": return i === "}" ? tl(i, n, r) : nl(e, n);
9150
- case "closeOrValue": return i === "]" ? tl(i, n, r) : rl(e, n, r);
9161
+ case "closeOrKey": return i === "}" ? nl(i, n, r) : rl(e, n);
9162
+ case "closeOrValue": return i === "]" ? nl(i, n, r) : il(e, n, r);
9151
9163
  case "colon": return i === ":" ? {
9152
9164
  expectation: "value",
9153
9165
  index: n + 1
@@ -9155,69 +9167,69 @@ function el(e, { expectation: t, index: n }, r) {
9155
9167
  case "commaOrClose": return i === "," ? {
9156
9168
  expectation: r.at(-1) === "{" ? "key" : "value",
9157
9169
  index: n + 1
9158
- } : tl(i, n, r);
9170
+ } : nl(i, n, r);
9159
9171
  case "end": return;
9160
- case "key": return nl(e, n);
9161
- case "value": return rl(e, n, r);
9172
+ case "key": return rl(e, n);
9173
+ case "value": return il(e, n, r);
9162
9174
  }
9163
9175
  }
9164
- function tl(e, t, n) {
9176
+ function nl(e, t, n) {
9165
9177
  if (e === (n.at(-1) === "{" ? "}" : "]")) return n.pop(), {
9166
9178
  expectation: n.length === 0 ? "end" : "commaOrClose",
9167
9179
  index: t + 1
9168
9180
  };
9169
9181
  }
9170
- function nl(e, t) {
9171
- let n = e.charAt(t) === "\"" ? il(e, t) : void 0;
9182
+ function rl(e, t) {
9183
+ let n = e.charAt(t) === "\"" ? al(e, t) : void 0;
9172
9184
  return n == null ? void 0 : {
9173
9185
  expectation: "colon",
9174
9186
  index: n
9175
9187
  };
9176
9188
  }
9177
- function rl(e, t, n) {
9189
+ function il(e, t, n) {
9178
9190
  let r = e.charAt(t);
9179
9191
  if (r === "{" || r === "[") return n.push(r), {
9180
9192
  expectation: r === "{" ? "closeOrKey" : "closeOrValue",
9181
9193
  index: t + 1
9182
9194
  };
9183
- let i = r === "\"" ? il(e, t) : ol(e, t);
9195
+ let i = r === "\"" ? al(e, t) : sl(e, t);
9184
9196
  return i == null ? void 0 : {
9185
9197
  expectation: "commaOrClose",
9186
9198
  index: i
9187
9199
  };
9188
9200
  }
9189
- function il(e, t) {
9201
+ function al(e, t) {
9190
9202
  let n = t + 1;
9191
9203
  for (; n < e.length;) {
9192
9204
  let t = e.charAt(n);
9193
9205
  if (t === "\"") return n + 1;
9194
9206
  if (t < " ") return;
9195
9207
  if (t === "\\") {
9196
- let t = al(e, n);
9208
+ let t = ol(e, n);
9197
9209
  if (t == null) return;
9198
9210
  n = t;
9199
9211
  } else n++;
9200
9212
  }
9201
9213
  return e.length;
9202
9214
  }
9203
- function al(e, t) {
9215
+ function ol(e, t) {
9204
9216
  let n = e.charAt(t + 1);
9205
9217
  return n === "u" ? /^[\da-f]*$/i.test(e.slice(t + 2, t + 6)) ? t + 6 : void 0 : n === "" || String.raw`"\/bfnrt`.includes(n) ? t + 2 : void 0;
9206
9218
  }
9207
- function ol(e, t) {
9219
+ function sl(e, t) {
9208
9220
  let n = /^[\w.+-]+/.exec(e.slice(t))?.[0];
9209
9221
  if (n == null) return;
9210
9222
  let r = t + n.length;
9211
- return r === e.length ? Rc.some((e) => e.startsWith(n)) || /^[\d.e+-]*$/i.test(n) ? r : void 0 : Rc.includes(n) || sl(n) ? r : void 0;
9223
+ return r === e.length ? Rc.some((e) => e.startsWith(n)) || /^[\d.e+-]*$/i.test(n) ? r : void 0 : Rc.includes(n) || cl(n) ? r : void 0;
9212
9224
  }
9213
- function sl(e) {
9225
+ function cl(e) {
9214
9226
  try {
9215
9227
  return typeof JSON.parse(e) == "number";
9216
9228
  } catch {
9217
9229
  return !1;
9218
9230
  }
9219
9231
  }
9220
- function cl(e) {
9232
+ function ll(e) {
9221
9233
  let t = e, n = t.length;
9222
9234
  for (let e = n - 1; e >= 0; e--) {
9223
9235
  let n = t[e];