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

Bumped to 0.4.0, updated libs, added version match check #260

Merged
merged 1 commit into from
Nov 8, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
with:
command: test
args: --all-features
- name: Check versions
run: tests/check_versions.sh

fixed-nightly-clippy:
name: Fixed Nightly clippy (wasm32)
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<!-- markdownlint-configure-file { "no-duplicate-heading": { "siblings_only": true } } -->

<!-- markdownlint-disable-next-line first-line-h1 -->
## Unreleased
## 0.4.0 - 2023-11-08

### Added

* `LazyCache::forget`
* Check for vertigo/vertigo-cli major.minor versions mismatch. Error is printed on CLI and JavaScript console.

### Fixed

* `LazyCache::force_update` really forces the update even if value not expired
* `JsJson` and `JsValue`` list size as u32 - fixes large DOM updates

## 0.3.2 - 2023-07-17

Expand Down
1 change: 0 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ script = [

[tasks.lint]
script = "cargo run --bin lint-project"

9 changes: 5 additions & 4 deletions crates/vertigo-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo-cli"
version = "0.3.2"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
description = "Reactive Real-DOM library with SSR for Rust - packaging/serving tool"
categories = ["command-line-utilities", "development-tools", "development-tools::build-utils", "wasm", "web-programming"]
Expand All @@ -20,18 +20,19 @@ path = "src/main.rs"
clap = { version = "4.0", features = ["derive"] }
hex = "0.4"
include_dir = "0.7"
pkg-version = "1"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
sha2 = "0.10"
wasmtime = "6.0"
wasmtime = "14.0"
log = "0.4"
env_logger = "0.10"
tokio = { version = "1.25", features = ["full"] }
tokio-stream = "0.1"
axum = { version = "0.6.12", features = ["macros"] }
axum-extra = "0.7.2"
axum-extra = "0.8.0"
tower-http = { version = "0.4", features = ["fs"] }
reqwest = "0.11.14"
notify = "5.1.0"
notify = "6.1.1"
poem = { version = "1.3.55", features = ["sse"] }
futures = "0.3.26"
2 changes: 1 addition & 1 deletion crates/vertigo-cli/src/serve/html/html_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl HtmlResponse {

for (env_name, env_value) in &self.env {
html.add_attr(format!("data-env-{env_name}"), env_value);
}
}
} else {
return (StatusCode::INTERNAL_SERVER_ERROR, "root: the html element was expected".into());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vertigo-cli/src/serve/html/ordered_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ impl OrderedMap {
if self.data.contains_key(&name) {
let mut order = self.order
.iter()
.filter(|&item_name| item_name != &name)
.cloned()
.filter(|item_name| item_name != &name)
.collect::<Vec<_>>();

order.push(name);
Expand Down
3 changes: 3 additions & 0 deletions crates/vertigo-cli/src/serve/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ mod data_context;

pub use wasm_instance::{Message, FetchRequest, FetchResponse, WasmInstance};
pub use get_now::get_now;

const VERTIGO_VERSION_MAJOR: u32 = pkg_version::pkg_version_major!();
const VERTIGO_VERSION_MINOR: u32 = pkg_version::pkg_version_minor!();
9 changes: 6 additions & 3 deletions crates/vertigo-cli/src/serve/wasm/wasm_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::serve::{
};

use super::get_now;
use super::js_value_match::{Match};
use super::js_value_match::Match;

#[derive(Debug)]
pub enum Message {
Expand Down Expand Up @@ -330,7 +330,7 @@ impl WasmInstance {

if let Ok(env_name) = match_get_env(&value) {
let env_value = request.env(env_name);

let result = match env_value {
Some(value) => JsValue::String(value),
None => JsValue::Null,
Expand Down Expand Up @@ -423,7 +423,10 @@ impl WasmInstance {
}

pub fn call_vertigo_entry_function(&mut self) {
self.call_function::<(), ()>("vertigo_entry_function", ()).unwrap();
self.call_function::<(u32, u32), ()>(
"vertigo_entry_function",
(super::VERTIGO_VERSION_MAJOR, super::VERTIGO_VERSION_MINOR),
).unwrap();
}

pub fn wasm_callback(&mut self, callback_id: u64, params: JsValue) -> JsValue {
Expand Down
2 changes: 1 addition & 1 deletion crates/vertigo-cli/src/watch/sse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::task::Poll;
use futures::{stream::{Stream, StreamExt}};
use futures::stream::{Stream, StreamExt};
use poem::{
handler,
web::{sse::{Event, SSE}, Data},
Expand Down
5 changes: 3 additions & 2 deletions crates/vertigo-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo-macro"
version = "0.3.2"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
description = "Reactive Real-DOM library with SSR for Rust - macros"
edition = "2021"
Expand All @@ -13,10 +13,11 @@ proc-macro = true
[dependencies]
pest = "2.5"
pest_derive = "2.1"
pkg-version = "1"
proc-macro2 = "1.0"
proc-macro-error = "1.0"
syn = { version = "1.0", features=["full"] }
itertools = "0.10"
itertools = "0.11"
syn-rsx = "0.8"
sha2 = "0.10"
hex = "0.4"
16 changes: 12 additions & 4 deletions crates/vertigo-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ use html_parser::{dom_inner, dom_element_inner};
use proc_macro::{TokenStream, Span};
use syn::{Visibility, __private::ToTokens};

use crate::{
css_parser::generate_css_string,
};
use crate::css_parser::generate_css_string;
use bind::{bind_macro_fn, bind_spawn_fn, bind_rc_fn};

#[proc_macro]
Expand Down Expand Up @@ -140,12 +138,22 @@ pub fn main(_attr: TokenStream, input: TokenStream) -> TokenStream {

let input: proc_macro2::TokenStream = input2.into();

const VERTIGO_VERSION_MAJOR: u32 = pkg_version::pkg_version_major!();
const VERTIGO_VERSION_MINOR: u32 = pkg_version::pkg_version_minor!();

quote! {
#input

#[no_mangle]
pub fn vertigo_entry_function() {
pub fn vertigo_entry_function(version: (u32, u32)) {
vertigo::start_app(#name);
if true || version.0 != #VERTIGO_VERSION_MAJOR || version.1 != #VERTIGO_VERSION_MINOR {
vertigo::log::error!(
"Vertigo version mismatch, server {}.{} != client {}.{}",
version.0, version.1,
#VERTIGO_VERSION_MAJOR, #VERTIGO_VERSION_MINOR
);
}
}
}.into()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/vertigo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo"
version = "0.3.2"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
description = "Reactive Real-DOM library with SSR for Rust"
readme = "README.md"
Expand All @@ -14,4 +14,4 @@ edition = "2021"

[dependencies]
log = { version = "0.4", features=["std"] }
vertigo-macro = { path = "../../crates/vertigo-macro", version="0.3.1" }
vertigo-macro = { path = "../../crates/vertigo-macro", version = "0.4.0" }
8 changes: 6 additions & 2 deletions crates/vertigo/src/driver_module/src_js/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { WasmModule } from "./wasm_module";

// vertigo-cli compatibility version, change together with package version.
const VERTIGO_COMPAT_VERSION_MAJOR = 0;
const VERTIGO_COMPAT_VERSION_MINOR = 4;

const moduleRun: Set<string> = new Set();

const runModule = async (wasm: string) => {
Expand All @@ -18,8 +22,8 @@ const runModule = async (wasm: string) => {
console.info(`Wasm module: "${wasm}" -> start`);
const wasmModule = await WasmModule.create(wasm);
console.info(`Wasm module: "${wasm}" -> initialized`);
wasmModule.vertigo_entry_function();
console.info(`Wasm module: "${wasm}" -> launched vertigo_entry_function`);
wasmModule.vertigo_entry_function(VERTIGO_COMPAT_VERSION_MAJOR, VERTIGO_COMPAT_VERSION_MINOR);
console.info(`Wasm module: "${wasm}" -> launched vertigo_entry_function with version ${VERTIGO_COMPAT_VERSION_MAJOR}.${VERTIGO_COMPAT_VERSION_MINOR}`);
};

const findAndRunModule = async () => {
Expand Down
6 changes: 3 additions & 3 deletions crates/vertigo/src/driver_module/src_js/wasm_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ExportType = {
alloc: (size: number) => number,
free: (pointer: number) => void,
wasm_callback: (callback_id: bigint, value_ptr: number) => bigint, //result => pointer: 32bit, size: 32bit
vertigo_entry_function: () => void,
vertigo_entry_function: (major: number, minor: number) => void,
}

export class WasmModule {
Expand All @@ -27,8 +27,8 @@ export class WasmModule {
this.wasm = wasm;
}

public vertigo_entry_function() {
this.wasm.exports.vertigo_entry_function();
public vertigo_entry_function(major: number, minor: number) {
this.wasm.exports.vertigo_entry_function(major, minor);
}

public static async create(wasmBinPath: string): Promise<WasmModule> {
Expand Down
11 changes: 7 additions & 4 deletions crates/vertigo/src/driver_module/wasm_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -1879,8 +1879,8 @@ class WasmModule {
constructor(wasm) {
this.wasm = wasm;
}
vertigo_entry_function() {
this.wasm.exports.vertigo_entry_function();
vertigo_entry_function(major, minor) {
this.wasm.exports.vertigo_entry_function(major, minor);
}
static async create(wasmBinPath) {
let wasmModule = null;
Expand Down Expand Up @@ -1924,6 +1924,9 @@ class WasmModule {
}
}

// vertigo-cli compatibility version, change together with package version.
const VERTIGO_COMPAT_VERSION_MAJOR = 0;
const VERTIGO_COMPAT_VERSION_MINOR = 4;
const moduleRun = new Set();
const runModule = async (wasm) => {
if (moduleRun.has(wasm)) {
Expand All @@ -1938,8 +1941,8 @@ const runModule = async (wasm) => {
console.info(`Wasm module: "${wasm}" -> start`);
const wasmModule = await WasmModule.create(wasm);
console.info(`Wasm module: "${wasm}" -> initialized`);
wasmModule.vertigo_entry_function();
console.info(`Wasm module: "${wasm}" -> launched vertigo_entry_function`);
wasmModule.vertigo_entry_function(VERTIGO_COMPAT_VERSION_MAJOR, VERTIGO_COMPAT_VERSION_MINOR);
console.info(`Wasm module: "${wasm}" -> launched vertigo_entry_function with version ${VERTIGO_COMPAT_VERSION_MAJOR}.${VERTIGO_COMPAT_VERSION_MINOR}`);
};
const findAndRunModule = async () => {
document.querySelectorAll('*[data-vertigo-run-wasm]').forEach((node) => {
Expand Down
1 change: 0 additions & 1 deletion crates/vertigo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ pub use vertigo_macro::css_block;

pub mod html_entities;


pub struct DriverConstruct {
driver: Driver,
subscription: ValueMut<Option<DomNode>>,
Expand Down
4 changes: 2 additions & 2 deletions demo/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo-demo"
version = "0.3.1"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
edition = "2021"

Expand All @@ -9,4 +9,4 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
log = "0.4.17"
vertigo = { path = "../../crates/vertigo", version = "0.3.1" }
vertigo = { path = "../../crates/vertigo", version = "0.4.0" }
4 changes: 2 additions & 2 deletions examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "vertigo-example-counter"
version = "0.3.2"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
vertigo = { path = "../../crates/vertigo", version = "0.3.2" }
vertigo = { path = "../../crates/vertigo", version = "0.4.0" }
4 changes: 2 additions & 2 deletions examples/router/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo-example-router"
version = "0.3.2"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
edition = "2021"

Expand All @@ -9,4 +9,4 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
log = "0.4.14"
vertigo = { path = "../../crates/vertigo", version = "0.3.2" }
vertigo = { path = "../../crates/vertigo", version = "0.4.0" }
4 changes: 2 additions & 2 deletions examples/trafficlights/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "vertigo-example-trafficlights"
version = "0.3.2"
version = "0.4.0"
authors = ["Grzegorz Szeliga <szeligagrzegorz@gmail.com>", "Michał Pokrywka <wolfmoon@o2.pl>"]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
vertigo = { path = "../../crates/vertigo", version = "0.3.2" }
vertigo = { path = "../../crates/vertigo", version = "0.4.0" }
39 changes: 39 additions & 0 deletions tests/check_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
VERTIGO_VERSION=`grep version crates/vertigo/Cargo.toml | head -1 | awk -F'[ ".]' '{printf("%s.%s", $4, $5)}'`
MACRO_VERSION=`grep version crates/vertigo-macro/Cargo.toml | head -1 | awk -F'[ ".]' '{printf("%s.%s", $4, $5)}'`
CLI_VERSION=`grep version crates/vertigo-cli/Cargo.toml | head -1 | awk -F'[ ".]' '{printf("%s.%s", $4, $5)}'`

TS_MAJOR=`grep "const VERTIGO_COMPAT_VERSION_MAJOR" crates/vertigo/src/driver_module/src_js/index.ts | awk -F'[ ;]' '{print($4)}'`
TS_MINOR=`grep "const VERTIGO_COMPAT_VERSION_MINOR" crates/vertigo/src/driver_module/src_js/index.ts | awk -F'[ ;]' '{print($4)}'`
JS_MAJOR=`grep "const VERTIGO_COMPAT_VERSION_MAJOR" crates/vertigo/src/driver_module/wasm_run.js | awk -F'[ ;]' '{print($4)}'`
JS_MINOR=`grep "const VERTIGO_COMPAT_VERSION_MINOR" crates/vertigo/src/driver_module/wasm_run.js | awk -F'[ ;]' '{print($4)}'`

TS_VERSION="${TS_MAJOR}.${TS_MINOR}"
JS_VERSION="${JS_MAJOR}.${JS_MINOR}"

echo VERTIGO_VERSION $VERTIGO_VERSION
echo MACRO_VERSION $MACRO_VERSION
echo CLI_VERSION $CLI_VERSION
echo TS_VERSION $TS_VERSION
echo JS_VERSION $JS_VERSION

if [ "$VERTIGO_VERSION" != "$MACRO_VERSION" ]
then
echo "MACRO VERSION MISMATCH!" && exit 1
fi

if [ "$VERTIGO_VERSION" != "$CLI_VERSION" ]
then
echo "CLI VERSION MISMATCH!" && exit 2
fi

if [ "$VERTIGO_VERSION" != "$TS_VERSION" ]
then
echo "TS MAJOR/MINOR MISMATCH!" && exit 3
fi

if [ "$VERTIGO_VERSION" != "$JS_VERSION" ]
then
echo "JS MAJOR/MINOR MISMATCH! JS not build?" && exit 4
fi

echo "OK"
2 changes: 1 addition & 1 deletion tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- markdownlint-disable no-inline-html -->

<!-- markdownlint-disable-next-line no-emphasis-as-heading -->
*Up to date with version 0.3.2*
*Up to date with version 0.4.0*

<!-- markdownlint-disable-next-line heading-increment -->
### Table of contents
Expand Down
Loading