mirror of https://github.com/vuejs/core.git
chore: fix runtime-vapor dts build
This commit is contained in:
parent
ddfd83639a
commit
b20bcf1fb6
|
@ -187,12 +187,9 @@ type NormalizedProp = PropOptions & {
|
||||||
/**
|
/**
|
||||||
* normalized value is a tuple of the actual normalized options
|
* normalized value is a tuple of the actual normalized options
|
||||||
* and an array of prop keys that need value casting (booleans and defaults)
|
* and an array of prop keys that need value casting (booleans and defaults)
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export type NormalizedProps = Record<string, NormalizedProp>
|
export type NormalizedProps = Record<string, NormalizedProp>
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export type NormalizedPropsOptions = [NormalizedProps, string[]] | []
|
export type NormalizedPropsOptions = [NormalizedProps, string[]] | []
|
||||||
|
|
||||||
export function initProps(
|
export function initProps(
|
||||||
|
|
|
@ -487,11 +487,22 @@ export const DeprecationTypes = (
|
||||||
// **IMPORTANT** These APIs are exposed solely for @vue/runtime-vapor and may
|
// **IMPORTANT** These APIs are exposed solely for @vue/runtime-vapor and may
|
||||||
// change without notice between versions. User code should never rely on them.
|
// change without notice between versions. User code should never rely on them.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* these types cannot be marked internal because runtime-vapor's type relies on
|
||||||
|
* them, but they should be considered internal
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
type ComponentInternalOptions,
|
||||||
|
type GenericComponentInstance,
|
||||||
|
type LifecycleHook,
|
||||||
|
} from './component'
|
||||||
|
export { type NormalizedPropsOptions } from './componentProps'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export {
|
export {
|
||||||
type NormalizedPropsOptions,
|
|
||||||
baseNormalizePropsOptions,
|
baseNormalizePropsOptions,
|
||||||
resolvePropValue,
|
resolvePropValue,
|
||||||
validateProps,
|
validateProps,
|
||||||
|
@ -507,14 +518,7 @@ export { type SchedulerJob, queueJob, flushOnAppMount } from './scheduler'
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export {
|
export { expose, nextUid, validateComponentName } from './component'
|
||||||
type ComponentInternalOptions,
|
|
||||||
type GenericComponentInstance,
|
|
||||||
type LifecycleHook,
|
|
||||||
expose,
|
|
||||||
nextUid,
|
|
||||||
validateComponentName,
|
|
||||||
} from './component'
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
import { Fragment, insert, normalizeBlock, prepend, remove } from '../src/block'
|
import {
|
||||||
|
VaporFragment,
|
||||||
|
insert,
|
||||||
|
normalizeBlock,
|
||||||
|
prepend,
|
||||||
|
remove,
|
||||||
|
} from '../src/block'
|
||||||
|
|
||||||
const node1 = document.createTextNode('node1')
|
const node1 = document.createTextNode('node1')
|
||||||
const node2 = document.createTextNode('node2')
|
const node2 = document.createTextNode('node2')
|
||||||
|
@ -13,7 +19,7 @@ describe('block + node ops', () => {
|
||||||
node2,
|
node2,
|
||||||
node3,
|
node3,
|
||||||
])
|
])
|
||||||
const frag = new Fragment(node2)
|
const frag = new VaporFragment(node2)
|
||||||
frag.anchor = anchor
|
frag.anchor = anchor
|
||||||
expect(normalizeBlock([node1, frag, [node3]])).toEqual([
|
expect(normalizeBlock([node1, frag, [node3]])).toEqual([
|
||||||
node1,
|
node1,
|
||||||
|
@ -39,14 +45,14 @@ describe('block + node ops', () => {
|
||||||
test('prepend', () => {
|
test('prepend', () => {
|
||||||
const container = document.createElement('div')
|
const container = document.createElement('div')
|
||||||
prepend(container, [node1], node2)
|
prepend(container, [node1], node2)
|
||||||
prepend(container, new Fragment(node3))
|
prepend(container, new VaporFragment(node3))
|
||||||
expect(Array.from(container.childNodes)).toEqual([node3, node1, node2])
|
expect(Array.from(container.childNodes)).toEqual([node3, node1, node2])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('remove', () => {
|
test('remove', () => {
|
||||||
const container = document.createElement('div')
|
const container = document.createElement('div')
|
||||||
container.append(node1, node2, node3)
|
container.append(node1, node2, node3)
|
||||||
const frag = new Fragment(node3)
|
const frag = new VaporFragment(node3)
|
||||||
remove([node1], container)
|
remove([node1], container)
|
||||||
remove(frag, container)
|
remove(frag, container)
|
||||||
expect(Array.from(container.childNodes)).toEqual([node2])
|
expect(Array.from(container.childNodes)).toEqual([node2])
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { resolveDynamicComponent } from '@vue/runtime-dom'
|
import { resolveDynamicComponent } from '@vue/runtime-dom'
|
||||||
import { DynamicFragment, type Fragment } from './block'
|
import { DynamicFragment, type VaporFragment } from './block'
|
||||||
import { createComponentWithFallback } from './component'
|
import { createComponentWithFallback } from './component'
|
||||||
import { renderEffect } from './renderEffect'
|
import { renderEffect } from './renderEffect'
|
||||||
import type { RawProps } from './componentProps'
|
import type { RawProps } from './componentProps'
|
||||||
|
@ -10,7 +10,7 @@ export function createDynamicComponent(
|
||||||
rawProps?: RawProps | null,
|
rawProps?: RawProps | null,
|
||||||
rawSlots?: RawSlots | null,
|
rawSlots?: RawSlots | null,
|
||||||
isSingleRoot?: boolean,
|
isSingleRoot?: boolean,
|
||||||
): Fragment {
|
): VaporFragment {
|
||||||
const frag = __DEV__
|
const frag = __DEV__
|
||||||
? new DynamicFragment('dynamic-component')
|
? new DynamicFragment('dynamic-component')
|
||||||
: new DynamicFragment()
|
: new DynamicFragment()
|
||||||
|
|
|
@ -9,13 +9,18 @@ import {
|
||||||
} from '@vue/reactivity'
|
} from '@vue/reactivity'
|
||||||
import { getSequence, isArray, isObject, isString } from '@vue/shared'
|
import { getSequence, isArray, isObject, isString } from '@vue/shared'
|
||||||
import { createComment, createTextNode } from './dom/node'
|
import { createComment, createTextNode } from './dom/node'
|
||||||
import { type Block, Fragment, insert, remove as removeBlock } from './block'
|
import {
|
||||||
|
type Block,
|
||||||
|
VaporFragment,
|
||||||
|
insert,
|
||||||
|
remove as removeBlock,
|
||||||
|
} from './block'
|
||||||
import { warn } from '@vue/runtime-dom'
|
import { warn } from '@vue/runtime-dom'
|
||||||
import { currentInstance, isVaporComponent } from './component'
|
import { currentInstance, isVaporComponent } from './component'
|
||||||
import type { DynamicSlot } from './componentSlots'
|
import type { DynamicSlot } from './componentSlots'
|
||||||
import { renderEffect } from './renderEffect'
|
import { renderEffect } from './renderEffect'
|
||||||
|
|
||||||
class ForBlock extends Fragment {
|
class ForBlock extends VaporFragment {
|
||||||
scope: EffectScope | undefined
|
scope: EffectScope | undefined
|
||||||
key: any
|
key: any
|
||||||
|
|
||||||
|
@ -64,13 +69,13 @@ export const createFor = (
|
||||||
isComponent = false,
|
isComponent = false,
|
||||||
once?: boolean,
|
once?: boolean,
|
||||||
// hydrationNode?: Node,
|
// hydrationNode?: Node,
|
||||||
): Fragment => {
|
): VaporFragment => {
|
||||||
let isMounted = false
|
let isMounted = false
|
||||||
let oldBlocks: ForBlock[] = []
|
let oldBlocks: ForBlock[] = []
|
||||||
let newBlocks: ForBlock[]
|
let newBlocks: ForBlock[]
|
||||||
let parent: ParentNode | undefined | null
|
let parent: ParentNode | undefined | null
|
||||||
const parentAnchor = __DEV__ ? createComment('for') : createTextNode()
|
const parentAnchor = __DEV__ ? createComment('for') : createTextNode()
|
||||||
const ref = new Fragment(oldBlocks)
|
const ref = new VaporFragment(oldBlocks)
|
||||||
const instance = currentInstance!
|
const instance = currentInstance!
|
||||||
|
|
||||||
if (__DEV__ && !instance) {
|
if (__DEV__ && !instance) {
|
||||||
|
|
|
@ -10,14 +10,14 @@ import { EffectScope, pauseTracking, resetTracking } from '@vue/reactivity'
|
||||||
|
|
||||||
export type Block =
|
export type Block =
|
||||||
| Node
|
| Node
|
||||||
| Fragment
|
| VaporFragment
|
||||||
| DynamicFragment
|
| DynamicFragment
|
||||||
| VaporComponentInstance
|
| VaporComponentInstance
|
||||||
| Block[]
|
| Block[]
|
||||||
|
|
||||||
export type BlockFn = (...args: any[]) => Block
|
export type BlockFn = (...args: any[]) => Block
|
||||||
|
|
||||||
export class Fragment {
|
export class VaporFragment {
|
||||||
nodes: Block
|
nodes: Block
|
||||||
anchor?: Node
|
anchor?: Node
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export class Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DynamicFragment extends Fragment {
|
export class DynamicFragment extends VaporFragment {
|
||||||
anchor: Node
|
anchor: Node
|
||||||
scope: EffectScope | undefined
|
scope: EffectScope | undefined
|
||||||
current?: BlockFn
|
current?: BlockFn
|
||||||
|
@ -76,8 +76,8 @@ export class DynamicFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFragment(val: NonNullable<unknown>): val is Fragment {
|
export function isFragment(val: NonNullable<unknown>): val is VaporFragment {
|
||||||
return val instanceof Fragment
|
return val instanceof VaporFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isBlock(val: NonNullable<unknown>): val is Block {
|
export function isBlock(val: NonNullable<unknown>): val is Block {
|
||||||
|
|
|
@ -64,8 +64,8 @@ import { setDynamicProps } from './dom/prop'
|
||||||
import {
|
import {
|
||||||
type DynamicSlotSource,
|
type DynamicSlotSource,
|
||||||
type RawSlots,
|
type RawSlots,
|
||||||
type Slot,
|
|
||||||
type StaticSlots,
|
type StaticSlots,
|
||||||
|
type VaporSlot,
|
||||||
dynamicSlotsProxyHandlers,
|
dynamicSlotsProxyHandlers,
|
||||||
getSlot,
|
getSlot,
|
||||||
} from './componentSlots'
|
} from './componentSlots'
|
||||||
|
@ -97,7 +97,7 @@ export interface ObjectVaporComponent
|
||||||
props?: any,
|
props?: any,
|
||||||
emit?: EmitFn,
|
emit?: EmitFn,
|
||||||
attrs?: any,
|
attrs?: any,
|
||||||
slots?: Record<string, Slot>,
|
slots?: Record<string, VaporSlot>,
|
||||||
): Block
|
): Block
|
||||||
|
|
||||||
name?: string
|
name?: string
|
||||||
|
@ -135,7 +135,7 @@ export type LooseRawProps = Record<
|
||||||
$?: DynamicPropsSource[]
|
$?: DynamicPropsSource[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type LooseRawSlots = Record<string, Slot | DynamicSlotSource[]> & {
|
type LooseRawSlots = Record<string, VaporSlot | DynamicSlotSource[]> & {
|
||||||
$?: DynamicSlotSource[]
|
$?: DynamicSlotSource[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ import { currentInstance } from '@vue/runtime-core'
|
||||||
import type { LooseRawProps, VaporComponentInstance } from './component'
|
import type { LooseRawProps, VaporComponentInstance } from './component'
|
||||||
import { renderEffect } from './renderEffect'
|
import { renderEffect } from './renderEffect'
|
||||||
|
|
||||||
export type RawSlots = Record<string, Slot> & {
|
export type RawSlots = Record<string, VaporSlot> & {
|
||||||
$?: DynamicSlotSource[]
|
$?: DynamicSlotSource[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StaticSlots = Record<string, Slot>
|
export type StaticSlots = Record<string, VaporSlot>
|
||||||
|
|
||||||
export type Slot = BlockFn
|
export type VaporSlot = BlockFn
|
||||||
export type DynamicSlot = { name: string; fn: Slot }
|
export type DynamicSlot = { name: string; fn: VaporSlot }
|
||||||
export type DynamicSlotFn = () => DynamicSlot | DynamicSlot[]
|
export type DynamicSlotFn = () => DynamicSlot | DynamicSlot[]
|
||||||
export type DynamicSlotSource = StaticSlots | DynamicSlotFn
|
export type DynamicSlotSource = StaticSlots | DynamicSlotFn
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export const dynamicSlotsProxyHandlers: ProxyHandler<RawSlots> = {
|
||||||
export function getSlot(
|
export function getSlot(
|
||||||
target: RawSlots,
|
target: RawSlots,
|
||||||
key: string,
|
key: string,
|
||||||
): (Slot & { _bound?: Slot }) | undefined {
|
): (VaporSlot & { _bound?: VaporSlot }) | undefined {
|
||||||
if (key === '$') return
|
if (key === '$') return
|
||||||
const dynamicSources = target.$
|
const dynamicSources = target.$
|
||||||
if (dynamicSources) {
|
if (dynamicSources) {
|
||||||
|
@ -112,7 +112,7 @@ const dynamicSlotsPropsProxyHandlers: ProxyHandler<RawProps> = {
|
||||||
export function createSlot(
|
export function createSlot(
|
||||||
name: string | (() => string),
|
name: string | (() => string),
|
||||||
rawProps?: LooseRawProps | null,
|
rawProps?: LooseRawProps | null,
|
||||||
fallback?: Slot,
|
fallback?: VaporSlot,
|
||||||
): Block {
|
): Block {
|
||||||
const instance = currentInstance as VaporComponentInstance
|
const instance = currentInstance as VaporComponentInstance
|
||||||
const rawSlots = instance.rawSlots
|
const rawSlots = instance.rawSlots
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
// public APIs
|
// public APIs
|
||||||
export { createVaporApp } from './apiCreateApp'
|
export { createVaporApp } from './apiCreateApp'
|
||||||
export { defineVaporComponent } from './apiDefineComponent'
|
export { defineVaporComponent } from './apiDefineComponent'
|
||||||
|
export { vaporInteropPlugin } from './vdomInterop'
|
||||||
|
|
||||||
// compiler-use only
|
// compiler-use only
|
||||||
export { insert, prepend, remove } from './block'
|
export { insert, prepend, remove } from './block'
|
||||||
export {
|
export { createComponent, createComponentWithFallback } from './component'
|
||||||
createComponent,
|
|
||||||
createComponentWithFallback,
|
|
||||||
mountComponent,
|
|
||||||
unmountComponent,
|
|
||||||
type VaporComponentInstance,
|
|
||||||
} from './component'
|
|
||||||
export { renderEffect } from './renderEffect'
|
export { renderEffect } from './renderEffect'
|
||||||
export { createSlot } from './componentSlots'
|
export { createSlot } from './componentSlots'
|
||||||
export { template, children, next } from './dom/template'
|
export { template, children, next } from './dom/template'
|
||||||
|
@ -44,4 +39,3 @@ export {
|
||||||
applySelectModel,
|
applySelectModel,
|
||||||
applyDynamicModel,
|
applyDynamicModel,
|
||||||
} from './directives/vModel'
|
} from './directives/vModel'
|
||||||
export { vaporInteropPlugin } from './vdomInterop'
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
// for type generation only
|
||||||
|
export * from './index'
|
||||||
|
export * from '@vue/runtime-vapor'
|
|
@ -22,7 +22,7 @@ export default targetPackages.map(
|
||||||
/** @returns {import('rollup').RollupOptions} */
|
/** @returns {import('rollup').RollupOptions} */
|
||||||
pkg => {
|
pkg => {
|
||||||
return {
|
return {
|
||||||
input: `./temp/packages/${pkg}/src/index.d.ts`,
|
input: `./temp/packages/${pkg}/src/index${pkg === 'vue' ? '-with-vapor' : ''}.d.ts`,
|
||||||
output: {
|
output: {
|
||||||
file: `packages/${pkg}/dist/${pkg}.d.ts`,
|
file: `packages/${pkg}/dist/${pkg}.d.ts`,
|
||||||
format: 'es',
|
format: 'es',
|
||||||
|
|
Loading…
Reference in New Issue