From ac36b2a520cada566e99999ea55b54fbfed8031f Mon Sep 17 00:00:00 2001
From: Damian Tarnawski
Date: Sat, 28 Dec 2024 11:33:53 +0100
Subject: [PATCH] Cleanup sandbox and walker
---
.vscode/settings.json | 1 +
examples/sandbox/src/App.tsx | 162 ++++++++++------------
examples/sandbox/src/Todos.tsx | 97 ++++++-------
packages/debugger/src/structure/walker.ts | 60 ++++----
4 files changed, 152 insertions(+), 168 deletions(-)
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 610f7f8e..128fa058 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -10,6 +10,7 @@
"outin",
"sarif",
"stefanzweifel",
+ "sweb",
"taze",
"todomvc",
"twind",
diff --git a/examples/sandbox/src/App.tsx b/examples/sandbox/src/App.tsx
index 5fb3757b..3c0e6f7a 100644
--- a/examples/sandbox/src/App.tsx
+++ b/examples/sandbox/src/App.tsx
@@ -1,55 +1,43 @@
-import {
- type Component,
- createComponent,
- createComputed,
- createEffect,
- createMemo,
- createRenderEffect,
- createResource,
- createRoot,
- createSignal,
- ErrorBoundary,
- type ParentComponent,
- type Setter,
- Show,
- Suspense,
-} from 'solid-js'
+import * as s from 'solid-js'
import {createMutable} from 'solid-js/store'
+import * as sweb from 'solid-js/web'
import Recursive from './Recursive.tsx'
import {ThemeExample} from './Theme.tsx'
-import Todos from './Todos.tsx'
+
+// import Todos from './Todos.tsx'
+const Todos = s.lazy(() => import('./Todos.tsx'))
const doMediumCalc = () => {
Array.from({length: 1000000}, (_, i) => i).sort(() => Math.random() - 5)
}
-let setRootCount: Setter
+let setRootCount: s.Setter
let disposeOuterRoot: VoidFunction
-createRoot(dispose => {
+s.createRoot(dispose => {
disposeOuterRoot = dispose
- const [count, setCount] = createSignal(0)
+ const [count, setCount] = s.createSignal(0)
setRootCount = setCount
function createEffectInRoot(dispose: VoidFunction) {
- createEffect(() => count() === 4 && dispose(), undefined, {})
+ s.createEffect(() => count() === 4 && dispose(), undefined, {})
- createRoot(_ => {
- createEffect(() => count())
+ s.createRoot(_ => {
+ s.createEffect(() => count())
})
}
- createEffect(() => {
+ s.createEffect(() => {
count()
if (count() === 1) {
- createRoot(createEffectInRoot)
+ s.createRoot(createEffectInRoot)
}
}, undefined)
})
const Button = (props: {text: string; onClick: VoidFunction}) => {
- const text = createMemo(() => {props.text})
+ const text = s.createMemo(() => {props.text})
return (
{/* Count: {state.count}
*/}
-
+
-
+
)
}
const DynamicSpreadParent = () => {
- const [props, setProps] = createSignal({
+ const [props, setProps] = s.createSignal({
a: 1,
b: 2,
c: 3,
@@ -120,17 +108,17 @@ const DynamicSpreadParent = () => {
return
}
-const Broken: Component = () => {
+const Broken: s.Component = () => {
throw new Error('Oh No')
}
-const App: Component = () => {
- const [count, setCount] = createSignal(0)
- const [showEven, setShowEven] = createSignal(false)
- const fnSig = createSignal({fn: () => {}}, {equals: (a, b) => a.fn === b.fn})
- const nullSig = createSignal(null)
- const symbolSig = createSignal(Symbol('hello-symbol'))
- const [header, setHeader] = createSignal(
+const App: s.Component = () => {
+ const [count, setCount] = s.createSignal(0)
+ const [showEven, setShowEven] = s.createSignal(false)
+ const fnSig = s.createSignal({fn: () => {}}, {equals: (a, b) => a.fn === b.fn})
+ const nullSig = s.createSignal(null)
+ const symbolSig = s.createSignal(Symbol('hello-symbol'))
+ const [header, setHeader] = s.createSignal(
setHeader(Call that an easter egg
)}>Welcome to the Sandbox
,
)
@@ -138,7 +126,7 @@ const App: Component = () => {
// setCount(count() + 1)
// }, 2000)
- const objmemo = createMemo(() => {
+ const objmemo = s.createMemo(() => {
return {
foo: 'bar',
count: count(),
@@ -148,22 +136,18 @@ const App: Component = () => {
}
})
- createComputed(
- _ => {
- const hello = createSignal('hello')
- setShowEven(count() % 3 === 0)
- return count()
- },
- undefined,
- {name: 'very-long-name-that-will-definitely-not-have-enough-space-to-render'},
- )
+ s.createComputed(_ => {
+ const hello = s.createSignal('hello')
+ setShowEven(count() % 3 === 0)
+ return count()
+ }, undefined, {name: 'very-long-name-that-will-definitely-not-have-enough-space-to-render'})
- createComputed(() => {}, undefined, {name: 'frozen'})
- createRenderEffect(() => {})
+ s.createComputed(() => {}, undefined, {name: 'frozen'})
+ s.createRenderEffect(() => {})
- const Bold: ParentComponent = props => {props.children}
+ const Bold: s.ParentComponent = props => {props.children}
- const [showBroken, setShowBroken] = createSignal(false)
+ const [showBroken, setShowBroken] = s.createSignal(false)
return (
<>
@@ -174,37 +158,38 @@ const App: Component = () => {