Skip to content

Commit 733ccce

Browse files
committed
Upgrade VanJS to 1.5.5
1 parent 84a0589 commit 733ccce

File tree

127 files changed

+1397
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1397
-433
lines changed

404.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
154154
<script async src="https://buttons.github.io/buttons.js"></script>
155155

156156

157-
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.3.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>
157+
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.5.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>

about.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
227227
<script async src="https://buttons.github.io/buttons.js"></script>
228228

229229

230-
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.3.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>
230+
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.5.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>

about/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
227227
<script async src="https://buttons.github.io/buttons.js"></script>
228228

229229

230-
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.3.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>
230+
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.5.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>

advanced.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
gtag('config', 'G-XFMTW2GNRV');
3232
</script>
33-
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.3.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
33+
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.5.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
3434
<!-- Sidebar/menu -->
3535
<nav class="w3-sidebar w3-red w3-collapse w3-top w3-large w3-padding" style="z-index:3;width:280px;font-weight:bold;" id="mySidebar"><br>
3636
<a href="javascript:void(0)" onclick="w3_close()" class="w3-button w3-hide-large w3-display-topleft" style="width:100%;font-size:22px">Close Menu</a>
@@ -342,4 +342,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
342342
<script async src="https://buttons.github.io/buttons.js"></script>
343343

344344

345-
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.3.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>
345+
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.5.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>

advanced/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
gtag('config', 'G-XFMTW2GNRV');
3232
</script>
33-
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.3.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
33+
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.5.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
3434
<!-- Sidebar/menu -->
3535
<nav class="w3-sidebar w3-red w3-collapse w3-top w3-large w3-padding" style="z-index:3;width:280px;font-weight:bold;" id="mySidebar"><br>
3636
<a href="javascript:void(0)" onclick="w3_close()" class="w3-button w3-hide-large w3-display-topleft" style="width:100%;font-size:22px">Close Menu</a>
@@ -342,4 +342,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
342342
<script async src="https://buttons.github.io/buttons.js"></script>
343343

344344

345-
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.3.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>
345+
<link rel="prefetch" href="/code/prism-v1.js" as="script"><link rel="prefetch" href="https://www.gstatic.com/charts/loader.js" as="script"><link rel="prefetch" href="/code/diff.min.js" as="script"><link rel="prefetch" href="/code/van-1.5.5.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.2.nomodule.min.js" as="script"></body></html>

autodownload.html

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,2 @@
11
<!DOCTYPE html>
2-
<html><head>
3-
<link rel="icon" href="/logo.svg">
4-
<title>Auto Download</title>
5-
<meta charset="UTF-8">
6-
</head>
7-
<body>
8-
<script>
9-
window.onload = () => {
10-
const file = new URLSearchParams(location.search).get("file")
11-
const downloadLink = document.createElement('a')
12-
downloadLink.href = "/code/" + file
13-
downloadLink.download = file
14-
downloadLink.click()
15-
}
16-
</script>
17-
18-
19-
</body></html>
2+
<html><head></head><body></body></html>

autodownload/index.html

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,2 @@
11
<!DOCTYPE html>
2-
<html><head>
3-
<link rel="icon" href="/logo.svg">
4-
<title>Auto Download</title>
5-
<meta charset="UTF-8">
6-
</head>
7-
<body>
8-
<script>
9-
window.onload = () => {
10-
const file = new URLSearchParams(location.search).get("file")
11-
const downloadLink = document.createElement('a')
12-
downloadLink.href = "/code/" + file
13-
downloadLink.download = file
14-
downloadLink.click()
15-
}
16-
</script>
17-
18-
19-
</body></html>
2+
<html><head></head><body></body></html>

code/code-browser/package-lock.json

+9-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/code-browser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"vite": "^4.3.9"
1414
},
1515
"dependencies": {
16-
"vanjs-core": "^1.5.3"
16+
"vanjs-core": "^1.5.5"
1717
}
1818
}

