feat: impl float-pigment-css-napi#36
Open
TtTRz wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new float-pigment-css-napi workspace crate that exposes float-pigment-css compilation through Node.js N-API bindings, alongside build scripts, package metadata, and documentation for distributing native prebuilds.
Changes:
- Adds synchronous and asynchronous N-API exports for batch and single-file CSS compilation.
- Adds Node package files, TypeScript declarations, loader logic, and build/postbuild scripts.
- Updates workspace membership and lockfile dependencies for the new crate.
Reviewed changes
Copilot reviewed 15 out of 22 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Adds the new N-API crate to the Rust workspace. |
Cargo.lock |
Locks new N-API-related Rust dependencies. |
float-pigment-css-napi/Cargo.toml |
Defines the new cdylib crate and dependencies. |
float-pigment-css-napi/build.rs |
Configures napi-rs build setup. |
float-pigment-css-napi/src/lib.rs |
Implements N-API compile APIs and async tasks. |
float-pigment-css-napi/index.js |
Loads the platform-specific native binding. |
float-pigment-css-napi/package.json |
Defines npm package metadata and scripts. |
float-pigment-css-napi/pnpm-lock.yaml |
Locks the NAPI CLI dev dependency. |
float-pigment-css-napi/type.d.ts |
Adds generated TypeScript declarations. |
float-pigment-css-napi/tsconfig.json |
Adds TypeScript config for declarations. |
float-pigment-css-napi/scripts/build-all.js |
Adds multi-target native build script. |
float-pigment-css-napi/scripts/build-current.js |
Adds current-platform build script. |
float-pigment-css-napi/scripts/build-target.js |
Adds target-specific build script. |
float-pigment-css-napi/scripts/postbuild.js |
Moves generated .node files into prebuild layout. |
float-pigment-css-napi/README.md |
Documents usage, API, and build process in English. |
float-pigment-css-napi/README_CN.md |
Documents usage, API, and build process in Chinese. |
float-pigment-css-napi/.gitignore |
Ignores local Node/build artifacts. |
float-pigment-css-napi/.npmignore |
Excludes source/build files from npm package contents. |
Files not reviewed (1)
- float-pigment-css-napi/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+23
| execSync( | ||
| `${napi} build --platform --release --target ${target} --js false --dts type.d.ts`, | ||
| { cwd: root, stdio: 'inherit' } |
Comment on lines
+32
to
+34
| execSync( | ||
| `${napi} build --platform ${profile} --target ${target} --js false --dts type.d.ts`, | ||
| { cwd: root, stdio: 'inherit' } |
Comment on lines
+19
to
+21
| execSync( | ||
| `${napi} build --platform --release --target ${target} --js false --dts type.d.ts`, | ||
| { cwd: root, stdio: 'inherit' } |
Comment on lines
+186
to
+188
| #[napi] | ||
| pub fn compile_sync(args: CompileArgument) -> Result<CompileResult> { | ||
| do_compile(args) |
Comment on lines
+141
to
+160
| interface CompileResult { | ||
| files: FileEntry[] | ||
| importIndex: Buffer | null | ||
| } | ||
|
|
||
| interface FileEntry { | ||
| path: string | ||
| file: FileResult | ||
| } | ||
|
|
||
| interface CompileSingleArgument { | ||
| fileName: string | ||
| fileContent: Buffer | ||
| outputType: OutputType | ||
| tagNamePrefix?: string // default: "wx-" | ||
| } | ||
|
|
||
| interface FileResult { | ||
| content: Buffer | null | ||
| warnings: CompileWarning[] |
Comment on lines
+141
to
+160
| interface CompileResult { | ||
| files: FileEntry[] | ||
| importIndex: Buffer | null | ||
| } | ||
|
|
||
| interface FileEntry { | ||
| path: string | ||
| file: FileResult | ||
| } | ||
|
|
||
| interface CompileSingleArgument { | ||
| fileName: string | ||
| fileContent: Buffer | ||
| outputType: OutputType | ||
| tagNamePrefix?: string // 默认: "wx-" | ||
| } | ||
|
|
||
| interface FileResult { | ||
| content: Buffer | null | ||
| warnings: CompileWarning[] |
Comment on lines
+100
to
+104
| const fileSync = compileSingleSync({ | ||
| fileName: 'app.wxss', | ||
| fileContent: Buffer.from('body { font-size: 14px; }'), | ||
| outputType: 'none', // validation only, content will be null | ||
| }) |
Comment on lines
+100
to
+104
| const fileSync = compileSingleSync({ | ||
| fileName: 'app.wxss', | ||
| fileContent: Buffer.from('body { font-size: 14px; }'), | ||
| outputType: 'none', // 仅校验,content 为 null | ||
| }) |
Comment on lines
+127
to
+133
| ```typescript | ||
| type OutputType = 'bincode' | 'json' | 'none' | ||
|
|
||
| interface CompileArgument { | ||
| src: SourceEntry[] | ||
| outputType: OutputType | ||
| tagNamePrefix?: string // default: "wx-" |
Comment on lines
+127
to
+133
| ```typescript | ||
| type OutputType = 'bincode' | 'json' | 'none' | ||
|
|
||
| interface CompileArgument { | ||
| src: SourceEntry[] | ||
| outputType: OutputType | ||
| tagNamePrefix?: string // 默认: "wx-" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.