Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a5321e6
* Separate marine worker as a package
akim-bow Aug 1, 2023
84406d4
Finalizing test fixes
akim-bow Aug 1, 2023
de39c0c
fix: rename back to Fluence CLI (#320)
shamsartem Jul 21, 2023
48d2d1b
fix(deps): update dependency @fluencelabs/avm to v0.43.1 (#322)
renovate[bot] Aug 8, 2023
a152db2
chore: release master (#324)
fluencebot Aug 9, 2023
9276dee
feat: use marine-js 0.7.2 (#321)
ValeryAntopol Aug 9, 2023
c85ed25
chore: Fix test with node 18/20 error message (#323)
akim-bow Aug 9, 2023
1ccf057
* Separate marine worker as a package
akim-bow Aug 1, 2023
34820cc
Finalizing test fixes
akim-bow Aug 1, 2023
a8f206e
* Refactoring packages.
akim-bow Aug 8, 2023
e6b62ac
Fix almost all tests
akim-bow Aug 10, 2023
a30ab59
Fix last strange test
akim-bow Aug 10, 2023
c8946e3
Remove package specific packages
akim-bow Aug 11, 2023
56dab3b
Remove avm class as it looks excessive
akim-bow Aug 14, 2023
61096ac
marine worker new version
akim-bow Aug 14, 2023
3468cbd
Merge branch 'master' into unify-all-packages
akim-bow Aug 14, 2023
1483b96
misc refactoring/remove console.log's
akim-bow Aug 15, 2023
9bd451b
Rename package js-peer to js-client
akim-bow Aug 15, 2023
bdfd617
Move service info to marine worker
akim-bow Aug 15, 2023
39328ad
Change CDN path
akim-bow Aug 15, 2023
5cb5f5f
Fix worker race confition
akim-bow Aug 15, 2023
c1cd6cd
Remove buffer type
akim-bow Aug 16, 2023
631f1ba
Remove turned off headless mode in platform tests
akim-bow Aug 16, 2023
315d760
Remove async keyword to make tests pass
akim-bow Aug 16, 2023
24b7bd5
Remove util package
akim-bow Aug 16, 2023
5ea2aef
Make js-client.api package just reexport interface from js-client mai…
akim-bow Aug 16, 2023
c078758
Update package info in CI
akim-bow Aug 16, 2023
2881e7a
Fix review comments
akim-bow Aug 17, 2023
ca93e66
Remove test entry from marine-worker package
akim-bow Aug 17, 2023
35c5a2f
Misc fixes
akim-bow Aug 17, 2023
e1de1b1
Fix worker type
akim-bow Aug 21, 2023
db34a6e
Add fetchers
akim-bow Aug 21, 2023
8e63dc8
Specify correct versions for js-client package
akim-bow Aug 21, 2023
3630d90
Set first ver for js-client
akim-bow Aug 21, 2023
c7552ac
Update libp2p and related dep versions to the latest
akim-bow Aug 22, 2023
b97ffe0
Build all deps into package itself
akim-bow Aug 23, 2023
b7d3a85
Fix review
akim-bow Aug 24, 2023
784ddef
Refine package
akim-bow Aug 24, 2023
bcf0a1c
Fix comment
akim-bow Aug 24, 2023
ffd7519
Update packages/core/js-client/src/fetchers/browser.ts
shamsartem Aug 24, 2023
5b5560a
Update packages/core/js-client/src/fetchers/index.ts
shamsartem Aug 24, 2023
ab10e57
Update packages/core/js-client/src/fetchers/node.ts
shamsartem Aug 24, 2023
50c72e7
Update packages/core/js-client/src/jsPeer/FluencePeer.ts
shamsartem Aug 24, 2023
14e0dd3
Update packages/core/js-client/src/keypair/__test__/KeyPair.spec.ts
shamsartem Aug 24, 2023
da8adb7
Update packages/core/js-client/src/jsPeer/FluencePeer.ts
akim-bow Aug 24, 2023
acefb3a
Delete outdated file
akim-bow Aug 24, 2023
a3543f4
Need types for build to work
akim-bow Aug 24, 2023
86a18be
Inline func call
akim-bow Aug 24, 2023
645a5bf
Add comments to replacement lines.
akim-bow Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/release-please/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
],
"packages": {
"packages/client/api": {},
"packages/client/js-client.node": {},
"packages/client/js-client.web": {},
"packages/client/js-client.web.standalone": {},
"packages/client/tools": {},
"packages/core/js-client": {},
"packages/core/interfaces": {},
"packages/core/js-peer": {}
"packages/core/marine-worker": {}
}
}
9 changes: 3 additions & 6 deletions .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"packages/client/api": "0.12.1",
"packages/client/js-client.node": "0.7.1",
"packages/client/js-client.web": "0.2.5",
"packages/client/js-client.web.standalone": "0.14.1",
"packages/client/tools": "0.2.1",
"packages/core/interfaces": "0.8.1",
"packages/core/js-peer": "0.9.1"
"packages/core/js-client": "0.0.10",
"packages/core/marine-worker": "0.2.10",
"packages/core/interfaces": "0.8.1"
}
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
uses: fluencelabs/flox/.github/workflows/tests.yml@main
with:
js-client-snapshots: "${{ needs.js-client.outputs.js-client-snapshots }}"
nox-image: "fluencelabs/nox:unstable_minimal"
nox-image: "fluencelabs/nox:unstable_minimal"
1 change: 1 addition & 0 deletions packages/@tests/aqua/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client.api": "workspace:^",
"@fluencelabs/js-client": "workspace:^",
"base64-js": "1.5.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/@tests/aqua/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fromByteArray } from 'base64-js';
import { Fluence } from '@fluencelabs/js-client.api';
import type { ClientConfig } from '@fluencelabs/js-client.api';
import { Fluence } from '@fluencelabs/js-client';
import type { ClientConfig } from '@fluencelabs/js-client';
import { registerHelloWorld, helloTest, marineTest, resourceTest } from './_aqua/smoke_test.js';
import { wasm } from './wasmb64.js';

Expand Down
8 changes: 3 additions & 5 deletions packages/@tests/smoke/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client.api": "workspace:^",
"@fluencelabs/js-client.node": "workspace:^",
"@test/aqua_for_test": "workspace:^"
},
"devDependencies": {}
"@fluencelabs/js-client": "workspace:*",
"@test/aqua_for_test": "workspace:../../aqua"
}
}
2 changes: 1 addition & 1 deletion packages/@tests/smoke/node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@fluencelabs/js-client.node';
import '@fluencelabs/js-client';
import { runTest } from '@test/aqua_for_test';