code/console.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
li(Snippet('plot([{Year:"2020",Sales:1000,Expenses:400},{Year:"2021",Sales:1170,Expenses:460},{Year:"2022",Sales:660,Expenses:1120},{Year:"2023",Sales:1030,Expenses:540}], "LineChart", {legend:{position:"bottom"}})')),
188188
li("The chart shown in the home page:", Snippet(`plot([
189189
["Framework", "Size", {role: "style"}, {role: "annotation"}],
190-
["VanJS", 1, "#f44336", "VanJS-1.5.3 1kB"],
190+
["VanJS", 1, "#f44336", "VanJS-1.5.5 1kB"],
191191
["Solid", 8.1, "#b7b7b7", "Solid-1.8.12 8.1kB"],
192192
["jQuery", 29.7, "#b7b7b7", "jQuery-3.7.1 29.7kB"],
193193
["Vue", 40, "#b7b7b7", "Vue-3.4.15 40kB"],

code/todo-app/package-lock.json

+57-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/todo-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"vite": "^6.2.2"
1515
},
1616
"dependencies": {
17-
"vanjs-core": "^1.5.3"
17+
"vanjs-core": "^1.5.5"
1818
}
1919
}

code/van-1.5.5.d.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export interface State<T> {
2+
val: T
3+
readonly oldVal: T
4+
readonly rawVal: T
5+
}
6+
7+
// Defining readonly view of State<T> for covariance.
8+
// Basically we want StateView<string> to implement StateView<string | number>
9+
export type StateView<T> = Readonly<State<T>>
10+
11+
export type Val<T> = State<T> | T
12+
13+
export type Primitive = string | number | boolean | bigint
14+
15+
export type PropValue = Primitive | ((e: any) => void) | null
16+
17+
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)
18+
19+
export type Props = Record<string, PropValueOrDerived> & { class?: PropValueOrDerived; is?: string }
20+
21+
export type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>
22+
23+
export type ValidChildDomValue = Primitive | Node | null | undefined
24+
25+
export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)
26+
27+
export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]
28+
29+
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
30+
31+
type Tags = Readonly<Record<string, TagFunc<Element>>> & {
32+
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
33+
}
34+
35+
declare function state<T>(): State<T>
36+
declare function state<T>(initVal: T): State<T>
37+
38+
export interface Van {
39+
readonly state: typeof state
40+
readonly derive: <T>(f: () => T) => State<T>
41+
readonly add: (dom: Element | DocumentFragment, ...children: readonly ChildDom[]) => Element
42+
readonly tags: Tags & ((namespaceURI: string) => Readonly<Record<string, TagFunc<Element>>>)
43+
readonly hydrate: <T extends Node>(dom: T, f: (dom: T) => T | null | undefined) => T
44+
}
45+
46+
declare const van: Van
47+
48+
export default van

code/van-1.5.5.debug.d.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export interface State<T> {
2+
val: T
3+
readonly oldVal: T
4+
readonly rawVal: T
5+
}
6+
7+
// Defining readonly view of State<T> for covariance.
8+
// Basically we want StateView<string> to implement StateView<string | number>
9+
export type StateView<T> = Readonly<State<T>>
10+
11+
export type Val<T> = State<T> | T
12+
13+
export type Primitive = string | number | boolean | bigint
14+
15+
export type PropValue = Primitive | ((e: any) => void) | null
16+
17+
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)
18+
19+
export type Props = Record<string, PropValueOrDerived> & { class?: PropValueOrDerived; is?: string }
20+
21+
export type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>
22+
23+
export type ValidChildDomValue = Primitive | Node | null | undefined
24+
25+
export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)
26+
27+
export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]
28+
29+
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
30+
31+
type Tags = Readonly<Record<string, TagFunc<Element>>> & {
32+
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
33+
}
34+
35+
declare function state<T>(): State<T>
36+
declare function state<T>(initVal: T): State<T>
37+
38+
export interface Van {
39+
readonly state: typeof state
40+
readonly derive: <T>(f: () => T) => State<T>
41+
readonly add: (dom: Element | DocumentFragment, ...children: readonly ChildDom[]) => Element
42+
readonly tags: Tags & ((namespaceURI: string) => Readonly<Record<string, TagFunc<Element>>>)
43+
readonly hydrate: <T extends Node>(dom: T, f: (dom: T) => T | null | undefined) => T
44+
}
45+
46+
declare const van: Van
47+
48+
export default van

0 commit comments

Comments
 (0)