Skip to content

Commit

Permalink
Upgrade VanJS to 1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao-VanJS committed Aug 19, 2024
1 parent 0494613 commit 3af627a
Show file tree
Hide file tree
Showing 120 changed files with 960 additions and 179 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
<script async defer src="https://buttons.github.io/buttons.js"></script>


<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.1.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
<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.2.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
2 changes: 1 addition & 1 deletion about.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
<script async defer src="https://buttons.github.io/buttons.js"></script>


<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.1.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
<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.2.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
2 changes: 1 addition & 1 deletion about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
<script async defer src="https://buttons.github.io/buttons.js"></script>


<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.1.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
<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.2.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
4 changes: 2 additions & 2 deletions advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

gtag('config', 'G-Q0NB75RY7E');
</script>
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.1.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.2.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
<!-- Sidebar/menu -->
<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>
<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>
Expand Down Expand Up @@ -294,4 +294,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
<script async defer src="https://buttons.github.io/buttons.js"></script>


<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.1.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
<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.2.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
4 changes: 2 additions & 2 deletions advanced/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

gtag('config', 'G-Q0NB75RY7E');
</script>
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.1.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
<script type="text/javascript" src="/code/prism-v1.js" defer></script><script type="text/javascript" src="/code/van-1.5.2.nomodule.min.js" defer></script><script type="text/javascript" src="advanced.js" defer></script>
<!-- Sidebar/menu -->
<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>
<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>
Expand Down Expand Up @@ -294,4 +294,4 @@ <h1 class="w3-padding-16 w3-xxxlarge">
<script async defer src="https://buttons.github.io/buttons.js"></script>


<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.1.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
<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.2.nomodule.min.js" as="script"><link rel="prefetch" href="/code/van-x-0.6.0.nomodule.min.js" as="script"></body></html>
44 changes: 22 additions & 22 deletions code/code-browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/code-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"dependencies": {
"terser": "^5.20.0",
"vanjs-core": "^1.5.1"
"vanjs-core": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion code/console.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
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"}})')),
li("The chart shown in the home page:", Snippet(`plot([
["Framework", "Size", {role: "style"}, {role: "annotation"}],
["VanJS", 1, "#f44336", "VanJS-1.5.1 1kB"],
["VanJS", 1, "#f44336", "VanJS-1.5.2 1kB"],
["Solid", 8.1, "#b7b7b7", "Solid-1.8.12 8.1kB"],
["jQuery", 29.7, "#b7b7b7", "jQuery-3.7.1 29.7kB"],
["Vue", 40, "#b7b7b7", "Vue-3.4.15 40kB"],
Expand Down
44 changes: 22 additions & 22 deletions code/todo-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/todo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"vite": "^4.3.9"
},
"dependencies": {
"vanjs-core": "^1.5.1"
"vanjs-core": "^1.5.2"
}
}
48 changes: 48 additions & 0 deletions code/van-1.5.2.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export interface State<T> {
val: T
readonly oldVal: T
readonly rawVal: T
}

// Defining readonly view of State<T> for covariance.
// Basically we want StateView<string> to implement StateView<string | number>
export type StateView<T> = Readonly<State<T>>

export type Val<T> = State<T> | T

export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

export type Props = Record<string, PropValueOrDerived> & { class?: PropValueOrDerived }

export type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
}

declare function state<T>(): State<T>
declare function state<T>(initVal: T): State<T>

export interface Van {
readonly state: typeof state
readonly derive: <T>(f: () => T) => State<T>
readonly add: (dom: Element, ...children: readonly ChildDom[]) => Element
readonly tags: Tags & ((namespaceURI: string) => Readonly<Record<string, TagFunc<Element>>>)
readonly hydrate: <T extends Node>(dom: T, f: (dom: T) => T | null | undefined) => T
}

declare const van: Van

export default van
48 changes: 48 additions & 0 deletions code/van-1.5.2.debug.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export interface State<T> {
val: T
readonly oldVal: T
readonly rawVal: T
}

// Defining readonly view of State<T> for covariance.
// Basically we want StateView<string> to implement StateView<string | number>
export type StateView<T> = Readonly<State<T>>

export type Val<T> = State<T> | T

export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

export type Props = Record<string, PropValueOrDerived> & { class?: PropValueOrDerived }

export type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
}

declare function state<T>(): State<T>
declare function state<T>(initVal: T): State<T>

export interface Van {
readonly state: typeof state
readonly derive: <T>(f: () => T) => State<T>
readonly add: (dom: Element, ...children: readonly ChildDom[]) => Element
readonly tags: Tags & ((namespaceURI: string) => Readonly<Record<string, TagFunc<Element>>>)
readonly hydrate: <T extends Node>(dom: T, f: (dom: T) => T | null | undefined) => T
}

declare const van: Van

export default van
Loading

0 comments on commit 3af627a

Please sign in to comment.