@editneo/pdf 0.1.1 → 0.1.2

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
@@ -10,7 +10,7 @@ All processing happens locally — no files are uploaded to any server.
10
10
  npm install @editneo/pdf @editneo/core
11
11
  ```
12
12
 
13
- This package depends on [pdfjs-dist](https://github.com/nicolo-ribaudo/pdfjs-dist) for PDF parsing.
13
+ This package depends on [pdfjs-dist](https://github.com/nicolo-ribaudo/pdfjs-dist) for PDF parsing. The pdf.js worker is auto-configured from CDN.
14
14
 
15
15
  ## Usage
16
16
 
@@ -29,7 +29,7 @@ Each returned block has a type inferred from the PDF content (paragraphs, headin
29
29
 
30
30
  ### With the React drop zone
31
31
 
32
- The `PDFDropZone` component from `@editneo/react` calls this function automatically when a user drops a PDF onto the editor. You only need this package directly if you want to handle PDF extraction yourself.
32
+ The `PDFDropZone` component from `@editneo/react` calls this function automatically when a user drops a PDF onto the editor:
33
33
 
34
34
  ```tsx
35
35
  import { PDFDropZone } from "@editneo/react";
@@ -37,36 +37,54 @@ import { PDFDropZone } from "@editneo/react";
37
37
  <PDFDropZone>{/* editor content */}</PDFDropZone>;
