diff --git a/CHANGELOG.md b/CHANGELOG.md index 75a08a17c..db2ddee8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,28 @@ # Changelog -## Unreleased +## 0.3.0 + +`@reactivescript/compiler`, `@reactivescript/runtime`, `@reactivescript/language-server` and the editor extension, +together. + +**Breaking** + +- `UNGUARDED_SNAPSHOT` (R-8) is stricter: an `errored` region or `disabled` covers a failure only when it reads the + value. A region whose content reads `x` only under `pending? x` never shows its fallback, so it no longer counts + (#58). **New** - Solid libraries (MO-10): declare a primitive once in a `.d.rx` (`export pure fn createToggle(v: boolean): [ref boolean, (v: boolean) => void]`) and use it like .rx: it is called once, `ref` arguments go in as accessors, readers are read without a call, and setters are io. A package's `.d.rx` sits beside the file its import resolves to. - `guide/libraries.md`. + `guide/libraries.md` (#57). +- The guide (shipped in `@reactivescript/compiler`) places data by its lifetime: what a visit, a write or the screen + needs, with a module only for data whose writes outlive their page (#58, #59). + +**Fixed** + +- `refresh` of a keyed equation re-asks it. It used to re-ask nothing in compiled code (#58). ## 0.2.0 diff --git a/compiler/Cargo.lock b/compiler/Cargo.lock index d46251595..a90b32d47 100644 --- a/compiler/Cargo.lock +++ b/compiler/Cargo.lock @@ -988,7 +988,7 @@ dependencies = [ [[package]] name = "reactivescript" -version = "0.2.0" +version = "0.3.0" dependencies = [ "indexmap", "napi", diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index ce695c02c..cd8e5eb7d 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reactivescript" -version = "0.2.0" +version = "0.3.0" edition = "2021" description = "ReactiveScript's compiler (spec/11): parse, check, resolve, and lower through Solid's solidjs-compiler" license = "MIT" diff --git a/compiler/npm/darwin-arm64/package.json b/compiler/npm/darwin-arm64/package.json index 209c93f93..fa5849fa0 100644 --- a/compiler/npm/darwin-arm64/package.json +++ b/compiler/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@reactivescript/compiler-darwin-arm64", - "version": "0.2.0", + "version": "0.3.0", "cpu": [ "arm64" ], diff --git a/compiler/npm/darwin-x64/package.json b/compiler/npm/darwin-x64/package.json index dc363f051..94139798e 100644 --- a/compiler/npm/darwin-x64/package.json +++ b/compiler/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@reactivescript/compiler-darwin-x64", - "version": "0.2.0", + "version": "0.3.0", "cpu": [ "x64" ], diff --git a/compiler/npm/linux-arm64-gnu/package.json b/compiler/npm/linux-arm64-gnu/package.json index 0e622b219..484f6785b 100644 --- a/compiler/npm/linux-arm64-gnu/package.json +++ b/compiler/npm/linux-arm64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@reactivescript/compiler-linux-arm64-gnu", - "version": "0.2.0", + "version": "0.3.0", "cpu": [ "arm64" ], diff --git a/compiler/npm/linux-x64-gnu/package.json b/compiler/npm/linux-x64-gnu/package.json index 3dc129d6c..0f40104d8 100644 --- a/compiler/npm/linux-x64-gnu/package.json +++ b/compiler/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@reactivescript/compiler-linux-x64-gnu", - "version": "0.2.0", + "version": "0.3.0", "cpu": [ "x64" ], diff --git a/compiler/npm/wasm32-wasi/package.json b/compiler/npm/wasm32-wasi/package.json index 121826579..55017fdb6 100644 --- a/compiler/npm/wasm32-wasi/package.json +++ b/compiler/npm/wasm32-wasi/package.json @@ -1,6 +1,6 @@ { "name": "@reactivescript/compiler-wasm32-wasi", - "version": "0.2.0", + "version": "0.3.0", "main": "compiler.wasi.cjs", "browser": "compiler.wasi-browser.js", "files": [ diff --git a/compiler/npm/win32-x64-msvc/package.json b/compiler/npm/win32-x64-msvc/package.json index 5236eabb4..7c7f2b982 100644 --- a/compiler/npm/win32-x64-msvc/package.json +++ b/compiler/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@reactivescript/compiler-win32-x64-msvc", - "version": "0.2.0", + "version": "0.3.0", "cpu": [ "x64" ], diff --git a/compiler/package-lock.json b/compiler/package-lock.json index bd91af544..ecceeb30c 100644 --- a/compiler/package-lock.json +++ b/compiler/package-lock.json @@ -1,12 +1,12 @@ { "name": "@reactivescript/compiler", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@reactivescript/compiler", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "devDependencies": { "@emnapi/core": "^1.11.3", diff --git a/compiler/package.json b/compiler/package.json index 262e369d0..508db4f9c 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -1,7 +1,7 @@ { "name": "@reactivescript/compiler", "description": "ReactiveScript's compiler, in process through Node-API, and its front end for @solidjs/vite-plugin", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "repository": { "type": "git", diff --git a/runtime/package-lock.json b/runtime/package-lock.json index 7f8159b8a..07dc6a9e2 100644 --- a/runtime/package-lock.json +++ b/runtime/package-lock.json @@ -1,12 +1,12 @@ { "name": "@reactivescript/runtime", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@reactivescript/runtime", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "devDependencies": { "@solidjs/signals": "2.0.0-rc.21", diff --git a/runtime/package.json b/runtime/package.json index e5431bbff..673f4cb4c 100644 --- a/runtime/package.json +++ b/runtime/package.json @@ -1,7 +1,7 @@ { "name": "@reactivescript/runtime", "description": "ReactiveScript's runtime (spec/11 CP-4a): createApp and the __rt helpers compiled .rx calls, over Solid, for the browser and the server", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "repository": { "type": "git", diff --git a/site/index.html b/site/index.html index 66a9abbc3..73dea7a69 100644 --- a/site/index.html +++ b/site/index.html @@ -88,7 +88,7 @@

