mirror of https://github.com/boa-dev/boa.git
Browse Source
* Remove references to dev docs and npm dependencies * Remove webpack configpull/3788/head
José Julián Espina
8 months ago
committed by
GitHub
30 changed files with 218 additions and 6054 deletions
@ -1,55 +0,0 @@ |
|||||||
name: Main workflows |
|
||||||
on: |
|
||||||
push: |
|
||||||
branches: |
|
||||||
- main |
|
||||||
|
|
||||||
jobs: |
|
||||||
benchmark: |
|
||||||
if: ${{ github.actor != 'dependabot[bot]' }} |
|
||||||
name: Upload docs and run benchmarks |
|
||||||
runs-on: ubuntu-latest |
|
||||||
timeout-minutes: 120 |
|
||||||
steps: |
|
||||||
- uses: actions/checkout@v4 |
|
||||||
- uses: actions-rs/toolchain@v1.0.7 |
|
||||||
with: |
|
||||||
toolchain: stable |
|
||||||
override: true |
|
||||||
profile: minimal |
|
||||||
- name: Cache cargo |
|
||||||
uses: actions/cache@v4 |
|
||||||
with: |
|
||||||
path: | |
|
||||||
target |
|
||||||
!target/doc_upload |
|
||||||
~/.cargo/git |
|
||||||
~/.cargo/registry |
|
||||||
key: ${{ runner.os }}-cargo-doc-bench-${{ hashFiles('**/Cargo.lock') }} |
|
||||||
- name: Generate documentation |
|
||||||
uses: actions-rs/cargo@v1 |
|
||||||
with: |
|
||||||
command: doc |
|
||||||
args: -v --document-private-items --all-features --workspace --no-deps --exclude boa_examples |
|
||||||
- run: echo "<meta http-equiv=refresh content=0;url=boa_engine/index.html>" > target/doc/index.html |
|
||||||
- run: | |
|
||||||
if [ -d target/doc_upload ]; then rm -rf target/doc_upload; fi |
|
||||||
mkdir target/doc_upload && mv target/doc target/doc_upload/doc |
|
||||||
- name: Upload documentation |
|
||||||
uses: crazy-max/ghaction-github-pages@v4.0.0 |
|
||||||
with: |
|
||||||
target_branch: gh-pages |
|
||||||
keep_history: true |
|
||||||
build_dir: target/doc_upload |
|
||||||
env: |
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
||||||
- name: Run benchmark |
|
||||||
run: cargo bench -p boa_engine -- --output-format bencher | tee output.txt |
|
||||||
- name: Store benchmark result |
|
||||||
uses: benchmark-action/github-action-benchmark@v1.19.3 |
|
||||||
with: |
|
||||||
name: Boa Benchmarks |
|
||||||
tool: "cargo" |
|
||||||
output-file-path: output.txt |
|
||||||
auto-push: true |
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }} |
|
@ -1,25 +0,0 @@ |
|||||||
import { expect, test } from "@playwright/test"; |
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => { |
|
||||||
page.on("console", (msg) => { |
|
||||||
let msgText = ""; |
|
||||||
for (let i = 0; i < msg.args().length; ++i) { |
|
||||||
msgText += `${msg.args()[i]}`; |
|
||||||
} |
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(msgText); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
test("boa demo", async ({ page }) => { |
|
||||||
await page.goto("/", { |
|
||||||
// wait until all content is loaded
|
|
||||||
waitUntil: "networkidle", |
|
||||||
}); |
|
||||||
// wait for the code evaluate
|
|
||||||
await page.waitForTimeout(2000); |
|
||||||
const output = page.getByTestId("output"); |
|
||||||
const result = await output.innerHTML(); |
|
||||||
console.log("eval result: ", result); |
|
||||||
await expect(result.match("Hello, World")?.length).toEqual(1); |
|
||||||
}); |
|
@ -1,71 +0,0 @@ |
|||||||
import { defineConfig, devices } from "@playwright/test"; |
|
||||||
|
|
||||||
/** |
|
||||||
* Read environment variables from file. |
|
||||||
* https://github.com/motdotla/dotenv
|
|
||||||
*/ |
|
||||||
// require('dotenv').config();
|
|
||||||
|
|
||||||
/** |
|
||||||
* See https://playwright.dev/docs/test-configuration.
|
|
||||||
*/ |
|
||||||
export default defineConfig({ |
|
||||||
testDir: "./", |
|
||||||
/* Maximum time one test can run for. */ |
|
||||||
timeout: 300 * 1000, |
|
||||||
expect: { |
|
||||||
/** |
|
||||||
* Maximum time expect() should wait for the condition to be met. |
|
||||||
* For example in `await expect(locator).toHaveText();` |
|
||||||
*/ |
|
||||||
timeout: 5000, |
|
||||||
}, |
|
||||||
/* Run tests in files in parallel */ |
|
||||||
fullyParallel: true, |
|
||||||
/* Fail the build on CI if you accidentally left test.only in the source code. */ |
|
||||||
forbidOnly: !!process.env.CI, |
|
||||||
/* Retry on CI only */ |
|
||||||
retries: process.env.CI ? 2 : 0, |
|
||||||
/* Opt out of parallel tests on CI. */ |
|
||||||
workers: process.env.CI ? 1 : undefined, |
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
|
||||||
reporter: "html", |
|
||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
|
||||||
use: { |
|
||||||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ |
|
||||||
actionTimeout: 0, |
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */ |
|
||||||
// baseURL: 'http://localhost:3000',
|
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
|
||||||
trace: "on-first-retry", |
|
||||||
baseURL: "http://localhost:8081/", |
|
||||||
}, |
|
||||||
webServer: { |
|
||||||
command: "node ./server.mjs", |
|
||||||
cwd: "./", |
|
||||||
url: "http://localhost:8081", |
|
||||||
timeout: 60 * 1000, |
|
||||||
reuseExistingServer: !process.env.CI, |
|
||||||
stdout: "pipe", |
|
||||||
stderr: "pipe", |
|
||||||
}, |
|
||||||
|
|
||||||
/* Configure projects for major browsers */ |
|
||||||
projects: [ |
|
||||||
{ |
|
||||||
name: "chromium", |
|
||||||
use: { ...devices["Desktop Chrome"] }, |
|
||||||
}, |
|
||||||
|
|
||||||
{ |
|
||||||
name: "firefox", |
|
||||||
use: { ...devices["Desktop Firefox"] }, |
|
||||||
}, |
|
||||||
|
|
||||||
{ |
|
||||||
name: "webkit", |
|
||||||
use: { ...devices["Desktop Safari"] }, |
|
||||||
}, |
|
||||||
], |
|
||||||
}); |
|
@ -1,23 +0,0 @@ |
|||||||
import { createServer } from "http"; |
|
||||||
import { readFile, readFileSync } from "fs"; |
|
||||||
import { dirname, join } from "path"; |
|
||||||
import { fileURLToPath, parse } from "url"; |
|
||||||
import { lookup } from "mime-types"; |
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url); |
|
||||||
|
|
||||||
createServer((req, res) => { |
|
||||||
const __dirname = dirname(__filename); |
|
||||||
const path = join(__dirname, "../../../dist", parse(req.url, true).path); |
|
||||||
readFile(path, (err, data) => { |
|
||||||
if (err) { |
|
||||||
res.writeHead(200, { "Content-Type": "text/html" }); |
|
||||||
res.end(readFileSync(join(__dirname, "../../../dist/index.html"))); |
|
||||||
} else { |
|
||||||
res.writeHead(200, { "Content-Type": lookup(path) }); |
|
||||||
res.end(data); |
|
||||||
} |
|
||||||
}); |
|
||||||
}).listen(8081, () => { |
|
||||||
console.log("Server running at http://localhost:8081/"); |
|
||||||
}); |
|
@ -0,0 +1,19 @@ |
|||||||
|
#![allow(unused_crate_dependencies)] |
||||||
|
use wasm_bindgen_test::*; |
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser); |
||||||
|
|
||||||
|
#[wasm_bindgen_test] |
||||||
|
fn simple() { |
||||||
|
const CODE: &str = r" |
||||||
|
function greet(targetName) { |
||||||
|
return 'Hello, ' + targetName + '!'; |
||||||
|
} |
||||||
|
|
||||||
|
greet('World') |
||||||
|
"; |
||||||
|
|
||||||
|
let result = boa_wasm::evaluate(CODE).unwrap(); |
||||||
|
|
||||||
|
assert_eq!(result, "\"Hello, World!\""); |
||||||
|
} |
@ -1,77 +0,0 @@ |
|||||||
<!doctype html> |
|
||||||
<html> |
|
||||||
<head> |
|
||||||
<meta charset="utf-8" /> |
|
||||||
<title>Boa Playground</title> |
|
||||||
<link href="assets/bootstrap.min.css" rel="stylesheet" /> |
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
|
||||||
</head> |
|
||||||
<style> |
|
||||||
header { |
|
||||||
display: flex; |
|
||||||
align-items: center; |
|
||||||
} |
|
||||||
|
|
||||||
.demo__img { |
|
||||||
width: 170px; |
|
||||||
display: block; |
|
||||||
margin-bottom: 16px; |
|
||||||
margin-right: 3rem; |
|
||||||
} |
|
||||||
|
|
||||||
.textbox { |
|
||||||
height: 250px; |
|
||||||
border: 1px solid #8db5e4; |
|
||||||
margin-bottom: 16px; |
|
||||||
flex: 2; |
|
||||||
margin-right: 16px; |
|
||||||
} |
|
||||||
|
|
||||||
.container { |
|
||||||
margin: 0 auto; |
|
||||||
} |
|
||||||
|
|
||||||
.demo__repl { |
|
||||||
display: flex; |
|
||||||
font-family: monospace; |
|
||||||
} |
|
||||||
|
|
||||||
.output { |
|
||||||
flex: 1; |
|
||||||
border: 1px solid black; |
|
||||||
padding: 8px; |
|
||||||
font-size: 2rem; |
|
||||||
} |
|
||||||
|
|
||||||
@media (min-width: 320px) and (max-width: 1024px) { |
|
||||||
.demo__img { |
|
||||||
max-width: 100%; |
|
||||||
} |
|
||||||
|
|
||||||
.demo__repl { |
|
||||||
flex-direction: column; |
|
||||||
} |
|
||||||
|
|
||||||
.textbox { |
|
||||||
min-height: 279px; |
|
||||||
} |
|
||||||
|
|
||||||
.output { |
|
||||||
min-height: 100px; |
|
||||||
} |
|
||||||
} |
|
||||||
</style> |
|
||||||
|
|
||||||
<body> |
|
||||||
<div class="container"> |
|
||||||
<header> |
|
||||||
<img class="demo__img" src="./assets/logo.svg" /> |
|
||||||
<h1>Boa Playground</h1> |
|
||||||
</header> |
|
||||||
<div class="demo__repl"> |
|
||||||
<div class="textbox"></div> |
|
||||||
<p data-testid="output" class="output"></p> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</body> |
|
||||||
</html> |
|
@ -1,46 +0,0 @@ |
|||||||
import { evaluate } from "./ffi/wasm/pkg"; |
|
||||||
|
|
||||||
import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; |
|
||||||
|
|
||||||
const initialCode = `\
|
|
||||||
function greet(targetName) { |
|
||||||
return 'Hello, ' + targetName + '!'; |
|
||||||
} |
|
||||||
|
|
||||||
greet('World') |
|
||||||
`;
|
|
||||||
|
|
||||||
const editor = monaco.editor.create( |
|
||||||
document.getElementsByClassName("textbox")[0], |
|
||||||
{ |
|
||||||
value: initialCode, |
|
||||||
language: "javascript", |
|
||||||
theme: "vs", |
|
||||||
minimap: { |
|
||||||
enabled: false, |
|
||||||
}, |
|
||||||
}, |
|
||||||
); |
|
||||||
|
|
||||||
// Fix size of Monaco Editor when window resize
|
|
||||||
window.addEventListener("resize", () => { |
|
||||||
editor.layout(); |
|
||||||
}); |
|
||||||
|
|
||||||
window.evaluate = evaluate; |
|
||||||
|
|
||||||
editor.getModel().onDidChangeContent(inputHandler); |
|
||||||
inputHandler(); // Evaluate initial code
|
|
||||||
|
|
||||||
function inputHandler(evt) { |
|
||||||
const text = editor.getValue(); |
|
||||||
let p = document.querySelector("p.output"); |
|
||||||
|
|
||||||
try { |
|
||||||
let result = window.evaluate(text); |
|
||||||
p.textContent = `> ${result}`; |
|
||||||
} catch (err) { |
|
||||||
console.error(err); |
|
||||||
p.innerHTML = `<span style="color:red">${err}</span>`; |
|
||||||
} |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
{ |
|
||||||
"scripts": { |
|
||||||
"build": "webpack", |
|
||||||
"serve": "webpack-dev-server", |
|
||||||
"e2e": "playwright test -c ./ffi/wasm/e2e_test/playwright.config.ts", |
|
||||||
"build:prod": "webpack --mode=production" |
|
||||||
}, |
|
||||||
"devDependencies": { |
|
||||||
"@playwright/test": "^1.42.1", |
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.7.0", |
|
||||||
"bootstrap": "^5.3.3", |
|
||||||
"clean-webpack-plugin": "^4.0.0", |
|
||||||
"copy-webpack-plugin": "^12.0.2", |
|
||||||
"css-loader": "^6.10.0", |
|
||||||
"file-loader": "^6.2.0", |
|
||||||
"html-webpack-plugin": "^5.6.0", |
|
||||||
"monaco-editor-webpack-plugin": "^7.1.0", |
|
||||||
"prettier": "^3.2.5", |
|
||||||
"style-loader": "^3.3.4", |
|
||||||
"terser-webpack-plugin": "^5.3.10", |
|
||||||
"webpack": "^5.91.0", |
|
||||||
"webpack-cli": "^5.1.4", |
|
||||||
"webpack-dev-server": "^5.0.4" |
|
||||||
}, |
|
||||||
"dependencies": { |
|
||||||
"mime-types": "^2.1.35", |
|
||||||
"monaco-editor": "^0.47.0" |
|
||||||
} |
|
||||||
} |
|
@ -1,89 +0,0 @@ |
|||||||
const path = require("path"); |
|
||||||
const fs = require("fs"); |
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin"); |
|
||||||
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); |
|
||||||
const CopyWebpackPlugin = require("copy-webpack-plugin"); |
|
||||||
const webpack = require("webpack"); |
|
||||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); |
|
||||||
const TerserPlugin = require("terser-webpack-plugin"); |
|
||||||
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin"); |
|
||||||
|
|
||||||
const outdir = path.resolve(__dirname, "./dist"); |
|
||||||
|
|
||||||
if (fs.existsSync(outdir)) { |
|
||||||
fs.rmSync(outdir, { recursive: true }); |
|
||||||
} |
|
||||||
|
|
||||||
module.exports = { |
|
||||||
experiments: { |
|
||||||
asyncWebAssembly: true, |
|
||||||
}, |
|
||||||
entry: { |
|
||||||
app: "./index.js", |
|
||||||
}, |
|
||||||
output: { |
|
||||||
path: outdir, |
|
||||||
filename: "[name].js", |
|
||||||
}, |
|
||||||
plugins: [ |
|
||||||
new MonacoWebpackPlugin({ |
|
||||||
languages: ["javascript", "typescript"], |
|
||||||
features: [ |
|
||||||
"browser", |
|
||||||
"find", |
|
||||||
"inlayHints", |
|
||||||
"documentSymbols", |
|
||||||
"inlineCompletions", |
|
||||||
"parameterHints", |
|
||||||
"snippet", |
|
||||||
"suggest", |
|
||||||
"wordHighlighter", |
|
||||||
"codelens", |
|
||||||
"hover", |
|
||||||
"bracketMatching", |
|
||||||
], |
|
||||||
}), |
|
||||||
new CleanWebpackPlugin(), |
|
||||||
new HtmlWebpackPlugin({ template: "index.html" }), |
|
||||||
// WasmPackPlugin doesn't work in CI environment
|
|
||||||
// thanks to https://github.com/wasm-tool/wasm-pack-plugin/issues/90
|
|
||||||
...(!process.env.CI |
|
||||||
? [ |
|
||||||
new WasmPackPlugin({ |
|
||||||
crateDirectory: path.resolve(__dirname, "./ffi/wasm/"), |
|
||||||
outDir: path.resolve(__dirname, "./ffi/wasm/pkg/"), |
|
||||||
forceMode: "production", |
|
||||||
}), |
|
||||||
] |
|
||||||
: []), |
|
||||||
new CopyWebpackPlugin({ |
|
||||||
patterns: [ |
|
||||||
{ |
|
||||||
from: "./assets/*", |
|
||||||
to: ".", |
|
||||||
}, |
|
||||||
{ |
|
||||||
from: "./node_modules/bootstrap/dist/css/bootstrap.min.css", |
|
||||||
to: "./assets", |
|
||||||
}, |
|
||||||
], |
|
||||||
}), |
|
||||||
], |
|
||||||
module: { |
|
||||||
rules: [ |
|
||||||
{ |
|
||||||
test: /\.css$/, |
|
||||||
use: ["style-loader", "css-loader"], |
|
||||||
}, |
|
||||||
{ |
|
||||||
test: /\.ttf$/, |
|
||||||
use: ["file-loader"], |
|
||||||
}, |
|
||||||
], |
|
||||||
}, |
|
||||||
optimization: { |
|
||||||
minimize: true, |
|
||||||
minimizer: [new TerserPlugin()], |
|
||||||
}, |
|
||||||
mode: "development", |
|
||||||
}; |
|
Loading…
Reference in new issue