diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index a881074..a576ee2 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -23,5 +23,5 @@ jobs:
- run: npm ci
- run: npm run build -s
- run: npm test
- - run: npm publish --ignore-scripts --tag latest
+ - run: npm publish --ignore-scripts --tag next
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a440031..7df5aa8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,22 @@
+
+
+## v0.4
+
+### v0.4.0
+- 🟥 upgraded to [@e280/strata](https://github.com/e280/strata) v0.4
+ - 🟥 this is not compatible with strata 0.3, which means 0.4 will not respond to 0.3 signals, eg, your app also needs to adopt strata 0.4 to work with sly now -- strata is now a proper peerDependency of sly
+ - 🟥 strata-oriented hooks like `useSignal` now return strata 0.4 signals, not 0.3 signals, they're different, see the [strata changelog](https://github.com/e280/strata/blob/main/CHANGELOG.md) for details
+ - 🟥 removed `useLazy` hook in favor of improved lazy `useDerived`
+ - 🟥 renamed `useWaitResult` to `useWaitFormal`
+ - 🟥 `useEffect` is now simpler and only takes one simple fn, returns nothing
+- 🟥 delete old deprecated `Op` stuff in favor of newer `wait` stuff from strata
+- 🟥 delete old deprecated `loader` stuff in favor of newer `spinner` stuff
+
+
+
## v0.3
diff --git a/README.md b/README.md
index 2ee63e7..5455286 100644
--- a/README.md
+++ b/README.md
@@ -52,10 +52,10 @@ export const MyShadowView = shadow(() => html`
shrouded in darkness
`)
export const MyCounter = light((start: number) => {
const $count = useSignal(start)
- const increment = () => $count.value++
+ const increment = () => $count($count() + 1)
return html`
- ${$count.value}
+ ${$count()}
`
})
```
@@ -83,10 +83,10 @@ export const MyShadowView = shadow(() => html`shrouded in darkness
`)
useCss(css`button { color: cyan }`)
const $count = useSignal(start)
- const increment = () => $count.value++
+ const increment = () => $count($count() + 1)
return html`
- ${$count.value}
+ ${$count()}
`
})
@@ -216,7 +216,7 @@ you must not call these hooks under if-conditionals, or for-loops, or inside cal
// write the signal
$count(2)
```
-- **useDerived,** create a [strata](https://github.com/e280/strata) derived signal
+- **useDerived,** create a [strata](https://github.com/e280/strata) derived formula
```ts
const $product = useDerived(() => $count() * $whatever())
```
@@ -286,9 +286,9 @@ you must not call these hooks under if-conditionals, or for-loops, or inside cal
await $wait.ready
// 123
```
-- **useWaitResult,** start a [strata#wait](https://github.com/e280/strata#wait), but with a formal [stz#ok](https://github.com/e280/stz#ok) ok/err result
+- **useWaitFormal,** start a [strata#wait](https://github.com/e280/strata#wait), but with a formal [stz#ok](https://github.com/e280/stz#ok) ok/err result
```ts
- const $wait = useWaitResult(async() => {
+ const $wait = useWaitFormal(async() => {
await nap(2000)
return (Math.random() > 0.5)
? ok(123)
@@ -306,7 +306,7 @@ you must not call these hooks under if-conditionals, or for-loops, or inside cal
useMount(() => cycle(async() => {
await nap(1000)
- $seconds.value++
+ $seconds($seconds() + 1)
}))
```
- wake + rendered, to do something after each mount's first render
@@ -463,7 +463,7 @@ now, if you want to setup `location.hash` routing, you might want these primitiv
const $hash = hashSignal()
```
```ts
- $hash.value
+ $hash()
// "user/123/profile"
```
- the signal value auto-updates whenever the hash changes
diff --git a/package-lock.json b/package-lock.json
index 0edf44f..83b5dec 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,16 +1,15 @@
{
"name": "@e280/sly",
- "version": "0.3.12",
+ "version": "0.4.0-next.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@e280/sly",
- "version": "0.3.12",
+ "version": "0.4.0-next.5",
"license": "MIT",
"dependencies": {
- "@e280/strata": "^0.3.4",
- "@e280/stz": "^0.2.34"
+ "@e280/stz": "0.3.0-next.1"
},
"devDependencies": {
"@e280/hottie": "^0.1.1",
@@ -20,7 +19,8 @@
"typescript": "^6.0.3"
},
"peerDependencies": {
- "lit": "^3.3.2"
+ "@e280/strata": "0.4.0-next.8",
+ "lit": "^3.3.3"
}
},
"node_modules/@benev/argv": {
@@ -48,6 +48,13 @@
"hottie": "x/cli.js"
}
},
+ "node_modules/@e280/hottie/node_modules/@e280/stz": {
+ "version": "0.2.36",
+ "resolved": "https://registry.npmjs.org/@e280/stz/-/stz-0.2.36.tgz",
+ "integrity": "sha512-lA+CqHdWabjUEpxFzYfag8Pb76EM4RfRyK+PWqYL0gkrhHxCkAcjESWKioAwXHQiJB/cdiIlYWSLc6qcIL0WIA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@e280/octo": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@e280/octo/-/octo-0.1.1.tgz",
@@ -70,6 +77,23 @@
"octo-sequence": "x/octo-sequence.js"
}
},
+ "node_modules/@e280/octo/node_modules/@e280/strata": {
+ "version": "0.3.5",
+ "resolved": "https://registry.npmjs.org/@e280/strata/-/strata-0.3.5.tgz",
+ "integrity": "sha512-tt+yRugsosuDIe1cdaEaWKMvWAr0Ng+k9Crs3S1pMlKPX0sF7JBGdF9zKx3xqpc7KxNX/r6s0l77HKaE40B3UA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@e280/stz": "^0.2.35"
+ }
+ },
+ "node_modules/@e280/octo/node_modules/@e280/stz": {
+ "version": "0.2.36",
+ "resolved": "https://registry.npmjs.org/@e280/stz/-/stz-0.2.36.tgz",
+ "integrity": "sha512-lA+CqHdWabjUEpxFzYfag8Pb76EM4RfRyK+PWqYL0gkrhHxCkAcjESWKioAwXHQiJB/cdiIlYWSLc6qcIL0WIA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@e280/science": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/@e280/science/-/science-0.1.11.tgz",
@@ -99,6 +123,13 @@
"scute": "x/scute/cli.js"
}
},
+ "node_modules/@e280/scute/node_modules/@e280/stz": {
+ "version": "0.2.36",
+ "resolved": "https://registry.npmjs.org/@e280/stz/-/stz-0.2.36.tgz",
+ "integrity": "sha512-lA+CqHdWabjUEpxFzYfag8Pb76EM4RfRyK+PWqYL0gkrhHxCkAcjESWKioAwXHQiJB/cdiIlYWSLc6qcIL0WIA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@e280/sten": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@e280/sten/-/sten-0.1.1.tgz",
@@ -107,18 +138,19 @@
"license": "MIT"
},
"node_modules/@e280/strata": {
- "version": "0.3.4",
- "resolved": "https://registry.npmjs.org/@e280/strata/-/strata-0.3.4.tgz",
- "integrity": "sha512-Ff2fuVLS37nJ7p3zk/KHqqizIER4t1groco+nElauFZ8ViVxdrsoINWs8i1B6ThT+w6fPCe7tv83q4FZbdX8rg==",
+ "version": "0.4.0-next.8",
+ "resolved": "https://registry.npmjs.org/@e280/strata/-/strata-0.4.0-next.8.tgz",
+ "integrity": "sha512-n3aXMKlAxBjPCQJx6X2DQOKvZcS5x6aIghBkEsT0fT1X37g89rhK9Y2KM01yrqhfjt5e1JbbPqDz/7kh1Kot8A==",
"license": "MIT",
+ "peer": true,
"dependencies": {
- "@e280/stz": "^0.2.34"
+ "@e280/stz": "0.3.0-next.1"
}
},
"node_modules/@e280/stz": {
- "version": "0.2.34",
- "resolved": "https://registry.npmjs.org/@e280/stz/-/stz-0.2.34.tgz",
- "integrity": "sha512-qto1EhziB6QSlts1MsG8LSPGkQkZ4hbSOIW7HiqFcM6ftyq19++3H5MU5I75oNQ/qwPRYwbWtmuOXCSfK13tOQ==",
+ "version": "0.3.0-next.1",
+ "resolved": "https://registry.npmjs.org/@e280/stz/-/stz-0.3.0-next.1.tgz",
+ "integrity": "sha512-QDwen0GyDITbOiZSUKcpAdrLqdJ/qr5UGkzOff+K0aKSTp57UmDfFzH6LLD2Hhddf//GRBBoX8tU2BWUuMYzRw==",
"license": "MIT"
},
"node_modules/@esbuild/aix-ppc64": {
@@ -926,9 +958,9 @@
}
},
"node_modules/lit": {
- "version": "3.3.2",
- "resolved": "https://registry.npmjs.org/lit/-/lit-3.3.2.tgz",
- "integrity": "sha512-NF9zbsP79l4ao2SNrH3NkfmFgN/hBYSQo90saIVI1o5GpjAdCPVstVzO1MrLOakHoEhYkrtRjPK6Ob521aoYWQ==",
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/lit/-/lit-3.3.3.tgz",
+ "integrity": "sha512-fycuvZg/hkpozL00lm1pEJH5nN/lr9ZXd6mJI2HSN4+Bzc+LDNdEApJ6HFbPkdFNHLvOplIIuJvxkS4XUxqirw==",
"license": "BSD-3-Clause",
"peer": true,
"dependencies": {
diff --git a/package.json b/package.json
index 725eb76..14ee902 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@e280/sly",
- "version": "0.3.12",
+ "version": "0.4.0-next.5",
"description": "web shadow views",
"license": "MIT",
"type": "module",
@@ -15,9 +15,7 @@
"./loot": "./x/loot/index.js",
"./spa": "./x/spa/index.js",
"./spinner": "./x/spinner/index.js",
- "./view": "./x/view/index.js",
- "./loader": "./x/deprecated/loader/index.js",
- "./op": "./x/deprecated/op/index.js"
+ "./view": "./x/view/index.js"
},
"scripts": {
"build": "rm -rf x && mkdir x && tsc && scute -v",
@@ -26,11 +24,11 @@
"count": "find s -path '*/_archive' -prune -o -name '*.ts' -exec wc -l {} +"
},
"peerDependencies": {
- "lit": "^3.3.2"
+ "@e280/strata": "0.4.0-next.8",
+ "lit": "^3.3.3"
},
"dependencies": {
- "@e280/strata": "^0.3.4",
- "@e280/stz": "^0.2.34"
+ "@e280/stz": "0.3.0-next.1"
},
"devDependencies": {
"@e280/hottie": "^0.1.1",
diff --git a/s/demo/views/counter-light.ts b/s/demo/views/counter-light.ts
index e233051..bf80ac5 100644
--- a/s/demo/views/counter-light.ts
+++ b/s/demo/views/counter-light.ts
@@ -4,7 +4,7 @@ import {light, useSignal} from "../../view/index.js"
export const CounterLight = light((start: number) => {
const $count = useSignal(start)
- const increment = () => $count.value++
+ const increment = () => $count($count() + 1)
return html`
${$count()}
diff --git a/s/demo/views/counter-shadow.ts b/s/demo/views/counter-shadow.ts
index 5257ad1..7b66f05 100644
--- a/s/demo/views/counter-shadow.ts
+++ b/s/demo/views/counter-shadow.ts
@@ -7,7 +7,7 @@ export const CounterShadow = shadow((start: number) => {
useCss(css`:host{display:inline-block} button{color:cyan}`)
const $count = useSignal(start)
- const increment = () => $count.value++
+ const increment = () => $count($count() + 1)
return html`
${$count()}
diff --git a/s/demo/views/loaders.ts b/s/demo/views/loaders.ts
index 14a63be..26526e7 100644
--- a/s/demo/views/loaders.ts
+++ b/s/demo/views/loaders.ts
@@ -1,6 +1,6 @@
import {css, html} from "lit"
-import {newWait} from "@e280/strata"
+import {makeWait} from "@e280/strata"
import {shadow} from "../../view/shadow.js"
import {moonSpinner} from "../../spinner/spinners/moon.js"
import {waveSpinner} from "../../spinner/spinners/wave.js"
@@ -13,7 +13,7 @@ export const LoadersView = shadow(() => {
useName("loaders")
useStyles(cssReset, styles)
- const wait = useOnce(() => newWait())
+ const wait = useOnce(() => makeWait())
return Object.entries(spinners).map(([key, spinner]) => html`
diff --git a/s/deprecated/loader/index.barrel.ts b/s/deprecated/loader/index.barrel.ts
deleted file mode 100644
index 446cf15..0000000
--- a/s/deprecated/loader/index.barrel.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-
-export * as anims from "./parts/anims.js"
-export * from "./parts/ascii-anim.js"
-export * from "./parts/error-display.js"
-export * from "./make.js"
-export * from "./mock.js"
-export * from "./types.js"
-
-
diff --git a/s/deprecated/loader/index.ts b/s/deprecated/loader/index.ts
deleted file mode 100644
index ab459af..0000000
--- a/s/deprecated/loader/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-
-/** @deprecated see `spinner` instead */
-export * as loaders from "./index.barrel.js"
-
diff --git a/s/deprecated/loader/make.ts b/s/deprecated/loader/make.ts
deleted file mode 100644
index 3220ef8..0000000
--- a/s/deprecated/loader/make.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-
-import {Loader} from "./types.js"
-import {earth} from "./parts/anims.js"
-import {Content} from "../../view/types.js"
-import {ErrorDisplay} from "./parts/error-display.js"
-
-/** @deprecated use `makeSpinner` instead */
-export function make(
- loading: () => Content = earth,
- error: (error: any) => Content = (error: any) => ErrorDisplay(error),
- ): Loader {
-
- return (op, ready) => op.select({loading, ready, error})
-}
-
diff --git a/s/deprecated/loader/mock.ts b/s/deprecated/loader/mock.ts
deleted file mode 100644
index 39fa8c5..0000000
--- a/s/deprecated/loader/mock.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-
-import {Loader} from "./types.js"
-
-export function mock(): Loader {
- return (op, ready) => op.select({
- ready,
- loading: () => `[loading]`,
- error: () => `[error]`,
- })
-}
-
diff --git a/s/deprecated/loader/parts/anims.ts b/s/deprecated/loader/parts/anims.ts
deleted file mode 100644
index ae4fa17..0000000
--- a/s/deprecated/loader/parts/anims.ts
+++ /dev/null
@@ -1,413 +0,0 @@
-
-import {makeAsciiAnim} from "./ascii-anim.js"
-import type {Content} from "../../../view/types.js"
-
-const fast = 20
-const mid = 10
-const slow = 4
-
-export const spinner = makeAsciiAnim(fast, [
- "|",
- "/",
- "-",
- "\\",
-])
-
-export const braille = makeAsciiAnim(fast, [
- "⠈",
- "⠐",
- "⠠",
- "⢀",
- "⡀",
- "⠄",
- "⠂",
- "⠁",
-])
-
-export const arrow = makeAsciiAnim(fast, [
- "⬆️",
- "↗️",
- "➡️",
- "↘️",
- "⬇️",
- "↙️",
- "⬅️",
- "↖️",
-])
-
-export const bar = makeAsciiAnim(fast, [
- "▰▱▱▱▱",
- "▰▱▱▱▱",
- "▱▰▱▱▱",
- "▱▱▰▱▱",
- "▱▱▱▰▱",
- "▱▱▱▱▰",
- "▱▱▱▱▰",
- "▱▱▱▰▱",
- "▱▱▰▱▱",
- "▱▰▱▱▱",
-])
-
-export const bar2 = makeAsciiAnim(fast, [
- "▱▱▰▱▱",
- "▱▱▱▰▱",
- "▱▱▱▰▰",
- "▱▱▱▰▰",
- "▱▱▱▱▰",
- "▱▱▱▱▰",
- "▱▱▱▱▰",
- "▱▱▱▰▰",
- "▱▱▱▰▰",
- "▱▱▱▰▱",
- "▱▱▰▱▱",
- "▱▰▱▱▱",
- "▰▰▱▱▱",
- "▰▰▱▱▱",
- "▰▱▱▱▱",
- "▰▱▱▱▱",
- "▰▱▱▱▱",
- "▰▰▱▱▱",
- "▰▰▱▱▱",
- "▱▰▱▱▱",
-])
-
-export const bar3 = makeAsciiAnim(fast, [
- "▰▱▱▱▱",
- "▰▱▱▱▱",
- "▰▰▱▱▱",
- "▰▰▰▱▱",
- "▱▰▰▰▱",
- "▱▱▰▰▰",
- "▱▱▱▰▰",
- "▱▱▱▱▰",
- "▱▱▱▱▰",
- "▱▱▱▰▰",
- "▱▱▰▰▰",
- "▱▰▰▰▱",
- "▰▰▰▱▱",
- "▰▰▱▱▱",
-])
-
-export const bar4 = makeAsciiAnim(fast, [
- "▱▱▱▱▱",
- "▱▱▱▱▱",
- "▰▱▱▱▱",
- "▰▰▱▱▱",
- "▰▰▰▱▱",
- "▰▰▰▰▱",
- "▰▰▰▰▰",
- "▰▰▰▰▰",
- "▱▰▰▰▰",
- "▱▱▰▰▰",
- "▱▱▱▰▰",
- "▱▱▱▱▰",
-])
-
-export const block = makeAsciiAnim(fast, [
- "▁▁▁▁▁",
- "▁▁▁▁▁",
- "█▁▁▁▁",
- "██▁▁▁",
- "███▁▁",
- "████▁",
- "█████",
- "█████",
- "▁████",
- "▁▁███",
- "▁▁▁██",
- "▁▁▁▁█",
-])
-
-export const block2 = makeAsciiAnim(fast, [
- "█▁▁▁▁",
- "█▁▁▁▁",
- "██▁▁▁",
- "███▁▁",
- "████▁",
- "█████",
- "█████",
- "▁████",
- "▁▁███",
- "▁▁▁██",
- "▁▁▁▁█",
- "▁▁▁▁█",
- "▁▁▁██",
- "▁▁███",
- "▁████",
- "█████",
- "█████",
- "████▁",
- "███▁▁",
- "██▁▁▁",
-])
-
-export const runner = makeAsciiAnim(slow, [
- "🚶",
- "🏃",
-])
-
-export const pie = makeAsciiAnim(mid, [
- "◷",
- "◶",
- "◵",
- "◴",
-])
-
-export const cylon = makeAsciiAnim(fast, [
- "=----",
- "-=---",
- "--=--",
- "---=-",
- "----=",
- "----=",
- "---=-",
- "--=--",
- "-=---",
- "=----",
-])
-
-export const slider = makeAsciiAnim(fast, [
- "o----",
- "-o---",
- "--o--",
- "---o-",
- "----o",
- "----o",
- "---o-",
- "--o--",
- "-o---",
- "o----",
-])
-
-export const brackets = makeAsciiAnim(mid, [
- "[ ]",
- "[ ]",
- "[= ]",
- "[== ]",
- "[===]",
- "[ ==]",
- "[ =]",
-])
-
-export const brackets2 = makeAsciiAnim(mid, [
- "[ ]",
- "[ ]",
- "[= ]",
- "[== ]",
- "[===]",
- "[ ==]",
- "[ =]",
- "[ ]",
- "[ ]",
- "[ =]",
- "[ ==]",
- "[===]",
- "[== ]",
- "[= ]",
-])
-
-export const dots = makeAsciiAnim(mid, [
- " ",
- " ",
- ". ",
- ".. ",
- "...",
- " ..",
- " .",
-])
-
-export const dots2 = makeAsciiAnim(fast, [
- ". ",
- ". ",
- ".. ",
- "...",
- " ..",
- " .",
- " .",
- " ..",
- "...",
- ".. ",
-])
-
-export const wave = makeAsciiAnim(fast, [
- ".....",
- ".....",
- ":....",
- "::...",
- ":::..",
- "::::.",
- ":::::",
- ":::::",
- ".::::",
- "..:::",
- "...::",
- "....:",
-])
-
-export const wavescrub = makeAsciiAnim(fast, [
- ":....",
- ":....",
- "::...",
- ".::..",
- "..::.",
- "...::",
- "....:",
- "....:",
- "...::",
- "..::.",
- ".::..",
- "::...",
-])
-
-export const wavepulse = makeAsciiAnim(fast, [
- ".....",
- ".....",
- "..:..",
- ".:::.",
- ".:::.",
- ":::::",
- ":::::",
- "::.::",
- ":...:",
-])
-
-export const wavepulse2 = makeAsciiAnim(fast, [
- ".....",
- ".....",
- "..:..",
- ".:::.",
- ".:::.",
- ":::::",
- ":::::",
- "::.::",
- ":...:",
- ".....",
- ".....",
- ":...:",
- "::.::",
- ":::::",
- ":::::",
- ".:::.",
- ".:::.",
- "..:..",
-])
-
-export const bin = makeAsciiAnim(fast, [
- "000",
- "100",
- "110",
- "111",
- "011",
- "001",
-])
-
-export const binary = makeAsciiAnim(fast, [
- "11111",
- "01111",
- "00111",
- "10011",
- "11001",
- "01100",
- "00110",
- "10011",
- "11001",
- "11100",
- "11110",
-])
-
-export const binary2 = makeAsciiAnim(fast, [
- "11111",
- "01111",
- "10111",
- "11011",
- "11101",
- "11110",
- "11111",
- "11110",
- "11101",
- "11011",
- "10111",
- "01111",
-])
-
-export const pulseblue = makeAsciiAnim(slow, [
- "🔹",
- "🔵",
-])
-
-export const kiss = makeAsciiAnim(mid, [
- "🙂",
- "🙂",
- "😗",
- "😙",
- "😘",
- "😘",
- "😙",
-])
-
-export const clock = makeAsciiAnim(fast, [
- "🕐",
- "🕑",
- "🕒",
- "🕓",
- "🕔",
- "🕕",
- "🕖",
- "🕗",
- "🕘",
- "🕙",
- "🕚",
- "🕛",
-])
-
-export const fistbump = makeAsciiAnim(fast, [
- "🤜 🤛",
- "🤜 🤛",
- "🤜 🤛",
- " 🤜 🤛 ",
- " 🤜🤛 ",
- " 🤜🤛 ",
- " 🤜💥🤛 ",
- "🤜 💥 🤛",
- "🤜 ✨ 🤛",
- "🤜 ✨ 🤛",
-])
-
-export const earth = makeAsciiAnim(slow, [
- "🌎",
- "🌏",
- "🌍",
-])
-
-export const lock = makeAsciiAnim(slow, [
- "🔓",
- "🔒",
-])
-
-export const bright = makeAsciiAnim(slow, [
- "🔅",
- "🔆",
-])
-
-export const speaker = makeAsciiAnim(slow, [
- "🔈",
- "🔈",
- "🔉",
- "🔊",
- "🔊",
- "🔉",
-])
-
-export const moon = makeAsciiAnim(mid, [
- "🌑",
- "🌑",
- "🌑",
- "🌘",
- "🌗",
- "🌖",
- "🌕",
- "🌔",
- "🌓",
- "🌒",
-])
-
diff --git a/s/deprecated/loader/parts/ascii-anim.ts b/s/deprecated/loader/parts/ascii-anim.ts
deleted file mode 100644
index f925e27..0000000
--- a/s/deprecated/loader/parts/ascii-anim.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-
-import {css} from "lit"
-import {nap, cycle} from "@e280/stz"
-import {Content} from "../../../view/types.js"
-import {cssReset, shadow, useMount, useName, useSignal, useStyles} from "../../../view/index.js"
-
-export function makeAsciiAnim(hz: number, frames: string[]): () => Content {
- return () => AsciiAnim({hz, frames})
-}
-
-export const AsciiAnim = shadow(({hz, frames}: {
- hz: number,
- frames: string[],
- }) => {
-
- useName("loading")
- useStyles(cssReset, style)
-
- const frame = useSignal(0)
-
- useMount(() => cycle(async() => {
- await nap(1000 / hz)
- const next = frame.get() + 1
- frame.set(next >= frames.length ? 0 : next)
- }))
-
- return frames.at(frame.get())
-})
-
-const style = css`
-:host {
- font-family: monospace;
- white-space: pre;
- user-select: none;
-}
-`
-
diff --git a/s/deprecated/loader/parts/error-display.ts b/s/deprecated/loader/parts/error-display.ts
deleted file mode 100644
index 2943e2b..0000000
--- a/s/deprecated/loader/parts/error-display.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-
-import {css, html} from "lit"
-import {shadow} from "../../../view/shadow.js"
-import {cssReset, useName, useStyles} from "../../../view/index.js"
-
-export const ErrorDisplay = shadow((error: any) => {
- useName("error")
- useStyles(cssReset, style)
-
- if (typeof error === "string")
- return error
-
- else if (error instanceof Error)
- return html`
${error.name}: ${error.message} `
-
- else
- return `error`
-})
-
-const style = css`
- :host {
- font-family: monospace;
- color: red;
- }
-`
-
diff --git a/s/deprecated/loader/types.ts b/s/deprecated/loader/types.ts
deleted file mode 100644
index d47afd9..0000000
--- a/s/deprecated/loader/types.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-
-import type {Op} from "../op/op.js"
-import type {Content} from "../../view/types.js"
-
-export type Loader =
(op: Op, ready: (value: V) => Content) => Content
-
diff --git a/s/deprecated/op/index.ts b/s/deprecated/op/index.ts
deleted file mode 100644
index 23ac620..0000000
--- a/s/deprecated/op/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-
-export * from "./op.js"
-export * from "./podium.js"
-export * from "./types.js"
-
diff --git a/s/deprecated/op/op.ts b/s/deprecated/op/op.ts
deleted file mode 100644
index 9fac1ab..0000000
--- a/s/deprecated/op/op.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-
-import {pub} from "@e280/stz"
-import {Signal, signal} from "@e280/strata/signals"
-
-import {podium} from "./podium.js"
-import {Pod, PodSelect} from "./types.js"
-
-/** @deprecated use `wait` instead */
-export class Op {
- static loading() { return new this() }
- static ready(value: V) { return new this(["ready", value]) }
- static error(error: any) { return new this(["error", error]) }
-
- static promise(promise: Promise) {
- const op = new this()
- op.promise(promise)
- return op
- }
-
- static load(fn: () => Promise) {
- return this.promise(fn())
- }
-
- static all(...ops: Op[]) {
- const pods = ops.map(op => op.pod)
- return podium.all(...pods)
- }
-
- readonly signal: Signal>
- #count = 0
- #resolve = pub<[V]>()
- #reject = pub<[any]>()
-
- constructor(pod: Pod = ["loading"]) {
- this.signal = signal>(pod)
- }
-
- get wait() {
- return new Promise((resolve, reject) => {
- this.#resolve.next().then(([v]) => resolve(v))
- this.#reject.next().then(([e]) => reject(e))
- })
- }
-
- get then() { return this.wait.then.bind(this.wait) }
- get catch() { return this.wait.catch.bind(this.wait) }
- get finally() { return this.wait.finally.bind(this.wait) }
-
- async setLoading() {
- await this.signal.set(["loading"])
- }
-
- async setReady(value: V) {
- await this.signal.set(["ready", value])
- await this.#resolve(value)
- }
-
- async setError(error: any) {
- await this.signal.set(["error", error])
- await this.#reject(error)
- }
-
- async promise(promise: Promise) {
- const count = ++this.#count
- await this.setLoading()
- try {
- const value = await promise
- if (count === this.#count)
- await this.setReady(value)
- return value
- }
- catch (error) {
- console.error(error)
- if (count === this.#count)
- await this.setError(error)
- }
- }
-
- async load(fn: () => Promise) {
- return this.promise(fn())
- }
-
- get pod() {
- return this.signal.get()
- }
-
- set pod(p: Pod) {
- this.signal.set(p)
- }
-
- get status() {
- return this.signal.get()[0]
- }
-
- get value() {
- return podium.value(this.signal.get())
- }
-
- get error() {
- return podium.error(this.signal.get())
- }
-
- get isLoading() {
- return this.status === "loading"
- }
-
- get isReady() {
- return this.status === "ready"
- }
-
- get isError() {
- return this.status === "error"
- }
-
- require() {
- const pod = this.signal.get()
- if (pod[0] !== "ready") throw new Error("required value not ready")
- return pod[1]
- }
-
- select(select: PodSelect) {
- return podium.select(this.signal.get(), select)
- }
-
- morph(fn: (value: V) => V2) {
- return podium.morph(this.pod, fn)
- }
-}
-
diff --git a/s/deprecated/op/podium.ts b/s/deprecated/op/podium.ts
deleted file mode 100644
index 5c332fc..0000000
--- a/s/deprecated/op/podium.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-
-import {Pod, PodSelect} from "./types.js"
-
-/** @deprecated use `wait` instead */
-export const podium = {
- status: (pod: Pod) => pod[0],
-
- value: (pod: Pod) => {
- return pod[0] === "ready"
- ? pod[1]
- : undefined
- },
-
- error: (pod: Pod) => {
- return pod[0] === "error"
- ? pod[1]
- : undefined
- },
-
- select: (pod: Pod, select: PodSelect) => {
- switch (pod[0]) {
- case "loading": return select.loading()
- case "error": return select.error(pod[1])
- case "ready": return select.ready(pod[1])
- default: throw new Error("unknown op status")
- }
- },
-
- morph: (pod: Pod , fn: (a: A) => B): Pod => {
- return podium.select>(pod, {
- loading: () => ["loading"],
- error: error => ["error", error],
- ready: a => ["ready", fn(a)],
- })
- },
-
- all: (...pods: Pod[]): Pod => {
- const values: V[] = []
- const errors: any[] = []
- let loading = 0
-
- for (const pod of pods) {
- switch (pod[0]) {
- case "loading":
- loading++
- break
-
- case "ready":
- values.push(pod[1])
- break
-
- case "error":
- errors.push(pod[1])
- break
- }
- }
-
- if (errors.length > 0)
- return ["error", errors]
-
- else if (loading === 0)
- return ["ready", values]
-
- else
- return ["loading"]
- }
-}
-
diff --git a/s/deprecated/op/types.ts b/s/deprecated/op/types.ts
deleted file mode 100644
index d35f246..0000000
--- a/s/deprecated/op/types.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-
-export type PodLoading = [status: "loading"]
-export type PodReady = [status: "ready", value: V]
-export type PodError = [status: "error", error: any]
-
-/** @deprecated use `wait` instead */
-export type Pod = PodLoading | PodReady | PodError
-
-export type PodSelect = {
- loading: () => R
- ready: (value: V) => R
- error: (error: any) => R
-}
-
diff --git a/s/dom/dom.ts b/s/dom/dom.ts
index 63b8e2e..08479a2 100644
--- a/s/dom/dom.ts
+++ b/s/dom/dom.ts
@@ -33,6 +33,3 @@ dom.render = (container: Renderable, ...content: Content[]) => {
return render(content, container)
}
-/** @deprecated renamed to `dom.need` */
-dom.require = queryRequire
-
diff --git a/s/index.ts b/s/index.ts
index d381eff..754f61f 100644
--- a/s/index.ts
+++ b/s/index.ts
@@ -5,7 +5,3 @@ export * from "./spa/index.js"
export * from "./spinner/index.js"
export * from "./view/index.js"
-// deprecated
-export * from "./deprecated/loader/index.js"
-export * from "./deprecated/op/index.js"
-
diff --git a/s/loot/drag-and-drops.ts b/s/loot/drag-and-drops.ts
index 23453f0..3e84860 100644
--- a/s/loot/drag-and-drops.ts
+++ b/s/loot/drag-and-drops.ts
@@ -34,12 +34,12 @@ export class DragAndDrops {
draggable: "true",
dragstart: (_: DragEvent) => {
- this.$draggy.value = getDraggy()
+ this.$draggy(getDraggy())
},
dragend: (_: DragEvent) => {
- this.$draggy.value = undefined
- this.$droppy.value = undefined
+ this.$draggy(undefined)
+ this.$droppy(undefined)
},
})
@@ -50,14 +50,14 @@ export class DragAndDrops {
dragover: (event: DragEvent) => {
event.preventDefault()
if (this.$draggy())
- this.$droppy.value = getDroppy()
+ this.$droppy(getDroppy())
else
this.params.backchannelDrops?.dragover(event)
},
dragleave: (event: DragEvent) => {
if (outsideCurrentTarget(event))
- this.$droppy.value = undefined
+ this.$droppy(undefined)
this.params.backchannelDrops?.dragleave(event)
},
@@ -73,8 +73,8 @@ export class DragAndDrops {
this.params.backchannelDrops?.drop(event)
}
finally {
- this.$draggy.value = undefined
- this.$droppy.value = undefined
+ this.$draggy(undefined)
+ this.$droppy(undefined)
}
},
})
diff --git a/s/loot/drops.ts b/s/loot/drops.ts
index 4a1d76f..2f9abeb 100644
--- a/s/loot/drops.ts
+++ b/s/loot/drops.ts
@@ -17,17 +17,17 @@ export class Drops {
dragover = (event: DragEvent) => {
event.preventDefault()
- this.$indicator.value = this.params.predicate(event)
+ this.$indicator(this.params.predicate(event))
}
dragleave = (event: DragEvent) => {
if (outsideCurrentTarget(event))
- this.$indicator.value = false
+ this.$indicator(false)
}
drop = (event: DragEvent) => {
event.preventDefault()
- this.$indicator.value = false
+ this.$indicator(false)
if (this.params.predicate(event))
this.params.acceptDrop(event)
}
diff --git a/s/spinner/parts/ascii-anim.ts b/s/spinner/parts/ascii-anim.ts
index 3057e5d..f3c8fa5 100644
--- a/s/spinner/parts/ascii-anim.ts
+++ b/s/spinner/parts/ascii-anim.ts
@@ -16,15 +16,15 @@ export const AsciiAnim = shadow(({hz, frames}: {
useName("loading")
useStyles(cssReset, style)
- const frame = useSignal(0)
+ const $frame = useSignal(0)
useMount(() => cycle(async() => {
await nap(1000 / hz)
- const next = frame.get() + 1
- frame.set(next >= frames.length ? 0 : next)
+ const next = $frame() + 1
+ $frame(next >= frames.length ? 0 : next)
}))
- return frames.at(frame.get())
+ return frames.at($frame())
})
const style = css`
diff --git a/s/view/elements/shadow.ts b/s/view/elements/shadow.ts
index 804c4d5..4a718e6 100644
--- a/s/view/elements/shadow.ts
+++ b/s/view/elements/shadow.ts
@@ -1,13 +1,14 @@
+import {microbounce} from "@e280/stz"
import {render as litRender} from "lit"
-import {Constructor, microbounce} from "@e280/stz"
+
import {Content} from "../types.js"
import {ShadowCx} from "../parts/cx.js"
import {hooks} from "../hooks/plumbing/hooks.js"
import {Reactivity} from "../parts/reactivity.js"
import {Hookscope} from "../hooks/plumbing/hookscope.js"
-export function shadowElement(view: () => Content): Constructor {
+export function shadowElement(view: () => Content): new() => HTMLElement {
return class extends HTMLElement {
#cx
#hookscope
diff --git a/s/view/hooks/plumbing/hookscope.ts b/s/view/hooks/plumbing/hookscope.ts
index 93605a0..73109e0 100644
--- a/s/view/hooks/plumbing/hookscope.ts
+++ b/s/view/hooks/plumbing/hookscope.ts
@@ -1,11 +1,10 @@
-import {GMap} from "@e280/stz"
import {Mounts} from "../use-mount.js"
import {LightCx, ShadowCx} from "../../parts/cx.js"
export class Hookscope {
position = 0
- values = new GMap()
+ values = new Map()
mounts = new Mounts()
constructor(public cx: LightCx | ShadowCx) {}
}
diff --git a/s/view/hooks/use-lifecycle.ts b/s/view/hooks/use-lifecycle.ts
index 4d10da5..e434eb1 100644
--- a/s/view/hooks/use-lifecycle.ts
+++ b/s/view/hooks/use-lifecycle.ts
@@ -15,6 +15,3 @@ export function useLifecycle(fn: () => [value: Value, dispose: () => void
return ref.current
}
-/** @deprecated renamed to `useLifecycle` */
-export const useLife = useLifecycle
-
diff --git a/s/view/hooks/use-once.ts b/s/view/hooks/use-once.ts
index 9e9a582..9fd62ef 100644
--- a/s/view/hooks/use-once.ts
+++ b/s/view/hooks/use-once.ts
@@ -1,9 +1,10 @@
+import {guarantee} from "@e280/stz"
import {hooks} from "./plumbing/hooks.js"
/** run the fn only one time */
export function useOnce(fn: () => Value) {
const {scope, position} = hooks.increment()
- return scope.values.guarantee(position, fn) as Value
+ return guarantee(scope.values, position, fn) as Value
}
diff --git a/s/view/hooks/use-op.ts b/s/view/hooks/use-op.ts
deleted file mode 100644
index 5496687..0000000
--- a/s/view/hooks/use-op.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-
-import {Op} from "../../deprecated/op/op.js"
-import {useOnce} from "./use-once.js"
-
-/** @deprecated use `useWait` instead */
-export function useOp(fn: () => Promise) {
- return useOnce(() => Op.load(fn))
-}
-
-/** @deprecated use `useWait` instead */
-export function useOpPromise(promise: Promise) {
- return useOnce(() => Op.promise(promise))
-}
-
diff --git a/s/view/hooks/use-signal.ts b/s/view/hooks/use-signal.ts
index e8596fd..2daa5d2 100644
--- a/s/view/hooks/use-signal.ts
+++ b/s/view/hooks/use-signal.ts
@@ -1,28 +1,17 @@
-import {signal, watch} from "@e280/strata"
+import {derived, effect, signal} from "@e280/strata"
import {useOnce} from "./use-once.js"
-import {useLifecycle} from "./use-lifecycle.js"
+import {useMount} from "./use-mount.js"
export function useSignal(value: Value) {
return useOnce(() => signal(value))
}
export function useDerived(fn: () => Value) {
- return useOnce(() => signal.derived(fn))
+ return useOnce(() => derived(fn))
}
-export function useLazy(fn: () => Value) {
- return useOnce(() => signal.lazy(fn))
-}
-
-export function useEffect(
- collector: () => Value,
- responder?: (value: Value) => void,
- ) {
-
- return useLifecycle(() => {
- const {result, dispose} = watch(collector, responder)
- return [result, dispose]
- })
+export function useEffect(fn: () => void) {
+ return useMount(() => effect(fn))
}
diff --git a/s/view/hooks/use-wait.ts b/s/view/hooks/use-wait.ts
index fbda4cf..c0bece2 100644
--- a/s/view/hooks/use-wait.ts
+++ b/s/view/hooks/use-wait.ts
@@ -1,6 +1,6 @@
import {Result} from "@e280/stz"
-import {wait, waitResult} from "@e280/strata"
+import {wait, waitFormal} from "@e280/strata"
import {useOnce} from "./use-once.js"
export function useWait(
@@ -9,9 +9,9 @@ export function useWait(
return useOnce(() => wait(input))
}
-export function useWaitResult(
+export function useWaitFormal(
input: Promise> | (() => Promise>),
) {
- return useOnce(() => waitResult(input))
+ return useOnce(() => waitFormal(input))
}
diff --git a/s/view/index.ts b/s/view/index.ts
index 10f30c1..3dd90c8 100644
--- a/s/view/index.ts
+++ b/s/view/index.ts
@@ -12,7 +12,6 @@ export * from "./hooks/use-lifecycle.js"
export * from "./hooks/use-mount.js"
export * from "./hooks/use-name.js"
export * from "./hooks/use-once.js"
-export * from "./hooks/use-op.js"
export * from "./hooks/use-ref.js"
export * from "./hooks/use-signal.js"
export * from "./hooks/use-state.js"
diff --git a/s/view/parts/reactivity.ts b/s/view/parts/reactivity.ts
index f801be9..2a57672 100644
--- a/s/view/parts/reactivity.ts
+++ b/s/view/parts/reactivity.ts
@@ -10,13 +10,13 @@ export class Reactivity {
}
observe(fn: () => X, rerender: () => Promise) {
- const {seen, result} = tracker.observe(fn)
+ const {seen, value} = tracker.observe(fn)
this.clear()
for (const item of seen) {
const stop = tracker.subscribe(item, rerender)
this.#stoppers.push(stop)
}
- return result
+ return value
}
}