@plurnk/plurnk-mimetypes-audio 1.19.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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/Audio.d.ts +15 -0
- package/dist/Audio.d.ts.map +1 -0
- package/dist/Audio.js +43 -0
- package/dist/Audio.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +139 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PossumTech Laboratories, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @plurnk/plurnk-mimetypes-audio
|
|
2
|
+
|
|
3
|
+
Binary audio handlers for PLURNK. Bundled with the service and loaded on demand.
|
|
4
|
+
|
|
5
|
+
Ordinary `READ` exposes format, duration (when known), and byte size. The service
|
|
6
|
+
delivers the same retained source bytes to models whose catalog declares audio
|
|
7
|
+
input. Byte-scoped reads still return their selected hexadecimal lines.
|
|
8
|
+
|
|
9
|
+
[music-metadata](https://github.com/borewit/music-metadata) parses the container;
|
|
10
|
+
this package does not transcribe, decode samples, or transcode. Actual accepted
|
|
11
|
+
codecs depend on the model/provider. `.webm` is not inferred to be audio; an
|
|
12
|
+
explicit `audio/webm` source type is supported.
|
|
13
|
+
|
|
14
|
+
See {§mimetype-audio-facts} in the [mimetype specification](../plurnk-mimetypes/SPEC.md)
|
|
15
|
+
and {§packet-attachment-parts} in the [core specification](../plurnk-core/SPEC.md).
|
package/dist/Audio.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseHandler, type HandlerContent } from "@plurnk/plurnk-mimetypes";
|
|
2
|
+
export interface AudioFacts {
|
|
3
|
+
readonly format: string;
|
|
4
|
+
readonly duration: number | null;
|
|
5
|
+
readonly bytes: number;
|
|
6
|
+
}
|
|
7
|
+
export default class Audio extends BaseHandler {
|
|
8
|
+
#private;
|
|
9
|
+
facts(content: HandlerContent): Promise<AudioFacts>;
|
|
10
|
+
validate(content: HandlerContent): Promise<void>;
|
|
11
|
+
content(content: HandlerContent): Promise<string>;
|
|
12
|
+
summary(content: HandlerContent): Promise<string>;
|
|
13
|
+
deepJson(content: HandlerContent): Promise<AudioFacts>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Audio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Audio.d.ts","sourceRoot":"","sources":["../src/Audio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE5E,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW;;IAG3B,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAOjE;IAec,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;IAEc,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAI/D;IAEQ,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzD;IAEQ,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAE9D;CACJ"}
|
package/dist/Audio.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseHandler } from "@plurnk/plurnk-mimetypes";
|
|
2
|
+
// {§mimetype-audio-facts} — parsing is lazy; concurrent projection hooks share one observation.
|
|
3
|
+
export default class Audio extends BaseHandler {
|
|
4
|
+
#observations = new WeakMap();
|
|
5
|
+
async facts(content) {
|
|
6
|
+
if (!(content instanceof Uint8Array))
|
|
7
|
+
throw new TypeError("Audio handler receives binary content as a Uint8Array.");
|
|
8
|
+
const previous = this.#observations.get(content);
|
|
9
|
+
if (previous !== undefined)
|
|
10
|
+
return previous;
|
|
11
|
+
const observation = this.#inspect(content);
|
|
12
|
+
this.#observations.set(content, observation);
|
|
13
|
+
return observation;
|
|
14
|
+
}
|
|
15
|
+
async #inspect(bytes) {
|
|
16
|
+
const { parseBuffer } = await import("music-metadata");
|
|
17
|
+
const { format } = await parseBuffer(bytes, { mimeType: this.mimetype }, {
|
|
18
|
+
duration: true,
|
|
19
|
+
skipCovers: true,
|
|
20
|
+
skipPostHeaders: true,
|
|
21
|
+
});
|
|
22
|
+
if (!format.container || !format.numberOfChannels)
|
|
23
|
+
throw new SyntaxError("No audio track identified in the source bytes.");
|
|
24
|
+
const duration = typeof format.duration === "number" && Number.isFinite(format.duration) && format.duration >= 0
|
|
25
|
+
? format.duration : null;
|
|
26
|
+
return { format: format.container, duration, bytes: bytes.byteLength };
|
|
27
|
+
}
|
|
28
|
+
async validate(content) {
|
|
29
|
+
await this.facts(content);
|
|
30
|
+
}
|
|
31
|
+
async content(content) {
|
|
32
|
+
const facts = await this.facts(content);
|
|
33
|
+
const duration = facts.duration === null ? "" : `, ${facts.duration} s`;
|
|
34
|
+
return `${facts.format} audio${duration}, ${facts.bytes} bytes`;
|
|
35
|
+
}
|
|
36
|
+
summary(content) {
|
|
37
|
+
return this.content(content);
|
|
38
|
+
}
|
|
39
|
+
deepJson(content) {
|
|
40
|
+
return this.facts(content);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Audio.js","sourceRoot":"","sources":["../src/Audio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,0BAA0B,CAAC;AAQ5E,gGAAgG;AAChG,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW;IACjC,aAAa,GAAG,IAAI,OAAO,EAAmC,CAAC;IAE/D,KAAK,CAAC,KAAK,CAAC,OAAuB;QACxC,IAAI,CAAC,CAAC,OAAO,YAAY,UAAU,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;QACpH,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CA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AQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,QAAQ,IAAI,CAAC;QACxE,OAAO,GAAG,KAAK,CAAC,MAAM,SAAS,QAAQ,KAAK,KAAK,CAAC,KAAK,QAAQ,CAAC;IACpE,CAAC;IAEQ,OAAO,CAAC,OAAuB;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAEQ,QAAQ,CAAC,OAAuB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plurnk/plurnk-mimetypes-audio",
|
|
3
|
+
"version": "1.19.0",
|
|
4
|
+
"description": "Audio format and duration facts for ordinary PLURNK READ and native model input.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"plurnk",
|
|
7
|
+
"mimetype",
|
|
8
|
+
"audio",
|
|
9
|
+
"multimodal"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=26"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"plurnk-dev": "./src/index.ts",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"plurnk": {
|
|
32
|
+
"kind": "mimetype",
|
|
33
|
+
"binary": true,
|
|
34
|
+
"handlers": [
|
|
35
|
+
{
|
|
36
|
+
"name": "audio/wav",
|
|
37
|
+
"revision": "1",
|
|
38
|
+
"glyph": "🎵",
|
|
39
|
+
"extensions": [
|
|
40
|
+
".wav"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "audio/x-wav",
|
|
45
|
+
"revision": "1",
|
|
46
|
+
"glyph": "🎵",
|
|
47
|
+
"extensions": []
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "audio/vnd.wave",
|
|
51
|
+
"revision": "1",
|
|
52
|
+
"glyph": "🎵",
|
|
53
|
+
"extensions": []
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "audio/mpeg",
|
|
57
|
+
"revision": "1",
|
|
58
|
+
"glyph": "🎵",
|
|
59
|
+
"extensions": [
|
|
60
|
+
".mp3"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "audio/flac",
|
|
65
|
+
"revision": "1",
|
|
66
|
+
"glyph": "🎵",
|
|
67
|
+
"extensions": [
|
|
68
|
+
".flac"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "audio/ogg",
|
|
73
|
+
"revision": "1",
|
|
74
|
+
"glyph": "🎵",
|
|
75
|
+
"extensions": [
|
|
76
|
+
".ogg",
|
|
77
|
+
".oga",
|
|
78
|
+
".opus"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "audio/mp4",
|
|
83
|
+
"revision": "1",
|
|
84
|
+
"glyph": "🎵",
|
|
85
|
+
"extensions": [
|
|
86
|
+
".m4a"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "audio/aac",
|
|
91
|
+
"revision": "1",
|
|
92
|
+
"glyph": "🎵",
|
|
93
|
+
"extensions": [
|
|
94
|
+
".aac"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "audio/webm",
|
|
99
|
+
"revision": "1",
|
|
100
|
+
"glyph": "🎵",
|
|
101
|
+
"extensions": []
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "audio/aiff",
|
|
105
|
+
"revision": "1",
|
|
106
|
+
"glyph": "🎵",
|
|
107
|
+
"extensions": [
|
|
108
|
+
".aiff",
|
|
109
|
+
".aif"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"scripts": {
|
|
115
|
+
"test:lint": "tsc --noEmit",
|
|
116
|
+
"test:unit": "node --conditions=plurnk-dev --test src/**/*.test.ts",
|
|
117
|
+
"test": "npm run test:lint && npm run test:unit",
|
|
118
|
+
"build:clean": "rm -rf dist",
|
|
119
|
+
"build:dist": "tsc -p tsconfig.build.json",
|
|
120
|
+
"build": "npm run build:clean && npm run build:dist",
|
|
121
|
+
"prepack": "npm run build",
|
|
122
|
+
"prepublishOnly": "npm audit --audit-level=moderate && npm test"
|
|
123
|
+
},
|
|
124
|
+
"dependencies": {
|
|
125
|
+
"music-metadata": "^11.15.0"
|
|
126
|
+
},
|
|
127
|
+
"peerDependencies": {
|
|
128
|
+
"@plurnk/plurnk-mimetypes": "^1.19.0"
|
|
129
|
+
},
|
|
130
|
+
"homepage": "https://github.com/plurnk/plurnk-service/tree/main/plurnk-mimetypes-audio#readme",
|
|
131
|
+
"bugs": {
|
|
132
|
+
"url": "https://repo.possumtech.com/plurnk/plurnk-service/issues"
|
|
133
|
+
},
|
|
134
|
+
"repository": {
|
|
135
|
+
"type": "git",
|
|
136
|
+
"url": "git+https://github.com/plurnk/plurnk-service.git",
|
|
137
|
+
"directory": "plurnk-mimetypes-audio"
|
|
138
|
+
}
|
|
139
|
+
}
|