@privateid/small-age-sdk-alpha
Version:
55 lines • 2.43 kB
JavaScript
/* eslint-disable camelcase */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* @module PrivID
*/
import { detect } from 'detect-browser';
import { isLoad, getDebugType, getIsSIMD, iOS, printLogs, checkPackageSupport } from './utils';
let isSimd = null;
let moduleLoaded = false;
const debugType = getDebugType();
printLogs('debug_type', debugType, debugType);
/**
* This function load the wasm module
* @category Utils
*/
export const loadPrivIdModule = function (loadAntispoof = true) {
return __awaiter(this, void 0, void 0, function* () {
try {
const supportResult = yield checkPackageSupport();
if (moduleLoaded)
return { support: true };
const hasSIMD = yield getIsSIMD();
printLogs('=====> is SIMD or NOT SIMD?', hasSIMD, debugType);
printLogs('===> is IOS', iOS(), debugType);
printLogs('==> browser? ', detect(), debugType);
const { name: browserName, os } = detect();
if (iOS() || os === 'iOS' || (os === 'Mac OS' && browserName !== 'chrome')) {
isSimd = false;
}
else {
isSimd = hasSIMD;
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const loaded = yield isLoad(isSimd, debugType);
printLogs('------loaded------', loaded, debugType);
moduleLoaded = loaded === 'Loaded';
return supportResult;
}
catch (e) {
return { support: false, message: 'Unable to load wasm' };
}
});
};
export const isModuleLoaded = () => moduleLoaded;
export * from './ageestimate';
//# sourceMappingURL=index.js.map