ReactiveScript

Read the guide GitHub -

Experimental · 0.2. Files are .rx and compile to plain Solid 2.0. Releases follow Solid 2.0's release candidates, so expect breaking changes until Solid 2.0 is final.

+

Experimental · 0.3. Files are .rx and compile to plain Solid 2.0. Releases follow Solid 2.0's release candidates, so expect breaking changes until Solid 2.0 is final.

Mistakes of shape become errors

In Solid you already write UIs as derivations over signals. Most of what goes wrong is a shape mistake: writing to something that should be derived, writing during a computation, reading async data with no loading or error boundary above it. ReactiveScript makes those things the checker refuses, the way Rust refuses a borrow.

@@ -102,6 +102,19 @@

Mistakes of shape become errors

Write to the equation instead, double := 4, and the checker refuses it, in your editor and in CI:

counter.rx:5:3 - error WRITE_TO_NON_SOURCE: double is an equation: only sources are written (W-1)
+

Destructure props, keep them live

+

In Solid, destructuring props reads them once and the component stops updating. In .rx, destructure them right in the parameter list: every name follows its prop, defaults and rest included.

+
inbox.rxcomponent Badge({ label, tone = "info", ...rest }: { label: string; tone?: string; count: number }) {
+  <span class={tone}>{label}: {rest.count}</span>
+}
+
+export default component Inbox() {
+  source user := { name: "Ada", unread: 3 }
+
+  <Badge label={user.name} count={user.unread} />   // Badge updates when user changes
+  <button onClick={() => { user := { ...user, unread: 0 } }}>Mark read</button>
+}
+

Async is just await

Put an await in an equation. The checker tracks that the value can be pending and can fail, and asks you to say what to show in both cases.

profile.rximport pure { fetchUser } from "./api"
@@ -186,6 +199,7 @@ 

Every word is a Solid primitive

y = x * 2createMemo, createProjection user = await fetchUser(id)an async createMemo guess likes := likes + 1createOptimistic + component C({ label, ...rest })props.label, omit(props, "label") action send() { … }action effect (x) { … }createEffect(compute, apply) loading / errored<Loading> / <Errored> @@ -197,6 +211,19 @@

Every word is a Solid primitive

The spec is the product

Every behaviour is a numbered rule or an executable scenario, checked against Solid itself.

+

Use any Solid library

+

A Solid library is plain JavaScript, and .rx can use any of them: solid-primitives, a design system's hooks, your own create* helpers. Declare what you use once, in a .d.rx beside it, and the checker holds every use to that declaration. A ref is an accessor: you pass and read plain values, and the compiler adds the calls.

+
media.d.rx// beside ./media.js, which re-exports it from @solid-primitives/media
+export pure fn createMediaQuery(query: string): ref boolean
+
nav.rximport { createMediaQuery } from "./media.js"
+
+export default component Nav() {
+  wide = createMediaQuery("(min-width: 768px)")   // runs once; read it like any equation
+
+  <nav>{if wide { <Links /> } else { <Menu /> }}</nav>
+}
+

A package can ship its own .d.rx beside its build, and then there's nothing to declare. See Using Solid libraries.

+

Install

In a Solid app (Vite). Install the compiler and the runtime beside Solid 2.0. Solid's Vite plugin (3.0.0-next.57 or later) finds the compiler and compiles .rx on its own, so vite.config.js stays as it is.

npm i solid-js@next @solidjs/web@next @solidjs/signals@next @reactivescript/runtime
@@ -215,6 +242,7 @@ 

Learn more