@gjsify/lightningcss-native 0.22.0 → 0.23.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.
Files changed (3) hide show
  1. package/README.md +21 -1
  2. package/meson.build +51 -4
  3. package/package.json +12 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gjsify/lightningcss-native
2
2
 
3
- A native Rust cdylib + Vala/GObject bridge that exposes the Rust `lightningcss` CSS transformer and minifier to GJS via `gi://`. Ships prebuilt `.so` + `.typelib` for Linux and is loaded lazily at runtime — the consuming package (`@gjsify/rolldown-plugin-gjsify`'s `cssAsStringPlugin`) falls back to the npm `lightningcss` package when the prebuild is unavailable.
3
+ A native Rust cdylib + Vala/GObject bridge that exposes the Rust `lightningcss` CSS transformer and minifier to GJS via `gi://`. Ships prebuilt native libraries + typelibs for Linux and macOS (see [Platform coverage](#platform-coverage)) and is loaded lazily at runtime — the consuming package (`@gjsify/rolldown-plugin-gjsify`'s `cssAsStringPlugin`) falls back to the npm `lightningcss` package when the prebuild is unavailable.
4
4
 
5
5
  Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
6
6
 
@@ -32,6 +32,26 @@ if (hasNativeLightningcss()) {
32
32
 
33
33
  The native bridge is consumed automatically by `gjsify build --app gjs` via `@gjsify/rolldown-plugin-gjsify`. Direct use is only needed when calling the CSS pipeline outside of a gjsify build.
34
34
 
35
+ ## Platform coverage
36
+
37
+ | Platform | Prebuild | Built by |
38
+ |---|---|---|
39
+ | `linux-x86_64` | ✅ `.so` + `.gir` + `.typelib` | native runner |
40
+ | `linux-aarch64` | ✅ | native runner |
41
+ | `linux-ppc64`, `linux-s390x`, `linux-riscv64` | ✅ | QEMU emulation |
42
+ | `darwin-arm64` (macOS, Apple silicon) | ✅ `.dylib` + `.gir` + `.typelib` | `macos-latest` runner |
43
+ | `darwin-x64` (macOS, Intel) | ❌ | — no runner leg yet |
44
+ | Windows | ❌ | — no Vala/GI bridge in this repo targets Windows |
45
+
46
+ All prebuilds are produced by [`.github/workflows/prebuilds.yml`](../../../.github/workflows/prebuilds.yml)
47
+ and committed back to the repository.
48
+
49
+ **Known gap — a `darwin-arm64` prebuild is built and shipped, but the CLI does not
50
+ load it yet.** `detectNativePackages()` (`packages/infra/cli/src/utils/detect-native-packages.ts`)
51
+ hardcodes a `linux-` directory prefix, and `buildNativeEnv()` exports `LD_LIBRARY_PATH`,
52
+ which macOS `dyld` ignores in favour of `DYLD_LIBRARY_PATH`. Both are CLI-side fixes;
53
+ until they land, macOS falls back to the npm `lightningcss` package.
54
+
35
55
  ## License
36
56
 
37
57
  MIT
package/meson.build CHANGED
@@ -15,6 +15,48 @@ vala_deps = [
15
15
  dependency('gobject-2.0'),
16
16
  ]
17
17
 
18
+ # ----------------------------------------------------------------------------
19
+ # Host-dependent naming + runtime-lookup conventions
20
+ #
21
+ # Three things differ per host and MUST agree, or the prebuild loads on one
22
+ # platform and silently fails on the other (mirrors @gjsify/napi's meson
23
+ # branch):
24
+ #
25
+ # 1. cargo's cdylib leaf — libgjsify_lightningcss.{so,dylib}
26
+ # 2. meson's library() leaf — libgjsifylightningcss.{so,dylib}; the typelib
27
+ # records this name and gjs' g_module_open() resolves exactly it at load.
28
+ # 3. how the Vala library finds its sibling Rust cdylib at runtime. Both
29
+ # files ship side by side in prebuilds/<platform>-<arch>/, so the lookup
30
+ # must be relative to the loading binary: $ORIGIN on ELF, @loader_path on
31
+ # Mach-O. On macOS this is load-bearing — unlike Linux (where the CLI
32
+ # exports LD_LIBRARY_PATH for the prebuild dir) nothing sets
33
+ # DYLD_LIBRARY_PATH, so the rpath is the ONLY way the cdylib is found.
34
+ #
35
+ # Windows is deliberately absent: no Vala bridge here has had any Windows
36
+ # portability work, so `else` (ELF naming) is the honest fallback rather than a
37
+ # .dll branch that would imply support that does not exist.
38
+ # ----------------------------------------------------------------------------
39
+ host_system = host_machine.system()
40
+
41
+ if host_system == 'darwin'
42
+ rust_cdylib_name = 'libgjsify_lightningcss.dylib'
43
+ shared_lib_name = 'libgjsifylightningcss.dylib'
44
+ lib_rpath = '@loader_path'
45
+ # Normalise the cdylib's LC_ID_DYLIB to @rpath/<leaf> BEFORE the Vala
46
+ # library links against it: ld64 copies the dependency's install name
47
+ # verbatim into the dependent's LC_LOAD_DYLIB. rustc's own install name has
48
+ # varied across releases (absolute build path in older rustc, @rpath/<leaf>
49
+ # in current ones); pinning it here makes the recorded dependency
50
+ # rustc-version-independent, and @rpath/ is never longer than an absolute
51
+ # path so install_name_tool can always rewrite in place.
52
+ rust_cdylib_post = ' && install_name_tool -id "@rpath/' + rust_cdylib_name + '" "$3"'
53
+ else
54
+ rust_cdylib_name = 'libgjsify_lightningcss.so'
55
+ shared_lib_name = 'libgjsifylightningcss.so'
56
+ lib_rpath = '$ORIGIN'
57
+ rust_cdylib_post = ''
58
+ endif
59
+
18
60
  # ----------------------------------------------------------------------------
19
61
  # Rust cdylib (cargo)
20
62
  #
@@ -35,9 +77,10 @@ rust_target_dir = meson.current_build_dir() / 'cargo-target'
35
77
 
36
78
  rust_cdylib = custom_target('gjsify-lightningcss-rust',
37
79
  input: rust_sources,
38
- output: 'libgjsify_lightningcss.so',
80
+ output: rust_cdylib_name,
39
81
  command: ['sh', '-c',
40
- 'cargo build --release --manifest-path "$1" --target-dir "$2" && cp "$2/release/libgjsify_lightningcss.so" "$3"',
82
+ 'cargo build --release --manifest-path "$1" --target-dir "$2" && cp "$2/release/'
83
+ + rust_cdylib_name + '" "$3"' + rust_cdylib_post,
41
84
  'sh',
42
85
  meson.current_source_dir() / 'src/rust/Cargo.toml',
43
86
  rust_target_dir,
@@ -68,7 +111,11 @@ libGjsifyLightningcss = library('gjsifylightningcss', sources,
68
111
  link_depends: rust_cdylib,
69
112
  install: true,
70
113
  install_dir: [true, true, true, true],
71
- install_rpath: '$ORIGIN',
114
+ # `build_rpath` (not just `install_rpath`) is what matters for the prebuild:
115
+ # the artifact shipped in prebuilds/ is copied straight out of the build
116
+ # dir, never through `meson install`, so only the build-tree rpath survives.
117
+ build_rpath: lib_rpath,
118
+ install_rpath: lib_rpath,
72
119
  )
73
120
 
74
121
  g_ir_compiler = find_program('g-ir-compiler')
@@ -76,7 +123,7 @@ g_ir_compiler = find_program('g-ir-compiler')
76
123
  custom_target(meson.project_name() + '-1.0.typelib',
77
124
  command: [
78
125
  g_ir_compiler,
79
- '--shared-library', 'libgjsifylightningcss.so',
126
+ '--shared-library', shared_lib_name,
80
127
  '--output', '@OUTPUT@',
81
128
  meson.current_build_dir() / meson.project_name() + '-1.0.gir',
82
129
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/lightningcss-native",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Vala/GObject + Rust cdylib bridge to lightningcss for GJS. Replaces the Node-only npm `lightningcss` package: parse, transform, minify, and browserslist-target lowering of CSS without leaving a Node-free GJS process. Backs `@gjsify/rolldown-plugin-gjsify`'s cssAsStringPlugin under `--app gjs` so GTK4-CSS lowering (firefox60) works without a Node runtime in the build pipeline.",
5
5
  "type": "module",
6
6
  "main": "lib/esm/index.js",
@@ -20,6 +20,14 @@
20
20
  "src/vala"
21
21
  ],
22
22
  "gjsify": {
23
+ "platforms": [
24
+ "linux-x86_64",
25
+ "linux-aarch64",
26
+ "linux-ppc64",
27
+ "linux-s390x",
28
+ "linux-riscv64",
29
+ "darwin-arm64"
30
+ ],
23
31
  "prebuilds": "prebuilds",
24
32
  "tier": 1
25
33
  },
@@ -30,9 +38,9 @@
30
38
  "init:meson:wipe": "gjsify run init:meson --wipe",
31
39
  "build": "gjsify run build:gjsify && gjsify run build:types",
32
40
  "build:gjsify": "gjsify build --library 'src/ts/**/*.{ts,js}'",
33
- "build:meson": "gjsify run init:meson && meson compile -C build",
41
+ "build:meson": "node ../../../scripts/check-refs-pin.mjs . && gjsify run init:meson && meson compile -C build",
34
42
  "build:types": "gjsify tsc",
35
- "build:prebuilds": "gjsify run build:meson && mkdir -p prebuilds/linux-x86_64 && cp build/libgjsifylightningcss.so build/libgjsify_lightningcss.so build/GjsifyLightningcss-1.0.gir build/GjsifyLightningcss-1.0.typelib prebuilds/linux-x86_64/",
43
+ "build:prebuilds": "gjsify run build:meson && node ../../../scripts/stage-prebuild.mjs .",
36
44
  "build:gir-types": "ts-for-gir generate --externalDeps --allowMissingDeps --girDirectories=./prebuilds/linux-x86_64 --girDirectories=/usr/share/gir-1.0 --modules=GjsifyLightningcss-1.0 --outdir=src/ts --npmScope=@girs --package=false --ignoreVersionConflicts=true"
37
45
  },
38
46
  "keywords": [
@@ -51,7 +59,7 @@
51
59
  "@girs/gobject-2.0": "^4.1.0"
52
60
  },
53
61
  "devDependencies": {
54
- "@gjsify/cli": "^0.22.0",
62
+ "@gjsify/cli": "^0.23.0",
55
63
  "@ts-for-gir/cli": "^4.1.0",
56
64
  "@types/node": "^25.9.2",
57
65
  "typescript": "^6.0.3"