Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: svelte #31

Merged
merged 34 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5cbda2d
feat: svelte
storopoli Feb 28, 2024
dc2d5a7
feat: add flake
storopoli Feb 28, 2024
3835255
feat: basic template
storopoli Feb 28, 2024
36dc3d0
ci: github pages
storopoli Feb 28, 2024
5ad3ccd
ci: add just
storopoli Feb 28, 2024
a18e325
feat: svelte + wasm works
storopoli Feb 29, 2024
072316f
feat(svelte): update to svelte 5
storopoli Feb 29, 2024
4ecf2ba
feat(svelte): footer
storopoli Feb 29, 2024
cf9ee1f
chore: remove scripts/
storopoli Feb 29, 2024
61c6c5e
feat(svelte): Output template done
storopoli Feb 29, 2024
816b843
feat(svelte): Output template reactivity
storopoli Feb 29, 2024
32d60f2
feat(svelte): input logic figured out
storopoli Feb 29, 2024
9bbed82
feat(vscode): extensions.json
storopoli Feb 29, 2024
1bb41bb
feat(app): package info
storopoli Mar 1, 2024
241beed
ci: fix setup-node
storopoli Mar 1, 2024
d879f2c
feat(app): ttest templates done
storopoli Mar 2, 2024
b1928f8
refactor: props in App.svelte
storopoli Mar 2, 2024
2c5db2f
feat(app): ftest templates done
storopoli Mar 2, 2024
2968da9
feat(app): chitest templates done
storopoli Mar 2, 2024
1b4895a
feat(app): calculate button works
storopoli Mar 2, 2024
cf97a53
chore: remove old frontend files
storopoli Mar 2, 2024
e1b1e63
feat(app): reset button works
storopoli Mar 3, 2024
8cf5fe5
feat(app): jsdocs and animations for calculate and reset buttons
storopoli Mar 3, 2024
ab8e73f
refactor: reset to handleReset
storopoli Mar 3, 2024
77c1b85
feat(app): handle -111 error return value
storopoli Mar 3, 2024
284e55e
fix: bug in IncreaseMultiple Regression
storopoli Mar 3, 2024
a9a0979
fix(app): bug in reactivity not updating in input component
storopoli Mar 3, 2024
4ac8e80
feat(app): fix error message
storopoli Mar 3, 2024
66dcbe5
feat(app): sanitize valid inputs
storopoli Mar 3, 2024
397205b
feat(app): warning message for webassembly
storopoli Mar 3, 2024
b9e7f90
fix(readme): final readme touches
storopoli Mar 3, 2024
d47d85b
feat(app): update to svelte5 prerelease 70
storopoli Mar 3, 2024
e07baf8
feat: final touches
storopoli Mar 3, 2024
5c072c0
feat: it works
storopoli Mar 3, 2024
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
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Debian",
"image": "mcr.microsoft.com/devcontainers/base:debian",

"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/guiyomh/features/just:0": {}
},

"forwardPorts": [3000],
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot",
"GitHub.copilot-chat",
"github.vscode-github-actions",

"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates",
"vadimcn.vscode-lldb",

"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"svelte.svelte-vscode"
]
}
},
"remoteUser": "vscode",
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y emscripten && rustup target add wasm32-unknown-emscripten"
}
38 changes: 27 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Add release date to index.html
run: |
VERSION="$(date +'%Y-%m-%d %H:%M')"
sed --in-place "s/<VERSION>/$VERSION/g" index.html
shell: bash

- name: Setup emscripten SDK
uses: mymindstorm/setup-emsdk@v14
with:
Expand All @@ -29,6 +23,11 @@ jobs:
- name: Verify emscripten
run: emcc -v

- name: Setup just
uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Stable Rust with emscripten target
run: rustup target add wasm32-unknown-emscripten

Expand All @@ -41,16 +40,33 @@ jobs:
- name: Cargo fmt
run: cargo fmt --all --check

