Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 47 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ crate-type = ["cdylib"]

[dependencies]
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
napi-derive = "2.12.2"
napi = { version = "3.3.0", default-features = false, features = ["napi4"] }
napi-derive = "3.2.5"

syn = { version = "2.0", features = ["parsing", "visit"] }
bindgen = "0.72"
Expand Down
24 changes: 11 additions & 13 deletions packages/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
}
},
"napi": {
"name": "generator",
"triples": {
"additional": [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"i686-pc-windows-msvc"
]
}
"binaryName": "generator",
"targets": [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"i686-pc-windows-msvc"
]
Comment on lines +18 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Targets/optionalDependencies mismatch will skip key artifacts (darwin-x64, linux-x64-gnu, win32-x64).

napi.targets lacks:

  • x86_64-apple-darwin
  • x86_64-unknown-linux-gnu
  • x86_64-pc-windows-msvc

but these platforms exist in optionalDependencies. Add the missing triples or drop the corresponding optional deps to avoid broken installs.

Apply this diff to include the missing targets:

   "napi": {
     "binaryName": "generator",
     "targets": [
+      "x86_64-apple-darwin",
       "aarch64-apple-darwin",
       "aarch64-unknown-linux-gnu",
       "aarch64-unknown-linux-musl",
       "aarch64-pc-windows-msvc",
       "armv7-unknown-linux-gnueabihf",
+      "x86_64-unknown-linux-gnu",
       "x86_64-unknown-linux-musl",
+      "x86_64-pc-windows-msvc",
       "i686-pc-windows-msvc"
     ]
   },

🏁 Script executed:

#!/bin/bash
# Verify required targets exist for declared optionalDependencies
pkg=packages/generator/package.json
echo "Current targets:"; jq -r '.napi.targets[]' "$pkg" | sort
echo
echo "Checking for missing targets..."
missing=0
for t in x86_64-apple-darwin x86_64-unknown-linux-gnu x86_64-pc-windows-msvc; do
  if ! jq -re --arg t "$t" '.napi.targets[] | select(.==$t)' "$pkg" >/dev/null; then
    echo "MISSING: $t"
    missing=1
  fi
done
exit $missing

Length of output: 344


🏁 Script executed:

#!/bin/bash
set -euo pipefail
pkg=packages/generator/package.json

if [ ! -f "$pkg" ]; then
  echo "MISSING FILE: $pkg"
  exit 2
fi

echo "optionalDependencies keys:"
jq -r '.optionalDependencies // {} | keys[]' "$pkg" | sort || true
echo
echo "napi.targets:"
jq -r '.napi.targets[]' "$pkg" | sort || true
echo

check_triples=( "x86_64-apple-darwin" "x86_64-unknown-linux-gnu" "x86_64-pc-windows-msvc" )
for t in "${check_triples[@]}"; do
  present=$(jq -r --arg t "$t" 'any(.napi.targets[]; . == $t) // false' "$pkg")
  if [ "$present" = "true" ]; then
    echo "PRESENT: $t"
  else
    echo "MISSING: $t"
  fi
done

echo
echo "Optional deps with platform-like names:"
jq -r '.optionalDependencies // {} | keys[]' "$pkg" | grep -E 'x86_64|darwin|linux|windows|win32' || true

Length of output: 1161


Add missing x86_64 napi.targets to match optionalDependencies

napi.targets is missing x86_64 triples while optionalDependencies include x64 artifacts — installs will skip darwin-x64, linux-x64-gnu, and win32-x64.

  "napi": {
    "binaryName": "generator",
    "targets": [
+     "x86_64-apple-darwin",
      "aarch64-apple-darwin",
      "aarch64-unknown-linux-gnu",
      "aarch64-unknown-linux-musl",
      "aarch64-pc-windows-msvc",
      "armv7-unknown-linux-gnueabihf",
+     "x86_64-unknown-linux-gnu",
      "x86_64-unknown-linux-musl",
+     "x86_64-pc-windows-msvc",
      "i686-pc-windows-msvc"
    ]
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"binaryName": "generator",
"targets": [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"i686-pc-windows-msvc"
]
"binaryName": "generator",
"targets": [
"x86_64-apple-darwin",
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"x86_64-pc-windows-msvc",
"i686-pc-windows-msvc"
]
🤖 Prompt for AI Agents
In packages/generator/package.json around lines 18 to 27, the napi.targets array
omits x86_64 triples so x64 optionalDependencies (darwin-x64, linux-x64-gnu,
win32-x64) are skipped; add the corresponding targets to the array —
x86_64-apple-darwin, x86_64-unknown-linux-gnu, and x86_64-pc-windows-msvc —
alongside the existing arm/aarch64/i686 entries so installs include the x64
artifacts.

},
"files": [
"index.js",
Expand All @@ -40,7 +38,7 @@
"url": "git+https://github.com/ssssota/typed-cstruct.git"
},
"devDependencies": {
"@napi-rs/cli": "^2.18.4"
"@napi-rs/cli": "^3.2.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

CLI v3 upgrade: align Node engines with supported versions.

@napi-rs/cli@^3.2.0 typically requires newer Node; engines.node is still >= 10. Bump engines accordingly after confirming CLI v3 support matrix.

Proposed change (adjust the version per verification):

   "engines": {
-    "node": ">= 10"
+    "node": ">= 16"
   },

🌐 Web query:

What Node.js versions are supported by @napi-rs/cli v3.x, and what minimum Node version is recommended?

💡 Result:

  • Supported: Node.js 16 and newer (e.g. 16, 18, 20, 22). [1][2]
  • Recommended minimum: Node.js >= 16 (v3.x dropped support for older Node versions). [1]

Sources: changelog noting "requires node >= 16" for v3, and napi-rs docs showing Node support matrix. [1][2]


Bump engines.node to >=16 to match @napi-rs/cli v3 requirement.

Confirmed: @napi-rs/cli v3.x requires Node.js >=16 — update packages/generator/package.json (line ~41).

Proposed change:

  "engines": {
-    "node": ">= 10"
+    "node": ">= 16"
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@napi-rs/cli": "^3.2.0"
"engines": {
"node": ">= 16"
},
🤖 Prompt for AI Agents
In packages/generator/package.json around line 41, the project currently lists
"@napi-rs/cli": "^3.2.0" which requires Node.js >=16; update the package.json
engines field to require Node >=16 (e.g., "engines": { "node": ">=16" }) or add
an engines entry if missing so the package declares the correct minimum Node
version; ensure the version string follows existing formatting (e.g., ">=16" or
">=16.0.0") and run a quick install/test to confirm no other files need
adjustments.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

CLI v3 bump: double‑check Node engine floor.

@npm-rs/cli v3 may require newer Node than ">=10". Confirm and align engines if needed.


🌐 Web query:

What Node.js versions are supported by @napi-rs/cli v3.x, and are "napi.binaryName"/"napi.targets" the correct config keys in v3?

💡 Result:

Short answer:

  • Supported Node.js: napi v3 (used by NAPI‑RS v3 tooling) documents support for Node 12 through Node 22. [1]
  • Config keys in v3: yes — use napi.binaryName (replaces napi.name) and napi.targets (replaces napi.triples). See the v2→v3 migration docs and the CLI config schema. [2][3]

Sources:

  • Node support matrix (napi / napi-rs docs). [1]
  • v2 → v3 migration guide (shows napi.name → napi.binaryName and triples → targets). [2]
  • NAPI CLI config schema (shows binaryName and targets). [3]

Bump Node engine floor to >=12 and confirm N-API v3 keys

packages/generator/package.json — change "engines.node" from ">=10" to ">=12" to match @napi-rs/cli v3; verify N-API config uses napi.binaryName and napi.targets (v3 migration).

🤖 Prompt for AI Agents
In packages/generator/package.json around line 41, update the engines.node field
from ">=10" to ">=12" to match the @napi-rs/cli v3 requirement, and verify or
migrate the N-API configuration to use the v3 keys: ensure package.json uses
"napi.binaryName" (not old key names) and "napi.targets" (an array of target
triples) for prebuilds; adjust any existing napi config to these keys, bump any
related docs or CI Node versions, and run a local install/build to confirm
native builds still succeed.

},
"engines": {
"node": ">= 10"
Expand Down
15 changes: 11 additions & 4 deletions packages/generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ fn well_known_or(ty: &str) -> String {

#[napi]
pub fn generate(
headers: Vec<&str>,
headers: Vec<String>,
dump_rust_code: Option<bool>,
clang_args: Option<Vec<&str>>,
entry_types: Option<Vec<&str>>,
clang_args: Option<Vec<String>>,
entry_types: Option<Vec<String>>,
) -> Result<String> {
let bindings = bindgen::builder()
.clang_args(clang_args.unwrap_or_default())
Expand All @@ -104,7 +104,14 @@ pub fn generate(
}

// Ok(rust)
rust_to_ts(&rust, entry_types.unwrap_or_default())
rust_to_ts(
&rust,
entry_types
.unwrap_or_default()
.iter()
.map(|s| s.as_str())
.collect(),
)
}

struct Entity {
Expand Down
Loading
Loading