runTest().then(() => console.log('Smoke tests succeed!'));
3 changes: 2 additions & 1 deletion packages/@tests/smoke/web-cra-ts/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<script src='http://localhost:8766/js-client.min.js' async></script>
<!-- Ideally we want to use 'async' here. Currently, it's not supported. -->
<script src="js-client.min.js"></script>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand Down
14 changes: 9 additions & 5 deletions packages/@tests/smoke/web-cra-ts/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ import puppeteer from 'puppeteer';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

import { startCdn, startContentServer, stopServer } from '@test/test-utils';
import { CDN_PUBLIC_PATH, startContentServer, stopServer } from '@test/test-utils';
import { access, symlink } from 'fs/promises';

const port = 3001;
const uri = `http://localhost:${port}/`;
const __dirname = dirname(fileURLToPath(import.meta.url));
const publicPath = join(__dirname, '../build/');

const test = async () => {
const cdn = await startCdn(8766);
const localServer = await startContentServer(port, publicPath);
try {
await access(join(publicPath, 'source'))
} catch {
await symlink(CDN_PUBLIC_PATH, join(publicPath, 'source'));
}

console.log('starting puppeteer...');
const browser = await puppeteer.launch();
const page = await browser.newPage();
const browser = await puppeteer.launch({ headless: false });
const page = (await browser.pages())[0];

// uncomment to debug what's happening inside the browser
// page.on('console', (msg) => console.log('// from console: ', msg.text()));
Expand All @@ -34,7 +39,6 @@ const test = async () => {
console.log('raw result: ', content);

await browser.close();
await stopServer(cdn);
await stopServer(localServer);

if (!content) {
Expand Down
4 changes: 2 additions & 2 deletions packages/@tests/smoke/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client.web.standalone": "workspace:^",
"@test/test-utils": "workspace:^"
"@fluencelabs/js-client": "workspace:^",
"@test/test-utils": "workspace:../../test-utils"
},
"devDependencies": {}
}
4 changes: 2 additions & 2 deletions packages/@tests/smoke/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ <h1>Open console f12</h1>

<div id="res-placeholder"></div>

<script src='http://localhost:8765/js-client.min.js'></script>
<script src="./index.js"></script>
<script src="js-client.min.js"></script>
<script src="index.js"></script>
</main>
</body>

Expand Down
4 changes: 2 additions & 2 deletions packages/@tests/smoke/web/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const getRelayTime = () => {

const main = async () => {
console.log('starting fluence...');
await fluence.defaultClient.connect(relay);
fluence.defaultClient = await fluence.clientFactory(relay);
console.log('started fluence');

console.log('getting relay time...');
Expand All @@ -104,7 +104,7 @@ btn.addEventListener('click', () => {
main().then((res) => {
const inner = document.createElement('div');
inner.id = 'res';
inner.innerText = 'res';
inner.innerText = res;
document.getElementById('res-placeholder').appendChild(inner);
});
});
12 changes: 8 additions & 4 deletions packages/@tests/smoke/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ import puppeteer from 'puppeteer';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

import { startCdn, startContentServer, stopServer } from '@test/test-utils';
import { CDN_PUBLIC_PATH, startCdn, startContentServer, stopServer } from '@test/test-utils';
import { symlink, access } from 'fs/promises';

const port = 3000;
const uri = `http://localhost:${port}/`;
const __dirname = dirname(fileURLToPath(import.meta.url));
const publicPath = join(__dirname, '../public/');

const test = async () => {
const cdn = await startCdn(8765);
const localServer = await startContentServer(port, publicPath);
try {
await access(join(publicPath, 'source'))
} catch {
await symlink(CDN_PUBLIC_PATH, join(publicPath, 'source'));
}

console.log('starting puppeteer...');
const browser = await puppeteer.launch();
const page = await browser.newPage();
const page = (await browser.pages())[0];

// uncomment to debug what's happening inside the browser
// page.on('console', (msg) => console.log('// from console: ', msg.text()));
Expand All @@ -34,7 +39,6 @@ const test = async () => {
console.log('raw result: ', content);

await browser.close();
await stopServer(cdn);
await stopServer(localServer);

if (!content) {
Expand Down
2 changes: 0 additions & 2 deletions packages/@tests/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client.api": "workspace:^",
"@fluencelabs/js-client.node": "workspace:^",
"serve-handler": "6.1.5"
},
"devDependencies": {
Expand Down
13 changes: 12 additions & 1 deletion packages/@tests/test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@ import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

const CDN_PUBLIC_PATH = join(__dirname, '../../../client/js-client.web.standalone/dist/');
export const CDN_PUBLIC_PATH = join(__dirname, '../../../core/js-client/dist/browser');

export const startCdn = (port: number) => startContentServer(port, CDN_PUBLIC_PATH);

export const startContentServer = (port: number, publicDir: string): Promise<Server> => {
const server = createServer((request, response) => {
return handler(request, response, {
public: publicDir,
rewrites: [{
source: '/js-client.min.js',
destination: '/source/index.umd.cjs'
}],
headers: [{
source: '**/*',
headers: [
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
{ key: 'Cross-Origin-Embedder-Policy', value: 'require-corp' }
]
}]
});
});

Expand Down
5 changes: 5 additions & 0 deletions packages/client/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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

## Notes

This package just reexports everything from main library for backward compatibility
`export * from '@fluencelabs/js-client';`

## 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).
Expand Down
11 changes: 6 additions & 5 deletions packages/client/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/interfaces": "0.8.1"
},
"devDependencies": {
"@fluencelabs/avm": "0.43.1",
"@fluencelabs/interfaces": "workspace:*",
"@fluencelabs/marine-js": "0.7.2",
"microbundle": "0.15.1",
"dts-bundle-generator": "7.2.0"
"dts-bundle-generator": "7.2.0",
"microbundle": "0.15.1"
},
"dependencies": {
"@fluencelabs/js-client": "0.0.10"
}
}
117 changes: 1 addition & 116 deletions packages/client/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,120 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getFluenceInterface, getFluenceInterfaceFromGlobalThis } from './util.js';
import {
IFluenceClient,
ClientConfig,
RelayOptions,
ConnectionState,
CallAquaFunctionType,
RegisterServiceType,
} from '@fluencelabs/interfaces';
export type { IFluenceClient, ClientConfig, CallParams } from '@fluencelabs/interfaces';

export {
ArrayType,
ArrowType,
ArrowWithCallbacks,
ArrowWithoutCallbacks,
BottomType,
FunctionCallConstants,
FunctionCallDef,
LabeledProductType,
NilType,
NonArrowType,
OptionType,
ProductType,
ScalarNames,
ScalarType,
ServiceDef,
StructType,
TopType,
UnlabeledProductType,
CallAquaFunctionType,
CallAquaFunctionArgs,
PassedArgs,
FnConfig,
RegisterServiceType,
RegisterServiceArgs,
} from '@fluencelabs/interfaces';

export { v5_callFunction, v5_registerService } from './compilerSupport/implementation.js';

/**
* Public interface to Fluence Network
*/
export const Fluence = {
/**
* Connect to the Fluence network
* @param relay - relay node to connect to
* @param config - client configuration
*/
connect: async (relay: RelayOptions, config?: ClientConfig): Promise<void> => {
const fluence = await getFluenceInterface();
const client = await fluence.clientFactory(relay, config);
fluence.defaultClient = client;
},

/**
* Disconnect from the Fluence network
*/
disconnect: async (): Promise<void> => {
const fluence = await getFluenceInterface();
await fluence.defaultClient?.disconnect();
fluence.defaultClient = undefined;
},

/**
* Handle connection state changes. Immediately returns the current connection state
*/
onConnectionStateChange(handler: (state: ConnectionState) => void): ConnectionState {
const optimisticResult = getFluenceInterfaceFromGlobalThis();
if (optimisticResult && optimisticResult.defaultClient) {
return optimisticResult.defaultClient.onConnectionStateChange(handler);
}

getFluenceInterface().then((fluence) => {
fluence.defaultClient?.onConnectionStateChange(handler);
});

return 'disconnected';
},

/**
* Low level API. Get the underlying client instance which holds the connection to the network
* @returns IFluenceClient instance
*/
getClient: async (): Promise<IFluenceClient> => {
const fluence = await getFluenceInterface();
if (!fluence.defaultClient) {
throw new Error('Fluence client is not initialized. Call Fluence.connect() first');
}
return fluence.defaultClient;
},
};

/**
* Low level API. Generally you need Fluence.connect() instead.
* @returns IFluenceClient instance
*/
export const createClient = async (relay: RelayOptions, config?: ClientConfig): Promise<IFluenceClient> => {
const fluence = await getFluenceInterface();
return await fluence.clientFactory(relay, config);
};

/**
* Low level API. Generally you should use code generated by the Aqua compiler.
*/
export const callAquaFunction: CallAquaFunctionType = async (args) => {
const fluence = await getFluenceInterface();
return await fluence.callAquaFunction(args);
};

/**
* Low level API. Generally you should use code generated by the Aqua compiler.
*/
export const registerService: RegisterServiceType = async (args) => {
const fluence = await getFluenceInterface();
return await fluence.registerService(args);
};
export * from '@fluencelabs/js-client';
Loading