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

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
@@ -65,7 +65,7 @@ License data is updated each time `npm run document` is run, using [license-chec
65
65
  | Dependency | Version | License(s) | Document |
66
66
  | :--------------------------------------------------------------------- | :-----: | :--------- | :-------------------------------------------------------------------- |
67
67
  | [@borewit/text-codec](https://github.com/Borewit/text-codec) | 0.2.2 | MIT | [LICENSE](licenses/downloads/@borewit/text-codec@0.2.2-LICENSE.txt) |
68
- | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.132 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.132-LICENSE.txt) |
68
+ | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.134 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.134-LICENSE.txt) |
69
69
  | [@tokenizer/inflate](https://github.com/Borewit/tokenizer-inflate) | 0.5.1 | MIT | [LICENSE](licenses/downloads/@tokenizer/inflate@0.5.1-LICENSE.txt) |
70
70
  | [debug](https://github.com/debug-js/debug) | 4.4.3 | MIT | [LICENSE](licenses/downloads/debug@4.4.3-LICENSE.txt) |
71
71
  | [file-type](https://github.com/sindresorhus/file-type) | 22.2.0 | MIT | [LICENSE](licenses/downloads/file-type@22.2.0-LICENSE.txt) |
@@ -80,7 +80,7 @@ License data is updated each time `npm run document` is run, using [license-chec
80
80
 
81
81
  The dependency tree below shows how each package in the table above is reached — direct and transitive — along with its installed version, release date, and update status. A package that does not ship itself, such as one whose parts are bundled separately, is left out and what ships beneath it is shown in its place. Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are mature and stable (have limited or no dependencies), so they require no active development.
82
82
 
83
- - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.132 — this month: 2026-10-23
83
+ - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.134 — this month: 2026-10-24
84
84
  - **[file-type](https://github.com/sindresorhus/file-type)** 22.2.0 — this month: 2026-10-14
85
85
  - **[valibot](https://github.com/open-circle/valibot)** 1.5.0 — 1 mth ago: 2026-09-09
86
86
  - **[file-type](https://github.com/sindresorhus/file-type)** 22.2.0 — this month: 2026-10-14
@@ -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.6 kB · gzip 718.0 kB · 100.0% of the build |
108
+ | **dist/dpuse-tool-file-previewer.es.js** | 1238.8 kB · gzip 718.1 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,7 +114,7 @@ _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.6 kB |
117
+ |     src → index.ts | `░░░░░░░░░░░░░░░░░░░░` 0.6% · 6.8 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 |
@@ -8938,22 +8938,19 @@ function Mc(e) {
8938
8938
  return n > t && n < e.length - 1 ? n : void 0;
8939
8939
  }
8940
8940
  // src/index.ts
8941
- var Nc = .2, Pc = 4096, Fc = {
8941
+ var Nc = .2, Pc = 4096, Fc = 65536, Ic = {
8942
8942
  id: "utf-8",
8943
8943
  confidenceLevel: void 0
8944
- }, Ic = 256, Lc = /^<\?xml\s[^?]*?\bencoding\s*=\s*(["'])([A-Za-z][\w.:-]*)\1/, Rc = [
8944
+ }, Lc = 256, Rc = /^<\?xml\s[^?]*?\bencoding\s*=\s*(["'])([A-Za-z][\w.:-]*)\1/, zc = [
8945
8945
  "false",
8946
8946
  "null",
8947
8947
  "true"
8948
- ], zc = /* @__PURE__ */ new Set([
8948
+ ], Bc = /* @__PURE__ */ new Set([
8949
8949
  " ",
8950
8950
  " ",
8951
8951
  "\n",
8952
8952
  "\r"
8953
- ]), Bc = {
8954
- markdown: "markdown",
8955
- md: "markdown"
8956
- }, Vc = {
8953
+ ]), Vc = /* @__PURE__ */ new Set(["markdown", "md"]), Hc = "text/markdown", Uc = "application/octet-stream", Wc = {
8957
8954
  arrow: {
8958
8955
  label: "Columnar format for tables of data.",
8959
8956
  structure: "table",
@@ -9008,29 +9005,29 @@ var Nc = .2, Pc = 4096, Fc = {
9008
9005
  isAutoDetectable: !0,
9009
9006
  isSupported: !1
9010
9007
  }
9011
- }, Hc = class {
9012
- async previewFile(e, t, n, r = Nc) {
9013
- let i = n ?? Pc, a = await fetch(encodeURI(e), {
9014
- headers: { Range: `bytes=0-${String(i - 1)}` },
9008
+ }, Gc = class {
9009
+ async previewFile(e, t, n, r, i = Nc) {
9010
+ let a = el(r, jc(new URL(e).pathname)?.toLowerCase()), o = n ?? (a ? Fc : Pc), s = await fetch(encodeURI(e), {
9011
+ headers: { Range: `bytes=0-${String(o - 1)}` },
9015
9012
  signal: t
9016
- }), o = jc(new URL(e).pathname)?.toLowerCase();
9017
- if (a.status === 416) return {
9018
- ...await Wc(/* @__PURE__ */ new Uint8Array(), o, r, !0),
9013
+ });
9014
+ if (s.status === 416) return {
9015
+ ...await qc(/* @__PURE__ */ new Uint8Array(), a, i, !0),
9019
9016
  isComplete: !0
9020
9017
  };
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);
9018
+ if (!s.ok) throw await Tc(s, `Failed to fetch '${e}' file.`, "dpuse-tool-file-previewer.previewRemoteFile");
9019
+ let c = new Uint8Array(await s.arrayBuffer()), l = Kc(s, c.length, o);
9023
9020
  return {
9024
- ...await Wc(s, o, r, c),
9025
- isComplete: c
9021
+ ...await qc(c, a, i, l),
9022
+ isComplete: l
9026
9023
  };
9027
9024
  }
9028
9025
  };
9029
- function Uc(e, t, n) {
9026
+ function Kc(e, t, n) {
9030
9027
  let r = /\/(\d+)$/.exec(e.headers.get("content-range") ?? "")?.[1];
9031
9028
  return r == null ? e.status !== 206 || t < n : t >= Number(r);
9032
9029
  }
9033
- async function Wc(e, t, n, r) {
9030
+ async function qc(e, t, n, r) {
9034
9031
  if (e.length === 0) return {
9035
9032
  bytes: e,
9036
9033
  dataFormatId: void 0,
@@ -9041,11 +9038,11 @@ async function Wc(e, t, n, r) {
9041
9038
  text: void 0
9042
9039
  };
9043
9040
  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);
9041
+ if (i != null) return Jc(e, i, r);
9042
+ let a = Xc(e, n), o = $c(e, a[0] ?? Ic, r);
9046
9043
  return {
9047
9044
  bytes: e,
9048
- dataFormatId: Zc(o.text, t),
9045
+ dataFormatId: tl(o.text, t),
9049
9046
  encodingId: o.encoding.id,
9050
9047
  encodingConfidenceLevel: o.encoding.confidenceLevel,
9051
9048
  encodingCandidates: a,
@@ -9053,11 +9050,11 @@ async function Wc(e, t, n, r) {
9053
9050
  text: o.text
9054
9051
  };
9055
9052
  }
9056
- function Gc(e, t, n) {
9057
- let r = Vc[t.ext]?.isSupported === !0 ? t.ext : void 0;
9053
+ function Jc(e, t, n) {
9054
+ let r = Wc[t.ext]?.isSupported === !0 ? t.ext : void 0;
9058
9055
  if (t.ext === "xml") {
9059
- let i = Xc(e, {
9060
- id: Yc(e),
9056
+ let i = $c(e, {
9057
+ id: Qc(e),
9061
9058
  confidenceLevel: 1
9062
9059
  }, n);
9063
9060
  return {
@@ -9077,17 +9074,17 @@ function Gc(e, t, n) {
9077
9074
  encodingConfidenceLevel: void 0,
9078
9075
  encodingCandidates: void 0,
9079
9076
  fileTypeConfig: t,
9080
- text: Kc(e)
9077
+ text: Yc(e)
9081
9078
  };
9082
9079
  }
9083
- function Kc(e) {
9080
+ function Yc(e) {
9084
9081
  return Array.from(new TextDecoder("windows-1252").decode(e), (e) => {
9085
9082
  let t = e.codePointAt(0) ?? 0;
9086
9083
  return t < 32 && e !== " " && e !== "\n" && e !== "\r" || t >= 127 && t <= 159 ? "·" : e;
9087
9084
  }).join("");
9088
9085
  }
9089
- function qc(e, t) {
9090
- let n = Jc(e);
9086
+ function Xc(e, t) {
9087
+ let n = Zc(e);
9091
9088
  if (n != null) return [n];
9092
9089
  let r = Oa(e, { minimumThreshold: 0 }), i = [];
9093
9090
  for (let { confidence: e, encoding: t } of r) t != null && kc(t) && i.push({
@@ -9096,7 +9093,7 @@ function qc(e, t) {
9096
9093
  });
9097
9094
  return i.filter(({ confidenceLevel: e = 0 }, n) => n === 0 || e >= t);
9098
9095
  }
9099
- function Jc(e) {
9096
+ function Zc(e) {
9100
9097
  return e[0] === 239 && e[1] === 187 && e[2] === 191 ? {
9101
9098
  confidenceLevel: 1,
9102
9099
  id: "UTF-8-SIG"
@@ -9108,12 +9105,12 @@ function Jc(e) {
9108
9105
  id: "utf-16-le"
9109
9106
  } : void 0;
9110
9107
  }
9111
- function Yc(e) {
9112
- let t = new TextDecoder("ascii").decode(e.subarray(0, Ic));
9113
- return Jc(e)?.id ?? Lc.exec(t)?.[2] ?? "utf-8";
9108
+ function Qc(e) {
9109
+ let t = new TextDecoder("ascii").decode(e.subarray(0, Lc));
9110
+ return Zc(e)?.id ?? Rc.exec(t)?.[2] ?? "utf-8";
9114
9111
  }
9115
- function Xc(e, t, n) {
9116
- let r = n ? e : ll(e);
9112
+ function $c(e, t, n) {
9113
+ let r = n ? e : pl(e);
9117
9114
  try {
9118
9115
  return {
9119
9116
  encoding: t,
@@ -9121,29 +9118,33 @@ function Xc(e, t, n) {
9121
9118
  };
9122
9119
  } catch {
9123
9120
  return {
9124
- encoding: Fc,
9125
- text: new TextDecoder(Fc.id, { fatal: !1 }).decode(r)
9121
+ encoding: Ic,
9122
+ text: new TextDecoder(Ic.id, { fatal: !1 }).decode(r)
9126
9123
  };
9127
9124
  }
9128
9125
  }
9129
- function Zc(e, t) {
9130
- return Qc(e) ? "json" : $c(e) ? "jsonl" : (t == null ? void 0 : Bc[t]) ?? "dtv";
9126
+ function el(e, t) {
9127
+ let n = e?.split(";", 1)[0]?.trim().toLowerCase();
9128
+ return n != null && n !== "" && n !== Uc ? n === Hc : t != null && Vc.has(t);
9131
9129
  }
9132
- function Qc(e) {
9130
+ function tl(e, t) {
9131
+ return nl(e) ? "json" : rl(e) ? "jsonl" : t ? "markdown" : "dtv";
9132
+ }
9133
+ function nl(e) {
9133
9134
  let t = [], n = e.search(/\S/);
9134
9135
  if (e[n] !== "{" && e[n] !== "[") return !1;
9135
9136
  let r = {
9136
9137
  expectation: "value",
9137
9138
  index: n
9138
9139
  };
9139
- for (; r != null && r.index < e.length;) r = tl(e, r, t);
9140
+ for (; r != null && r.index < e.length;) r = al(e, r, t);
9140
9141
  return r != null;
9141
9142
  }
9142
- function $c(e) {
9143
+ function rl(e) {
9143
9144
  let t = e.split(/\r\n|\n|\r/).filter((e) => e.trim() !== "");
9144
- return t.length > 1 && t.every((e) => el(e));
9145
+ return t.length > 1 && t.every((e) => il(e));
9145
9146
  }
9146
- function el(e) {
9147
+ function il(e) {
9147
9148
  try {
9148
9149
  let t = JSON.parse(e);
9149
9150
  return typeof t == "object" && !!t;
@@ -9151,15 +9152,15 @@ function el(e) {
9151
9152
  return !1;
9152
9153
  }
9153
9154
  }
9154
- function tl(e, { expectation: t, index: n }, r) {
9155
+ function al(e, { expectation: t, index: n }, r) {
9155
9156
  let i = e.charAt(n);
9156
- if (zc.has(i)) return {
9157
+ if (Bc.has(i)) return {
9157
9158
  expectation: t,
9158
9159
  index: n + 1
9159
9160
  };
9160
9161
  switch (t) {
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);
9162
+ case "closeOrKey": return i === "}" ? ol(i, n, r) : sl(e, n);
9163
+ case "closeOrValue": return i === "]" ? ol(i, n, r) : cl(e, n, r);
9163
9164
  case "colon": return i === ":" ? {
9164
9165
  expectation: "value",
9165
9166
  index: n + 1
@@ -9167,69 +9168,69 @@ function tl(e, { expectation: t, index: n }, r) {
9167
9168
  case "commaOrClose": return i === "," ? {
9168
9169
  expectation: r.at(-1) === "{" ? "key" : "value",
9169
9170
  index: n + 1
9170
- } : nl(i, n, r);
9171
+ } : ol(i, n, r);
9171
9172
  case "end": return;
9172
- case "key": return rl(e, n);
9173
- case "value": return il(e, n, r);
9173
+ case "key": return sl(e, n);
9174
+ case "value": return cl(e, n, r);
9174
9175
  }
9175
9176
  }
9176
- function nl(e, t, n) {
9177
+ function ol(e, t, n) {
9177
9178
  if (e === (n.at(-1) === "{" ? "}" : "]")) return n.pop(), {
9178
9179
  expectation: n.length === 0 ? "end" : "commaOrClose",
9179
9180
  index: t + 1
9180
9181
  };
9181
9182
  }
9182
- function rl(e, t) {
9183
- let n = e.charAt(t) === "\"" ? al(e, t) : void 0;
9183
+ function sl(e, t) {
9184
+ let n = e.charAt(t) === "\"" ? ll(e, t) : void 0;
9184
9185
  return n == null ? void 0 : {
9185
9186
  expectation: "colon",
9186
9187
  index: n
9187
9188
  };
9188
9189
  }
9189
- function il(e, t, n) {
9190
+ function cl(e, t, n) {
9190
9191
  let r = e.charAt(t);
9191
9192
  if (r === "{" || r === "[") return n.push(r), {
9192
9193
  expectation: r === "{" ? "closeOrKey" : "closeOrValue",
9193
9194
  index: t + 1
9194
9195
  };
9195
- let i = r === "\"" ? al(e, t) : sl(e, t);
9196
+ let i = r === "\"" ? ll(e, t) : dl(e, t);
9196
9197
  return i == null ? void 0 : {
9197
9198
  expectation: "commaOrClose",
9198
9199
  index: i
9199
9200
  };
9200
9201
  }
9201
- function al(e, t) {
9202
+ function ll(e, t) {
9202
9203
  let n = t + 1;
9203
9204
  for (; n < e.length;) {
9204
9205
  let t = e.charAt(n);
9205
9206
  if (t === "\"") return n + 1;
9206
9207
  if (t < " ") return;
9207
9208
  if (t === "\\") {
9208
- let t = ol(e, n);
9209
+ let t = ul(e, n);
9209
9210
  if (t == null) return;
9210
9211
  n = t;
9211
9212
  } else n++;
9212
9213
  }
9213
9214
  return e.length;
9214
9215
  }
9215
- function ol(e, t) {
9216
+ function ul(e, t) {
9216
9217
  let n = e.charAt(t + 1);
9217
9218
  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;
9218
9219
  }
9219
- function sl(e, t) {
9220
+ function dl(e, t) {
9220
9221
  let n = /^[\w.+-]+/.exec(e.slice(t))?.[0];
9221
9222
  if (n == null) return;
9222
9223
  let r = t + n.length;
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;
9224
+ return r === e.length ? zc.some((e) => e.startsWith(n)) || /^[\d.e+-]*$/i.test(n) ? r : void 0 : zc.includes(n) || fl(n) ? r : void 0;
9224
9225
  }
9225
- function cl(e) {
9226
+ function fl(e) {
9226
9227
  try {
9227
9228
  return typeof JSON.parse(e) == "number";
9228
9229
  } catch {
9229
9230
  return !1;
9230
9231
  }
9231
9232
  }
9232
- function ll(e) {
9233
+ function pl(e) {
9233
9234
  let t = e, n = t.length;
9234
9235
  for (let e = n - 1; e >= 0; e--) {
9235
9236
  let n = t[e];
@@ -9244,4 +9245,4 @@ function ll(e) {
9244
9245
  }
9245
9246
  return t;
9246
9247
  }
9247
- export { Hc as Tool };
9248
+ export { Gc as Tool };