Skip to content

Commit

Permalink
types: adjust weex flow types
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 19, 2017
1 parent 5c2ce00 commit b06d09f
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 29 deletions.
22 changes: 9 additions & 13 deletions flow/compiler.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
11 changes: 11 additions & 0 deletions flow/weex.js
Original file line number Diff line number Diff line change
@@ -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;
};
9 changes: 0 additions & 9 deletions src/platforms/weex/compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/platforms/weex/compiler/modules/recycle-list/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/weex/compiler/modules/recycle-list/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/weex/compiler/modules/recycle-list/v-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/weex/compiler/modules/recycle-list/v-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/weex/compiler/modules/recycle-list/v-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */)
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/weex/compiler/modules/recycle-list/v-on.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b06d09f

Please sign in to comment.