mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-05 02:10:18 +00:00
Move non-relevant code from Marine repo into FluenceJS (#227)
1. Move marine-related part into FJS repo (DXJ184) 2. Move towards component-oriented architecture (DXJ183) 3. Different JS Client distros for node.js and web (DXJ185)
This commit is contained in:
parent
dcb15b7d3c
commit
267ebb687f
134
.github/workflows/tests.yml
vendored
134
.github/workflows/tests.yml
vendored
@ -1,112 +1,42 @@
|
|||||||
name: Run tests with worflow_call
|
name: Run tests
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: .
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
push:
|
||||||
inputs:
|
|
||||||
rust-peer-image:
|
|
||||||
description: "rust-peer image tag"
|
|
||||||
type: string
|
|
||||||
default: "fluencelabs/fluence:minimal"
|
|
||||||
avm-version:
|
|
||||||
description: "@fluencelabs/avm version"
|
|
||||||
type: string
|
|
||||||
default: "null"
|
|
||||||
marine-js-version:
|
|
||||||
description: "@fluencelabs/marine-js version"
|
|
||||||
type: string
|
|
||||||
default: "null"
|
|
||||||
ref:
|
|
||||||
description: "git ref to checkout to"
|
|
||||||
type: string
|
|
||||||
default: "master"
|
|
||||||
|
|
||||||
env:
|
|
||||||
RUST_PEER_IMAGE: "${{ inputs.rust-peer-image }}"
|
|
||||||
FORCE_COLOR: true
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
fluence-js:
|
build:
|
||||||
name: "Run tests"
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
strategy:
|
||||||
contents: read
|
matrix:
|
||||||
id-token: write
|
node-version: [16.x, 17.x, 18.x]
|
||||||
|
|
||||||
strategy:
|
steps:
|
||||||
matrix:
|
- uses: actions/checkout@v2
|
||||||
node-version:
|
|
||||||
- 16.x
|
|
||||||
- 17.x
|
|
||||||
|
|
||||||
steps:
|
- name: Setup Node.js ${{ matrix.node-version }}
|
||||||
- name: Import secrets
|
uses: actions/setup-node@v1
|
||||||
uses: hashicorp/vault-action@v2.4.3
|
with:
|
||||||
with:
|
node-version: ${{ matrix.node-version }}
|
||||||
url: https://vault.fluence.dev
|
|
||||||
path: jwt/github
|
|
||||||
role: ci
|
|
||||||
method: jwt
|
|
||||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
|
||||||
jwtTtl: 300
|
|
||||||
secrets: |
|
|
||||||
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
|
|
||||||
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Setup pnpm
|
||||||
uses: docker/login-action@v2
|
uses: pnpm/action-setup@v2.2.4
|
||||||
with:
|
with:
|
||||||
registry: docker.fluence.dev
|
version: 7
|
||||||
username: ${{ env.DOCKER_USERNAME }}
|
|
||||||
password: ${{ env.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Run container with Fluence node
|
||||||
uses: actions/checkout@v3
|
run: |
|
||||||
with:
|
docker pull fluencelabs/fluence
|
||||||
repository: fluencelabs/fluence-js
|
docker run -d --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj --local --aqua-pool-size 2
|
||||||
ref: ${{ inputs.ref }}
|
|
||||||
|
|
||||||
- name: Pull rust-peer image
|
- run: pnpm i
|
||||||
run: docker pull $RUST_PEER_IMAGE
|
- run: pnpm -r build
|
||||||
|
env:
|
||||||
- name: Run rust-peer
|
CI: true
|
||||||
uses: isbang/compose-action@v1.4.1
|
- run: pnpm -r test
|
||||||
with:
|
env:
|
||||||
compose-file: ".github/e2e/docker-compose.yml"
|
CI: true
|
||||||
down-flags: "--volumes"
|
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v2.2.4
|
|
||||||
with:
|
|
||||||
version: 7
|
|
||||||
|
|
||||||
- name: Setup node ${{ matrix.node-version }} with self-hosted registry
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
registry-url: "https://npm.fluence.dev"
|
|
||||||
cache: "pnpm"
|
|
||||||
|
|
||||||
- run: pnpm i
|
|
||||||
|
|
||||||
- name: Set avm version
|
|
||||||
if: inputs.avm-version != 'null'
|
|
||||||
uses: fluencelabs/github-actions/npm-set-dependency@main
|
|
||||||
with:
|
|
||||||
package: "@fluencelabs/avm"
|
|
||||||
version: ${{ inputs.avm-version }}
|
|
||||||
working-directory: packages/fluence-js
|
|
||||||
package-manager: pnpm
|
|
||||||
|
|
||||||
- name: Set marine-js version
|
|
||||||
if: inputs.marine-js-version != 'null'
|
|
||||||
uses: fluencelabs/github-actions/npm-set-dependency@main
|
|
||||||
with:
|
|
||||||
package: "@fluencelabs/marine-js"
|
|
||||||
version: ${{ inputs.marine-js-version }}
|
|
||||||
working-directory: packages/fluence-js
|
|
||||||
package-manager: pnpm
|
|
||||||
|
|
||||||
- run: pnpm -r build
|
|
||||||
- run: pnpm -r test
|
|
||||||
|
112
.github/workflows/tests.yml.disabled
vendored
Normal file
112
.github/workflows/tests.yml.disabled
vendored
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
name: Run tests with worflow_call
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
rust-peer-image:
|
||||||
|
description: "rust-peer image tag"
|
||||||
|
type: string
|
||||||
|
default: "fluencelabs/fluence:minimal"
|
||||||
|
avm-version:
|
||||||
|
description: "@fluencelabs/avm version"
|
||||||
|
type: string
|
||||||
|
default: "null"
|
||||||
|
marine-js-version:
|
||||||
|
description: "@fluencelabs/marine-js version"
|
||||||
|
type: string
|
||||||
|
default: "null"
|
||||||
|
ref:
|
||||||
|
description: "git ref to checkout to"
|
||||||
|
type: string
|
||||||
|
default: "master"
|
||||||
|
|
||||||
|
env:
|
||||||
|
RUST_PEER_IMAGE: "${{ inputs.rust-peer-image }}"
|
||||||
|
FORCE_COLOR: true
|
||||||
|
CI: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fluence-js:
|
||||||
|
name: "Run tests"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version:
|
||||||
|
- 16.x
|
||||||
|
- 17.x
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Import secrets
|
||||||
|
uses: hashicorp/vault-action@v2.4.3
|
||||||
|
with:
|
||||||
|
url: https://vault.fluence.dev
|
||||||
|
path: jwt/github
|
||||||
|
role: ci
|
||||||
|
method: jwt
|
||||||
|
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||||
|
jwtTtl: 300
|
||||||
|
secrets: |
|
||||||
|
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
|
||||||
|
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: docker.fluence.dev
|
||||||
|
username: ${{ env.DOCKER_USERNAME }}
|
||||||
|
password: ${{ env.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: fluencelabs/fluence-js
|
||||||
|
ref: ${{ inputs.ref }}
|
||||||
|
|
||||||
|
- name: Pull rust-peer image
|
||||||
|
run: docker pull $RUST_PEER_IMAGE
|
||||||
|
|
||||||
|
- name: Run rust-peer
|
||||||
|
uses: isbang/compose-action@v1.4.1
|
||||||
|
with:
|
||||||
|
compose-file: ".github/e2e/docker-compose.yml"
|
||||||
|
down-flags: "--volumes"
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v2.2.4
|
||||||
|
with:
|
||||||
|
version: 7
|
||||||
|
|
||||||
|
- name: Setup node ${{ matrix.node-version }} with self-hosted registry
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
registry-url: "https://npm.fluence.dev"
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- run: pnpm i
|
||||||
|
|
||||||
|
- name: Set avm version
|
||||||
|
if: inputs.avm-version != 'null'
|
||||||
|
uses: fluencelabs/github-actions/npm-set-dependency@main
|
||||||
|
with:
|
||||||
|
package: "@fluencelabs/avm"
|
||||||
|
version: ${{ inputs.avm-version }}
|
||||||
|
working-directory: packages/fluence-js
|
||||||
|
package-manager: pnpm
|
||||||
|
|
||||||
|
- name: Set marine-js version
|
||||||
|
if: inputs.marine-js-version != 'null'
|
||||||
|
uses: fluencelabs/github-actions/npm-set-dependency@main
|
||||||
|
with:
|
||||||
|
package: "@fluencelabs/marine-js"
|
||||||
|
version: ${{ inputs.marine-js-version }}
|
||||||
|
working-directory: packages/fluence-js
|
||||||
|
package-manager: pnpm
|
||||||
|
|
||||||
|
- run: pnpm -r build
|
||||||
|
- run: pnpm -r test
|
16
README.md
16
README.md
@ -30,12 +30,16 @@ pnpm -r build
|
|||||||
|
|
||||||
### Repository structure
|
### Repository structure
|
||||||
|
|
||||||
| Folder | Package | Description |
|
| Folder | Package | Description |
|
||||||
| --------------------------- | ----------------------- | --------------------------------------------- |
|
| --------------------------------- | ------------------------------------- | --------------------------------------------- |
|
||||||
| packages/fluence-js | @fluencelabs/fluence-js | TypeScript implementation of the Fluence Peer |
|
| packages/core/js-peer | @fluencelabs/js-peer | TypeScript implementation of the Fluence Peer |
|
||||||
| packages/fluence-interfaces | @fluencelabs/interfaces | Common interfaces used in Fluence Peer |
|
| packages/core/interfaces | @fluencelabs/interfaces | Common interfaces used in Fluence Peer |
|
||||||
| packages/fluence-connection | @fluencelabs/connection | Connectivity layer used in Fluence Peer |
|
| packages/core/connection | @fluencelabs/connection | Connectivity layer used in Fluence Peer |
|
||||||
| packages/fluence-keypair | @fluencelabs/keypair | Key Pair implementation |
|
| packages/core/keypair | @fluencelabs/keypair | Key Pair implementation |
|
||||||
|
| packages/marine/background-runner | @fluencelabs/marine.background-runner | MarineJS background runner |
|
||||||
|
| packages/marine/deps-loader.node | @fluencelabs/marine.deps-loader.node | MarineJS deps loader for nodejs |
|
||||||
|
| packages/marine/deps-loader.web | @fluencelabs/marine.deps-loader.web | MarineJS deps loader for web |
|
||||||
|
| packages/marine/worker-script | @fluencelabs/marine.worker-script | MarineJS background worker script |
|
||||||
|
|
||||||
### Running tests
|
### Running tests
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
|
@ -1,22 +0,0 @@
|
|||||||
:root {
|
|
||||||
--light-code-background: #F5F5F5;
|
|
||||||
--dark-code-background: #1E1E1E;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) { :root {
|
|
||||||
--code-background: var(--light-code-background);
|
|
||||||
} }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { :root {
|
|
||||||
--code-background: var(--dark-code-background);
|
|
||||||
} }
|
|
||||||
|
|
||||||
body.light {
|
|
||||||
--code-background: var(--light-code-background);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.dark {
|
|
||||||
--code-background: var(--dark-code-background);
|
|
||||||
}
|
|
||||||
|
|
||||||
pre, code { background: var(--code-background); }
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 480 B |
Binary file not shown.
Before Width: | Height: | Size: 855 B |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,16 +0,0 @@
|
|||||||
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@fluencelabs/fluence</title><meta name="description" content="Documentation for @fluencelabs/fluence"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">@fluencelabs/fluence</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1>@fluencelabs/fluence </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><div class="tsd-panel tsd-typography">
|
|
||||||
<a href="#fluence-js" id="fluence-js" style="color: inherit; text-decoration: none;">
|
|
||||||
<h1>Fluence JS</h1>
|
|
||||||
</a>
|
|
||||||
<p>To start developing applications with Fluence JS refer to the official <a href="https://fluence.dev/docs/build/fluence-js/">documentation</a></p>
|
|
||||||
<p>Fluence JS is an implementation of the Fluence protocol for JavaScript-based environments. It can connect browsers, Node.js applications, and so on to the Fluence p2p network.</p>
|
|
||||||
<p>Similar to the <a href="https://github.com/fluencelabs/fluence">Rust Fluence Peer implementation</a> it includes:</p>
|
|
||||||
<ul>
|
|
||||||
<li>Peer-to-peer communication layer (via <a href="https://github.com/libp2p/js-libp2p">js-libp2p</a>)</li>
|
|
||||||
<li><a href="https://github.com/fluencelabs/aquavm">Aqua VM</a></li>
|
|
||||||
<li>Builtin services</li>
|
|
||||||
</ul>
|
|
||||||
<p>Fluence JS can call services and functions on the Fluence network, and expose new APIs to the p2p network directly from TypeScript and JavaScript.
|
|
||||||
<a href="https://github.com/fluencelabs/aqua">Aqua language</a> uses Fluence JS as a compilation target, and they are designed to <a href="https://fluence.dev/docs/build/fluence-js/in-depth#understanding-the-aqua-compiler-output">work in tandem</a>.</p>
|
|
||||||
<p>Fluence JS can be used with any framework of your choice (or even without frameworks).</p>
|
|
||||||
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-class"><a href="classes/FluencePeer.html" class="tsd-kind-icon">Fluence<wbr/>Peer</a></li><li class="tsd-kind-class"><a href="classes/KeyPair.html" class="tsd-kind-icon">Key<wbr/>Pair</a></li><li class="tsd-kind-interface tsd-has-type-parameter"><a href="interfaces/CallParams.html" class="tsd-kind-icon">Call<wbr/>Params</a></li><li class="tsd-kind-interface"><a href="interfaces/PeerConfig.html" class="tsd-kind-icon">Peer<wbr/>Config</a></li><li class="tsd-kind-type-alias"><a href="modules.html#AvmLoglevel" class="tsd-kind-icon">Avm<wbr/>Loglevel</a></li><li class="tsd-kind-type-alias"><a href="modules.html#PeerIdB58" class="tsd-kind-icon">Peer<wbr/>Id<wbr/>B58</a></li><li class="tsd-kind-type-alias"><a href="modules.html#PeerStatus" class="tsd-kind-icon">Peer<wbr/>Status</a></li><li class="tsd-kind-variable"><a href="modules.html#Fluence" class="tsd-kind-icon">Fluence</a></li><li class="tsd-kind-function tsd-is-external"><a href="modules.html#loadWasmFromFileSystem" class="tsd-kind-icon">load<wbr/>Wasm<wbr/>From<wbr/>File<wbr/>System</a></li><li class="tsd-kind-function tsd-is-external"><a href="modules.html#loadWasmFromNpmPackage" class="tsd-kind-icon">load<wbr/>Wasm<wbr/>From<wbr/>Npm<wbr/>Package</a></li><li class="tsd-kind-function tsd-is-external"><a href="modules.html#loadWasmFromServer" class="tsd-kind-icon">load<wbr/>Wasm<wbr/>From<wbr/>Server</a></li><li class="tsd-kind-function"><a href="modules.html#setLogLevel" class="tsd-kind-icon">set<wbr/>Log<wbr/>Level</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
|
@ -1,16 +0,0 @@
|
|||||||
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CallParams | @fluencelabs/fluence</title><meta name="description" content="Documentation for @fluencelabs/fluence"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@fluencelabs/fluence</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@fluencelabs/fluence</a></li><li><a href="CallParams.html">CallParams</a></li></ul><h1>Interface CallParams<ArgName> </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Additional information about a service call</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-type-parameters"><h3>Type parameters</h3><ul class="tsd-type-parameters"><li><h4>ArgName<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></h4><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
</div></div></li></ul></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">CallParams</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#initPeerId" class="tsd-kind-icon">init<wbr/>Peer<wbr/>Id</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#particleId" class="tsd-kind-icon">particle<wbr/>Id</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#signature" class="tsd-kind-icon">signature</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#tetraplets" class="tsd-kind-icon">tetraplets</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#timestamp" class="tsd-kind-icon">timestamp</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#ttl" class="tsd-kind-icon">ttl</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="initPeerId" class="tsd-anchor"></a><h3 class="tsd-anchor-link">init<wbr/>Peer<wbr/>Id<a href="#initPeerId" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">init<wbr/>Peer<wbr/>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/commonTypes.ts#L37">src/internal/commonTypes.ts:37</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>The peer id which created the particle</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="particleId" class="tsd-anchor"></a><h3 class="tsd-anchor-link">particle<wbr/>Id<a href="#particleId" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">particle<wbr/>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/commonTypes.ts#L32">src/internal/commonTypes.ts:32</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>The identifier of particle which triggered the call</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="signature" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> signature<a href="#signature" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">signature<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/commonTypes.ts#L52">src/internal/commonTypes.ts:52</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Particle's signature</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="tetraplets" class="tsd-anchor"></a><h3 class="tsd-anchor-link">tetraplets<a href="#tetraplets" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">tetraplets<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type" data-tsd-kind="Type parameter">ArgName</span><span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> ? </span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">ArgName</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">SecurityTetraplet</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> : </span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/commonTypes.ts#L57">src/internal/commonTypes.ts:57</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Security tetraplets</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="timestamp" class="tsd-anchor"></a><h3 class="tsd-anchor-link">timestamp<a href="#timestamp" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">timestamp<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/commonTypes.ts#L42">src/internal/commonTypes.ts:42</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Particle's timestamp when it was created</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="ttl" class="tsd-anchor"></a><h3 class="tsd-anchor-link">ttl<a href="#ttl" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">ttl<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/commonTypes.ts#L47">src/internal/commonTypes.ts:47</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Time to live in milliseconds. The time after the particle should be expired</p>
|
|
||||||
</div></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface tsd-has-type-parameter"><a href="CallParams.html" class="tsd-kind-icon">Call<wbr/>Params</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#initPeerId" class="tsd-kind-icon">init<wbr/>Peer<wbr/>Id</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#particleId" class="tsd-kind-icon">particle<wbr/>Id</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#signature" class="tsd-kind-icon">signature</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#tetraplets" class="tsd-kind-icon">tetraplets</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#timestamp" class="tsd-kind-icon">timestamp</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="CallParams.html#ttl" class="tsd-kind-icon">ttl</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
|
|
@ -1,52 +0,0 @@
|
|||||||
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>PeerConfig | @fluencelabs/fluence</title><meta name="description" content="Documentation for @fluencelabs/fluence"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@fluencelabs/fluence</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@fluencelabs/fluence</a></li><li><a href="PeerConfig.html">PeerConfig</a></li></ul><h1>Interface PeerConfig </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Configuration used when initiating Fluence Peer</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">PeerConfig</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#KeyPair" class="tsd-kind-icon">Key<wbr/>Pair</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#avmLogLevel" class="tsd-kind-icon">avm<wbr/>Log<wbr/>Level</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#avmRunner" class="tsd-kind-icon">avm<wbr/>Runner</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#checkConnectionTimeoutMs" class="tsd-kind-icon">check<wbr/>Connection<wbr/>Timeout<wbr/>Ms</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#connectTo" class="tsd-kind-icon">connect<wbr/>To</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#debug" class="tsd-kind-icon">debug</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#defaultTtlMs" class="tsd-kind-icon">default<wbr/>Ttl<wbr/>Ms</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#dialTimeoutMs" class="tsd-kind-icon">dial<wbr/>Timeout<wbr/>Ms</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#marineJS" class="tsd-kind-icon">marineJS</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#skipCheckConnection" class="tsd-kind-icon">skip<wbr/>Check<wbr/>Connection</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="KeyPair" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> Key<wbr/>Pair<a href="#KeyPair" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">Key<wbr/>Pair<span class="tsd-signature-symbol">?:</span> <a href="../classes/KeyPair.html" class="tsd-signature-type" data-tsd-kind="Class">KeyPair</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L72">src/internal/FluencePeer.ts:72</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Specify the KeyPair to be used to identify the Fluence Peer.
|
|
||||||
Will be generated randomly if not specified</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="avmLogLevel" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> avm<wbr/>Log<wbr/>Level<a href="#avmLogLevel" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">avm<wbr/>Log<wbr/>Level<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">LogLevel</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L66">src/internal/FluencePeer.ts:66</a></li></ul></aside><div class="tsd-comment tsd-typography"><dl class="tsd-comment-tags"><dt>deprecated.</dt><dd><p>AVM run through marine-js infrastructure.</p>
|
|
||||||
</dd><dt>see</dt><dd><p>debug.marineLogLevel option to configure logging level of AVM</p>
|
|
||||||
</dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="avmRunner" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> avm<wbr/>Runner<a href="#avmRunner" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">avm<wbr/>Runner<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">AvmRunner</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L104">src/internal/FluencePeer.ts:104</a></li></ul></aside><div class="tsd-comment tsd-typography"><dl class="tsd-comment-tags"><dt>deprecated.</dt><dd><p>AVM run through marine-js infrastructure.</p>
|
|
||||||
</dd><dt>see</dt><dd><p>marineJS option to configure AVM</p>
|
|
||||||
</dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="checkConnectionTimeoutMs" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> check<wbr/>Connection<wbr/>Timeout<wbr/>Ms<a href="#checkConnectionTimeoutMs" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">check<wbr/>Connection<wbr/>Timeout<wbr/>Ms<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L79">src/internal/FluencePeer.ts:79</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>When the peer established the connection to the network it sends a ping-like message to check if it works correctly.
|
|
||||||
The options allows to specify the timeout for that message in milliseconds.
|
|
||||||
If not specified the default timeout will be used</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="connectTo" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> connect<wbr/>To<a href="#connectTo" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">connect<wbr/>To<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">ConnectionOption</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L60">src/internal/FluencePeer.ts:60</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Node in Fluence network to connect to.
|
|
||||||
Can be in the form of:</p>
|
|
||||||
<ul>
|
|
||||||
<li>string: multiaddr in string format</li>
|
|
||||||
<li>Multiaddr: multiaddr object, @see <a href="https://github.com/multiformats/js-multiaddr">https://github.com/multiformats/js-multiaddr</a></li>
|
|
||||||
<li>Node: node structure, @see Node</li>
|
|
||||||
<li>Implementation of FluenceConnection class, @see FluenceConnection
|
|
||||||
If not specified the will work locally and would not be able to send or receive particles.</li>
|
|
||||||
</ul>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="debug" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> debug<a href="#debug" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">debug<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{ </span>marineLogLevel<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">LogLevel</span><span class="tsd-signature-symbol">; </span>printParticleId<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> }</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L132">src/internal/FluencePeer.ts:132</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Enables\disabled various debugging features</p>
|
|
||||||
</div></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-flag ts-flagOptional">Optional</span> marine<wbr/>Log<wbr/>Level<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">LogLevel</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Log level for marine services. By default logging is turned off.</p>
|
|
||||||
</div></div></li><li class="tsd-parameter"><h5><span class="tsd-flag ts-flagOptional">Optional</span> print<wbr/>Particle<wbr/>Id<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>If set to true, newly initiated particle ids will be printed to console.
|
|
||||||
Useful to see what particle id is responsible for aqua function</p>
|
|
||||||
</div></div></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="defaultTtlMs" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> default<wbr/>Ttl<wbr/>Ms<a href="#defaultTtlMs" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">default<wbr/>Ttl<wbr/>Ms<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L98">src/internal/FluencePeer.ts:98</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Sets the default TTL for all particles originating from the peer with no TTL specified.
|
|
||||||
If the originating particle's TTL is defined then that value will be used
|
|
||||||
If the option is not set default TTL will be 7000</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="dialTimeoutMs" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> dial<wbr/>Timeout<wbr/>Ms<a href="#dialTimeoutMs" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">dial<wbr/>Timeout<wbr/>Ms<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L91">src/internal/FluencePeer.ts:91</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>The dialing timeout in milliseconds</p>
|
|
||||||
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="marineJS" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> marineJS<a href="#marineJS" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">marineJS<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{ </span>avmWasmPath<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>marineWasmPath<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>workerScriptPath<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L112">src/internal/FluencePeer.ts:112</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>This option allows to specify the location of various dependencies needed for marine-js.
|
|
||||||
Each key specifies the location of the corresponding dependency.
|
|
||||||
If Fluence peer is started inside browser the location is treated as the path to the file relative to origin.
|
|
||||||
IF Fluence peer is started in nodejs the location is treated as the full path to file on the file system.</p>
|
|
||||||
</div></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter"><h5>avm<wbr/>Wasm<wbr/>Path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Configures the path to AVM wasm module</p>
|
|
||||||
</div></div></li><li class="tsd-parameter"><h5>marine<wbr/>Wasm<wbr/>Path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Configures the path to marine-js control wasm module</p>
|
|
||||||
</div></div></li><li class="tsd-parameter"><h5>worker<wbr/>Script<wbr/>Path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>Configures path to the marine-js worker script.</p>
|
|
||||||
</div></div></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="skipCheckConnection" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> skip<wbr/>Check<wbr/>Connection<a href="#skipCheckConnection" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">skip<wbr/>Check<wbr/>Connection<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/fluencelabs/fluence-js/blob/fea91db/src/internal/FluencePeer.ts#L86">src/internal/FluencePeer.ts:86</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
|
||||||
<p>When the peer established the connection to the network it sends a ping-like message to check if it works correctly.
|
|
||||||
If set to true, the ping-like message will be skipped
|
|
||||||
Default: false</p>
|
|
||||||
</div></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="PeerConfig.html" class="tsd-kind-icon">Peer<wbr/>Config</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#KeyPair" class="tsd-kind-icon">Key<wbr/>Pair</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#avmLogLevel" class="tsd-kind-icon">avm<wbr/>Log<wbr/>Level</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#avmRunner" class="tsd-kind-icon">avm<wbr/>Runner</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#checkConnectionTimeoutMs" class="tsd-kind-icon">check<wbr/>Connection<wbr/>Timeout<wbr/>Ms</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#connectTo" class="tsd-kind-icon">connect<wbr/>To</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#debug" class="tsd-kind-icon">debug</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#defaultTtlMs" class="tsd-kind-icon">default<wbr/>Ttl<wbr/>Ms</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#dialTimeoutMs" class="tsd-kind-icon">dial<wbr/>Timeout<wbr/>Ms</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#marineJS" class="tsd-kind-icon">marineJS</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="PeerConfig.html#skipCheckConnection" class="tsd-kind-icon">skip<wbr/>Check<wbr/>Connection</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
|
|
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "fluence-js",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
19
packages/@tests/marine/node/.gitignore
vendored
Normal file
19
packages/@tests/marine/node/.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 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/
|
||||||
|
/worker/dist/
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
.idea
|
8
packages/@tests/marine/node/.prettierrc.js
Normal file
8
packages/@tests/marine/node/.prettierrc.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
semi: true,
|
||||||
|
trailingComma: 'all',
|
||||||
|
singleQuote: true,
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 4,
|
||||||
|
useTabs: false,
|
||||||
|
};
|
5
packages/@tests/marine/node/jest.config.js
Normal file
5
packages/@tests/marine/node/jest.config.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
testPathIgnorePatterns: ['dist'],
|
||||||
|
};
|
19
packages/@tests/marine/node/package.json
Normal file
19
packages/@tests/marine/node/package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "@test/marine_node",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"test": "jest"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "16.11.59",
|
||||||
|
"typescript": "^4.0.0",
|
||||||
|
"@types/jest": "28.1.0",
|
||||||
|
"jest": "28.1.0",
|
||||||
|
"ts-jest": "28.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fluencelabs/avm": "0.32.1",
|
||||||
|
"@fluencelabs/marine.background-runner": "workspace:0.1.0",
|
||||||
|
"@fluencelabs/marine.deps-loader.node": "workspace:0.1.0"
|
||||||
|
}
|
||||||
|
}
|
54
packages/@tests/marine/node/src/test.spec.ts
Normal file
54
packages/@tests/marine/node/src/test.spec.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { MarineBackgroundRunner } from '@fluencelabs/marine.background-runner';
|
||||||
|
import { InlinedWorkerLoader, WasmNpmLoader } from '@fluencelabs/marine.deps-loader.node';
|
||||||
|
import { callAvm, JSONArray, JSONObject } from '@fluencelabs/avm';
|
||||||
|
|
||||||
|
const vmPeerId = '12D3KooWNzutuy8WHXDKFqFsATvCR6j9cj2FijYbnd47geRKaQZS';
|
||||||
|
|
||||||
|
describe('Nodejs integration tests', () => {
|
||||||
|
it('Smoke test', async () => {
|
||||||
|
let runner: MarineBackgroundRunner | undefined = undefined;
|
||||||
|
try {
|
||||||
|
// arrange
|
||||||
|
const avm = new WasmNpmLoader('@fluencelabs/avm', 'avm.wasm');
|
||||||
|
const control = new WasmNpmLoader('@fluencelabs/marine-js', 'marine-js.wasm');
|
||||||
|
const worker = new InlinedWorkerLoader();
|
||||||
|
runner = new MarineBackgroundRunner(worker, control, () => {});
|
||||||
|
|
||||||
|
await avm.start();
|
||||||
|
|
||||||
|
await runner.start();
|
||||||
|
await runner.createService(avm.getValue(), 'avm');
|
||||||
|
|
||||||
|
const s = `(seq
|
||||||
|
(par
|
||||||
|
(call "${vmPeerId}" ("local_service_id" "local_fn_name") [] result_1)
|
||||||
|
(call "remote_peer_id" ("service_id" "fn_name") [] g)
|
||||||
|
)
|
||||||
|
(call "${vmPeerId}" ("local_service_id" "local_fn_name") [] result_2)
|
||||||
|
)`;
|
||||||
|
|
||||||
|
// act
|
||||||
|
const res = await callAvm(
|
||||||
|
(args: JSONArray | JSONObject) => runner!.callService('avm', 'invoke', args, undefined),
|
||||||
|
{
|
||||||
|
currentPeerId: vmPeerId,
|
||||||
|
initPeerId: vmPeerId,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
ttl: 10000,
|
||||||
|
},
|
||||||
|
s,
|
||||||
|
Buffer.from(''),
|
||||||
|
Buffer.from(''),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(res).toMatchObject({
|
||||||
|
retCode: 0,
|
||||||
|
errorMessage: '',
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
runner?.stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
17
packages/@tests/marine/node/tsconfig.json
Normal file
17
packages/@tests/marine/node/tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["es2015", "dom"],
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": false,
|
||||||
|
"sourceMap": true
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist"],
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
22
packages/@tests/marine/web/.gitignore
vendored
Normal file
22
packages/@tests/marine/web/.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
build/
|
||||||
|
public/*.*
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
bundle/
|
||||||
|
/dist/
|
||||||
|
/worker/dist/
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
.idea
|
8
packages/@tests/marine/web/.prettierrc.js
Normal file
8
packages/@tests/marine/web/.prettierrc.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
semi: true,
|
||||||
|
trailingComma: 'all',
|
||||||
|
singleQuote: true,
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 4,
|
||||||
|
useTabs: false,
|
||||||
|
};
|
12
packages/@tests/marine/web/index.html
Normal file
12
packages/@tests/marine/web/index.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>Webpack App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello world!</h1>
|
||||||
|
<h2>Tip: Check your console</h2>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
9
packages/@tests/marine/web/jest.config.js
Normal file
9
packages/@tests/marine/web/jest.config.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'jest-puppeteer',
|
||||||
|
testMatch: ['**/?(*.)+(spec|test).[t]s'],
|
||||||
|
testPathIgnorePatterns: ['/node_modules/', 'dist'],
|
||||||
|
testMatch: ['**/test/*.spec.ts'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.ts?$': 'ts-jest',
|
||||||
|
},
|
||||||
|
};
|
39
packages/@tests/marine/web/package.json.skip
Normal file
39
packages/@tests/marine/web/package.json.skip
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "@test/marine_web",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"scripts": {
|
||||||
|
"start": "webpack serve",
|
||||||
|
"test": "jest",
|
||||||
|
"build": "webpack --mode=production --node-env=production",
|
||||||
|
"build:dev": "webpack --mode=development",
|
||||||
|
"build:prod": "webpack --mode=production --node-env=production",
|
||||||
|
"watch": "webpack --watch",
|
||||||
|
"serve": "webpack serve"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@webpack-cli/generators": "^2.4.1",
|
||||||
|
"css-loader": "^6.5.1",
|
||||||
|
"html-webpack-plugin": "^5.5.0",
|
||||||
|
"install-local": "^3.0.1",
|
||||||
|
"style-loader": "^3.3.1",
|
||||||
|
"ts-loader": "^8.3.0",
|
||||||
|
"typescript": "^4.5.4",
|
||||||
|
"util": "^0.12.4",
|
||||||
|
"webpack": "^5.65.0",
|
||||||
|
"webpack-cli": "^4.9.1",
|
||||||
|
"webpack-dev-server": "^4.6.0",
|
||||||
|
"@types/jest": "^27.0.3",
|
||||||
|
"@types/jest-environment-puppeteer": "^4.4.1",
|
||||||
|
"@types/puppeteer": "^5.4.4",
|
||||||
|
"jest": "28.1.0",
|
||||||
|
"jest-puppeteer": "^6.0.2",
|
||||||
|
"ts-jest": "28.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fluencelabs/marine.deps-loader.web": "workspace:*",
|
||||||
|
"@fluencelabs/marine.background-runner": "workspace:*",
|
||||||
|
"@fluencelabs/avm": "0.34.4",
|
||||||
|
"js-base64": "^3.7.2",
|
||||||
|
"buffer": "6.0.3"
|
||||||
|
}
|
||||||
|
}
|
56
packages/@tests/marine/web/src/index.ts
Normal file
56
packages/@tests/marine/web/src/index.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
window.Buffer = Buffer;
|
||||||
|
|
||||||
|
import { MarineBackgroundRunner } from '@fluencelabs/marine.background-runner';
|
||||||
|
import { InlinedWorkerLoader, WasmWebLoader } from '@fluencelabs/marine.deps-loader.web';
|
||||||
|
import { callAvm, JSONArray, JSONObject } from '@fluencelabs/avm';
|
||||||
|
import { toUint8Array } from 'js-base64';
|
||||||
|
|
||||||
|
const vmPeerId = '12D3KooWNzutuy8WHXDKFqFsATvCR6j9cj2FijYbnd47geRKaQZS';
|
||||||
|
|
||||||
|
const b = (s: string) => {
|
||||||
|
return toUint8Array(s);
|
||||||
|
};
|
||||||
|
|
||||||
|
const main = async () => {
|
||||||
|
const avm = new WasmWebLoader('avm.wasm');
|
||||||
|
const control = new WasmWebLoader('marine-js.wasm');
|
||||||
|
const worker = new InlinedWorkerLoader();
|
||||||
|
const runner = new MarineBackgroundRunner(worker, control, () => {});
|
||||||
|
|
||||||
|
await runner.start();
|
||||||
|
await avm.start();
|
||||||
|
const avmVal = await avm.getValue();
|
||||||
|
await runner.createService(avmVal, 'avm');
|
||||||
|
|
||||||
|
const s = `(seq
|
||||||
|
(par
|
||||||
|
(call "${vmPeerId}" ("local_service_id" "local_fn_name") [] result_1)
|
||||||
|
(call "remote_peer_id" ("service_id" "fn_name") [] g)
|
||||||
|
)
|
||||||
|
(call "${vmPeerId}" ("local_service_id" "local_fn_name") [] result_2)
|
||||||
|
)`;
|
||||||
|
|
||||||
|
// act
|
||||||
|
const res = await callAvm(
|
||||||
|
(args: JSONArray | JSONObject) => runner.callService('avm', 'invoke', args, undefined),
|
||||||
|
{
|
||||||
|
currentPeerId: vmPeerId,
|
||||||
|
initPeerId: vmPeerId,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
ttl: 10000,
|
||||||
|
},
|
||||||
|
s,
|
||||||
|
b(''),
|
||||||
|
b(''),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
await runner.stop();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
window.MAIN = main;
|
115
packages/@tests/marine/web/test/test.spec.ts
Normal file
115
packages/@tests/marine/web/test/test.spec.ts
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
import Webpack from 'webpack';
|
||||||
|
import WebpackDevServer from 'webpack-dev-server';
|
||||||
|
import webpackConfig from '../webpack.config.js';
|
||||||
|
import process from 'process';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
// change directory to the location to the test-project.
|
||||||
|
// run all the subsequent Webpack scripts in that directory
|
||||||
|
process.chdir(path.join(__dirname, '..'));
|
||||||
|
|
||||||
|
let server;
|
||||||
|
const port = 8080;
|
||||||
|
|
||||||
|
jest.setTimeout(10000);
|
||||||
|
|
||||||
|
const startServer = async (modifyConfig?) => {
|
||||||
|
const loadInBrowserToDebug = false;
|
||||||
|
// const loadInBrowserToDebug = true; // use this line to debug
|
||||||
|
|
||||||
|
modifyConfig = modifyConfig || ((_) => {});
|
||||||
|
|
||||||
|
const config: any = webpackConfig();
|
||||||
|
modifyConfig(config);
|
||||||
|
config.devServer.open = loadInBrowserToDebug;
|
||||||
|
server = await makeServer(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/42940550/wait-until-webpack-dev-server-is-ready
|
||||||
|
function makeServer(config) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const compiler = Webpack(config);
|
||||||
|
|
||||||
|
let compiled = false;
|
||||||
|
let listening = false;
|
||||||
|
|
||||||
|
compiler.hooks.done.tap('tap_name', () => {
|
||||||
|
// console.log('compiled');
|
||||||
|
|
||||||
|
if (listening) resolve(server);
|
||||||
|
else compiled = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const server = new WebpackDevServer(compiler, config.devServer);
|
||||||
|
|
||||||
|
server.listen(port, '0.0.0.0', (err) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
|
||||||
|
// console.log('listening');
|
||||||
|
|
||||||
|
if (compiled) {
|
||||||
|
resolve(server);
|
||||||
|
} else {
|
||||||
|
listening = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopServer = async () => {
|
||||||
|
console.log('test: stopping server');
|
||||||
|
await server.stop();
|
||||||
|
};
|
||||||
|
|
||||||
|
const publicDir = 'public';
|
||||||
|
|
||||||
|
const copyFile = async (packageName: string, fileName: string) => {
|
||||||
|
const modulePath = require.resolve(packageName);
|
||||||
|
const source = path.join(path.dirname(modulePath), fileName);
|
||||||
|
const dest = path.join(publicDir, fileName);
|
||||||
|
|
||||||
|
return fs.promises.copyFile(source, dest);
|
||||||
|
};
|
||||||
|
|
||||||
|
const copyPublicDeps = async () => {
|
||||||
|
await fs.promises.mkdir(publicDir, { recursive: true });
|
||||||
|
return Promise.all([
|
||||||
|
copyFile('@fluencelabs/marine-js', 'marine-js.wasm'),
|
||||||
|
copyFile('@fluencelabs/avm', 'avm.wasm'),
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cleanPublicDeps = () => {
|
||||||
|
return fs.promises.rm(publicDir, { recursive: true, force: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Browser integration tests', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await copyPublicDeps();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await stopServer();
|
||||||
|
await cleanPublicDeps();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Some test', async () => {
|
||||||
|
console.log('test: starting server...');
|
||||||
|
await startServer();
|
||||||
|
console.log('test: navigating to page...');
|
||||||
|
await page.goto('http://localhost:8080/');
|
||||||
|
|
||||||
|
console.log('test: running script in browser...');
|
||||||
|
const res = await page.evaluate(() => {
|
||||||
|
// @ts-ignore
|
||||||
|
return window.MAIN();
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('test: checking expectations...');
|
||||||
|
await expect(res).toMatchObject({
|
||||||
|
retCode: 0,
|
||||||
|
errorMessage: '',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
23
packages/@tests/marine/web/tsconfig.json
Normal file
23
packages/@tests/marine/web/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"allowJs": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"sourceMap": false,
|
||||||
|
"inlineSources": false,
|
||||||
|
"pretty": true,
|
||||||
|
"target": "esnext",
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": false,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"declarationMap": false,
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"alwaysStrict": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"strictNullChecks": false
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist"],
|
||||||
|
"include": ["src", "test"]
|
||||||
|
}
|
65
packages/@tests/marine/web/webpack.config.js
Normal file
65
packages/@tests/marine/web/webpack.config.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Generated using webpack-cli https://github.com/webpack/webpack-cli
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
|
||||||
|
const isProduction = process.env.NODE_ENV == 'production';
|
||||||
|
|
||||||
|
const stylesHandler = 'style-loader';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
entry: './src/index.ts',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, 'dist'),
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
open: true,
|
||||||
|
host: 'localhost',
|
||||||
|
static: {
|
||||||
|
directory: path.join(__dirname, 'public'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: 'index.html',
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Add your plugins here
|
||||||
|
// Learn more about plugins from https://webpack.js.org/configuration/plugins/
|
||||||
|
],
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(ts|tsx)$/i,
|
||||||
|
loader: 'ts-loader',
|
||||||
|
exclude: ['/node_modules/'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/i,
|
||||||
|
use: [stylesHandler, 'css-loader'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
|
||||||
|
type: 'asset',
|
||||||
|
},
|
||||||
|
|
||||||
|
// Add your rules for custom modules here
|
||||||
|
// Learn more about loaders from https://webpack.js.org/loaders/
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.tsx', '.ts', '.js'],
|
||||||
|
fallback: {
|
||||||
|
buffer: require.resolve('buffer/'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
if (isProduction) {
|
||||||
|
config.mode = 'production';
|
||||||
|
} else {
|
||||||
|
config.mode = 'development';
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
};
|
@ -3,13 +3,13 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/fluence": "workspace:*",
|
"@fluencelabs/js-client.web": "workspace:*",
|
||||||
"@fluencelabs/fluence-network-environment": "^1.0.13",
|
"@fluencelabs/fluence-network-environment": "^1.0.13",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^27.5.2",
|
||||||
"@types/node": "^16.11.56",
|
"@types/node": "16.11.59",
|
||||||
"@types/react": "^18.0.18",
|
"@types/react": "^18.0.18",
|
||||||
"@types/react-dom": "^18.0.6",
|
"@types/react-dom": "^18.0.6",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
@ -21,7 +21,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"_test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
@ -2,16 +2,18 @@ import React, { useEffect, useState } from "react";
|
|||||||
import logo from "./logo.svg";
|
import logo from "./logo.svg";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
|
||||||
import { Fluence } from "@fluencelabs/fluence";
|
import { makeDefaultPeer } from "@fluencelabs/js-client.web";
|
||||||
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
||||||
|
|
||||||
const relayNode = krasnodar[4];
|
const relayNode = krasnodar[4];
|
||||||
|
|
||||||
|
const peer = makeDefaultPeer();
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [connected, setConnected] = useState<boolean>(false);
|
const [connected, setConnected] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Fluence.start({ connectTo: relayNode })
|
peer.start({ connectTo: relayNode })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setConnected(true);
|
setConnected(true);
|
||||||
})
|
})
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/fluence": "workspace:*",
|
"@fluencelabs/fluence": "workspace:*",
|
||||||
"ts-node": "^10.9.1"
|
"@fluencelabs/js-client.node": "workspace:*",
|
||||||
|
"ts-node": "10.9.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.7.13",
|
"@types/node": "16.11.59",
|
||||||
"typescript": "^4.6.4"
|
"typescript": "4.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { FluencePeer } from "@fluencelabs/fluence";
|
import "@fluencelabs/js-client.node";
|
||||||
|
import { Fluence } from "@fluencelabs/fluence";
|
||||||
|
|
||||||
const peer = new FluencePeer();
|
const peer = Fluence.getPeer();
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
await peer.start({});
|
await peer.start({});
|
||||||
|
11
packages/client/compiler-support/README.md
Normal file
11
packages/client/compiler-support/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# JS Client compiler support
|
||||||
|
|
||||||
|
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)
|
28
packages/client/compiler-support/package.json
Normal file
28
packages/client/compiler-support/package.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "@fluencelabs/compiler-support",
|
||||||
|
"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.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "16.11.59",
|
||||||
|
"@types/jest": "28.1.0",
|
||||||
|
"jest": "28.1.0",
|
||||||
|
"ts-jest": "28.0.2",
|
||||||
|
"ts-node": "10.9.1",
|
||||||
|
"typescript": "4.6.4"
|
||||||
|
}
|
||||||
|
}
|
6
packages/client/compiler-support/src/util.ts
Normal file
6
packages/client/compiler-support/src/util.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import type { FluencePeer } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||||
|
|
||||||
|
export const getDefaultPeer = (): FluencePeer => {
|
||||||
|
// @ts-ignore
|
||||||
|
return globalThis.defaultPeer;
|
||||||
|
};
|
175
packages/client/compiler-support/src/v3.ts
Normal file
175
packages/client/compiler-support/src/v3.ts
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2022 Fluence Labs Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { FluencePeer } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||||
|
import { FnConfig, FunctionCallDef, ServiceDef } from '@fluencelabs/js-peer/dist/compilerSupport/interface';
|
||||||
|
import { registerServiceImpl } from '@fluencelabs/js-peer/dist/compilerSupport/registerService';
|
||||||
|
import { callFunctionImpl, getArgumentTypes } from '@fluencelabs/js-peer/dist/compilerSupport/callFunction';
|
||||||
|
|
||||||
|
import { getDefaultPeer } from './util';
|
||||||
|
|
||||||
|
export { FluencePeer } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||||
|
export { CallParams } from '@fluencelabs/js-peer/dist/commonTypes';
|
||||||
|
export {
|
||||||
|
ArrayType,
|
||||||
|
ArrowType,
|
||||||
|
ArrowWithCallbacks,
|
||||||
|
ArrowWithoutCallbacks,
|
||||||
|
BottomType,
|
||||||
|
FnConfig,
|
||||||
|
FunctionCallConstants,
|
||||||
|
FunctionCallDef,
|
||||||
|
LabeledProductType,
|
||||||
|
NilType,
|
||||||
|
NonArrowType,
|
||||||
|
OptionType,
|
||||||
|
ProductType,
|
||||||
|
ScalarNames,
|
||||||
|
ScalarType,
|
||||||
|
ServiceDef,
|
||||||
|
StructType,
|
||||||
|
TopType,
|
||||||
|
UnlabeledProductType,
|
||||||
|
} from '@fluencelabs/js-peer/dist/compilerSupport/interface';
|
||||||
|
export { callFunctionImpl } from '@fluencelabs/js-peer/dist/compilerSupport/callFunction';
|
||||||
|
export { registerServiceImpl } from '@fluencelabs/js-peer/dist/compilerSupport/registerService';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience function to support Aqua `func` generation backend
|
||||||
|
* The compiler only need to generate a call the function and provide the corresponding definitions and the air script
|
||||||
|
*
|
||||||
|
* @param rawFnArgs - raw arguments passed by user to the generated function
|
||||||
|
* @param def - function definition generated by the Aqua compiler
|
||||||
|
* @param script - air script with function execution logic generated by the Aqua compiler
|
||||||
|
*/
|
||||||
|
export const callFunction = (rawFnArgs: Array<any>, def: FunctionCallDef, script: string) => {
|
||||||
|
const { args, peer, config } = extractFunctionArgs(rawFnArgs, def);
|
||||||
|
return callFunctionImpl(def, script, config || {}, peer, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience function to support Aqua `service` generation backend
|
||||||
|
* The compiler only need to generate a call the function and provide the corresponding definitions and the air script
|
||||||
|
*
|
||||||
|
* @param args - raw arguments passed by user to the generated function
|
||||||
|
* @param def - service definition generated by the Aqua compiler
|
||||||
|
*/
|
||||||
|
export function registerService(args: any[], def: ServiceDef) {
|
||||||
|
const { peer, service, serviceId } = extractServiceArgs(args, def.defaultServiceId);
|
||||||
|
|
||||||
|
return registerServiceImpl(peer, def, serviceId, service);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arguments could be passed in one these configurations:
|
||||||
|
* [...actualArgs]
|
||||||
|
* [peer, ...actualArgs]
|
||||||
|
* [...actualArgs, config]
|
||||||
|
* [peer, ...actualArgs, config]
|
||||||
|
*
|
||||||
|
* This function select the appropriate configuration and returns
|
||||||
|
* arguments in a structured way of: { peer, config, args }
|
||||||
|
*/
|
||||||
|
const extractFunctionArgs = (
|
||||||
|
args: any[],
|
||||||
|
def: FunctionCallDef,
|
||||||
|
): {
|
||||||
|
peer: FluencePeer;
|
||||||
|
config?: FnConfig;
|
||||||
|
args: { [key: string]: any };
|
||||||
|
} => {
|
||||||
|
const argumentTypes = getArgumentTypes(def);
|
||||||
|
const argumentNames = Object.keys(argumentTypes);
|
||||||
|
const numberOfExpectedArgs = argumentNames.length;
|
||||||
|
|
||||||
|
let peer: FluencePeer;
|
||||||
|
let structuredArgs: any[];
|
||||||
|
let config: FnConfig;
|
||||||
|
if (FluencePeer.isInstance(args[0])) {
|
||||||
|
peer = args[0];
|
||||||
|
structuredArgs = args.slice(1, numberOfExpectedArgs + 1);
|
||||||
|
config = args[numberOfExpectedArgs + 1];
|
||||||
|
} else {
|
||||||
|
peer = getDefaultPeer();
|
||||||
|
structuredArgs = args.slice(0, numberOfExpectedArgs);
|
||||||
|
config = args[numberOfExpectedArgs];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredArgs.length !== numberOfExpectedArgs) {
|
||||||
|
throw new Error(`Incorrect number of arguments. Expecting ${numberOfExpectedArgs}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const argsRes = argumentNames.reduce((acc, name, index) => ({ ...acc, [name]: structuredArgs[index] }), {});
|
||||||
|
|
||||||
|
return {
|
||||||
|
peer: peer,
|
||||||
|
config: config,
|
||||||
|
args: argsRes,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arguments could be passed in one these configurations:
|
||||||
|
* [serviceObject]
|
||||||
|
* [peer, serviceObject]
|
||||||
|
* [defaultId, serviceObject]
|
||||||
|
* [peer, defaultId, serviceObject]
|
||||||
|
*
|
||||||
|
* Where serviceObject is the raw object with function definitions passed by user
|
||||||
|
*
|
||||||
|
* This function select the appropriate configuration and returns
|
||||||
|
* arguments in a structured way of: { peer, serviceId, service }
|
||||||
|
*/
|
||||||
|
const extractServiceArgs = (
|
||||||
|
args: any[],
|
||||||
|
defaultServiceId?: string,
|
||||||
|
): { peer: FluencePeer; serviceId: string; service: any } => {
|
||||||
|
let peer: FluencePeer;
|
||||||
|
let serviceId: any;
|
||||||
|
let service: any;
|
||||||
|
if (FluencePeer.isInstance(args[0])) {
|
||||||
|
peer = args[0];
|
||||||
|
} else {
|
||||||
|
peer = getDefaultPeer();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof args[0] === 'string') {
|
||||||
|
serviceId = args[0];
|
||||||
|
} else if (typeof args[1] === 'string') {
|
||||||
|
serviceId = args[1];
|
||||||
|
} else {
|
||||||
|
serviceId = defaultServiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Figuring out which overload is the service.
|
||||||
|
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||||
|
// If the first argument is peer, we are checking further. The second argument might either be
|
||||||
|
// an object, that it must be the service object
|
||||||
|
// or a string, which is the service id. In that case the service is the third argument
|
||||||
|
if (!FluencePeer.isInstance(args[0]) && typeof args[0] === 'object') {
|
||||||
|
service = args[0];
|
||||||
|
} else if (typeof args[1] === 'object') {
|
||||||
|
service = args[1];
|
||||||
|
} else {
|
||||||
|
service = args[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
peer: peer,
|
||||||
|
serviceId: serviceId,
|
||||||
|
service: service,
|
||||||
|
};
|
||||||
|
};
|
@ -14,8 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { FluencePeer } from '../FluencePeer';
|
export { FluencePeer } from './v3';
|
||||||
export { CallParams as CallParams$$ } from '../commonTypes';
|
export { CallParams as CallParams$$ } from './v3';
|
||||||
export {
|
export {
|
||||||
ArrayType as ArrayType$$,
|
ArrayType as ArrayType$$,
|
||||||
ArrowType as ArrowType$$,
|
ArrowType as ArrowType$$,
|
||||||
@ -38,4 +38,6 @@ export {
|
|||||||
UnlabeledProductType as UnlabeledProductType$$,
|
UnlabeledProductType as UnlabeledProductType$$,
|
||||||
callFunction as callFunction$$,
|
callFunction as callFunction$$,
|
||||||
registerService as registerService$$,
|
registerService as registerService$$,
|
||||||
|
registerServiceImpl as registerServiceImpl$$,
|
||||||
|
callFunctionImpl as callFunctionImpl$$,
|
||||||
} from './v3';
|
} from './v3';
|
1
packages/client/fluence-js/.prettierignore
Normal file
1
packages/client/fluence-js/.prettierignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist/
|
32
packages/client/fluence-js/package.json
Normal file
32
packages/client/fluence-js/package.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "@fluencelabs/fluence",
|
||||||
|
"version": "0.28.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": {
|
||||||
|
"loglevel": "1.8.1",
|
||||||
|
"@fluencelabs/keypair": "workspace:0.2.0",
|
||||||
|
"@fluencelabs/avm": "0.32.1",
|
||||||
|
"@fluencelabs/marine-js": "0.3.38",
|
||||||
|
"@fluencelabs/js-peer": "workspace:0.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "16.11.59",
|
||||||
|
"@types/jest": "28.1.0",
|
||||||
|
"jest": "28.1.0",
|
||||||
|
"ts-jest": "28.0.2",
|
||||||
|
"ts-node": "10.9.1",
|
||||||
|
"typescript": "4.6.4"
|
||||||
|
}
|
||||||
|
}
|
@ -17,13 +17,11 @@
|
|||||||
import log, { LogLevelDesc } from 'loglevel';
|
import log, { LogLevelDesc } from 'loglevel';
|
||||||
export { KeyPair } from '@fluencelabs/keypair';
|
export { KeyPair } from '@fluencelabs/keypair';
|
||||||
|
|
||||||
import { FluencePeer, PeerConfig } from './internal/FluencePeer';
|
import { FluencePeer, PeerConfig } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||||
|
|
||||||
export { PeerStatus } from './internal/FluencePeer';
|
export { PeerStatus } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||||
export { FluencePeer, PeerConfig } from './internal/FluencePeer';
|
export { FluencePeer, PeerConfig } from '@fluencelabs/js-peer/dist/FluencePeer';
|
||||||
export { MarineLoglevel as AvmLoglevel } from './internal/utils';
|
export { PeerIdB58, CallParams } from '@fluencelabs/js-peer/dist/commonTypes';
|
||||||
export { PeerIdB58, CallParams } from './internal/commonTypes';
|
|
||||||
export { loadWasmFromFileSystem, loadWasmFromNpmPackage, loadWasmFromServer } from '@fluencelabs/marine-js';
|
|
||||||
|
|
||||||
export const setLogLevel = (level: LogLevelDesc) => {
|
export const setLogLevel = (level: LogLevelDesc) => {
|
||||||
log.setLevel(level);
|
log.setLevel(level);
|
||||||
@ -31,7 +29,8 @@ export const setLogLevel = (level: LogLevelDesc) => {
|
|||||||
|
|
||||||
log.setDefaultLevel('WARN');
|
log.setDefaultLevel('WARN');
|
||||||
|
|
||||||
const defaultPeer = new FluencePeer();
|
// @ts-ignore
|
||||||
|
const defaultPeer = globalThis.defaultPeer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public interface to Fluence JS
|
* Public interface to Fluence JS
|
2
packages/client/fluence-js/src/services.ts
Normal file
2
packages/client/fluence-js/src/services.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from '@fluencelabs/js-peer/dist/builtins/Sig';
|
||||||
|
export { registerSig } from '@fluencelabs/js-peer/dist/_aqua/services';
|
21
packages/client/fluence-js/tsconfig.json
Normal file
21
packages/client/fluence-js/tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"target": "ES5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist", "bundle"],
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
1
packages/client/js-client.node/.prettierignore
Normal file
1
packages/client/js-client.node/.prettierignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist/
|
11
packages/client/js-client.node/README.md
Normal file
11
packages/client/js-client.node/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# JS Client node
|
||||||
|
|
||||||
|
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)
|
30
packages/client/js-client.node/package.json
Normal file
30
packages/client/js-client.node/package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "@fluencelabs/js-client.node",
|
||||||
|
"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.1.0",
|
||||||
|
"@fluencelabs/marine.deps-loader.node": "workspace:0.1.0",
|
||||||
|
"@fluencelabs/marine.background-runner": "workspace:0.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "16.11.59",
|
||||||
|
"@types/jest": "28.1.0",
|
||||||
|
"jest": "28.1.0",
|
||||||
|
"ts-jest": "28.0.2",
|
||||||
|
"ts-node": "10.9.1",
|
||||||
|
"typescript": "4.6.4"
|
||||||
|
}
|
||||||
|
}
|
29
packages/client/js-client.node/src/index.ts
Normal file
29
packages/client/js-client.node/src/index.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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, WasmNpmLoader } from '@fluencelabs/marine.deps-loader.node';
|
||||||
|
|
||||||
|
export const defaultNames = {
|
||||||
|
avm: {
|
||||||
|
file: 'avm.wasm',
|
||||||
|
package: '@fluencelabs/avm',
|
||||||
|
},
|
||||||
|
marine: {
|
||||||
|
file: 'marine-js.wasm',
|
||||||
|
package: '@fluencelabs/marine-js',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const makeDefaultPeer = () => {
|
||||||
|
const workerLoader = new InlinedWorkerLoader();
|
||||||
|
const controlModuleLoader = new WasmNpmLoader(defaultNames.marine.package, defaultNames.marine.file);
|
||||||
|
const avmModuleLoader = new WasmNpmLoader(defaultNames.avm.package, defaultNames.avm.file);
|
||||||
|
|
||||||
|
const marine = new MarineBackgroundRunner(workerLoader, controlModuleLoader, marineLogFunction);
|
||||||
|
const avm = new MarineBasedAvmRunner(marine, avmModuleLoader, undefined);
|
||||||
|
return new FluencePeer(marine, avm);
|
||||||
|
};
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
globalThis.defaultPeer = makeDefaultPeer();
|
21
packages/client/js-client.node/tsconfig.json
Normal file
21
packages/client/js-client.node/tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"target": "ES5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist", "bundle"],
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
1
packages/client/js-client.web/.prettierignore
Normal file
1
packages/client/js-client.web/.prettierignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist/
|
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)
|
30
packages/client/js-client.web/package.json
Normal file
30
packages/client/js-client.web/package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"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.1.0",
|
||||||
|
"@fluencelabs/marine.deps-loader.web": "workspace:0.1.0",
|
||||||
|
"@fluencelabs/marine.background-runner": "workspace:0.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "16.11.59",
|
||||||
|
"@types/jest": "28.1.0",
|
||||||
|
"jest": "28.1.0",
|
||||||
|
"ts-jest": "28.0.2",
|
||||||
|
"ts-node": "10.9.1",
|
||||||
|
"typescript": "4.6.4"
|
||||||
|
}
|
||||||
|
}
|
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();
|
21
packages/client/js-client.web/tsconfig.json
Normal file
21
packages/client/js-client.web/tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"target": "ES5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist", "bundle"],
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
21
packages/client/tools/.gitignore
vendored
Normal file
21
packages/client/tools/.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
|
1
packages/client/tools/.prettierignore
Normal file
1
packages/client/tools/.prettierignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist/
|
8
packages/client/tools/.prettierrc.js
Normal file
8
packages/client/tools/.prettierrc.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
semi: true,
|
||||||
|
trailingComma: "all",
|
||||||
|
singleQuote: true,
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 4,
|
||||||
|
useTabs: false
|
||||||
|
};
|
11
packages/client/tools/README.md
Normal file
11
packages/client/tools/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Fluence JS Client tools
|
||||||
|
|
||||||
|
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)
|
25
packages/client/tools/package.json
Normal file
25
packages/client/tools/package.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "@fluencelabs/tools",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Fluence JS Client tools",
|
||||||
|
"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",
|
||||||
|
"bin": {
|
||||||
|
"copy-marine": "dist/copyMarine.js"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "16.11.59",
|
||||||
|
"typescript": "4.6.4"
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,7 @@ async function main() {
|
|||||||
await fs.promises.mkdir(destPath, { recursive: true });
|
await fs.promises.mkdir(destPath, { recursive: true });
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
copyFile('@fluencelabs/marine-js', 'marine-js.web.js'),
|
copyFile('@fluencelabs/marine.worker-script', 'marine-js.web.js'),
|
||||||
copyFile('@fluencelabs/marine-js', 'marine-js.wasm'),
|
copyFile('@fluencelabs/marine-js', 'marine-js.wasm'),
|
||||||
copyFile('@fluencelabs/avm', 'avm.wasm'),
|
copyFile('@fluencelabs/avm', 'avm.wasm'),
|
||||||
]);
|
]);
|
21
packages/client/tools/tsconfig.json
Normal file
21
packages/client/tools/tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"target": "ES5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist", "bundle"],
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
21
packages/core/connection/.gitignore
vendored
Normal file
21
packages/core/connection/.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
|
8
packages/core/connection/.prettierrc.js
Normal file
8
packages/core/connection/.prettierrc.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
semi: true,
|
||||||
|
trailingComma: "all",
|
||||||
|
singleQuote: true,
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 4,
|
||||||
|
useTabs: false
|
||||||
|
};
|
@ -15,21 +15,21 @@
|
|||||||
"author": "Fluence Labs",
|
"author": "Fluence Labs",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/interfaces": "workspace:0.1.0",
|
"@fluencelabs/interfaces": "workspace:0.2.0",
|
||||||
"peer-id": "0.16.0",
|
"peer-id": "0.16.0",
|
||||||
"it-length-prefixed": "5.0.3",
|
"it-length-prefixed": "5.0.3",
|
||||||
"it-pipe": "1.1.0",
|
"it-pipe": "1.1.0",
|
||||||
"@chainsafe/libp2p-noise": "^4.1.1",
|
"@chainsafe/libp2p-noise": "4.1.1",
|
||||||
"libp2p": "0.36.2",
|
"libp2p": "0.36.2",
|
||||||
"libp2p-interfaces": "^4.0.6",
|
"libp2p-interfaces": "4.0.6",
|
||||||
"libp2p-mplex": "0.10.7",
|
"libp2p-mplex": "0.10.7",
|
||||||
"libp2p-websockets": "0.16.2",
|
"libp2p-websockets": "0.16.2",
|
||||||
"loglevel": "1.8.1",
|
"loglevel": "1.8.1",
|
||||||
"multiaddr": "10.0.1",
|
"multiaddr": "10.0.1",
|
||||||
"browser-or-node": "2.0.0",
|
"browser-or-node": "2.0.0",
|
||||||
"buffer": "^6.0.3"
|
"buffer": "6.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.6.4"
|
"typescript": "4.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,10 +25,10 @@ import * as log from 'loglevel';
|
|||||||
import { Noise } from '@chainsafe/libp2p-noise';
|
import { Noise } from '@chainsafe/libp2p-noise';
|
||||||
import PeerId from 'peer-id';
|
import PeerId from 'peer-id';
|
||||||
import type { MultiaddrInput } from 'multiaddr';
|
import type { MultiaddrInput } from 'multiaddr';
|
||||||
|
import { Connection } from 'libp2p-interfaces/src/topology';
|
||||||
import { Multiaddr } from 'multiaddr';
|
import { Multiaddr } from 'multiaddr';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { all as allow_all } from 'libp2p-websockets/src/filters';
|
import { all as allow_all } from 'libp2p-websockets/src/filters';
|
||||||
import { Connection } from 'libp2p-interfaces/src/topology';
|
|
||||||
import Buffer from './Buffer';
|
import Buffer from './Buffer';
|
||||||
|
|
||||||
export const PROTOCOL_NAME = '/fluence/particle/2.0.0';
|
export const PROTOCOL_NAME = '/fluence/particle/2.0.0';
|
||||||
@ -53,7 +53,7 @@ export interface FluenceConnectionOptions {
|
|||||||
dialTimeoutMs?: number;
|
dialTimeoutMs?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Implementation for JS peers which connects to Fluence through relay node
|
* Implementation for JS peers which connects to Fluence through relay node
|
||||||
*/
|
*/
|
||||||
export class RelayConnection extends FluenceConnection {
|
export class RelayConnection extends FluenceConnection {
|
||||||
@ -65,9 +65,7 @@ export class RelayConnection extends FluenceConnection {
|
|||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _connection?: Connection;
|
private _connection?: Connection;
|
||||||
|
|
||||||
static async createConnection(options: FluenceConnectionOptions): Promise<RelayConnection> {
|
static async createConnection(options: FluenceConnectionOptions): Promise<RelayConnection> {
|
||||||
const transportKey = Websockets.prototype[Symbol.toStringTag];
|
const transportKey = Websockets.prototype[Symbol.toStringTag];
|
||||||
const lib2p2Peer = await Lib2p2Peer.create({
|
const lib2p2Peer = await Lib2p2Peer.create({
|
||||||
@ -88,13 +86,11 @@ export class RelayConnection extends FluenceConnection {
|
|||||||
dialTimeout: options?.dialTimeoutMs,
|
dialTimeout: options?.dialTimeoutMs,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const relayMultiaddr = new Multiaddr(options.relayAddress);
|
const relayMultiaddr = new Multiaddr(options.relayAddress);
|
||||||
const relayPeerId = relayMultiaddr.getPeerId();
|
const relayPeerId = relayMultiaddr.getPeerId();
|
||||||
if (relayPeerId === null) {
|
if (relayPeerId === null) {
|
||||||
throw new Error('Specified multiaddr is invalid or missing peer id: ' + options.relayAddress);
|
throw new Error('Specified multiaddr is invalid or missing peer id: ' + options.relayAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RelayConnection(
|
return new RelayConnection(
|
||||||
// force new line
|
// force new line
|
||||||
options.peerId.toB58String(),
|
options.peerId.toB58String(),
|
||||||
@ -117,19 +113,15 @@ export class RelayConnection extends FluenceConnection {
|
|||||||
)} instead.`,
|
)} instead.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO:: find out why this doesn't work and a new connection has to be established each time
|
TODO:: find out why this doesn't work and a new connection has to be established each time
|
||||||
if (this._connection.streams.length !== 1) {
|
if (this._connection.streams.length !== 1) {
|
||||||
throw new Error('Incorrect number of streams in FluenceConnection');
|
throw new Error('Incorrect number of streams in FluenceConnection');
|
||||||
}
|
}
|
||||||
|
|
||||||
const sink = this._connection.streams[0].sink;
|
const sink = this._connection.streams[0].sink;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const conn = await this._lib2p2Peer.dialProtocol(this._relayAddress, PROTOCOL_NAME);
|
const conn = await this._lib2p2Peer.dialProtocol(this._relayAddress, PROTOCOL_NAME);
|
||||||
const sink = conn.stream.sink;
|
const sink = conn.stream.sink;
|
||||||
|
|
||||||
pipe(
|
pipe(
|
||||||
// force new line
|
// force new line
|
||||||
[Buffer.from(particle, 'utf8')],
|
[Buffer.from(particle, 'utf8')],
|
||||||
@ -161,9 +153,7 @@ export class RelayConnection extends FluenceConnection {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.debug(`dialing to the node with client's address: ` + this._lib2p2Peer.peerId.toB58String());
|
log.debug(`dialing to the node with client's address: ` + this._lib2p2Peer.peerId.toB58String());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this._connection = await this._lib2p2Peer.dial(this._relayAddress);
|
this._connection = await this._lib2p2Peer.dial(this._relayAddress);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
21
packages/core/interfaces/.gitignore
vendored
Normal file
21
packages/core/interfaces/.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
|
8
packages/core/interfaces/.prettierrc.js
Normal file
8
packages/core/interfaces/.prettierrc.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
semi: true,
|
||||||
|
trailingComma: "all",
|
||||||
|
singleQuote: true,
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 4,
|
||||||
|
useTabs: false
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user