@dpuse/dpuse-tool-file-previewer 1.0.131 → 1.0.134

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,7 +1,7 @@
1
1
  {
2
2
  "packages": [
3
3
  "@borewit/text-codec@0.2.3",
4
- "@dpuse/dpuse-shared@1.0.205",
4
+ "@dpuse/dpuse-shared@1.0.209",
5
5
  "@tokenizer/inflate@0.6.0",
6
6
  "debug@4.4.3",
7
7
  "file-type@22.3.0",
@@ -0,0 +1,20 @@
1
+ import { EncodingDetectionConfig, EncodingSourceId } from '@dpuse/dpuse-shared';
2
+ export type DecodingEncoding = Omit<EncodingDetectionConfig, 'id'> & {
3
+ id: string;
4
+ };
5
+ export interface EncodingDetection {
6
+ encoding: DecodingEncoding;
7
+ sourceId: EncodingSourceId;
8
+ }
9
+ export interface DecodedText {
10
+ encoding: DecodingEncoding;
11
+ isFallback: boolean;
12
+ replacementCharacterCount: number;
13
+ text: string;
14
+ }
15
+ export declare function detectTextEncoding(fileBytes: Uint8Array, isComplete: boolean): EncodingDetection & {
16
+ candidates: EncodingDetectionConfig[];
17
+ };
18
+ export declare function detectXMLEncoding(fileBytes: Uint8Array): EncodingDetection;
19
+ export declare function decodeFileBytes(fileBytes: Uint8Array, encoding: DecodingEncoding, isComplete: boolean): DecodedText;
20
+ export declare function decodeBytesAsCharacters(fileBytes: Uint8Array): string;
@@ -1,19 +1,4 @@
1
- import { FileTypeResult } from 'file-type';
2
- import { DataFormatId, EncodingDetectionConfig } from '@dpuse/dpuse-shared';
3
- export interface FilePreviewResult {
4
- bytes: Uint8Array;
5
- dataFormatId: DataFormatId | undefined;
6
- encodingId: string | undefined;
7
- encodingConfidenceLevel: number | undefined;
8
- encodingCandidates: EncodingDetectionConfig[] | undefined;
9
- fileTypeConfig: FileTypeResult | undefined;
10
- isComplete: boolean;
11
- text: string | undefined;
12
- }
13
- export interface PreviewChoices {
14
- dataFormatId: DataFormatId | undefined;
15
- encodingId: string | undefined;
16
- }
17
- export declare class Tool {
18
- previewFile(url: string, signal: AbortSignal, chunkSize?: number, mimeType?: string, minimumConfidenceLevel?: number, choices?: PreviewChoices): Promise<FilePreviewResult>;
1
+ import { FilePreviewerInterface, FilePreviewResult, PreviewChoices } from '@dpuse/dpuse-shared';
2
+ export declare class Tool implements FilePreviewerInterface {
3
+ previewFile(url: string, signal: AbortSignal, chunkSize?: number, mimeType?: string, choices?: PreviewChoices): Promise<FilePreviewResult>;
19
4
  }
@@ -0,0 +1,2 @@
1
+ export declare function isLikelyJSONFormat(text: string): boolean;
2
+ export declare function isLikelyJSONLinesFormat(text: string): boolean;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dpuse/dpuse-tool-file-previewer",
3
- "version": "1.0.131",
3
+ "version": "1.0.134",
4
4
  "private": false,
5
- "description": "...",
5
+ "description": "A library that wraps file-type and jschardet to identify a file's format and encoding from its first bytes, and return a decoded sample of its text.",
6
6
  "license": "MIT",
7
7
  "author": "Jonathan Terrell <terrell.jm@gmail.com>",
8
8
  "type": "module",
@@ -61,7 +61,7 @@
61
61
  "test": "node -e \"import('@dpuse/dpuse-development').then(m => m.testProject())\""
62
62
  },
63
63
  "dependencies": {
64
- "@dpuse/dpuse-shared": "^1.0.205",
64
+ "@dpuse/dpuse-shared": "^1.0.209",
65
65
  "file-type": "^22.3.0",
66
66
  "jschardet": "^4.1.0"
67
67
  },
@@ -74,7 +74,7 @@
74
74
  "prettier": "^3.9.10",
75
75
  "sonda": "^0.14.0",
76
76
  "typescript": "^6.0.3",
77
- "vite": "^8.3.7",
77
+ "vite": "^8.3.8",
78
78
  "vite-plugin-dts": "^5.1.2",
79
79
  "vitest": "^5.1.0",
80
80
  "wrangler": "^4.160.0"