@animus-ui/extract 0.1.0-next.v7 → 0.1.1-beta.2

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // @ts-nocheck
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- const { readFileSync } = require('node:fs')
6
+ const { readFileSync } = require('fs')
7
7
  let nativeBinding = null
8
8
  const loadErrors = []
9
9
 
@@ -33,7 +33,7 @@ const isMuslFromFilesystem = () => {
33
33
 
34
34
  const isMuslFromReport = () => {
35
35
  let report = null
36
- if (typeof process.report?.getReport === 'function') {
36
+ if (process.report && typeof process.report.getReport === 'function') {
37
37
  process.report.excludeNetwork = true
38
38
  report = process.report.getReport()
39
39
  }
@@ -105,7 +105,7 @@ function requireNative() {
105
105
  }
106
106
  } else if (process.platform === 'win32') {
107
107
  if (process.arch === 'x64') {
108
- if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
108
+ if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
109
109
  try {
110
110
  return require('./animus-extract.win32-x64-gnu.node')
111
111
  } catch (e) {
@@ -525,23 +525,33 @@ function requireNative() {
525
525
 
526
526
  nativeBinding = requireNative()
527
527
 
528
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
528
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
529
+ // unset / any other value → native binding preferred, WASI is only a fallback
530
+ // 'true' → force WASI fallback even if native loaded
531
+ // 'error' → force WASI and throw if no WASI binding is found
532
+ // Treating any non-empty string as truthy (the historical behavior) meant
533
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
534
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
535
+ const forceWasi =
536
+ process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
537
+
538
+ if (!nativeBinding || forceWasi) {
529
539
  let wasiBinding = null
530
540
  let wasiBindingError = null
531
541
  try {
532
542
  wasiBinding = require('./animus-extract.wasi.cjs')
533
543
  nativeBinding = wasiBinding
534
544
  } catch (err) {
535
- if (process.env.NAPI_RS_FORCE_WASI) {
545
+ if (forceWasi) {
536
546
  wasiBindingError = err
537
547
  }
538
548
  }
539
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
549
+ if (!nativeBinding || forceWasi) {
540
550
  try {
541
551
  wasiBinding = require('@animus-ui/extract-wasm32-wasi')
542
552
  nativeBinding = wasiBinding
543
553
  } catch (err) {
544
- if (process.env.NAPI_RS_FORCE_WASI) {
554
+ if (forceWasi) {
545
555
  if (!wasiBindingError) {
546
556
  wasiBindingError = err
547
557
  } else {
@@ -560,17 +570,18 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
560
570
 
561
571
  if (!nativeBinding) {
562
572
  if (loadErrors.length > 0) {
563
- throw new Error(
573
+ const error = new Error(
564
574
  `Cannot find native binding. ` +
565
575
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
566
576
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
567
- {
568
- cause: loadErrors.reduce((err, cur) => {
569
- cur.cause = err
570
- return cur
571
- }),
572
- },
573
577
  )
578
+ // assign instead of the `new Error(message, { cause })` options form,
579
+ // which Node < 16.9 silently ignores
580
+ error.cause = loadErrors.reduce((err, cur) => {
581
+ cur.cause = err
582
+ return cur
583
+ })
584
+ throw error
574
585
  }
575
586
  throw new Error(`Failed to load native binding`)
576
587
  }
@@ -579,4 +590,5 @@ module.exports = nativeBinding
579
590
  module.exports.analyzeProject = nativeBinding.analyzeProject
580
591
  module.exports.clearAnalysisCache = nativeBinding.clearAnalysisCache
581
592
  module.exports.extract = nativeBinding.extract
593
+ module.exports.loadSystemModule = nativeBinding.loadSystemModule
582
594
  module.exports.transformFile = nativeBinding.transformFile
package/package.json CHANGED
@@ -1,22 +1,85 @@
1
1
  {
2
2
  "name": "@animus-ui/extract",
3
- "version": "0.1.0-next.v7",
3
+ "version": "0.1.1-beta.2",
4
4
  "description": "Animus static CSS extraction pipeline (Rust/NAPI)",
5
- "author": "codecaaron <airrobb@gmail.com>",
5
+ "keywords": [
6
+ "animus",
7
+ "compiler",
8
+ "css",
9
+ "css-in-js",
10
+ "napi",
11
+ "rust",
12
+ "static-css",
13
+ "zero-runtime"
14
+ ],
15
+ "homepage": "https://github.com/codecaaron/animus/tree/main/packages/extract#readme",
6
16
  "license": "MIT",
7
- "main": "index.js",
8
- "types": "index.d.ts",
17
+ "author": "codecaaron <airrobb@gmail.com>",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/codecaaron/animus",
21
+ "directory": "packages/extract"
22
+ },
9
23
  "files": [
10
24
  "index.js",
11
25
  "index.d.ts",
12
- "*.node"
26
+ "*.node",
27
+ "dist",
28
+ "index-v2.js",
29
+ "index-v2.d.ts",
30
+ "crates/extract-v2/*.node",
31
+ "crates/extract-v2/index.d.ts"
13
32
  ],
33
+ "main": "index.js",
34
+ "types": "index.d.ts",
35
+ "exports": {
36
+ ".": {
37
+ "import": "./index.js",
38
+ "require": "./index.js",
39
+ "default": "./index.js"
40
+ },
41
+ "./pipeline": {
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.cjs"
44
+ },
45
+ "./engine-v2": {
46
+ "import": "./index-v2.js",
47
+ "require": "./index-v2.js",
48
+ "default": "./index-v2.js"
49
+ }
50
+ },
14
51
  "publishConfig": {
15
52
  "access": "public"
16
53
  },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/codecaaron/animus"
54
+ "scripts": {
55
+ "build": "napi build --platform --release && bun run build:v2 && bun run build:ts",
56
+ "build:v1": "napi build --platform --release",
57
+ "build:ts": "tsdown && tsgo -p tsconfig.build.json",
58
+ "build:debug": "napi build --platform",
59
+ "compile": "tsgo -p tsconfig.build.json --noEmit",
60
+ "build:v2": "cd crates/extract-v2 && bunx napi build --platform --release",
61
+ "build:v2:debug": "cd crates/extract-v2 && bunx napi build --platform"
62
+ },
63
+ "dependencies": {
64
+ "@animus-ui/properties": "0.1.1-beta.2"
65
+ },
66
+ "devDependencies": {
67
+ "@animus-ui/system": "workspace:*",
68
+ "@mdx-js/mdx": "^3.0.0",
69
+ "@napi-rs/cli": "^3.7.3"
70
+ },
71
+ "peerDependencies": {
72
+ "@mdx-js/mdx": "^3.0.0"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@mdx-js/mdx": {
76
+ "optional": true
77
+ }
78
+ },
79
+ "optionalDependencies": {
80
+ "@animus-ui/extract-darwin-arm64": "0.1.1-beta.2",
81
+ "@animus-ui/extract-linux-arm64-gnu": "0.1.1-beta.2",
82
+ "@animus-ui/extract-linux-x64-gnu": "0.1.1-beta.2"
20
83
  },
21
84
  "napi": {
22
85
  "binaryName": "animus-extract",
@@ -25,17 +88,5 @@
25
88
  "x86_64-unknown-linux-gnu",
26
89
  "aarch64-unknown-linux-gnu"
27
90
  ]
28
- },
29
- "scripts": {
30
- "build": "napi build --platform --release",
31
- "build:debug": "napi build --platform"
32
- },
33
- "optionalDependencies": {
34
- "@animus-ui/extract-darwin-arm64": "0.1.0-next.v7",
35
- "@animus-ui/extract-linux-x64-gnu": "0.1.0-next.v7",
36
- "@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.v7"
37
- },
38
- "devDependencies": {
39
- "@napi-rs/cli": "^3.0.0"
40
91
  }
41
92
  }