web-sdk-pp-detection 0.2.0 → 0.3.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 +10 -6
- package/dist/browser-global.js +14 -7
- package/dist/browser-global.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -141,6 +141,7 @@ interface PPDetectionProgressEvent {
|
|
|
141
141
|
readonly fallback?: PPDetectionFallback;
|
|
142
142
|
}
|
|
143
143
|
interface CreatePPDetectionOptions {
|
|
144
|
+
readonly allowExperimental?: boolean;
|
|
144
145
|
readonly allowFallback?: boolean;
|
|
145
146
|
readonly backend?: BackendPreference;
|
|
146
147
|
readonly cache?: boolean | "memory" | "indexeddb";
|
|
@@ -401,6 +402,7 @@ declare class PPDetectionError extends Error {
|
|
|
401
402
|
}
|
|
402
403
|
|
|
403
404
|
interface SelectExecutionOptions {
|
|
405
|
+
readonly allowExperimental?: boolean;
|
|
404
406
|
readonly backend?: BackendPreference;
|
|
405
407
|
readonly precision?: Precision;
|
|
406
408
|
readonly executionMode?: ExecutionMode;
|
|
@@ -633,7 +635,7 @@ declare class IndexedDBModelCache implements ModelCache {
|
|
|
633
635
|
declare global {
|
|
634
636
|
var __PPDETECTION_SCRIPT_URL__: string | undefined;
|
|
635
637
|
}
|
|
636
|
-
declare const CURRENT_SDK_VERSION = "0.
|
|
638
|
+
declare const CURRENT_SDK_VERSION = "0.3.0";
|
|
637
639
|
|
|
638
640
|
declare function probePPDetectionCapabilities(options?: CapabilityProbeOptions): DetectionCapabilities;
|
|
639
641
|
|
package/dist/index.js
CHANGED
|
@@ -2031,13 +2031,19 @@ function selectExecutionPlan(options, capabilities, manifest) {
|
|
|
2031
2031
|
if (executionMode === "worker" && !capabilities.worker) {
|
|
2032
2032
|
fail("CAPABILITY_UNSUPPORTED", "\u8BF7\u6C42\u7684 worker \u4E0D\u53EF\u7528", { executionMode });
|
|
2033
2033
|
}
|
|
2034
|
-
const
|
|
2035
|
-
(candidate) => candidate.precision === requestedPrecision && candidate.status !== "
|
|
2036
|
-
);
|
|
2034
|
+
const matchingVariants = manifest.variants?.filter(
|
|
2035
|
+
(candidate) => candidate.precision === requestedPrecision && candidate.status !== "blocked"
|
|
2036
|
+
) ?? [];
|
|
2037
|
+
const variant3 = matchingVariants.find((candidate) => candidate.status !== "labs") ?? (options.allowExperimental === true ? matchingVariants.find((candidate) => candidate.status === "labs") : void 0);
|
|
2037
2038
|
if (!variant3) {
|
|
2038
|
-
fail(
|
|
2039
|
-
|
|
2040
|
-
|
|
2039
|
+
fail(
|
|
2040
|
+
"MODEL_INCOMPATIBLE",
|
|
2041
|
+
options.allowExperimental === true ? `manifest \u6CA1\u6709\u53EF\u7528\u7684 ${requestedPrecision} \u53D8\u4F53` : `manifest \u6CA1\u6709\u53EF\u7528\u7684 ${requestedPrecision} \u7A33\u5B9A\u53D8\u4F53`,
|
|
2042
|
+
{
|
|
2043
|
+
requestedPrecision,
|
|
2044
|
+
allowExperimental: options.allowExperimental === true
|
|
2045
|
+
}
|
|
2046
|
+
);
|
|
2041
2047
|
}
|
|
2042
2048
|
const candidates = candidatesForBackend(requestedBackend, capabilities).filter(
|
|
2043
2049
|
(backend) => variant3.backends.includes(backend)
|
|
@@ -2213,7 +2219,7 @@ var WorkerBridge = class {
|
|
|
2213
2219
|
};
|
|
2214
2220
|
|
|
2215
2221
|
// src/index.ts
|
|
2216
|
-
var CURRENT_SDK_VERSION = "0.
|
|
2222
|
+
var CURRENT_SDK_VERSION = "0.3.0";
|
|
2217
2223
|
function probePPDetectionCapabilities(options = {}) {
|
|
2218
2224
|
return probeCapabilities(options);
|
|
2219
2225
|
}
|
|
@@ -2328,6 +2334,7 @@ async function createPPDetection(options = {}) {
|
|
|
2328
2334
|
options.onProgress?.({ phase: "manifest", status: "complete" });
|
|
2329
2335
|
const plan = selectExecutionPlan(
|
|
2330
2336
|
{
|
|
2337
|
+
allowExperimental: options.allowExperimental,
|
|
2331
2338
|
backend: options.backend,
|
|
2332
2339
|
precision: options.precision === "auto" ? void 0 : options.precision,
|
|
2333
2340
|
executionMode: options.executionMode,
|