types: adjust weex flow types

This commit is contained in:
Evan You 2017-11-29 15:12:08 -05:00
parent 5c2ce0017f
commit b06d09f274
10 changed files with 25 additions and 29 deletions

View File

@ -1,34 +1,30 @@
// global flag to be compiled away
declare var __WEEX__: boolean;
declare type CompilerOptions = {
warn?: Function; // allow customizing warning in different environments; e.g. node
expectHTML?: boolean; // only false for non-web builds
modules?: Array<ModuleOptions>; // platform specific modules; e.g. style; class
staticKeys?: string; // a list of AST properties to be considered static; for optimization
directives?: { [key: string]: Function }; // platform specific directives
staticKeys?: string; // a list of AST properties to be considered static; for optimization
isUnaryTag?: (tag: string) => ?boolean; // check if a tag is unary for the platform
canBeLeftOpenTag?: (tag: string) => ?boolean; // check if a tag can be left opened
isReservedTag?: (tag: string) => ?boolean; // check if a tag is a native for the platform
preserveWhitespace?: boolean; // preserve whitespace between elements?
optimize?: boolean; // optimize static content?
// web specific
mustUseProp?: (tag: string, type: ?string, name: string) => boolean; // check if an attribute should be bound as a property
isPreTag?: (attr: string) => ?boolean; // check if a tag needs to preserve whitespace
getTagNamespace?: (tag: string) => ?string; // check the namespace for a tag
transforms?: Array<Function>; // a list of transforms on parsed AST before codegen
preserveWhitespace?: boolean;
expectHTML?: boolean; // only false for non-web builds
isFromDOM?: boolean;
shouldDecodeTags?: boolean;
shouldDecodeNewlines?: boolean;
shouldDecodeNewlinesForHref?: boolean;
optimize?: boolean;
// for ssr optimization compiler
scopeId?: string;
// runtime user-configurable
delimiters?: [string, string]; // template delimiters
comments?: boolean; // preserve comments in template
// allow user kept comments
comments?: boolean
// for ssr optimization compiler
scopeId?: string;
};
declare type CompiledResult = {

11
flow/weex.js Normal file
View File

@ -0,0 +1,11 @@
// global flag to be compiled away
declare var __WEEX__: boolean;
declare type WeexCompilerOptions = CompilerOptions & {
// whether to compile special template for <recycle-list>
recyclable?: boolean;
};
declare type WeexCompiledResult = CompiledResult & {
'@render'?: string;
};

View File

@ -14,15 +14,6 @@ import {
getTagNamespace
} from '../util/index'
export type WeexCompilerOptions = CompilerOptions & {
// whether to compile special template for <recycle-list>
recyclable?: boolean;
};
export type WeexCompiledResult = CompiledResult & {
'@render'?: string;
};
export const baseOptions: WeexCompilerOptions = {
modules,
directives,

View File

@ -2,7 +2,6 @@
import { addAttr } from 'compiler/helpers'
import { RECYCLE_LIST_MARKER } from 'weex/util/index'
import type { WeexCompilerOptions } from 'weex/compiler/index'
// mark components as inside recycle-list so that we know we need to invoke
// their special @render function instead of render in create-component.js

View File

@ -1,6 +1,5 @@
/* @flow */
import type { WeexCompilerOptions } from 'weex/compiler/index'
import { postTransformComponent } from './component'
import { postTransformText } from './text'
import { preTransformVBind } from './v-bind'

View File

@ -13,7 +13,7 @@ function genText (node: ASTNode) {
return JSON.stringify(value)
}
export function postTransformText (el: ASTElement, options: CompilerOptions) {
export function postTransformText (el: ASTElement, options: WeexCompilerOptions) {
// weex <text> can only contain text, so the parser
// always generates a single child.
if (el.children.length) {

View File

@ -8,7 +8,7 @@ function parseAttrName (name: string): string {
return camelize(name.replace(bindRE, ''))
}
export function preTransformVBind (el: ASTElement, options: CompilerOptions) {
export function preTransformVBind (el: ASTElement, options: WeexCompilerOptions) {
for (const attr in el.attrsMap) {
if (bindRE.test(attr)) {
const name: string = parseAttrName(attr)

View File

@ -3,7 +3,7 @@
import { forAliasRE, forIteratorRE, stripParensRE } from 'compiler/parser/index'
import { getAndRemoveAttr } from 'compiler/helpers'
export function preTransformVFor (el: ASTElement, options: CompilerOptions) {
export function preTransformVFor (el: ASTElement, options: WeexCompilerOptions) {
const exp = getAndRemoveAttr(el, 'v-for')
if (!exp) {
return

View File

@ -18,7 +18,7 @@ function getPrevMatch (el: ASTElement): any {
}
}
export function preTransformVIf (el: ASTElement, options: CompilerOptions) {
export function preTransformVIf (el: ASTElement, options: WeexCompilerOptions) {
if (hasConditionDirective(el)) {
let exp
const ifExp = getAndRemoveAttr(el, 'v-if', true /* remove from attrsMap */)

View File

@ -9,7 +9,7 @@ function parseHandlerParams (handler: ASTElementHandler) {
}
}
export function postTransformVOn (el: ASTElement, options: CompilerOptions) {
export function postTransformVOn (el: ASTElement, options: WeexCompilerOptions) {
const events: ASTElementHandlers | void = el.events
if (!events) {
return