@deepseek-ai/libreoffice-kit 0.1.2 → 0.1.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/README.md +16 -5
- package/README.zh.md +17 -6
- package/lib/cli.js +457 -251
- package/lib/font-snapshot-worker.js +37 -26
- package/lib/index.js +456 -250
- package/lib/types/engine.d.ts +1 -1
- package/lib/types/font-file-identity.d.ts +13 -0
- package/lib/types/fonts.d.ts +2 -2
- package/lib/types/native-process.d.ts +20 -0
- package/lib/types/native.d.ts +8 -0
- package/lib/worker.js +26 -12
- package/package.json +8 -7
package/lib/types/engine.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Node API release version returned by runtime discovery. */
|
|
2
|
-
export declare const ENGINE_VERSION = "0.1.
|
|
2
|
+
export declare const ENGINE_VERSION = "0.1.4";
|
|
3
3
|
/** Exact compatible engine versions; unchanged platforms retain their published packages. */
|
|
4
4
|
export declare const ENGINE_VERSIONS: Readonly<Record<string, string>>;
|
|
5
5
|
/** Host diagnostic fields used to identify the runtime glibc version. */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Exact filesystem identifiers with JSON-compatible font metadata. */
|
|
2
|
+
import type { BigIntStats } from 'node:fs';
|
|
3
|
+
/** Preserve 64-bit device and inode values without JavaScript integer rounding. */
|
|
4
|
+
export declare function fontFileIdentity(status: BigIntStats): {
|
|
5
|
+
dev: string;
|
|
6
|
+
ino: string;
|
|
7
|
+
size: number;
|
|
8
|
+
mtimeMs: number;
|
|
9
|
+
ctimeMs: number;
|
|
10
|
+
};
|
|
11
|
+
/** Compare a source descriptor's exact identity with its indexed font metadata. */
|
|
12
|
+
export declare function matchesFontFile(status: BigIntStats, expected: ReturnType<typeof fontFileIdentity>): boolean;
|
|
13
|
+
//# sourceMappingURL=font-file-identity.d.ts.map
|
package/lib/types/fonts.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export interface FontFace {
|
|
|
7
7
|
readonly size: number;
|
|
8
8
|
readonly mtimeMs: number;
|
|
9
9
|
readonly ctimeMs: number;
|
|
10
|
-
readonly dev:
|
|
11
|
-
readonly ino:
|
|
10
|
+
readonly dev: string;
|
|
11
|
+
readonly ino: string;
|
|
12
12
|
readonly faceIndex: number;
|
|
13
13
|
readonly family: string;
|
|
14
14
|
readonly style: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { Readable, Writable } from 'node:stream';
|
|
3
|
+
/** The helper owner observes closure only after both output pipes finish. */
|
|
4
|
+
export interface NativeChild extends EventEmitter {
|
|
5
|
+
stdin: Writable;
|
|
6
|
+
stdout: Readable;
|
|
7
|
+
stderr: Readable;
|
|
8
|
+
readonly exitCode: number | null;
|
|
9
|
+
readonly signalCode: NodeJS.Signals | null;
|
|
10
|
+
kill(signal: NodeJS.Signals): boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Spawn with inherited token and Job restrictions; pipe creation never requests a new sandbox policy.
|
|
14
|
+
* @param executable - Verified native helper executable.
|
|
15
|
+
* @param args - Helper protocol arguments.
|
|
16
|
+
* @param env - Filtered operation environment.
|
|
17
|
+
* @returns Helper streams and process lifetime, with output drained before close.
|
|
18
|
+
*/
|
|
19
|
+
export declare function spawnNative(executable: string, args: string[], env: NodeJS.ProcessEnv): NativeChild;
|
|
20
|
+
//# sourceMappingURL=native-process.d.ts.map
|
package/lib/types/native.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ export declare function prepareNativeFontProfile(profile: string, substitutions:
|
|
|
19
19
|
* @returns the environment the helper starts with.
|
|
20
20
|
*/
|
|
21
21
|
export declare function nativeEnvironment(profile: string, programDirectory: string, source?: NodeJS.ProcessEnv, platform?: string): Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Keep Windows engine resources reachable through a short profile-owned path until the helper exits.
|
|
24
|
+
* @param engine - Verified engine installation; its resources remain in place.
|
|
25
|
+
* @param profile - Private operation directory that owns the temporary executable and junction.
|
|
26
|
+
* @param run - Operation that settles only after its helper closes.
|
|
27
|
+
* @returns The operation result after removing the resource junction.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withNativeEngine<T>(engine: NativeEngine, profile: string, run: (engine: NativeEngine) => Promise<T>): Promise<T>;
|
|
22
30
|
/**
|
|
23
31
|
* Run one native conversion and await bounded result transport.
|
|
24
32
|
* @param engine - Resolved native engine installation.
|
package/lib/worker.js
CHANGED
|
@@ -43,6 +43,29 @@ function failureCode(error) {
|
|
|
43
43
|
return typeof code === "string" && CODES.has(code) ? code : "failed";
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
|
+
//#region lib/types/font-file-identity.js
|
|
47
|
+
/** Preserve 64-bit device and inode values without JavaScript integer rounding. */
|
|
48
|
+
function fontFileIdentity(status) {
|
|
49
|
+
return {
|
|
50
|
+
dev: status.dev.toString(),
|
|
51
|
+
ino: status.ino.toString(),
|
|
52
|
+
size: Number(status.size),
|
|
53
|
+
mtimeMs: Number(status.mtimeNs) / 1e6,
|
|
54
|
+
ctimeMs: Number(status.ctimeNs) / 1e6
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Compare a source descriptor's exact identity with its indexed font metadata. */
|
|
58
|
+
function matchesFontFile(status, expected) {
|
|
59
|
+
const current = fontFileIdentity(status);
|
|
60
|
+
return [
|
|
61
|
+
"dev",
|
|
62
|
+
"ino",
|
|
63
|
+
"size",
|
|
64
|
+
"mtimeMs",
|
|
65
|
+
"ctimeMs"
|
|
66
|
+
].every((key) => current[key] === expected[key]);
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
46
69
|
//#region lib/types/fonts.js
|
|
47
70
|
/** Host font metadata snapshots and conversion-local glyph matching over original files. */
|
|
48
71
|
const VCL_WEIGHTS = [
|
|
@@ -67,14 +90,6 @@ const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
|
67
90
|
"systemui",
|
|
68
91
|
"symbol"
|
|
69
92
|
]);
|
|
70
|
-
/** File identity read from the descriptor, before and after, to detect concurrent replacement. */
|
|
71
|
-
const STAT_KEYS = [
|
|
72
|
-
"dev",
|
|
73
|
-
"ino",
|
|
74
|
-
"size",
|
|
75
|
-
"mtimeMs",
|
|
76
|
-
"ctimeMs"
|
|
77
|
-
];
|
|
78
93
|
/**
|
|
79
94
|
* Case- and separator-insensitive family key used to compare names across sources.
|
|
80
95
|
* @param value - Family, style, or postscript name as recorded by a document or font.
|
|
@@ -218,16 +233,15 @@ var SystemFontCatalog = class {
|
|
|
218
233
|
function readFont(face) {
|
|
219
234
|
const fd = openSync(face.path, constants.O_RDONLY | constants.O_NONBLOCK | constants.O_NOFOLLOW);
|
|
220
235
|
try {
|
|
221
|
-
const before = fstatSync(fd);
|
|
222
|
-
if (!before.isFile() ||
|
|
236
|
+
const before = fstatSync(fd, { bigint: true });
|
|
237
|
+
if (!before.isFile() || !matchesFontFile(before, face)) throw new Error("An indexed font changed; recreate the converter.");
|
|
223
238
|
const bytes = Buffer.alloc(face.size);
|
|
224
239
|
for (let offset = 0; offset < bytes.length;) {
|
|
225
240
|
const count = readSync(fd, bytes, offset, bytes.length - offset, offset);
|
|
226
241
|
if (!count) throw new Error("An indexed font was truncated.");
|
|
227
242
|
offset += count;
|
|
228
243
|
}
|
|
229
|
-
|
|
230
|
-
if (STAT_KEYS.some((key) => after[key] !== face[key])) throw new Error("An indexed font changed while reading.");
|
|
244
|
+
if (!matchesFontFile(fstatSync(fd, { bigint: true }), face)) throw new Error("An indexed font changed while reading.");
|
|
231
245
|
return bytes;
|
|
232
246
|
} finally {
|
|
233
247
|
closeSync(fd);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/libreoffice-kit",
|
|
3
3
|
"description": "Convert, recalculate, and render Office documents with prebuilt LibreOffice",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -37,16 +37,17 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"fflate": "0.8.2",
|
|
39
39
|
"fontkit": "2.0.4",
|
|
40
|
+
"koffi": "3.1.1",
|
|
40
41
|
"saxes": "6.0.0"
|
|
41
42
|
},
|
|
42
43
|
"optionalDependencies": {
|
|
43
|
-
"@deepseek-ai/libreoffice-kit-darwin-arm64": "0.1.
|
|
44
|
-
"@deepseek-ai/libreoffice-kit-
|
|
45
|
-
"@deepseek-ai/libreoffice-kit-win32-
|
|
46
|
-
"@deepseek-ai/libreoffice-kit-
|
|
47
|
-
"@deepseek-ai/libreoffice-kit-win32-
|
|
44
|
+
"@deepseek-ai/libreoffice-kit-darwin-arm64": "0.1.4",
|
|
45
|
+
"@deepseek-ai/libreoffice-kit-wasm": "0.1.4",
|
|
46
|
+
"@deepseek-ai/libreoffice-kit-win32-x64": "0.1.4",
|
|
47
|
+
"@deepseek-ai/libreoffice-kit-darwin-x64": "0.1.4",
|
|
48
|
+
"@deepseek-ai/libreoffice-kit-win32-arm64": "0.1.4"
|
|
48
49
|
},
|
|
49
50
|
"bin": {
|
|
50
|
-
"
|
|
51
|
+
"dsoffice": "./lib/cli.js"
|
|
51
52
|
}
|
|
52
53
|
}
|