@zealakit/css-doctor-binding 1.0.0 → 1.1.0
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/css-doctor-binding.darwin-arm64.node +0 -0
- package/index.d.ts +235 -0
- package/index.js +10 -1
- package/package.json +29 -6
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -296,3 +296,238 @@ export interface JsPipelineOutput {
|
|
|
296
296
|
* stylesheet/AST cannot be processed.
|
|
297
297
|
*/
|
|
298
298
|
export declare function optimizeCss(input: JsPipelineInput): JsPipelineOutput
|
|
299
|
+
/** Combined pipeline output + optimization report from a single native run. */
|
|
300
|
+
export interface JsOptimizeExplained {
|
|
301
|
+
pipeline: JsPipelineOutput
|
|
302
|
+
reportJson: string
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Runs the optimization pipeline once and returns both chunks and a report.
|
|
306
|
+
*
|
|
307
|
+
* Prefer this over calling [`optimize_css`] and [`optimize_css_report`]
|
|
308
|
+
* separately to avoid double parsing/splitting.
|
|
309
|
+
*
|
|
310
|
+
* # Errors
|
|
311
|
+
*
|
|
312
|
+
* Rejects when the pipeline or report builder fails.
|
|
313
|
+
*/
|
|
314
|
+
export declare function optimizeCssExplained(input: JsPipelineInput, maxSelectorDecisions?: number | undefined | null): JsOptimizeExplained
|
|
315
|
+
/**
|
|
316
|
+
* Runs the optimization pipeline and returns a versioned report JSON document
|
|
317
|
+
* that includes decisions, metrics, and chunk inventory.
|
|
318
|
+
*
|
|
319
|
+
* # Errors
|
|
320
|
+
*
|
|
321
|
+
* Rejects when the pipeline or report builder fails.
|
|
322
|
+
*/
|
|
323
|
+
export declare function optimizeCssReport(input: JsPipelineInput, maxSelectorDecisions?: number | undefined | null): string
|
|
324
|
+
/** Lists built-in autofix rules as JSON. */
|
|
325
|
+
export declare function listCssFixes(): string
|
|
326
|
+
/** Autofix input. */
|
|
327
|
+
export interface JsFixInput {
|
|
328
|
+
cssContent: string
|
|
329
|
+
filePath?: string
|
|
330
|
+
dryRun?: boolean
|
|
331
|
+
rules?: Array<string>
|
|
332
|
+
includeReview?: boolean
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Plans or applies safe CSS autofixes. Returns a JSON `FixApplicationResult`.
|
|
336
|
+
*
|
|
337
|
+
* # Errors
|
|
338
|
+
*
|
|
339
|
+
* Rejects for parse/serialize failures or unsafe rule selection.
|
|
340
|
+
*/
|
|
341
|
+
export declare function applyCssFixes(input: JsFixInput): string
|
|
342
|
+
/** Optional weights for CSS Health Score dimensions (must be >= 0). */
|
|
343
|
+
export interface JsHealthWeights {
|
|
344
|
+
selectorComplexity?: number
|
|
345
|
+
duplicateRules?: number
|
|
346
|
+
cssSizeEfficiency?: number
|
|
347
|
+
deadCss?: number
|
|
348
|
+
variableConsistency?: number
|
|
349
|
+
}
|
|
350
|
+
/** Optional thresholds for CSS Health Score analyzers. */
|
|
351
|
+
export interface JsHealthThresholds {
|
|
352
|
+
highSpecificityClasses?: number
|
|
353
|
+
highSpecificityIds?: number
|
|
354
|
+
deepCombinatorCount?: number
|
|
355
|
+
deepNestingDepth?: number
|
|
356
|
+
longSelectorTokenCount?: number
|
|
357
|
+
largeStylesheetBytes?: number
|
|
358
|
+
criticalStylesheetBytes?: number
|
|
359
|
+
heavyRuleDeclarations?: number
|
|
360
|
+
manySelectors?: number
|
|
361
|
+
}
|
|
362
|
+
/** Input for [`evaluate_css_health`]. */
|
|
363
|
+
export interface JsHealthInput {
|
|
364
|
+
cssContent: string
|
|
365
|
+
filePath?: string
|
|
366
|
+
sizeBytes?: number
|
|
367
|
+
weights?: JsHealthWeights
|
|
368
|
+
thresholds?: JsHealthThresholds
|
|
369
|
+
}
|
|
370
|
+
/** One health diagnostic finding. */
|
|
371
|
+
export interface JsHealthDiagnostic {
|
|
372
|
+
code: string
|
|
373
|
+
severity: string
|
|
374
|
+
category: string
|
|
375
|
+
message: string
|
|
376
|
+
filePath?: string
|
|
377
|
+
location?: JsSourceLocation
|
|
378
|
+
selector?: string
|
|
379
|
+
remediation: string
|
|
380
|
+
certainty: string
|
|
381
|
+
}
|
|
382
|
+
/** Score metadata for one health dimension. */
|
|
383
|
+
export interface JsDimensionScore {
|
|
384
|
+
id: string
|
|
385
|
+
score?: number
|
|
386
|
+
weight: number
|
|
387
|
+
effectiveWeight: number
|
|
388
|
+
evaluated: boolean
|
|
389
|
+
issueCount: number
|
|
390
|
+
errorCount: number
|
|
391
|
+
warningCount: number
|
|
392
|
+
infoCount: number
|
|
393
|
+
diagnosticCodes: Array<string>
|
|
394
|
+
recommendations: Array<string>
|
|
395
|
+
note?: string
|
|
396
|
+
}
|
|
397
|
+
/** Aggregate counters for a health report. */
|
|
398
|
+
export interface JsHealthScoreSummary {
|
|
399
|
+
files: number
|
|
400
|
+
rules: number
|
|
401
|
+
selectors: number
|
|
402
|
+
declarations: number
|
|
403
|
+
sizeBytes: number
|
|
404
|
+
errors: number
|
|
405
|
+
warnings: number
|
|
406
|
+
suggestions: number
|
|
407
|
+
analysisMs: number
|
|
408
|
+
}
|
|
409
|
+
/** Complete CSS Health Score report. */
|
|
410
|
+
export interface JsHealthReport {
|
|
411
|
+
schemaVersion: number
|
|
412
|
+
overall: number
|
|
413
|
+
grade: string
|
|
414
|
+
status: string
|
|
415
|
+
dimensions: Array<JsDimensionScore>
|
|
416
|
+
summary: JsHealthScoreSummary
|
|
417
|
+
diagnostics: Array<JsHealthDiagnostic>
|
|
418
|
+
recommendations: Array<string>
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Evaluates CSS Health Score for a single stylesheet.
|
|
422
|
+
*
|
|
423
|
+
* # Errors
|
|
424
|
+
*
|
|
425
|
+
* Rejects when configuration is invalid or CSS cannot be parsed.
|
|
426
|
+
*/
|
|
427
|
+
export declare function evaluateCssHealth(input: JsHealthInput): JsHealthReport
|
|
428
|
+
/** One stylesheet entry for multi-file health evaluation. */
|
|
429
|
+
export interface JsHealthFileInput {
|
|
430
|
+
cssContent: string
|
|
431
|
+
filePath?: string
|
|
432
|
+
sizeBytes?: number
|
|
433
|
+
}
|
|
434
|
+
/** Multi-file health evaluation input. */
|
|
435
|
+
export interface JsHealthBatchInput {
|
|
436
|
+
files: Array<JsHealthFileInput>
|
|
437
|
+
weights?: JsHealthWeights
|
|
438
|
+
thresholds?: JsHealthThresholds
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Evaluates and merges CSS Health Score across multiple stylesheets.
|
|
442
|
+
*
|
|
443
|
+
* # Errors
|
|
444
|
+
*
|
|
445
|
+
* Rejects when configuration is invalid or any stylesheet cannot be parsed.
|
|
446
|
+
*/
|
|
447
|
+
export declare function evaluateCssHealthBatch(input: JsHealthBatchInput): JsHealthReport
|
|
448
|
+
/** File entry used when creating a baseline document. */
|
|
449
|
+
export interface JsBaselineFileInput {
|
|
450
|
+
path: string
|
|
451
|
+
cssContent: string
|
|
452
|
+
sizeBytes?: number
|
|
453
|
+
}
|
|
454
|
+
/** Optional Git metadata for a baseline. */
|
|
455
|
+
export interface JsBaselineGitMetadata {
|
|
456
|
+
commit?: string
|
|
457
|
+
branch?: string
|
|
458
|
+
dirty?: boolean
|
|
459
|
+
}
|
|
460
|
+
/** Optional project metadata for a baseline. */
|
|
461
|
+
export interface JsBaselineProjectMetadata {
|
|
462
|
+
name?: string
|
|
463
|
+
root?: string
|
|
464
|
+
}
|
|
465
|
+
/** Input for [`create_baseline`]. */
|
|
466
|
+
export interface JsBaselineCreateInput {
|
|
467
|
+
files: Array<JsBaselineFileInput>
|
|
468
|
+
toolVersion: string
|
|
469
|
+
createdAt?: string
|
|
470
|
+
patterns?: Array<string>
|
|
471
|
+
threshold?: number
|
|
472
|
+
project?: JsBaselineProjectMetadata
|
|
473
|
+
git?: JsBaselineGitMetadata
|
|
474
|
+
weights?: JsHealthWeights
|
|
475
|
+
thresholds?: JsHealthThresholds
|
|
476
|
+
}
|
|
477
|
+
/** Validation outcome for a baseline document. */
|
|
478
|
+
export interface JsBaselineValidationResult {
|
|
479
|
+
status: string
|
|
480
|
+
message?: string
|
|
481
|
+
}
|
|
482
|
+
/** Comparison tolerances for regression detection. */
|
|
483
|
+
export interface JsCompareOptions {
|
|
484
|
+
scoreTolerance?: number
|
|
485
|
+
sizeAbsoluteToleranceBytes?: number
|
|
486
|
+
sizeIncreasePercent?: number
|
|
487
|
+
countAbsoluteTolerance?: number
|
|
488
|
+
countIncreasePercent?: number
|
|
489
|
+
}
|
|
490
|
+
/** Minimum dimension score gate. */
|
|
491
|
+
export interface JsMinDimensionScore {
|
|
492
|
+
id: string
|
|
493
|
+
minScore: number
|
|
494
|
+
}
|
|
495
|
+
/** Quality-gate configuration for regression comparison. */
|
|
496
|
+
export interface JsQualityGateConfig {
|
|
497
|
+
minScore?: number
|
|
498
|
+
minDimensionScores?: Array<JsMinDimensionScore>
|
|
499
|
+
maxCssSize?: number
|
|
500
|
+
maxSizeIncreasePercent?: number
|
|
501
|
+
maxNewErrors?: number
|
|
502
|
+
maxNewWarnings?: number
|
|
503
|
+
failOnRegression?: boolean
|
|
504
|
+
failOnNewErrors?: boolean
|
|
505
|
+
failOnNewDiagnostics?: boolean
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Creates a versioned baseline JSON document from CSS files.
|
|
509
|
+
*
|
|
510
|
+
* # Errors
|
|
511
|
+
*
|
|
512
|
+
* Rejects when configuration is invalid, CSS cannot be parsed, or
|
|
513
|
+
* serialization fails.
|
|
514
|
+
*/
|
|
515
|
+
export declare function createBaseline(input: JsBaselineCreateInput): string
|
|
516
|
+
/**
|
|
517
|
+
* Validates a baseline JSON document.
|
|
518
|
+
*
|
|
519
|
+
* # Errors
|
|
520
|
+
*
|
|
521
|
+
* Rejects when the JSON cannot be parsed.
|
|
522
|
+
*/
|
|
523
|
+
export declare function validateBaseline(baselineJson: string, toolVersion: string): JsBaselineValidationResult
|
|
524
|
+
/**
|
|
525
|
+
* Compares a stored baseline against a current baseline snapshot.
|
|
526
|
+
*
|
|
527
|
+
* Returns a versioned regression report as pretty JSON.
|
|
528
|
+
*
|
|
529
|
+
* # Errors
|
|
530
|
+
*
|
|
531
|
+
* Rejects when either document is invalid JSON or options are invalid.
|
|
532
|
+
*/
|
|
533
|
+
export declare function compareBaselines(baselineJson: string, currentJson: string, options?: JsCompareOptions | undefined | null, gates?: JsQualityGateConfig | undefined | null): string
|
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { JsSelectorKind, analyzeCss, analyzeCssAsync, analyzeCssJson, splitCssByPages, JsPipelineChunkKind, optimizeCss } = nativeBinding
|
|
313
|
+
const { JsSelectorKind, analyzeCss, analyzeCssAsync, analyzeCssJson, splitCssByPages, JsPipelineChunkKind, optimizeCss, optimizeCssExplained, optimizeCssReport, listCssFixes, applyCssFixes, evaluateCssHealth, evaluateCssHealthBatch, createBaseline, validateBaseline, compareBaselines } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.JsSelectorKind = JsSelectorKind
|
|
316
316
|
module.exports.analyzeCss = analyzeCss
|
|
@@ -319,3 +319,12 @@ module.exports.analyzeCssJson = analyzeCssJson
|
|
|
319
319
|
module.exports.splitCssByPages = splitCssByPages
|
|
320
320
|
module.exports.JsPipelineChunkKind = JsPipelineChunkKind
|
|
321
321
|
module.exports.optimizeCss = optimizeCss
|
|
322
|
+
module.exports.optimizeCssExplained = optimizeCssExplained
|
|
323
|
+
module.exports.optimizeCssReport = optimizeCssReport
|
|
324
|
+
module.exports.listCssFixes = listCssFixes
|
|
325
|
+
module.exports.applyCssFixes = applyCssFixes
|
|
326
|
+
module.exports.evaluateCssHealth = evaluateCssHealth
|
|
327
|
+
module.exports.evaluateCssHealthBatch = evaluateCssHealthBatch
|
|
328
|
+
module.exports.createBaseline = createBaseline
|
|
329
|
+
module.exports.validateBaseline = validateBaseline
|
|
330
|
+
module.exports.compareBaselines = compareBaselines
|
package/package.json
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zealakit/css-doctor-binding",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Native Node.js bindings for the css-doctor CSS analysis engine",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css",
|
|
7
|
+
"css-doctor",
|
|
8
|
+
"css-analysis",
|
|
9
|
+
"css-optimizer",
|
|
10
|
+
"dead-code-elimination",
|
|
11
|
+
"unused-css",
|
|
12
|
+
"purgecss",
|
|
13
|
+
"critical-css",
|
|
14
|
+
"css-splitting",
|
|
15
|
+
"page-coverage",
|
|
16
|
+
"lightningcss",
|
|
17
|
+
"native-addon",
|
|
18
|
+
"napi",
|
|
19
|
+
"napi-rs",
|
|
20
|
+
"rust",
|
|
21
|
+
"nodejs",
|
|
22
|
+
"performance",
|
|
23
|
+
"web-performance",
|
|
24
|
+
"stylesheet",
|
|
25
|
+
"frontend"
|
|
26
|
+
],
|
|
5
27
|
"author": "nqhed - Huy Edward Nguyen",
|
|
6
28
|
"license": "MIT",
|
|
7
29
|
"main": "index.js",
|
|
@@ -14,6 +36,7 @@
|
|
|
14
36
|
"files": [
|
|
15
37
|
"index.js",
|
|
16
38
|
"index.d.ts",
|
|
39
|
+
"index.d.cts",
|
|
17
40
|
"*.node",
|
|
18
41
|
"README.md",
|
|
19
42
|
"README_VI.md",
|
|
@@ -38,11 +61,11 @@
|
|
|
38
61
|
"access": "public"
|
|
39
62
|
},
|
|
40
63
|
"optionalDependencies": {
|
|
41
|
-
"@zealakit/css-doctor-binding-darwin-arm64": "1.
|
|
42
|
-
"@zealakit/css-doctor-binding-darwin-x64": "1.
|
|
43
|
-
"@zealakit/css-doctor-binding-linux-x64-gnu": "1.
|
|
44
|
-
"@zealakit/css-doctor-binding-linux-x64-musl": "1.
|
|
45
|
-
"@zealakit/css-doctor-binding-win32-x64-msvc": "1.
|
|
64
|
+
"@zealakit/css-doctor-binding-darwin-arm64": "1.1.0",
|
|
65
|
+
"@zealakit/css-doctor-binding-darwin-x64": "1.1.0",
|
|
66
|
+
"@zealakit/css-doctor-binding-linux-x64-gnu": "1.1.0",
|
|
67
|
+
"@zealakit/css-doctor-binding-linux-x64-musl": "1.1.0",
|
|
68
|
+
"@zealakit/css-doctor-binding-win32-x64-msvc": "1.1.0"
|
|
46
69
|
},
|
|
47
70
|
"bugs": {
|
|
48
71
|
"url": "https://github.com/zealakit/css-doctor/issues"
|