prosemirror-rs 0.3.0 → 0.3.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/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "prosemirror-rs-node"
3
- version = "0.3.0"
3
+ version = "0.3.4"
4
4
  authors = [
5
5
  "Johannes Wilm <johannes@fiduswriter.org>",
6
6
  "Daniel Seiler <me@dseiler.eu>",
package/copy-artifact.mjs CHANGED
@@ -4,23 +4,42 @@
4
4
  * The filename follows the napi-rs triple convention so that index.js can
5
5
  * load the correct binary at runtime. Called automatically by `npm run build`
6
6
  * after `cargo build --release`.
7
+ *
8
+ * Environment variables (optional, used in CI):
9
+ * RUST_TARGET – cross-compilation target, e.g. "aarch64-unknown-linux-gnu"
10
+ * When set, the binary is looked up under
11
+ * target/<RUST_TARGET>/release/ instead of target/release/.
7
12
  */
8
- import { cpSync } from 'fs';
13
+ import { cpSync, existsSync } from 'fs';
9
14
  import { platform, arch } from 'os';
10
15
  import { fileURLToPath } from 'url';
11
16
  import { join, dirname } from 'path';
12
17
 
13
18
  const __dirname = dirname(fileURLToPath(import.meta.url));
14
19
 
15
- // Map OS shared library extension
16
- function libExtension() {
20
+ // ── Per-platform helper: shared library filename (without path) ───────────
21
+ // Windows: prosemirror_rs.dll (no lib- prefix)
22
+ // macOS: libprosemirror_rs.dylib
23
+ // Linux: libprosemirror_rs.so
24
+ function libFilename() {
17
25
  const p = platform();
18
- if (p === 'win32') return '.dll';
19
- if (p === 'darwin') return '.dylib';
20
- return '.so';
26
+ if (p === 'win32') return 'prosemirror_rs.dll';
27
+ if (p === 'darwin') return 'libprosemirror_rs.dylib';
28
+ return 'libprosemirror_rs.so';
29
+ }
30
+
31
+ // ── Build directory ──────────────────────────────────────────────────────
32
+ // When cross-compiling, cargo places output under target/<rust_target>/release/
33
+ // instead of target/release/.
34
+ function buildDir() {
35
+ const rustTarget = process.env.RUST_TARGET;
36
+ if (rustTarget) {
37
+ return join(__dirname, '..', 'target', rustTarget, 'release');
38
+ }
39
+ return join(__dirname, '..', 'target', 'release');
21
40
  }
22
41
 
23
- // Map Node platform+arch napi-rs triple
42
+ // ── napi-rs platform triple for the output file ──────────────────────────
24
43
  function triple() {
25
44
  const p = platform();
26
45
  const a = arch();
@@ -32,8 +51,18 @@ function triple() {
32
51
  throw new Error(`Unsupported platform/arch: ${p}-${a}`);
33
52
  }
34
53
 
35
- const src = join(__dirname, '..', 'target', 'release', `libprosemirror_rs${libExtension()}`);
54
+ const src = join(buildDir(), libFilename());
36
55
  const dest = join(__dirname, `prosemirror-rs.${triple()}.node`);
37
56
 
57
+ if (!existsSync(src)) {
58
+ console.error(`ERROR: compiled artifact not found at ${src}`);
59
+ console.error('');
60
+ console.error('Make sure cargo build --release completed successfully first.');
61
+ if (process.env.RUST_TARGET) {
62
+ console.error(`(RUST_TARGET=${process.env.RUST_TARGET} is set)`);
63
+ }
64
+ process.exit(1);
65
+ }
66
+
38
67
  cpSync(src, dest);
39
- console.log(`Copied ${src} → ${dest}`);
68
+ console.log(`Copied ${src} → ${dest}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-rs",
3
- "version": "0.3.0",
3
+ "version": "0.3.4",
4
4
  "description": "Node.js bindings for prosemirror-rs: a Rust implementation of ProseMirror's document model and transform pipeline",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
Binary file
Binary file