mirror of https://github.com/vuejs/core.git
refactor: isolatedDeclarations for vapor
This commit is contained in:
parent
4468a2bea8
commit
2ef97fec30
|
@ -6,6 +6,7 @@ on:
|
|||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- minor
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
|
|
@ -44,9 +44,8 @@ import { parseExpression } from '@babel/parser'
|
|||
import { IS_REF, UNREF } from '../runtimeHelpers'
|
||||
import { BindingTypes } from '../options'
|
||||
|
||||
export const isLiteralWhitelisted = /*#__PURE__*/ makeMap(
|
||||
'true,false,null,this',
|
||||
)
|
||||
export const isLiteralWhitelisted: (key: string) => boolean =
|
||||
/*#__PURE__*/ makeMap('true,false,null,this')
|
||||
|
||||
export const transformExpression: NodeTransform = (node, context) => {
|
||||
if (node.type === NodeTypes.INTERPOLATION) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import { validateBrowserExpression } from '../validateExpression'
|
|||
import { hasScopeRef, isMemberExpression } from '../utils'
|
||||
import { TO_HANDLER_KEY } from '../runtimeHelpers'
|
||||
|
||||
export const fnExpRE =
|
||||
export const fnExpRE: RegExp =
|
||||
/^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/
|
||||
|
||||
export interface VOnDirectiveNode extends DirectiveNode {
|
||||
|
|
|
@ -158,7 +158,7 @@ export const isMemberExpressionNode: (
|
|||
context: Pick<TransformContext, 'expressionPlugins'>,
|
||||
) => boolean = __BROWSER__
|
||||
? (NOOP as any)
|
||||
: (path, context): boolean => {
|
||||
: (path, context) => {
|
||||
try {
|
||||
let ret: Expression = parseExpression(path, {
|
||||
plugins: context.expressionPlugins,
|
||||
|
@ -176,7 +176,7 @@ export const isMemberExpressionNode: (
|
|||
|
||||
export const isMemberExpression: (
|
||||
path: string,
|
||||
context: TransformContext,
|
||||
context: Pick<TransformContext, 'expressionPlugins'>,
|
||||
) => boolean = __BROWSER__ ? isMemberExpressionBrowser : isMemberExpressionNode
|
||||
|
||||
export function advancePositionWithClone(
|
||||
|
|
|
@ -37,7 +37,11 @@ export const resolveModifiers = (
|
|||
modifiers: string[],
|
||||
context: TransformContext | null,
|
||||
loc: SourceLocation,
|
||||
) => {
|
||||
): {
|
||||
keyModifiers: string[]
|
||||
nonKeyModifiers: string[]
|
||||
eventOptionModifiers: string[]
|
||||
} => {
|
||||
const keyModifiers = []
|
||||
const nonKeyModifiers = []
|
||||
const eventOptionModifiers = []
|
||||
|
|
|
@ -22,8 +22,8 @@ export type CodegenOptions = Omit<BaseCodegenOptions, 'optimizeImports'>
|
|||
export class CodegenContext {
|
||||
options: Required<CodegenOptions>
|
||||
|
||||
helpers = new Set<string>([])
|
||||
vaporHelpers = new Set<string>([])
|
||||
helpers: Set<string> = new Set<string>([])
|
||||
vaporHelpers: Set<string> = new Set<string>([])
|
||||
helper = (name: string) => {
|
||||
this.helpers.add(name)
|
||||
return `_${name}`
|
||||
|
@ -33,7 +33,7 @@ export class CodegenContext {
|
|||
return `_${name}`
|
||||
}
|
||||
|
||||
delegates = new Set<string>()
|
||||
delegates: Set<string> = new Set<string>()
|
||||
|
||||
identifiers: Record<string, string[]> = Object.create(null)
|
||||
|
||||
|
@ -56,11 +56,11 @@ export class CodegenContext {
|
|||
enterBlock(block: BlockIRNode) {
|
||||
const parent = this.block
|
||||
this.block = block
|
||||
return () => (this.block = parent)
|
||||
return (): BlockIRNode => (this.block = parent)
|
||||
}
|
||||
|
||||
scopeLevel: number = 0
|
||||
enterScope() {
|
||||
enterScope(): [level: number, exit: () => number] {
|
||||
return [this.scopeLevel++, () => this.scopeLevel--] as const
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,10 @@ export function genCreateComponent(
|
|||
}
|
||||
}
|
||||
|
||||
export function genRawProps(props: IRProps[], context: CodegenContext) {
|
||||
export function genRawProps(
|
||||
props: IRProps[],
|
||||
context: CodegenContext,
|
||||
): CodeFragment[] | undefined {
|
||||
const { vaporHelper } = context
|
||||
const frag = props
|
||||
.map(props => {
|
||||
|
|
|
@ -20,7 +20,10 @@ import {
|
|||
type WithDirectiveIRNode,
|
||||
} from '../ir'
|
||||
|
||||
export function genDirectivesForElement(id: number, context: CodegenContext) {
|
||||
export function genDirectivesForElement(
|
||||
id: number,
|
||||
context: CodegenContext,
|
||||
): CodeFragment[] {
|
||||
const dirs = filterDirectives(id, context.block.operation)
|
||||
return dirs.length ? genWithDirective(dirs, context) : []
|
||||
}
|
||||
|
@ -78,7 +81,7 @@ export function genWithDirective(
|
|||
}
|
||||
}
|
||||
|
||||
export function genDirectiveModifiers(modifiers: string[]) {
|
||||
export function genDirectiveModifiers(modifiers: string[]): string {
|
||||
return modifiers
|
||||
.map(
|
||||
value =>
|
||||
|
|
|
@ -90,7 +90,7 @@ function genArrayExpression(elements: string[]) {
|
|||
export function genEventHandler(
|
||||
context: CodegenContext,
|
||||
value: SimpleExpressionNode | undefined,
|
||||
) {
|
||||
): CodeFragment[] {
|
||||
if (value && value.content.trim()) {
|
||||
const isMemberExp = isMemberExpression(value.content, context.options)
|
||||
const isInlineStatement = !(isMemberExp || fnExpRE.test(value.content))
|
||||
|
|
|
@ -25,7 +25,7 @@ export function genSetModelValue(
|
|||
export function genModelHandler(
|
||||
value: SimpleExpressionNode,
|
||||
context: CodegenContext,
|
||||
) {
|
||||
): CodeFragment[] {
|
||||
const {
|
||||
options: { isTS },
|
||||
} = context
|
||||
|
|
|
@ -19,7 +19,10 @@ import {
|
|||
import { genCreateComponent } from './component'
|
||||
import { genSlotOutlet } from './slotOutlet'
|
||||
|
||||
export function genOperations(opers: OperationNode[], context: CodegenContext) {
|
||||
export function genOperations(
|
||||
opers: OperationNode[],
|
||||
context: CodegenContext,
|
||||
): CodeFragment[] {
|
||||
const [frag, push] = buildCodeFragment()
|
||||
for (const operation of opers) {
|
||||
push(...genOperation(operation, context))
|
||||
|
@ -69,7 +72,10 @@ export function genOperation(
|
|||
return []
|
||||
}
|
||||
|
||||
export function genEffects(effects: IREffect[], context: CodegenContext) {
|
||||
export function genEffects(
|
||||
effects: IREffect[],
|
||||
context: CodegenContext,
|
||||
): CodeFragment[] {
|
||||
const [frag, push] = buildCodeFragment()
|
||||
for (const effect of effects) {
|
||||
push(...genEffect(effect, context))
|
||||
|
@ -77,7 +83,10 @@ export function genEffects(effects: IREffect[], context: CodegenContext) {
|
|||
return frag
|
||||
}
|
||||
|
||||
export function genEffect({ operations }: IREffect, context: CodegenContext) {
|
||||
export function genEffect(
|
||||
{ operations }: IREffect,
|
||||
context: CodegenContext,
|
||||
): CodeFragment[] {
|
||||
const { vaporHelper } = context
|
||||
const [frag, push] = buildCodeFragment(
|
||||
NEWLINE,
|
||||
|
|
|
@ -5,7 +5,10 @@ import { genExpression } from './expression'
|
|||
import { type CodeFragment, NEWLINE, buildCodeFragment, genCall } from './utils'
|
||||
import { genRawProps } from './component'
|
||||
|
||||
export function genSlotOutlet(oper: SlotOutletIRNode, context: CodegenContext) {
|
||||
export function genSlotOutlet(
|
||||
oper: SlotOutletIRNode,
|
||||
context: CodegenContext,
|
||||
): CodeFragment[] {
|
||||
const { vaporHelper } = context
|
||||
const { id, name, fallback } = oper
|
||||
const [frag, push] = buildCodeFragment()
|
||||
|
|
|
@ -6,7 +6,7 @@ import { type CodeFragment, NEWLINE, buildCodeFragment, genCall } from './utils'
|
|||
export function genTemplates(
|
||||
templates: string[],
|
||||
{ vaporHelper }: CodegenContext,
|
||||
) {
|
||||
): string {
|
||||
return templates
|
||||
.map(
|
||||
(template, i) =>
|
||||
|
|
|
@ -10,11 +10,11 @@ import {
|
|||
import { isArray, isString } from '@vue/shared'
|
||||
import type { CodegenContext } from '../generate'
|
||||
|
||||
export const NEWLINE = Symbol(__DEV__ ? `newline` : ``)
|
||||
export const NEWLINE: unique symbol = Symbol(__DEV__ ? `newline` : ``)
|
||||
/** increase offset but don't push actual code */
|
||||
export const LF = Symbol(__DEV__ ? `line feed` : ``)
|
||||
export const INDENT_START = Symbol(__DEV__ ? `indent start` : ``)
|
||||
export const INDENT_END = Symbol(__DEV__ ? `indent end` : ``)
|
||||
export const LF: unique symbol = Symbol(__DEV__ ? `line feed` : ``)
|
||||
export const INDENT_START: unique symbol = Symbol(__DEV__ ? `indent start` : ``)
|
||||
export const INDENT_END: unique symbol = Symbol(__DEV__ ? `indent end` : ``)
|
||||
|
||||
type FalsyValue = false | null | undefined
|
||||
export type CodeFragment =
|
||||
|
|
|
@ -113,14 +113,14 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|||
}
|
||||
}
|
||||
|
||||
increaseId = () => this.globalId++
|
||||
reference() {
|
||||
increaseId = (): number => this.globalId++
|
||||
reference(): number {
|
||||
if (this.dynamic.id !== undefined) return this.dynamic.id
|
||||
this.dynamic.flags |= DynamicFlag.REFERENCED
|
||||
return (this.dynamic.id = this.increaseId())
|
||||
}
|
||||
|
||||
pushTemplate(content: string) {
|
||||
pushTemplate(content: string): number {
|
||||
const existing = this.ir.template.findIndex(
|
||||
template => template === content,
|
||||
)
|
||||
|
@ -128,7 +128,7 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|||
this.ir.template.push(content)
|
||||
return this.ir.template.length - 1
|
||||
}
|
||||
registerTemplate() {
|
||||
registerTemplate(): number {
|
||||
if (!this.template) return -1
|
||||
const id = this.pushTemplate(this.template)
|
||||
return (this.dynamic.template = id)
|
||||
|
@ -137,7 +137,7 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|||
registerEffect(
|
||||
expressions: SimpleExpressionNode[],
|
||||
...operations: OperationNode[]
|
||||
) {
|
||||
): void {
|
||||
expressions = expressions.filter(exp => !isConstantExpression(exp))
|
||||
if (this.inVOnce || expressions.length === 0) {
|
||||
return this.registerOperation(...operations)
|
||||
|
@ -162,7 +162,7 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|||
return a.every((exp, i) => exp.content === b[i].content)
|
||||
}
|
||||
}
|
||||
registerOperation(...node: OperationNode[]) {
|
||||
registerOperation(...node: OperationNode[]): void {
|
||||
this.block.operation.push(...node)
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ export function transform(
|
|||
|
||||
export function transformNode(
|
||||
context: TransformContext<RootNode | TemplateChildNode>,
|
||||
) {
|
||||
): void {
|
||||
let { node } = context
|
||||
|
||||
// apply transform plugins
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
type CommentNode,
|
||||
type ElementNode,
|
||||
NodeTypes,
|
||||
type TemplateChildNode,
|
||||
} from '@vue/compiler-dom'
|
||||
|
@ -20,7 +21,7 @@ export const transformComment: NodeTransform = (node, context) => {
|
|||
export function getSiblingIf(
|
||||
context: TransformContext<TemplateChildNode>,
|
||||
reverse?: boolean,
|
||||
) {
|
||||
): ElementNode | undefined {
|
||||
const parent = context.parent
|
||||
if (!parent) return
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import {
|
|||
} from '../ir'
|
||||
import { EMPTY_EXPRESSION } from './utils'
|
||||
|
||||
export const isReservedProp = /*#__PURE__*/ makeMap(
|
||||
export const isReservedProp: (key: string) => boolean = /*#__PURE__*/ makeMap(
|
||||
// the leading comma is intentional so empty string "" is also included
|
||||
',key,ref,ref_for,ref_key,',
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
type ElementNode,
|
||||
ElementTypes,
|
||||
NodeTypes,
|
||||
type SimpleExpressionNode,
|
||||
type TemplateChildNode,
|
||||
type TemplateNode,
|
||||
createSimpleExpression,
|
||||
|
@ -54,4 +55,7 @@ export function wrapTemplate(node: ElementNode, dirs: string[]): TemplateNode {
|
|||
} as Partial<TemplateNode>)
|
||||
}
|
||||
|
||||
export const EMPTY_EXPRESSION = createSimpleExpression('', true)
|
||||
export const EMPTY_EXPRESSION: SimpleExpressionNode = createSimpleExpression(
|
||||
'',
|
||||
true,
|
||||
)
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
createCompilerError,
|
||||
} from '@vue/compiler-dom'
|
||||
import {
|
||||
type NodeTransform,
|
||||
type TransformContext,
|
||||
createStructuralDirectiveTransform,
|
||||
} from '../transform'
|
||||
|
@ -17,7 +18,7 @@ import {
|
|||
import { findProp, propToExpression } from '../utils'
|
||||
import { newBlock, wrapTemplate } from './utils'
|
||||
|
||||
export const transformVFor = createStructuralDirectiveTransform(
|
||||
export const transformVFor: NodeTransform = createStructuralDirectiveTransform(
|
||||
'for',
|
||||
processFor,
|
||||
)
|
||||
|
@ -52,7 +53,7 @@ export function processFor(
|
|||
const exitBlock = context.enterBlock(render, true)
|
||||
context.reference()
|
||||
|
||||
return () => {
|
||||
return (): void => {
|
||||
exitBlock()
|
||||
context.registerOperation({
|
||||
type: IRNodeTypes.FOR,
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
createSimpleExpression,
|
||||
} from '@vue/compiler-dom'
|
||||
import {
|
||||
type NodeTransform,
|
||||
type TransformContext,
|
||||
createStructuralDirectiveTransform,
|
||||
} from '../transform'
|
||||
|
@ -18,7 +19,7 @@ import { extend } from '@vue/shared'
|
|||
import { newBlock, wrapTemplate } from './utils'
|
||||
import { getSiblingIf } from './transformComment'
|
||||
|
||||
export const transformVIf = createStructuralDirectiveTransform(
|
||||
export const transformVIf: NodeTransform = createStructuralDirectiveTransform(
|
||||
['if', 'else', 'else-if'],
|
||||
processIf,
|
||||
)
|
||||
|
@ -27,7 +28,7 @@ export function processIf(
|
|||
node: ElementNode,
|
||||
dir: VaporDirectiveNode,
|
||||
context: TransformContext<ElementNode>,
|
||||
) {
|
||||
): (() => void) | undefined {
|
||||
if (dir.name !== 'else' && (!dir.exp || !dir.exp.content.trim())) {
|
||||
const loc = dir.exp ? dir.exp.loc : node.loc
|
||||
context.options.onError(
|
||||
|
|
|
@ -27,7 +27,9 @@ export const findDir = _findDir as (
|
|||
allowEmpty?: boolean,
|
||||
) => VaporDirectiveNode | undefined
|
||||
|
||||
export function propToExpression(prop: AttributeNode | VaporDirectiveNode) {
|
||||
export function propToExpression(
|
||||
prop: AttributeNode | VaporDirectiveNode,
|
||||
): SimpleExpressionNode | undefined {
|
||||
return prop.type === NodeTypes.ATTRIBUTE
|
||||
? prop.value
|
||||
? createSimpleExpression(prop.value.content, true, prop.value.loc)
|
||||
|
@ -35,7 +37,7 @@ export function propToExpression(prop: AttributeNode | VaporDirectiveNode) {
|
|||
: prop.exp
|
||||
}
|
||||
|
||||
export function isConstantExpression(exp: SimpleExpressionNode) {
|
||||
export function isConstantExpression(exp: SimpleExpressionNode): boolean {
|
||||
return (
|
||||
isLiteralWhitelisted(exp.content) ||
|
||||
isGloballyAllowed(exp.content) ||
|
||||
|
@ -43,7 +45,9 @@ export function isConstantExpression(exp: SimpleExpressionNode) {
|
|||
)
|
||||
}
|
||||
|
||||
export function resolveExpression(exp: SimpleExpressionNode) {
|
||||
export function resolveExpression(
|
||||
exp: SimpleExpressionNode,
|
||||
): SimpleExpressionNode {
|
||||
if (!exp.isStatic) {
|
||||
const value = getLiteralExpressionValue(exp)
|
||||
if (value !== null) {
|
||||
|
|
|
@ -38,7 +38,7 @@ export class EffectScope {
|
|||
|
||||
constructor(
|
||||
public detached = false,
|
||||
parent = activeEffectScope,
|
||||
parent: EffectScope | undefined = activeEffectScope,
|
||||
) {
|
||||
this.parent = parent
|
||||
if (!detached && parent) {
|
||||
|
|
|
@ -7,12 +7,13 @@ import {
|
|||
isReservedProp,
|
||||
normalizeClass,
|
||||
} from '@vue/shared'
|
||||
import type { ComponentInternalInstance, Data } from '../component'
|
||||
import type { ComponentInternalInstance } from '../component'
|
||||
import type { Slot } from '../componentSlots'
|
||||
import { createSlots } from '../helpers/createSlots'
|
||||
import { renderSlot } from '../helpers/renderSlot'
|
||||
import { toHandlers } from '../helpers/toHandlers'
|
||||
import { type VNode, mergeProps } from '../vnode'
|
||||
import type { Data } from '@vue/runtime-shared'
|
||||
|
||||
function toObject(arr: Array<any>): Object {
|
||||
const res = {}
|
||||
|
|
|
@ -2,4 +2,7 @@ import { toHandlers as _toHandlers } from '@vue/runtime-shared'
|
|||
import { warn } from '../warning'
|
||||
import { NOOP } from '@vue/shared'
|
||||
|
||||
export const toHandlers = _toHandlers.bind(undefined, __DEV__ ? warn : NOOP)
|
||||
export const toHandlers: (
|
||||
obj: Record<string, any>,
|
||||
preserveCaseIfNecessary?: boolean | undefined,
|
||||
) => Record<string, any> = _toHandlers.bind(undefined, __DEV__ ? warn : NOOP)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
type Component,
|
||||
type ComponentInternalInstance,
|
||||
createComponentInstance,
|
||||
currentInstance,
|
||||
} from './component'
|
||||
|
@ -14,7 +15,7 @@ export function createComponent(
|
|||
slots: RawSlots | null = null,
|
||||
singleRoot: boolean = false,
|
||||
once: boolean = false,
|
||||
) {
|
||||
): ComponentInternalInstance {
|
||||
const current = currentInstance!
|
||||
const instance = createComponentInstance(
|
||||
comp,
|
||||
|
|
|
@ -8,7 +8,7 @@ export interface InjectionKey<T> extends Symbol {}
|
|||
export function provide<T, K = InjectionKey<T> | string | number>(
|
||||
key: K,
|
||||
value: K extends InjectionKey<infer V> ? V : T,
|
||||
) {
|
||||
): void {
|
||||
if (!currentInstance) {
|
||||
if (__DEV__) {
|
||||
warn(`provide() can only be used inside setup().`)
|
||||
|
|
|
@ -59,19 +59,29 @@ const createHook =
|
|||
<T extends Function = () => any>(lifecycle: VaporLifecycleHooks) =>
|
||||
(hook: T, target: ComponentInternalInstance | null = currentInstance) =>
|
||||
injectHook(lifecycle, (...args: unknown[]) => hook(...args), target)
|
||||
type CreateHook<T = any> = (
|
||||
hook: T,
|
||||
target?: ComponentInternalInstance | null,
|
||||
) => void
|
||||
|
||||
export const onBeforeMount = createHook(VaporLifecycleHooks.BEFORE_MOUNT)
|
||||
export const onMounted = createHook(VaporLifecycleHooks.MOUNTED)
|
||||
export const onBeforeUpdate = createHook(VaporLifecycleHooks.BEFORE_UPDATE)
|
||||
export const onUpdated = createHook(VaporLifecycleHooks.UPDATED)
|
||||
export const onBeforeUnmount = createHook(VaporLifecycleHooks.BEFORE_UNMOUNT)
|
||||
export const onUnmounted = createHook(VaporLifecycleHooks.UNMOUNTED)
|
||||
export const onBeforeMount: CreateHook = createHook(
|
||||
VaporLifecycleHooks.BEFORE_MOUNT,
|
||||
)
|
||||
export const onMounted: CreateHook = createHook(VaporLifecycleHooks.MOUNTED)
|
||||
export const onBeforeUpdate: CreateHook = createHook(
|
||||
VaporLifecycleHooks.BEFORE_UPDATE,
|
||||
)
|
||||
export const onUpdated: CreateHook = createHook(VaporLifecycleHooks.UPDATED)
|
||||
export const onBeforeUnmount: CreateHook = createHook(
|
||||
VaporLifecycleHooks.BEFORE_UNMOUNT,
|
||||
)
|
||||
export const onUnmounted: CreateHook = createHook(VaporLifecycleHooks.UNMOUNTED)
|
||||
|
||||
export type DebuggerHook = (e: DebuggerEvent) => void
|
||||
export const onRenderTriggered = createHook<DebuggerHook>(
|
||||
export const onRenderTriggered: CreateHook = createHook<DebuggerHook>(
|
||||
VaporLifecycleHooks.RENDER_TRIGGERED,
|
||||
)
|
||||
export const onRenderTracked = createHook<DebuggerHook>(
|
||||
export const onRenderTracked: CreateHook = createHook<DebuggerHook>(
|
||||
VaporLifecycleHooks.RENDER_TRACKED,
|
||||
)
|
||||
|
||||
|
@ -84,6 +94,6 @@ export type ErrorCapturedHook<TError = unknown> = (
|
|||
export function onErrorCaptured<TError = Error>(
|
||||
hook: ErrorCapturedHook<TError>,
|
||||
target: ComponentInternalInstance | null = currentInstance,
|
||||
) {
|
||||
): void {
|
||||
injectHook(VaporLifecycleHooks.ERROR_CAPTURED, hook, target)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { VaporErrorCodes, callWithErrorHandling } from './errorHandling'
|
|||
import { endMeasure, startMeasure } from './profiling'
|
||||
import { devtoolsComponentAdded } from './devtools'
|
||||
|
||||
export const fragmentKey = Symbol(__DEV__ ? `fragmentKey` : ``)
|
||||
export const fragmentKey: unique symbol = Symbol(__DEV__ ? `fragmentKey` : ``)
|
||||
|
||||
export type Block = Node | Fragment | ComponentInternalInstance | Block[]
|
||||
export type Fragment = {
|
||||
|
@ -152,7 +152,7 @@ function mountComponent(
|
|||
return instance
|
||||
}
|
||||
|
||||
export function unmountComponent(instance: ComponentInternalInstance) {
|
||||
export function unmountComponent(instance: ComponentInternalInstance): void {
|
||||
const { container, block, scope } = instance
|
||||
|
||||
// hook: beforeUnmount
|
||||
|
|
|
@ -65,7 +65,7 @@ export function watchEffect(
|
|||
export function watchPostEffect(
|
||||
effect: WatchEffect,
|
||||
options?: DebuggerOptions,
|
||||
) {
|
||||
): WatchStopHandle {
|
||||
return doWatch(
|
||||
effect,
|
||||
null,
|
||||
|
@ -76,7 +76,7 @@ export function watchPostEffect(
|
|||
export function watchSyncEffect(
|
||||
effect: WatchEffect,
|
||||
options?: DebuggerOptions,
|
||||
) {
|
||||
): WatchStopHandle {
|
||||
return doWatch(
|
||||
effect,
|
||||
null,
|
||||
|
|
|
@ -146,7 +146,7 @@ export interface ComponentInternalOptions {
|
|||
|
||||
type LifecycleHook<TFn = Function> = TFn[] | null
|
||||
|
||||
export const componentKey = Symbol(__DEV__ ? `componentKey` : ``)
|
||||
export const componentKey: unique symbol = Symbol(__DEV__ ? `componentKey` : ``)
|
||||
|
||||
export interface ComponentInternalInstance {
|
||||
[componentKey]: true
|
||||
|
@ -246,12 +246,12 @@ export const getCurrentInstance: () => ComponentInternalInstance | null = () =>
|
|||
export const setCurrentInstance = (instance: ComponentInternalInstance) => {
|
||||
const prev = currentInstance
|
||||
currentInstance = instance
|
||||
return () => {
|
||||
return (): void => {
|
||||
currentInstance = prev
|
||||
}
|
||||
}
|
||||
|
||||
export const unsetCurrentInstance = () => {
|
||||
export const unsetCurrentInstance = (): void => {
|
||||
currentInstance && currentInstance.scope.off()
|
||||
currentInstance = null
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ export function isVaporComponent(
|
|||
export function validateComponentName(
|
||||
name: string,
|
||||
{ isNativeTag }: AppConfig,
|
||||
) {
|
||||
): void {
|
||||
if (isBuiltInTag(name) || isNativeTag(name)) {
|
||||
warn(
|
||||
'Do not use built-in or reserved HTML elements as component id: ' + name,
|
||||
|
|
|
@ -5,7 +5,7 @@ import { setDynamicProps } from './dom/prop'
|
|||
import type { RawProps } from './componentProps'
|
||||
import { renderEffect } from './renderEffect'
|
||||
|
||||
export function patchAttrs(instance: ComponentInternalInstance) {
|
||||
export function patchAttrs(instance: ComponentInternalInstance): void {
|
||||
const {
|
||||
attrs,
|
||||
rawProps,
|
||||
|
@ -64,7 +64,7 @@ export function withAttrs(props: RawProps): RawProps {
|
|||
return [attrsGetter, props]
|
||||
}
|
||||
|
||||
export function fallThroughAttrs(instance: ComponentInternalInstance) {
|
||||
export function fallThroughAttrs(instance: ComponentInternalInstance): void {
|
||||
const {
|
||||
block,
|
||||
type: { inheritAttrs },
|
||||
|
|
|
@ -43,7 +43,7 @@ export function emit(
|
|||
instance: ComponentInternalInstance,
|
||||
event: string,
|
||||
...rawArgs: any[]
|
||||
) {
|
||||
): void {
|
||||
if (instance.isUnmounted) return
|
||||
|
||||
if (__DEV__) {
|
||||
|
|
|
@ -10,7 +10,7 @@ export function invokeLifecycle(
|
|||
directive: DirectiveHookName,
|
||||
cb?: (instance: ComponentInternalInstance) => void,
|
||||
post?: boolean,
|
||||
) {
|
||||
): void {
|
||||
invokeArrayFns(post ? [invokeSub, invokeCurrent] : [invokeCurrent, invokeSub])
|
||||
|
||||
function invokeCurrent() {
|
||||
|
|
|
@ -29,5 +29,5 @@ export function recordEventMetadata(el: Node, key: string, value: any) {
|
|||
const metadata = getMetadata(el)[MetadataKind.event]
|
||||
const handlers = (metadata[key] ||= [])
|
||||
handlers.push(value)
|
||||
return () => remove(handlers, value)
|
||||
return (): void => remove(handlers, value)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ export function initProps(
|
|||
rawProps: RawProps,
|
||||
isStateful: boolean,
|
||||
once: boolean,
|
||||
) {
|
||||
): void {
|
||||
if (!rawProps) rawProps = []
|
||||
else if (!isArray(rawProps)) rawProps = [rawProps]
|
||||
instance.rawProps = rawProps
|
||||
|
|
|
@ -36,7 +36,7 @@ export const isDynamicSlotFn = isFunction as (
|
|||
export function initSlots(
|
||||
instance: ComponentInternalInstance,
|
||||
rawSlots: RawSlots | null = null,
|
||||
) {
|
||||
): void {
|
||||
if (!rawSlots) return
|
||||
if (!isArray(rawSlots)) rawSlots = [rawSlots]
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ function emit(event: string, ...args: any[]) {
|
|||
}
|
||||
}
|
||||
|
||||
export function setDevtoolsHook(hook: DevtoolsHook, target: any) {
|
||||
export function setDevtoolsHook(hook: DevtoolsHook, target: any): void {
|
||||
devtools = hook
|
||||
if (devtools) {
|
||||
devtools.enabled = true
|
||||
|
@ -86,19 +86,18 @@ export function setDevtoolsHook(hook: DevtoolsHook, target: any) {
|
|||
}
|
||||
}
|
||||
|
||||
export function devtoolsInitApp(app: App, version: string) {
|
||||
export function devtoolsInitApp(app: App, version: string): void {
|
||||
emit(DevtoolsHooks.APP_INIT, app, version, {})
|
||||
}
|
||||
|
||||
export function devtoolsUnmountApp(app: App) {
|
||||
export function devtoolsUnmountApp(app: App): void {
|
||||
emit(DevtoolsHooks.APP_UNMOUNT, app)
|
||||
}
|
||||
|
||||
export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook(
|
||||
DevtoolsHooks.COMPONENT_ADDED,
|
||||
)
|
||||
export const devtoolsComponentAdded: DevtoolsComponentHook =
|
||||
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_ADDED)
|
||||
|
||||
export const devtoolsComponentUpdated =
|
||||
export const devtoolsComponentUpdated: DevtoolsComponentHook =
|
||||
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_UPDATED)
|
||||
|
||||
const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
|
||||
|
@ -107,7 +106,7 @@ const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
|
|||
|
||||
export const devtoolsComponentRemoved = (
|
||||
component: ComponentInternalInstance,
|
||||
) => {
|
||||
): void => {
|
||||
if (
|
||||
devtools &&
|
||||
typeof devtools.cleanupBuffer === 'function' &&
|
||||
|
@ -118,8 +117,12 @@ export const devtoolsComponentRemoved = (
|
|||
}
|
||||
}
|
||||
|
||||
type DevtoolsComponentHook = (component: ComponentInternalInstance) => void
|
||||
|
||||
/*! #__NO_SIDE_EFFECTS__ */
|
||||
function createDevtoolsComponentHook(hook: DevtoolsHooks) {
|
||||
function createDevtoolsComponentHook(
|
||||
hook: DevtoolsHooks,
|
||||
): DevtoolsComponentHook {
|
||||
return (component: ComponentInternalInstance) => {
|
||||
emit(
|
||||
hook,
|
||||
|
@ -131,15 +134,20 @@ function createDevtoolsComponentHook(hook: DevtoolsHooks) {
|
|||
}
|
||||
}
|
||||
|
||||
export const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook(
|
||||
DevtoolsHooks.PERFORMANCE_START,
|
||||
)
|
||||
export const devtoolsPerfStart: DevtoolsPerformanceHook =
|
||||
/*#__PURE__*/ createDevtoolsPerformanceHook(DevtoolsHooks.PERFORMANCE_START)
|
||||
|
||||
export const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook(
|
||||
DevtoolsHooks.PERFORMANCE_END,
|
||||
)
|
||||
export const devtoolsPerfEnd: DevtoolsPerformanceHook =
|
||||
/*#__PURE__*/ createDevtoolsPerformanceHook(DevtoolsHooks.PERFORMANCE_END)
|
||||
|
||||
function createDevtoolsPerformanceHook(hook: DevtoolsHooks) {
|
||||
type DevtoolsPerformanceHook = (
|
||||
component: ComponentInternalInstance,
|
||||
type: string,
|
||||
time: number,
|
||||
) => void
|
||||
function createDevtoolsPerformanceHook(
|
||||
hook: DevtoolsHooks,
|
||||
): DevtoolsPerformanceHook {
|
||||
return (component: ComponentInternalInstance, type: string, time: number) => {
|
||||
emit(hook, component.appContext.app, component.uid, component, type, time)
|
||||
}
|
||||
|
@ -149,7 +157,7 @@ export function devtoolsComponentEmit(
|
|||
component: ComponentInternalInstance,
|
||||
event: string,
|
||||
params: any[],
|
||||
) {
|
||||
): void {
|
||||
emit(
|
||||
DevtoolsHooks.COMPONENT_EMIT,
|
||||
component.appContext.app,
|
||||
|
|
|
@ -72,7 +72,7 @@ export type Directive<T = any, V = any, M extends string = string> =
|
|||
| ObjectDirective<T, V, M>
|
||||
| FunctionDirective<T, V, M>
|
||||
|
||||
export function validateDirectiveName(name: string) {
|
||||
export function validateDirectiveName(name: string): void {
|
||||
if (isBuiltInDirective(name)) {
|
||||
warn('Do not use built-in directive ids as custom directive id: ' + name)
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ export function invokeDirectiveHook(
|
|||
instance: ComponentInternalInstance | null,
|
||||
name: DirectiveHookName,
|
||||
scope: BlockEffectScope,
|
||||
) {
|
||||
): void {
|
||||
const { dirs } = scope
|
||||
if (name === 'mounted') scope.im = true
|
||||
if (!dirs) return
|
||||
|
|
|
@ -22,7 +22,7 @@ export function createChildFragmentDirectives(
|
|||
initCallback: (getValue: () => any) => void,
|
||||
effectCallback: (getValue: () => any) => void,
|
||||
once?: boolean,
|
||||
) {
|
||||
): void {
|
||||
let isTriggered = false
|
||||
const instance = currentInstance!
|
||||
const parentScope = getCurrentScope() as BlockEffectScope
|
||||
|
@ -92,7 +92,10 @@ export function createChildFragmentDirectives(
|
|||
}
|
||||
}
|
||||
|
||||
export function invokeWithMount(scope: BlockEffectScope, handler?: () => any) {
|
||||
export function invokeWithMount(
|
||||
scope: BlockEffectScope,
|
||||
handler?: () => any,
|
||||
): any {
|
||||
if (isRenderEffectScope(scope.parent) && !scope.parent.im) {
|
||||
return handler && handler()
|
||||
}
|
||||
|
@ -102,7 +105,7 @@ export function invokeWithMount(scope: BlockEffectScope, handler?: () => any) {
|
|||
export function invokeWithUnmount(
|
||||
scope: BlockEffectScope,
|
||||
handler?: () => void,
|
||||
) {
|
||||
): any {
|
||||
try {
|
||||
return invokeWithDirsHooks(scope, 'unmount', handler)
|
||||
} finally {
|
||||
|
@ -113,7 +116,7 @@ export function invokeWithUnmount(
|
|||
export function invokeWithUpdate(
|
||||
scope: BlockEffectScope,
|
||||
handler?: () => void,
|
||||
) {
|
||||
): any {
|
||||
return invokeWithDirsHooks(scope, 'update', handler)
|
||||
}
|
||||
|
||||
|
|
|
@ -24,15 +24,15 @@ export function insert(
|
|||
block: Block,
|
||||
parent: ParentNode,
|
||||
anchor: Node | null = null,
|
||||
) {
|
||||
): void {
|
||||
normalizeBlock(block).forEach(node => parent.insertBefore(node, anchor))
|
||||
}
|
||||
|
||||
export function prepend(parent: ParentNode, ...blocks: Block[]) {
|
||||
export function prepend(parent: ParentNode, ...blocks: Block[]): void {
|
||||
parent.prepend(...normalizeBlock(blocks))
|
||||
}
|
||||
|
||||
export function remove(block: Block, parent: ParentNode) {
|
||||
export function remove(block: Block, parent: ParentNode): void {
|
||||
normalizeBlock(block).forEach(node => parent.removeChild(node))
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ export function addEventListener(
|
|||
options?: AddEventListenerOptions,
|
||||
) {
|
||||
el.addEventListener(event, handler, options)
|
||||
return () => el.removeEventListener(event, handler, options)
|
||||
return (): void => el.removeEventListener(event, handler, options)
|
||||
}
|
||||
|
||||
interface ModifierOptions {
|
||||
|
@ -32,7 +32,7 @@ export function on(
|
|||
handlerGetter: () => undefined | ((...args: any[]) => any),
|
||||
options: AddEventListenerOptions &
|
||||
ModifierOptions & { effect?: boolean } = {},
|
||||
) {
|
||||
): void {
|
||||
const handler: DelegatedHandler = eventHandler(handlerGetter, options)
|
||||
let cleanupEvent: (() => void) | undefined
|
||||
queuePostFlushCb(() => {
|
||||
|
@ -60,7 +60,7 @@ export function delegate(
|
|||
event: string,
|
||||
handlerGetter: () => undefined | ((...args: any[]) => any),
|
||||
options: ModifierOptions = {},
|
||||
) {
|
||||
): void {
|
||||
const handler: DelegatedHandler = eventHandler(handlerGetter, options)
|
||||
handler.delegate = true
|
||||
recordEventMetadata(el, event, handler)
|
||||
|
@ -85,7 +85,7 @@ function eventHandler(
|
|||
*/
|
||||
const delegatedEvents = Object.create(null)
|
||||
|
||||
export const delegateEvents = (...names: string[]) => {
|
||||
export const delegateEvents = (...names: string[]): void => {
|
||||
for (const name of names) {
|
||||
if (!delegatedEvents[name]) {
|
||||
delegatedEvents[name] = true
|
||||
|
@ -130,7 +130,7 @@ const delegatedEventHandler = (e: Event) => {
|
|||
export function setDynamicEvents(
|
||||
el: HTMLElement,
|
||||
events: Record<string, (...args: any[]) => any>,
|
||||
) {
|
||||
): void {
|
||||
for (const name in events) {
|
||||
on(el, name, () => events[name], { effect: true })
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ import {
|
|||
import { on } from './event'
|
||||
import type { Data } from '@vue/runtime-shared'
|
||||
|
||||
export function setClass(el: Element, value: any) {
|
||||
export function setClass(el: Element, value: any): void {
|
||||
const prev = recordPropMetadata(el, 'class', (value = normalizeClass(value)))
|
||||
if (value !== prev && (value || prev)) {
|
||||
el.className = value
|
||||
}
|
||||
}
|
||||
|
||||
export function setAttr(el: Element, key: string, value: any) {
|
||||
export function setAttr(el: Element, key: string, value: any): void {
|
||||
const oldVal = recordPropMetadata(el, key, value)
|
||||
if (value !== oldVal) {
|
||||
if (value != null) {
|
||||
|
@ -37,7 +37,7 @@ export function setAttr(el: Element, key: string, value: any) {
|
|||
}
|
||||
}
|
||||
|
||||
export function setDOMProp(el: any, key: string, value: any) {
|
||||
export function setDOMProp(el: any, key: string, value: any): void {
|
||||
const oldVal = recordPropMetadata(el, key, value)
|
||||
if (value === oldVal) return
|
||||
|
||||
|
@ -109,7 +109,7 @@ export function setDOMProp(el: any, key: string, value: any) {
|
|||
needRemove && el.removeAttribute(key)
|
||||
}
|
||||
|
||||
export function setDynamicProp(el: Element, key: string, value: any) {
|
||||
export function setDynamicProp(el: Element, key: string, value: any): void {
|
||||
// TODO
|
||||
const isSVG = false
|
||||
if (key === 'class') {
|
||||
|
@ -132,7 +132,7 @@ export function setDynamicProp(el: Element, key: string, value: any) {
|
|||
}
|
||||
}
|
||||
|
||||
export function setDynamicProps(el: Element, ...args: any) {
|
||||
export function setDynamicProps(el: Element, ...args: any): void {
|
||||
const oldProps = getMetadata(el)[MetadataKind.prop]
|
||||
const props = args.length > 1 ? mergeProps(...args) : args[0]
|
||||
|
||||
|
@ -154,7 +154,7 @@ export function setDynamicProps(el: Element, ...args: any) {
|
|||
}
|
||||
|
||||
// TODO copied from runtime-core
|
||||
export function mergeProps(...args: Data[]) {
|
||||
export function mergeProps(...args: Data[]): Data {
|
||||
const ret: Data = {}
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const toMerge = args[i]
|
||||
|
@ -185,7 +185,7 @@ export function mergeProps(...args: Data[]) {
|
|||
return ret
|
||||
}
|
||||
|
||||
export function setText(el: Node, ...values: any[]) {
|
||||
export function setText(el: Node, ...values: any[]): void {
|
||||
const text = values.map(v => toDisplayString(v)).join('')
|
||||
const oldVal = recordPropMetadata(el, 'textContent', text)
|
||||
if (text !== oldVal) {
|
||||
|
@ -193,7 +193,7 @@ export function setText(el: Node, ...values: any[]) {
|
|||
}
|
||||
}
|
||||
|
||||
export function setHtml(el: Element, value: any) {
|
||||
export function setHtml(el: Element, value: any): void {
|
||||
const oldVal = recordPropMetadata(el, 'innerHTML', value)
|
||||
if (value !== oldVal) {
|
||||
el.innerHTML = value
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
import { warn } from '../warning'
|
||||
import { recordPropMetadata } from '../componentMetadata'
|
||||
|
||||
export function setStyle(el: HTMLElement, value: any) {
|
||||
export function setStyle(el: HTMLElement, value: any): void {
|
||||
const prev = recordPropMetadata(el, 'style', (value = normalizeStyle(value)))
|
||||
patchStyle(el, prev, value)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export function template(html: string) {
|
|||
t.innerHTML = html
|
||||
return t.content.firstChild!
|
||||
}
|
||||
return () => (node || (node = create())).cloneNode(true)
|
||||
return (): Node => (node || (node = create())).cloneNode(true)
|
||||
}
|
||||
|
||||
/*! #__NO_SIDE_EFFECTS__ */
|
||||
|
|
|
@ -32,7 +32,7 @@ export function setRef(
|
|||
ref: NodeRef,
|
||||
oldRef?: NodeRef,
|
||||
refFor = false,
|
||||
) {
|
||||
): NodeRef | undefined {
|
||||
if (!currentInstance) return
|
||||
const { setupState, isUnmounted } = currentInstance
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ export function callWithErrorHandling(
|
|||
instance: ComponentInternalInstance | null,
|
||||
type: ErrorTypes,
|
||||
args?: unknown[],
|
||||
) {
|
||||
): any {
|
||||
let res
|
||||
try {
|
||||
res = args ? fn(...args) : fn()
|
||||
|
@ -116,7 +116,7 @@ export function handleError(
|
|||
instance: ComponentInternalInstance | null,
|
||||
type: ErrorTypes,
|
||||
throwInDev = true,
|
||||
) {
|
||||
): void {
|
||||
if (instance) {
|
||||
let cur = instance.parent
|
||||
// in production the hook receives only the error code
|
||||
|
|
|
@ -8,11 +8,14 @@ export const DIRECTIVES = 'directives'
|
|||
|
||||
export type AssetTypes = typeof COMPONENTS | typeof DIRECTIVES
|
||||
|
||||
export function resolveComponent(name: string, maybeSelfReference?: boolean) {
|
||||
export function resolveComponent(
|
||||
name: string,
|
||||
maybeSelfReference?: boolean,
|
||||
): string | Component {
|
||||
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name
|
||||
}
|
||||
|
||||
export function resolveDirective(name: string) {
|
||||
export function resolveDirective(name: string): Directive | undefined {
|
||||
return resolveAsset(DIRECTIVES, name)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,4 +2,7 @@ import { toHandlers as _toHandlers } from '@vue/runtime-shared'
|
|||
import { warn } from '../warning'
|
||||
import { NOOP } from '@vue/shared'
|
||||
|
||||
export const toHandlers = _toHandlers.bind(undefined, __DEV__ ? warn : NOOP)
|
||||
export const toHandlers: (
|
||||
obj: Record<string, any>,
|
||||
preserveCaseIfNecessary?: boolean | undefined,
|
||||
) => Record<string, any> = _toHandlers.bind(undefined, __DEV__ ? warn : NOOP)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Core API ------------------------------------------------------------------
|
||||
|
||||
export const version = __VERSION__
|
||||
export const version: string = __VERSION__
|
||||
export {
|
||||
// core
|
||||
type Ref,
|
||||
|
|
|
@ -11,7 +11,7 @@ let perf: Performance
|
|||
export function startMeasure(
|
||||
instance: ComponentInternalInstance,
|
||||
type: string,
|
||||
) {
|
||||
): void {
|
||||
if (instance.appContext.config.performance && isSupported()) {
|
||||
perf.mark(`vue-${type}-${instance.uid}`)
|
||||
}
|
||||
|
@ -21,7 +21,10 @@ export function startMeasure(
|
|||
}
|
||||
}
|
||||
|
||||
export function endMeasure(instance: ComponentInternalInstance, type: string) {
|
||||
export function endMeasure(
|
||||
instance: ComponentInternalInstance,
|
||||
type: string,
|
||||
): void {
|
||||
if (instance.appContext.config.performance && isSupported()) {
|
||||
const startTag = `vue-${type}-${instance.uid}`
|
||||
const endTag = startTag + `:end`
|
||||
|
|
|
@ -15,7 +15,7 @@ import { queueJob, queuePostFlushCb } from './scheduler'
|
|||
import { VaporErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
|
||||
import { invokeDirectiveHook } from './directives'
|
||||
|
||||
export function renderEffect(cb: () => void) {
|
||||
export function renderEffect(cb: () => void): void {
|
||||
const instance = getCurrentInstance()
|
||||
const scope = getCurrentScope()
|
||||
|
||||
|
@ -94,7 +94,7 @@ export function renderEffect(cb: () => void) {
|
|||
export function firstEffect(
|
||||
instance: ComponentInternalInstance,
|
||||
fn: () => void,
|
||||
) {
|
||||
): void {
|
||||
const effect = new ReactiveEffect(fn)
|
||||
const job: SchedulerJob = () => effect.run()
|
||||
job.flags! |= SchedulerJobFlags.PRE
|
||||
|
|
|
@ -32,7 +32,7 @@ let postFlushIndex = 0
|
|||
const resolvedPromise = /*#__PURE__*/ Promise.resolve() as Promise<any>
|
||||
let currentFlushPromise: Promise<void> | null = null
|
||||
|
||||
export function queueJob(job: SchedulerJob) {
|
||||
export function queueJob(job: SchedulerJob): void {
|
||||
let lastOne: SchedulerJob | undefined
|
||||
if (!(job.flags! & SchedulerJobFlags.QUEUED)) {
|
||||
if (job.id == null) {
|
||||
|
@ -54,7 +54,7 @@ export function queueJob(job: SchedulerJob) {
|
|||
}
|
||||
}
|
||||
|
||||
export function queuePostFlushCb(cb: SchedulerJobs) {
|
||||
export function queuePostFlushCb(cb: SchedulerJobs): void {
|
||||
if (!isArray(cb)) {
|
||||
if (!(cb.flags! & SchedulerJobFlags.QUEUED)) {
|
||||
pendingPostFlushCbs.push(cb)
|
||||
|
@ -78,7 +78,7 @@ function queueFlush() {
|
|||
}
|
||||
}
|
||||
|
||||
export function flushPostFlushCbs() {
|
||||
export function flushPostFlushCbs(): void {
|
||||
if (!pendingPostFlushCbs.length) return
|
||||
|
||||
const deduped = [...new Set(pendingPostFlushCbs)]
|
||||
|
|
|
@ -15,7 +15,7 @@ type TraceEntry = {
|
|||
|
||||
type ComponentTraceStack = TraceEntry[]
|
||||
|
||||
export function warn(msg: string, ...args: any[]) {
|
||||
export function warn(msg: string, ...args: any[]): void {
|
||||
// avoid props formatting or warn handler tracking deps that might be mutated
|
||||
// during patch, leading to infinite recursion.
|
||||
pauseTracking()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { initCustomFormatter } from '@vue/runtime-dom'
|
||||
|
||||
export function initDev() {
|
||||
export function initDev(): void {
|
||||
if (__BROWSER__) {
|
||||
/* istanbul ignore if */
|
||||
if (!__ESM_BUNDLER__) {
|
||||
|
|
|
@ -10,7 +10,7 @@ if (__DEV__) {
|
|||
|
||||
export * from '@vue/runtime-vapor'
|
||||
|
||||
export const compile = () => {
|
||||
export const compile = (): void => {
|
||||
if (__DEV__) {
|
||||
console.warn(
|
||||
`Runtime compilation is not supported in this build of Vue.` +
|
||||
|
|
Loading…
Reference in New Issue