Skip to content

Commit 3a6915b

Browse files
committed
refactor: remove @vue/vapor package
1 parent c73ee16 commit 3a6915b

32 files changed

+41
-826
lines changed

benchmark/client/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
triggerRef,
55
type ShallowRef,
66
createSelector,
7-
} from '@vue/vapor'
7+
} from 'vue/vapor'
88
import { buildData } from './data'
99
import { defer, wrap } from './profiling'
1010

benchmark/client/data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { shallowRef } from '@vue/vapor'
1+
import { shallowRef } from 'vue/vapor'
22

33
let ID = 1
44

benchmark/client/profiling.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable no-restricted-syntax */
33
/* eslint-disable no-restricted-globals */
44

5-
import { nextTick } from '@vue/vapor'
5+
import { nextTick } from 'vue/vapor'
66

77
declare namespace globalThis {
88
let doProfile: boolean

benchmark/client/vapor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createVaporApp } from '@vue/vapor'
1+
import { createVaporApp } from 'vue/vapor'
22
import App from './App.vue'
33

44
createVaporApp(App as any).mount('#app')

benchmark/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ async function buildApp(isVapor) {
179179
},
180180
resolve: {
181181
alias: {
182-
'@vue/vapor': runtimePath,
183182
'vue/vapor': runtimePath,
184183
vue: runtimePath,
185184
},

benchmark/tsconfig.json

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
"noEmit": true,
1919
"paths": {
2020
"vue": ["../packages/vue/src"],
21-
"@vue/vapor": ["../packages/vue-vapor/src"],
22-
"vue/vapor": ["../packages/vue-vapor/src"],
2321
"@vue/*": ["../packages/*/src"]
2422
}
2523
},

packages/runtime-dom/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,17 @@ function injectCompilerOptionsCheck(app: App) {
230230
/**
231231
* @internal
232232
*/
233-
export function normalizeContainer(
234-
container: Element | ShadowRoot | string,
235-
): Element | ShadowRoot | null {
233+
export function normalizeContainer<T extends ParentNode>(
234+
container: T | string,
235+
): T | null {
236236
if (isString(container)) {
237237
const res = document.querySelector(container)
238238
if (__DEV__ && !res) {
239239
warn(
240240
`Failed to mount app: mount target selector "${container}" returned null.`,
241241
)
242242
}
243-
return res
243+
return res as any
244244
}
245245
if (
246246
__DEV__ &&

packages/runtime-vapor/src/apiCreateApp.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { normalizeContainer } from './_old/apiRender'
21
import { insert } from './dom/element'
32
import { type VaporComponent, createComponent } from './component'
43
import {
54
type AppMountFn,
65
type AppUnmountFn,
76
type CreateAppFunction,
87
createAppAPI,
9-
} from '@vue/runtime-core'
8+
normalizeContainer,
9+
} from '@vue/runtime-dom'
1010

1111
let _createApp: CreateAppFunction<ParentNode, VaporComponent>
1212

@@ -32,7 +32,7 @@ export const createVaporApp: CreateAppFunction<
3232
const app = _createApp(comp)
3333
const mount = app.mount
3434
app.mount = (container, ...args: any[]) => {
35-
container = normalizeContainer(container) // TODO reuse from runtime-dom
35+
container = normalizeContainer(container) as ParentNode
3636
return mount(container, ...args)
3737
}
3838
return app

packages/runtime-vapor/src/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
nextUid,
1212
popWarningContext,
1313
pushWarningContext,
14-
} from '@vue/runtime-core'
14+
} from '@vue/runtime-dom'
1515
import type { Block } from './block'
1616
import { pauseTracking, resetTracking } from '@vue/reactivity'
1717
import { EMPTY_OBJ, isFunction } from '@vue/shared'

packages/runtime-vapor/src/componentEmits.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
type EmitFn,
33
type ObjectEmitsOptions,
44
baseEmit,
5-
} from '@vue/runtime-core'
5+
} from '@vue/runtime-dom'
66
import {
77
type VaporComponent,
88
type VaporComponentInstance,

packages/runtime-vapor/src/componentProps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
baseNormalizePropsOptions,
66
isEmitListener,
77
resolvePropValue,
8-
} from '@vue/runtime-core'
8+
} from '@vue/runtime-dom'
99
import { normalizeEmitsOptions } from './componentEmits'
1010

1111
export interface RawProps {

packages/runtime-vapor/src/dom/prop.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import {
1212
shouldSetAsAttr,
1313
toDisplayString,
1414
} from '@vue/shared'
15-
import { warn } from '../_old/warning'
1615
import { setStyle } from './style'
1716
import {
1817
MetadataKind,
1918
getMetadata,
2019
recordPropMetadata,
2120
} from '../componentMetadata'
2221
import { on } from './event'
23-
import { currentInstance } from '../_old/component'
22+
import { currentInstance } from '../component'
23+
import { warn } from '@vue/runtime-dom'
2424

2525
export function mergeInheritAttr(key: string, value: any): unknown {
2626
const instance = currentInstance!

packages/runtime-vapor/src/dom/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
isString,
77
normalizeStyle,
88
} from '@vue/shared'
9-
import { warn } from '../_old/warning'
9+
import { warn } from '@vue/runtime-dom'
1010
import { recordPropMetadata } from '../componentMetadata'
1111
import { mergeInheritAttr } from './prop'
1212

packages/runtime-vapor/src/dom/templateRef.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { type Ref, isRef, onScopeDispose } from '@vue/reactivity'
22
import {
3-
type ComponentInternalInstance,
3+
type VaporComponentInstance,
44
currentInstance,
55
isVaporComponent,
6-
} from '../_old/component'
7-
import { VaporErrorCodes, callWithErrorHandling } from '../_old/errorHandling'
6+
} from '../component'
7+
import {
8+
type SchedulerJob,
9+
callWithErrorHandling,
10+
queuePostFlushCb,
11+
warn,
12+
} from '@vue/runtime-dom'
813
import {
914
EMPTY_OBJ,
1015
hasOwn,
@@ -13,11 +18,9 @@ import {
1318
isString,
1419
remove,
1520
} from '@vue/shared'
16-
import { warn } from '../_old/warning'
17-
import { type SchedulerJob, queuePostFlushCb } from '../_old/scheduler'
1821

1922
export type NodeRef = string | Ref | ((ref: Element) => void)
20-
export type RefEl = Element | ComponentInternalInstance
23+
export type RefEl = Element | VaporComponentInstance
2124

2225
/**
2326
* Function for handling a template ref
@@ -29,6 +32,7 @@ export function setRef(
2932
refFor = false,
3033
): NodeRef | undefined {
3134
if (!currentInstance) return
35+
// @ts-expect-error TODO
3236
const { setupState, isUnmounted } = currentInstance
3337

3438
if (isUnmounted) {
@@ -46,7 +50,7 @@ export function setRef(
4650
if (oldRef != null && oldRef !== ref) {
4751
if (isString(oldRef)) {
4852
refs[oldRef] = null
49-
if (hasOwn(setupState, oldRef)) {
53+
if (setupState && hasOwn(setupState, oldRef)) {
5054
setupState[oldRef] = null
5155
}
5256
} else if (isRef(oldRef)) {
@@ -59,7 +63,8 @@ export function setRef(
5963
callWithErrorHandling(
6064
ref,
6165
currentInstance,
62-
VaporErrorCodes.FUNCTION_REF,
66+
// @ts-expect-error
67+
null,
6368
[value, refs],
6469
)
6570
}
@@ -126,7 +131,7 @@ export function setRef(
126131
})
127132
})
128133
} else if (__DEV__) {
129-
warn('Invalid template ref type:', ref, `(${typeof ref})`)
134+
// warn('Invalid template ref type:', ref, `(${typeof ref})`)
130135
}
131136
}
132137
return ref

packages/runtime-vapor/src/renderEffect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactiveEffect } from '@vue/reactivity'
2-
import { type SchedulerJob, queueJob } from '@vue/runtime-core'
2+
import { type SchedulerJob, queueJob } from '@vue/runtime-dom'
33
import { currentInstance } from './component'
44

55
export function renderEffect(fn: () => void): void {

packages/vue-vapor/LICENSE

-21
This file was deleted.

packages/vue-vapor/README.md

-1
This file was deleted.

0 commit comments

Comments
 (0)