-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from jawahar273/web-asm
Demo with web assembly
- Loading branch information
Showing
32 changed files
with
978 additions
and
1,408 deletions.
There are no files selected for viewing
File renamed without changes.
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,74 @@ | ||
name: deploy to gh page | ||
on: | ||
push: | ||
branches: | ||
- web-asm | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
defaults: | ||
run: | ||
working-directory: ./server/web | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
# - name: Change folder location | ||
# id: web-folder | ||
# run: | | ||
# echo "path=./server/web" >> $GITHUB_OUTPUT | ||
# exit 0 | ||
- name: Setup Node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
cache-dependency-path: ./server/web | ||
- name: Cache dependencies ⚡ | ||
id: cache_dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ hashFiles('package-lock.json') }} | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v4 | ||
with: | ||
# Automatically inject basePath in your Next.js configuration file and disable | ||
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). | ||
# | ||
# You may remove this line if you want to manage the configuration yourself. | ||
static_site_generator: next | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Update web assembly | ||
run: cd ../.. && make ci-install && make js-asm | ||
- name: Build with Next.js | ||
run: npx next build | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: "./server/web/out" | ||
|
||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./server/web | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
workspace = { members = ["asm"] } | ||
[package] | ||
name = "timex" | ||
version = "0.3.2-beta.1" | ||
edition = "2021" | ||
resolver = "2" | ||
authors = ["Jawahar S <[email protected]>"] | ||
license = "MIT" | ||
license = "mit" | ||
description = "Generate date times as event similar to Microsoft calender or Google calender based on the given parameters." | ||
readme = "README.md" | ||
homepage = "https://github.com/jawahar273/timex" | ||
|
@@ -25,8 +26,6 @@ env_logger = "0.10.1" | |
log = "0.4.20" | ||
serde = { version = "1.0.193", features = ["derive"] } | ||
thiserror = "1.0.50" | ||
wasm-bindgen = "0.2.89" | ||
serde-wasm-bindgen = "0.6.3" | ||
serde_json = "1.0.108" | ||
|
||
# reduce web assembly size https://rustwasm.github.io/twiggy/ | ||
|
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
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,20 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
# Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
debug/ | ||
wasm32-unknown-unknown | ||
wasm32-wasi | ||
release/ | ||
pkg | ||
.rust_info.json |
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,15 @@ | ||
[package] | ||
name = "asm" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
crate-type = ["rlib", "cdylib"] | ||
|
||
[dependencies] | ||
chrono = "0.4.31" | ||
wasm-bindgen = "0.2.90" | ||
timex = { path = "../"} | ||
serde-wasm-bindgen = "0.6.3" |
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,62 @@ | ||
use chrono::{DateTime, Utc}; | ||
use timex::{ | ||
model::ScheduleDetails, | ||
schedule_date_times, | ||
}; | ||
use wasm_bindgen::{prelude::wasm_bindgen, *}; | ||
|
||
|
||
#[wasm_bindgen] | ||
pub fn show_detail_in_display(_detail: JsValue) -> std::result::Result<JsValue, JsValue> { | ||
let detail: ScheduleDetails = match serde_wasm_bindgen::from_value(_detail) { | ||
Err(e) => return Err(e.to_string().into()), | ||
std::result::Result::Ok(v) => v, | ||
}; | ||
|
||
return std::result::Result::Ok(format!("{}", detail).into()); | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn find_schedule_date_time( | ||
_detail: JsValue, | ||
previous_scheduled_date: String, | ||
start_range_date: String, | ||
end_range_date: String, | ||
) -> std::result::Result<Vec<JsValue>, JsValue> { | ||
let mut _previous_scheduled_date: DateTime<Utc>; | ||
let detail: ScheduleDetails = serde_wasm_bindgen::from_value(_detail)?; | ||
|
||
match DateTime::parse_from_rfc3339(&previous_scheduled_date) { | ||
std::result::Result::Ok(v) => _previous_scheduled_date = v.with_timezone(&Utc), | ||
Err(e) => return Err(e.to_string().into()), | ||
}; | ||
|
||
let mut _start_range_date: DateTime<Utc>; | ||
|
||
match DateTime::parse_from_rfc3339(&start_range_date) { | ||
std::result::Result::Ok(v) => _start_range_date = v.with_timezone(&Utc), | ||
Err(e) => return Err(e.to_string().into()), | ||
}; | ||
|
||
let mut _end_range_date: DateTime<Utc>; | ||
|
||
match DateTime::parse_from_rfc3339(&end_range_date) { | ||
std::result::Result::Ok(v) => _end_range_date = v.with_timezone(&Utc), | ||
Err(e) => return Err(e.to_string().into()), | ||
}; | ||
|
||
let t = schedule_date_times( | ||
&detail, | ||
_previous_scheduled_date, | ||
_start_range_date, | ||
_end_range_date, | ||
); | ||
match t { | ||
std::result::Result::Ok(v) => std::result::Result::Ok( | ||
v.into_iter() | ||
.map(|x| x.to_rfc3339().into()) | ||
.collect::<Vec<_>>(), | ||
), | ||
Err(e) => Err(e.to_string().into()), | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
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
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 @@ | ||
**/src/asm/* |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.