spectrum-ts 4.1.0 → 5.0.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 +29 -67
- package/dist/authoring.d.ts +1 -6
- package/dist/authoring.js +2 -36
- package/dist/elysia.d.ts +1 -0
- package/dist/elysia.js +2 -0
- package/dist/express.d.ts +1 -0
- package/dist/express.js +2 -0
- package/dist/hono.d.ts +1 -0
- package/dist/hono.js +2 -0
- package/dist/index.d.ts +1 -2837
- package/dist/index.js +2 -3373
- package/dist/manifest.json +5 -5
- package/dist/providers/imessage/index.d.ts +1 -222
- package/dist/providers/imessage/index.js +2 -25
- package/dist/providers/index.d.ts +6 -19
- package/dist/providers/index.js +6 -34
- package/dist/providers/slack/index.d.ts +1 -46
- package/dist/providers/slack/index.js +2 -11
- package/dist/providers/telegram/index.d.ts +1 -45
- package/dist/providers/telegram/index.js +2 -13
- package/dist/providers/terminal/index.d.ts +1 -119
- package/dist/providers/terminal/index.js +2 -13
- package/dist/providers/whatsapp-business/index.d.ts +1 -27
- package/dist/providers/whatsapp-business/index.js +2 -14
- package/package.json +23 -26
- package/dist/attachment-CnivEhr6.d.ts +0 -29
- package/dist/authoring-b9AhXgPI.d.ts +0 -304
- package/dist/chunk-2D27WW5B.js +0 -63
- package/dist/chunk-34FQGGD7.js +0 -34
- package/dist/chunk-3GEJYGZK.js +0 -84
- package/dist/chunk-3KWFP4L2.js +0 -864
- package/dist/chunk-5XEFJBN2.js +0 -197
- package/dist/chunk-6UZFVXQF.js +0 -374
- package/dist/chunk-A37PM5N2.js +0 -91
- package/dist/chunk-B52VPQO3.js +0 -1379
- package/dist/chunk-DMT6BFJV.js +0 -2980
- package/dist/chunk-FAIFTUV2.js +0 -139
- package/dist/chunk-IM5ADDZS.js +0 -887
- package/dist/chunk-LZXPLXZF.js +0 -35
- package/dist/chunk-U3QQ56YZ.js +0 -929
- package/dist/chunk-UXAKIXVM.js +0 -409
- package/dist/chunk-WXLQNANA.js +0 -539
- package/dist/chunk-ZR3TKZMT.js +0 -129
- package/dist/read-C4uvozGX.d.ts +0 -53
- package/dist/types-BIta6Kxi.d.ts +0 -82
- package/dist/types-CyfLJXgu.d.ts +0 -1530
package/dist/chunk-FAIFTUV2.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
bufferToStream,
|
|
4
|
-
fetchUrlBytes,
|
|
5
|
-
readSchema,
|
|
6
|
-
streamSchema
|
|
7
|
-
} from "./chunk-UXAKIXVM.js";
|
|
8
|
-
|
|
9
|
-
// src/content/voice.ts
|
|
10
|
-
import { createReadStream } from "fs";
|
|
11
|
-
import { readFile, stat } from "fs/promises";
|
|
12
|
-
import { basename } from "path";
|
|
13
|
-
import { Readable } from "stream";
|
|
14
|
-
import { lookup as lookupMimeType } from "mime-types";
|
|
15
|
-
import z from "zod";
|
|
16
|
-
var AUDIO_MIME_PATTERN = /^audio\//i;
|
|
17
|
-
var audioMimeSchema = z.string().nonempty().regex(AUDIO_MIME_PATTERN, "voice content requires an audio/* MIME type");
|
|
18
|
-
var voiceSchema = z.object({
|
|
19
|
-
type: z.literal("voice"),
|
|
20
|
-
name: z.string().nonempty().optional(),
|
|
21
|
-
mimeType: audioMimeSchema,
|
|
22
|
-
duration: z.number().nonnegative().optional(),
|
|
23
|
-
size: z.number().int().nonnegative().optional(),
|
|
24
|
-
read: readSchema,
|
|
25
|
-
stream: streamSchema
|
|
26
|
-
});
|
|
27
|
-
var resolveVoiceName = (input, name) => {
|
|
28
|
-
if (name) {
|
|
29
|
-
return name;
|
|
30
|
-
}
|
|
31
|
-
if (input instanceof URL) {
|
|
32
|
-
return basename(input.pathname) || void 0;
|
|
33
|
-
}
|
|
34
|
-
if (typeof input === "string") {
|
|
35
|
-
return basename(input);
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
38
|
-
};
|
|
39
|
-
var resolveVoiceMimeHint = (input, name) => {
|
|
40
|
-
if (input instanceof URL) {
|
|
41
|
-
return basename(input.pathname) || void 0;
|
|
42
|
-
}
|
|
43
|
-
if (typeof input === "string") {
|
|
44
|
-
return basename(input);
|
|
45
|
-
}
|
|
46
|
-
return name;
|
|
47
|
-
};
|
|
48
|
-
var resolveVoiceMimeType = (name, mimeType) => {
|
|
49
|
-
if (mimeType) {
|
|
50
|
-
if (!AUDIO_MIME_PATTERN.test(mimeType)) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`voice content requires an audio/* MIME type, got "${mimeType}".`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return mimeType;
|
|
56
|
-
}
|
|
57
|
-
if (name) {
|
|
58
|
-
const resolved = lookupMimeType(name);
|
|
59
|
-
if (resolved && AUDIO_MIME_PATTERN.test(resolved)) {
|
|
60
|
-
return resolved;
|
|
61
|
-
}
|
|
62
|
-
if (resolved) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Resolved non-audio MIME type "${resolved}" from name "${name}". Pass options.mimeType explicitly with an audio/* type.`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
throw new Error(
|
|
69
|
-
"Unable to resolve MIME type for voice content. Pass options.mimeType explicitly."
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
var asVoice = (input) => {
|
|
73
|
-
let cached;
|
|
74
|
-
const read = () => {
|
|
75
|
-
cached ??= input.read().catch((err) => {
|
|
76
|
-
cached = void 0;
|
|
77
|
-
throw err;
|
|
78
|
-
});
|
|
79
|
-
return cached;
|
|
80
|
-
};
|
|
81
|
-
const stream = input.stream ?? (async () => bufferToStream(await read()));
|
|
82
|
-
return voiceSchema.parse({
|
|
83
|
-
type: "voice",
|
|
84
|
-
name: input.name,
|
|
85
|
-
mimeType: input.mimeType,
|
|
86
|
-
duration: input.duration,
|
|
87
|
-
size: input.size,
|
|
88
|
-
read,
|
|
89
|
-
stream
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
function voice(input, options) {
|
|
93
|
-
return {
|
|
94
|
-
build: async () => {
|
|
95
|
-
const name = resolveVoiceName(input, options?.name);
|
|
96
|
-
const mimeHint = resolveVoiceMimeHint(input, name);
|
|
97
|
-
const mimeType = resolveVoiceMimeType(mimeHint, options?.mimeType);
|
|
98
|
-
if (input instanceof URL) {
|
|
99
|
-
return asVoice({
|
|
100
|
-
name,
|
|
101
|
-
mimeType,
|
|
102
|
-
duration: options?.duration,
|
|
103
|
-
read: async () => (await fetchUrlBytes(input)).data
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if (typeof input === "string") {
|
|
107
|
-
const stats = await stat(input);
|
|
108
|
-
if (!stats.isFile()) {
|
|
109
|
-
throw new Error(
|
|
110
|
-
`voice content path "${input}" is not a regular file.`
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
return asVoice({
|
|
114
|
-
name,
|
|
115
|
-
mimeType,
|
|
116
|
-
duration: options?.duration,
|
|
117
|
-
size: stats.size,
|
|
118
|
-
read: () => readFile(input),
|
|
119
|
-
stream: async () => Readable.toWeb(
|
|
120
|
-
createReadStream(input)
|
|
121
|
-
)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return asVoice({
|
|
125
|
-
name,
|
|
126
|
-
mimeType,
|
|
127
|
-
duration: options?.duration,
|
|
128
|
-
size: input.byteLength,
|
|
129
|
-
read: async () => input,
|
|
130
|
-
stream: async () => bufferToStream(input)
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export {
|
|
137
|
-
asVoice,
|
|
138
|
-
voice
|
|
139
|
-
};
|