- name: Cargo test
run: cargo test
- name: Test
run: just test

- name: Build site
run: just b

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: app/package-lock.json

- name: Install dependencies
run: npm ci
working-directory: app

- name: build
run: |
npm run build
working-directory: app

- name: Build site into the public/ dir
run: ./script/build.sh

- uses: actions/upload-pages-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
path: './public'
path: './app/dist'
retention-days: '1'

deploy:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
**/*.pdb

# Static
**/public/
**/public/pa.wasm
**/public/pa.js
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recommendations": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates",
"vadimcn.vscode-lldb",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"svelte.svelte-vscode"
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rust-analyzer.check.command": "clippy",
"rust-analyzer.checkOnSave": true,
"svelte.enable-ts-plugin": true,
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
}
}
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[workspace]
members = [
"dist",
"power"
]
members = ["dist", "power"]
resolver = "2"

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

[workspace.package]
authors = [
"Rik Huijzer <[email protected]>",
"Jose Storopoli <[email protected]>",
]
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ Statistical power analyses in the browser via R's nmath library and WebAssembly.

## License

The favicon is obtained from Flaticon (https://www.flaticon.com/free-icon/statistics_4064965).
The favicon is obtained from [Flaticon](https://www.flaticon.com/free-icon/statistics_4064965).

## Developer notes

Going via emscripten because we link a C library.

A big thanks to https://github.com/rustwasm/team/issues/291#issuecomment-644946504 for writing down how to build a C library to WebAssembly via Rust.
A big thanks to [`rustwasm/team`](https://github.com/rustwasm/team/issues/291#issuecomment-644946504)
for writing down how to build a C library to WebAssembly via Rust.

For development, checkout the scripts in the [`scripts` folder](https://github.com/poweranalyses-org/poweranalyses/tree/main/script).
For development, checkout the scripts in the [`justfile`](https://github.com/poweranalyses-org/poweranalyses/tree/main/justfile).
If you are lazy just run `just`.
24 changes: 24 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 6 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Svelte + Vite

This is the App's reactive frontend.

The app is built with [Svelte](https://svelte.dev) and Vite.
We are using Svelte 5 for reactivity and leaning heavily in the new Runes API.
25 changes: 25 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">

<head>
<title>PowerAnalyses.org</title>
<link rel="icon" href="./src/assets/favicon.png" />
<link rel="stylesheet" href="./src/assets/style.css" />
<script src="./pa.js"></script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>

<body>
<noscript>
<br />
<center>
This site only works with WebAssembly. Enable WebAssembly in your
browser to continue.
</center>
</noscript>
<div id="app"></div>
<script type="module" src="./src/main.js"></script>
</body>

</html>
44 changes: 44 additions & 0 deletions app/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"compilerOptions": {
"moduleResolution": "bundler",
"target": "ESNext",
"module": "ESNext",
/**
* svelte-preprocess cannot figure out whether you have
* a value or a type, so tell TypeScript to enforce using
* `import type` instead of `import` for Types.
*/
"verbatimModuleSyntax": true,
"isolatedModules": true,
"resolveJsonModule": true,
/**
* To have warnings / errors of the Svelte compiler at the
* correct position, enable source maps by default.
*/
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
/**
* Typecheck JS in `.svelte` and `.js` files by default.
* Disable this if you'd like to use dynamic types.
*/
"checkJs": true,
"plugins": [
{
"name": "typescript-svelte-plugin",
// the following options can be set additionally; they are optional; their default values are listed here
"enabled": true, // enables this plugin
"assumeIsSvelteProject": false // if true, skip detection and always assume it's a Svelte project
}
]
},
/**
* Use global.d.ts instead of compilerOptions.types
* to avoid limiting type declarations.
*/
"include": [
"src/**/*.d.ts",
"src/**/*.js",
"src/**/*.svelte"
]
}
Loading