@owncast/plugin-sdk 0.3.0 → 0.3.1

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.
@@ -25,6 +25,27 @@ function fail(e) {
25
25
  process.exit(1);
26
26
  }
27
27
 
28
+ // toolchainEnv extends the current environment with the variables
29
+ // the dynamic linker needs to find `libbinaryen` next to `wasm-merge`
30
+ // and `wasm-opt` (which extism-js shells out to during the wasm
31
+ // pipeline). Linux uses LD_LIBRARY_PATH; macOS uses DYLD_LIBRARY_PATH
32
+ // plus DYLD_FALLBACK_LIBRARY_PATH (Apple Silicon strips
33
+ // DYLD_LIBRARY_PATH in some sandboxed contexts, the FALLBACK
34
+ // variant survives). Setting all three is safe on both OSes; the
35
+ // inactive ones are ignored. This is the difference between "build
36
+ // succeeds" and `library not loaded: @rpath/libbinaryen.dylib` on
37
+ // macOS.
38
+ function toolchainEnv(cache) {
39
+ const libDir = path.join(cache, "lib");
40
+ return {
41
+ ...process.env,
42
+ PATH: `${cache}:${process.env.PATH}`,
43
+ LD_LIBRARY_PATH: `${libDir}:${process.env.LD_LIBRARY_PATH || ""}`,
44
+ DYLD_LIBRARY_PATH: `${libDir}:${process.env.DYLD_LIBRARY_PATH || ""}`,
45
+ DYLD_FALLBACK_LIBRARY_PATH: `${libDir}:${process.env.DYLD_FALLBACK_LIBRARY_PATH || "/usr/local/lib:/usr/lib"}`,
46
+ };
47
+ }
48
+
28
49
  // slugPattern matches a valid plugin slug: a lowercase letter
29
50
  // followed by lowercase letters/digits/hyphens, up to 64 chars total.
30
51
  // Same shape the host + SDK + registry all validate against.
@@ -106,10 +127,7 @@ function runBinary(name, args) {
106
127
  );
107
128
  process.exit(1);
108
129
  }
109
- const env = {
110
- ...process.env,
111
- LD_LIBRARY_PATH: `${path.join(cache, "lib")}:${process.env.LD_LIBRARY_PATH || ""}`,
112
- };
130
+ const env = toolchainEnv(cache);
113
131
  try {
114
132
  execFileSync(bin, args.length > 0 ? args : [process.cwd()], {
115
133
  stdio: "inherit",
@@ -212,11 +230,7 @@ module.exports = { register, on_event, on_filter, on_http_request };
212
230
  `extism-js not found at ${extismJs}, run \`npm install\` to fetch the toolchain`,
213
231
  );
214
232
  }
215
- const env = {
216
- ...process.env,
217
- PATH: `${cache}:${process.env.PATH}`,
218
- LD_LIBRARY_PATH: `${path.join(cache, "lib")}:${process.env.LD_LIBRARY_PATH || ""}`,
219
- };
233
+ const env = toolchainEnv(cache);
220
234
 
221
235
  const wasmOut = path.join(cwd, `${slug}.wasm`);
222
236
  execFileSync(extismJs, [bundledJS, "-i", dts, "-o", wasmOut], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owncast/plugin-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "SDK for authoring Owncast plugins in JavaScript",
5
5
  "license": "MIT",
6
6
  "author": "Owncast",
package/testing.js CHANGED
@@ -141,9 +141,17 @@ function runScenarios(scenarios, opts = {}) {
141
141
  JSON.stringify(scenarios, null, 2),
142
142
  );
143
143
 
144
+ // Match the build CLI: extism-js (and its wasm-merge/wasm-opt
145
+ // children) needs LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH +
146
+ // DYLD_FALLBACK_LIBRARY_PATH on macOS to find libbinaryen via
147
+ // @rpath. Setting all three is safe on both OSes; the inactive
148
+ // ones are ignored.
149
+ const libDir = path.join(cache, "lib");
144
150
  const env = {
145
151
  ...process.env,
146
- LD_LIBRARY_PATH: `${path.join(cache, "lib")}:${process.env.LD_LIBRARY_PATH || ""}`,
152
+ LD_LIBRARY_PATH: `${libDir}:${process.env.LD_LIBRARY_PATH || ""}`,
153
+ DYLD_LIBRARY_PATH: `${libDir}:${process.env.DYLD_LIBRARY_PATH || ""}`,
154
+ DYLD_FALLBACK_LIBRARY_PATH: `${libDir}:${process.env.DYLD_FALLBACK_LIBRARY_PATH || "/usr/local/lib:/usr/lib"}`,
147
155
  };
148
156
  try {
149
157
  execFileSync(bin, [tmp], { stdio: "inherit", env });