@microblink/capture 1.0.5 → 1.0.7
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/dist/capture.js +4334 -4734
- package/dist/capture.umd.cjs +54 -49
- package/dist/resources/advanced/capture-wasm.wasm +0 -0
- package/dist/resources/advanced-threads/capture-wasm.wasm +0 -0
- package/dist/resources/basic/capture-wasm.wasm +0 -0
- package/dist/resources/capture-worker.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +4 -25
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,4 +2,4 @@ var captureWorker=function(P){"use strict";/**
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/const
|
|
5
|
+
*/const W=Symbol("Comlink.proxy"),B=Symbol("Comlink.endpoint"),I=Symbol("Comlink.releaseProxy"),m=Symbol("Comlink.finalizer"),h=Symbol("Comlink.thrown"),T=e=>typeof e=="object"&&e!==null||typeof e=="function",F={canHandle:e=>T(e)&&e[W],serialize(e){const{port1:t,port2:r}=new MessageChannel;return R(e,t),[r,[r]]},deserialize(e){return e.start(),D(e)}},H={canHandle:e=>T(e)&&h in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},x=new Map([["proxy",F],["throw",H]]);function V(e,t){for(const r of e)if(t===r||r==="*"||r instanceof RegExp&&r.test(t))return!0;return!1}function R(e,t=globalThis,r=["*"]){t.addEventListener("message",function o(s){if(!s||!s.data)return;if(!V(r,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:i,type:n,path:a}=Object.assign({path:[]},s.data),f=(s.data.argumentList||[]).map(y);let c;try{const l=a.slice(0,-1).reduce((u,b)=>u[b],e),d=a.reduce((u,b)=>u[b],e);switch(n){case"GET":c=d;break;case"SET":l[a.slice(-1)[0]]=y(s.data.value),c=!0;break;case"APPLY":c=d.apply(l,f);break;case"CONSTRUCT":{const u=new d(...f);c=O(u)}break;case"ENDPOINT":{const{port1:u,port2:b}=new MessageChannel;R(e,b),c=X(u,[u])}break;case"RELEASE":c=void 0;break;default:return}}catch(l){c={value:l,[h]:0}}Promise.resolve(c).catch(l=>({value:l,[h]:0})).then(l=>{const[d,u]=S(l);t.postMessage(Object.assign(Object.assign({},d),{id:i}),u),n==="RELEASE"&&(t.removeEventListener("message",o),C(t),m in e&&typeof e[m]=="function"&&e[m]())}).catch(l=>{const[d,u]=S({value:new TypeError("Unserializable return value"),[h]:0});t.postMessage(Object.assign(Object.assign({},d),{id:i}),u)})}),t.start&&t.start()}function _(e){return e.constructor.name==="MessagePort"}function C(e){_(e)&&e.close()}function D(e,t){return M(e,[],t)}function A(e){if(e)throw new Error("Proxy has been released and is not useable")}function L(e){return g(e,{type:"RELEASE"}).then(()=>{C(e)})}const E=new WeakMap,k="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(E.get(e)||0)-1;E.set(e,t),t===0&&L(e)});function G(e,t){const r=(E.get(t)||0)+1;E.set(t,r),k&&k.register(e,t,e)}function q(e){k&&k.unregister(e)}function M(e,t=[],r=function(){}){let o=!1;const s=new Proxy(r,{get(i,n){if(A(o),n===I)return()=>{q(s),L(e),o=!0};if(n==="then"){if(t.length===0)return{then:()=>s};const a=g(e,{type:"GET",path:t.map(f=>f.toString())}).then(y);return a.then.bind(a)}return M(e,[...t,n])},set(i,n,a){A(o);const[f,c]=S(a);return g(e,{type:"SET",path:[...t,n].map(l=>l.toString()),value:f},c).then(y)},apply(i,n,a){A(o);const f=t[t.length-1];if(f===B)return g(e,{type:"ENDPOINT"}).then(y);if(f==="bind")return M(e,t.slice(0,-1));const[c,l]=z(a);return g(e,{type:"APPLY",path:t.map(d=>d.toString()),argumentList:c},l).then(y)},construct(i,n){A(o);const[a,f]=z(n);return g(e,{type:"CONSTRUCT",path:t.map(c=>c.toString()),argumentList:a},f).then(y)}});return G(s,e),s}function Y(e){return Array.prototype.concat.apply([],e)}function z(e){const t=e.map(S);return[t.map(r=>r[0]),Y(t.map(r=>r[1]))]}const v=new WeakMap;function X(e,t){return v.set(e,t),e}function O(e){return Object.assign(e,{[W]:!0})}function S(e){for(const[t,r]of x)if(r.canHandle(e)){const[o,s]=r.serialize(e);return[{type:"HANDLER",name:t,value:o},s]}return[{type:"RAW",value:e},v.get(e)||[]]}function y(e){switch(e.type){case"HANDLER":return x.get(e.name).deserialize(e.value);case"RAW":return e.value}}function g(e,t,r){return new Promise(o=>{const s=J();e.addEventListener("message",function i(n){!n.data||!n.data.id||n.data.id!==s||(e.removeEventListener("message",i),o(n.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:s},t),r)})}function J(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const K=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),Q=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])),Z=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),ee=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])),te=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])),re=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),ne=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]));function se(){return/iOS|iPhone|iPad|iPod/i.test(navigator.userAgent)}async function ae(){if(!await ne())return!1;if(!("importScripts"in self))throw Error("Not implemented");return se()?!1:"Worker"in self}async function oe(){const e=[Q(),Z(),K(),ee(),te()];if(!(await Promise.all(e)).every(Boolean))throw new Error("Browser doesn't meet minimum requirements!");return await re()?await ae()?"advanced-threads":"advanced":"basic"}const j="application/javascript",N=(e,t={})=>{const r={skipSameOrigin:!0,useBlob:!0,...t};return r.skipSameOrigin&&new URL(e).origin===self.location.origin?Promise.resolve(e):new Promise((o,s)=>void fetch(e).then(i=>i.text()).then(i=>{new URL(e).href.split("/").pop();let a=`data:${j},`+encodeURIComponent(i);r.useBlob&&(a=URL.createObjectURL(new Blob([`importScripts("${a}")`],{type:j}))),o(a)}).catch(s))};let p,w,U;console.log("Worker loaded");async function ie(){const e=await oe();console.log(`Requesting ${e} Wasm build`);const t=`${U}/${e}`,r=`${t}/capture-wasm.js`,o=`${t}/capture-wasm.worker.js`,s=await N(r),i=await N(o);try{importScripts(s)}catch(n){console.error("loading scripts failed",n)}return p=await self.createModule({locateFile:n=>{let a;return n.includes(".worker.js")?a=i:a=`${U}/${e}/${n}`,a},mainScriptUrlOrBlob:s.toString(),setStatus:n=>{}}),p[m]=()=>{console.log("finalizer wasmModule")},O(p)}function ce(){return p||console.warn("Wasm is not initialized yet. Call loadWasm() first."),w=new p.Analyzer,w[m]=()=>{console.log("Comlink.finalizer called on Analyzer instance. Deleting instance."),w.delete()},O(w)}function le(e){const t=w.analyze(e);return self.postMessage({},[e.data.buffer]),e=null,t}const $={createAnalyzer:ce,loadWasm:ie,analyze:le,terminate:()=>self.close(),setResourceUrl:e=>{U=e},[m]:()=>{console.log("Comlink.finalizer called on proxyWorker")}};return R($),P.proxyWorker=$,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({});
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -455,34 +455,15 @@ export declare function createCaptureSdk(settings: CaptureSdkSettings): Promise<
|
|
|
455
455
|
destroy: typeof destroy;
|
|
456
456
|
}>;
|
|
457
457
|
|
|
458
|
-
/** Creates the capture UI and loads the SDK */
|
|
459
|
-
export declare function createCaptureUi(settings: CreateCaptureUiSettings): Promise<CaptureComponent>;
|
|
460
|
-
|
|
461
458
|
/**
|
|
462
|
-
*
|
|
459
|
+
* Creates the capture UI and loads the SDK
|
|
463
460
|
*
|
|
464
|
-
* @param
|
|
465
|
-
* @param sdkSettings Settings for the Capture SDK
|
|
466
|
-
* @param uiSettings Settings for the Capture SDK UI component
|
|
461
|
+
* @param settings {@linkcode CreateCaptureUiSettings}
|
|
467
462
|
* @returns An object with methods for controlling the Capture SDK and the UI
|
|
468
463
|
* component
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```typescript
|
|
472
|
-
* // Load the UI and the SDK
|
|
473
|
-
* const captureComponent = await createCaptureUi({
|
|
474
|
-
* sdkSettings: {
|
|
475
|
-
* licenseKey: "YOUR_LICENCE_KEY",
|
|
476
|
-
* callbacks: {
|
|
477
|
-
* onCaptureResult: (result) => console.log(result),
|
|
478
|
-
* },
|
|
479
|
-
* },
|
|
480
|
-
* });
|
|
481
|
-
*
|
|
482
|
-
* // Will dismount and clean up
|
|
483
|
-
* captureComponent.dismount()
|
|
484
|
-
* ```
|
|
485
464
|
*/
|
|
465
|
+
export declare function createCaptureUi(settings: CreateCaptureUiSettings): Promise<CaptureComponent>;
|
|
466
|
+
|
|
486
467
|
declare type CreateCaptureUiSettings = {
|
|
487
468
|
sdkSettings: CaptureSdkSettings;
|
|
488
469
|
uiSettings?: UiSettings;
|
|
@@ -702,8 +683,6 @@ export declare type LightingThresholds = {
|
|
|
702
683
|
|
|
703
684
|
declare type LocalizationStrings = typeof _default;
|
|
704
685
|
|
|
705
|
-
export declare const MOUNT_POINT_ID = "mount-point";
|
|
706
|
-
|
|
707
686
|
/**
|
|
708
687
|
* Pauses the capture process without resetting the recognizer.
|
|
709
688
|
*/
|