@whanext/core 0.19.15 → 0.19.16
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/CHANGELOG.md +10 -0
- package/README.md +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.16
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Remote media URLs are now streamed into Zapo instead of being fully materialized as `Uint8Array` in memory before upload. This removes the extra whole-file buffering step that could stall or intermittently fail larger MP3/audio sends.
|
|
7
|
+
- Remote media fetches now have a bounded 120-second transfer timeout and surface provider errors when the source cannot be opened or returns an empty body.
|
|
8
|
+
- Local paths and caller-provided byte arrays keep their existing behavior.
|
|
9
|
+
|
|
10
|
+
### Performance
|
|
11
|
+
- URL-backed audio/video/image uploads now follow Zapo's recommended streaming media path, keeping memory usage flat while Zapo stages, hashes, encrypts, and uploads the attachment.
|
|
12
|
+
|
|
3
13
|
## 0.19.15
|
|
4
14
|
|
|
5
15
|
### Added
|
package/README.md
CHANGED
|
@@ -537,6 +537,8 @@ const downloaded = await app.media.download(message);
|
|
|
537
537
|
await writeFile(`./downloads/${downloaded.fileName ?? message.id}`, downloaded.data);
|
|
538
538
|
```
|
|
539
539
|
|
|
540
|
+
Ao enviar `{ url }`, o provider abre a origem remota como stream e entrega o fluxo ao pipeline de mídia do Zapo; o arquivo não é carregado inteiro na memória antes do upload. Para arquivos locais, `{ path }` continua sendo a opção mais direta.
|
|
541
|
+
|
|
540
542
|
`download()` aceita a `Message` recebida, uma `QuotedMessage` ou uma `MessageKey` e devolve o buffer junto dos metadados normalizados. A mídia deve ser baixada enquanto a mensagem ainda está no cache da instância; o provider tenta renovar a URL de mídia automaticamente quando necessário.
|
|
541
543
|
|
|
542
544
|
Para visualização única citada, o provider oficial preserva os metadados do envelope sem expor tipos do Zapo:
|
package/dist/index.d.ts
CHANGED
|
@@ -646,8 +646,8 @@ declare const guards: {
|
|
|
646
646
|
custom(guard: CommandGuard): CommandGuard;
|
|
647
647
|
};
|
|
648
648
|
|
|
649
|
-
type CommandScope =
|
|
650
|
-
type ConcurrencyStrategy =
|
|
649
|
+
type CommandScope = 'global' | 'user' | 'chat' | 'user-chat' | 'user-group';
|
|
650
|
+
type ConcurrencyStrategy = 'parallel' | 'reject' | 'queue' | 'replace';
|
|
651
651
|
interface CommandCooldown {
|
|
652
652
|
durationMs: number;
|
|
653
653
|
scope?: CommandScope;
|
package/dist/index.js
CHANGED
|
@@ -2406,6 +2406,7 @@ var Browser = /* @__PURE__ */ ((Browser2) => {
|
|
|
2406
2406
|
// src/provider/zapo/zapo-provider.ts
|
|
2407
2407
|
import { mkdir, stat } from "fs/promises";
|
|
2408
2408
|
import { createRequire as createRequire2 } from "module";
|
|
2409
|
+
import { Readable } from "stream";
|
|
2409
2410
|
import { basename, dirname as dirname2, join, resolve as resolve2 } from "path";
|
|
2410
2411
|
import { createMediaProcessor } from "@zapo-js/media-utils";
|
|
2411
2412
|
import { createSqliteStore } from "@zapo-js/store-sqlite";
|
|
@@ -2930,6 +2931,7 @@ var fatalDisconnectReasons = /* @__PURE__ */ new Set([
|
|
|
2930
2931
|
]);
|
|
2931
2932
|
var fatalDisconnectCodes = /* @__PURE__ */ new Set([401, 403, 405, 406, 409, 516]);
|
|
2932
2933
|
var sharedMediaProcessor = createMediaProcessor();
|
|
2934
|
+
var REMOTE_MEDIA_TIMEOUT_MS = 12e4;
|
|
2933
2935
|
var messageSnapshotRetentionSeconds = 7 * 24 * 60 * 60;
|
|
2934
2936
|
var messageSnapshotMaxPerSession = 2e4;
|
|
2935
2937
|
var messageSnapshotPruneInterval = 256;
|
|
@@ -3968,8 +3970,20 @@ var ZapoProvider = class {
|
|
|
3968
3970
|
async #media(source) {
|
|
3969
3971
|
if (source instanceof Uint8Array) return source;
|
|
3970
3972
|
if ("path" in source) return source.path;
|
|
3971
|
-
|
|
3973
|
+
let response;
|
|
3974
|
+
try {
|
|
3975
|
+
response = await fetch(source.url, {
|
|
3976
|
+
signal: AbortSignal.timeout(REMOTE_MEDIA_TIMEOUT_MS)
|
|
3977
|
+
});
|
|
3978
|
+
} catch (error) {
|
|
3979
|
+
throw new WhaNextError(
|
|
3980
|
+
"PROVIDER_ERROR",
|
|
3981
|
+
"Could not open the remote media source.",
|
|
3982
|
+
{ cause: error, recoverable: true }
|
|
3983
|
+
);
|
|
3984
|
+
}
|
|
3972
3985
|
if (!response.ok) {
|
|
3986
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3973
3987
|
throw new WhaNextError(
|
|
3974
3988
|
"PROVIDER_ERROR",
|
|
3975
3989
|
"Could not download the remote media source.",
|
|
@@ -3979,7 +3993,16 @@ var ZapoProvider = class {
|
|
|
3979
3993
|
}
|
|
3980
3994
|
);
|
|
3981
3995
|
}
|
|
3982
|
-
|
|
3996
|
+
if (!response.body) {
|
|
3997
|
+
throw new WhaNextError(
|
|
3998
|
+
"PROVIDER_ERROR",
|
|
3999
|
+
"The remote media source returned an empty response body.",
|
|
4000
|
+
{ recoverable: true }
|
|
4001
|
+
);
|
|
4002
|
+
}
|
|
4003
|
+
return Readable.fromWeb(
|
|
4004
|
+
response.body
|
|
4005
|
+
);
|
|
3983
4006
|
}
|
|
3984
4007
|
#mentions(mentions) {
|
|
3985
4008
|
return mentions.map((mention) => typeof mention === "string" ? mention : mention.mentionId);
|