mirror of https://github.com/vuejs/core.git
style: fix lint errors in vapor
This commit is contained in:
parent
a82d070890
commit
dce55475a5
|
|
@ -1,4 +1,4 @@
|
||||||
import { type RootNode, BindingTypes } from '@vue/compiler-dom'
|
import { BindingTypes, type RootNode } from '@vue/compiler-dom'
|
||||||
import { type CompilerOptions, compile as _compile } from '../src'
|
import { type CompilerOptions, compile as _compile } from '../src'
|
||||||
|
|
||||||
function compile(template: string | RootNode, options: CompilerOptions = {}) {
|
function compile(template: string | RootNode, options: CompilerOptions = {}) {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { ErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
import { ErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
type RootIRNode,
|
|
||||||
type CompilerOptions,
|
type CompilerOptions,
|
||||||
parse,
|
|
||||||
transform,
|
|
||||||
transformVBind,
|
|
||||||
transformElement,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
type RootIRNode,
|
||||||
compile as _compile,
|
compile as _compile,
|
||||||
generate,
|
generate,
|
||||||
|
parse,
|
||||||
|
transform,
|
||||||
|
transformElement,
|
||||||
|
transformVBind,
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
|
|
||||||
function compileWithVBind(
|
function compileWithVBind(
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ import {
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
type CompilerOptions,
|
type CompilerOptions,
|
||||||
compile as _compile,
|
|
||||||
RootIRNode,
|
|
||||||
transform,
|
|
||||||
generate,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
type RootIRNode,
|
||||||
|
compile as _compile,
|
||||||
|
generate,
|
||||||
|
transform,
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
import { getBaseTransformPreset } from '../../src/compile'
|
import { getBaseTransformPreset } from '../../src/compile'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { BindingTypes, ErrorCodes, parse, NodeTypes } from '@vue/compiler-dom'
|
import { BindingTypes, ErrorCodes, NodeTypes, parse } from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
type CompilerOptions,
|
type CompilerOptions,
|
||||||
compile as _compile,
|
|
||||||
RootIRNode,
|
|
||||||
transform,
|
|
||||||
generate,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
type RootIRNode,
|
||||||
|
compile as _compile,
|
||||||
|
generate,
|
||||||
|
transform,
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
|
|
||||||
import { transformVOn } from '../../src/transforms/vOn'
|
import { transformVOn } from '../../src/transforms/vOn'
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { BindingTypes, NodeTypes, parse } from '@vue/compiler-dom'
|
import { BindingTypes, NodeTypes, parse } from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
type CompilerOptions,
|
type CompilerOptions,
|
||||||
compile as _compile,
|
|
||||||
transform,
|
|
||||||
generate as generate,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
RootIRNode,
|
type RootIRNode,
|
||||||
|
compile as _compile,
|
||||||
|
generate as generate,
|
||||||
|
transform,
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
import { getBaseTransformPreset } from '../../src/compile'
|
import { getBaseTransformPreset } from '../../src/compile'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ import {
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
type CompilerOptions,
|
type CompilerOptions,
|
||||||
compile as _compile,
|
|
||||||
RootIRNode,
|
|
||||||
transform,
|
|
||||||
generate,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
type RootIRNode,
|
||||||
|
compile as _compile,
|
||||||
|
generate,
|
||||||
|
transform,
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
import { getBaseTransformPreset } from '../../src/compile'
|
import { getBaseTransformPreset } from '../../src/compile'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import {
|
import {
|
||||||
type CodegenResult,
|
|
||||||
type CompilerOptions as BaseCompilerOptions,
|
type CompilerOptions as BaseCompilerOptions,
|
||||||
type RootNode,
|
type CodegenResult,
|
||||||
parse,
|
|
||||||
defaultOnError,
|
|
||||||
createCompilerError,
|
|
||||||
ErrorCodes,
|
ErrorCodes,
|
||||||
|
type RootNode,
|
||||||
|
createCompilerError,
|
||||||
|
defaultOnError,
|
||||||
|
parse,
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
import { extend, isString } from '@vue/shared'
|
import { extend, isString } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import {
|
import {
|
||||||
CompilerError,
|
type CompilerError,
|
||||||
SourceLocation,
|
type SourceLocation,
|
||||||
createCompilerError,
|
createCompilerError,
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
import {
|
import {
|
||||||
|
BindingTypes,
|
||||||
type CodegenOptions,
|
type CodegenOptions,
|
||||||
type CodegenResult,
|
type CodegenResult,
|
||||||
|
NewlineType,
|
||||||
type Position,
|
type Position,
|
||||||
type SourceLocation,
|
type SourceLocation,
|
||||||
NewlineType,
|
|
||||||
advancePositionWithMutation,
|
|
||||||
locStub,
|
|
||||||
BindingTypes,
|
|
||||||
createSimpleExpression,
|
|
||||||
walkIdentifiers,
|
|
||||||
advancePositionWithClone,
|
advancePositionWithClone,
|
||||||
|
advancePositionWithMutation,
|
||||||
|
createSimpleExpression,
|
||||||
isSimpleIdentifier,
|
isSimpleIdentifier,
|
||||||
|
locStub,
|
||||||
|
walkIdentifiers,
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
type IRDynamicChildren,
|
|
||||||
type RootIRNode,
|
|
||||||
type SetPropIRNode,
|
|
||||||
type IRExpression,
|
|
||||||
type OperationNode,
|
|
||||||
type VaporHelper,
|
|
||||||
type SetEventIRNode,
|
|
||||||
type WithDirectiveIRNode,
|
|
||||||
type SetTextIRNode,
|
|
||||||
type SetHtmlIRNode,
|
|
||||||
type CreateTextNodeIRNode,
|
|
||||||
type InsertNodeIRNode,
|
|
||||||
type PrependNodeIRNode,
|
|
||||||
type AppendNodeIRNode,
|
type AppendNodeIRNode,
|
||||||
|
type CreateTextNodeIRNode,
|
||||||
|
type IRDynamicChildren,
|
||||||
|
type IRExpression,
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
type InsertNodeIRNode,
|
||||||
|
type OperationNode,
|
||||||
|
type PrependNodeIRNode,
|
||||||
|
type RootIRNode,
|
||||||
|
type SetEventIRNode,
|
||||||
|
type SetHtmlIRNode,
|
||||||
|
type SetPropIRNode,
|
||||||
|
type SetTextIRNode,
|
||||||
|
type VaporHelper,
|
||||||
|
type WithDirectiveIRNode,
|
||||||
} from './ir'
|
} from './ir'
|
||||||
import { SourceMapGenerator } from 'source-map-js'
|
import { SourceMapGenerator } from 'source-map-js'
|
||||||
import { camelize, isGloballyAllowed, isString, makeMap } from '@vue/shared'
|
import { camelize, isGloballyAllowed, isString, makeMap } from '@vue/shared'
|
||||||
|
|
@ -212,7 +212,7 @@ function createCodegenContext(
|
||||||
generatedLine: context.line,
|
generatedLine: context.line,
|
||||||
generatedColumn: context.column - 1,
|
generatedColumn: context.column - 1,
|
||||||
source: filename,
|
source: filename,
|
||||||
// @ts-ignore it is possible to be null
|
// @ts-expect-error it is possible to be null
|
||||||
name,
|
name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
import {
|
import {
|
||||||
|
type AllNode,
|
||||||
|
type TransformOptions as BaseTransformOptions,
|
||||||
|
type CompilerCompatOptions,
|
||||||
|
type ElementNode,
|
||||||
|
NodeTypes,
|
||||||
|
type ParentNode,
|
||||||
type RootNode,
|
type RootNode,
|
||||||
type TemplateChildNode,
|
type TemplateChildNode,
|
||||||
type ElementNode,
|
|
||||||
type TransformOptions as BaseTransformOptions,
|
|
||||||
type ParentNode,
|
|
||||||
type AllNode,
|
|
||||||
type CompilerCompatOptions,
|
|
||||||
NodeTypes,
|
|
||||||
defaultOnError,
|
defaultOnError,
|
||||||
defaultOnWarn,
|
defaultOnWarn,
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
import { EMPTY_OBJ, NOOP, isArray } from '@vue/shared'
|
import { EMPTY_OBJ, NOOP, extend, isArray } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
type OperationNode,
|
|
||||||
type RootIRNode,
|
|
||||||
type IRDynamicInfo,
|
type IRDynamicInfo,
|
||||||
type IRExpression,
|
type IRExpression,
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
type OperationNode,
|
||||||
|
type RootIRNode,
|
||||||
} from './ir'
|
} from './ir'
|
||||||
import type { VaporDirectiveNode, HackOptions } from './ir'
|
import type { HackOptions, VaporDirectiveNode } from './ir'
|
||||||
|
|
||||||
export type NodeTransform = (
|
export type NodeTransform = (
|
||||||
node: RootNode | TemplateChildNode,
|
node: RootNode | TemplateChildNode,
|
||||||
|
|
@ -73,30 +73,33 @@ function createRootContext(
|
||||||
parent: null,
|
parent: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
root: null!, // set later
|
root: null!, // set later
|
||||||
options: {
|
options: extend(
|
||||||
filename: '',
|
{},
|
||||||
prefixIdentifiers: false,
|
{
|
||||||
hoistStatic: false,
|
filename: '',
|
||||||
hmr: false,
|
prefixIdentifiers: false,
|
||||||
cacheHandlers: false,
|
hoistStatic: false,
|
||||||
nodeTransforms: [],
|
hmr: false,
|
||||||
directiveTransforms: {},
|
cacheHandlers: false,
|
||||||
transformHoist: null,
|
nodeTransforms: [],
|
||||||
isBuiltInComponent: NOOP,
|
directiveTransforms: {},
|
||||||
isCustomElement: NOOP,
|
transformHoist: null,
|
||||||
expressionPlugins: [],
|
isBuiltInComponent: NOOP,
|
||||||
scopeId: null,
|
isCustomElement: NOOP,
|
||||||
slotted: true,
|
expressionPlugins: [],
|
||||||
ssr: false,
|
scopeId: null,
|
||||||
inSSR: false,
|
slotted: true,
|
||||||
ssrCssVars: ``,
|
ssr: false,
|
||||||
bindingMetadata: EMPTY_OBJ,
|
inSSR: false,
|
||||||
inline: false,
|
ssrCssVars: ``,
|
||||||
isTS: false,
|
bindingMetadata: EMPTY_OBJ,
|
||||||
onError: defaultOnError,
|
inline: false,
|
||||||
onWarn: defaultOnWarn,
|
isTS: false,
|
||||||
...options,
|
onError: defaultOnError,
|
||||||
},
|
onWarn: defaultOnWarn,
|
||||||
|
},
|
||||||
|
options,
|
||||||
|
),
|
||||||
dynamic: ir.dynamic,
|
dynamic: ir.dynamic,
|
||||||
inVOnce: false,
|
inVOnce: false,
|
||||||
|
|
||||||
|
|
@ -175,8 +178,7 @@ function createContext<T extends TemplateChildNode>(
|
||||||
parent: TransformContext<ParentNode>,
|
parent: TransformContext<ParentNode>,
|
||||||
index: number,
|
index: number,
|
||||||
): TransformContext<T> {
|
): TransformContext<T> {
|
||||||
const ctx: TransformContext<T> = {
|
const ctx: TransformContext<T> = extend({}, parent, {
|
||||||
...parent,
|
|
||||||
node,
|
node,
|
||||||
parent,
|
parent,
|
||||||
index,
|
index,
|
||||||
|
|
@ -190,7 +192,7 @@ function createContext<T extends TemplateChildNode>(
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
children: {},
|
children: {},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import {
|
import {
|
||||||
type ElementNode,
|
|
||||||
type AttributeNode,
|
type AttributeNode,
|
||||||
NodeTypes,
|
type ElementNode,
|
||||||
ElementTypes,
|
ElementTypes,
|
||||||
|
NodeTypes,
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
import { isBuiltInDirective, isVoidTag } from '@vue/shared'
|
import { isBuiltInDirective, isVoidTag } from '@vue/shared'
|
||||||
import { NodeTransform, TransformContext } from '../transform'
|
import type { NodeTransform, TransformContext } from '../transform'
|
||||||
import { VaporDirectiveNode, IRNodeTypes } from '../ir'
|
import { IRNodeTypes, type VaporDirectiveNode } from '../ir'
|
||||||
|
|
||||||
export const transformElement: NodeTransform = (node, ctx) => {
|
export const transformElement: NodeTransform = (node, ctx) => {
|
||||||
return function postTransformElement() {
|
return function postTransformElement() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { NodeTypes, SimpleExpressionNode } from '@vue/compiler-dom'
|
import { NodeTypes, type SimpleExpressionNode } from '@vue/compiler-dom'
|
||||||
import { NodeTransform } from '../transform'
|
import type { NodeTransform } from '../transform'
|
||||||
import { IRNodeTypes } from '../ir'
|
import { IRNodeTypes } from '../ir'
|
||||||
|
|
||||||
export const transformInterpolation: NodeTransform = (node, ctx) => {
|
export const transformInterpolation: NodeTransform = (node, ctx) => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {
|
import {
|
||||||
|
ErrorCodes,
|
||||||
createCompilerError,
|
createCompilerError,
|
||||||
createSimpleExpression,
|
createSimpleExpression,
|
||||||
ErrorCodes,
|
|
||||||
} from '@vue/compiler-core'
|
} from '@vue/compiler-core'
|
||||||
import { camelize } from '@vue/shared'
|
import { camelize } from '@vue/shared'
|
||||||
import { IRNodeTypes } from '../ir'
|
import { IRNodeTypes } from '../ir'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { IRNodeTypes } from '../ir'
|
import { IRNodeTypes } from '../ir'
|
||||||
import { DirectiveTransform } from '../transform'
|
import type { DirectiveTransform } from '../transform'
|
||||||
import { DOMErrorCodes, createDOMCompilerError } from '@vue/compiler-dom'
|
import { DOMErrorCodes, createDOMCompilerError } from '@vue/compiler-dom'
|
||||||
|
|
||||||
export const transformVHtml: DirectiveTransform = (dir, node, context) => {
|
export const transformVHtml: DirectiveTransform = (dir, node, context) => {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import {
|
import {
|
||||||
createCompilerError,
|
|
||||||
ElementTypes,
|
ElementTypes,
|
||||||
ErrorCodes,
|
ErrorCodes,
|
||||||
|
createCompilerError,
|
||||||
} from '@vue/compiler-core'
|
} from '@vue/compiler-core'
|
||||||
import type { DirectiveTransform } from '../transform'
|
import type { DirectiveTransform } from '../transform'
|
||||||
import { IRNodeTypes, KeyOverride, SetEventIRNode } from '../ir'
|
import { IRNodeTypes, type KeyOverride, type SetEventIRNode } from '../ir'
|
||||||
import { resolveModifiers } from '@vue/compiler-dom'
|
import { resolveModifiers } from '@vue/compiler-dom'
|
||||||
import { camelize } from '@vue/shared'
|
import { camelize, extend } from '@vue/shared'
|
||||||
|
|
||||||
export const transformVOn: DirectiveTransform = (dir, node, context) => {
|
export const transformVOn: DirectiveTransform = (dir, node, context) => {
|
||||||
let { arg, exp, loc, modifiers } = dir
|
let { arg, exp, loc, modifiers } = dir
|
||||||
|
|
@ -54,7 +54,7 @@ export const transformVOn: DirectiveTransform = (dir, node, context) => {
|
||||||
|
|
||||||
if (nonKeyModifiers.includes('right')) {
|
if (nonKeyModifiers.includes('right')) {
|
||||||
if (isStaticClick) {
|
if (isStaticClick) {
|
||||||
arg = { ...arg, content: 'contextmenu' }
|
arg = extend({}, arg, { content: 'contextmenu' })
|
||||||
} else if (!arg.isStatic) {
|
} else if (!arg.isStatic) {
|
||||||
keyOverride = ['click', 'contextmenu']
|
keyOverride = ['click', 'contextmenu']
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ export const transformVOn: DirectiveTransform = (dir, node, context) => {
|
||||||
// TODO error here
|
// TODO error here
|
||||||
}
|
}
|
||||||
if (isStaticClick) {
|
if (isStaticClick) {
|
||||||
arg = { ...arg, content: 'mouseup' }
|
arg = extend({}, arg, { content: 'mouseup' })
|
||||||
} else if (!arg.isStatic) {
|
} else if (!arg.isStatic) {
|
||||||
keyOverride = ['click', 'mouseup']
|
keyOverride = ['click', 'mouseup']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { NodeTypes, findDir } from '@vue/compiler-dom'
|
import { NodeTypes, findDir } from '@vue/compiler-dom'
|
||||||
import { NodeTransform } from '../transform'
|
import type { NodeTransform } from '../transform'
|
||||||
|
|
||||||
const seen = new WeakSet()
|
const seen = new WeakSet()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { DOMErrorCodes, createDOMCompilerError } from '@vue/compiler-dom'
|
import { DOMErrorCodes, createDOMCompilerError } from '@vue/compiler-dom'
|
||||||
import { DirectiveTransform } from '../transform'
|
import type { DirectiveTransform } from '../transform'
|
||||||
import { IRNodeTypes } from '../ir'
|
import { IRNodeTypes } from '../ir'
|
||||||
|
|
||||||
export const transformVText: DirectiveTransform = (dir, node, context) => {
|
export const transformVText: DirectiveTransform = (dir, node, context) => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { EffectScope, Ref, ref } from '@vue/reactivity'
|
import { EffectScope, type Ref, ref } from '@vue/reactivity'
|
||||||
import {
|
import {
|
||||||
onEffectCleanup,
|
onEffectCleanup,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {
|
import {
|
||||||
template,
|
|
||||||
children,
|
children,
|
||||||
setText,
|
|
||||||
render,
|
|
||||||
ref,
|
ref,
|
||||||
|
render,
|
||||||
|
setText,
|
||||||
|
template,
|
||||||
unmountComponent,
|
unmountComponent,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
} from '../src'
|
} from '../src'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { template, fragment } from '../src'
|
import { fragment, template } from '../src'
|
||||||
|
|
||||||
describe('api: template', () => {
|
describe('api: template', () => {
|
||||||
test('create element', () => {
|
test('create element', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { template, children, withDirectives, on, vShow, render } from '../src'
|
import { children, on, render, template, vShow, withDirectives } from '../src'
|
||||||
import { ref, defineComponent, nextTick } from 'vue'
|
import { defineComponent, nextTick, ref } from 'vue'
|
||||||
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
|
import { afterEach, beforeEach, describe, expect, test } from 'vitest'
|
||||||
|
|
||||||
let host: HTMLElement
|
let host: HTMLElement
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import {
|
import {
|
||||||
ComputedRef,
|
type ComputedRef,
|
||||||
Ref,
|
type DebuggerOptions,
|
||||||
|
type EffectScheduler,
|
||||||
|
ReactiveEffect,
|
||||||
|
ReactiveFlags,
|
||||||
|
type Ref,
|
||||||
|
getCurrentScope,
|
||||||
isReactive,
|
isReactive,
|
||||||
isRef,
|
isRef,
|
||||||
ReactiveEffect,
|
|
||||||
EffectScheduler,
|
|
||||||
DebuggerOptions,
|
|
||||||
getCurrentScope,
|
|
||||||
ReactiveFlags,
|
|
||||||
} from '@vue/reactivity'
|
} from '@vue/reactivity'
|
||||||
import {
|
import {
|
||||||
EMPTY_OBJ,
|
EMPTY_OBJ,
|
||||||
|
|
@ -25,10 +25,10 @@ import {
|
||||||
import { currentInstance } from './component'
|
import { currentInstance } from './component'
|
||||||
import {
|
import {
|
||||||
type Scheduler,
|
type Scheduler,
|
||||||
|
type SchedulerJob,
|
||||||
getVaporSchedulerByFlushMode,
|
getVaporSchedulerByFlushMode,
|
||||||
vaporPostScheduler,
|
vaporPostScheduler,
|
||||||
vaporSyncScheduler,
|
vaporSyncScheduler,
|
||||||
SchedulerJob,
|
|
||||||
} from './scheduler'
|
} from './scheduler'
|
||||||
import {
|
import {
|
||||||
VaporErrorCodes,
|
VaporErrorCodes,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { EffectScope, Ref, ref } from '@vue/reactivity'
|
import { EffectScope, type Ref, ref } from '@vue/reactivity'
|
||||||
|
|
||||||
import { EMPTY_OBJ } from '@vue/shared'
|
import { EMPTY_OBJ } from '@vue/shared'
|
||||||
import { Block } from './render'
|
import type { Block } from './render'
|
||||||
import { type DirectiveBinding } from './directive'
|
import type { DirectiveBinding } from './directive'
|
||||||
import {
|
import {
|
||||||
type ComponentPropsOptions,
|
type ComponentPropsOptions,
|
||||||
type NormalizedPropsOptions,
|
type NormalizedPropsOptions,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// NOTE: runtime-core/src/componentProps.ts
|
// NOTE: runtime-core/src/componentProps.ts
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Data,
|
type Data,
|
||||||
EMPTY_ARR,
|
EMPTY_ARR,
|
||||||
EMPTY_OBJ,
|
EMPTY_OBJ,
|
||||||
camelize,
|
camelize,
|
||||||
|
|
@ -13,7 +13,7 @@ import {
|
||||||
isReservedProp,
|
isReservedProp,
|
||||||
} from '@vue/shared'
|
} from '@vue/shared'
|
||||||
import { shallowReactive, toRaw } from '@vue/reactivity'
|
import { shallowReactive, toRaw } from '@vue/reactivity'
|
||||||
import { type ComponentInternalInstance, type Component } from './component'
|
import type { Component, ComponentInternalInstance } from './component'
|
||||||
|
|
||||||
export type ComponentPropsOptions<P = Data> =
|
export type ComponentPropsOptions<P = Data> =
|
||||||
| ComponentObjectPropsOptions<P>
|
| ComponentObjectPropsOptions<P>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { isFunction } from '@vue/shared'
|
import { isFunction } from '@vue/shared'
|
||||||
import { currentInstance, type ComponentInternalInstance } from './component'
|
import { type ComponentInternalInstance, currentInstance } from './component'
|
||||||
import { watchEffect } from './apiWatch'
|
import { watchEffect } from './apiWatch'
|
||||||
|
|
||||||
export type DirectiveModifiers<M extends string = string> = Record<M, boolean>
|
export type DirectiveModifiers<M extends string = string> = Record<M, boolean>
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,16 @@ export function setDynamicProp(el: Element, key: string, val: any) {
|
||||||
|
|
||||||
type Children = Record<number, [ChildNode, Children]>
|
type Children = Record<number, [ChildNode, Children]>
|
||||||
export function children(n: Node): Children {
|
export function children(n: Node): Children {
|
||||||
return { ...Array.from(n.childNodes).map((n) => [n, children(n)]) }
|
const result: Children = {}
|
||||||
|
const array = Array.from(n.childNodes)
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
const n = array[i]
|
||||||
|
result[i] = [n, children(n)]
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTextNode(val: unknown): Text {
|
export function createTextNode(val: unknown): Text {
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
return document.createTextNode(toDisplayString(val))
|
return document.createTextNode(toDisplayString(val))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// The ultimate aim is to uncouple this replicated code and
|
// The ultimate aim is to uncouple this replicated code and
|
||||||
// facilitate its shared use between two runtimes.
|
// facilitate its shared use between two runtimes.
|
||||||
|
|
||||||
import { type ComponentInternalInstance } from './component'
|
import type { ComponentInternalInstance } from './component'
|
||||||
import { isFunction, isPromise } from '@vue/shared'
|
import { isFunction, isPromise } from '@vue/shared'
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
import { VaporLifecycleHooks } from './enums'
|
import { VaporLifecycleHooks } from './enums'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { proxyRefs } from '@vue/reactivity'
|
import { proxyRefs } from '@vue/reactivity'
|
||||||
import { invokeArrayFns, type Data } from '@vue/shared'
|
import { type Data, invokeArrayFns } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
type Component,
|
type Component,
|
||||||
type ComponentInternalInstance,
|
type ComponentInternalInstance,
|
||||||
|
|
@ -33,7 +33,8 @@ export function render(
|
||||||
|
|
||||||
export function normalizeContainer(container: string | ParentNode): ParentNode {
|
export function normalizeContainer(container: string | ParentNode): ParentNode {
|
||||||
return typeof container === 'string'
|
return typeof container === 'string'
|
||||||
? (document.querySelector(container) as ParentNode)
|
? // eslint-disable-next-line no-restricted-globals
|
||||||
|
(document.querySelector(container) as ParentNode)
|
||||||
: container
|
: container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { ReactiveEffect } from '@vue/reactivity'
|
import type { ReactiveEffect } from '@vue/reactivity'
|
||||||
import { ComponentInternalInstance } from './component'
|
import type { ComponentInternalInstance } from './component'
|
||||||
import { getIsRendering } from '.'
|
import { getIsRendering } from '.'
|
||||||
|
|
||||||
export interface SchedulerJob extends Function {
|
export interface SchedulerJob extends Function {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ export const template = (str: string): (() => DocumentFragment) => {
|
||||||
return () => {
|
return () => {
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
cached = true
|
cached = true
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
const t = document.createElement('template')
|
const t = document.createElement('template')
|
||||||
t.innerHTML = str
|
t.innerHTML = str
|
||||||
// first render: insert the node directly.
|
// first render: insert the node directly.
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ import {
|
||||||
children,
|
children,
|
||||||
on,
|
on,
|
||||||
ref,
|
ref,
|
||||||
template,
|
render as renderComponent,
|
||||||
watchEffect,
|
|
||||||
setText,
|
setText,
|
||||||
render as renderComponent // TODO:
|
template,
|
||||||
|
watchEffect, // TODO:
|
||||||
} from '@vue/vapor'
|
} from '@vue/vapor'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -22,7 +22,7 @@ export default {
|
||||||
|
|
||||||
Object.defineProperty(__returned__, '__isScriptSetup', {
|
Object.defineProperty(__returned__, '__isScriptSetup', {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: true
|
value: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return __returned__
|
return __returned__
|
||||||
|
|
@ -32,7 +32,7 @@ export default {
|
||||||
const t0 = template('<button></button>')
|
const t0 = template('<button></button>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const {
|
const {
|
||||||
0: [n1]
|
0: [n1],
|
||||||
} = children(n0)
|
} = children(n0)
|
||||||
on(n1, 'click', _ctx.handleClick)
|
on(n1, 'click', _ctx.handleClick)
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
|
|
@ -55,36 +55,36 @@ export default {
|
||||||
/* <Comp :inline-double="count * 2" /> */
|
/* <Comp :inline-double="count * 2" /> */
|
||||||
get inlineDouble() {
|
get inlineDouble() {
|
||||||
return _ctx.count * 2
|
return _ctx.count * 2
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
n0
|
n0,
|
||||||
)
|
)
|
||||||
|
|
||||||
return n0
|
return n0
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const child = {
|
const child = {
|
||||||
props: {
|
props: {
|
||||||
count: { type: Number, default: 1 },
|
count: { type: Number, default: 1 },
|
||||||
inlineDouble: { type: Number, default: 2 }
|
inlineDouble: { type: Number, default: 2 },
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props) {
|
setup(props) {
|
||||||
watch(
|
watch(
|
||||||
() => props.count,
|
() => props.count,
|
||||||
v => console.log('count changed', v)
|
v => console.log('count changed', v),
|
||||||
)
|
)
|
||||||
watch(
|
watch(
|
||||||
() => props.inlineDouble,
|
() => props.inlineDouble,
|
||||||
v => console.log('inlineDouble changed', v)
|
v => console.log('inlineDouble changed', v),
|
||||||
)
|
)
|
||||||
|
|
||||||
const __returned__ = {}
|
const __returned__ = {}
|
||||||
|
|
||||||
Object.defineProperty(__returned__, '__isScriptSetup', {
|
Object.defineProperty(__returned__, '__isScriptSetup', {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: true
|
value: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return __returned__
|
return __returned__
|
||||||
|
|
@ -94,11 +94,11 @@ const child = {
|
||||||
const t0 = template('<p></p>')
|
const t0 = template('<p></p>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const {
|
const {
|
||||||
0: [n1]
|
0: [n1],
|
||||||
} = children(n0)
|
} = children(n0)
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setText(n1, void 0, _ctx.count + ' * 2 = ' + _ctx.inlineDouble)
|
setText(n1, void 0, _ctx.count + ' * 2 = ' + _ctx.inlineDouble)
|
||||||
})
|
})
|
||||||
return n0
|
return n0
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue