@dragon708/docmind-browser 1.8.6 → 1.9.0

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.
Files changed (2) hide show
  1. package/README.md +179 -0
  2. package/package.json +5 -5
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # `@dragon708/docmind-browser`
2
+
3
+ **Cliente oficial de DocMind para el navegador** (API pública de alto nivel): mismos **intents** que en Node (`analyzeFile`, `extractText`, `extractMetadata`, `convertToHtml`, `runOcr`, `extractStructuredData`, `extractMarkdown`, `extractLlmContent`, `extractStructuredChunks`, `detectFileKind`, `getCapabilities`, `explainAnalysisPlan`) pero con un **alcance de runtime** distinto: aquí hay **DOCX**, **imágenes (OCR con Tesseract.js / WASM)** y **texto UTF-8**. **No** hay motor PDF completo ni **conversión binaria pesada a Markdown** (PDF/HTML/CSV/Excel desde bytes) en el navegador: esas rutas viven en Node.
4
+
5
+ ---
6
+
7
+ ## Instalación
8
+
9
+ ```bash
10
+ npm install @dragon708/docmind-browser
11
+ ```
12
+
13
+ Incluye `@dragon708/docmind-ocr` (Tesseract.js), `@dragon708/docmind-docx`, `@dragon708/docmind-markdown` y `@dragon708/docmind-shared`. El bundle será pesado por WASM y modelos de OCR si los cargas.
14
+
15
+ ---
16
+
17
+ ## Alcance: navegador vs Node
18
+
19
+ | Capacidad | En navegador (`docmind-browser`) | En Node (`docmind-node`) |
20
+ |-----------|-----------------------------------|---------------------------|
21
+ | PDF texto/metadata/OCR/pdf.js | No (PDF → `not_implemented` o envelope vacío según API) | Sí |
22
+ | DOCX texto/HTML/structured | Sí (Mammoth) | Sí |
23
+ | Imagen OCR | Sí (Tesseract.js) | Sí |
24
+ | `extractMarkdown` con bytes PDF/HTML/CSV/XLSX | No (en cliente: fallback estructurado o vacío con avisos) | Sí (motor de conversión en Node) |
25
+ | `extractLlmContent` / chunks | Sobre structured disponible (DOCX/imagen/texto) | Igual + PDF |
26
+
27
+ Las funciones **`convertHtmlToMarkdown`**, **`convertCsvToMarkdown`**, **`convertSpreadsheetToMarkdown`** y **`detectBinaryFormat`** se re-exportan para **imports isomórficos**; en navegador devuelven rutas “unsupported runtime” con `warnings` (no lanzan por defecto en el patrón de markdown package).
28
+
29
+ ---
30
+
31
+ ## Uso rápido
32
+
33
+ ### Analizar un `File` del `<input type="file">`
34
+
35
+ ```ts
36
+ import { analyzeFile } from "@dragon708/docmind-browser";
37
+
38
+ input.addEventListener("change", async () => {
39
+ const file = input.files?.[0];
40
+ if (!file) return;
41
+ const result = await analyzeFile(file);
42
+ console.log(result.text, result.warnings);
43
+ });
44
+ ```
45
+
46
+ ### Structured opcional en `analyzeFile`
47
+
48
+ ```ts
49
+ import { analyzeFile } from "@dragon708/docmind-browser";
50
+ import { analyzeFileRequestsStructured } from "@dragon708/docmind-shared";
51
+
52
+ const result = await analyzeFile(file, {
53
+ structuredOutput: true,
54
+ });
55
+ if ("structured" in result && result.structured) {
56
+ console.log(result.structured.blocks.length);
57
+ }
58
+ ```
59
+
60
+ ### Documento estructurado
61
+
62
+ ```ts
63
+ import { extractStructuredData } from "@dragon708/docmind-browser";
64
+
65
+ const structured = await extractStructuredData({
66
+ data: await file.arrayBuffer(),
67
+ name: file.name,
68
+ mimeType: file.type,
69
+ });
70
+ ```
71
+
72
+ Para **PDF**, el resultado suele ser un envelope con advertencias de soporte (`BROWSER_PDF_STRUCTURED_UNSUPPORTED_WARNING`, etc.); no uses este paquete como sustituto de `@dragon708/docmind-node` para PDF.
73
+
74
+ ### OCR en imagen
75
+
76
+ ```ts
77
+ import { runOcr, analyzeFile } from "@dragon708/docmind-browser";
78
+
79
+ // runOcr respeta BrowserAnalyzeOptions.ocr.mode: off | auto | force
80
+ const ocrResult = await runOcr(file, { ocr: { mode: "auto" } });
81
+ ```
82
+
83
+ ### Markdown / LLM / chunks en navegador
84
+
85
+ ```ts
86
+ import {
87
+ extractMarkdown,
88
+ extractLlmContent,
89
+ extractStructuredChunks,
90
+ } from "@dragon708/docmind-browser";
91
+
92
+ // DOCX/imagen/texto: structured → Markdown (Turndown/serialización según ruta)
93
+ const md = await extractMarkdown(file, { /* BrowserExtractMarkdownOptions */ });
94
+ const llm = await extractLlmContent(file, { /* … */ });
95
+ const sections = await extractStructuredChunks(file, {
96
+ chunks: { includeMarkdown: true },
97
+ });
98
+ ```
99
+
100
+ ### Introspección
101
+
102
+ ```ts
103
+ import { getCapabilities, explainAnalysisPlan } from "@dragon708/docmind-browser";
104
+
105
+ const caps = await getCapabilities({ /* … */ });
106
+ const plan = await explainAnalysisPlan({ /* … */ });
107
+ ```
108
+
109
+ ### Clasificación
110
+
111
+ ```ts
112
+ import { detectFileKind } from "@dragon708/docmind-browser";
113
+ ```
114
+
115
+ ### Extractores por formato (sin PDF)
116
+
117
+ ```ts
118
+ import {
119
+ extractStructuredDataFromDocx,
120
+ extractStructuredDataFromImage,
121
+ } from "@dragon708/docmind-browser";
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Opciones (`BrowserAnalyzeOptions`)
127
+
128
+ Incluyen cortes alineados con Node donde aplica:
129
+
130
+ - **`ocr`**: `BrowserOcrOptions` con `mode` `off` | `auto` | `force`.
131
+ - **`docx`**: `include` (headings, tables, blocks, …) como en Node.
132
+ - **`structuredOutput` / `output`**: merge de `structured` en `analyzeFile`.
133
+
134
+ Para Markdown/LLM/chunks: **`BrowserExtractMarkdownOptions`**, **`BrowserExtractLlmContentOptions`**, **`BrowserExtractStructuredChunksOptions`**.
135
+
136
+ ---
137
+
138
+ ## Constantes útiles
139
+
140
+ - **`BROWSER_PDF_UNSUPPORTED_WARNING`**: texto de aviso cuando se intenta PDF en rutas que no lo implementan.
141
+ - **`BROWSER_PDF_STRUCTURED_UNSUPPORTED_WARNING`**: structured PDF no disponible en browser.
142
+
143
+ ---
144
+
145
+ ## Capacidades declarativas
146
+
147
+ - **`DOCX_EMBEDDED_IMAGE_CAPABILITIES_BROWSER`**, **`DOCX_STRUCTURE_CAPABILITIES_BROWSER`**, **`docxIncludeRequested`**: para informes tipo `getCapabilities`.
148
+
149
+ ---
150
+
151
+ ## Rendimiento y UX
152
+
153
+ - **Tesseract.js** descarga idiomas y WASM en el cliente; primer uso puede ser lento.
154
+ - **TIFF multipage**: soporte best-effort (UTIF) con limitaciones documentadas en warnings y `explainAnalysisPlan`.
155
+
156
+ ---
157
+
158
+ ## Paquetes relacionados
159
+
160
+ | Paquete | Rol |
161
+ |---------|-----|
162
+ | `@dragon708/docmind-node` | PDF, conversión binaria a Markdown en servidor |
163
+ | `@dragon708/docmind-shared` | Tipos compartidos |
164
+ | `@dragon708/docmind-markdown` | Lógica Markdown/LLM/chunks (en browser sin rutas binarias pesadas) |
165
+ | `@dragon708/docmind-docx` | DOCX |
166
+ | `@dragon708/docmind-ocr` | OCR raster |
167
+
168
+ ---
169
+
170
+ ## Seguridad
171
+
172
+ - No insertes HTML de `convertToHtml` sin sanitizar si el documento no es de confianza.
173
+ - Los modelos OCR y WASM se ejecutan en el cliente; valora privacidad y tamaño de descarga.
174
+
175
+ ---
176
+
177
+ ## Licencia
178
+
179
+ MIT (monorepo DocMind).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dragon708/docmind-browser",
3
- "version": "1.8.6",
3
+ "version": "1.9.0",
4
4
  "description": "Official DocMind browser facade: analyzeFile and intent APIs (DOCX, image OCR, text). PDF and fs paths use @dragon708/docmind-node.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,10 +33,10 @@
33
33
  ],
34
34
  "license": "MIT",
35
35
  "dependencies": {
36
- "@dragon708/docmind-docx": "^1.8.0",
37
- "@dragon708/docmind-markdown": "^1.2.9",
38
- "@dragon708/docmind-ocr": "^1.1.4",
39
- "@dragon708/docmind-shared": "^1.2.0"
36
+ "@dragon708/docmind-docx": "^1.9.0",
37
+ "@dragon708/docmind-markdown": "^1.3.0",
38
+ "@dragon708/docmind-ocr": "^1.2.0",
39
+ "@dragon708/docmind-shared": "^1.3.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^20.19.37",