@rel-packages/audio-utils 0.2.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 ADDED
@@ -0,0 +1,32 @@
1
+ # audio utils
2
+
3
+ ## build
4
+
5
+ ### requirements
6
+
7
+ - `vcpkg`
8
+ - `cmake`
9
+ - `ninja`
10
+ - `llvm` (windows)
11
+
12
+ ### linux (static)
13
+
14
+ ```bash
15
+ export VCPKG_ROOT=/path/to/vcpkg
16
+ export VCPKG_DEFAULT_TRIPLET=x64-linux
17
+ export VCPKG_TARGET_TRIPLET=x64-linux
18
+ export CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
19
+ vcpkg install
20
+ bun run build
21
+ ```
22
+
23
+ ### windows (static)
24
+
25
+ ```powershell
26
+ $env:VCPKG_ROOT="C:\vcpkg"
27
+ $env:VCPKG_DEFAULT_TRIPLET="x64-windows-static"
28
+ $env:VCPKG_TARGET_TRIPLET="x64-windows-static"
29
+ $env:CMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
30
+ vcpkg install
31
+ bun run build
32
+ ```
@@ -0,0 +1,7 @@
1
+ export * from "./types/types";
2
+ declare const get_duration: (path: string) => number;
3
+ export { get_duration };
4
+ declare const _default: {
5
+ get_duration: (path: string) => number;
6
+ };
7
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.get_duration = void 0;
18
+ const bindings_1 = require("./lib/bindings");
19
+ __exportStar(require("./types/types"), exports);
20
+ let next_call_id = 1;
21
+ const get_call_id = () => {
22
+ const current = next_call_id;
23
+ next_call_id = (next_call_id + 1) >>> 0;
24
+ if (next_call_id === 0) {
25
+ next_call_id = 1;
26
+ }
27
+ return current;
28
+ };
29
+ const get_duration = (path) => {
30
+ const call_id = get_call_id();
31
+ const result = bindings_1.native.get_duration(call_id, path);
32
+ if (result == null) {
33
+ const error_message = bindings_1.native.get_last_error(call_id);
34
+ if (error_message) {
35
+ throw new Error(`libsndfile: ${error_message}`);
36
+ }
37
+ throw new Error("libsndfile: unknown error");
38
+ }
39
+ return result;
40
+ };
41
+ exports.get_duration = get_duration;
42
+ exports.default = { get_duration };
@@ -0,0 +1,3 @@
1
+ import { INativeAudio } from "../types/types";
2
+ declare const native: INativeAudio;
3
+ export { native };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.native = void 0;
7
+ const node_gyp_build_1 = __importDefault(require("node-gyp-build"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const native = (0, node_gyp_build_1.default)(path_1.default.join(__dirname, "..", ".."));
10
+ exports.native = native;
@@ -0,0 +1,4 @@
1
+ export interface INativeAudio {
2
+ get_duration(call_id: number, path: string): number | null;
3
+ get_last_error(call_id: number): string | null;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@rel-packages/audio-utils",
3
+ "version": "0.2.0",
4
+ "description": "audio utils (libsndfile)",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "homepage": "https://github.com/mezleca/audio-utils",
8
+ "scripts": {
9
+ "update:patch": "npm version patch && git push --follow-tags",
10
+ "update:minor": "npm version minor && git push --follow-tags",
11
+ "update:major": "npm version major && git push --follow-tags",
12
+ "prepublishOnly": "npm run compile:tsc && mkdir -p lib",
13
+ "compile:native": "bun scripts/build.ts native",
14
+ "compile:tsc": "tsc",
15
+ "format": "prettier --write . --ignore-unknown",
16
+ "pretest": "bun run format",
17
+ "test": "bun test",
18
+ "prebuild": "bun run format",
19
+ "build": "bun scripts/build.ts native && npm run compile:tsc",
20
+ "build:clean": "bun run scripts/build.ts native clean && npm run compile:tsc",
21
+ "ci:build": "bun scripts/build.ts ci",
22
+ "example": "bun run scripts/example.ts"
23
+ },
24
+ "author": "rel",
25
+ "license": "ISC",
26
+ "repository": {
27
+ "url": "https://github.com/mezleca/audio-utils.git"
28
+ },
29
+ "type": "commonjs",
30
+ "files": [
31
+ "dist/",
32
+ "prebuilds/",
33
+ "README.md"
34
+ ],
35
+ "devDependencies": {
36
+ "@types/bindings": "^1.5.5",
37
+ "@types/node": "^24.10.4",
38
+ "@types/bun": "latest",
39
+ "cmake-js": "^7.4.0",
40
+ "node-addon-api": "^8.5.0",
41
+ "prettier": "^3.6.2",
42
+ "prettier-plugin-svelte": "^3.4.1",
43
+ "tsx": "^4.21.0",
44
+ "typescript": "^5.9.3"
45
+ },
46
+ "dependencies": {
47
+ "node-gyp-build": "^4.8.4"
48
+ }
49
+ }