@polkadot/wasm-crypto
Advanced tools
Comparing version 6.0.2-7 to 6.0.2-8
@@ -1,2 +0,2 @@ | ||
import type { WasmCryptoInstance } from './types'; | ||
import type { CreatePromise, WasmCryptoInstance } from './types'; | ||
declare type PopFirst<T extends unknown[]> = T extends [WasmCryptoInstance, ...infer N] ? N : []; | ||
@@ -6,6 +6,4 @@ interface Bridge { | ||
cachegetUint8: Uint8Array | null; | ||
type: 'wasm' | 'asm'; | ||
wasm: WasmCryptoInstance | null; | ||
wasmPromise: Promise<void> | null; | ||
wasmPromiseFn: null | (() => Promise<void>); | ||
wasmPromise: CreatePromise | null; | ||
} | ||
@@ -12,0 +10,0 @@ export declare const __bridge: Bridge; |
@@ -9,6 +9,4 @@ // Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
cachegetUint8: null, | ||
type: 'wasm', | ||
wasm: null, | ||
wasmPromise: null, | ||
wasmPromiseFn: null | ||
wasmPromise: null | ||
}; | ||
@@ -15,0 +13,0 @@ export function withWasm(fn) { |
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { __bridge, allocString, allocU8a, getWasm, resultString, resultU8a, withWasm } from "./bridge.js"; | ||
import { allocString, allocU8a, getWasm, resultString, resultU8a, withWasm } from "./bridge.js"; | ||
import { initWasm } from "./init.js"; | ||
@@ -139,11 +139,3 @@ export { packageInfo } from "./packageInfo.js"; | ||
try { | ||
if (!__bridge.wasmPromise) { | ||
if (!__bridge.wasmPromiseFn) { | ||
__bridge.wasmPromiseFn = initWasm; | ||
} | ||
__bridge.wasmPromise = __bridge.wasmPromiseFn(); | ||
} | ||
await __bridge.wasmPromise; | ||
await initWasm(); | ||
return isReady(); | ||
@@ -150,0 +142,0 @@ } catch { |
@@ -27,6 +27,4 @@ "use strict"; | ||
cachegetUint8: null, | ||
type: 'wasm', | ||
wasm: null, | ||
wasmPromise: null, | ||
wasmPromiseFn: null | ||
wasmPromise: null | ||
}; | ||
@@ -33,0 +31,0 @@ exports.__bridge = __bridge; |
@@ -193,11 +193,3 @@ "use strict"; | ||
try { | ||
if (!_bridge.__bridge.wasmPromise) { | ||
if (!_bridge.__bridge.wasmPromiseFn) { | ||
_bridge.__bridge.wasmPromiseFn = _init.initWasm; | ||
} | ||
_bridge.__bridge.wasmPromise = _bridge.__bridge.wasmPromiseFn(); | ||
} | ||
await _bridge.__bridge.wasmPromise; | ||
await (0, _init.initWasm)(); | ||
return isReady(); | ||
@@ -204,0 +196,0 @@ } catch { |
@@ -8,9 +8,11 @@ "use strict"; | ||
var _packageInfo = require("@polkadot/wasm-crypto-asmjs/cjs/packageInfo"); | ||
var _packageInfo = require("@polkadot/wasm-crypto-init/cjs/packageInfo"); | ||
var _packageInfo2 = require("@polkadot/wasm-crypto-wasm/cjs/packageInfo"); | ||
var _packageInfo2 = require("@polkadot/wasm-data-asmjs/cjs/packageInfo"); | ||
var _packageInfo3 = require("@polkadot/wasm-data-wasm/cjs/packageInfo"); | ||
// Copyright 2017-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
var _default = [_packageInfo.packageInfo, _packageInfo2.packageInfo]; | ||
var _default = [_packageInfo.packageInfo, _packageInfo2.packageInfo, _packageInfo3.packageInfo]; | ||
exports.default = _default; |
@@ -7,9 +7,5 @@ "use strict"; | ||
exports.initWasm = initWasm; | ||
exports.setWasmPromise = setWasmPromise; | ||
exports.setWasmPromiseFn = setWasmPromiseFn; | ||
var _util = require("@polkadot/util"); | ||
var _wasmCryptoInit = require("@polkadot/wasm-crypto-init"); | ||
var _wasmCryptoWasm = require("@polkadot/wasm-crypto-wasm"); | ||
var _bridge = require("./bridge"); | ||
@@ -25,32 +21,11 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
async function createPromise(wasmBytes, asmFn) { | ||
try { | ||
(0, _util.assert)(typeof WebAssembly === 'object' && typeof WebAssembly.instantiate === 'function' && wasmBytes && wasmBytes.length, 'WebAssembly is not available in your environment'); | ||
const source = await WebAssembly.instantiate(wasmBytes, { | ||
wbg | ||
}); | ||
_bridge.__bridge.wasm = source.instance.exports; | ||
} catch (error) { | ||
// if we have a valid supplied asm.js, return that | ||
if (asmFn) { | ||
_bridge.__bridge.type = 'asm'; | ||
_bridge.__bridge.wasm = asmFn(wbg); | ||
} else { | ||
console.error(`FATAL: Unable to initialize @polkadot/wasm-crypto:: ${error.message}`); | ||
_bridge.__bridge.wasm = null; | ||
} | ||
async function initWasm(initOverride) { | ||
if (!_bridge.__bridge.wasmPromise || initOverride) { | ||
_bridge.__bridge.wasmPromise = (initOverride || _wasmCryptoInit.init)(wbg); | ||
} | ||
} | ||
function setWasmPromise(wasmBytes, asmFn) { | ||
_bridge.__bridge.wasmPromise = createPromise(wasmBytes, asmFn); | ||
return _bridge.__bridge.wasmPromise; | ||
} | ||
function setWasmPromiseFn(fn) { | ||
_bridge.__bridge.wasmPromiseFn = fn; | ||
} | ||
function initWasm() { | ||
return setWasmPromise(_wasmCryptoWasm.wasmBytes, null); | ||
const { | ||
wasm | ||
} = await _bridge.__bridge.wasmPromise; | ||
_bridge.__bridge.wasm = wasm; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.initWasm = initWasm; | ||
exports.setWasmOnlyPromise = setWasmOnlyPromise; | ||
exports.setWasmPromise = setWasmPromise; | ||
exports.setWasmPromiseFn = setWasmPromiseFn; | ||
var _none = require("@polkadot/wasm-crypto-init/cjs/none"); | ||
var _bridge = require("./bridge"); | ||
var _init = require("./init"); | ||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function setWasmPromise(_wasmBytes, _asmFn) { | ||
_bridge.__bridge.wasmPromise = Promise.resolve(); | ||
return _bridge.__bridge.wasmPromise; | ||
} | ||
function setWasmPromiseFn(fn) { | ||
_bridge.__bridge.wasmPromiseFn = fn; | ||
} | ||
function setWasmOnlyPromise() { | ||
return setWasmPromise(null, null); | ||
} | ||
function initWasm() { | ||
return setWasmOnlyPromise(); | ||
} | ||
setWasmPromiseFn(initWasm); | ||
(0, _init.initWasm)(_none.init).catch(undefined); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.initWasm = initWasm; | ||
var _asm = require("@polkadot/wasm-crypto-init/cjs/asm"); | ||
var _wasmCryptoAsmjs = require("@polkadot/wasm-crypto-asmjs"); | ||
var _init = require("./init"); | ||
@@ -14,6 +9,2 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
function initWasm() { | ||
return (0, _init.setWasmPromise)(null, _wasmCryptoAsmjs.asmJsInit); | ||
} | ||
(0, _init.setWasmPromiseFn)(initWasm); | ||
(0, _init.initWasm)(_asm.init).catch(undefined); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.initWasm = initWasm; | ||
var _wasm = require("@polkadot/wasm-crypto-init/cjs/wasm"); | ||
@@ -12,6 +9,2 @@ var _init = require("./init"); | ||
// SPDX-License-Identifier: Apache-2.0 | ||
function initWasm() { | ||
return (0, _init.initWasm)(); | ||
} | ||
(0, _init.setWasmPromiseFn)(initWasm); | ||
(0, _init.initWasm)(_wasm.init).catch(undefined); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.initWasm = initWasm; | ||
var _both = require("@polkadot/wasm-crypto-init/cjs/both"); | ||
var _wasmCryptoAsmjs = require("@polkadot/wasm-crypto-asmjs"); | ||
var _wasmCryptoWasm = require("@polkadot/wasm-crypto-wasm"); | ||
var _init = require("./init"); | ||
@@ -16,6 +9,2 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
function initWasm() { | ||
return (0, _init.setWasmPromise)(_wasmCryptoWasm.wasmBytes, _wasmCryptoAsmjs.asmJsInit); | ||
} | ||
(0, _init.setWasmPromiseFn)(initWasm); | ||
(0, _init.initWasm)(_both.init).catch(undefined); |
@@ -14,4 +14,4 @@ "use strict"; | ||
type: 'cjs', | ||
version: '6.0.2-7' | ||
version: '6.0.2-8' | ||
}; | ||
exports.packageInfo = packageInfo; |
// Copyright 2017-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { packageInfo as asmInfo } from '@polkadot/wasm-crypto-asmjs/packageInfo'; | ||
import { packageInfo as wasmInfo } from '@polkadot/wasm-crypto-wasm/packageInfo'; | ||
export default [asmInfo, wasmInfo]; | ||
import { packageInfo as initInfo } from '@polkadot/wasm-crypto-init/packageInfo'; | ||
import { packageInfo as asmInfo } from '@polkadot/wasm-data-asmjs/packageInfo'; | ||
import { packageInfo as wasmInfo } from '@polkadot/wasm-data-wasm/packageInfo'; | ||
export default [initInfo, asmInfo, wasmInfo]; |
@@ -1,4 +0,2 @@ | ||
import type { AsmCreator } from './types'; | ||
export declare function setWasmPromise(wasmBytes: Uint8Array | null, asmFn: AsmCreator | null): Promise<void>; | ||
export declare function setWasmPromiseFn(fn: () => Promise<void>): void; | ||
export declare function initWasm(): Promise<void>; | ||
import type { CreatePromise } from './types'; | ||
export declare function initWasm(initOverride?: (wbg: WebAssembly.ModuleImports) => CreatePromise): Promise<void>; |
37
init.js
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { assert } from '@polkadot/util'; | ||
import { wasmBytes } from '@polkadot/wasm-crypto-wasm'; | ||
import { init } from '@polkadot/wasm-crypto-init'; | ||
import { __bridge } from "./bridge.js"; | ||
import * as wbg from "./imports.js"; | ||
async function createPromise(wasmBytes, asmFn) { | ||
try { | ||
assert(typeof WebAssembly === 'object' && typeof WebAssembly.instantiate === 'function' && wasmBytes && wasmBytes.length, 'WebAssembly is not available in your environment'); | ||
const source = await WebAssembly.instantiate(wasmBytes, { | ||
wbg | ||
}); | ||
__bridge.wasm = source.instance.exports; | ||
} catch (error) { | ||
// if we have a valid supplied asm.js, return that | ||
if (asmFn) { | ||
__bridge.type = 'asm'; | ||
__bridge.wasm = asmFn(wbg); | ||
} else { | ||
console.error(`FATAL: Unable to initialize @polkadot/wasm-crypto:: ${error.message}`); | ||
__bridge.wasm = null; | ||
} | ||
export async function initWasm(initOverride) { | ||
if (!__bridge.wasmPromise || initOverride) { | ||
__bridge.wasmPromise = (initOverride || init)(wbg); | ||
} | ||
} | ||
export function setWasmPromise(wasmBytes, asmFn) { | ||
__bridge.wasmPromise = createPromise(wasmBytes, asmFn); | ||
return __bridge.wasmPromise; | ||
} | ||
export function setWasmPromiseFn(fn) { | ||
__bridge.wasmPromiseFn = fn; | ||
} | ||
export function initWasm() { | ||
return setWasmPromise(wasmBytes, null); | ||
const { | ||
wasm | ||
} = await __bridge.wasmPromise; | ||
__bridge.wasm = wasm; | ||
} |
@@ -1,5 +0,1 @@ | ||
import type { AsmCreator } from './types'; | ||
export declare function setWasmPromise(_wasmBytes: Uint8Array | null, _asmFn: AsmCreator | null): Promise<void>; | ||
export declare function setWasmPromiseFn(fn: () => Promise<void>): void; | ||
export declare function setWasmOnlyPromise(): Promise<void>; | ||
export declare function initWasm(): Promise<void>; | ||
export {}; |
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { __bridge } from "./bridge.js"; // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function setWasmPromise(_wasmBytes, _asmFn) { | ||
__bridge.wasmPromise = Promise.resolve(); | ||
return __bridge.wasmPromise; | ||
} | ||
export function setWasmPromiseFn(fn) { | ||
__bridge.wasmPromiseFn = fn; | ||
} | ||
export function setWasmOnlyPromise() { | ||
return setWasmPromise(null, null); | ||
} | ||
export function initWasm() { | ||
return setWasmOnlyPromise(); | ||
} | ||
setWasmPromiseFn(initWasm); | ||
import { init } from '@polkadot/wasm-crypto-init/none'; | ||
import { initWasm } from "./init.js"; | ||
initWasm(init).catch(undefined); |
@@ -1,1 +0,1 @@ | ||
export declare function initWasm(): Promise<void>; | ||
export {}; |
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs'; | ||
import { setWasmPromise, setWasmPromiseFn } from "./init.js"; | ||
export function initWasm() { | ||
return setWasmPromise(null, asmJsInit); | ||
} | ||
setWasmPromiseFn(initWasm); | ||
import { init } from '@polkadot/wasm-crypto-init/asm'; | ||
import { initWasm } from "./init.js"; | ||
initWasm(init).catch(undefined); |
@@ -1,1 +0,1 @@ | ||
export declare function initWasm(): Promise<void>; | ||
export {}; |
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { initWasm as baseInitWasm, setWasmPromiseFn } from "./init.js"; | ||
export function initWasm() { | ||
return baseInitWasm(); | ||
} | ||
setWasmPromiseFn(initWasm); | ||
import { init } from '@polkadot/wasm-crypto-init/wasm'; | ||
import { initWasm } from "./init.js"; | ||
initWasm(init).catch(undefined); |
@@ -1,1 +0,1 @@ | ||
export declare function initWasm(): Promise<void>; | ||
export {}; |
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs'; | ||
import { wasmBytes } from '@polkadot/wasm-crypto-wasm'; | ||
import { setWasmPromise, setWasmPromiseFn } from "./init.js"; | ||
export function initWasm() { | ||
return setWasmPromise(wasmBytes, asmJsInit); | ||
} | ||
setWasmPromiseFn(initWasm); | ||
import { init } from '@polkadot/wasm-crypto-init/both'; | ||
import { initWasm } from "./init.js"; | ||
initWasm(init).catch(undefined); |
@@ -31,3 +31,3 @@ { | ||
"type": "module", | ||
"version": "6.0.2-7", | ||
"version": "6.0.2-8", | ||
"main": "./cjs/index.js", | ||
@@ -113,4 +113,5 @@ "module": "./index.js", | ||
"@babel/runtime": "^7.17.9", | ||
"@polkadot/wasm-crypto-asmjs": "6.0.2-7", | ||
"@polkadot/wasm-crypto-wasm": "6.0.2-7" | ||
"@polkadot/wasm-crypto-init": "6.0.2-8", | ||
"@polkadot/wasm-data-asmjs": "6.0.2-8", | ||
"@polkadot/wasm-data-wasm": "6.0.2-8" | ||
}, | ||
@@ -117,0 +118,0 @@ "peerDependencies": { |
@@ -8,3 +8,3 @@ // Copyright 2017-2022 @polkadot/wasm-crypto authors & contributors | ||
type: 'esm', | ||
version: '6.0.2-7' | ||
version: '6.0.2-8' | ||
}; |
@@ -0,1 +1,2 @@ | ||
import type { InitResult } from '@polkadot/wasm-crypto-init/types'; | ||
export interface WasmCryptoInstance { | ||
@@ -41,1 +42,2 @@ memory: WebAssembly.Memory; | ||
export declare type AsmCreator = (wbg: Record<string, WebAssembly.ImportValue>) => WasmCryptoInstance; | ||
export declare type CreatePromise = Promise<InitResult>; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312100
6
2445
+ Added@polkadot/wasm-crypto-init@6.0.2-8(transitive)
+ Added@polkadot/wasm-data-asmjs@6.0.2-8(transitive)
+ Added@polkadot/wasm-data-wasm@6.0.2-8(transitive)
- Removed@polkadot/wasm-crypto-asmjs@6.0.2-7
- Removed@polkadot/wasm-crypto-wasm@6.0.2-7
- Removed@polkadot/wasm-crypto-asmjs@6.0.2-7(transitive)
- Removed@polkadot/wasm-crypto-wasm@6.0.2-7(transitive)