Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vapor mode #12359

Draft
wants to merge 718 commits into
base: minor
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
718 commits
Select commit Hold shift + click to select a range
2e2f3e2
test(vue-vapor): todomvc e2e test (#115)
LittleSound May 21, 2024
4e13a57
feat(compiler/runtime-vapor): implement v-slots + v-for / v-if (#207)
Doctor-wu May 21, 2024
1008199
ci: fix RCE vulnerability in file overwrite
sxzz May 20, 2024
969f53f
test(runtime-vapor): api lifecycle hooks (#215)
ubugeeei May 26, 2024
b5ecb72
feat: directive lifecycle hooks in `v-for`, `v-if` and component (#123)
LittleSound May 26, 2024
ca61022
fix(playground): import type error (#219)
shellingfordly May 28, 2024
c97dee3
refactor(compiler-vapor): remove Object.entries
sxzz May 28, 2024
4ed4fb6
fix(vue-vapor): build dts
sxzz May 28, 2024
107569b
feat(runtime-vapor): resolve assets of components & directives (#214)
Doctor-wu May 28, 2024
00c6e6d
refactor(compiler-vapor): inline literal value into template
sxzz May 29, 2024
868c429
feat: destructuring + nesting in v-for (#217)
LittleSound May 29, 2024
334e72e
Merge remote-tracking branch 'upstream/minor'
sxzz May 30, 2024
5a0a2bf
refactor: remove optional chaining
sxzz May 30, 2024
b2259a5
refactor: general destructuring function (#221)
LittleSound May 31, 2024
cef446a
fix(compiler-sfc): `vapor` attribute on template tag
sxzz Jun 2, 2024
208dbc6
feat(compiler-vapor): v-slot props + v-slot on component (#223)
LittleSound Jun 2, 2024
8a59311
perf(compiler-vapor/runtime-vapor): finer update granularity (#222)
Doctor-wu Jun 2, 2024
8ccfce5
refactor(compiler/runtime-vapor): remove unnecessary slot key (#225)
Doctor-wu Jun 3, 2024
bbd1944
test(runtime-vapor): finish createVaporApp unit tests
sxzz Jun 4, 2024
598b55f
test(runtime-vapor): finish expose and inject tests
sxzz Jun 4, 2024
b023b9b
test(compiler-vapor): add scopeId test
sxzz Jun 4, 2024
c9241da
feat(runtime-vapor): slot props (#227)
LittleSound Jun 10, 2024
325eb13
chore: update readme
sxzz Jun 10, 2024
a1797f8
fix(runtime-vapor): infer component name from registry
sxzz Jun 16, 2024
ad3d8fa
test(runtime-vapor): fix type (#229)
Doctor-wu Jun 16, 2024
3ac951b
feat(runtime-vapor): implement app.config.performance (#230)
xiaodong2008 Jun 16, 2024
cf8be99
Merge remote-tracking branch 'upstream/minor'
sxzz Jun 16, 2024
80acfa5
test(runtime-vapor): add directive test case (#231)
Doctor-wu Jun 16, 2024
bc04592
test(runtime-vapor): add unit test for config.performance (#234)
xiaodong2008 Jun 17, 2024
bbde386
test(runtime-vapor): add apiSetupContext unit test (#237)
xiaodong2008 Jun 18, 2024
97f0b3b
refactor: component slots (#238)
sxzz Jun 18, 2024
d451115
test(runtime-vapor): add directives test (#240)
xiaodong2008 Jun 19, 2024
be6a2d1
fix(runtime-vapor): apiLifeCycle circular dependencies (#244)
xiaodong2008 Jun 20, 2024
aa5fe96
feat(template-explorer): add vapor option
sxzz Jun 20, 2024
7d90c88
fix(runtime-vapor): current instance is not attached to static slots …
LittleSound Jun 20, 2024
07444b3
feat(runtime-vapor): try to support devtools
sxzz Jun 21, 2024
63dbc26
test(runtime-vapor): add misc test (#246)
xiaodong2008 Jun 21, 2024
20b6594
revert: test(runtime-vapor): add misc test
sxzz Jun 22, 2024
4be49b2
Merge remote-tracking branch 'upstream/minor'
sxzz Jun 22, 2024
5eb43b0
ci: add release tag (#254)
sxzz Jun 23, 2024
b44ca85
feat(compiler-vapor): support v-for without prefixIdentifiers (#259)
zhiyuanzmj Jul 2, 2024
d14c5d9
test(runtime-vapor): globalProperty (#255)
GaoNeng-wWw Jul 14, 2024
8941779
test(runtime-vapor): errorHandling (#245)
xiaodong2008 Jul 14, 2024
e552ed2
test(runtime-vapor): rendererElement test (#256)
xiaodong2008 Jul 14, 2024
6608bb3
test(compiler-vapor): add temporary test TODO
sxzz Jul 14, 2024
a8248cf
Merge remote-tracking branch 'upstream/minor'
sxzz Jul 19, 2024
0fde1e1
ci: continuous releases with pkg.pr.new (#264)
Aslemammad Jul 26, 2024
be332dc
perf(runtime-vapor): `children` helper (#263)
LittleSound Jul 29, 2024
61ddfe9
chore: remove todo from README
sxzz Jul 29, 2024
f0405f1
Merge tag 'v3.5.0-alpha.4'
sxzz Jul 29, 2024
d23095e
Merge tag 'v3.5.0-alpha.5'
sxzz Aug 6, 2024
669c295
ci: remove release concurrency limit
sxzz Aug 6, 2024
25f8502
workflow: add quick benchmark (#266)
sxzz Aug 6, 2024
16ea5ff
chore: revert release script for vapor
sxzz Aug 8, 2024
5632e2f
refactor: `baseWatch` always return effect
sxzz Aug 8, 2024
4468a2b
Merge tag 'v3.5.0-beta.1'
sxzz Aug 8, 2024
2ef97fe
refactor: isolatedDeclarations for vapor
sxzz Aug 9, 2024
7b3c176
workflow: fix missing terser dependencies
LittleSound Aug 15, 2024
abd685d
workflow: improve the benchmark scripts
LittleSound Aug 17, 2024
30583b9
workflow: add dev build mode for benchmark
LittleSound Aug 19, 2024
594cb14
Merge remote-tracking branch 'upstream/main'
sxzz Sep 17, 2024
daf098e
ci: cleanup & fix repo
sxzz Sep 17, 2024
1094b05
chore: update readme & sponsors
sxzz Sep 17, 2024
ced7ee6
feat(compiler-vapor): support v-slots expression for jsx-vapor (#271)
zhiyuanzmj Sep 17, 2024
c065aaf
chore(benchmark): fix path
sxzz Sep 17, 2024
3f1ee07
fix(runtime-vapor): swc minify error
sxzz Sep 17, 2024
95e93c1
chore(benchmark): 4x cpu slowdown
sxzz Sep 17, 2024
6791c88
perf: improve benchmark test code (#268)
LittleSound Sep 17, 2024
e1bedb8
refactor!: drop custom directives (#274)
sxzz Sep 18, 2024
cc58f65
refactor(compiler-vapor): remove `proxyRefs` in v-for
sxzz Sep 18, 2024
884c190
feat: `v-memo` for `v-for` (#276)
sxzz Sep 19, 2024
e07eac9
feat(runtime-vapor): createSelector (#279)
LittleSound Sep 21, 2024
b871358
Merge remote-tracking branch 'upstream/main'
sxzz Sep 21, 2024
c366948
chore: upgrade deps, remove playground demos
sxzz Sep 22, 2024
b962aa5
refactor(runtime-vapor): remove support of shallowRef in v-for
sxzz Sep 27, 2024
5f6cd32
test(runtime-vapor): fix shallowRef in v-for (#280)
LittleSound Sep 27, 2024
eda2a43
refactor(runtime-vapor): remove shallowRef list for v-for (#281)
LittleSound Sep 28, 2024
604c42d
chore(runtime-vapor): add benchmark build flag
sxzz Sep 28, 2024
126ce65
chore(benchmark): fix conflict args (#282)
Doctor-wu Sep 30, 2024
c7fd6ae
Merge tag 'v3.5.11'
sxzz Oct 5, 2024
abacf63
chore(benchmark): dedupe deps
sxzz Oct 5, 2024
7e153f8
ci: continuous release without checking
sxzz Oct 5, 2024
3d48718
chore: rename repo name
sxzz Oct 5, 2024
3867942
fix(runtime-vapor): stale memo cache
sxzz Oct 5, 2024
c1c316d
feat(runtime-vapor): fast path for clear all children
sxzz Oct 5, 2024
3fa4069
perf(runtime): clear container on unmount
sxzz Oct 5, 2024
c849864
fix(runtime-shared): dedupe deps
sxzz Oct 6, 2024
2ed0be8
fix(compiler-vapor): quote slot name
sxzz Oct 7, 2024
b5ed2ec
workflow: fix inaccurate test timer in benchmark (#286)
LittleSound Nov 11, 2024
2d30c71
workflow(benchmark): warmup run (#287)
LittleSound Nov 11, 2024
b1260e0
Merge remote-tracking branch 'upstream/main'
yyx990803 Nov 11, 2024
eed7d1d
refactor(compiler-vapor): drop browser build
sxzz Nov 13, 2024
c574faa
refactor(runtime-vapor): simplify directive mechanism (#278)
sxzz Nov 13, 2024
8ea6e4f
fix(vue-vapor): remove compiler version
sxzz Nov 13, 2024
51d9bbe
fix(compiler-vapor): nested component
sxzz Nov 13, 2024
114d501
feat(compiler-vapor): support implicit prop in template
sxzz Nov 13, 2024
fab9917
fix(runtime-vapor): component self-reference
sxzz Nov 13, 2024
5f92ff8
feat(vapor): dynamic component
sxzz Nov 13, 2024
39f85ec
fix(runtime-vapor): don't overridden attrs in static template
sxzz Nov 13, 2024
f85ac40
chore(compiler-vapor): fix type error
sxzz Nov 13, 2024
c915865
feat(runtime-vapor): fallback component (#232)
sxzz Nov 13, 2024
2476176
feat(vapor): merge inherited attrs with current attrs
sxzz Nov 14, 2024
af75b64
feat: scope id for child component
sxzz Nov 14, 2024
7a98f4b
fix(runtime-vapor): invoke getter for static attrs
sxzz Nov 14, 2024
faa3e2c
fix(runtime-vapor): `v-if` with inherit attrs
sxzz Nov 14, 2024
7f3ca46
fix(runtime-vapor): scope id for `v-if`
sxzz Nov 14, 2024
c223eb2
fix(runtime-vapor): switch to fallback when slot is empty
sxzz Nov 14, 2024
3da5ecf
fix(runtime-vapor): add scope id for fallback component
sxzz Nov 14, 2024
59975ed
feat(runtime-vapor): export createBranch
sxzz Nov 14, 2024
30f6eec
refactor(runtime-vapor): re-organize block
sxzz Nov 15, 2024
886440d
test(runtime-vapor): tidy custom directives test
sxzz Nov 15, 2024
d845108
refactor(runtime-vapor): extract fallback component
sxzz Nov 15, 2024
f6ce3f9
Merge tag 'v3.5.13'
sxzz Nov 15, 2024
de3a611
fix(runtime-vapor): export types from reactivity
sxzz Nov 15, 2024
4078206
fix(runtime-vapor): attach scope id only to root sub-element
sxzz Nov 15, 2024
0c7817c
fix(compiler-vapor): stringify number prop value
sxzz Nov 15, 2024
81b3d36
fix(vapor): destructure in `v-for`
sxzz Nov 15, 2024
3f6ce96
feat(vapor): support more magic vars
sxzz Nov 15, 2024
9a2158d
refactor(vapor): drop `v-memo` (#288)
sxzz Nov 17, 2024
e61cedf
perf(runtime-vapor): use `setAttr` or `setDOMProp` instead of `setDyn…
edison1105 Nov 27, 2024
f0361ba
perf(runtime-vapor): `setup()` returning object is only needed in __D…
LittleSound Nov 30, 2024
842f94c
perf(vapor): improve component instantiation by using class
yyx990803 Dec 1, 2024
0196e1a
perf(runtime-vapor): optimize `setDOMProp` on static tag + key (#294)
edison1105 Dec 1, 2024
f0a8bfd
chore: fix test
yyx990803 Dec 1, 2024
516d4ed
chore: revert temporarily commented lines
yyx990803 Dec 1, 2024
d6415d8
chore: use actual production build for playground build and preview
yyx990803 Dec 1, 2024
5828f24
perf: use class for SetupContext
yyx990803 Dec 1, 2024
a3edc27
chore: remove unnecessary config in dev config [ci skip]
yyx990803 Dec 1, 2024
0acafc7
wip: save
yyx990803 Dec 2, 2024
41c18ef
wip: props handling
yyx990803 Dec 2, 2024
f3b9070
chore: disable modulePreload
yyx990803 Dec 2, 2024
0986051
chore: avoid toHandlers not treeshaken
yyx990803 Dec 2, 2024
435ca32
wip: props casting
yyx990803 Dec 2, 2024
1636dce
wip: inheritAttrs
yyx990803 Dec 2, 2024
f8046a3
wip: attr fallthrough
yyx990803 Dec 3, 2024
783d8b4
refactor: reuse props logic from core
yyx990803 Dec 3, 2024
9d89d7a
refactor: expose scheduler for vapor
yyx990803 Dec 3, 2024
4ea6677
wip: filter emits
yyx990803 Dec 3, 2024
72d8235
refactor: make core warning and errorHandling vdom/vapor generic
yyx990803 Dec 3, 2024
65fc976
wip: emits
yyx990803 Dec 3, 2024
e88c4e2
chore: playground
yyx990803 Dec 3, 2024
cc2439c
wip: vapor warning context integration
yyx990803 Dec 4, 2024
4fe05bd
wip(vapor): reuse createApp from core
yyx990803 Dec 4, 2024
c73ee16
refactor: remove runtime-shared
yyx990803 Dec 4, 2024
3a6915b
refactor: remove @vue/vapor package
yyx990803 Dec 4, 2024
b1b3bae
wip: make sfc playground work after refactor + support dev mode
yyx990803 Dec 4, 2024
59b1aed
chore: notes
yyx990803 Dec 4, 2024
23ba438
wip(vapor): align compiler with new props runtime behavior
yyx990803 Dec 4, 2024
52fabd5
chore: vapor playground preview script
yyx990803 Dec 4, 2024
33d1b8b
wip: use proxy for static props too
yyx990803 Dec 4, 2024
caca46b
wip: fix value casting
yyx990803 Dec 4, 2024
004e23f
wip: cache normalized options for dev check
yyx990803 Dec 4, 2024
8725954
wip: should resolve dynamic props first + optimize ownKeys
yyx990803 Dec 5, 2024
93a16af
wip: vapor component props validation
yyx990803 Dec 5, 2024
fc9aa62
wip: handle props case matching
yyx990803 Dec 5, 2024
4baaa7b
wip: optimize props validation
yyx990803 Dec 5, 2024
ee7a93d
refactor: split current instance logic to separate file
yyx990803 Dec 5, 2024
e23a6a8
wip: unify currentInstance between vdom and vapor + provide/inject
yyx990803 Dec 5, 2024
ebe7871
wip(vapor): mounted/beforeMounted lifecycle hooks
yyx990803 Dec 5, 2024
5d86027
chore: disable options api in playground
yyx990803 Dec 5, 2024
30e24ce
wip(vapor): updated/beforeUpdate
yyx990803 Dec 5, 2024
300bb08
wip: fix all runtime-core type errors
yyx990803 Dec 5, 2024
ae5ec07
wip: component with fallback
yyx990803 Dec 6, 2024
e60ec9f
wip: proxy refs on setup ctx during dev
yyx990803 Dec 6, 2024
f6f3f14
chore: update playground vapor welcome
yyx990803 Dec 6, 2024
238d181
wip: get instance from rawProps to fix proxy handler caching
yyx990803 Dec 6, 2024
685f782
wip: fix props/attrs bugs
yyx990803 Dec 6, 2024
3ef1656
wip: slots proxy
yyx990803 Dec 6, 2024
68aa9bd
wip: respect rootProps in createVaporApp
yyx990803 Dec 6, 2024
db3151b
wip: avoid including vdom-only public properties map in bundle
yyx990803 Dec 6, 2024
91fc0d1
chore: minify config for playground
yyx990803 Dec 6, 2024
8331aa4
wip: avoid proxy when slots are static
yyx990803 Dec 6, 2024
4b61006
wip: slots
yyx990803 Dec 7, 2024
e6d4a24
wip: adjust slots codegen
yyx990803 Dec 7, 2024
aa96762
wip: dynamic slots
yyx990803 Dec 7, 2024
407b9ab
chore: BlockFn
yyx990803 Dec 7, 2024
f413e00
chore: element -> node
yyx990803 Dec 7, 2024
f8a7046
wip: slot props
yyx990803 Dec 8, 2024
9a8645d
wip: adjust slot props compilation
yyx990803 Dec 8, 2024
7e8edcd
build: add runtime-with-vapor format + fix sfc playground for vapor mode
yyx990803 Dec 8, 2024
d376f00
build: trim vapor intenral helper exports form runtime-core in non-es…
yyx990803 Dec 8, 2024
30a7e79
chore: fix playground import
yyx990803 Dec 8, 2024
6f5493c
wip: make dev mode work for sfc generated code
yyx990803 Dec 8, 2024
e8067f1
wip: prepare hmr for vapor
yyx990803 Dec 8, 2024
6c40186
chore: fix vdom slots currentInstance
yyx990803 Dec 8, 2024
4833c1c
wip: vapor hmr rerender
yyx990803 Dec 8, 2024
6f44934
build: fix esm-bundler vapor re-exports
yyx990803 Dec 8, 2024
bb0787b
wip: prepare hmr reload
yyx990803 Dec 8, 2024
83be45e
wip: optimize vapor currentInstance setting
yyx990803 Dec 8, 2024
4f613dc
chore: remove vue/vapor
yyx990803 Dec 8, 2024
ac5f1cf
chore: fix vapor playground tsconfig
yyx990803 Dec 8, 2024
366dcb7
wip: vapor app.unmount + unmounted hooks
yyx990803 Dec 8, 2024
54c29ab
wip: vapor hmr reload
yyx990803 Dec 8, 2024
f2b69d7
chore: remove non-function-related changes from vapor branch
yyx990803 Nov 11, 2024
4df4624
chore: make vapor compiler tests pass
yyx990803 Dec 9, 2024
edde81c
wip: respect inheritAttrs
yyx990803 Dec 9, 2024
2b05c1e
wip: remove setInheritAttrs codegen
yyx990803 Dec 9, 2024
2bbb6d2
fix(scheduler): recover nextTick from error in post flush cb
yyx990803 Dec 9, 2024
ec23ab9
test(vapor): renderEffect
yyx990803 Dec 9, 2024
b7aec13
test(vapor): block tests
yyx990803 Dec 9, 2024
ac43b11
fix(reactivity): toRefs should be allowed on plain objects
yyx990803 Dec 9, 2024
8540ee4
test(vapor): componentProps
yyx990803 Dec 9, 2024
527905a
test(vapor): errorHandling
yyx990803 Dec 9, 2024
ab6f75d
test(vapor): skip todo tests
yyx990803 Dec 9, 2024
c2ff3bd
chore: fix compat props default test
yyx990803 Dec 10, 2024
017c860
build: fix mutli format build script
yyx990803 Dec 10, 2024
dc90783
chore: fix sfc playground build
yyx990803 Dec 10, 2024
08c4967
wip: avoid iife for vapor prod mode
yyx990803 Dec 10, 2024
443ac60
chore: remove stale test lines
yyx990803 Dec 10, 2024
48fc65f
test(vapor): apiCreateVaporApp
yyx990803 Dec 10, 2024
89707e8
test(vapor): inject
yyx990803 Dec 10, 2024
c2e7312
test(vapor): lifecycle (partial)
yyx990803 Dec 10, 2024
217e1e6
wip(vapor): make createComponent rawProps/rawSlots accept wider types…
yyx990803 Dec 10, 2024
baf68a0
test(vapor): apiSetupContext
yyx990803 Dec 10, 2024
12ef121
test(vapor): api expose (partial)
yyx990803 Dec 10, 2024
4366a7e
test(vapor): apiWatch
yyx990803 Dec 10, 2024
25989f6
chore: update compiler-vapor inline mode snapshots
yyx990803 Dec 10, 2024
a1276f7
test(vapor): componentAttrs
yyx990803 Dec 10, 2024
5648dda
test(vapor): componentEmits
yyx990803 Dec 10, 2024
7f3b883
chore: make types pass in vapor directive tests
yyx990803 Dec 10, 2024
dff54a1
test(vapor): componentSlots
yyx990803 Dec 10, 2024
b191beb
chore: fix vapor apiExpose test
yyx990803 Dec 10, 2024
dbdc0aa
chore: make compile type consistent
yyx990803 Dec 10, 2024
92526b0
chore: fix dts build
yyx990803 Dec 11, 2024
23fe7f9
chore: make type check pass
yyx990803 Dec 11, 2024
4e17b0b
chore: disable continuous release for vapor for now
yyx990803 Dec 11, 2024
1bb9a0f
refactor: drop recordPropMetadata + merge renderEffect (#301)
edison1105 Dec 11, 2024
64e007e
chore: Merge branch 'main' into vapor
yyx990803 Dec 11, 2024
e41858c
chore: todos
yyx990803 Dec 11, 2024
badd995
ci: fix continuous release vapor skip
yyx990803 Dec 11, 2024
dfe06f8
wip: cache setProp prev value on element, simplify codegen
yyx990803 Dec 11, 2024
4505727
wip: refactor vapor vBind codegen
yyx990803 Dec 12, 2024
c4b853d
chore: remove no longer needed file
yyx990803 Dec 12, 2024
e388053
chore: fix setStyle and tests
yyx990803 Dec 12, 2024
0d1df25
wip(vapor): templateRef adjustments
yyx990803 Dec 12, 2024
023f72f
test(vapor): useTemplateRef tests
yyx990803 Dec 13, 2024
4160b6d
test(vapor): fix templateRef compiler tests
yyx990803 Dec 13, 2024
f9a6e8c
wip(vapor): handle class / style merging behavior
yyx990803 Dec 13, 2024
c07734d
wip(vapor): further tweak single root attr fallthrough behavior
yyx990803 Dec 13, 2024
76e8d2c
wip(vapor): init feature flags + set devtools when creating vapor app
yyx990803 Dec 14, 2024
bcb9209
wip(vapor): optimize unmounted children removal
yyx990803 Dec 14, 2024
4318129
wip(vapor): createIf
yyx990803 Dec 14, 2024
6c0e8a8
wip(vapor): handle slot fallback when content changes
yyx990803 Dec 14, 2024
e79a6df
fix(vapor/defineProps): register type bindings before compile templat…
edison1105 Dec 16, 2024
bd13001
refactor(vapor): import v-o withModifiers or withKeys on demand (#12539)
edison1105 Dec 16, 2024
ef6986f
refactor(compiler-vapor): move operation with constant values out of …
edison1105 Dec 16, 2024
757b3df
refactor(compiler-vapor): cache inline handlers passed to component (…
edison1105 Jan 8, 2025
58b4974
refactor(compiler-vapor): cache multiple access to the same expressio…
edison1105 Jan 8, 2025
20cd429
fix(compiler-vapor): once modifier work with component event (#12606)
edison1105 Jan 8, 2025
679cbdf
fix(reactivity): ensure multiple effectScope `on()` and `off()` calls…
edison1105 Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: ./.github/workflows/test.yml

continuous-release:
if: github.repository == 'vuejs/core'
if: github.repository == 'vuejs/core' && github.ref_name != 'vapor'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/*
144 changes: 144 additions & 0 deletions benchmark/client/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<script setup lang="ts" vapor>
import {
shallowRef,
triggerRef,
type ShallowRef,
createSelector,
} from 'vue/vapor'
import { buildData } from './data'
import { defer, wrap } from './profiling'

const isVapor = !!import.meta.env.IS_VAPOR

const selected = shallowRef<number>()
const rows = shallowRef<
{
id: number
label: ShallowRef<string>
}[]
>([])

// Bench Add: https://jsbench.me/45lzxprzmu/1
const add = wrap('add', () => {
rows.value.push(...buildData(1000))
triggerRef(rows)
})

const remove = wrap('remove', (id: number) => {
rows.value.splice(
rows.value.findIndex(d => d.id === id),
1,
)
triggerRef(rows)
})

const select = wrap('select', (id: number) => {
selected.value = id
})

const run = wrap('run', () => {
rows.value = buildData()
selected.value = undefined
})

const update = wrap('update', () => {
const _rows = rows.value
for (let i = 0, len = _rows.length; i < len; i += 10) {
_rows[i].label.value += ' !!!'
}
})

const runLots = wrap('runLots', () => {
rows.value = buildData(10000)
selected.value = undefined
})

const clear = wrap('clear', () => {
rows.value = []
selected.value = undefined
})

const swapRows = wrap('swap', () => {
const _rows = rows.value
if (_rows.length > 998) {
const d1 = _rows[1]
const d998 = _rows[998]
_rows[1] = d998
_rows[998] = d1
triggerRef(rows)
}
})

async function bench() {
for (let i = 0; i < 30; i++) {
rows.value = []
await runLots()
await defer()
}
}

const isSelected = createSelector(selected)

const globalThis = window
</script>

<template>
<h1>Vue.js ({{ isVapor ? 'Vapor' : 'Virtual DOM' }}) Benchmark</h1>

<div style="display: flex; gap: 4px; margin-bottom: 4px">
<label>
<input
type="checkbox"
:value="globalThis.doProfile"
@change="globalThis.doProfile = $event.target.checked"
/>
Profiling
</label>
<label>
<input
type="checkbox"
:value="globalThis.reactivity"
@change="globalThis.reactivity = $event.target.checked"
/>
Reactivity Cost
</label>
</div>

<div
id="control"
style="display: flex; flex-direction: column; width: fit-content; gap: 6px"
>
<button @click="bench">Benchmark mounting</button>
<button id="run" @click="run">Create 1,000 rows</button>
<button id="runLots" @click="runLots">Create 10,000 rows</button>
<button id="add" @click="add">Append 1,000 rows</button>
<button id="update" @click="update">Update every 10th row</button>
<button id="clear" @click="clear">Clear</button>
<button id="swaprows" @click="swapRows">Swap Rows</button>
</div>
<div id="time"></div>
<table>
<tbody>
<tr
v-for="row of rows"
:key="row.id"
:class="{ danger: isSelected(row.id) }"
>
<td>{{ row.id }}</td>
<td>
<a @click="select(row.id)">{{ row.label.value }}</a>
</td>
<td>
<button @click="remove(row.id)">x</button>
</td>
<td class="col-md-6"></td>
</tr>
</tbody>
</table>
</template>

<style>
.danger {
background-color: red;
}
</style>
78 changes: 78 additions & 0 deletions benchmark/client/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { shallowRef } from 'vue/vapor'

let ID = 1

function _random(max: number) {
return Math.round(Math.random() * 1000) % max
}

export function buildData(count = 1000) {
const adjectives = [
'pretty',
'large',
'big',
'small',
'tall',
'short',
'long',
'handsome',
'plain',
'quaint',
'clean',
'elegant',
'easy',
'angry',
'crazy',
'helpful',
'mushy',
'odd',
'unsightly',
'adorable',
'important',
'inexpensive',
'cheap',
'expensive',
'fancy',
]
const colours = [
'red',
'yellow',
'blue',
'green',
'pink',
'brown',
'purple',
'brown',
'white',
'black',
'orange',
]
const nouns = [
'table',
'chair',
'house',
'bbq',
'desk',
'car',
'pony',
'cookie',
'sandwich',
'burger',
'pizza',
'mouse',
'keyboard',
]
const data = []
for (let i = 0; i < count; i++)
data.push({
id: ID++,
label: shallowRef(
adjectives[_random(adjectives.length)] +
' ' +
colours[_random(colours.length)] +
' ' +
nouns[_random(nouns.length)],
),
})
return data
}
17 changes: 17 additions & 0 deletions benchmark/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue Vapor Benchmark</title>
<style>
html {
color-scheme: light dark;
}
</style>
</head>
<body class="done">
<div id="app"></div>
<script type="module" src="./index.ts"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions benchmark/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (import.meta.env.IS_VAPOR) {
import('./vapor')
} else {
import('./vdom')
}
94 changes: 94 additions & 0 deletions benchmark/client/profiling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* eslint-disable no-console */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-restricted-globals */

import { nextTick } from 'vue/vapor'

declare namespace globalThis {
let doProfile: boolean
let reactivity: boolean
let recordTime: boolean
let times: Record<string, number[]>
}

globalThis.recordTime = true
globalThis.doProfile = false
globalThis.reactivity = false

export const defer = () => new Promise(r => requestIdleCallback(r))

const times: Record<string, number[]> = (globalThis.times = {})

export function wrap(
id: string,
fn: (...args: any[]) => any,
): (...args: any[]) => Promise<void> {
return async (...args) => {
if (!globalThis.recordTime) {
return fn(...args)
}

document.body.classList.remove('done')

const { doProfile } = globalThis
await nextTick()

doProfile && console.profile(id)
const start = performance.now()
fn(...args)

await nextTick()
let time: number
if (globalThis.reactivity) {
time = performance.measure(
'flushJobs-measure',
'flushJobs-start',
'flushJobs-end',
).duration
performance.clearMarks()
performance.clearMeasures()
} else {
time = performance.now() - start
}
const prevTimes = times[id] || (times[id] = [])
prevTimes.push(time)

const { min, max, median, mean, std } = compute(prevTimes)
const msg =
`${id}: min: ${min} / ` +
`max: ${max} / ` +
`median: ${median}ms / ` +
`mean: ${mean}ms / ` +
`time: ${time.toFixed(2)}ms / ` +
`std: ${std} ` +
`over ${prevTimes.length} runs`
doProfile && console.profileEnd(id)
console.log(msg)
const timeEl = document.getElementById('time')!
timeEl.textContent = msg

document.body.classList.add('done')
}
}

function compute(array: number[]) {
const n = array.length
const max = Math.max(...array)
const min = Math.min(...array)
const mean = array.reduce((a, b) => a + b) / n
const std = Math.sqrt(
array.map(x => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n,
)
const median = array.slice().sort((a, b) => a - b)[Math.floor(n / 2)]
return {
max: round(max),
min: round(min),
mean: round(mean),
std: round(std),
median: round(median),
}
}

function round(n: number) {
return +n.toFixed(2)
}
4 changes: 4 additions & 0 deletions benchmark/client/vapor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createVaporApp } from 'vue/vapor'
import App from './App.vue'

createVaporApp(App as any).mount('#app')
4 changes: 4 additions & 0 deletions benchmark/client/vdom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')
Loading
Loading