38
38
  ```
39
39
 
40
+ ### Error handling
41
+
42
+ The function provides clear error messages for common failures:
43
+
44
+ ```typescript
45
+ try {
46
+ const blocks = await extractBlocksFromPdf(buffer);
47
+ } catch (err) {
48
+ // Possible errors:
49
+ // "[EditNeo PDF] Cannot extract blocks: empty or missing PDF data"
50
+ // "[EditNeo PDF] This PDF is password-protected. Please provide an unlocked file."
51
+ // "[EditNeo PDF] Failed to load PDF: <reason>"
52
+ console.error(err.message);
53
+ }
54
+ ```
55
+
56
+ Per-page errors are caught individually — one corrupted page won't prevent the rest from extracting.
57
+
40
58
  ## How Extraction Works
41
59
 
42
60
  The extraction processes each page of the PDF in order and applies heuristics to convert raw PDF content into structured blocks.
43
61
 
44
62
  ### Text extraction
45
63
 
46
- PDF files don't have a concept of "paragraphs" or "headings" — they store positioned text fragments with font metadata. The extractor groups these fragments into blocks using two signals:
64
+ PDF files don't have a concept of "paragraphs" or "headings" — they store positioned text fragments with font metadata. The extractor groups these fragments into blocks using vertical position gaps (>5 PDF units between lines starts a new block).
47
65
 
48
- 1. **Vertical position:** When there's a significant vertical gap between consecutive text items (more than 5 PDF units), the extractor treats them as separate blocks.
66
+ ### Heading detection
49
67
 
50
- 2. **Font size:** The extractor calculates the most common font size on each page (the "mode"). Text items significantly larger than the mode are classified as headings:
51
- - Greater than 2x the mode font size: `heading-1`
52
- - Greater than 1.5x the mode font size: `heading-2`
53
- - Everything else: `paragraph`
68
+ Headings are classified using multiple signals:
54
69
 
55
- ### Image detection
70
+ - **Font size ratio** — text significantly larger than the page's most common font size
71
+ - \>1.8× → `heading-1`
72
+ - \>1.4× → `heading-2`
73
+ - \>1.15× (if bold or all-caps) → `heading-3`
74
+ - **Bold font name** — fonts with "Bold", "Heavy", or "Black" in the name
75
+ - **Line length** — headings are typically shorter than 120 characters
76
+ - **All-caps** — uppercase text at normal size with a bold font → `heading-3`
56
77
 
57
- The extractor scans each page's operator list for `PaintImageXObject` operations, which indicate rendered images. When found, an `image` block is added to the output.
78
+ ### Image extraction
58
79
 
59
- Note: Full image data extraction (decoding the pixel data from the PDF) requires additional processing of the operator list's argument arrays. The current implementation adds placeholder image blocks proper image extraction can be implemented by processing `page.getOperatorList()` results in more detail.
80
+ The extractor scans each page's operator list for `PaintImageXObject` operations. When found, the raw pixel data is read and converted to a PNG data URI via canvas. Small decorative images (<50×50px) are filtered out. In SSR environments where `document.createElement` isn't available, a placeholder is used instead.
60
81
 
61
82
  ### Limitations
62
83
 
63
- This is a heuristic-based extractor designed for common document layouts. Some things it does not handle perfectly:
64
-
65
84
  - **Multi-column layouts** — text from different columns may be merged or ordered incorrectly
66
85
  - **Tables** — table content is extracted as plain text, not as a structured table block
67
86
  - **Footnotes and headers/footers** — these are extracted as regular text blocks
68
87
  - **Scanned PDFs** — if the PDF contains only images (no text layer), the extractor produces only image blocks. OCR is not performed.
69
- - **Complex font detection** — bold and italic detection based on font name analysis is not yet implemented; all text is returned as plain spans
70
88
 
71
89
  ## API Reference
72
90
 
@@ -78,11 +96,14 @@ This is a heuristic-based extractor designed for common document layouts. Some t
78
96
 
79
97
  **Returns:** `Promise<NeoBlock[]>`
80
98
 
99
+ **Throws:** `Error` with descriptive message on failure (empty data, password-protected, corrupt file).
100
+
81
101
  An array of `NeoBlock` objects in reading order. Each block has:
82
102
 
83
103
  - A generated UUID as its `id`
84
- - A `type` inferred from the content (`paragraph`, `heading-1`, `heading-2`, or `image`)
104
+ - A `type` inferred from the content (`paragraph`, `heading-1`, `heading-2`, `heading-3`, or `image`)
85
105
  - A `content` array with a single `Span` containing the extracted text
106
+ - Image blocks include `props.src` (data URI), `props.width`, and `props.height`
86
107
  - `createdAt` and `updatedAt` timestamps set to the extraction time
87
108
 
88
109
  ### Example output
@@ -115,7 +136,7 @@ Given a PDF with a title, some body text, and an image, the function might retur
115
136
  id: "g7h8i9...",
116
137
  type: "image",
117
138
  content: [{ text: "" }],
118
- props: { src: "placeholder-image-url" },
139
+ props: { src: "data:image/png;base64,...", width: 640, height: 480 },
119
140
  children: [],
120
141
  parentId: null,
121
142
  createdAt: 1707840000000,
package/dist/worker.d.ts CHANGED
@@ -1,3 +1,10 @@
1
1
  import { NeoBlock } from '@editneo/core';
2
+ /**
3
+ * Extract structured NeoBlocks from a PDF file.
4
+ *
5
+ * @param data - An ArrayBuffer of the PDF file
6
+ * @returns An array of NeoBlock objects
7
+ * @throws Error with descriptive message on failure
8
+ */
2
9
  export declare function extractBlocksFromPdf(data: ArrayBuffer): Promise<NeoBlock[]>;
3
10
  //# sourceMappingURL=worker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAa,MAAM,eAAe,CAAC;AAOpD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAkEjF"}
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAa,MAAM,eAAe,CAAC;AA0KpD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CA8FjF"}
package/dist/worker.js CHANGED
@@ -1,67 +1,240 @@
1
1
  import * as pdfjs from 'pdfjs-dist';
2
2
  import { v4 as uuid } from 'uuid';
3
- // Configure worker - in a real app, this needs careful path handling or a bundler plugin
4
- // For now, we assume the worker is loaded by the main thread or handled by the build system
5
- // pdfjs.GlobalWorkerOptions.workerSrc = ...;
6
- export async function extractBlocksFromPdf(data) {
7
- const loadingTask = pdfjs.getDocument(data);
8
- const pdf = await loadingTask.promise;
9
- const blocks = [];
10
- for (let i = 1; i <= pdf.numPages; i++) {
11
- const page = await pdf.getPage(i);
12
- const textContent = await page.getTextContent();
13
- const opList = await page.getOperatorList();
14
- // Simplistic mode font size calculation for the page
15
- const fontSizes = {};
16
- for (const item of textContent.items) {
17
- if ('height' in item) {
18
- const height = Math.floor(item.height);
19
- fontSizes[height] = (fontSizes[height] || 0) + 1;
20
- }
3
+ /**
4
+ * Configure the pdf.js worker automatically.
5
+ * Uses the CDN-hosted worker matching the installed pdfjs-dist version.
6
+ * Falls back to disabling the worker if configuration fails.
7
+ */
8
+ function ensureWorkerConfigured() {
9
+ if (!pdfjs.GlobalWorkerOptions.workerSrc) {
10
+ try {
11
+ const version = pdfjs.version;
12
+ pdfjs.GlobalWorkerOptions.workerSrc =
13
+ `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${version}/pdf.worker.min.js`;
21
14
  }
22
- let modeFontSize = 12;
23
- let maxCount = 0;
24
- for (const size in fontSizes) {
25
- if (fontSizes[size] > maxCount) {
26
- maxCount = fontSizes[size];
27
- modeFontSize = Number(size);
15
+ catch {
16
+ // Fallback: disable worker (runs on main thread, slower but works)
17
+ pdfjs.disableWorker = true;
18
+ }
19
+ }
20
+ }
21
+ /**
22
+ * (#39) Improved heading detection using multiple heuristics:
23
+ * - Font size relative to the page mode
24
+ * - Short line length (headings are usually < 100 chars)
25
+ * - Bold font name patterns
26
+ * - All-caps detection
27
+ */
28
+ function classifyBlockType(item, text, modeFontSize, fontStyles) {
29
+ const ratio = item.height / modeFontSize;
30
+ const trimmed = text.trim();
31
+ const isShortLine = trimmed.length < 120;
32
+ const fontInfo = item.fontName ? fontStyles.get(item.fontName) : undefined;
33
+ const isBoldFont = (fontInfo === null || fontInfo === void 0 ? void 0 : fontInfo.bold) || false;
34
+ const isAllCaps = trimmed.length > 2 && trimmed === trimmed.toUpperCase() && /[A-Z]/.test(trimmed);
35
+ // Large font → heading
36
+ if (ratio > 1.8 && isShortLine)
37
+ return 'heading-1';
38
+ if (ratio > 1.4 && isShortLine)
39
+ return 'heading-2';
40
+ if (ratio > 1.15 && isShortLine && (isBoldFont || isAllCaps))
41
+ return 'heading-3';
42
+ // Bold short line at normal size → heading-3
43
+ if (isBoldFont && isShortLine && trimmed.length < 60)
44
+ return 'heading-3';
45
+ return 'paragraph';
46
+ }
47
+ /**
48
+ * Extract font style information from the page's common objects.
49
+ * Detects bold fonts by checking the font name for common bold patterns.
50
+ */
51
+ function extractFontStyles(page) {
52
+ var _a;
53
+ const styles = new Map();
54
+ try {
55
+ const commonObjs = page.commonObjs;
56
+ if (commonObjs && commonObjs._objs) {
57
+ for (const [key, entry] of Object.entries(commonObjs._objs)) {
58
+ if ((_a = entry === null || entry === void 0 ? void 0 : entry.data) === null || _a === void 0 ? void 0 : _a.name) {
59
+ const name = entry.data.name.toLowerCase();
60
+ styles.set(key, {
61
+ bold: name.includes('bold') || name.includes('heavy') || name.includes('black'),
62
+ });
63
+ }
28
64
  }
29
65
  }
30
- // Heuristic 1: Text extraction
31
- // This is a simplified extraction that doesn't handle layout perfectly but follows the plan
32
- let currentBlockText = '';
33
- let currentBlockType = 'paragraph';
34
- let lastY = -1;
35
- for (const item of textContent.items) {
36
- if (!('str' in item))
66
+ }
67
+ catch {
68
+ // Font extraction is best-effort
69
+ }
70
+ return styles;
71
+ }
72
+ // ── Image extraction (#37) ────────────────────────────────────────────
73
+ /**
74
+ * (#37) Extract images from a PDF page's operator list.
75
+ * Converts image data to a data URI when possible.
76
+ */
77
+ async function extractImages(page, opList) {
78
+ var _a;
79
+ const blocks = [];
80
+ const seenImages = new Set();
81
+ for (let i = 0; i < opList.fnArray.length; i++) {
82
+ if (opList.fnArray[i] === pdfjs.OPS.paintImageXObject) {
83
+ const imgName = (_a = opList.argsArray[i]) === null || _a === void 0 ? void 0 : _a[0];
84
+ if (!imgName || seenImages.has(imgName))
37
85
  continue;
38
- // Simple line grouping test
39
- if (lastY !== -1 && Math.abs(item.transform[5] - lastY) > 5) {
40
- if (currentBlockText.trim()) {
41
- blocks.push(createBlock(currentBlockType, currentBlockText));
86
+ seenImages.add(imgName);
87
+ try {
88
+ const imgData = await new Promise((resolve, reject) => {
89
+ page.objs.get(imgName, (data) => {
90
+ if (data)
91
+ resolve(data);
92
+ else
93
+ reject(new Error('No image data'));
94
+ });
95
+ });
96
+ if (imgData && imgData.data && imgData.width && imgData.height) {
97
+ // Convert raw pixel data to a data URI via canvas
98
+ const canvas = typeof document !== 'undefined' ? document.createElement('canvas') : null;
99
+ if (canvas) {
100
+ canvas.width = imgData.width;
101
+ canvas.height = imgData.height;
102
+ const ctx = canvas.getContext('2d');
103
+ if (ctx) {
104
+ const imageData = ctx.createImageData(imgData.width, imgData.height);
105
+ // pdfjs image data can be RGB (3 bytes) or RGBA (4 bytes) per pixel
106
+ const src = imgData.data;
107
+ const dst = imageData.data;
108
+ const bytesPerPixel = src.length / (imgData.width * imgData.height);
109
+ if (bytesPerPixel === 4) {
110
+ dst.set(src);
111
+ }
112
+ else if (bytesPerPixel === 3) {
113
+ for (let j = 0, k = 0; j < dst.length; j += 4, k += 3) {
114
+ dst[j] = src[k];
115
+ dst[j + 1] = src[k + 1];
116
+ dst[j + 2] = src[k + 2];
117
+ dst[j + 3] = 255;
118
+ }
119
+ }
120
+ else {
121
+ // Grayscale or unsupported — skip
122
+ continue;
123
+ }
124
+ ctx.putImageData(imageData, 0, 0);
125
+ const dataUrl = canvas.toDataURL('image/png');
126
+ // Only include images of meaningful size (skip tiny decorative images)
127
+ if (imgData.width > 50 && imgData.height > 50) {
128
+ blocks.push(createBlock('image', '', {
129
+ src: dataUrl,
130
+ width: imgData.width,
131
+ height: imgData.height,
132
+ }));
133
+ }
134
+ }
135
+ }
136
+ else {
137
+ // No DOM (SSR) — insert placeholder
138
+ blocks.push(createBlock('image', '', {
139
+ src: 'placeholder-image-url',
140
+ width: imgData.width,
141
+ height: imgData.height,
142
+ }));
143
+ }
42
144
  }
43
- currentBlockText = '';
44
- // Reset type based on new line height
45
- if (item.height > modeFontSize * 2)
46
- currentBlockType = 'heading-1';
47
- else if (item.height > modeFontSize * 1.5)
48
- currentBlockType = 'heading-2';
49
- else
50
- currentBlockType = 'paragraph';
51
145
  }
52
- currentBlockText += item.str + ' ';
53
- lastY = item.transform[5];
146
+ catch {
147
+ // Image extraction failed for this image — skip
148
+ }
149
+ }
150
+ }
151
+ return blocks;
152
+ }
153
+ // ── Main extraction ───────────────────────────────────────────────────
154
+ /**
155
+ * Extract structured NeoBlocks from a PDF file.
156
+ *
157
+ * @param data - An ArrayBuffer of the PDF file
158
+ * @returns An array of NeoBlock objects
159
+ * @throws Error with descriptive message on failure
160
+ */
161
+ export async function extractBlocksFromPdf(data) {
162
+ var _a;
163
+ if (!data || data.byteLength === 0) {
164
+ throw new Error('[EditNeo PDF] Cannot extract blocks: empty or missing PDF data');
165
+ }
166
+ ensureWorkerConfigured();
167
+ let pdf;
168
+ try {
169
+ const loadingTask = pdfjs.getDocument(data);
170
+ pdf = await loadingTask.promise;
171
+ }
172
+ catch (err) {
173
+ if ((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes('password')) {
174
+ throw new Error('[EditNeo PDF] This PDF is password-protected. Please provide an unlocked file.');
54
175
  }
55
- if (currentBlockText.trim()) {
56
- blocks.push(createBlock(currentBlockType, currentBlockText));
176
+ throw new Error(`[EditNeo PDF] Failed to load PDF: ${(err === null || err === void 0 ? void 0 : err.message) || 'Unknown error'}`);
177
+ }
178
+ const blocks = [];
179
+ for (let i = 1; i <= pdf.numPages; i++) {
180
+ try {
181
+ const page = await pdf.getPage(i);
182
+ const textContent = await page.getTextContent();
183
+ const opList = await page.getOperatorList();
184
+ // (#39) Extract font style info for heading heuristics
185
+ const fontStyles = extractFontStyles(page);
186
+ // Mode font-size calculation
187
+ const fontSizes = {};
188
+ for (const item of textContent.items) {
189
+ if ('height' in item) {
190
+ const height = Math.floor(item.height);
191
+ fontSizes[height] = (fontSizes[height] || 0) + 1;
192
+ }
193
+ }
194
+ let modeFontSize = 12;
195
+ let maxCount = 0;
196
+ for (const size in fontSizes) {
197
+ if (fontSizes[size] > maxCount) {
198
+ maxCount = fontSizes[size];
199
+ modeFontSize = Number(size);
200
+ }
201
+ }
202
+ // Text extraction with improved line grouping
203
+ let currentBlockText = '';
204
+ let currentBlockType = 'paragraph';
205
+ let currentItem = null;
206
+ let lastY = -1;
207
+ for (const item of textContent.items) {
208
+ if (!('str' in item))
209
+ continue;
210
+ if (lastY !== -1 && Math.abs(item.transform[5] - lastY) > 5) {
211
+ if (currentBlockText.trim()) {
212
+ blocks.push(createBlock(currentBlockType, currentBlockText));
213
+ }
214
+ currentBlockText = '';
215
+ // (#39) Use improved heading heuristics
216
+ currentBlockType = classifyBlockType(item, item.str, modeFontSize, fontStyles);
217
+ currentItem = item;
218
+ }
219
+ currentBlockText += item.str + ' ';
220
+ lastY = item.transform[5];
221
+ if (!currentItem)
222
+ currentItem = item;
223
+ }
224
+ if (currentBlockText.trim()) {
225
+ blocks.push(createBlock(currentBlockType, currentBlockText));
226
+ }
227
+ // (#37) Extract actual images
228
+ const imageBlocks = await extractImages(page, opList);
229
+ blocks.push(...imageBlocks);
57
230
  }
58
- // Heuristic 2: Images (Simplistic mock logic as real extraction form opList is complex)
59
- // Real implementation requires processing opList.fnArray and argsArray for PaintImageXObject
60
- // For this task, we will just add a placeholder if we detect image ops
61
- if (opList.fnArray.includes(pdfjs.OPS.paintImageXObject)) {
62
- blocks.push(createBlock('image', '', { src: 'placeholder-image-url' }));
231
+ catch (pageErr) {
232
+ console.warn(`[EditNeo PDF] Failed to extract page ${i}: ${pageErr === null || pageErr === void 0 ? void 0 : pageErr.message}`);
63
233
  }
64
234
  }
235
+ if (blocks.length === 0) {
236
+ console.warn('[EditNeo PDF] No content extracted from PDF');
237
+ }
65
238
  return blocks;
66
239
  }
67
240
  function createBlock(type, text, props = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,yFAAyF;AACzF,4FAA4F;AAC5F,8CAA8C;AAE9C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAiB;IAC1D,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC;IACtC,MAAM,MAAM,GAAe,EAAE,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,IAAI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,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC;YAC/D,CAAC;YAED,8BAA8B;YAC9B,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;QAE9B,CAAC;QAAC,OAAO,OAAY,EAAE,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,KAAK,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,IAAe,EAAE,IAAY,EAAE,QAA6B,EAAE;IACjF,OAAO;QACL,EAAE,EAAE,IAAI,EAAE;QACV,IAAI;QACJ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,KAAK;QACL,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@editneo/pdf",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "PDF transmutation engine for EditNeo — converts PDFs into editable blocks",
5
+ "type": "module",
5
6
  "main": "./dist/worker.js",
6
7
  "types": "./dist/worker.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/worker.d.ts",
11
+ "import": "./dist/worker.js",
12
+ "default": "./dist/worker.js"
13
+ }
14
+ },
7
15
  "files": ["dist"],
8
16
  "scripts": {
9
17
  "build": "tsc",