-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create a ESM build for node It fixes the XMLHttpRequest is not defined error when "import"ing library from node. We now have 2 ESM in the dist, one built for node, one build for the browser. Quick reminder on why there are 4 files: browser: archethic.js browser import: archethic-browser.mjs node import: archethic-node.mjs node require: archethic.cjs * Expose Archethic in the archethic.js Add a small example to demonstrate how to use it * Expose Archethic so we do not have to use .default in browser
- Loading branch information
Showing
11 changed files
with
309 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<!-- This example demonstrates how to use the Archethic JavaScript SDK without any build system --> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Example: AE Browser Connect</title> | ||
<!-- Load the SDK --> | ||
<script src="../../dist/archethic.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1>Connect to the Archethic via the JavaScript SDK</h1> | ||
|
||
<form action="#" onsubmit="return connect(this);"> | ||
<label>Endpoint:<input name="endpoint" value="http://localhost:4000" /></label> | ||
<button type="submit">Connect</button> | ||
<span> | ||
Status: <span id="status"></span> | ||
</span> | ||
</form> | ||
|
||
<script type="text/javascript"> | ||
function displayStatus(status) { | ||
document.getElementById("status").innerText = status | ||
} | ||
|
||
displayStatus("DISCONNECTED") | ||
|
||
function connect(form) { | ||
displayStatus("CONNECTING") | ||
|
||
endpoint = form.querySelector("input[name=endpoint]").value | ||
|
||
var promiseToConnect = new Archethic(endpoint).connect() | ||
|
||
promiseToConnect | ||
.then(() => { | ||
displayStatus("CONNECTED") | ||
}) | ||
.catch((a) => { | ||
displayStatus(`DISCONNECTED (${a.message})`) | ||
}) | ||
|
||
return false | ||
} | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters