@datapos/datapos-tool-file-operators 0.0.5 → 0.0.6

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.
@@ -8155,9 +8155,8 @@ class De extends Error {
8155
8155
  super(e, t), this.name = new.target.name, this.locator = x;
8156
8156
  }
8157
8157
  }
8158
- class Be extends De {
8159
- }
8160
- let Ie = class extends Be {
8158
+ let Be = class extends De {
8159
+ }, Ie = class extends Be {
8161
8160
  body;
8162
8161
  /** Sanitized HTTP response body. */
8163
8162
  constructor(e, x, t, a) {
@@ -8241,23 +8240,23 @@ const Ae = { id: "ascii", groupLabel: "", label: "ascii", isDetectable: !1, isDe
8241
8240
  "windows-874": { id: "windows-874", groupLabel: "Thai", label: "Thai (windows-874)", isDetectable: !1, isDecodable: !0 },
8242
8241
  "x-mac-cyrillic": { id: "x-mac-cyrillic", groupLabel: "Cyrillic", label: "Cyrillic (x-mac-cyrillic)", isDetectable: !1, isDecodable: !0 },
8243
8242
  "x-user-defined": { id: "x-user-defined", groupLabel: "Other", label: "Other (x-user-defined)", isDetectable: !1, isDecodable: !0 }
8244
- }, Ke = 4096, v0 = { id: "utf8", confidenceLevel: void 0 };
8245
- class xx {
8243
+ }, Ke = Je, Ze = 4096, v0 = { id: "utf8", confidenceLevel: void 0 };
8244
+ class ix {
8246
8245
  /**
8247
- * Preview remote file.
8246
+ * Preview file.
8248
8247
  */
8249
- async previewRemoteFile(e, x, t) {
8250
- const a = await fetch(encodeURI(e), { headers: { Range: `bytes=0-${t ?? Ke - 1}` }, signal: x });
8248
+ async previewFile(e, x, t) {
8249
+ const a = await fetch(encodeURI(e), { headers: { Range: `bytes=0-${t ?? Ze - 1}` }, signal: x });
8251
8250
  if (!a.ok)
8252
8251
  throw await Oe(a, `Failed to fetch '${e}' file.`, "datapos-tool-file-operators.previewRemoteFile");
8253
8252
  const n = new Uint8Array(await a.arrayBuffer()), s = await Se(n);
8254
8253
  if (s && !s.mime.startsWith("text/"))
8255
8254
  throw new Error(`Files of type '${s.ext}' (mine '${s.mime}') not supported.`);
8256
- return Ze(n);
8255
+ return $e(n);
8257
8256
  }
8258
8257
  }
8259
- function Ze(i) {
8260
- const e = $e(i), x = Qe(i, e);
8258
+ function $e(i) {
8259
+ const e = Qe(i), x = Xe(i, e);
8261
8260
  return {
8262
8261
  bytes: i,
8263
8262
  dataFormatId: "dtv",
@@ -8267,14 +8266,14 @@ function Ze(i) {
8267
8266
  text: x.text
8268
8267
  };
8269
8268
  }
8270
- function $e(i) {
8269
+ function Qe(i) {
8271
8270
  if (i[0] === 239 && i[1] === 187 && i[2] === 191) return { confidenceLevel: 100, id: "utf8" };
8272
8271
  if (i[0] === 254 && i[1] === 255) return { confidenceLevel: 100, id: "utf-16be" };
8273
8272
  if (i[0] === 255 && i[1] === 254) return { confidenceLevel: 100, id: "utf-16le" };
8274
- const x = j0.analyse(i)[0] ?? { confidence: void 0, name: "utf8" }, t = Je[x.name.toLowerCase()], a = t == null ? "utf8" : t.id;
8273
+ const x = j0.analyse(i)[0] ?? { confidence: void 0, name: "utf8" }, t = Ke[x.name.toLowerCase()], a = t == null ? "utf8" : t.id;
8275
8274
  return { confidenceLevel: x.confidence, id: a };
8276
8275
  }
8277
- function Qe(i, e) {
8276
+ function Xe(i, e) {
8278
8277
  try {
8279
8278
  const x = new TextDecoder(e.id).decode(F0(i));
8280
8279
  return { encoding: e, text: x };
@@ -8304,5 +8303,5 @@ function F0(i) {
8304
8303
  return e;
8305
8304
  }
8306
8305
  export {
8307
- xx as Tool
8306
+ ix as Tool
8308
8307
  };
@@ -7,10 +7,13 @@ interface PreviewConfig {
7
7
  size: number;
8
8
  text: string;
9
9
  }
10
+ /**
11
+ * Tool.
12
+ */
10
13
  declare class Tool {
11
14
  /**
12
- * Preview remote file.
15
+ * Preview file.
13
16
  */
14
- previewRemoteFile(url: string, signal: AbortSignal, chunkSize?: number): Promise<PreviewConfig>;
17
+ previewFile(url: string, signal: AbortSignal, chunkSize?: number): Promise<PreviewConfig>;
15
18
  }
16
19
  export { type PreviewConfig, Tool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-tool-file-operators",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -65,7 +65,7 @@
65
65
  "update": "node -e \"import('@datapos/datapos-development').then(m => m.updateDataPosDependencies(['development']))\""
66
66
  },
67
67
  "dependencies": {
68
- "@datapos/datapos-shared": "^0.3.430",
68
+ "@datapos/datapos-shared": "^0.3.433",
69
69
  "chardet": "^2.1.1",
70
70
  "file-type": "^21.2.0"
71
71
  }