Adjust WASM init process (w/ RN aliases) (#340)
* Adjust WASM init process (w/ RN aliases) * Remove stray log * Cleanup * CHANGELOG * yarn.lock
This commit is contained in:
+1
-1
@@ -17,4 +17,4 @@ exclude_patterns:
|
||||
- "**/*.spec.ts"
|
||||
- "docs/**/*.js"
|
||||
- "**/test/**/*.js"
|
||||
- "packages/wasm-crypto-wasm/src/fflate.ts"
|
||||
- "packages/wasm-data-wasm/src/fflate.ts"
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# CHANGELOG
|
||||
|
||||
## master
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust init, allow RN with default ASM.js-only fallback
|
||||
|
||||
|
||||
## 6.0.1 Apr 9, 2022
|
||||
|
||||
- **Breaking change** In this major version the commonjs outputs are moved to a sub-folder. Since the `export` map and `main` field in `package.json` does reflect this change, there should be no usage changes. However the packages here will all need to be on the same version for internal linkage.
|
||||
|
||||
+2
-1
@@ -6,7 +6,8 @@ const config = require('@polkadot/dev/config/jest.cjs');
|
||||
module.exports = {
|
||||
...config,
|
||||
moduleNameMapper: {
|
||||
'@polkadot/wasm-crypto-(asmjs|wasm)(.*)$': '<rootDir>/packages/wasm-crypto-$1/build/$2',
|
||||
'@polkadot/wasm-crypto-init(.*)$': '<rootDir>/packages/wasm-crypto-init/build/$1',
|
||||
'@polkadot/wasm-data-(asmjs|wasm)(.*)$': '<rootDir>/packages/wasm-data-$1/build/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/wasm-crypto(.*)$': '<rootDir>/packages/wasm-crypto/src/$1'
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.17.10",
|
||||
"@polkadot/dev": "^0.66.16",
|
||||
"@polkadot/dev": "^0.66.18",
|
||||
"fflate": "^0.7.3",
|
||||
"override-require": "^1.1.1"
|
||||
},
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '6.0.2-7' };
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"contributors": [],
|
||||
"description": "Asm.js content for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-init#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto-init",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto-init",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "6.0.2-7",
|
||||
"browser": "wasm.js",
|
||||
"main": "wasm.js",
|
||||
"react-native": "asm.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.17.9",
|
||||
"@polkadot/wasm-data-asmjs": "6.0.2-7",
|
||||
"@polkadot/wasm-data-wasm": "6.0.2-7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^9.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitResult } from './types';
|
||||
|
||||
import { asmJsInit } from '@polkadot/wasm-data-asmjs';
|
||||
|
||||
import { createPromise } from './create';
|
||||
|
||||
export function init (wbg: WebAssembly.ModuleImports): Promise<InitResult> {
|
||||
return createPromise(wbg, null, asmJsInit);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitResult } from './types';
|
||||
|
||||
import { asmJsInit } from '@polkadot/wasm-data-asmjs';
|
||||
import { wasmBytes } from '@polkadot/wasm-data-wasm';
|
||||
|
||||
import { createPromise } from './create';
|
||||
|
||||
export function init (wbg: WebAssembly.ModuleImports): Promise<InitResult> {
|
||||
return createPromise(wbg, wasmBytes, asmJsInit);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitResult } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
export async function createPromise (wbg: WebAssembly.ModuleImports, wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WebAssembly.ModuleImports) => unknown)): Promise<InitResult> {
|
||||
const result: InitResult = {
|
||||
type: 'wasm',
|
||||
wasm: null
|
||||
};
|
||||
|
||||
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 });
|
||||
|
||||
result.wasm = source.instance.exports;
|
||||
} catch (error) {
|
||||
// if we have a valid supplied asm.js, return that
|
||||
if (asmFn) {
|
||||
result.type = 'asm';
|
||||
result.wasm = asmFn(wbg);
|
||||
} else {
|
||||
console.error(`FATAL: Unable to initialize @polkadot/wasm-crypto:: ${(error as Error).message}`);
|
||||
|
||||
result.wasm = null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Empty template, auto-generated by @polkadot/dev
|
||||
|
||||
export default [];
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { init } from './wasm';
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitResult } from './types';
|
||||
|
||||
import { createPromise } from './create';
|
||||
|
||||
export function init (wbg: WebAssembly.ModuleImports): Promise<InitResult> {
|
||||
return createPromise(wbg, null, null);
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '6.0.2-7' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '6.0.2-7' };
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare interface InitResult {
|
||||
type: 'wasm' | 'asm';
|
||||
wasm: unknown;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitResult } from './types';
|
||||
|
||||
import { wasmBytes } from '@polkadot/wasm-data-wasm';
|
||||
|
||||
import { createPromise } from './create';
|
||||
|
||||
export function init (wbg: WebAssembly.ModuleImports): Promise<InitResult> {
|
||||
return createPromise(wbg, wasmBytes, null);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../wasm-data-asmjs/tsconfig.build.json" },
|
||||
{ "path": "../wasm-data-wasm/tsconfig.build.json" }
|
||||
]
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -32,8 +32,9 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@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-7",
|
||||
"@polkadot/wasm-data-asmjs": "6.0.2-7",
|
||||
"@polkadot/wasm-data-wasm": "6.0.2-7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^9.1.1",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import type { WasmCryptoInstance } from './types';
|
||||
import type { CreatePromise, WasmCryptoInstance } from './types';
|
||||
|
||||
import { assert, stringToU8a, u8aToString } from '@polkadot/util';
|
||||
|
||||
@@ -15,19 +15,15 @@ type PopFirst<T extends unknown[]> =
|
||||
interface Bridge {
|
||||
cachegetInt32: Int32Array | null;
|
||||
cachegetUint8: Uint8Array | null;
|
||||
type: 'wasm' | 'asm';
|
||||
wasm: WasmCryptoInstance | null;
|
||||
wasmPromise: Promise<void> | null;
|
||||
wasmPromiseFn: null | (() => Promise<void>);
|
||||
wasmPromise: CreatePromise | null;
|
||||
}
|
||||
|
||||
export const __bridge: Bridge = {
|
||||
cachegetInt32: null,
|
||||
cachegetUint8: null,
|
||||
type: 'wasm',
|
||||
wasm: null,
|
||||
wasmPromise: null,
|
||||
wasmPromiseFn: null
|
||||
wasmPromise: null
|
||||
};
|
||||
|
||||
export function withWasm <T, F extends (wasm: WasmCryptoInstance, ...params: never[]) => T> (fn: F): (...params: PopFirst<Parameters<F>>) => ReturnType<F> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { __bridge, allocString, allocU8a, getWasm, resultString, resultU8a, withWasm } from './bridge';
|
||||
import { allocString, allocU8a, getWasm, resultString, resultU8a, withWasm } from './bridge';
|
||||
import { initWasm } from './init';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
@@ -204,15 +204,7 @@ export function isReady (): boolean {
|
||||
|
||||
export async function waitReady (): Promise<boolean> {
|
||||
try {
|
||||
if (!__bridge.wasmPromise) {
|
||||
if (!__bridge.wasmPromiseFn) {
|
||||
__bridge.wasmPromiseFn = initWasm;
|
||||
}
|
||||
|
||||
__bridge.wasmPromise = __bridge.wasmPromiseFn();
|
||||
}
|
||||
|
||||
await __bridge.wasmPromise;
|
||||
await initWasm();
|
||||
|
||||
return isReady();
|
||||
} catch {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// 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';
|
||||
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 [asmInfo, wasmInfo];
|
||||
export default [initInfo, asmInfo, wasmInfo];
|
||||
|
||||
@@ -1,44 +1,19 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AsmCreator, WasmCryptoInstance } from './types';
|
||||
import type { CreatePromise, WasmCryptoInstance } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
import { wasmBytes } from '@polkadot/wasm-crypto-wasm';
|
||||
import { init } from '@polkadot/wasm-crypto-init';
|
||||
|
||||
import { __bridge } from './bridge';
|
||||
import * as wbg from './imports';
|
||||
|
||||
async function createPromise (wasmBytes: Uint8Array | null, asmFn: AsmCreator | null): Promise<void> {
|
||||
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 as unknown as WasmCryptoInstance);
|
||||
} 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 as Error).message}`);
|
||||
|
||||
__bridge.wasm = null;
|
||||
}
|
||||
export async function initWasm (initOverride?: (wbg: WebAssembly.ModuleImports) => CreatePromise): Promise<void> {
|
||||
if (!__bridge.wasmPromise || initOverride) {
|
||||
__bridge.wasmPromise = (initOverride || init)(wbg);
|
||||
}
|
||||
}
|
||||
|
||||
export function setWasmPromise (wasmBytes: Uint8Array | null, asmFn: AsmCreator | null): Promise<void> {
|
||||
__bridge.wasmPromise = createPromise(wasmBytes, asmFn);
|
||||
const { wasm } = await __bridge.wasmPromise;
|
||||
|
||||
return __bridge.wasmPromise;
|
||||
}
|
||||
|
||||
export function setWasmPromiseFn (fn: () => Promise<void>): void {
|
||||
__bridge.wasmPromiseFn = fn;
|
||||
}
|
||||
|
||||
export function initWasm (): Promise<void> {
|
||||
return setWasmPromise(wasmBytes, null);
|
||||
__bridge.wasm = wasm as WasmCryptoInstance;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,8 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AsmCreator } from './types';
|
||||
import { init } from '@polkadot/wasm-crypto-init/none';
|
||||
|
||||
import { __bridge } from './bridge';
|
||||
import { initWasm } from './init';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setWasmPromise (_wasmBytes: Uint8Array | null, _asmFn: AsmCreator | null): Promise<void> {
|
||||
__bridge.wasmPromise = Promise.resolve();
|
||||
|
||||
return __bridge.wasmPromise;
|
||||
}
|
||||
|
||||
export function setWasmPromiseFn (fn: () => Promise<void>): void {
|
||||
__bridge.wasmPromiseFn = fn;
|
||||
}
|
||||
|
||||
export function setWasmOnlyPromise (): Promise<void> {
|
||||
return setWasmPromise(null, null);
|
||||
}
|
||||
|
||||
export function initWasm (): Promise<void> {
|
||||
return setWasmOnlyPromise();
|
||||
}
|
||||
|
||||
setWasmPromiseFn(initWasm);
|
||||
initWasm(init).catch(undefined);
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs';
|
||||
import { init } from '@polkadot/wasm-crypto-init/asm';
|
||||
|
||||
import { setWasmPromise, setWasmPromiseFn } from './init';
|
||||
import { initWasm } from './init';
|
||||
|
||||
export function initWasm (): Promise<void> {
|
||||
return setWasmPromise(null, asmJsInit);
|
||||
}
|
||||
|
||||
setWasmPromiseFn(initWasm);
|
||||
initWasm(init).catch(undefined);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { initWasm as baseInitWasm, setWasmPromiseFn } from './init';
|
||||
import { init } from '@polkadot/wasm-crypto-init/wasm';
|
||||
|
||||
export function initWasm (): Promise<void> {
|
||||
return baseInitWasm();
|
||||
}
|
||||
import { initWasm } from './init';
|
||||
|
||||
setWasmPromiseFn(initWasm);
|
||||
initWasm(init).catch(undefined);
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
// 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 { init } from '@polkadot/wasm-crypto-init/both';
|
||||
|
||||
import { setWasmPromise, setWasmPromiseFn } from './init';
|
||||
import { initWasm } from './init';
|
||||
|
||||
export function initWasm (): Promise<void> {
|
||||
return setWasmPromise(wasmBytes, asmJsInit);
|
||||
}
|
||||
|
||||
setWasmPromiseFn(initWasm);
|
||||
initWasm(init).catch(undefined);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitResult } from '@polkadot/wasm-crypto-init/types';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// wasm-pack build output (formatted) from pkg/wasm_bg.d.ts
|
||||
@@ -85,3 +87,5 @@ export interface WasmCryptoInstance {
|
||||
}
|
||||
|
||||
export type AsmCreator = (wbg: Record<string, WebAssembly.ImportValue>) => WasmCryptoInstance;
|
||||
|
||||
export type CreatePromise = Promise<InitResult>;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const rootIncl = ['@polkadot/wasm-crypto', '@polkadot/wasm-crypto-asmjs', '@polkadot/wasm-crypto-wasm'];
|
||||
const rootIncl = ['@polkadot/wasm-crypto', '@polkadot/wasm-crypto-init', '@polkadot/wasm-data-asmjs', '@polkadot/wasm-data-wasm'];
|
||||
const detcIncl = [
|
||||
...rootIncl.map((p) => `${p}/initOnlyAsm`),
|
||||
...rootIncl.map((p) => `${p}/cjs/asm`),
|
||||
...rootIncl.map((p) => `${p}/cjs/packageInfo`)
|
||||
];
|
||||
|
||||
@@ -15,7 +16,8 @@ require('override-require')(
|
||||
rootIncl.some((p) => request.endsWith(p))
|
||||
? require(`${rootIncl.find((p) => request.endsWith(p))}/build/cjs`)
|
||||
: require(`${detcIncl.find((p) => request.endsWith(p))
|
||||
.replace('initOnlyAsm', 'build/cjs/initOnlyAsm.js')
|
||||
.replace('/initOnlyAsm', '/build/cjs/initOnlyAsm.js')
|
||||
.replace('/cjs/asm', '/build/cjs/asm.js')
|
||||
.replace('/cjs/packageInfo', '/build/cjs/packageInfo.js')
|
||||
}`)
|
||||
);
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../wasm-crypto-asmjs/tsconfig.build.json" },
|
||||
{ "path": "../wasm-crypto-wasm/tsconfig.build.json" }
|
||||
{ "path": "../wasm-crypto-init/tsconfig.build.json" },
|
||||
{ "path": "../wasm-data-asmjs/tsconfig.build.json" },
|
||||
{ "path": "../wasm-data-wasm/tsconfig.build.json" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-asmjs#readme",
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-data-asmjs#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto-asmjs",
|
||||
"name": "@polkadot/wasm-data-asmjs",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto-asmjs",
|
||||
"directory": "packages/wasm-data-asmjs",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { asmJsInit } from './cjs/data.js';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const data = require('../data');
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const asmJsInit: null;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const asmJsInit = null;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2017-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-data-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-data-asmjs', path: 'auto', type: 'auto', version: '6.0.2-7' };
|
||||
@@ -6,12 +6,12 @@
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-wasm#readme",
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-data-wasm#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto-wasm",
|
||||
"name": "@polkadot/wasm-data-wasm",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto-wasm",
|
||||
"directory": "packages/wasm-data-wasm",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { bytes, sizeUncompressed } from './cjs/bytes';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const bytes = '';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports.bytes = '';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const bytes = require('../bytes');
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther';
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-data-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-data-wasm', path: 'auto', type: 'auto', version: '6.0.2-7' };
|
||||
+5
-4
@@ -14,10 +14,11 @@ const external = [
|
||||
|
||||
const overrides = {
|
||||
'@polkadot/wasm-crypto': {
|
||||
entries: ['asmjs', 'wasm'].map((p) => `wasm-crypto-${p}`).reduce((all, p) => ({
|
||||
...all,
|
||||
[`@polkadot/${p}`]: `../../${p}/build`
|
||||
}), {})
|
||||
entries: {
|
||||
'@polkadot/wasm-crypto-init': '../../wasm-crypto-init/build',
|
||||
'@polkadot/wasm-data-asmjs': '../../../wasm-data-asmjs/build',
|
||||
'@polkadot/wasm-data-wasm': '../../../wasm-data-wasm/build',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ source ../scripts/rust-version.sh
|
||||
|
||||
WSM=bytes/wasm_bg.wasm
|
||||
OPT=bytes/wasm_opt.wasm
|
||||
ASM=wasm-crypto-asmjs/build/cjs/data.js
|
||||
ASM=wasm-data-asmjs/build/cjs/data.js
|
||||
|
||||
# build new via wasm-pack
|
||||
echo "*** Building Rust sources"
|
||||
@@ -42,5 +42,5 @@ sed -i -e '1,/var retasmFunc = /!d' $ASM
|
||||
sed -i -e 's/var retasmFunc = .*/const asmJsInit = (wbg) => asmFunc(wbg);\n\nmodule.exports = { asmJsInit };/g' $ASM
|
||||
|
||||
# cleanups
|
||||
rm -rf wasm-crypto-asmjs/build/cjs/*-e
|
||||
rm -rf wasm-crypto-wasm/build/cjs/*-e
|
||||
rm -rf wasm-data-asmjs/build/cjs/*-e
|
||||
rm -rf wasm-data-wasm/build/cjs/*-e
|
||||
|
||||
+4
-4
@@ -19,11 +19,11 @@ echo ""
|
||||
echo "*** wasm-crypto"
|
||||
ls -alR wasm-crypto/build
|
||||
echo ""
|
||||
echo "*** wasm-crypto-asmjs"
|
||||
ls -alR wasm-crypto-asmjs/build
|
||||
echo "*** wasm-data-asmjs"
|
||||
ls -alR wasm-data-asmjs/build
|
||||
echo ""
|
||||
echo "*** wasm-crypto-wasm"
|
||||
ls -alR wasm-crypto-wasm/build
|
||||
echo "*** wasm-data-wasm"
|
||||
ls -alR wasm-data-wasm/build
|
||||
|
||||
cd ..
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ const fflate = require('fflate/node');
|
||||
const fs = require('fs');
|
||||
const { formatNumber } = require('@polkadot/util');
|
||||
|
||||
const W_NAME = 'wasm-crypto-wasm';
|
||||
const W_NAME = 'wasm-data-wasm';
|
||||
|
||||
const data = fs.readFileSync('./bytes/wasm_opt.wasm');
|
||||
const compressed = Buffer.from(fflate.zlibSync(data, { level: 9 }));
|
||||
|
||||
+11
-4
@@ -3,10 +3,17 @@
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"paths": {
|
||||
"@polkadot/wasm-crypto-asmjs/packageInfo": ["wasm-crypto-asmjs/src/packageInfo"],
|
||||
"@polkadot/wasm-crypto-asmjs": ["wasm-crypto-asmjs/src"],
|
||||
"@polkadot/wasm-crypto-wasm/packageInfo": ["wasm-crypto-wasm/src/packageInfo"],
|
||||
"@polkadot/wasm-crypto-wasm": ["wasm-crypto-wasm/src"],
|
||||
"@polkadot/wasm-data-asmjs/packageInfo": ["wasm-data-asmjs/src/packageInfo"],
|
||||
"@polkadot/wasm-data-asmjs": ["wasm-data-asmjs/src"],
|
||||
"@polkadot/wasm-data-wasm/packageInfo": ["wasm-data-wasm/src/packageInfo"],
|
||||
"@polkadot/wasm-data-wasm": ["wasm-data-wasm/src"],
|
||||
"@polkadot/wasm-crypto-init/asm": ["wasm-crypto-init/src/asm"],
|
||||
"@polkadot/wasm-crypto-init/both": ["wasm-crypto-init/src/both"],
|
||||
"@polkadot/wasm-crypto-init/none": ["wasm-crypto-init/src/none"],
|
||||
"@polkadot/wasm-crypto-init/wasm": ["wasm-crypto-init/src/wasm"],
|
||||
"@polkadot/wasm-crypto-init/types": ["wasm-crypto-init/src/types"],
|
||||
"@polkadot/wasm-crypto-init/packageInfo": ["wasm-crypto-init/src/packageInfo"],
|
||||
"@polkadot/wasm-crypto-init": ["wasm-crypto-init/src"],
|
||||
"@polkadot/wasm-crypto": ["wasm-crypto/src"]
|
||||
},
|
||||
"skipLibCheck": true
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./packages/wasm-crypto/tsconfig.build.json" },
|
||||
{ "path": "./packages/wasm-crypto-asmjs/tsconfig.build.json" },
|
||||
{ "path": "./packages/wasm-crypto-wasm/tsconfig.build.json" }
|
||||
{ "path": "./packages/wasm-data-asmjs/tsconfig.build.json" },
|
||||
{ "path": "./packages/wasm-data-wasm/tsconfig.build.json" }
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user