web-sdk-pp-detection 0.1.1 → 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 +20 -8
- package/dist/browser-global.js +214 -23
- package/dist/browser-global.js.map +1 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.js +214 -23
- package/dist/index.js.map +1 -1
- package/dist/inference.worker.js +10 -2
- package/dist/inference.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/inference.worker.js
CHANGED
|
@@ -13650,7 +13650,7 @@ function mapError(error, phase) {
|
|
|
13650
13650
|
if (error instanceof PPDetectionError) return error;
|
|
13651
13651
|
const message = error instanceof Error ? error.message : String(error);
|
|
13652
13652
|
const details = { phase, causeMessage: message };
|
|
13653
|
-
if (
|
|
13653
|
+
if (error instanceof Error && error.name === "AbortError")
|
|
13654
13654
|
return new PPDetectionError("ABORTED", "\u63A8\u7406\u5DF2\u53D6\u6D88", details, { cause: error });
|
|
13655
13655
|
if (/memory|out.of.memory|allocation/i.test(message))
|
|
13656
13656
|
return new PPDetectionError("OUT_OF_MEMORY", "\u8FD0\u884C\u65F6\u5185\u5B58\u4E0D\u8DB3", details, { cause: error });
|
|
@@ -13695,6 +13695,7 @@ async function createOrtSession(modelBytes, plan, options = {}) {
|
|
|
13695
13695
|
return {
|
|
13696
13696
|
plan,
|
|
13697
13697
|
sessionMs,
|
|
13698
|
+
runtimeVersion: ort.env.versions?.web ?? null,
|
|
13698
13699
|
async run(feeds, runOptions = {}) {
|
|
13699
13700
|
if (disposed) throw new PPDetectionError("DISPOSED", "\u4F1A\u8BDD\u5DF2\u91CA\u653E", { phase: "run" });
|
|
13700
13701
|
if (runOptions.signal?.aborted)
|
|
@@ -13819,7 +13820,14 @@ workerScope.onmessage = async (event) => {
|
|
|
13819
13820
|
const previousSession = session;
|
|
13820
13821
|
session = nextSession;
|
|
13821
13822
|
await previousSession?.dispose();
|
|
13822
|
-
send({
|
|
13823
|
+
send({
|
|
13824
|
+
id: request.id,
|
|
13825
|
+
type: "result",
|
|
13826
|
+
result: {
|
|
13827
|
+
loaded: true,
|
|
13828
|
+
runtimeVersion: nextSession.runtimeVersion ?? null
|
|
13829
|
+
}
|
|
13830
|
+
});
|
|
13823
13831
|
return;
|
|
13824
13832
|
}
|
|
13825
13833
|
if (request.type === "run") {
|