@deepseek-ai/libreoffice-kit 0.2.0-alpha7 → 0.2.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/NOTICE +1 -1
- package/README.md +7 -7
- package/README.zh.md +7 -7
- package/frame-forwarding/CMakeLists.txt +3 -4
- package/frame-forwarding/README.md +18 -18
- package/frame-forwarding/README.zh.md +19 -19
- package/frame-forwarding/include/dsh_frame_forwarding.h +33 -9
- package/frame-forwarding/index.d.ts +58 -54
- package/frame-forwarding/index.mjs +14 -17
- package/frame-forwarding/prebuilds/darwin-arm64/frame-forwarding.node +0 -0
- package/frame-forwarding/prebuilds/darwin-arm64/libdsh_frame_forwarding_sdk.a +0 -0
- package/frame-forwarding/prebuilds/darwin-arm64/manifest.json +22 -21
- package/frame-forwarding/prebuilds/darwin-x64/frame-forwarding.node +0 -0
- package/frame-forwarding/prebuilds/darwin-x64/libdsh_frame_forwarding_sdk.a +0 -0
- package/frame-forwarding/prebuilds/darwin-x64/manifest.json +22 -21
- package/frame-forwarding/prebuilds/win32-arm64/dsh_frame_forwarding_sdk.lib +0 -0
- package/frame-forwarding/prebuilds/win32-arm64/frame-forwarding.node +0 -0
- package/frame-forwarding/prebuilds/win32-arm64/manifest.json +22 -21
- package/frame-forwarding/prebuilds/win32-x64/dsh_frame_forwarding_sdk.lib +0 -0
- package/frame-forwarding/prebuilds/win32-x64/frame-forwarding.node +0 -0
- package/frame-forwarding/prebuilds/win32-x64/manifest.json +22 -21
- package/frame-forwarding/receipt.json +15 -14
- package/frame-forwarding/scripts/build-webgpu.mjs +1 -0
- package/frame-forwarding/scripts/build.mjs +5 -4
- package/frame-forwarding/scripts/metadata.mjs +11 -8
- package/frame-forwarding/scripts/source-identity.mjs +3 -3
- package/frame-forwarding/sdk.json +6 -5
- package/frame-forwarding/{include/dsh_webgpu.h → src/graphite-interop-internal.hxx} +22 -22
- package/frame-forwarding/src/{webgpu.cc → graphite-interop.cc} +34 -24
- package/frame-forwarding/src/node-producer.cc +24 -154
- package/frame-forwarding/src/producer.cc +93 -26
- package/frame-forwarding/src/receiver.cc +416 -212
- package/frame-forwarding/src/relay-transport.inc +38 -10
- package/frame-forwarding/src/transport.cc +307 -141
- package/frame-forwarding/src/transport.h +60 -9
- package/frame-forwarding/verify.d.mts +1 -1
- package/frame-forwarding/verify.mjs +19 -17
- package/lib/cli.js +79 -8
- package/lib/editor.js +16 -11
- package/lib/index.js +79 -8
- package/lib/types/editor.d.ts +17 -4
- package/lib/types/engine.d.ts +1 -1
- package/lib/types/fonts.d.ts +1 -1
- package/lib/types/index.d.ts +4 -2
- package/lib/types/pdf.d.ts +10 -0
- package/lib/worker.js +4 -3
- package/package.json +8 -10
- package/frame-forwarding/include/dsh_frame_forwarding_engine.h +0 -66
- package/frame-forwarding/include/dsh_frame_forwarding_node.h +0 -27
|
@@ -13,43 +13,92 @@ constexpr uint32_t magic = 0x44535231;
|
|
|
13
13
|
enum Kind : uint32_t { hello = 1, ready, frame, release, message, goodbye, allocate, allocated, deallocate };
|
|
14
14
|
/** hello.max_frames carries optional capabilities; zero is the legacy producer. */
|
|
15
15
|
constexpr uint32_t hello_keyed_mutex = 1;
|
|
16
|
+
/**
|
|
17
|
+
* The producer holds a transferable TX credential and requires the connection identifier in ready.token. Receivers
|
|
18
|
+
* refuse producers without it, so a producer that relied on PID binding never connects.
|
|
19
|
+
*/
|
|
20
|
+
constexpr uint32_t hello_transferable = 2;
|
|
21
|
+
/**
|
|
22
|
+
* frame.max_frames carries per-frame flags; zero is an ordered frame. A replaceable frame may be dropped before
|
|
23
|
+
* presentation once a newer replaceable frame of the same view is ready; receivers that ignore the flag present it.
|
|
24
|
+
*/
|
|
25
|
+
constexpr uint32_t frame_replaceable = 1;
|
|
26
|
+
/** goodbye.text of a candidate the receiver refuses before it receives a connection identifier. */
|
|
27
|
+
constexpr const char* reject_busy = "channel-busy";
|
|
28
|
+
constexpr const char* reject_capability = "transferable-tx-required";
|
|
29
|
+
constexpr const char* reject_credential = "invalid-credential";
|
|
30
|
+
constexpr const char* reject_closed = "channel-closed";
|
|
31
|
+
/** Prefix of a refusal that names the producer's and the receiver's protocol versions. */
|
|
32
|
+
constexpr const char* reject_protocol = "protocol-mismatch";
|
|
16
33
|
struct Packet {
|
|
17
34
|
uint32_t marker = magic, version = DSH_FRAME_FORWARDING_PROTOCOL_VERSION, kind = 0;
|
|
18
35
|
uint32_t width = 0, height = 0, stride = 0, max_frames = 0;
|
|
19
36
|
uint64_t frame_id = 0, allocation_id = 0, max_bytes = 0, resource = 0;
|
|
37
|
+
/** hello: the TX secret. After the handshake: the decimal connection identifier. */
|
|
20
38
|
char token[65] = {};
|
|
21
39
|
char text[DSH_FRAME_FORWARDING_TEXT_CAPACITY] = {};
|
|
22
40
|
};
|
|
23
41
|
struct Received { Packet packet; uint32_t pid = 0; uintptr_t resource = 0; };
|
|
24
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* One physical producer connection. receive returns 1 data, 0 timeout, -1 closed/error. After bind_connection, every
|
|
44
|
+
* sent packet carries the connection identifier and a received packet without it closes the channel.
|
|
45
|
+
*/
|
|
25
46
|
class Channel {
|
|
26
47
|
public:
|
|
27
48
|
virtual ~Channel() = default;
|
|
28
|
-
|
|
29
|
-
|
|
49
|
+
int receive(Received& out, uint32_t timeout_ms);
|
|
50
|
+
bool send(const Packet& packet, uintptr_t resource = 0);
|
|
51
|
+
void bind_connection(uint64_t id);
|
|
52
|
+
uint64_t connection() const { return connection_; }
|
|
53
|
+
/** The last receive closed because a packet named another connection. */
|
|
54
|
+
bool foreign_packet() const { return foreign_; }
|
|
30
55
|
virtual void interrupt() = 0;
|
|
31
56
|
virtual uint32_t peer_pid() const = 0;
|
|
57
|
+
protected:
|
|
58
|
+
virtual int receive_packet(Received&, uint32_t timeout_ms) = 0;
|
|
59
|
+
virtual bool send_packet(const Packet&, uintptr_t resource) = 0;
|
|
60
|
+
private:
|
|
61
|
+
uint64_t connection_ = 0;
|
|
62
|
+
char connection_text_[65] = {};
|
|
63
|
+
bool foreign_ = false;
|
|
64
|
+
};
|
|
65
|
+
/** A producer whose hello reached the listener; its channel answers it before acceptance or refusal. */
|
|
66
|
+
struct Candidate { Received hello; std::unique_ptr<Channel> channel; };
|
|
67
|
+
/** The stable endpoint of one logical channel. Each producer connection gets a channel of its own. */
|
|
68
|
+
class Listener {
|
|
69
|
+
public:
|
|
70
|
+
virtual ~Listener() = default;
|
|
71
|
+
/** 1 candidate, 0 timeout, -1 stopped or failed. Malformed or silent connections are dropped without affecting others. */
|
|
72
|
+
virtual int accept(Candidate& candidate, uint32_t timeout_ms) = 0;
|
|
73
|
+
virtual void interrupt() = 0;
|
|
32
74
|
};
|
|
33
75
|
struct Endpoint { uint32_t pid; std::string token, name; };
|
|
34
76
|
Endpoint parse_endpoint(const std::string& value);
|
|
35
|
-
|
|
77
|
+
/** Publish the endpoint name. handshake_ms bounds how long a connected client may withhold its hello. */
|
|
78
|
+
std::unique_ptr<Listener> listen(Endpoint& endpoint, uint32_t handshake_ms);
|
|
36
79
|
std::unique_ptr<Channel> connect_channel(const Endpoint& endpoint, const std::function<bool()>& cancelled = {});
|
|
80
|
+
/** Parse a decimal connection identifier from a token; 0 when it is not one. */
|
|
81
|
+
uint64_t parse_connection(const char (&token)[65]);
|
|
37
82
|
uint32_t process_id();
|
|
38
83
|
uintptr_t receive_resource(Received& received);
|
|
39
84
|
void release_resource(uintptr_t resource);
|
|
40
85
|
void clear_validation_device();
|
|
41
86
|
uint64_t resource_bytes(uintptr_t resource);
|
|
42
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Validate a producer frame's format and dimensions and report its adapter. On Windows a keyed-mutex texture is also
|
|
89
|
+
* made ready: key 0 is acquired within the deadline and released, before Chromium's unbounded key-0 acquisition.
|
|
90
|
+
*/
|
|
91
|
+
bool resource_dimensions(uintptr_t resource, uint32_t width, uint32_t height, uint32_t stride,
|
|
92
|
+
std::chrono::steady_clock::time_point deadline, std::string& diagnostic, std::string& adapter, bool* keyed_mutex = nullptr);
|
|
43
93
|
/** Adapter owning a shared resource, or an empty string when it cannot be identified. */
|
|
44
94
|
std::string resource_adapter(uintptr_t resource);
|
|
45
95
|
/** Adapter owning the producer's graphics device. */
|
|
46
96
|
std::string device_adapter(void* device);
|
|
47
97
|
#if defined(_WIN32)
|
|
48
|
-
/** Bounded source readiness check before Chromium's unbounded key-0 acquisition. */
|
|
49
|
-
bool resource_ready(uintptr_t resource, std::chrono::steady_clock::time_point deadline, std::string& diagnostic);
|
|
50
98
|
struct RelayDevice;
|
|
51
99
|
struct RelayTexture;
|
|
52
100
|
struct RelayReadback;
|
|
101
|
+
struct RelaySource;
|
|
53
102
|
uintptr_t relay_handle(const std::shared_ptr<RelayTexture>& texture);
|
|
54
103
|
bool relay_begin(uintptr_t resource, uint32_t width, uint32_t height,
|
|
55
104
|
const std::string& adapter, std::chrono::steady_clock::time_point deadline, const std::atomic<bool>& stopped,
|
|
@@ -59,8 +108,10 @@ int relay_advance(const std::shared_ptr<RelayTexture>& slot, const std::atomic<b
|
|
|
59
108
|
uintptr_t relay_completion_event(const std::shared_ptr<RelayTexture>& slot);
|
|
60
109
|
/** True only after every submitted copy completes or its device is removed. */
|
|
61
110
|
bool relay_gpu_idle(const std::shared_ptr<RelayTexture>& slot, std::string& diagnostic);
|
|
62
|
-
|
|
63
|
-
|
|
111
|
+
/** Validate each frame and copy under key 0; reuse the allocation's import only for the same NT object and dimensions. */
|
|
112
|
+
bool relay_readback_begin(uintptr_t resource, uint32_t width, uint32_t height, uint32_t stride,
|
|
113
|
+
std::shared_ptr<RelayReadback>& slot, std::shared_ptr<RelaySource>& imported,
|
|
114
|
+
std::string& diagnostic, std::string& adapter, bool* keyed_mutex,
|
|
64
115
|
std::chrono::steady_clock::time_point deadline);
|
|
65
116
|
int relay_readback_ready(const std::shared_ptr<RelayReadback>& slot, bool retiring, std::string& diagnostic);
|
|
66
117
|
uintptr_t relay_readback_event(const std::shared_ptr<RelayReadback>& slot);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Validate one complete target's addon, static library, sources, hashes, and architecture. */
|
|
2
2
|
export declare function verifyFrameForwardingPackage(directory: string, target: { platform: string; arch: string }): Promise<void>;
|
|
3
3
|
/** Validate all four payloads against one Kit version and source commit. */
|
|
4
|
-
export declare function verifyFrameForwardingPrebuilds(directory: string, expected?: { version?: string; sourceCommit?: string }): Promise<{ version: string; protocolVersion: number; sourceCommit: string }>;
|
|
4
|
+
export declare function verifyFrameForwardingPrebuilds(directory: string, expected?: { version?: string; sourceCommit?: string }): Promise<{ version: string; protocolVersion: number; capabilities: string[]; sourceCommit: string }>;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import { buildSources, targets } from './scripts/metadata.mjs';
|
|
5
|
+
import { buildSources, capabilities, targets } from './scripts/metadata.mjs';
|
|
6
6
|
|
|
7
7
|
const digest = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
8
|
+
const sameCapabilities = value => JSON.stringify(value) === JSON.stringify(capabilities);
|
|
8
9
|
function verifyObject(bytes, target, subject, archive = false) {
|
|
9
10
|
if (target.platform === 'win32') {
|
|
10
11
|
let machine;
|
|
@@ -49,53 +50,54 @@ function verifyArchive(bytes, target, subject) {
|
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* Check one target's addon, static SDK, and source files against its build receipt.
|
|
52
|
-
* @param {string} directory
|
|
53
|
+
* @param {string} directory Frame-forwarding SDK directory.
|
|
53
54
|
* @param {{platform:string,arch:string}} target Operating system and CPU architecture.
|
|
54
55
|
* @returns {Promise<void>} Resolves only for a complete matching SDK target.
|
|
55
56
|
*/
|
|
56
57
|
export async function verifyFrameForwardingPackage(directory, target) {
|
|
57
58
|
const name = `${target.platform}-${target.arch}`;
|
|
58
|
-
if (!targets.includes(name)) throw new Error(`
|
|
59
|
+
if (!targets.includes(name)) throw new Error(`Frame forwarding has no packaged backend for ${name}`);
|
|
59
60
|
const root = join(directory, 'prebuilds', name);
|
|
60
61
|
const manifest = JSON.parse(await readFile(join(root, 'manifest.json'), 'utf8'));
|
|
61
62
|
const sdk = JSON.parse(await readFile(join(directory, 'sdk.json'), 'utf8'));
|
|
62
63
|
if (typeof sdk.version !== 'string' || !sdk.version || sdk.protocolVersion !== 1
|
|
64
|
+
|| !sameCapabilities(sdk.capabilities) || !sameCapabilities(manifest.capabilities)
|
|
63
65
|
|| JSON.stringify(sdk.platforms) !== JSON.stringify(targets)
|
|
64
66
|
|| JSON.stringify(sdk.buildSources) !== JSON.stringify(buildSources)
|
|
65
67
|
|| manifest.platform !== name || manifest.protocolVersion !== sdk.protocolVersion || manifest.version !== sdk.version
|
|
66
|
-
|| !/^[a-f0-9]{40}$/.test(manifest.sourceCommit) || typeof manifest.sourceDirty !== 'boolean') throw new Error(`
|
|
68
|
+
|| !/^[a-f0-9]{40}$/.test(manifest.sourceCommit) || typeof manifest.sourceDirty !== 'boolean') throw new Error(`Frame-forwarding build receipt does not match ${name}`);
|
|
67
69
|
const library = target.platform === 'win32' ? 'dsh_frame_forwarding_sdk.lib' : 'libdsh_frame_forwarding_sdk.a';
|
|
68
|
-
if (sdk.staticLibraries?.[name] !== `prebuilds/${name}/${library}`) throw new Error(`
|
|
69
|
-
if (Object.keys(manifest.files ?? {}).sort().join(',') !== [library, 'frame-forwarding.node'].sort().join(',')) throw new Error(`
|
|
70
|
+
if (sdk.staticLibraries?.[name] !== `prebuilds/${name}/${library}`) throw new Error(`Frame-forwarding library metadata differs: ${name}`);
|
|
71
|
+
if (Object.keys(manifest.files ?? {}).sort().join(',') !== [library, 'frame-forwarding.node'].sort().join(',')) throw new Error(`Frame-forwarding artifact inventory differs: ${name}`);
|
|
70
72
|
for (const filename of ['frame-forwarding.node', library]) {
|
|
71
73
|
const bytes = await readFile(join(root, filename));
|
|
72
|
-
if (digest(bytes) !== manifest.files[filename]) throw new Error(`
|
|
73
|
-
if (filename === 'frame-forwarding.node') verifyObject(bytes, target, '
|
|
74
|
-
else verifyArchive(bytes, target, '
|
|
74
|
+
if (digest(bytes) !== manifest.files[filename]) throw new Error(`Frame-forwarding artifact hash mismatch: ${name}/${filename}`);
|
|
75
|
+
if (filename === 'frame-forwarding.node') verifyObject(bytes, target, 'Frame-forwarding addon');
|
|
76
|
+
else verifyArchive(bytes, target, 'Frame-forwarding producer SDK');
|
|
75
77
|
}
|
|
76
|
-
if (Object.keys(manifest.sources ?? {}).sort().join(',') !== [...buildSources].sort().join(',')) throw new Error(`
|
|
78
|
+
if (Object.keys(manifest.sources ?? {}).sort().join(',') !== [...buildSources].sort().join(',')) throw new Error(`Frame-forwarding source inventory differs: ${name}`);
|
|
77
79
|
for (const source of buildSources) {
|
|
78
|
-
if (digest(await readFile(join(directory, source))) !== manifest.sources[source]) throw new Error(`
|
|
80
|
+
if (digest(await readFile(join(directory, source))) !== manifest.sources[source]) throw new Error(`Frame-forwarding source receipt differs: ${name}/${source}`);
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* Require all four payloads to share the expected package version and source commit.
|
|
84
|
-
* @param {string} directory
|
|
86
|
+
* @param {string} directory Frame-forwarding SDK directory.
|
|
85
87
|
* @param {{version?:string,sourceCommit?:string}} expected Release identity, when known by the caller.
|
|
86
|
-
* @returns {Promise<{version:string,protocolVersion:number,sourceCommit:string}>} Shared build identity.
|
|
88
|
+
* @returns {Promise<{version:string,protocolVersion:number,capabilities:string[],sourceCommit:string}>} Shared build identity.
|
|
87
89
|
*/
|
|
88
90
|
export async function verifyFrameForwardingPrebuilds(directory, expected = {}) {
|
|
89
91
|
const sdk = JSON.parse(await readFile(join(directory, 'sdk.json'), 'utf8'));
|
|
90
|
-
if (expected.version !== undefined && sdk.version !== expected.version) throw new Error('
|
|
92
|
+
if (expected.version !== undefined && sdk.version !== expected.version) throw new Error('Frame-forwarding version differs from the Kit package');
|
|
91
93
|
let sourceCommit = expected.sourceCommit;
|
|
92
94
|
for (const name of targets) {
|
|
93
95
|
const [platform, arch] = name.split('-');
|
|
94
96
|
await verifyFrameForwardingPackage(directory, { platform, arch });
|
|
95
97
|
const manifest = JSON.parse(await readFile(join(directory, 'prebuilds', name, 'manifest.json'), 'utf8'));
|
|
96
|
-
if (manifest.sourceDirty) throw new Error(`
|
|
98
|
+
if (manifest.sourceDirty) throw new Error(`Frame-forwarding artifact was built from dirty SDK sources: ${name}`);
|
|
97
99
|
sourceCommit ??= manifest.sourceCommit;
|
|
98
|
-
if (sourceCommit !== manifest.sourceCommit) throw new Error(`
|
|
100
|
+
if (sourceCommit !== manifest.sourceCommit) throw new Error(`Frame-forwarding source commit differs: ${name}`);
|
|
99
101
|
}
|
|
100
|
-
return { version: sdk.version, protocolVersion: sdk.protocolVersion, sourceCommit };
|
|
102
|
+
return { version: sdk.version, protocolVersion: sdk.protocolVersion, capabilities: sdk.capabilities, sourceCommit };
|
|
101
103
|
}
|
package/lib/cli.js
CHANGED
|
@@ -779,7 +779,7 @@ async function prepareNativeEngine(engine, profile) {
|
|
|
779
779
|
const root = join(profile, "engine");
|
|
780
780
|
await symlink(engine.root, root, "junction");
|
|
781
781
|
try {
|
|
782
|
-
const executable = join(profile, "
|
|
782
|
+
const executable = join(profile, "dsoffice.exe");
|
|
783
783
|
await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
|
|
784
784
|
return {
|
|
785
785
|
engine: {
|
|
@@ -1537,16 +1537,16 @@ function resolveOptions(input = {}) {
|
|
|
1537
1537
|
/** Resolve installed, version-matched engine packages without downloads or compilation. */
|
|
1538
1538
|
const require = createRequire(import.meta.url);
|
|
1539
1539
|
/** Node API release version returned by runtime discovery. */
|
|
1540
|
-
const ENGINE_VERSION = "0.2.
|
|
1540
|
+
const ENGINE_VERSION = "0.2.2";
|
|
1541
1541
|
/** Exact compatible engine versions; unchanged platforms retain their published packages. */
|
|
1542
1542
|
const ENGINE_VERSIONS = Object.freeze({
|
|
1543
|
-
"darwin-arm64": "0.2.
|
|
1544
|
-
"darwin-x64": "0.2.
|
|
1543
|
+
"darwin-arm64": "0.2.2",
|
|
1544
|
+
"darwin-x64": "0.2.2",
|
|
1545
1545
|
"linux-arm64-glibc": "0.1.1",
|
|
1546
1546
|
"linux-x64-glibc": "0.1.1",
|
|
1547
|
-
"win32-arm64": "0.
|
|
1548
|
-
"win32-x64": "0.2.
|
|
1549
|
-
wasm: "0.2.
|
|
1547
|
+
"win32-arm64": "0.2.2",
|
|
1548
|
+
"win32-x64": "0.2.2",
|
|
1549
|
+
wasm: "0.2.2"
|
|
1550
1550
|
});
|
|
1551
1551
|
/** npm scope and name prefix shared by the engine packages this adapter installs. */
|
|
1552
1552
|
const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
|
|
@@ -1739,6 +1739,75 @@ function validateOutput(bytes, format) {
|
|
|
1739
1739
|
].includes(format) && (bytes[0] !== 80 || bytes[1] !== 75 || bytes[2] !== 3 || bytes[3] !== 4)) throw new ConversionError("invalid-output", `LibreOffice did not produce a ${format} archive.`);
|
|
1740
1740
|
}
|
|
1741
1741
|
//#endregion
|
|
1742
|
+
//#region lib/types/pdf.js
|
|
1743
|
+
/** Page count of exported PDFs, read from the cross-reference table and page tree that LibreOffice writes. */
|
|
1744
|
+
/** LibreOffice ends each export with `startxref`, its byte offset, and `%%EOF`. */
|
|
1745
|
+
const TRAILER_WINDOW_BYTES = 1024;
|
|
1746
|
+
function unreadable(reason) {
|
|
1747
|
+
return new ConversionError("invalid-output", `LibreOffice produced a PDF without a readable page tree: ${reason}.`);
|
|
1748
|
+
}
|
|
1749
|
+
function crossReferences(pdf, offset, end) {
|
|
1750
|
+
const tokens = pdf.toString("latin1", offset, end).trim().split(/\s+/u);
|
|
1751
|
+
if (tokens[0] !== "xref") throw unreadable("startxref does not point to a cross-reference table");
|
|
1752
|
+
const offsets = /* @__PURE__ */ new Map();
|
|
1753
|
+
for (let index = 1; index < tokens.length;) {
|
|
1754
|
+
const first = Number(tokens[index]);
|
|
1755
|
+
const count = Number(tokens[index + 1]);
|
|
1756
|
+
index += 2;
|
|
1757
|
+
if (!Number.isSafeInteger(first) || !Number.isSafeInteger(count) || count < 0 || index + count * 3 > tokens.length) throw unreadable("a cross-reference subsection is malformed");
|
|
1758
|
+
for (let entry = 0; entry < count; entry++, index += 3) {
|
|
1759
|
+
const [position, generation, kind] = [
|
|
1760
|
+
tokens[index],
|
|
1761
|
+
tokens[index + 1],
|
|
1762
|
+
tokens[index + 2]
|
|
1763
|
+
];
|
|
1764
|
+
if (!/^\d{10}$/u.test(position) || !/^\d{5}$/u.test(generation) || kind !== "n" && kind !== "f") throw unreadable("a cross-reference entry is malformed");
|
|
1765
|
+
if (kind === "n") offsets.set(`${first + entry} ${Number(generation)}`, Number(position));
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return offsets;
|
|
1769
|
+
}
|
|
1770
|
+
function reference(dictionary, key) {
|
|
1771
|
+
const match = new RegExp(`/${key}\\s+(\\d+)\\s+(\\d+)\\s+R\\b`, "u").exec(dictionary);
|
|
1772
|
+
return match === null ? void 0 : `${Number(match[1])} ${Number(match[2])}`;
|
|
1773
|
+
}
|
|
1774
|
+
function indirectObject(pdf, offsets, target) {
|
|
1775
|
+
const offset = offsets.get(target);
|
|
1776
|
+
const end = offset === void 0 ? -1 : pdf.indexOf("endobj", offset, "latin1");
|
|
1777
|
+
const header = end < 0 ? null : /^(\d+)\s+(\d+)\s+obj\b/u.exec(pdf.toString("latin1", offset, end));
|
|
1778
|
+
if (header === null || `${Number(header[1])} ${Number(header[2])}` !== target) throw unreadable(`object ${target} is not at a cross-reference offset`);
|
|
1779
|
+
return header.input;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Read the page count of one complete PDF written by LibreOffice export.
|
|
1783
|
+
* Accepts the classic cross-reference table and uncompressed catalog and page-tree objects LibreOffice writes; rejects
|
|
1784
|
+
* truncated files, cross-reference streams, and references the table does not resolve.
|
|
1785
|
+
* @param bytes - Complete PDF output.
|
|
1786
|
+
* @returns The direct `/Count` of the catalog's root page tree.
|
|
1787
|
+
* @throws ConversionError `invalid-output` when the trailer, catalog, or page tree cannot be read.
|
|
1788
|
+
*/
|
|
1789
|
+
function pdfPageCount(bytes) {
|
|
1790
|
+
const pdf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1791
|
+
const windowStart = Math.max(0, pdf.length - TRAILER_WINDOW_BYTES);
|
|
1792
|
+
const tail = /startxref\s+(\d+)\s+%%EOF\s*$/u.exec(pdf.toString("latin1", windowStart));
|
|
1793
|
+
if (tail === null) throw unreadable("the file does not end with startxref and %%EOF");
|
|
1794
|
+
const startxref = windowStart + tail.index;
|
|
1795
|
+
const table = Number(tail[1]);
|
|
1796
|
+
const trailer = pdf.subarray(0, startxref).indexOf("trailer", table, "latin1");
|
|
1797
|
+
if (trailer < 0) throw unreadable("startxref does not precede a trailer");
|
|
1798
|
+
const offsets = crossReferences(pdf, table, trailer);
|
|
1799
|
+
const root = reference(pdf.toString("latin1", trailer, startxref), "Root");
|
|
1800
|
+
if (root === void 0) throw unreadable("the trailer has no /Root reference");
|
|
1801
|
+
const catalog = indirectObject(pdf, offsets, root);
|
|
1802
|
+
const pagesReference = /\/Type\s*\/Catalog\b/u.test(catalog) ? reference(catalog, "Pages") : void 0;
|
|
1803
|
+
if (pagesReference === void 0) throw unreadable("/Root is not a catalog with a /Pages reference");
|
|
1804
|
+
const pages = indirectObject(pdf, offsets, pagesReference);
|
|
1805
|
+
const count = /\/Type\s*\/Pages\b/u.test(pages) ? /\/Count\s+(\d+)\b(?!\s+\d+\s+R\b)/u.exec(pages) : null;
|
|
1806
|
+
const value = count === null ? NaN : Number(count[1]);
|
|
1807
|
+
if (!Number.isSafeInteger(value)) throw unreadable("the root page tree has no direct /Count");
|
|
1808
|
+
return value;
|
|
1809
|
+
}
|
|
1810
|
+
//#endregion
|
|
1742
1811
|
//#region lib/types/runtime.js
|
|
1743
1812
|
/** Offline discovery of the installed engine and public entry points. */
|
|
1744
1813
|
/**
|
|
@@ -2067,6 +2136,7 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
|
|
|
2067
2136
|
bytes = await readBounded(path, resolvedOptions.maxOutputBytes, stopped, "output");
|
|
2068
2137
|
}
|
|
2069
2138
|
validateOutput(bytes, format);
|
|
2139
|
+
const pageCount = format === "pdf" ? pdfPageCount(bytes) : void 0;
|
|
2070
2140
|
await validateFontSnapshot(fonts);
|
|
2071
2141
|
stopped.throwIfAborted();
|
|
2072
2142
|
await output.writeFile(bytes);
|
|
@@ -2074,7 +2144,8 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
|
|
|
2074
2144
|
succeeded = true;
|
|
2075
2145
|
return {
|
|
2076
2146
|
backend: engine.backend,
|
|
2077
|
-
missingFonts: result.missingFonts
|
|
2147
|
+
missingFonts: result.missingFonts,
|
|
2148
|
+
...pageCount === void 0 ? {} : { pageCount }
|
|
2078
2149
|
};
|
|
2079
2150
|
} catch (error) {
|
|
2080
2151
|
failure = error;
|
package/lib/editor.js
CHANGED
|
@@ -176,7 +176,7 @@ var SystemFontCatalog = class {
|
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Find installed faces covering the requested family or missing characters.
|
|
179
|
-
* Exact families precede configured alternatives, symbol families for
|
|
179
|
+
* Exact families precede configured alternatives, symbol families for requests without letters or numbers,
|
|
180
180
|
* generic families, then other glyph-covering faces.
|
|
181
181
|
* @param request - VCL family/style attributes and Unicode scalars missing from its current font.
|
|
182
182
|
* @param signal - cancellation checked between synchronous font reads.
|
|
@@ -189,7 +189,8 @@ var SystemFontCatalog = class {
|
|
|
189
189
|
const primary = requested[0];
|
|
190
190
|
let missingFamily;
|
|
191
191
|
if (primary !== void 0 && !GENERIC_FAMILIES.has(normalize(primary)) && !this.faces.some((face) => face.aliases.includes(normalize(primary)))) missingFamily = primary;
|
|
192
|
-
const
|
|
192
|
+
const symbols = request.codePoints.some((point) => /\p{Symbol}/u.test(String.fromCodePoint(point))) && !request.codePoints.some((point) => /[\p{Letter}\p{Number}]/u.test(String.fromCodePoint(point)));
|
|
193
|
+
const priority = fontFamilyPriority(requested, this.options.fallbackFamilies, request.pitch, symbols).map(normalize);
|
|
193
194
|
const missing = new Set(request.codePoints);
|
|
194
195
|
const ranked = this.faces.map((face) => {
|
|
195
196
|
const rank = priority.findIndex((family) => face.aliases.includes(family));
|
|
@@ -474,13 +475,13 @@ function resolveOptions(input = {}) {
|
|
|
474
475
|
const require = createRequire(import.meta.url);
|
|
475
476
|
/** Exact compatible engine versions; unchanged platforms retain their published packages. */
|
|
476
477
|
const ENGINE_VERSIONS = Object.freeze({
|
|
477
|
-
"darwin-arm64": "0.2.
|
|
478
|
-
"darwin-x64": "0.2.
|
|
478
|
+
"darwin-arm64": "0.2.2",
|
|
479
|
+
"darwin-x64": "0.2.2",
|
|
479
480
|
"linux-arm64-glibc": "0.1.1",
|
|
480
481
|
"linux-x64-glibc": "0.1.1",
|
|
481
|
-
"win32-arm64": "0.
|
|
482
|
-
"win32-x64": "0.2.
|
|
483
|
-
wasm: "0.2.
|
|
482
|
+
"win32-arm64": "0.2.2",
|
|
483
|
+
"win32-x64": "0.2.2",
|
|
484
|
+
wasm: "0.2.2"
|
|
484
485
|
});
|
|
485
486
|
/** npm scope and name prefix shared by the engine packages this adapter installs. */
|
|
486
487
|
const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
|
|
@@ -1424,7 +1425,7 @@ async function prepareNativeEngine(engine, profile) {
|
|
|
1424
1425
|
const root = join(profile, "engine");
|
|
1425
1426
|
await symlink(engine.root, root, "junction");
|
|
1426
1427
|
try {
|
|
1427
|
-
const executable = join(profile, "
|
|
1428
|
+
const executable = join(profile, "dsoffice.exe");
|
|
1428
1429
|
await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
|
|
1429
1430
|
return {
|
|
1430
1431
|
engine: {
|
|
@@ -1647,7 +1648,8 @@ var EditorTransport = class {
|
|
|
1647
1648
|
return;
|
|
1648
1649
|
}
|
|
1649
1650
|
if (c.kind === "ready") {
|
|
1650
|
-
if (c.protocol !== 4 || c.
|
|
1651
|
+
if (c.protocol !== 4 || c.frameForwardingProtocol !== 1 || frame.pixels.length !== 0) throw new Error("Native editor requires editor protocol 4 and frame-forwarding protocol 1.");
|
|
1652
|
+
if (c.frameForwardingTransferable !== true) throw new Error("Native editor predates transferable frame-forwarding channels; install the matching engine.");
|
|
1651
1653
|
this.initialized = true;
|
|
1652
1654
|
clearTimeout(this.startupTimer);
|
|
1653
1655
|
this.ready.resolve(frame);
|
|
@@ -1881,10 +1883,13 @@ async function openDocument(request) {
|
|
|
1881
1883
|
missingFonts: fonts.missingFonts,
|
|
1882
1884
|
writable,
|
|
1883
1885
|
processId: process.processId,
|
|
1884
|
-
async attachSurfaceTransport(
|
|
1886
|
+
async attachSurfaceTransport(tx, { timeoutMs }) {
|
|
1887
|
+
if (typeof tx !== "string" || tx.length === 0) throw new TypeError("A frame-forwarding TX credential is required.");
|
|
1888
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs >= options.timeoutMs) throw new RangeError("Surface transport timeoutMs must be a positive integer below the operation timeout.");
|
|
1885
1889
|
await execute({
|
|
1886
1890
|
op: "attachSurfaceTransport",
|
|
1887
|
-
|
|
1891
|
+
tx,
|
|
1892
|
+
timeoutMs
|
|
1888
1893
|
});
|
|
1889
1894
|
},
|
|
1890
1895
|
async detachSurfaceTransport() {
|
package/lib/index.js
CHANGED
|
@@ -777,7 +777,7 @@ async function prepareNativeEngine(engine, profile) {
|
|
|
777
777
|
const root = join(profile, "engine");
|
|
778
778
|
await symlink(engine.root, root, "junction");
|
|
779
779
|
try {
|
|
780
|
-
const executable = join(profile, "
|
|
780
|
+
const executable = join(profile, "dsoffice.exe");
|
|
781
781
|
await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
|
|
782
782
|
return {
|
|
783
783
|
engine: {
|
|
@@ -1535,16 +1535,16 @@ function resolveOptions(input = {}) {
|
|
|
1535
1535
|
/** Resolve installed, version-matched engine packages without downloads or compilation. */
|
|
1536
1536
|
const require = createRequire(import.meta.url);
|
|
1537
1537
|
/** Node API release version returned by runtime discovery. */
|
|
1538
|
-
const ENGINE_VERSION = "0.2.
|
|
1538
|
+
const ENGINE_VERSION = "0.2.2";
|
|
1539
1539
|
/** Exact compatible engine versions; unchanged platforms retain their published packages. */
|
|
1540
1540
|
const ENGINE_VERSIONS = Object.freeze({
|
|
1541
|
-
"darwin-arm64": "0.2.
|
|
1542
|
-
"darwin-x64": "0.2.
|
|
1541
|
+
"darwin-arm64": "0.2.2",
|
|
1542
|
+
"darwin-x64": "0.2.2",
|
|
1543
1543
|
"linux-arm64-glibc": "0.1.1",
|
|
1544
1544
|
"linux-x64-glibc": "0.1.1",
|
|
1545
|
-
"win32-arm64": "0.
|
|
1546
|
-
"win32-x64": "0.2.
|
|
1547
|
-
wasm: "0.2.
|
|
1545
|
+
"win32-arm64": "0.2.2",
|
|
1546
|
+
"win32-x64": "0.2.2",
|
|
1547
|
+
wasm: "0.2.2"
|
|
1548
1548
|
});
|
|
1549
1549
|
/** npm scope and name prefix shared by the engine packages this adapter installs. */
|
|
1550
1550
|
const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
|
|
@@ -1737,6 +1737,75 @@ function validateOutput(bytes, format) {
|
|
|
1737
1737
|
].includes(format) && (bytes[0] !== 80 || bytes[1] !== 75 || bytes[2] !== 3 || bytes[3] !== 4)) throw new ConversionError("invalid-output", `LibreOffice did not produce a ${format} archive.`);
|
|
1738
1738
|
}
|
|
1739
1739
|
//#endregion
|
|
1740
|
+
//#region lib/types/pdf.js
|
|
1741
|
+
/** Page count of exported PDFs, read from the cross-reference table and page tree that LibreOffice writes. */
|
|
1742
|
+
/** LibreOffice ends each export with `startxref`, its byte offset, and `%%EOF`. */
|
|
1743
|
+
const TRAILER_WINDOW_BYTES = 1024;
|
|
1744
|
+
function unreadable(reason) {
|
|
1745
|
+
return new ConversionError("invalid-output", `LibreOffice produced a PDF without a readable page tree: ${reason}.`);
|
|
1746
|
+
}
|
|
1747
|
+
function crossReferences(pdf, offset, end) {
|
|
1748
|
+
const tokens = pdf.toString("latin1", offset, end).trim().split(/\s+/u);
|
|
1749
|
+
if (tokens[0] !== "xref") throw unreadable("startxref does not point to a cross-reference table");
|
|
1750
|
+
const offsets = /* @__PURE__ */ new Map();
|
|
1751
|
+
for (let index = 1; index < tokens.length;) {
|
|
1752
|
+
const first = Number(tokens[index]);
|
|
1753
|
+
const count = Number(tokens[index + 1]);
|
|
1754
|
+
index += 2;
|
|
1755
|
+
if (!Number.isSafeInteger(first) || !Number.isSafeInteger(count) || count < 0 || index + count * 3 > tokens.length) throw unreadable("a cross-reference subsection is malformed");
|
|
1756
|
+
for (let entry = 0; entry < count; entry++, index += 3) {
|
|
1757
|
+
const [position, generation, kind] = [
|
|
1758
|
+
tokens[index],
|
|
1759
|
+
tokens[index + 1],
|
|
1760
|
+
tokens[index + 2]
|
|
1761
|
+
];
|
|
1762
|
+
if (!/^\d{10}$/u.test(position) || !/^\d{5}$/u.test(generation) || kind !== "n" && kind !== "f") throw unreadable("a cross-reference entry is malformed");
|
|
1763
|
+
if (kind === "n") offsets.set(`${first + entry} ${Number(generation)}`, Number(position));
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return offsets;
|
|
1767
|
+
}
|
|
1768
|
+
function reference(dictionary, key) {
|
|
1769
|
+
const match = new RegExp(`/${key}\\s+(\\d+)\\s+(\\d+)\\s+R\\b`, "u").exec(dictionary);
|
|
1770
|
+
return match === null ? void 0 : `${Number(match[1])} ${Number(match[2])}`;
|
|
1771
|
+
}
|
|
1772
|
+
function indirectObject(pdf, offsets, target) {
|
|
1773
|
+
const offset = offsets.get(target);
|
|
1774
|
+
const end = offset === void 0 ? -1 : pdf.indexOf("endobj", offset, "latin1");
|
|
1775
|
+
const header = end < 0 ? null : /^(\d+)\s+(\d+)\s+obj\b/u.exec(pdf.toString("latin1", offset, end));
|
|
1776
|
+
if (header === null || `${Number(header[1])} ${Number(header[2])}` !== target) throw unreadable(`object ${target} is not at a cross-reference offset`);
|
|
1777
|
+
return header.input;
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Read the page count of one complete PDF written by LibreOffice export.
|
|
1781
|
+
* Accepts the classic cross-reference table and uncompressed catalog and page-tree objects LibreOffice writes; rejects
|
|
1782
|
+
* truncated files, cross-reference streams, and references the table does not resolve.
|
|
1783
|
+
* @param bytes - Complete PDF output.
|
|
1784
|
+
* @returns The direct `/Count` of the catalog's root page tree.
|
|
1785
|
+
* @throws ConversionError `invalid-output` when the trailer, catalog, or page tree cannot be read.
|
|
1786
|
+
*/
|
|
1787
|
+
function pdfPageCount(bytes) {
|
|
1788
|
+
const pdf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1789
|
+
const windowStart = Math.max(0, pdf.length - TRAILER_WINDOW_BYTES);
|
|
1790
|
+
const tail = /startxref\s+(\d+)\s+%%EOF\s*$/u.exec(pdf.toString("latin1", windowStart));
|
|
1791
|
+
if (tail === null) throw unreadable("the file does not end with startxref and %%EOF");
|
|
1792
|
+
const startxref = windowStart + tail.index;
|
|
1793
|
+
const table = Number(tail[1]);
|
|
1794
|
+
const trailer = pdf.subarray(0, startxref).indexOf("trailer", table, "latin1");
|
|
1795
|
+
if (trailer < 0) throw unreadable("startxref does not precede a trailer");
|
|
1796
|
+
const offsets = crossReferences(pdf, table, trailer);
|
|
1797
|
+
const root = reference(pdf.toString("latin1", trailer, startxref), "Root");
|
|
1798
|
+
if (root === void 0) throw unreadable("the trailer has no /Root reference");
|
|
1799
|
+
const catalog = indirectObject(pdf, offsets, root);
|
|
1800
|
+
const pagesReference = /\/Type\s*\/Catalog\b/u.test(catalog) ? reference(catalog, "Pages") : void 0;
|
|
1801
|
+
if (pagesReference === void 0) throw unreadable("/Root is not a catalog with a /Pages reference");
|
|
1802
|
+
const pages = indirectObject(pdf, offsets, pagesReference);
|
|
1803
|
+
const count = /\/Type\s*\/Pages\b/u.test(pages) ? /\/Count\s+(\d+)\b(?!\s+\d+\s+R\b)/u.exec(pages) : null;
|
|
1804
|
+
const value = count === null ? NaN : Number(count[1]);
|
|
1805
|
+
if (!Number.isSafeInteger(value)) throw unreadable("the root page tree has no direct /Count");
|
|
1806
|
+
return value;
|
|
1807
|
+
}
|
|
1808
|
+
//#endregion
|
|
1740
1809
|
//#region lib/types/runtime.js
|
|
1741
1810
|
/** Offline discovery of the installed engine and public entry points. */
|
|
1742
1811
|
/**
|
|
@@ -2065,6 +2134,7 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
|
|
|
2065
2134
|
bytes = await readBounded(path, resolvedOptions.maxOutputBytes, stopped, "output");
|
|
2066
2135
|
}
|
|
2067
2136
|
validateOutput(bytes, format);
|
|
2137
|
+
const pageCount = format === "pdf" ? pdfPageCount(bytes) : void 0;
|
|
2068
2138
|
await validateFontSnapshot(fonts);
|
|
2069
2139
|
stopped.throwIfAborted();
|
|
2070
2140
|
await output.writeFile(bytes);
|
|
@@ -2072,7 +2142,8 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
|
|
|
2072
2142
|
succeeded = true;
|
|
2073
2143
|
return {
|
|
2074
2144
|
backend: engine.backend,
|
|
2075
|
-
missingFonts: result.missingFonts
|
|
2145
|
+
missingFonts: result.missingFonts,
|
|
2146
|
+
...pageCount === void 0 ? {} : { pageCount }
|
|
2076
2147
|
};
|
|
2077
2148
|
} catch (error) {
|
|
2078
2149
|
failure = error;
|
package/lib/types/editor.d.ts
CHANGED
|
@@ -47,9 +47,14 @@ export interface EditorSurfaceResult {
|
|
|
47
47
|
readonly part?: number;
|
|
48
48
|
readonly ended?: boolean;
|
|
49
49
|
}
|
|
50
|
+
/** Deadline for connecting a document to a frame-forwarding channel. */
|
|
51
|
+
export interface EditorSurfaceTransportOptions {
|
|
52
|
+
/** Positive milliseconds, shorter than the document's operation timeout. */
|
|
53
|
+
readonly timeoutMs: number;
|
|
54
|
+
}
|
|
50
55
|
/** One in-memory document with ordered operations and explicit process ownership. Native views hide comments while original-format snapshots retain their data. */
|
|
51
56
|
export interface EditorDocument {
|
|
52
|
-
/** Owned native PID
|
|
57
|
+
/** Owned native PID for process supervision; frame-forwarding channels do not authorize by process. */
|
|
53
58
|
readonly processId: number;
|
|
54
59
|
readonly initialInfo: EditorInfo;
|
|
55
60
|
readonly missingFonts: readonly string[];
|
|
@@ -58,9 +63,17 @@ export interface EditorDocument {
|
|
|
58
63
|
readonly revision: number;
|
|
59
64
|
/** Subscribe to transient engine callbacks and process failure; returns an unsubscribe function. */
|
|
60
65
|
onEvent(listener: (event: EditorEvent) => void): () => void;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Connect shared rendering and input to a frame-forwarding channel with its TX credential. While another producer of
|
|
68
|
+
* the channel is connected the attach rejects with a message starting "channel-busy"; after that producer
|
|
69
|
+
* disconnects, it waits until the receiver released the previous connection's frames. The wait is bounded by
|
|
70
|
+
* `timeoutMs`, which must be shorter than the document's operation timeout because an operation timeout ends the
|
|
71
|
+
* session.
|
|
72
|
+
* @param tx - TX credential issued by the channel's receiver.
|
|
73
|
+
* @param options - Connection deadline in milliseconds.
|
|
74
|
+
*/
|
|
75
|
+
attachSurfaceTransport(tx: string, options: EditorSurfaceTransportOptions): Promise<void>;
|
|
76
|
+
/** Close this document's producer connection; the channel and its TX credential stay valid for a successor. The editable document is retained. */
|
|
64
77
|
detachSurfaceTransport(): Promise<void>;
|
|
65
78
|
/** Wait for the canonical direct-input sequence before the next business operation. */
|
|
66
79
|
waitForInput(sequence: number): Promise<void>;
|
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.2.
|
|
2
|
+
export declare const ENGINE_VERSION = "0.2.2";
|
|
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. */
|
package/lib/types/fonts.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export declare class SystemFontCatalog {
|
|
|
125
125
|
constructor(options: SystemFontCatalogOptions);
|
|
126
126
|
/**
|
|
127
127
|
* Find installed faces covering the requested family or missing characters.
|
|
128
|
-
* Exact families precede configured alternatives, symbol families for
|
|
128
|
+
* Exact families precede configured alternatives, symbol families for requests without letters or numbers,
|
|
129
129
|
* generic families, then other glyph-covering faces.
|
|
130
130
|
* @param request - VCL family/style attributes and Unicode scalars missing from its current font.
|
|
131
131
|
* @param signal - cancellation checked between synchronous font reads.
|
package/lib/types/index.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export interface RenderResult {
|
|
|
49
49
|
readonly backend: 'native' | 'wasm';
|
|
50
50
|
/** Declared OOXML families no installed font provides; binary formats return an empty list. */
|
|
51
51
|
readonly missingFonts: string[];
|
|
52
|
+
/** Pages in the written PDF's page tree; present exactly when the output is PDF. */
|
|
53
|
+
readonly pageCount?: number;
|
|
52
54
|
}
|
|
53
55
|
/** A converter serializes document operations; cancellation and disposal await process/worker exit. */
|
|
54
56
|
export interface Converter {
|
|
@@ -59,7 +61,7 @@ export interface Converter {
|
|
|
59
61
|
* Rejects existing output paths; removes a newly created output on failure or cancellation.
|
|
60
62
|
* @param request - Absolute paths. Input suffixes are listed in CONVERSION_FORMATS.
|
|
61
63
|
* @param signal - Optional cancellation, including while queued.
|
|
62
|
-
* @returns Engine choice
|
|
64
|
+
* @returns Engine choice, missing declared font families, and the PDF page count.
|
|
63
65
|
*/
|
|
64
66
|
render(request: {
|
|
65
67
|
inputPath: string;
|
|
@@ -70,7 +72,7 @@ export interface Converter {
|
|
|
70
72
|
* Failure/cancellation removes the complete batch. The manifest describes one saved input snapshot.
|
|
71
73
|
*/
|
|
72
74
|
renderImages(request: RenderImagesRequest, signal?: AbortSignal): Promise<RenderImagesResult>;
|
|
73
|
-
/** Convert to the output extension; CSV requires a sheet for multi-sheet inputs. */
|
|
75
|
+
/** Convert to the output extension; CSV requires a sheet for multi-sheet inputs. PDF results include `pageCount`. */
|
|
74
76
|
convert(request: ConversionRequest, signal?: AbortSignal): Promise<RenderResult>;
|
|
75
77
|
/**
|
|
76
78
|
* Recalculate the entire workbook synchronously and save formulas with refreshed cached results.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the page count of one complete PDF written by LibreOffice export.
|
|
3
|
+
* Accepts the classic cross-reference table and uncompressed catalog and page-tree objects LibreOffice writes; rejects
|
|
4
|
+
* truncated files, cross-reference streams, and references the table does not resolve.
|
|
5
|
+
* @param bytes - Complete PDF output.
|
|
6
|
+
* @returns The direct `/Count` of the catalog's root page tree.
|
|
7
|
+
* @throws ConversionError `invalid-output` when the trailer, catalog, or page tree cannot be read.
|
|
8
|
+
*/
|
|
9
|
+
export declare function pdfPageCount(bytes: Uint8Array): number;
|
|
10
|
+
//# sourceMappingURL=pdf.d.ts.map
|