Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit efc32b7

Browse files
committed
refactor(runtime-vapor): remove public instance
1 parent 3d4bc01 commit efc32b7

File tree

5 files changed

+3
-37
lines changed

5 files changed

+3
-37
lines changed

packages/runtime-vapor/__tests__/apiWatch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('watchEffect and onEffectCleanup', () => {
137137
}
138138

139139
const instance = render(demo as any, {}, '#host')
140-
const { change } = instance.proxy as any
140+
const { change } = instance.setupState as any
141141

142142
expect(calls).toEqual(['pre 0', 'sync 0', 'render 0'])
143143
calls.length = 0

packages/runtime-vapor/src/component.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ export interface ComponentInternalInstance {
3737

3838
parent: ComponentInternalInstance | null
3939

40-
// TODO: type
41-
proxy: Data | null
42-
4340
// state
4441
props: Data
4542
setupState: Data
@@ -144,7 +141,6 @@ export const createComponentInstance = (
144141
// resolved props and emits options
145142
propsOptions: normalizePropsOptions(component),
146143
// emitsOptions: normalizeEmitsOptions(type, appContext), // TODO:
147-
proxy: null,
148144

149145
// state
150146
props: EMPTY_OBJ,

packages/runtime-vapor/src/componentPublicInstance.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/runtime-vapor/src/errorHandling.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ export function handleError(
113113
) {
114114
if (instance) {
115115
let cur = instance.parent
116-
// the exposed instance is the render proxy to keep it consistent with 2.x
117-
const exposedInstance = ('proxy' in instance && instance.proxy) || null
118116
// in production the hook receives only the error code
119117
const errorInfo = __DEV__
120118
? ErrorTypeStrings[type]
@@ -123,9 +121,7 @@ export function handleError(
123121
const errorCapturedHooks = 'ec' in cur ? cur.ec : null
124122
if (errorCapturedHooks) {
125123
for (let i = 0; i < errorCapturedHooks.length; i++) {
126-
if (
127-
errorCapturedHooks[i](err, exposedInstance, errorInfo) === false
128-
) {
124+
if (errorCapturedHooks[i](err, instance, errorInfo) === false) {
129125
return
130126
}
131127
}

packages/runtime-vapor/src/render.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { initProps } from './componentProps'
1111
import { invokeDirectiveHook } from './directive'
1212
import { insert, remove } from './dom'
13-
import { PublicInstanceProxyHandlers } from './componentPublicInstance'
1413

1514
export type Block = Node | Fragment | Block[]
1615
export type ParentBlock = ParentNode | Node[]
@@ -51,17 +50,14 @@ export function mountComponent(
5150

5251
const setupFn =
5352
typeof component === 'function' ? component : component.setup
54-
instance.proxy = markRaw(
55-
new Proxy({ _: instance }, PublicInstanceProxyHandlers),
56-
)
5753
const state = setupFn && setupFn(props, ctx)
5854
let block: Block | null = null
5955
if (state && '__isScriptSetup' in state) {
6056
instance.setupState = proxyRefs(state)
6157
const currentlyRenderingActivity = isRenderingActivity
6258
isRenderingActivity = true
6359
try {
64-
block = component.render(instance.proxy)
60+
block = component.render(instance.setupState)
6561
} finally {
6662
isRenderingActivity = currentlyRenderingActivity
6763
}

0 commit comments

Comments
 (0)