Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

docs: update docs for GH Pages #679

Merged
merged 3 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
173,178 changes: 173,178 additions & 0 deletions docs/assets/js/ganache/ganache.min.js

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions docs/assets/js/ganache/ganache.min.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*!
* prr
* (c) 2013 Rod Vagg <[email protected]>
* https://github.com/rvagg/prr
* License: MIT
*/

/*!
* @ganache/ethereum
*
* @copyright 2019-2020 Truffle Blockchain Group
* @author David Murdoch <[email protected]> (https://davidmurdoch.com)
* @license MIT
*/

/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
* @license MIT
*/

/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/

/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1 change: 1 addition & 0 deletions docs/assets/js/ganache/ganache.min.js.map

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions docs/assets/js/inject-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// remove the typedoc theme's keydown handler so we can type in our monaco-editors
$("body").off("keydown");

require.config({
paths: {
vs: "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.21.2/min/vs"
}
});

require([
"../../assets/js/ganache/ganache.min.js",
"vs/editor/editor.main"
], function (Ganache) {
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;

document.querySelectorAll(".monaco").forEach(codeNode => {
async function run(e) {
e.preventDefault();
e.stopPropagation();

const code = editor.getValue();

consoleDiv.innerHTML = "";

const k = {
log: (...args) => {
// very naive console implementation
const line = document.createElement("div");
line.className = "mtk1";
line.innerText = args.map(a => "" + a).join(" ");
consoleDiv.appendChild(line);
}
};
const ganache = {
provider: (options = {}) => {
delete options.logger;
if (!options.logging) {
options.logging = {};
}
options.logging.logger = k;
return Ganache.provider(options);
}
};
const codeText = code.trim();
const assert = a => {
if (a) return true;
throw new Error("not equal");
};
assert.strictEqual = (a, b) => {
if (a === b) return true;
throw new Error("not strict equal");
};
const fn = new AsyncFunction(
"ganache",
"assert",
"console",
`with ({provider: ganache.provider()}) {
try {
return await (async () => {
"use strict";
${codeText}
;
})();
} catch (e) {
console.log(e);
} finally {
try {
// await provider.disconnect();
// delete all tmp ganache-core databases
await indexedDB.databases().then(dbs => {
return Promise.all(dbs.map(db => {
if (db.name.startsWith("/tmp/ganache-core_")) {
// return indexedDB.deleteDatabase(db.name);
}
}));
});
} catch {}
}
}`
);
await fn(ganache, assert, k);
}

const consoleDiv = document.createElement("div");
consoleDiv.className = "monaco-editor-background";
consoleDiv.style.borderTop = "solid 1px #393939";
consoleDiv.style.fontFamily =
'"Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"';
consoleDiv.style.fontSize = "14px";
consoleDiv.style.fontFeatureSettings = '"liga" 0, "calt" 0';
consoleDiv.style.lineHeight = "19px";
consoleDiv.style.letterSpacing = "0px";
consoleDiv.style.height = "200px";
consoleDiv.style.position = "relative";
consoleDiv.style.overflow = "auto";
consoleDiv.style.padding = ".3em 26px";
codeNode.parentNode.insertBefore(consoleDiv, codeNode.nextSibling);

const container = document.createElement("div");
codeNode.parentNode.insertBefore(container, codeNode.nextSibling);
codeNode.style.display = "none";
container.style.height = "600px";

const editor = monaco.editor.create(container, {
value: codeNode.innerText.trim(),
language: "javascript", // TODO, get language from element
// lineNumbers: "off",
minimap: { enabled: false },
scrollBeyondLastLine: false,
theme: "vs" // use light theme until
});

const runButton = document.createElement("button");
runButton.innerText = "Run";
runButton.addEventListener("click", run);
codeNode.parentNode.insertBefore(runButton, codeNode.nextSibling);
});
});
Loading