Skip to content

feat: impl float-pigment-css-napi#36

Open
TtTRz wants to merge 1 commit into
masterfrom
feat-float-pigment-css-napi
Open

feat: impl float-pigment-css-napi#36
TtTRz wants to merge 1 commit into
masterfrom
feat-float-pigment-css-napi

Conversation

@TtTRz
Copy link
Copy Markdown
Member

@TtTRz TtTRz commented May 29, 2026

No description provided.

Copy link
Copy Markdown

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 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-"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants