Skip to content

Commit c73ee16

Browse files
committed
refactor: remove runtime-shared
1 parent 4fe05bd commit c73ee16

File tree

98 files changed

+535
-5308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+535
-5308
lines changed

packages/compiler-vapor/src/ir/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface BaseIRNode {
4343
type: IRNodeTypes
4444
}
4545

46-
export type VaporHelper = keyof typeof import('@vue/runtime-vapor')
46+
export type VaporHelper = keyof typeof import('packages/runtime-vapor/src')
4747

4848
export interface BlockIRNode extends BaseIRNode {
4949
type: IRNodeTypes.BLOCK

packages/runtime-core/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"homepage": "https://github.com/vuejs/vue-vapor/tree/main/packages/runtime-core#readme",
4848
"dependencies": {
4949
"@vue/shared": "workspace:*",
50-
"@vue/reactivity": "workspace:*",
51-
"@vue/runtime-shared": "workspace:*"
50+
"@vue/reactivity": "workspace:*"
5251
}
5352
}

packages/runtime-core/src/apiCreateApp.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
type Component,
33
type ConcreteComponent,
4+
type Data,
45
type GenericComponent,
56
type GenericComponentInstance,
67
getComponentPublicInstance,
@@ -22,7 +23,6 @@ import { warn } from './warning'
2223
import type { VNode } from './vnode'
2324
import { devtoolsInitApp, devtoolsUnmountApp } from './devtools'
2425
import { NO, extend, isFunction, isObject } from '@vue/shared'
25-
import type { Data } from '@vue/runtime-shared'
2626
import { version } from '.'
2727
import { installAppCompatProperties } from './compat/global'
2828
import type { NormalizedPropsOptions } from './componentProps'
@@ -256,8 +256,8 @@ export function createAppContext(): AppContext {
256256
}
257257
}
258258

