@convis/audio-native 0.0.2 → 0.0.3

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
@@ -12,7 +12,7 @@ napi-rs compiles Rust and generates 3 files in `dist/`: `audio.<local target>.no
12
12
  ## Releases
13
13
 
14
14
  * Trigger the GitHub workflow here: <https://github.com/k2d222/convis-audio/actions/workflows/build.yml>
15
- * When completed: `pnpm download-artifacts <workflow run ID>`
15
+ * When completed: `pnpm script:download-artifacts <workflow run ID>`
16
16
  * Check that the `.node` files were copied to `platforms/<target>/audio-<target>.node`
17
- * Bump package versions and commit
17
+ * Bump package versions and commit: `pnpm script:version patch` (for a patch version bump)
18
18
  * `pnpm publish -r --access public`
package/dist/index.js ADDED
@@ -0,0 +1,104 @@
1
+ /** Load the native module for the current OS / architecture combo.
2
+ * Modified from the auto-generated file by napi-rs.
3
+ */
4
+
5
+ let nativeBinding = null;
6
+ const loadErrors = [];
7
+
8
+ function requireNative() {
9
+ try {
10
+ // the locally-build module overrides all others. (generated in dev mode)
11
+ return require("./audio.node");
12
+ } catch (e) {
13
+ loadErrors.push(e);
14
+ }
15
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
16
+ try {
17
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
18
+ } catch (err) {
19
+ loadErrors.push(err);
20
+ }
21
+ } else if (process.platform === "win32") {
22
+ if (process.arch === "x64") {
23
+ try {
24
+ return require("@convis/audio-x86_64-pc-windows-msvc");
25
+ } catch (e) {
26
+ loadErrors.push(e);
27
+ }
28
+ } else if (process.arch === "arm64") {
29
+ try {
30
+ return require("@convis/audio-aarch64-pc-windows-msvc");
31
+ } catch (e) {
32
+ loadErrors.push(e);
33
+ }
34
+ } else {
35
+ loadErrors.push(
36
+ new Error(`Unsupported architecture on Windows: ${process.arch}`),
37
+ );
38
+ }
39
+ } else if (process.platform === "darwin") {
40
+ if (process.arch === "x64") {
41
+ try {
42
+ return require("@convis/audio-x86_64-apple-darwin");
43
+ } catch (e) {
44
+ loadErrors.push(e);
45
+ }
46
+ } else if (process.arch === "arm64") {
47
+ try {
48
+ return require("@convis/audio-aarch64-apple-darwin");
49
+ } catch (e) {
50
+ loadErrors.push(e);
51
+ }
52
+ } else {
53
+ loadErrors.push(
54
+ new Error(`Unsupported architecture on macOS: ${process.arch}`),
55
+ );
56
+ }
57
+ } else if (process.platform === "linux") {
58
+ if (process.arch === "x64") {
59
+ try {
60
+ return require("@convis/audio-x86_64-unknown-linux-gnu");
61
+ } catch (e) {
62
+ loadErrors.push(e);
63
+ }
64
+ } else if (process.arch === "arm64") {
65
+ try {
66
+ return require("@convis/audio-aarch64-unknown-linux-gnu");
67
+ } catch (e) {
68
+ loadErrors.push(e);
69
+ }
70
+ } else {
71
+ loadErrors.push(
72
+ new Error(`Unsupported architecture on Linux: ${process.arch}`),
73
+ );
74
+ }
75
+ } else {
76
+ loadErrors.push(
77
+ new Error(
78
+ `Unsupported OS: ${process.platform}, architecture: ${process.arch}`,
79
+ ),
80
+ );
81
+ }
82
+ }
83
+
84
+ nativeBinding = requireNative();
85
+
86
+ if (!nativeBinding) {
87
+ if (loadErrors.length > 0) {
88
+ throw new Error(
89
+ `Cannot find native binding. ` +
90
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
91
+ "Please try `npm i` again after removing both package-lock.json and node_modules directory.",
92
+ {
93
+ cause: loadErrors.reduce((err, cur) => {
94
+ cur.cause = err;
95
+ return cur;
96
+ }),
97
+ },
98
+ );
99
+ }
100
+ throw new Error(`Failed to load native binding`);
101
+ }
102
+
103
+ module.exports = nativeBinding;
104
+ module.exports.AudioHardware = nativeBinding.AudioHardware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convis/audio-native",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Native Node (N-API) module for @convis/audio",
5
5
  "homepage": "https://github.com/k2d222/convis-audio",
6
6
  "bugs": "https://github.com/k2d222/convis-audio/issues",
@@ -8,7 +8,8 @@
8
8
  "author": "Mathis Brossier <mathis.brossier@gmail.com>",
9
9
  "repository": "github:k2d222/convis-audio",
10
10
  "files": [
11
- "./dist/*",
11
+ "./dist/index.d.ts",
12
+ "./dist/index.js",
12
13
  "./src/*"
13
14
  ],
14
15
  "type": "module",
@@ -21,12 +22,12 @@
21
22
  "@types/node": "^25.6.2"
22
23
  },
23
24
  "optionalDependencies": {
24
- "@convis/audio-aarch64-apple-darwin": "0.0.2",
25
- "@convis/audio-aarch64-pc-windows-msvc": "0.0.2",
26
- "@convis/audio-x86_64-pc-windows-msvc": "0.0.2",
27
- "@convis/audio-x86_64-unknown-linux-gnu": "0.0.2",
28
- "@convis/audio-aarch64-unknown-linux-gnu": "0.0.2",
29
- "@convis/audio-x86_64-apple-darwin": "0.0.2"
25
+ "@convis/audio-aarch64-apple-darwin": "0.0.3",
26
+ "@convis/audio-x86_64-apple-darwin": "0.0.3",
27
+ "@convis/audio-x86_64-pc-windows-msvc": "0.0.3",
28
+ "@convis/audio-aarch64-unknown-linux-gnu": "0.0.3",
29
+ "@convis/audio-aarch64-pc-windows-msvc": "0.0.3",
30
+ "@convis/audio-x86_64-unknown-linux-gnu": "0.0.3"
30
31
  },
31
32
  "napi": {
32
33
  "npmClient": "pnpm",
@@ -41,10 +42,11 @@
41
42
  ]
42
43
  },
43
44
  "scripts": {
44
- "build": "rm -rf dist/ && pnpm run napi:build:release",
45
+ "build": "pnpm run napi:build:release",
45
46
  "dev": "pnpm napi:build:debug --watch",
46
47
  "napi:build:debug": "napi build -o dist/",
47
- "napi:build:release": "napi build --release --strip -o dist/",
48
- "download-artifacts": "sh scripts/download-artifacts.sh"
48
+ "napi:build:release": "napi build -o dist/ --release --strip",
49
+ "script:download-artifacts": "sh scripts/download-artifacts.sh",
50
+ "script:version": "sh scripts/version.sh"
49
51
  }
50
52
  }
package/dist/audio.node DELETED
Binary file
@@ -1,8 +0,0 @@
1
- declare module "@audio/decode-wav" {
2
- export interface AudioData {
3
- channelData: Float32Array[];
4
- sampleRate: number;
5
- }
6
-
7
- export default function decode(buf: ArrayBuffer | Uint8Array): Promise<AudioData>;
8
- }