Merge remote-tracking branch 'origin/main' into minor

This commit is contained in:
daiwei 2025-03-29 13:51:19 +08:00
commit d523d24ac0
23 changed files with 943 additions and 822 deletions

View File

@ -37,7 +37,7 @@ jobs:
run: pnpm install
- name: Download Size Data
uses: dawidd6/action-download-artifact@v7
uses: dawidd6/action-download-artifact@v9
with:
name: size-data
run_id: ${{ github.event.workflow_run.id }}
@ -56,7 +56,7 @@ jobs:
path: temp/size/base.txt
- name: Download Previous Size Data
uses: dawidd6/action-download-artifact@v7
uses: dawidd6/action-download-artifact@v9
with:
branch: ${{ steps.pr-base.outputs.content }}
workflow: size-data.yml

View File

@ -44,7 +44,9 @@ Please make sure to read the [Contributing Guide](https://github.com/vuejs/core/
Thank you to all the people who already contributed to Vue!
<a href="https://github.com/vuejs/core/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
<a href="https://github.com/vuejs/core/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890&limit=500" /></a>
<sub>_Note: Showing the first 500 contributors only due to GitHub image size limitations_</sub>
## License

View File

@ -1,3 +1,3 @@
[build.environment]
NODE_VERSION = "18"
NODE_VERSION = "22"
NPM_FLAGS = "--version" # prevent Netlify npm install

View File

@ -1,7 +1,7 @@
{
"private": true,
"version": "3.5.13",
"packageManager": "pnpm@10.4.1",
"packageManager": "pnpm@10.6.5",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
@ -65,52 +65,52 @@
"@babel/parser": "catalog:",
"@babel/types": "catalog:",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-replace": "5.0.4",
"@swc/core": "^1.10.16",
"@swc/core": "^1.11.12",
"@types/hash-sum": "^1.0.2",
"@types/node": "^22.13.4",
"@types/node": "^22.13.13",
"@types/semver": "^7.5.8",
"@types/serve-handler": "^6.1.4",
"@vitest/coverage-v8": "^3.0.5",
"@vitest/eslint-plugin": "^1.1.31",
"@vitest/coverage-v8": "^3.0.9",
"@vitest/eslint-plugin": "^1.1.38",
"@vue/consolidate": "1.0.0",
"conventional-changelog-cli": "^5.0.0",
"enquirer": "^2.4.1",
"esbuild": "^0.25.0",
"esbuild": "^0.25.1",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^9.20.1",
"eslint-plugin-import-x": "^4.6.1",
"eslint": "^9.23.0",
"eslint-plugin-import-x": "^4.9.1",
"estree-walker": "catalog:",
"jsdom": "^26.0.0",
"lint-staged": "^15.4.3",
"lint-staged": "^15.5.0",
"lodash": "^4.17.21",
"magic-string": "^0.30.17",
"markdown-table": "^3.0.4",
"marked": "13.0.3",
"npm-run-all2": "^7.0.2",
"picocolors": "^1.1.1",
"prettier": "^3.5.1",
"prettier": "^3.5.3",
"pretty-bytes": "^6.1.1",
"pug": "^3.0.3",
"puppeteer": "~24.2.1",
"puppeteer": "~24.4.0",
"rimraf": "^6.0.1",
"rollup": "^4.34.7",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.2.0",
"rollup": "^4.37.0",
"rollup-plugin-dts": "^6.2.1",
"rollup-plugin-esbuild": "^6.2.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"semver": "^7.7.1",
"serve": "^14.2.4",
"serve-handler": "^6.1.6",
"simple-git-hooks": "^2.11.1",
"simple-git-hooks": "^2.12.1",
"todomvc-app-css": "^2.4.3",
"tslib": "^2.8.1",
"typescript": "~5.6.2",
"typescript-eslint": "^8.24.0",
"typescript-eslint": "^8.27.0",
"vite": "catalog:",
"vitest": "^3.0.5"
"vitest": "^3.0.9"
},
"pnpm": {
"peerDependencyRules": {

View File

@ -9,7 +9,7 @@ app.directive<HTMLElement, string, 'prevent' | 'stop', 'arg1' | 'arg2'>(
mounted(el, binding) {
expectType<HTMLElement>(el)
expectType<string>(binding.value)
expectType<{ prevent: boolean; stop: boolean }>(binding.modifiers)
expectType<{ prevent?: boolean; stop?: boolean }>(binding.modifiers)
expectType<'arg1' | 'arg2'>(binding.arg!)
// @ts-expect-error not any

View File

@ -12,8 +12,11 @@ app.use(PluginWithoutType, 2)
app.use(PluginWithoutType, { anything: 'goes' }, true)
type PluginOptions = {
/** option1 */
option1?: string
/** option2 */
option2: number
/** option3 */
option3: boolean
}
@ -25,6 +28,20 @@ const PluginWithObjectOptions = {
},
}
const objectPluginOptional = {
install(app: App, options?: PluginOptions) {},
}
app.use(objectPluginOptional)
app.use(
objectPluginOptional,
// Test JSDoc and `go to definition` for options
{
option1: 'foo',
option2: 1,
option3: true,
},
)
for (const Plugin of [
PluginWithObjectOptions,
PluginWithObjectOptions.install,
@ -92,7 +109,27 @@ const PluginTyped: Plugin<PluginOptions> = (app, options) => {}
// @ts-expect-error: needs options
app.use(PluginTyped)
app.use(PluginTyped, { option2: 2, option3: true })
app.use(
PluginTyped,
// Test autocomplete for options
{
option1: '',
option2: 2,
option3: true,
},
)
const functionPluginOptional = (app: App, options?: PluginOptions) => {}
app.use(functionPluginOptional)
app.use(functionPluginOptional, { option2: 2, option3: true })
// type optional params
const functionPluginOptional2: Plugin<[options?: PluginOptions]> = (
app,
options,
) => {}
app.use(functionPluginOptional2)
app.use(functionPluginOptional2, { option2: 2, option3: true })
// vuetify usage
const key: string = ''

View File

@ -29,7 +29,7 @@ describe('custom', () => {
value: number
oldValue: number | null
arg?: 'Arg'
modifiers: Record<'a' | 'b', boolean>
modifiers: Partial<Record<'a' | 'b', boolean>>
}>(testDirective<number, 'a' | 'b', 'Arg'>())
expectType<{

View File

@ -4,6 +4,7 @@ import {
type MaybeRefOrGetter,
type Ref,
type ShallowRef,
type TemplateRef,
type ToRefs,
type WritableComputedRef,
computed,
@ -535,7 +536,7 @@ expectType<string>(toValue(unref2))
// useTemplateRef
const tRef = useTemplateRef('foo')
expectType<Readonly<ShallowRef<unknown>>>(tRef)
expectType<TemplateRef>(tRef)
const tRef2 = useTemplateRef<HTMLElement>('bar')
expectType<Readonly<ShallowRef<HTMLElement | null>>>(tRef2)
expectType<TemplateRef<HTMLElement>>(tRef2)

View File

@ -13,7 +13,7 @@
"vite": "catalog:"
},
"dependencies": {
"@vue/repl": "^4.4.3",
"@vue/repl": "^4.5.1",
"file-saver": "^2.0.5",
"jszip": "^3.10.1",
"vue": "workspace:*"

View File

@ -17,7 +17,10 @@ export async function downloadProject(store: ReplStore) {
// basic structure
zip.file('index.html', index)
zip.file('package.json', pkg)
zip.file(
'package.json',
pkg.replace(`"vue": "latest"`, `"vue": "${store.vueVersion || 'latest'}"`),
)
zip.file('vite.config.js', config)
zip.file('README.md', readme)

View File

@ -8,10 +8,10 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.4.0"
"vue": "latest"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"vite": "^6.1.0"
"@vitejs/plugin-vue": "^5.2.3",
"vite": "^6.2.2"
}
}

View File

@ -49,7 +49,7 @@
"@vue/shared": "workspace:*",
"estree-walker": "catalog:",
"magic-string": "catalog:",
"postcss": "^8.5.1",
"postcss": "^8.5.3",
"source-map-js": "catalog:"
},
"devDependencies": {
@ -60,8 +60,8 @@
"merge-source-map": "^1.1.0",
"minimatch": "~10.0.1",
"postcss-modules": "^6.0.1",
"postcss-selector-parser": "^7.0.0",
"postcss-selector-parser": "^7.1.0",
"pug": "^3.0.3",
"sass": "^1.85.0"
"sass": "^1.86.0"
}
}

View File

@ -1,4 +1,4 @@
import { isRef, ref } from '../src/ref'
import { isRef, ref, shallowRef } from '../src/ref'
import {
isProxy,
isReactive,
@ -426,4 +426,17 @@ describe('reactivity/reactive', () => {
map.set(void 0, 1)
expect(c.value).toBe(1)
})
test('should return true for reactive objects', () => {
expect(isReactive(reactive({}))).toBe(true)
expect(isReactive(readonly(reactive({})))).toBe(true)
expect(isReactive(ref({}).value)).toBe(true)
expect(isReactive(readonly(ref({})).value)).toBe(true)
expect(isReactive(shallowReactive({}))).toBe(true)
})
test('should return false for non-reactive objects', () => {
expect(isReactive(ref(true))).toBe(false)
expect(isReactive(shallowRef({}).value)).toBe(false)
})
})

View File

@ -108,9 +108,9 @@ export declare const ShallowReactiveMarker: unique symbol
export type ShallowReactive<T> = T & { [ShallowReactiveMarker]?: true }
/**
* Shallow version of {@link reactive()}.
* Shallow version of {@link reactive}.
*
* Unlike {@link reactive()}, there is no deep conversion: only root-level
* Unlike {@link reactive}, there is no deep conversion: only root-level
* properties are reactive for a shallow reactive object. Property values are
* stored and exposed as-is - this also means properties with ref values will
* not be automatically unwrapped.
@ -178,7 +178,7 @@ export type DeepReadonly<T> = T extends Builtin
* the original.
*
* A readonly proxy is deep: any nested property accessed will be readonly as
* well. It also has the same ref-unwrapping behavior as {@link reactive()},
* well. It also has the same ref-unwrapping behavior as {@link reactive},
* except the unwrapped values will also be made readonly.
*
* @example
@ -215,9 +215,9 @@ export function readonly<T extends object>(
}
/**
* Shallow version of {@link readonly()}.
* Shallow version of {@link readonly}.
*
* Unlike {@link readonly()}, there is no deep conversion: only root-level
* Unlike {@link readonly}, there is no deep conversion: only root-level
* properties are made readonly. Property values are stored and exposed as-is -
* this also means properties with ref values will not be automatically
* unwrapped.
@ -298,8 +298,8 @@ function createReactiveObject(
}
/**
* Checks if an object is a proxy created by {@link reactive()} or
* {@link shallowReactive()} (or {@link ref()} in some cases).
* Checks if an object is a proxy created by {@link reactive} or
* {@link shallowReactive} (or {@link ref} in some cases).
*
* @example
* ```js
@ -327,7 +327,7 @@ export function isReactive(value: unknown): boolean {
* readonly object can change, but they can't be assigned directly via the
* passed object.
*
* The proxies created by {@link readonly()} and {@link shallowReadonly()} are
* The proxies created by {@link readonly} and {@link shallowReadonly} are
* both considered readonly, as is a computed ref without a set function.
*
* @param value - The value to check.
@ -343,7 +343,7 @@ export function isShallow(value: unknown): boolean {
/**
* Checks if an object is a proxy created by {@link reactive},
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly()}.
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
*
* @param value - The value to check.
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
@ -356,8 +356,8 @@ export function isProxy(value: any): boolean {
* Returns the raw, original object of a Vue-created proxy.
*
* `toRaw()` can return the original object from proxies created by
* {@link reactive()}, {@link readonly()}, {@link shallowReactive()} or
* {@link shallowReadonly()}.
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
* {@link shallowReadonly}.
*
* This is an escape hatch that can be used to temporarily read without
* incurring proxy access / tracking overhead or write without triggering
@ -397,7 +397,7 @@ export type Raw<T> = T & { [RawSymbol]?: true }
* ```
*
* **Warning:** `markRaw()` together with the shallow APIs such as
* {@link shallowReactive()} allow you to selectively opt-out of the default
* {@link shallowReactive} allow you to selectively opt-out of the default
* deep reactive/readonly conversion and embed raw, non-proxied objects in your
* state graph.
*

View File

@ -70,7 +70,7 @@ export type ShallowRef<T = any, S = T> = Ref<T, S> & {
}
/**
* Shallow version of {@link ref()}.
* Shallow version of {@link ref}.
*
* @example
* ```js
@ -237,7 +237,7 @@ export function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T {
/**
* Normalizes values / refs / getters to values.
* This is similar to {@link unref()}, except that it also normalizes getters.
* This is similar to {@link unref}, except that it also normalizes getters.
* If the argument is a getter, it will be invoked and its return value will
* be returned.
*
@ -347,7 +347,7 @@ export type ToRefs<T = any> = {
/**
* Converts a reactive object to a plain object where each property of the
* resulting object is a ref pointing to the corresponding property of the
* original object. Each individual ref is created using {@link toRef()}.
* original object. Each individual ref is created using {@link toRef}.
*
* @param object - Reactive object to be made into an object of linked refs.
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}

View File

@ -36,9 +36,9 @@ export interface App<HostElement = any> {
use<Options extends unknown[]>(
plugin: Plugin<Options>,
...options: Options
...options: NoInfer<Options>
): this
use<Options>(plugin: Plugin<Options>, options: Options): this
use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this
mixin(mixin: ComponentOptions): this
component(name: string): Component | undefined
@ -215,9 +215,11 @@ export type ObjectPlugin<Options = any[]> = {
export type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> &
Partial<ObjectPlugin<Options>>
export type Plugin<Options = any[]> =
| FunctionPlugin<Options>
| ObjectPlugin<Options>
export type Plugin<
Options = any[],
// TODO: in next major Options extends unknown[] and remove P
P extends unknown[] = Options extends unknown[] ? Options : [Options],
> = FunctionPlugin<P> | ObjectPlugin<P>
export function createAppContext(): AppContext {
return {

View File

@ -4,6 +4,8 @@ import {
isReadonly,
isRef,
isShallow,
pauseTracking,
resetTracking,
toRaw,
} from '@vue/reactivity'
import { EMPTY_OBJ, extend, isArray, isFunction, isObject } from '@vue/shared'
@ -34,13 +36,16 @@ export function initCustomFormatter(): void {
if (obj.__isVue) {
return ['div', vueStyle, `VueInstance`]
} else if (isRef(obj)) {
// avoid tracking during debugger accessing
pauseTracking()
const value = obj.value
resetTracking()
return [
'div',
{},
['span', vueStyle, genRefFlag(obj)],
'<',
// avoid debugger accessing value affecting behavior
formatValue('_value' in obj ? obj._value : obj),
formatValue(value),
`>`,
]
} else if (isReactive(obj)) {

View File

@ -111,7 +111,9 @@ export type Directive<
| ObjectDirective<HostElement, Value, Modifiers, Arg>
| FunctionDirective<HostElement, Value, Modifiers, Arg>
export type DirectiveModifiers<K extends string = string> = Record<K, boolean>
export type DirectiveModifiers<K extends string = string> = Partial<
Record<K, boolean>
>
export function validateDirectiveName(name: string): void {
if (isBuiltInDirective(name)) {

View File

@ -5,9 +5,11 @@ import { EMPTY_OBJ } from '@vue/shared'
export const knownTemplateRefs: WeakSet<ShallowRef> = new WeakSet()
export type TemplateRef<T = unknown> = Readonly<ShallowRef<T | null>>
export function useTemplateRef<T = unknown, Keys extends string = string>(
key: Keys,
): Readonly<ShallowRef<T | null>> {
): TemplateRef<T> {
const i = getCurrentInstance()
const r = shallowRef(null)
if (i) {

View File

@ -64,7 +64,7 @@ export { defineComponent } from './apiDefineComponent'
export { defineAsyncComponent } from './apiAsyncComponent'
export { useAttrs, useSlots } from './apiSetupHelpers'
export { useModel } from './helpers/useModel'
export { useTemplateRef } from './helpers/useTemplateRef'
export { useTemplateRef, type TemplateRef } from './helpers/useTemplateRef'
export { useId } from './helpers/useId'
export {
hydrateOnIdle,

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,10 @@ packages:
- 'packages-private/*'
catalog:
'@babel/parser': ^7.25.3
'@babel/types': ^7.25.2
'@babel/parser': ^7.26.10
'@babel/types': ^7.26.10
'estree-walker': ^2.0.2
'magic-string': ^0.30.11
'magic-string': ^0.30.17
'source-map-js': ^1.2.1
'vite': ^5.4.14
'@vitejs/plugin-vue': ^5.2.1
'@vitejs/plugin-vue': ^5.2.3

View File

@ -36,7 +36,7 @@ exec('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => {
prodBuild.includes('annotation,annotation-xml,maction')
) {
errors.push(
'prod build contains unexpected domTagConifg lists.\n' +
'prod build contains unexpected domTagConfig lists.\n' +
'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.',
)
}