259-
export type CreateAppFunction<HostElement> = (
260-
rootComponent: GenericComponent,
259+
export type CreateAppFunction<HostElement, Comp = Component> = (
260+
rootComponent: Comp,
261261
rootProps?: Data | null,
262262
) => App<HostElement>
263263

@@ -275,13 +275,13 @@ export type AppUnmountFn = (app: App) => void
275275
/**
276276
* @internal
277277
*/
278-
export function createAppAPI<HostElement>(
278+
export function createAppAPI<HostElement, Comp = Component>(
279279
// render: RootRenderFunction<HostElement>,
280280
// hydrate?: RootHydrateFunction,
281281
mount: AppMountFn<HostElement>,
282282
unmount: AppUnmountFn,
283283
render?: RootRenderFunction,
284-
): CreateAppFunction<HostElement> {
284+
): CreateAppFunction<HostElement, Comp> {
285285
return function createApp(rootComponent, rootProps = null) {
286286
if (!isFunction(rootComponent)) {
287287
rootComponent = extend({}, rootComponent)

packages/runtime-core/src/compat/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ function installCompatMount(
462462
* function simulates that behavior.
463463
*/
464464
app._createRoot = options => {
465-
const component = app._component
465+
const component = app._component as Component
466466
const vnode = createVNode(component, options.propsData || null)
467467
vnode.appContext = context
468468

packages/runtime-core/src/compat/props.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { isArray } from '@vue/shared'
2-
import type { Data } from '@vue/runtime-shared'
32
import { inject } from '../apiInject'
4-
import type { ComponentInternalInstance } from '../component'
3+
import type { ComponentInternalInstance, Data } from '../component'
54
import {
65
type ComponentOptions,
76
resolveMergedOptions,

packages/runtime-core/src/compat/renderFn.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import {
1010
normalizeStyle,
1111
toHandlerKey,
1212
} from '@vue/shared'
13-
import type { Data } from '@vue/runtime-shared'
1413
import type {
1514
Component,
1615
ComponentInternalInstance,
1716
ComponentOptions,
17+
Data,
1818
InternalRenderFunction,
1919
} from '../component'
2020
import { currentRenderingInstance } from '../componentRenderContext'

packages/runtime-core/src/compat/renderHelpers.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import {
77
isReservedProp,
88
normalizeClass,
99
} from '@vue/shared'
10-
import type { ComponentInternalInstance } from '../component'
10+
import type { ComponentInternalInstance, Data } from '../component'
1111
import type { Slot } from '../componentSlots'
1212
import { createSlots } from '../helpers/createSlots'
1313
import { renderSlot } from '../helpers/renderSlot'
1414
import { toHandlers } from '../helpers/toHandlers'
1515
import { type VNode, mergeProps } from '../vnode'
16-
import type { Data } from '@vue/runtime-shared'
1716

1817
function toObject(arr: Array<any>): Object {
1918
const res = {}

packages/runtime-core/src/component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ import {
7373
isObject,
7474
isPromise,
7575
} from '@vue/shared'
76-
import type { Data } from '@vue/runtime-shared'
7776
import type { SuspenseBoundary } from './components/Suspense'
7877
import type { CompilerOptions } from '@vue/compiler-core'
7978
import { markAttrsAccessed } from './componentRenderUtils'
@@ -98,6 +97,8 @@ import { markAsyncBoundary } from './helpers/useId'
9897
import { isAsyncWrapper } from './apiAsyncComponent'
9998
import type { RendererElement } from './renderer'
10099

100+
export type Data = Record<string, unknown>
101+
101102
/**
102103
* Public utility type for extracting the instance type of a component.
103104
* Works with all valid component definition types. This is intended to replace
@@ -509,7 +510,7 @@ export interface ComponentInternalInstance extends GenericComponentInstance {
509510
* setup related
510511
* @internal
511512
*/
512-
setupState: Data | null
513+
setupState: Data
513514
/**
514515
* devtools access to additional info
515516
* @internal

packages/runtime-core/src/componentOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type ComponentInternalInstance,
44
type ComponentInternalOptions,
55
type ConcreteComponent,
6+
type Data,
67
type InternalRenderFunction,
78
type SetupContext,
89
currentInstance,
@@ -18,7 +19,6 @@ import {
1819
isPromise,
1920
isString,
2021
} from '@vue/shared'
21-
import type { Data } from '@vue/runtime-shared'
2222
import { type Ref, getCurrentScope, isRef, traverse } from '@vue/reactivity'
2323
import { computed } from './apiComputed'
2424
import {

packages/runtime-core/src/componentProps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import {
2424
makeMap,
2525
toRawType,
2626
} from '@vue/shared'
27-
import type { Data } from '@vue/runtime-shared'
2827
import { warn } from './warning'
2928
import {
3029
type ComponentInternalInstance,
3130
type ComponentOptions,
3231
type ConcreteComponent,
32+
type Data,
3333
type GenericComponentInstance,
3434
setCurrentInstance,
3535
} from './component'

packages/runtime-core/src/componentPublicInstance.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
type Component,
33
type ComponentInternalInstance,
4+
type Data,
45
getComponentPublicInstance,
56
isStatefulComponent,
67
} from './component'
@@ -23,7 +24,6 @@ import {
2324
isGloballyAllowed,
2425
isString,
2526
} from '@vue/shared'
26-
import type { Data } from '@vue/runtime-shared'
2727
import {
2828
ReactiveFlags,
2929
type ShallowUnwrapRef,

packages/runtime-core/src/componentRenderUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
type ComponentInternalInstance,
3+
type Data,
34
type FunctionalComponent,
45
getComponentName,
56
} from './component'
@@ -15,7 +16,6 @@ import {
1516
} from './vnode'
1617
import { ErrorCodes, handleError } from './errorHandling'
1718
import { PatchFlags, ShapeFlags, isModelListener, isOn } from '@vue/shared'
18-
import type { Data } from '@vue/runtime-shared'
1919
import { warn } from './warning'
2020
import { isHmrUpdating } from './hmr'
2121
import type { NormalizedProps } from './componentProps'

packages/runtime-core/src/directives.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ return withDirectives(h(comp), [
1313

1414
import type { VNode } from './vnode'
1515
import { EMPTY_OBJ, isBuiltInDirective, isFunction } from '@vue/shared'
16-
import type { Data } from '@vue/runtime-shared'
1716
import { warn } from './warning'
1817
import {
1918
type ComponentInternalInstance,
19+
type Data,
2020
getComponentPublicInstance,
2121
} from './component'
2222
import { currentRenderingInstance } from './componentRenderContext'

packages/runtime-core/src/helpers/renderSlot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
openBlock,
1515
} from '../vnode'
1616
import { PatchFlags, SlotFlags, isSymbol } from '@vue/shared'
17-
import type { Data } from '@vue/runtime-shared'
1817
import { warn } from '../warning'
1918
import { isAsyncWrapper } from '../apiAsyncComponent'
19+
import type { Data } from '../component'
2020

2121
/**
2222
* Compiler runtime helper for rendering `<slot/>`
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
import { toHandlers as _toHandlers } from '@vue/runtime-shared'
1+
import { isObject, toHandlerKey } from '@vue/shared'
22
import { warn } from '../warning'
3-
import { NOOP } from '@vue/shared'
43

5-
export const toHandlers: (
4+
/**
5+
* For prefixing keys in v-on="obj" with "on"
6+
* @private
7+
*/
8+
export function toHandlers(
69
obj: Record<string, any>,
7-
preserveCaseIfNecessary?: boolean | undefined,
8-
) => Record<string, any> = _toHandlers.bind(undefined, __DEV__ ? warn : NOOP)
10+
preserveCaseIfNecessary?: boolean,
11+
): Record<string, any> {
12+
const ret: Record<string, any> = {}
13+
if (__DEV__ && !isObject(obj)) {
14+
warn(`v-on with no argument expects an object value.`)
15+
return ret
16+
}
17+
for (const key in obj) {
18+
ret[
19+
preserveCaseIfNecessary && /[A-Z]/.test(key)
20+
? `on:${key}`
21+
: toHandlerKey(key)
22+
] = obj[key]
23+
}
24+
return ret
25+
}

packages/runtime-core/src/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import {
1818
type ComponentInternalInstance,
1919
type ComponentOptions,
20+
type Data,
2021
type LifecycleHook,
2122
createComponentInstance,
2223
setupComponent,
@@ -39,7 +40,6 @@ import {
3940
isArray,
4041
isReservedProp,
4142
} from '@vue/shared'
42-
import type { Data } from '@vue/runtime-shared'
4343
import {
4444
type SchedulerJob,
4545
SchedulerJobFlags,

packages/runtime-core/src/vnode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import {
1212
normalizeClass,
1313
normalizeStyle,
1414
} from '@vue/shared'
15-
import type { Data } from '@vue/runtime-shared'
1615
import {
1716
type ClassComponent,
1817
type Component,
1918
type ComponentInternalInstance,
2019
type ConcreteComponent,
20+
type Data,
2121
isClassComponent,
2222
} from './component'
2323
import type { RawSlots } from './componentSlots'

packages/runtime-core/src/warning.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {
22
type ComponentInternalInstance,
3+
type Data,
34
type GenericComponentInstance,
45
formatComponentName,
56
} from './component'
67
import { isFunction, isString } from '@vue/shared'
7-
import type { Data } from '@vue/runtime-shared'
88
import { isRef, pauseTracking, resetTracking, toRaw } from '@vue/reactivity'
99
import { ErrorCodes, callWithErrorHandling } from './errorHandling'
1010
import { type VNode, isVNode } from './vnode'

packages/runtime-dom/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
type App,
3+
type Component,
34
type ConcreteComponent,
45
type CreateAppFunction,
56
type DefineComponent,
@@ -144,7 +145,7 @@ export const createApp = ((...args) => {
144145
}
145146

146147
return app
147-
}) as CreateAppFunction<Element>
148+
}) as CreateAppFunction<Element, Component>
148149

149150
export const createSSRApp = ((...args) => {
150151
const app = ensureHydrationRenderer().createApp(...args)

packages/runtime-shared/LICENSE

-21
This file was deleted.

packages/runtime-shared/README.md

-1
This file was deleted.

packages/runtime-shared/index.js

-7
This file was deleted.

packages/runtime-shared/package.json

-50
This file was deleted.

packages/runtime-shared/src/index.ts

-2
This file was deleted.

0 commit comments

Comments
 (0)