fix(js-client): Fix CDN flow and move it in modules [fixes DXJ-527] (#376)

* Use type module in html

* Fix autocommit

* Try fix template

* Try fix template

* Try fix template

* Try fix template

* Try fix template

* Fix test

* Update packages/@tests/smoke/web/public/index.html

Co-authored-by: shamsartem <shamsartem@gmail.com>

* Minify es bundle

* Remove autocommit

* Fix lint

* Remove minimal

* Change nox version

* Change nox version

* Fix CDN

---------

Co-authored-by: shamsartem <shamsartem@gmail.com>
This commit is contained in:
Akim
2023-11-10 21:29:49 +07:00
committed by GitHub
parent 1803d83ce7
commit f5e9923974
11 changed files with 322 additions and 54 deletions

View File

@ -7,8 +7,6 @@
<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" />
<!-- 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

View File

@ -17,7 +17,7 @@ const publicPath = join(__dirname, "../build/");
const test = async () => {
const localServer = await startContentServer(port, publicPath);
await createSymlinkIfNotExists(CDN_PUBLIC_PATH, join(publicPath, "source"));
await createSymlinkIfNotExists(
JS_CLIENT_DEPS_PATH,
join(publicPath, "node_modules"),

View File

@ -16,8 +16,9 @@
<div id="res-placeholder"></div>
<script src="js-client.min.js"></script>
<script src="index.js"></script>
<!-- Importing js-client from local server that is used instead of the CDN -->
<script type="module" src="js-client.min.js"></script>
<script type="module" src="index.js"></script>
</main>
</body>

View File

@ -1,8 +1,8 @@
const fluence = globalThis.fluence;
import { Fluence, callAquaFunction, randomStage } from "./js-client.min.js";
const relay = {
multiaddr:
"/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
"/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
peerId: "12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
};
@ -74,18 +74,19 @@ const getRelayTime = () => {
const config = {};
const args = { relayPeerId: relay.peerId };
return fluence.callAquaFunction({
return callAquaFunction({
args,
def,
script,
config,
peer: fluence.defaultClient,
peer: Fluence.defaultClient,
});
};
const main = async () => {
console.log("starting fluence...");
fluence.defaultClient = await fluence.clientFactory(relay, {
await Fluence.connect(relay, {
CDNUrl: "http://localhost:3000",
});
console.log("started fluence");
@ -95,7 +96,7 @@ const main = async () => {
console.log("got relay time, ", relayTime);
console.log("stopping fluence...");
await fluence.defaultClient.stop();
await Fluence.disconnect();
console.log("stopped fluence...");
return relayTime;