mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-05 02:10:18 +00:00
update wasm-pack compiled js (#982)
This commit is contained in:
parent
f7e99247d1
commit
581193b044
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fluence",
|
||||
"version": "0.7.68",
|
||||
"version": "0.7.77",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -25,9 +25,9 @@
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aquamarine-stepper": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aquamarine-stepper/-/aquamarine-stepper-0.0.9.tgz",
|
||||
"integrity": "sha512-DzxaYuzg0zgmDdr63de72b7K0UZPRCiZ93PTxt4BpksSLdP7LNsGHSCjh6FCQpFRQEqSb5S5hFI4nEJmBzRU3Q=="
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aquamarine-stepper/-/aquamarine-stepper-0.0.10.tgz",
|
||||
"integrity": "sha512-TvJdDFqSlQmsUQ15y8Buk/dx20FpGRNkCX31fPRIn+a7lp4L+dpa4rS3ZxjhgDhUYdhVTxtEtnQwY64Z678wFA=="
|
||||
},
|
||||
"@sinonjs/commons": {
|
||||
"version": "1.7.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fluence",
|
||||
"version": "0.7.77",
|
||||
"version": "0.7.80",
|
||||
"description": "the browser js-libp2p client for the Fluence network",
|
||||
"main": "./dist/fluence.js",
|
||||
"typings": "./dist/fluence.d.ts",
|
||||
@ -8,14 +8,14 @@
|
||||
"test": "mocha -r ts-node/register src/**/*.spec.ts",
|
||||
"test-ts": "ts-mocha -p tsconfig.json src/**/*.spec.ts",
|
||||
"package:build": "NODE_ENV=production webpack && npm run package",
|
||||
"package": "tsc",
|
||||
"package": "tsc && rsync -r src/aqua/*.js dist/aqua",
|
||||
"start": "webpack-dev-server -p",
|
||||
"build": "webpack"
|
||||
},
|
||||
"author": "Fluence Labs",
|
||||
"license": "Apache 2.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/aquamarine-stepper": "0.0.9",
|
||||
"@fluencelabs/aquamarine-stepper": "0.0.10",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.3.1",
|
||||
"bs58": "4.0.1",
|
||||
|
@ -18,7 +18,9 @@ export function getUint8Memory0(wasm) {
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
|
||||
let cachedTextEncoder = new TextEncoder('utf-8');
|
||||
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
||||
|
||||
let cachedTextEncoder = new lTextEncoder('utf-8');
|
||||
|
||||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
||||
? function (arg, view) {
|
||||
@ -79,7 +81,9 @@ export function getInt32Memory0(wasm) {
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
|
||||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
||||
|
||||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
|
||||
cachedTextDecoder.decode();
|
||||
|
||||
@ -96,8 +100,6 @@ export function getStringFromWasm0(wasm, ptr, len) {
|
||||
*/
|
||||
export function invoke(wasm, init_user_id, aqua, prev_data, data) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_export_0.value - 16;
|
||||
wasm.__wbindgen_export_0.value = retptr;
|
||||
var ptr0 = passStringToWasm0(wasm, init_user_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
var ptr1 = passStringToWasm0(wasm, aqua, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
@ -106,12 +108,11 @@ export function invoke(wasm, init_user_id, aqua, prev_data, data) {
|
||||
var len2 = WASM_VECTOR_LEN;
|
||||
var ptr3 = passStringToWasm0(wasm, data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len3 = WASM_VECTOR_LEN;
|
||||
wasm.invoke(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
||||
var r0 = getInt32Memory0(wasm)[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0(wasm)[retptr / 4 + 1];
|
||||
wasm.invoke(8, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
||||
var r0 = getInt32Memory0(wasm)[8 / 4 + 0];
|
||||
var r1 = getInt32Memory0(wasm)[8 / 4 + 1];
|
||||
return getStringFromWasm0(wasm, r0, r1);
|
||||
} finally {
|
||||
wasm.__wbindgen_export_0.value += 16;
|
||||
wasm.__wbindgen_free(r0, r1);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {getCurrentParticleId, registerService} from "./globalState";
|
||||
import {Service} from "./service";
|
||||
import {ServiceMultiple} from "./service";
|
||||
import log from "loglevel";
|
||||
|
||||
let storage: Map<string, Map<string, any>> = new Map();
|
||||
@ -12,7 +12,7 @@ export function addData(particleId: string, data: Map<string, any>, ttl: number)
|
||||
}, ttl)
|
||||
}
|
||||
|
||||
export const storageService = new Service("")
|
||||
export const storageService = new ServiceMultiple("")
|
||||
storageService.registerFunction("load", (args: any[]) => {
|
||||
let current = getCurrentParticleId();
|
||||
|
||||
|
@ -19,6 +19,9 @@ import Multiaddr from "multiaddr"
|
||||
import {FluenceClient} from "./fluenceClient";
|
||||
import * as log from "loglevel";
|
||||
import {LogLevelDesc} from "loglevel";
|
||||
import {ServiceMultiple} from "./service";
|
||||
import {registerService} from "./globalState";
|
||||
import {build} from "./particle";
|
||||
|
||||
log.setLevel('info')
|
||||
|
||||
@ -58,7 +61,6 @@ export default class Fluence {
|
||||
declare global {
|
||||
interface Window {
|
||||
Fluence: Fluence;
|
||||
test: any
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {genUUID} from "../particle";
|
||||
import log from "loglevel";
|
||||
import {Service} from "../service";
|
||||
import {ServiceMultiple} from "../service";
|
||||
import {deleteService, registerService} from "../globalState";
|
||||
import {delay} from "../utils";
|
||||
|
||||
@ -25,7 +25,7 @@ export function waitResult(ttl: number): NamedPromise<any[]> {
|
||||
export function waitService<T>(functionName: string, func: (args: any[]) => T, ttl: number): NamedPromise<T> {
|
||||
let serviceName = `${functionName}-${genUUID()}`;
|
||||
log.info(`Create waiting service '${serviceName}'`)
|
||||
let service = new Service(serviceName)
|
||||
let service = new ServiceMultiple(serviceName)
|
||||
registerService(service)
|
||||
|
||||
let promise: Promise<T> = new Promise(function (resolve) {
|
||||
|
@ -21,7 +21,45 @@ export interface CallServiceResult {
|
||||
result: string
|
||||
}
|
||||
|
||||
export class Service {
|
||||
export abstract class Service {
|
||||
serviceId: string;
|
||||
abstract call(fnName: string, args: any[]): CallServiceResult
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates one function for all function names.
|
||||
*/
|
||||
export class ServiceOne implements Service {
|
||||
|
||||
serviceId: string;
|
||||
fn: (fnName: string, args: any[]) => object
|
||||
|
||||
constructor(serviceId: string, fn: (fnName: string, args: any[]) => object) {
|
||||
this.serviceId = serviceId;
|
||||
this.fn = fn;
|
||||
}
|
||||
|
||||
call(fnName: string, args: any[]): CallServiceResult {
|
||||
try {
|
||||
let result = this.fn(fnName, args)
|
||||
return {
|
||||
ret_code: 0,
|
||||
result: JSON.stringify(result)
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
ret_code: 1,
|
||||
result: JSON.stringify(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates function per function name. Returns an error when call a name without registered function.
|
||||
*/
|
||||
export class ServiceMultiple implements Service {
|
||||
|
||||
serviceId: string;
|
||||
functions: Map<string, (args: any[]) => object> = new Map();
|
||||
|
@ -34,7 +34,7 @@ export async function instantiateStepper(pid: PeerId): Promise<Stepper> {
|
||||
const importObject = {
|
||||
// __wbg_callserviceimpl_c0ca292e3c8c0c97 this is a function generated by bindgen. Could be changed.
|
||||
// If so, an error with a new name will be occurred after wasm initialization.
|
||||
"./index_bg.js": { __wbg_callserviceimpl_543ea6b03160524e: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, arg5: any, arg6: any) => {
|
||||
"./aquamarine_client_bg.js": { __wbg_callserviceimpl_7d3cf77a2722659e: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, arg5: any, arg6: any) => {
|
||||
try {
|
||||
let serviceId = getStringFromWasm0(wasm, arg1, arg2)
|
||||
let fnName = getStringFromWasm0(wasm, arg3, arg4)
|
||||
@ -51,7 +51,7 @@ export async function instantiateStepper(pid: PeerId): Promise<Stepper> {
|
||||
wasm.__wbindgen_free(arg5, arg6);
|
||||
}
|
||||
},
|
||||
__wbg_getcurrentpeeridimpl_8924d0a646015630: (arg0: any) => {
|
||||
__wbg_getcurrentpeeridimpl_154ce1848a306ff5: (arg0: any) => {
|
||||
var ret = pid.toB58String();
|
||||
var ptr0 = passStringToWasm0(wasm, ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
@ -86,8 +86,8 @@ export async function instantiateStepper(pid: PeerId): Promise<Stepper> {
|
||||
}
|
||||
};
|
||||
|
||||
let module = await WebAssembly.compile(arr);
|
||||
let webAssemblyInstantiatedSource = await WebAssembly.instantiate(module, {
|
||||
let module1 = await WebAssembly.compile(arr);
|
||||
let webAssemblyInstantiatedSource = await WebAssembly.instantiate(module1, {
|
||||
...importObject
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user