Skip to content

Commit 90fd005

Browse files
committed
chore: organize exports
1 parent e9555ce commit 90fd005

File tree

5 files changed

+11
-44
lines changed

5 files changed

+11
-44
lines changed

packages/reactivity/src/baseWatch.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export interface SchedulerJob extends Function {
5656
allowRecurse?: boolean
5757
}
5858

59-
export type WatchEffect = (onCleanup: OnCleanup) => void
59+
type WatchEffect = (onCleanup: OnCleanup) => void
6060

61-
export type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
61+
type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
6262

63-
export type WatchCallback<V = any, OV = any> = (
63+
type WatchCallback<V = any, OV = any> = (
6464
value: V,
6565
oldValue: OV,
6666
onCleanup: OnCleanup,
@@ -77,7 +77,7 @@ export interface BaseWatchOptions<Immediate = boolean> extends DebuggerOptions {
7777
handleWarn?: HandleWarn
7878
}
7979

80-
export type WatchStopHandle = () => void
80+
type WatchStopHandle = () => void
8181

8282
export interface WatchInstance extends WatchStopHandle {
8383
effect?: ReactiveEffect
@@ -369,7 +369,7 @@ export function traverse(value: unknown, seen?: Set<unknown>) {
369369
return value
370370
}
371371

372-
export function callWithErrorHandling(
372+
function callWithErrorHandling(
373373
fn: Function,
374374
handleError: HandleError,
375375
type: BaseWatchErrorCodes,
@@ -384,7 +384,7 @@ export function callWithErrorHandling(
384384
return res
385385
}
386386

387-
export function callWithAsyncErrorHandling(
387+
function callWithAsyncErrorHandling(
388388
fn: Function | Function[],
389389
handleError: HandleError,
390390
type: BaseWatchErrorCodes,

packages/reactivity/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,8 @@ export {
7373
baseWatch,
7474
onEffectCleanup,
7575
BaseWatchErrorCodes,
76+
traverse,
7677
type BaseWatchOptions,
78+
type Scheduler,
79+
type WatchInstance,
7780
} from './baseWatch'

packages/runtime-core/src/apiWatch.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import {
33
type BaseWatchOptions,
44
type ComputedRef,
55
type DebuggerOptions,
6-
ReactiveFlags,
76
type Ref,
87
baseWatch,
98
getCurrentScope,
10-
isRef,
119
} from '@vue/reactivity'
1210
import {
1311
type SchedulerJob,
@@ -18,12 +16,7 @@ import {
1816
EMPTY_OBJ,
1917
NOOP,
2018
extend,
21-
isArray,
2219
isFunction,
23-
isMap,
24-
isObject,
25-
isPlainObject,
26-
isSet,
2720
isString,
2821
remove,
2922
} from '@vue/shared'
@@ -284,30 +277,3 @@ export function createPathGetter(ctx: any, path: string) {
284277
return cur
285278
}
286279
}
287-
288-
export function traverse(value: unknown, seen?: Set<unknown>) {
289-
if (!isObject(value) || (value as any)[ReactiveFlags.SKIP]) {
290-
return value
291-
}
292-
seen = seen || new Set()
293-
if (seen.has(value)) {
294-
return value
295-
}
296-
seen.add(value)
297-
if (isRef(value)) {
298-
traverse(value.value, seen)
299-
} else if (isArray(value)) {
300-
for (let i = 0; i < value.length; i++) {
301-
traverse(value[i], seen)
302-
}
303-
} else if (isSet(value) || isMap(value)) {
304-
value.forEach((v: any) => {
305-
traverse(v, seen)
306-
})
307-
} else if (isPlainObject(value)) {
308-
for (const key in value) {
309-
traverse(value[key], seen)
310-
}
311-
}
312-
return value
313-
}

packages/runtime-core/src/componentOptions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ import {
1919
isPromise,
2020
isString,
2121
} from '@vue/shared'
22-
import { type Ref, getCurrentScope, isRef } from '@vue/reactivity'
22+
import { type Ref, getCurrentScope, isRef, traverse } from '@vue/reactivity'
2323
import { computed } from './apiComputed'
2424
import {
2525
type WatchCallback,
2626
type WatchOptions,
2727
createPathGetter,
28-
traverse,
2928
watch,
3029
} from './apiWatch'
3130
import { inject, provide } from './apiInject'

packages/runtime-core/src/directives.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import { currentRenderingInstance } from './componentRenderContext'
2323
import { ErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
2424
import type { ComponentPublicInstance } from './componentPublicInstance'
2525
import { mapCompatDirectiveHook } from './compat/customDirective'
26-
import { pauseTracking, resetTracking } from '@vue/reactivity'
27-
import { traverse } from './apiWatch'
26+
import { pauseTracking, resetTracking, traverse } from '@vue/reactivity'
2827

2928
export interface DirectiveBinding<V = any> {
3029
instance: ComponentPublicInstance | null

0 commit comments

Comments
 (0)