stem-mqtt 0.6.0 → 0.8.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/README.md CHANGED
@@ -23,10 +23,15 @@ hand-written napi-rs addon `stem-mqtt-client`, which had no broker.
23
23
 
24
24
  - Node.js 16+ (ESM — use `"type": "module"` or `.mjs`). **Server-side only**; there is no browser build
25
25
  (browsers can talk to the broker's WebSocket port with any MQTT.js client instead).
26
- - The package bundles the native library under `client/prebuilds/<platform>-<arch>[-libc]/` and
27
- `broker/prebuilds/…` for the platforms the release built — **Linux x86_64 (glibc) today**. `package.json`
28
- lists exactly those platforms in `os` / `cpu`, so `npm install` on another platform fails immediately
29
- (`EBADPLATFORM`) instead of at first use. Other platforms: build the library (below) or ask for it to be added.
26
+ - The native libraries come in one package per platform, installed automatically: `stem-mqtt` lists
27
+ `stem-mqtt-linux-x64-gnu`, `stem-mqtt-linux-arm64-gnu`, `stem-mqtt-darwin-x64` and `stem-mqtt-darwin-arm64`
28
+ as optional dependencies, each restricted to its `os` / `cpu` (and glibc), so
29
+ npm installs only the one your machine needs. On any other platform `npm install` fails up front
30
+ (`EBADPLATFORM`). With `--omit=optional` (or a lockfile made on another OS) the platform package is
31
+ missing: install it explicitly, e.g. `npm install stem-mqtt-linux-x64-gnu`.
32
+ - **Windows is not on npmjs.org yet**: npm's spam detection rejects the Windows package's name. Until
33
+ that is cleared, use the `x86_64-pc-windows-msvc` libraries from the GitHub release (see
34
+ `EBADPLATFORM` under Troubleshooting) or the package from GitHub Packages.
30
35
  - No compiler is needed at install time: `koffi` ships prebuilt binaries.
31
36
 
32
37
  ## Quick start
@@ -154,9 +159,9 @@ nu scripts/publish_packages.nu stage node # dist/node/{client,broker,runtim
154
159
  cd dist/node && npm pack
155
160
  ```
156
161
 
157
- To ship more platforms in one package, build `stage` on each OS and merge the extra libraries in:
158
- `nu scripts/publish_packages.nu stage node --add-native /path/to/other-stage/native` (a directory containing
159
- `<platform>/` folders such as `linux-x86_64/` or `macos-aarch64/`).
162
+ Publishing (`publish_packages.nu publish node …`) moves the libraries into one package per platform under
163
+ `dist/node/platforms/<target>/` and publishes those before the main package. Release CI passes
164
+ `--natives native-libs`: every target's libraries, built by `scripts/ci/native_libs.nu`.
160
165
 
161
166
  The package layout is `client/`, `broker/` and one shared `runtime/` — the generator emits a copy of the runtime
162
167
  per component, and two copies cannot be loaded into one process because they register the same named types in
@@ -169,9 +174,11 @@ The end-to-end test is [`tests/bindings/node/smoke.mjs`](https://github.com/sori
169
174
 
170
175
  - **`Cannot find module './client/index.js'`** — import the package entry points
171
176
  (`stem-mqtt/client`), not a path.
172
- - **`EBADPLATFORM` on install, or `Failed to load shared library`** — the package has no native library for your
173
- OS/arch; build from source and copy `libmqtt_client.*` / `libmqtt_broker.*` into
174
- `client/prebuilds/<platform>-<arch>/` and `broker/prebuilds/<platform>-<arch>/`.
177
+ - **`EBADPLATFORM` on install** — there is no package for your OS/arch; build from source and copy
178
+ `libmqtt_client.*` / `libmqtt_broker.*` into `client/prebuilds/<platform>-<arch>/` and
179
+ `broker/prebuilds/<platform>-<arch>/` of the installed package.
180
+ - **`Failed to load shared library`** — the platform package was not installed (optional dependencies
181
+ omitted); `npm install stem-mqtt-<platform>-<arch>[-gnu]` of the same version.
175
182
  - **`Duplicate type name 'RustBuffer'`** — you are using separately generated components; the published
176
183
  package shares one `runtime/` between client and broker precisely to avoid this.
177
184
  - **`SyntaxError: Cannot use import statement`** — the file isn't ESM; use `.mjs` or `"type": "module"`.
@@ -1,3 +1,17 @@
1
+ import { createRequire as uniffiCreateRequire } from "node:module";
2
+
3
+ // stem-mqtt: the native library ships in a per-platform package (an optional dependency),
4
+ // named <prefix><target>, with -msvc on Windows.
5
+ function uniffiPlatformLibrary(target, filename) {
6
+ const name = target.startsWith("win32-") ? `${target}-msvc` : target;
7
+ try {
8
+ const manifest = uniffiCreateRequire(import.meta.url).resolve(`stem-mqtt-${name}/package.json`);
9
+ return join(dirname(manifest), "broker", filename);
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+
1
15
  import { existsSync, realpathSync } from "node:fs";
2
16
  import { dirname, isAbsolute, join } from "node:path";
3
17
  import { fileURLToPath } from "node:url";
@@ -169,7 +183,7 @@ function defaultBundledLibrary() {
169
183
  return Object.freeze({
170
184
  target,
171
185
  packageRelativePath: `prebuilds/${target}/${filename}`,
172
- libraryPath: join(moduleDirectory, "prebuilds", target, filename),
186
+ libraryPath: uniffiPlatformLibrary(target, filename) ?? join(moduleDirectory, "prebuilds", target, filename),
173
187
  });
174
188
  }
175
189
 
@@ -1,3 +1,17 @@
1
+ import { createRequire as uniffiCreateRequire } from "node:module";
2
+
3
+ // stem-mqtt: the native library ships in a per-platform package (an optional dependency),
4
+ // named <prefix><target>, with -msvc on Windows.
5
+ function uniffiPlatformLibrary(target, filename) {
6
+ const name = target.startsWith("win32-") ? `${target}-msvc` : target;
7
+ try {
8
+ const manifest = uniffiCreateRequire(import.meta.url).resolve(`stem-mqtt-${name}/package.json`);
9
+ return join(dirname(manifest), "client", filename);
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+
1
15
  import { existsSync, realpathSync } from "node:fs";
2
16
  import { dirname, isAbsolute, join } from "node:path";
3
17
  import { fileURLToPath } from "node:url";
@@ -157,7 +171,7 @@ function defaultBundledLibrary() {
157
171
  return Object.freeze({
158
172
  target,
159
173
  packageRelativePath: `prebuilds/${target}/${filename}`,
160
- libraryPath: join(moduleDirectory, "prebuilds", target, filename),
174
+ libraryPath: uniffiPlatformLibrary(target, filename) ?? join(moduleDirectory, "prebuilds", target, filename),
161
175
  });
162
176
  }
163
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stem-mqtt",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "MQTT 3.1.1 / 5.0 client and broker (Rust core, UniFFI Node bindings)",
5
5
  "type": "module",
6
6
  "engines": {
@@ -43,10 +43,18 @@
43
43
  "registry": "https://registry.npmjs.org/",
44
44
  "access": "public"
45
45
  },
46
+ "optionalDependencies": {
47
+ "stem-mqtt-darwin-arm64": "0.8.0",
48
+ "stem-mqtt-darwin-x64": "0.8.0",
49
+ "stem-mqtt-linux-arm64-gnu": "0.8.0",
50
+ "stem-mqtt-linux-x64-gnu": "0.8.0"
51
+ },
46
52
  "os": [
53
+ "darwin",
47
54
  "linux"
48
55
  ],
49
56
  "cpu": [
57
+ "arm64",
50
58
  "x64"
51
59
  ]
52
60
  }