diff --git a/flow/compiler.js b/flow/compiler.js index 39e559ac72b..a3dc1c920fd 100644 --- a/flow/compiler.js +++ b/flow/compiler.js @@ -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; // 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; // 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 = { diff --git a/flow/weex.js b/flow/weex.js new file mode 100644 index 00000000000..2f32bf5c699 --- /dev/null +++ b/flow/weex.js @@ -0,0 +1,11 @@ +// global flag to be compiled away +declare var __WEEX__: boolean; + +declare type WeexCompilerOptions = CompilerOptions & { + // whether to compile special template for + recyclable?: boolean; +}; + +declare type WeexCompiledResult = CompiledResult & { + '@render'?: string; +}; diff --git a/src/platforms/weex/compiler/index.js b/src/platforms/weex/compiler/index.js index 47d7835f6fe..127de6f1816 100644 --- a/src/platforms/weex/compiler/index.js +++ b/src/platforms/weex/compiler/index.js @@ -14,15 +14,6 @@ import { getTagNamespace } from '../util/index' -export type WeexCompilerOptions = CompilerOptions & { - // whether to compile special template for - recyclable?: boolean; -}; - -export type WeexCompiledResult = CompiledResult & { - '@render'?: string; -}; - export const baseOptions: WeexCompilerOptions = { modules, directives, diff --git a/src/platforms/weex/compiler/modules/recycle-list/component.js b/src/platforms/weex/compiler/modules/recycle-list/component.js index cade4df4423..3358548e7f3 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/component.js +++ b/src/platforms/weex/compiler/modules/recycle-list/component.js @@ -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 diff --git a/src/platforms/weex/compiler/modules/recycle-list/index.js b/src/platforms/weex/compiler/modules/recycle-list/index.js index d3cb85a9cba..27973ef93d9 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/index.js +++ b/src/platforms/weex/compiler/modules/recycle-list/index.js @@ -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' diff --git a/src/platforms/weex/compiler/modules/recycle-list/text.js b/src/platforms/weex/compiler/modules/recycle-list/text.js index d896d53c4c1..575ec7f6cea 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/text.js +++ b/src/platforms/weex/compiler/modules/recycle-list/text.js @@ -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 can only contain text, so the parser // always generates a single child. if (el.children.length) { diff --git a/src/platforms/weex/compiler/modules/recycle-list/v-bind.js b/src/platforms/weex/compiler/modules/recycle-list/v-bind.js index a940896df74..3173cacf35e 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +++ b/src/platforms/weex/compiler/modules/recycle-list/v-bind.js @@ -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) diff --git a/src/platforms/weex/compiler/modules/recycle-list/v-for.js b/src/platforms/weex/compiler/modules/recycle-list/v-for.js index 8f3a19d62fe..7dc3243f79e 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/v-for.js +++ b/src/platforms/weex/compiler/modules/recycle-list/v-for.js @@ -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 diff --git a/src/platforms/weex/compiler/modules/recycle-list/v-if.js b/src/platforms/weex/compiler/modules/recycle-list/v-if.js index ffcea24ccdf..50576628055 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/v-if.js +++ b/src/platforms/weex/compiler/modules/recycle-list/v-if.js @@ -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 */) diff --git a/src/platforms/weex/compiler/modules/recycle-list/v-on.js b/src/platforms/weex/compiler/modules/recycle-list/v-on.js index c2f4c19a708..b1ba262c025 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/v-on.js +++ b/src/platforms/weex/compiler/modules/recycle-list/v-on.js @@ -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