cowork-os 0.4.3 → 0.4.4

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/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.4] - 2026-02-26
11
+
12
+ ### Fixed
13
+ - **Windows ARM64 startup crash after native setup**: moved `pdf-parse` loading to runtime in `parsePdfBuffer` so Electron startup no longer crashes when `@napi-rs/canvas` bindings are unavailable (`DOMMatrix is not defined` on app boot).
14
+ - **PDF parser failure isolation**: PDF parsing backend load errors are now surfaced only when a PDF is actually parsed, allowing normal app startup and non-PDF workflows to proceed.
15
+
10
16
  ## [0.4.3] - 2026-02-26
11
17
 
12
18
  ### Fixed
@@ -1,18 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parsePdfBuffer = parsePdfBuffer;
4
- // eslint-disable-next-line @typescript-eslint/no-require-imports
5
- const pdfParseModule = require("pdf-parse");
6
- const legacyPdfParseFn = typeof pdfParseModule === "function"
7
- ? pdfParseModule
8
- : typeof pdfParseModule.default === "function"
9
- ? pdfParseModule.default
10
- : null;
11
- const pdfParseV2Ctor = typeof pdfParseModule === "object" ? pdfParseModule.PDFParse : undefined;
4
+ let cachedPdfParseRuntime = null;
5
+ let cachedPdfParseLoadError = null;
6
+ function getPdfParseRuntime() {
7
+ if (cachedPdfParseRuntime)
8
+ return cachedPdfParseRuntime;
9
+ if (cachedPdfParseLoadError)
10
+ throw cachedPdfParseLoadError;
11
+ try {
12
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
13
+ const pdfParseModule = require("pdf-parse");
14
+ const legacyPdfParseFn = typeof pdfParseModule === "function"
15
+ ? pdfParseModule
16
+ : typeof pdfParseModule.default === "function"
17
+ ? pdfParseModule.default
18
+ : null;
19
+ const pdfParseV2Ctor = typeof pdfParseModule === "object" ? pdfParseModule.PDFParse : undefined;
20
+ cachedPdfParseRuntime = { legacyPdfParseFn, pdfParseV2Ctor };
21
+ return cachedPdfParseRuntime;
22
+ }
23
+ catch (error) {
24
+ const message = error instanceof Error ? error.message : String(error);
25
+ cachedPdfParseLoadError = new Error("PDF parsing backend failed to load. " +
26
+ "This usually means native canvas bindings are unavailable on this platform. " +
27
+ `Original error: ${message}`);
28
+ throw cachedPdfParseLoadError;
29
+ }
30
+ }
12
31
  /**
13
32
  * Parse PDF buffers across pdf-parse v1 (function export) and v2 (PDFParse class).
14
33
  */
15
34
  async function parsePdfBuffer(dataBuffer) {
35
+ const { legacyPdfParseFn, pdfParseV2Ctor } = getPdfParseRuntime();
16
36
  if (legacyPdfParseFn) {
17
37
  return legacyPdfParseFn(dataBuffer);
18
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-os",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "CoWork OS - The most complete open-source AI assistant platform",
5
5
  "overrides": {
6
6
  "@whiskeysockets/baileys": {
@@ -31,23 +31,50 @@ type PdfParseModuleShape =
31
31
  PDFParse?: V2ParserCtor;
32
32
  };
33
33
 
34
- // eslint-disable-next-line @typescript-eslint/no-require-imports
35
- const pdfParseModule = require("pdf-parse") as PdfParseModuleShape;
34
+ type PdfParseRuntime = {
35
+ legacyPdfParseFn: LegacyPdfParseFn | null;
36
+ pdfParseV2Ctor?: V2ParserCtor;
37
+ };
38
+
39
+ let cachedPdfParseRuntime: PdfParseRuntime | null = null;
40
+ let cachedPdfParseLoadError: Error | null = null;
36
41
 
37
- const legacyPdfParseFn: LegacyPdfParseFn | null =
38
- typeof pdfParseModule === "function"
39
- ? pdfParseModule
40
- : typeof pdfParseModule.default === "function"
41
- ? pdfParseModule.default
42
- : null;
42
+ function getPdfParseRuntime(): PdfParseRuntime {
43
+ if (cachedPdfParseRuntime) return cachedPdfParseRuntime;
44
+ if (cachedPdfParseLoadError) throw cachedPdfParseLoadError;
43
45
 
44
- const pdfParseV2Ctor: V2ParserCtor | undefined =
45
- typeof pdfParseModule === "object" ? pdfParseModule.PDFParse : undefined;
46
+ try {
47
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
48
+ const pdfParseModule = require("pdf-parse") as PdfParseModuleShape;
49
+ const legacyPdfParseFn: LegacyPdfParseFn | null =
50
+ typeof pdfParseModule === "function"
51
+ ? pdfParseModule
52
+ : typeof pdfParseModule.default === "function"
53
+ ? pdfParseModule.default
54
+ : null;
55
+
56
+ const pdfParseV2Ctor: V2ParserCtor | undefined =
57
+ typeof pdfParseModule === "object" ? pdfParseModule.PDFParse : undefined;
58
+
59
+ cachedPdfParseRuntime = { legacyPdfParseFn, pdfParseV2Ctor };
60
+ return cachedPdfParseRuntime;
61
+ } catch (error: unknown) {
62
+ const message = error instanceof Error ? error.message : String(error);
63
+ cachedPdfParseLoadError = new Error(
64
+ "PDF parsing backend failed to load. " +
65
+ "This usually means native canvas bindings are unavailable on this platform. " +
66
+ `Original error: ${message}`,
67
+ );
68
+ throw cachedPdfParseLoadError;
69
+ }
70
+ }
46
71
 
47
72
  /**
48
73
  * Parse PDF buffers across pdf-parse v1 (function export) and v2 (PDFParse class).
49
74
  */
50
75
  export async function parsePdfBuffer(dataBuffer: Buffer): Promise<LegacyPdfParseResult> {
76
+ const { legacyPdfParseFn, pdfParseV2Ctor } = getPdfParseRuntime();
77
+
51
78
  if (legacyPdfParseFn) {
52
79
  return legacyPdfParseFn(dataBuffer);
53
80
  }