type BaseWatchOptions,
type BaseWatchMiddleware,
type Scheduler,
+ type SchedulerJob,
} from './baseWatch'
} from '@vue/reactivity'
export { withModifiers, withKeys } from '@vue/runtime-dom'
+export { nextTick } from './scheduler'
+export { getCurrentInstance, type ComponentInternalInstance } from './component'
export * from './on'
export * from './render'
export * from './renderWatch'
export * from './template'
-export * from './scheduler'
export * from './apiWatch'
export * from './directive'
export * from './dom'
export * from './directives/vShow'
export * from './apiLifecycle'
-export { getCurrentInstance, type ComponentInternalInstance } from './component'
export * from './if'
export type Fragment = { nodes: Block; anchor: Node }
export type BlockFn = (props?: any) => Block
-let isRenderingActivity = false
-export function getIsRendering() {
- return isRenderingActivity
-}
-
export function render(
comp: Component,
props: Data,
let block: Block | null = null
if (state && '__isScriptSetup' in state) {
instance.setupState = proxyRefs(state)
- const currentlyRenderingActivity = isRenderingActivity
- isRenderingActivity = true
- try {
- block = component.render(instance.setupState)
- } finally {
- isRenderingActivity = currentlyRenderingActivity
- }
+ block = component.render(instance.setupState)
} else {
block = state as Block
}
// if (__SSR__) {}
const instance = getCurrentInstance()
-
- extendOptions.onError = (err: unknown, type: BaseWatchErrorCodes) =>
- handleErrorWithInstance(err, instance, type)
- extendOptions.scheduler = createVaporRenderingScheduler(instance)
-
- extendOptions.middleware = createMiddleware(instance)
-
+ extend(extendOptions, {
+ onError: (err: unknown, type: BaseWatchErrorCodes) =>
+ handleErrorWithInstance(err, instance, type),
+ scheduler: createVaporRenderingScheduler(instance),
+ middleware: createMiddleware(instance),
+ })
let effect = baseWatch(source, cb, extendOptions)
const unwatch = !effect
-import type { Scheduler } from '@vue/reactivity'
+import type { Scheduler, SchedulerJob } from '@vue/reactivity'
import type { ComponentInternalInstance } from './component'
import { isArray } from '@vue/shared'
-export interface SchedulerJob extends Function {
- id?: number
- pre?: boolean
- active?: boolean
- computed?: boolean
- /**
- * Indicates whether the effect is allowed to recursively trigger itself
- * when managed by the scheduler.
- *
- * By default, a job cannot trigger itself because some built-in method calls,
- * e.g. Array.prototype.push actually performs reads as well (#1740) which
- * can lead to confusing infinite loops.
- * The allowed cases are component update functions and watch callbacks.
- * Component update functions may update child component props, which in turn
- * trigger flush: "pre" watch callbacks that mutates state that the parent
- * relies on (#1801). Watch callbacks doesn't track its dependencies so if it
- * triggers itself again, it's likely intentional and it is the user's
- * responsibility to perform recursive state mutation that eventually
- * stabilizes (#1727).
- */
- allowRecurse?: boolean
- /**
- * Attached by renderer.ts when setting up a component's render effect
- * Used to obtain component information when reporting max recursive updates.
- * dev only.
- */
- ownerInstance?: ComponentInternalInstance
-}
-
export type SchedulerJobs = SchedulerJob | SchedulerJob[]
-
export type QueueEffect = (
cb: SchedulerJobs,
suspense: ComponentInternalInstance | null,
) => Scheduler
export const createVaporSyncScheduler: SchedulerFactory =
- (instance) => (job, effect, isInit) => {
+ () => (job, effect, isInit) => {
if (isInit) {
effect.run()
} else {
}
export const createVaporPostScheduler: SchedulerFactory =
- (instance) => (job, effect, isInit) => {
+ () => (job, effect, isInit) => {
if (isInit) {
queuePostRenderEffect(effect.run.bind(effect))
} else {