@omnimedia/omnitool 1.1.0-97 → 1.1.0-98
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/package.json +1 -1
- package/s/features/bg-remover/worker.bundle.ts +4 -3
- package/s/features/parts/expose-errors.ts +41 -0
- package/s/features/speech/transcribe/worker.bundle.ts +4 -3
- package/x/features/bg-remover/worker.bundle.js +4 -3
- package/x/features/bg-remover/worker.bundle.js.map +1 -1
- package/x/features/bg-remover/worker.bundle.min.js +167 -167
- package/x/features/bg-remover/worker.bundle.min.js.map +4 -4
- package/x/features/parts/expose-errors.d.ts +3 -0
- package/x/features/parts/expose-errors.js +32 -0
- package/x/features/parts/expose-errors.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.js +4 -3
- package/x/features/speech/transcribe/worker.bundle.js.map +1 -1
- package/x/features/speech/transcribe/worker.bundle.min.js +167 -167
- package/x/features/speech/transcribe/worker.bundle.min.js.map +4 -4
- package/x/index.html +1 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {BackgroundRemovalPipeline} from "@huggingface/transformers"
|
|
|
6
6
|
import {PipelineSpec} from "../parts/types.js"
|
|
7
7
|
import {BgRemoverSchematic} from "./types.js"
|
|
8
8
|
import {loadPipe} from "../parts/load-pipe.js"
|
|
9
|
+
import {exposeErrors} from "../parts/expose-errors.js"
|
|
9
10
|
|
|
10
11
|
const deferred = defer<{spec: PipelineSpec, pipe: BackgroundRemovalPipeline}>()
|
|
11
12
|
const makePrepare = (host: Host<BgRemoverSchematic>) => once(async(spec: PipelineSpec) => {
|
|
@@ -25,8 +26,8 @@ const ctx = canvas.getContext("2d")
|
|
|
25
26
|
await Comrade.worker<BgRemoverSchematic>(shell => {
|
|
26
27
|
const prepare = makePrepare(shell.host)
|
|
27
28
|
return {
|
|
28
|
-
prepare,
|
|
29
|
-
|
|
29
|
+
prepare: exposeErrors(prepare),
|
|
30
|
+
remove: exposeErrors(async(request) => {
|
|
30
31
|
const {pipe} = await deferred.promise
|
|
31
32
|
|
|
32
33
|
canvas.width = request.displayWidth
|
|
@@ -44,7 +45,7 @@ await Comrade.worker<BgRemoverSchematic>(shell => {
|
|
|
44
45
|
request.close()
|
|
45
46
|
shell.transfer = [frame]
|
|
46
47
|
return frame
|
|
47
|
-
}
|
|
48
|
+
})
|
|
48
49
|
}
|
|
49
50
|
})
|
|
50
51
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {ExposedError} from "@e280/renraku"
|
|
2
|
+
|
|
3
|
+
export function exposeError(error: unknown) {
|
|
4
|
+
if (error instanceof ExposedError)
|
|
5
|
+
return error
|
|
6
|
+
|
|
7
|
+
const exposed = new ExposedError(errorToString(error))
|
|
8
|
+
|
|
9
|
+
if (error instanceof Error)
|
|
10
|
+
exposed.stack = error.stack
|
|
11
|
+
|
|
12
|
+
return exposed
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function exposeErrors<Args extends unknown[], Result>(
|
|
16
|
+
fn: (...args: Args) => Result | Promise<Result>
|
|
17
|
+
) {
|
|
18
|
+
return async(...args: Args) => {
|
|
19
|
+
try {
|
|
20
|
+
return await fn(...args)
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw exposeError(error)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function errorToString(error: unknown) {
|
|
29
|
+
if (error instanceof Error)
|
|
30
|
+
return error.message
|
|
31
|
+
|
|
32
|
+
if (typeof error === "string")
|
|
33
|
+
return error
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(error) ?? String(error)
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return String(error)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -5,6 +5,7 @@ import {AutomaticSpeechRecognitionPipeline, Pipeline} from "@huggingface/transfo
|
|
|
5
5
|
|
|
6
6
|
import {loadPipe} from "../../parts/load-pipe.js"
|
|
7
7
|
import {transcribe} from "./parts/transcribe.js"
|
|
8
|
+
import {exposeErrors} from "../../parts/expose-errors.js"
|
|
8
9
|
import {TranscriberSchematic, TranscriberSpec} from "./types.js"
|
|
9
10
|
|
|
10
11
|
const deferred = defer<{pipe: Pipeline, spec: TranscriberSpec}>()
|
|
@@ -23,8 +24,8 @@ const makePrepare = (host: Host<TranscriberSchematic>) => once(async(spec: Trans
|
|
|
23
24
|
await Comrade.worker<TranscriberSchematic>(shell => {
|
|
24
25
|
const prepare = makePrepare(shell.host)
|
|
25
26
|
return {
|
|
26
|
-
prepare,
|
|
27
|
-
|
|
27
|
+
prepare: exposeErrors(prepare),
|
|
28
|
+
transcribe: exposeErrors(async(request) => {
|
|
28
29
|
const {pipe, spec} = await deferred.promise
|
|
29
30
|
return transcribe({
|
|
30
31
|
pipe,
|
|
@@ -35,7 +36,7 @@ await Comrade.worker<TranscriberSchematic>(shell => {
|
|
|
35
36
|
onTranscription: transcription => shell.host.deliverTranscription(transcription),
|
|
36
37
|
},
|
|
37
38
|
})
|
|
38
|
-
}
|
|
39
|
+
})
|
|
39
40
|
}
|
|
40
41
|
})
|
|
41
42
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defer, once } from "@e280/stz";
|
|
2
2
|
import { Comrade } from "@e280/comrade";
|
|
3
3
|
import { loadPipe } from "../parts/load-pipe.js";
|
|
4
|
+
import { exposeErrors } from "../parts/expose-errors.js";
|
|
4
5
|
const deferred = defer();
|
|
5
6
|
const makePrepare = (host) => once(async (spec) => {
|
|
6
7
|
deferred.resolve({
|
|
@@ -17,8 +18,8 @@ const ctx = canvas.getContext("2d");
|
|
|
17
18
|
await Comrade.worker(shell => {
|
|
18
19
|
const prepare = makePrepare(shell.host);
|
|
19
20
|
return {
|
|
20
|
-
prepare,
|
|
21
|
-
async
|
|
21
|
+
prepare: exposeErrors(prepare),
|
|
22
|
+
remove: exposeErrors(async (request) => {
|
|
22
23
|
const { pipe } = await deferred.promise;
|
|
23
24
|
canvas.width = request.displayWidth;
|
|
24
25
|
canvas.height = request.displayHeight;
|
|
@@ -32,7 +33,7 @@ await Comrade.worker(shell => {
|
|
|
32
33
|
request.close();
|
|
33
34
|
shell.transfer = [frame];
|
|
34
35
|
return frame;
|
|
35
|
-
}
|
|
36
|
+
})
|
|
36
37
|
};
|
|
37
38
|
});
|
|
38
39
|
//# sourceMappingURL=worker.bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.bundle.js","sourceRoot":"","sources":["../../../s/features/bg-remover/worker.bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,EAAC,OAAO,EAAO,MAAM,eAAe,CAAA;AAK3C,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"worker.bundle.js","sourceRoot":"","sources":["../../../s/features/bg-remover/worker.bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,EAAC,OAAO,EAAO,MAAM,eAAe,CAAA;AAK3C,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAA;AAEtD,MAAM,QAAQ,GAAG,KAAK,EAAyD,CAAA;AAC/E,MAAM,WAAW,GAAG,CAAC,IAA8B,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAC,IAAkB,EAAE,EAAE;IACxF,QAAQ,CAAC,OAAO,CAAC;QAChB,IAAI;QACJ,IAAI,EAAE,MAAM,QAAQ,CAAC;YACpB,IAAI;YACJ,IAAI,EAAE,oBAAoB;YAC1B,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SAC3C,CAA8B;KAC/B,CAAC,CAAA;AACH,CAAC,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