@deepseek-ai/libreoffice-kit 0.2.0 → 0.2.3-rc.3
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 +5 -5
- package/README.zh.md +5 -5
- package/frame-forwarding/CMakeLists.txt +3 -4
- package/frame-forwarding/README.md +21 -17
- package/frame-forwarding/README.zh.md +22 -18
- package/frame-forwarding/include/dsh_frame_forwarding.h +42 -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 +23 -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 +23 -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 +23 -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 +23 -21
- package/frame-forwarding/receipt.json +16 -14
- package/frame-forwarding/scripts/build-webgpu.mjs +1 -0
- package/frame-forwarding/scripts/build.mjs +3 -3
- package/frame-forwarding/scripts/metadata.mjs +12 -8
- package/frame-forwarding/scripts/source-identity.mjs +3 -3
- package/frame-forwarding/sdk.json +7 -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 +120 -30
- package/frame-forwarding/src/receiver.cc +422 -212
- package/frame-forwarding/src/relay-transport.inc +38 -10
- package/frame-forwarding/src/transport.cc +328 -155
- package/frame-forwarding/src/transport.h +73 -9
- package/frame-forwarding/verify.d.mts +1 -1
- package/frame-forwarding/verify.mjs +19 -17
- package/lib/cli.js +6 -6
- package/lib/editor.js +15 -10
- package/lib/index.js +6 -6
- 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/worker.js +3 -2
- 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,105 @@ 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
|
+
* Every handle a producer names belongs to the producer: on Windows frame.resource is a handle value in the producer's
|
|
23
|
+
* process, which the receiver duplicates from that process. Receivers refuse producers without it, and ready.stride
|
|
24
|
+
* echoes the hello capabilities the receiver accepted, so producers refuse receivers that would read the value as a
|
|
25
|
+
* handle of their own.
|
|
26
|
+
*/
|
|
27
|
+
constexpr uint32_t hello_producer_local_handles = 4;
|
|
28
|
+
/** The hello capabilities a receiver of these sources accepts and echoes in ready.stride. */
|
|
29
|
+
constexpr uint32_t hello_capabilities = hello_keyed_mutex | hello_transferable | hello_producer_local_handles;
|
|
30
|
+
/**
|
|
31
|
+
* frame.max_frames carries per-frame flags; zero is an ordered frame. A replaceable frame may be dropped before
|
|
32
|
+
* presentation once a newer replaceable frame of the same view is ready; receivers that ignore the flag present it.
|
|
33
|
+
*/
|
|
34
|
+
constexpr uint32_t frame_replaceable = 1;
|
|
35
|
+
/** goodbye.text of a candidate the receiver refuses before it receives a connection identifier. */
|
|
36
|
+
constexpr const char* reject_busy = "channel-busy";
|
|
37
|
+
constexpr const char* reject_capability = "transferable-tx-required";
|
|
38
|
+
constexpr const char* reject_local_handles = "producer-local-handles-required";
|
|
39
|
+
constexpr const char* reject_credential = "invalid-credential";
|
|
40
|
+
constexpr const char* reject_closed = "channel-closed";
|
|
41
|
+
/** Prefix of a refusal that names the producer's and the receiver's protocol versions. */
|
|
42
|
+
constexpr const char* reject_protocol = "protocol-mismatch";
|
|
16
43
|
struct Packet {
|
|
17
44
|
uint32_t marker = magic, version = DSH_FRAME_FORWARDING_PROTOCOL_VERSION, kind = 0;
|
|
18
45
|
uint32_t width = 0, height = 0, stride = 0, max_frames = 0;
|
|
19
46
|
uint64_t frame_id = 0, allocation_id = 0, max_bytes = 0, resource = 0;
|
|
47
|
+
/** hello: the TX secret. After the handshake: the decimal connection identifier. */
|
|
20
48
|
char token[65] = {};
|
|
21
49
|
char text[DSH_FRAME_FORWARDING_TEXT_CAPACITY] = {};
|
|
22
50
|
};
|
|
23
51
|
struct Received { Packet packet; uint32_t pid = 0; uintptr_t resource = 0; };
|
|
24
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* One physical producer connection. receive returns 1 data, 0 timeout, -1 closed/error. After bind_connection, every
|
|
54
|
+
* sent packet carries the connection identifier and a received packet without it closes the channel.
|
|
55
|
+
*/
|
|
25
56
|
class Channel {
|
|
26
57
|
public:
|
|
27
58
|
virtual ~Channel() = default;
|
|
28
|
-
|
|
29
|
-
|
|
59
|
+
int receive(Received& out, uint32_t timeout_ms);
|
|
60
|
+
bool send(const Packet& packet, uintptr_t resource = 0);
|
|
61
|
+
void bind_connection(uint64_t id);
|
|
62
|
+
uint64_t connection() const { return connection_; }
|
|
63
|
+
/** The last receive closed because a packet named another connection. */
|
|
64
|
+
bool foreign_packet() const { return foreign_; }
|
|
65
|
+
/** The last receive closed because a packet named a handle its live sender does not own. */
|
|
66
|
+
bool invalid_resource() const { return invalid_resource_; }
|
|
30
67
|
virtual void interrupt() = 0;
|
|
31
68
|
virtual uint32_t peer_pid() const = 0;
|
|
69
|
+
protected:
|
|
70
|
+
virtual int receive_packet(Received&, uint32_t timeout_ms) = 0;
|
|
71
|
+
virtual bool send_packet(const Packet&, uintptr_t resource) = 0;
|
|
72
|
+
bool invalid_resource_ = false;
|
|
73
|
+
private:
|
|
74
|
+
uint64_t connection_ = 0;
|
|
75
|
+
char connection_text_[65] = {};
|
|
76
|
+
bool foreign_ = false;
|
|
77
|
+
};
|
|
78
|
+
/** A producer whose hello reached the listener; its channel answers it before acceptance or refusal. */
|
|
79
|
+
struct Candidate { Received hello; std::unique_ptr<Channel> channel; };
|
|
80
|
+
/** The stable endpoint of one logical channel. Each producer connection gets a channel of its own. */
|
|
81
|
+
class Listener {
|
|
82
|
+
public:
|
|
83
|
+
virtual ~Listener() = default;
|
|
84
|
+
/** 1 candidate, 0 timeout, -1 stopped or failed. Malformed or silent connections are dropped without affecting others. */
|
|
85
|
+
virtual int accept(Candidate& candidate, uint32_t timeout_ms) = 0;
|
|
86
|
+
virtual void interrupt() = 0;
|
|
32
87
|
};
|
|
33
88
|
struct Endpoint { uint32_t pid; std::string token, name; };
|
|
34
89
|
Endpoint parse_endpoint(const std::string& value);
|
|
35
|
-
|
|
90
|
+
/** Publish the endpoint name. handshake_ms bounds how long a connected client may withhold its hello. */
|
|
91
|
+
std::unique_ptr<Listener> listen(Endpoint& endpoint, uint32_t handshake_ms);
|
|
36
92
|
std::unique_ptr<Channel> connect_channel(const Endpoint& endpoint, const std::function<bool()>& cancelled = {});
|
|
93
|
+
/** Parse a decimal connection identifier from a token; 0 when it is not one. */
|
|
94
|
+
uint64_t parse_connection(const char (&token)[65]);
|
|
37
95
|
uint32_t process_id();
|
|
38
96
|
uintptr_t receive_resource(Received& received);
|
|
39
97
|
void release_resource(uintptr_t resource);
|
|
40
98
|
void clear_validation_device();
|
|
41
99
|
uint64_t resource_bytes(uintptr_t resource);
|
|
42
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Validate a producer frame's format and dimensions and report its adapter. On Windows a keyed-mutex texture is also
|
|
102
|
+
* made ready: key 0 is acquired within the deadline and released, before Chromium's unbounded key-0 acquisition.
|
|
103
|
+
*/
|
|
104
|
+
bool resource_dimensions(uintptr_t resource, uint32_t width, uint32_t height, uint32_t stride,
|
|
105
|
+
std::chrono::steady_clock::time_point deadline, std::string& diagnostic, std::string& adapter, bool* keyed_mutex = nullptr);
|
|
43
106
|
/** Adapter owning a shared resource, or an empty string when it cannot be identified. */
|
|
44
107
|
std::string resource_adapter(uintptr_t resource);
|
|
45
108
|
/** Adapter owning the producer's graphics device. */
|
|
46
109
|
std::string device_adapter(void* device);
|
|
47
110
|
#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
111
|
struct RelayDevice;
|
|
51
112
|
struct RelayTexture;
|
|
52
113
|
struct RelayReadback;
|
|
114
|
+
struct RelaySource;
|
|
53
115
|
uintptr_t relay_handle(const std::shared_ptr<RelayTexture>& texture);
|
|
54
116
|
bool relay_begin(uintptr_t resource, uint32_t width, uint32_t height,
|
|
55
117
|
const std::string& adapter, std::chrono::steady_clock::time_point deadline, const std::atomic<bool>& stopped,
|
|
@@ -59,8 +121,10 @@ int relay_advance(const std::shared_ptr<RelayTexture>& slot, const std::atomic<b
|
|
|
59
121
|
uintptr_t relay_completion_event(const std::shared_ptr<RelayTexture>& slot);
|
|
60
122
|
/** True only after every submitted copy completes or its device is removed. */
|
|
61
123
|
bool relay_gpu_idle(const std::shared_ptr<RelayTexture>& slot, std::string& diagnostic);
|
|
62
|
-
|
|
63
|
-
|
|
124
|
+
/** Validate each frame and copy under key 0; reuse the allocation's import only for the same NT object and dimensions. */
|
|
125
|
+
bool relay_readback_begin(uintptr_t resource, uint32_t width, uint32_t height, uint32_t stride,
|
|
126
|
+
std::shared_ptr<RelayReadback>& slot, std::shared_ptr<RelaySource>& imported,
|
|
127
|
+
std::string& diagnostic, std::string& adapter, bool* keyed_mutex,
|
|
64
128
|
std::chrono::steady_clock::time_point deadline);
|
|
65
129
|
int relay_readback_ready(const std::shared_ptr<RelayReadback>& slot, bool retiring, std::string& diagnostic);
|
|
66
130
|
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
|
@@ -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.3-rc.3";
|
|
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.3-rc.3",
|
|
1544
|
+
"darwin-x64": "0.2.3-rc.3",
|
|
1545
1545
|
"linux-arm64-glibc": "0.1.1",
|
|
1546
1546
|
"linux-x64-glibc": "0.1.1",
|
|
1547
|
-
"win32-arm64": "0.2.
|
|
1548
|
-
"win32-x64": "0.2.
|
|
1549
|
-
wasm: "0.2.
|
|
1547
|
+
"win32-arm64": "0.2.3-rc.3",
|
|
1548
|
+
"win32-x64": "0.2.3-rc.3",
|
|
1549
|
+
wasm: "0.2.3-rc.3"
|
|
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";
|
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.3-rc.3",
|
|
479
|
+
"darwin-x64": "0.2.3-rc.3",
|
|
479
480
|
"linux-arm64-glibc": "0.1.1",
|
|
480
481
|
"linux-x64-glibc": "0.1.1",
|
|
481
|
-
"win32-arm64": "0.2.
|
|
482
|
-
"win32-x64": "0.2.
|
|
483
|
-
wasm: "0.2.
|
|
482
|
+
"win32-arm64": "0.2.3-rc.3",
|
|
483
|
+
"win32-x64": "0.2.3-rc.3",
|
|
484
|
+
wasm: "0.2.3-rc.3"
|
|
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";
|
|
@@ -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
|
@@ -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.3-rc.3";
|
|
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.3-rc.3",
|
|
1542
|
+
"darwin-x64": "0.2.3-rc.3",
|
|
1543
1543
|
"linux-arm64-glibc": "0.1.1",
|
|
1544
1544
|
"linux-x64-glibc": "0.1.1",
|
|
1545
|
-
"win32-arm64": "0.2.
|
|
1546
|
-
"win32-x64": "0.2.
|
|
1547
|
-
wasm: "0.2.
|
|
1545
|
+
"win32-arm64": "0.2.3-rc.3",
|
|
1546
|
+
"win32-x64": "0.2.3-rc.3",
|
|
1547
|
+
wasm: "0.2.3-rc.3"
|
|
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";
|
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.3-rc.3";
|
|
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/worker.js
CHANGED
|
@@ -157,7 +157,7 @@ var SystemFontCatalog = class {
|
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* Find installed faces covering the requested family or missing characters.
|
|
160
|
-
* Exact families precede configured alternatives, symbol families for
|
|
160
|
+
* Exact families precede configured alternatives, symbol families for requests without letters or numbers,
|
|
161
161
|
* generic families, then other glyph-covering faces.
|
|
162
162
|
* @param request - VCL family/style attributes and Unicode scalars missing from its current font.
|
|
163
163
|
* @param signal - cancellation checked between synchronous font reads.
|
|
@@ -170,7 +170,8 @@ var SystemFontCatalog = class {
|
|
|
170
170
|
const primary = requested[0];
|
|
171
171
|
let missingFamily;
|
|
172
172
|
if (primary !== void 0 && !GENERIC_FAMILIES.has(normalize(primary)) && !this.faces.some((face) => face.aliases.includes(normalize(primary)))) missingFamily = primary;
|
|
173
|
-
const
|
|
173
|
+
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)));
|
|
174
|
+
const priority = fontFamilyPriority(requested, this.options.fallbackFamilies, request.pitch, symbols).map(normalize);
|
|
174
175
|
const missing = new Set(request.codePoints);
|
|
175
176
|
const ranked = this.faces.map((face) => {
|
|
176
177
|
const rank = priority.findIndex((family) => face.aliases.includes(family));
|
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.2.
|
|
4
|
+
"version": "0.2.3-rc.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -69,9 +69,7 @@
|
|
|
69
69
|
"frame-forwarding/README.md",
|
|
70
70
|
"frame-forwarding/README.zh.md",
|
|
71
71
|
"frame-forwarding/include/dsh_frame_forwarding.h",
|
|
72
|
-
"frame-forwarding/
|
|
73
|
-
"frame-forwarding/include/dsh_frame_forwarding_node.h",
|
|
74
|
-
"frame-forwarding/include/dsh_webgpu.h",
|
|
72
|
+
"frame-forwarding/src/graphite-interop-internal.hxx",
|
|
75
73
|
"frame-forwarding/src/node-producer.cc",
|
|
76
74
|
"frame-forwarding/src/producer-internal.h",
|
|
77
75
|
"frame-forwarding/src/transport.h",
|
|
@@ -81,7 +79,7 @@
|
|
|
81
79
|
"frame-forwarding/src/receiver.cc",
|
|
82
80
|
"frame-forwarding/src/win-delay-load.cc",
|
|
83
81
|
"frame-forwarding/src/win-delay-load.LICENSE",
|
|
84
|
-
"frame-forwarding/src/
|
|
82
|
+
"frame-forwarding/src/graphite-interop.cc",
|
|
85
83
|
"frame-forwarding/CMakeLists.txt",
|
|
86
84
|
"frame-forwarding/sdk.json",
|
|
87
85
|
"frame-forwarding/scripts/build.mjs",
|
|
@@ -126,11 +124,11 @@
|
|
|
126
124
|
},
|
|
127
125
|
"optionalDependencies": {
|
|
128
126
|
"koffi": "3.1.1",
|
|
129
|
-
"@deepseek-ai/libreoffice-kit-darwin-
|
|
130
|
-
"@deepseek-ai/libreoffice-kit-darwin-
|
|
131
|
-
"@deepseek-ai/libreoffice-kit-wasm": "0.2.
|
|
132
|
-
"@deepseek-ai/libreoffice-kit-win32-
|
|
133
|
-
"@deepseek-ai/libreoffice-kit-win32-
|
|
127
|
+
"@deepseek-ai/libreoffice-kit-darwin-arm64": "0.2.3-rc.3",
|
|
128
|
+
"@deepseek-ai/libreoffice-kit-darwin-x64": "0.2.3-rc.3",
|
|
129
|
+
"@deepseek-ai/libreoffice-kit-wasm": "0.2.3-rc.3",
|
|
130
|
+
"@deepseek-ai/libreoffice-kit-win32-arm64": "0.2.3-rc.3",
|
|
131
|
+
"@deepseek-ai/libreoffice-kit-win32-x64": "0.2.3-rc.3"
|
|
134
132
|
},
|
|
135
133
|
"bin": {
|
|
136
134
|
"dsoffice": "./lib/cli.js"
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#ifndef DSH_FRAME_FORWARDING_ENGINE_H
|
|
2
|
-
#define DSH_FRAME_FORWARDING_ENGINE_H
|
|
3
|
-
#include <stddef.h>
|
|
4
|
-
#include <stdint.h>
|
|
5
|
-
#ifdef __cplusplus
|
|
6
|
-
extern "C" {
|
|
7
|
-
#endif
|
|
8
|
-
/** A borrowed GPU target valid only during render(). Native objects never enter JS. */
|
|
9
|
-
typedef struct dsh_frame_forwarding_target {
|
|
10
|
-
void* texture; /* IOSurfaceRef on macOS; ID3D11Texture2D* on Windows. */
|
|
11
|
-
void* shared_handle; /* Borrowed Windows NT handle; NULL on macOS. */
|
|
12
|
-
void* device; /* Borrowed ID3D11Device*; NULL on macOS. */
|
|
13
|
-
uint32_t width, height;
|
|
14
|
-
uint64_t frame_id, input_sequence;
|
|
15
|
-
double time_seconds; /* Monotonic time since this producer was created. */
|
|
16
|
-
void* cancellation_context;
|
|
17
|
-
int (*cancelled)(void*); /* Close or operation deadline; callable from this worker. */
|
|
18
|
-
} dsh_frame_forwarding_target;
|
|
19
|
-
/** Native engine adapter ABI v1. The factory and its configuration outlive the
|
|
20
|
-
* producer. Every callback runs serially on that producer's native worker.
|
|
21
|
-
* create/destroy own one engine instance; device returns its borrowed D3D11
|
|
22
|
-
* device (or NULL for default/macOS). update receives bounded application JSON.
|
|
23
|
-
* On Windows the SDK owns key 0 around render: queue commands on target.device's
|
|
24
|
-
* immediate context without acquiring the mutex again. Release imported views
|
|
25
|
-
* before returning 1; no completion wait is required. On macOS GPU writes must
|
|
26
|
-
* be complete on return. External devices/import APIs that acquire their own lock
|
|
27
|
-
* use the C surface API instead of this callback. Return 0 with diagnostic text on failure; the producer closes
|
|
28
|
-
* instead of reusing a target whose completion is uncertain. Long-running work
|
|
29
|
-
* must observe target.cancelled. No callback may throw across this C ABI.
|
|
30
|
-
*/
|
|
31
|
-
typedef struct dsh_frame_forwarding_engine_v1 {
|
|
32
|
-
uint32_t version, size;
|
|
33
|
-
void* configuration;
|
|
34
|
-
void* (*create)(void* configuration, char* error, size_t error_size);
|
|
35
|
-
void (*destroy)(void* engine);
|
|
36
|
-
void* (*device)(void* engine);
|
|
37
|
-
int (*update)(void* engine, const char* json, char* error, size_t error_size);
|
|
38
|
-
int (*render)(void* engine, const dsh_frame_forwarding_target* target, char* error, size_t error_size);
|
|
39
|
-
} dsh_frame_forwarding_engine_v1;
|
|
40
|
-
/** Surface-free frame information borrowed during prepare(). */
|
|
41
|
-
typedef struct dsh_frame_forwarding_frame_info {
|
|
42
|
-
uint32_t width, height;
|
|
43
|
-
uint64_t input_sequence;
|
|
44
|
-
double time_seconds;
|
|
45
|
-
void* cancellation_context;
|
|
46
|
-
int (*cancelled)(void*);
|
|
47
|
-
} dsh_frame_forwarding_frame_info;
|
|
48
|
-
/** Engine ABI v2: base.version is 2 and base.size is sizeof(dsh_frame_forwarding_engine_v2).
|
|
49
|
-
* The v1 callbacks and ownership rules are unchanged. prepare runs on the same
|
|
50
|
-
* worker before acquiring a surface: 1 declares a changed frame, 0 declares no
|
|
51
|
-
* change, and -1 reports failure with diagnostic text. It must honor cancelled
|
|
52
|
-
* and must not acquire or access a transport surface. A declared change remains
|
|
53
|
-
* pending across credit waits; update may replace that pending application state
|
|
54
|
-
* before render. prepare continues at the stream cadence while credit is held.
|
|
55
|
-
* A successful render consumes the prepared state. Starting or
|
|
56
|
-
* resizing a stream forces one render even when prepare reports no change.
|
|
57
|
-
* Manual surface.render() invokes base.render directly, without prepare.
|
|
58
|
-
*/
|
|
59
|
-
typedef struct dsh_frame_forwarding_engine_v2 {
|
|
60
|
-
dsh_frame_forwarding_engine_v1 base;
|
|
61
|
-
int (*prepare)(void* engine, const dsh_frame_forwarding_frame_info* frame, char* error, size_t error_size);
|
|
62
|
-
} dsh_frame_forwarding_engine_v2;
|
|
63
|
-
#ifdef __cplusplus
|
|
64
|
-
}
|
|
65
|
-
#endif
|
|
66
|
-
#endif
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#ifndef DSH_FRAME_FORWARDING_NODE_H
|
|
2
|
-
#define DSH_FRAME_FORWARDING_NODE_H
|
|
3
|
-
#include <node_api.h>
|
|
4
|
-
#include "dsh_frame_forwarding_engine.h"
|
|
5
|
-
/** Shared type tag for engine objects produced by cooperating native addons. */
|
|
6
|
-
static const napi_type_tag dsh_frame_forwarding_engine_tag = {0xe1910c31bb654d4aULL, 0x9c30d42b2c88ee15ULL};
|
|
7
|
-
/** Export a native engine factory as an opaque JS object. The descriptor and its
|
|
8
|
-
* configuration must remain alive until finalize runs. The producer retains the
|
|
9
|
-
* object through native teardown. The addon supplying callbacks must remain
|
|
10
|
-
* loaded for the object's lifetime. No graphics work runs in this helper.
|
|
11
|
-
*/
|
|
12
|
-
static inline napi_status dsh_frame_forwarding_export_engine(napi_env env, dsh_frame_forwarding_engine_v1* factory,
|
|
13
|
-
napi_finalize finalize, void* hint, napi_value* result) {
|
|
14
|
-
napi_status status = napi_create_object(env, result);
|
|
15
|
-
if (status == napi_ok) status = napi_wrap(env, *result, factory, finalize, hint, NULL);
|
|
16
|
-
if (status == napi_ok) {
|
|
17
|
-
status = napi_type_tag_object(env, *result, &dsh_frame_forwarding_engine_tag);
|
|
18
|
-
if (status != napi_ok) { void* removed = NULL; napi_remove_wrap(env, *result, &removed); }
|
|
19
|
-
}
|
|
20
|
-
return status;
|
|
21
|
-
}
|
|
22
|
-
/** Export v2 with the same descriptor, configuration, and addon lifetime as v1. */
|
|
23
|
-
static inline napi_status dsh_frame_forwarding_export_engine_v2(napi_env env, dsh_frame_forwarding_engine_v2* factory,
|
|
24
|
-
napi_finalize finalize, void* hint, napi_value* result) {
|
|
25
|
-
return dsh_frame_forwarding_export_engine(env, &factory->base, finalize, hint, result);
|
|
26
|
-
}
|
|
27
|
-
#endif
|