mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-22 12:21:32 +00:00
feat!: Standalone web JS Client (#243)
- Move marine-related part into FJS repo (fixes DXJ-184) - Move towards component-oriented architecture (fixes DXJ-183) - Different JS Client distros for node.js and web (fixes DXJ-185) - Update libp2p to 0.42.2 (fixes DXJ-26) - Add JS Client API (fixes DXJ-196, fixes DXJ-177, fixes DXJ-60) - Add Smoke test for JS Client web (fixes DXJ-253) --------- Co-authored-by: Anatoly Laskaris <github_me@nahsi.dev>
This commit is contained in:
21
packages/client/js-client.web/.gitignore
vendored
Normal file
21
packages/client/js-client.web/.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
bundle/
|
||||
|
||||
dist
|
||||
esm
|
||||
types
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
.idea
|
11
packages/client/js-client.web/README.md
Normal file
11
packages/client/js-client.web/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# JS Client web
|
||||
|
||||
This package is a part of FluenceJS, the official implementation of the Fluence Peer in typescript. See the [FluenceJS repo](https://github.com/fluencelabs/fluence-js) for more info
|
||||
|
||||
## Contributing
|
||||
|
||||
While the project is still in the early stages of development, you are welcome to track progress and contribute. As the project is undergoing rapid changes, interested contributors should contact the team before embarking on larger pieces of work. All contributors should consult with and agree to our [basic contributing rules](CONTRIBUTING.md).
|
||||
|
||||
## License
|
||||
|
||||
[Apache 2.0](LICENSE)
|
26
packages/client/js-client.web/package.json.skip
Normal file
26
packages/client/js-client.web/package.json.skip
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@fluencelabs/js-client.web",
|
||||
"version": "0.1.0",
|
||||
"description": "TypeScript implementation of Fluence Peer",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"engines": {
|
||||
"node": ">=10",
|
||||
"pnpm": ">=3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"repository": "https://github.com/fluencelabs/fluence-js",
|
||||
"author": "Fluence Labs",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/js-peer": "workspace:0.60.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "16.11.59",
|
||||
"@types/jest": "28.1.0",
|
||||
"jest": "28.1.0",
|
||||
"ts-jest": "28.0.2"
|
||||
}
|
||||
}
|
23
packages/client/js-client.web/src/index.ts
Normal file
23
packages/client/js-client.web/src/index.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { MarineBackgroundRunner } from '@fluencelabs/marine.background-runner';
|
||||
import { MarineBasedAvmRunner } from '@fluencelabs/js-peer/dist/avm';
|
||||
import { marineLogFunction } from '@fluencelabs/js-peer/dist/utils';
|
||||
import { FluencePeer } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||
import { InlinedWorkerLoader, WasmWebLoader } from '@fluencelabs/marine.deps-loader.web';
|
||||
|
||||
export const defaultNames = {
|
||||
avm: 'avm.wasm',
|
||||
marine: 'marine-js.wasm',
|
||||
};
|
||||
|
||||
export const makeDefaultPeer = () => {
|
||||
const workerLoader = new InlinedWorkerLoader();
|
||||
const controlModuleLoader = new WasmWebLoader(defaultNames.marine);
|
||||
const avmModuleLoader = new WasmWebLoader(defaultNames.avm);
|
||||
|
||||
const marine = new MarineBackgroundRunner(workerLoader, controlModuleLoader, marineLogFunction);
|
||||
const avm = new MarineBasedAvmRunner(marine, avmModuleLoader, undefined);
|
||||
return new FluencePeer(marine, avm);
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
globalThis.defaultPeer = makeDefaultPeer();
|
7
packages/client/js-client.web/tsconfig.json
Normal file
7
packages/client/js-client.web/tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
Reference in New Issue
Block a user