Skip to content

Conversation

@kraenhansen
Copy link
Collaborator

More refactoring (following up on #327 and #328), preparing for #329.

@kraenhansen kraenhansen self-assigned this Nov 13, 2025
@kraenhansen kraenhansen added C++ Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) weak-node-api labels Nov 13, 2025
@kraenhansen kraenhansen requested a review from Copilot November 13, 2025 10:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the weak-node-api package by renaming WeakNodeApiHost to NodeApiHost and reorganizing code generation. The changes improve code organization by separating the NodeApiHost struct generation into its own file and enhancing generated file documentation with structured comments.

Key changes:

  • Renamed WeakNodeApiHost to NodeApiHost throughout the codebase
  • Extracted NodeApiHost struct generation to a dedicated generator file
  • Added JSDoc-style file headers to all generated files
  • Consolidated npm scripts with consistent naming conventions (e.g., prebuild:* prefix)

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/weak-node-api/tests/test_inject.cpp Updated test references from WeakNodeApiHost to NodeApiHost
packages/weak-node-api/scripts/generators/weak-node-api.ts Removed NodeApiHost struct generation, now imports from separate file
packages/weak-node-api/scripts/generators/NodeApiHost.ts New file containing extracted NodeApiHost struct generation logic
packages/weak-node-api/scripts/generate.ts Added file header generation with JSDoc comments for all output files
packages/weak-node-api/package.json Renamed scripts to use consistent prebuild:* and generate naming
packages/weak-node-api/CMakeLists.txt Added NodeApiHost.hpp to the list of public headers
packages/weak-node-api/.gitignore Simplified to ignore entire /generated/ directory
packages/host/scripts/generate-injector.mts Updated struct name from WeakNodeApiHost to NodeApiHost
packages/host/package.json Renamed script to injector:generate for consistency
package.json Removed unused prerelease script
.github/workflows/check.yml Updated workflow to use renamed npm scripts
.changeset/slimy-parts-admire.md Changeset documenting the rename

@kraenhansen kraenhansen changed the title Kh/weak node api refactored generator 3 More refactoring of the weak-node-api generator Nov 13, 2025
@kraenhansen kraenhansen force-pushed the kh/weak-node-api-refactored-generator-3 branch from cf5e056 to bd952a6 Compare November 13, 2025 13:58
@kraenhansen kraenhansen marked this pull request as draft November 14, 2025 23:27
@kraenhansen
Copy link
Collaborator Author

Putting this back in draft, since the the new name is crashing with symbols in the host package 🙃

@kraenhansen kraenhansen force-pushed the kh/weak-node-api-refactored-generator-3 branch from bd952a6 to 4ab6985 Compare November 15, 2025 06:00
@kraenhansen kraenhansen force-pushed the kh/weak-node-api-refactored-generator-3 branch from 4ab6985 to 0e545a5 Compare November 15, 2025 06:26
@kraenhansen kraenhansen marked this pull request as ready for review November 15, 2025 09:15
@kraenhansen kraenhansen requested a review from Copilot November 15, 2025 09:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

* Generates source code for a version script for the given Node API version.
*/
export function generateHeader(functions: FunctionDecl[]) {
export function generateHeader() {
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

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

The generateHeader function signature has been changed to accept no parameters, but it's still being called with a functions parameter in generate.ts (line 73). This will cause the functions parameter to be ignored, though the code may still work. Update the call site to pass no arguments, or restore the parameter if it's needed for future use.

Copilot uses AI. Check for mistakes.
"test:gradle": "ENABLE_GRADLE_TESTS=true node --run test",
"bootstrap": "node --run generate-weak-node-api-injector",
"prerelease": "node --run generate-weak-node-api-injector"
"bootstrap": "node --run injector:generate"
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

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

The prerelease script has been removed from this package's scripts, but it's still referenced (and removed) in the root package.json. Ensure that the build/release pipeline doesn't depend on this script, as workspace packages may have had individual prerelease tasks that are no longer executed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) C++ weak-node-api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants