Skip to content

Commit

Permalink
Merge branch 'main' into renovate/test
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 authored Oct 4, 2024
2 parents b5fcbed + 6e4de8d commit d1a4542
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 148 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [3.5.11](https://github.com/vuejs/core/compare/v3.5.10...v3.5.11) (2024-10-03)


### Bug Fixes

* **compiler-sfc:** do not skip `TSSatisfiesExpression` when transforming props destructure ([#12062](https://github.com/vuejs/core/issues/12062)) ([2328b05](https://github.com/vuejs/core/commit/2328b051f4efa1f1394b7d4e73b7c3f76e430e7c)), closes [#12061](https://github.com/vuejs/core/issues/12061)
* **reactivity:** prevent overwriting `next` property during batch processing ([#12075](https://github.com/vuejs/core/issues/12075)) ([d3f5e6e](https://github.com/vuejs/core/commit/d3f5e6e5319b4ffaa55ca9a2ea3d95d78e76fa58)), closes [#12072](https://github.com/vuejs/core/issues/12072)
* **scheduler:** job ordering when the post queue is flushing ([#12090](https://github.com/vuejs/core/issues/12090)) ([577edca](https://github.com/vuejs/core/commit/577edca8e7795436efd710d1c289ea8ea2642b0e))
* **types:** correctly infer `TypeProps` when it is `any` ([#12073](https://github.com/vuejs/core/issues/12073)) ([57315ab](https://github.com/vuejs/core/commit/57315ab9688c9741a271d1075bbd28cbe5f71e2f)), closes [#12058](https://github.com/vuejs/core/issues/12058)
* **types:** should not intersect `PublicProps` with `Props` ([#12077](https://github.com/vuejs/core/issues/12077)) ([6f85894](https://github.com/vuejs/core/commit/6f8589437635706f825ccec51800effba1d2bf5f))
* **types:** infer the first generic type of `Ref` correctly ([#12094](https://github.com/vuejs/core/issues/12094)) ([c97bb84](https://github.com/vuejs/core/commit/c97bb84d0b0a16b012f886b6498e924415ed63e5))



## [3.5.10](https://github.com/vuejs/core/compare/v3.5.9...v3.5.10) (2024-09-27)


Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "3.5.10",
"version": "3.5.11",
"packageManager": "pnpm@9.12.0",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -94,7 +94,7 @@
"pug": "^3.0.3",
"puppeteer": "~23.5.0",
"rimraf": "^6.0.1",
"rollup": "^4.22.4",
"rollup": "^4.24.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-sfc",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/compiler-sfc",
"main": "dist/compiler-sfc.cjs.js",
"module": "dist/compiler-sfc.esm-browser.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-ssr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-ssr",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/compiler-ssr",
"main": "dist/compiler-ssr.cjs.js",
"types": "dist/compiler-ssr.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/reactivity",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/reactivity",
"main": "index.js",
"module": "dist/reactivity.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/src/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export type DeepReadonly<T> = T extends Builtin
? WeakSet<DeepReadonly<U>>
: T extends Promise<infer U>
? Promise<DeepReadonly<U>>
: T extends Ref<infer U>
: T extends Ref<infer U, unknown>
? Readonly<Ref<DeepReadonly<U>>>
: T extends {}
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
Expand Down
6 changes: 3 additions & 3 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,12 @@ export type ShallowUnwrapRef<T> = {
[K in keyof T]: DistributeRef<T[K]>
}

type DistributeRef<T> = T extends Ref<infer V> ? V : T
type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T

export type UnwrapRef<T> =
T extends ShallowRef<infer V, infer _>
T extends ShallowRef<infer V, unknown>
? V
: T extends Ref<infer V, infer _>
: T extends Ref<infer V, unknown>
? UnwrapRefSimple<V>
: UnwrapRefSimple<T>

Expand Down
54 changes: 54 additions & 0 deletions packages/runtime-core/__tests__/scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,29 @@ describe('scheduler', () => {
await nextTick()
expect(calls).toEqual(['job1', 'job2', 'cb1', 'cb2'])
})

test('jobs added during post flush are ordered correctly', async () => {
const calls: string[] = []

const job1: SchedulerJob = () => {
calls.push('job1')
}
job1.id = 1

const job2: SchedulerJob = () => {
calls.push('job2')
}
job2.id = 2

queuePostFlushCb(() => {
queueJob(job2)
queueJob(job1)
})

await nextTick()

expect(calls).toEqual(['job1', 'job2'])
})
})

test('sort job based on id', async () => {
Expand Down Expand Up @@ -758,6 +781,37 @@ describe('scheduler', () => {
expect(spy).toHaveBeenCalledTimes(1)
})

test('flushPreFlushCbs inside a post job', async () => {
const calls: string[] = []
const callsAfterFlush: string[] = []

const job1: SchedulerJob = () => {
calls.push('job1')
}
job1.id = 1
job1.flags! |= SchedulerJobFlags.PRE

const job2: SchedulerJob = () => {
calls.push('job2')
}
job2.id = 2
job2.flags! |= SchedulerJobFlags.PRE

queuePostFlushCb(() => {
queueJob(job2)
queueJob(job1)

// e.g. nested app.mount() call
flushPreFlushCbs()
callsAfterFlush.push(...calls)
})

await nextTick()

expect(callsAfterFlush).toEqual(['job1', 'job2'])
expect(calls).toEqual(['job1', 'job2'])
})

it('nextTick should return promise', async () => {
const fn = vi.fn(() => {
return 1
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/runtime-core",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/runtime-core",
"main": "index.js",
"module": "dist/runtime-core.esm-bundler.js",
Expand Down
20 changes: 9 additions & 11 deletions packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {
EmitsToProps,
TypeEmitsToOptions,
} from './componentEmits'
import { extend, isFunction } from '@vue/shared'
import { type IsKeyValues, extend, isFunction } from '@vue/shared'
import type { VNodeProps } from './vnode'
import type {
ComponentPublicInstanceConstructor,
Expand Down Expand Up @@ -79,7 +79,7 @@ export type DefineComponent<
Mixin,
Extends,
E,
PP & Props,
PP,
Defaults,
MakeDefaultsOptional,
{},
Expand Down Expand Up @@ -208,15 +208,13 @@ export function defineComponent<
ResolvedEmits extends EmitsOptions = {} extends RuntimeEmitsOptions
? TypeEmitsToOptions<TypeEmits>
: RuntimeEmitsOptions,
InferredProps = unknown extends TypeProps
? keyof TypeProps extends never
? string extends RuntimePropsKeys
? ComponentObjectPropsOptions extends RuntimePropsOptions
? {}
: ExtractPropTypes<RuntimePropsOptions>
: { [key in RuntimePropsKeys]?: any }
: TypeProps
: TypeProps,
InferredProps = IsKeyValues<TypeProps> extends true
? TypeProps
: string extends RuntimePropsKeys
? ComponentObjectPropsOptions extends RuntimePropsOptions
? {}
: ExtractPropTypes<RuntimePropsOptions>
: { [key in RuntimePropsKeys]?: any },
TypeRefs extends Record<string, unknown> = {},
TypeEl extends Element = any,
>(
Expand Down
22 changes: 7 additions & 15 deletions packages/runtime-core/src/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ export interface SchedulerJob extends Function {

export type SchedulerJobs = SchedulerJob | SchedulerJob[]

let isFlushing = false
let isFlushPending = false

const queue: SchedulerJob[] = []
let flushIndex = 0
let flushIndex = -1

const pendingPostFlushCbs: SchedulerJob[] = []
let activePostFlushCbs: SchedulerJob[] | null = null
Expand Down Expand Up @@ -74,7 +71,7 @@ export function nextTick<T = void, R = void>(
// watcher should be inserted immediately before the update job. This allows
// watchers to be skipped if the component is unmounted by the parent update.
function findInsertionIndex(id: number) {
let start = isFlushing ? flushIndex + 1 : 0
let start = flushIndex + 1
let end = queue.length

while (start < end) {
Expand Down Expand Up @@ -115,8 +112,7 @@ export function queueJob(job: SchedulerJob): void {
}

function queueFlush() {
if (!isFlushing && !isFlushPending) {
isFlushPending = true
if (!currentFlushPromise) {
currentFlushPromise = resolvedPromise.then(flushJobs)
}
}
Expand All @@ -141,8 +137,8 @@ export function queuePostFlushCb(cb: SchedulerJobs): void {
export function flushPreFlushCbs(
instance?: ComponentInternalInstance,
seen?: CountMap,
// if currently flushing, skip the current job itself
i: number = isFlushing ? flushIndex + 1 : 0,
// skip the current job
i: number = flushIndex + 1,
): void {
if (__DEV__) {
seen = seen || new Map()
Expand Down Expand Up @@ -211,8 +207,6 @@ const getId = (job: SchedulerJob): number =>
job.id == null ? (job.flags! & SchedulerJobFlags.PRE ? -1 : Infinity) : job.id

function flushJobs(seen?: CountMap) {
isFlushPending = false
isFlushing = true
if (__DEV__) {
seen = seen || new Map()
}
Expand Down Expand Up @@ -255,15 +249,13 @@ function flushJobs(seen?: CountMap) {
}
}

flushIndex = 0
flushIndex = -1
queue.length = 0

flushPostFlushCbs(seen)

isFlushing = false
currentFlushPromise = null
// some postFlushCb queued jobs!
// keep flushing until it drains.
// If new jobs have been added to either queue, keep flushing
if (queue.length || pendingPostFlushCbs.length) {
flushJobs(seen)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/runtime-dom",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/runtime-dom",
"main": "index.js",
"module": "dist/runtime-dom.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/server-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/server-renderer",
"version": "3.5.10",
"version": "3.5.11",
"description": "@vue/server-renderer",
"main": "index.js",
"module": "dist/server-renderer.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/shared",
"version": "3.5.10",
"version": "3.5.11",
"description": "internal utils shared across @vue packages",
"main": "index.js",
"module": "dist/shared.esm-bundler.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/shared/src/typeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export type LooseRequired<T> = { [P in keyof (T & Required<T>)]: T[P] }
// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N

export type IsKeyValues<T, K = string> = IfAny<
T,
false,
T extends object ? (keyof T extends K ? true : false) : false
>

/**
* Utility for extracting the parameters from a function overload (for typed emits)
* https://github.com/microsoft/TypeScript/issues/32164#issuecomment-1146737709
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compat",
"version": "3.5.10",
"version": "3.5.11",
"description": "Vue 3 compatibility build for Vue 2",
"main": "index.js",
"module": "dist/vue.runtime.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue",
"version": "3.5.10",
"version": "3.5.11",
"description": "The progressive JavaScript framework for building modern web UI.",
"main": "index.js",
"module": "dist/vue.runtime.esm-bundler.js",
Expand Down
Loading

0 comments on commit d1a4542

Please sign in to comment.