Browse Source

types: adjust weex flow types

dev
Evan You 7 years ago
parent
commit
b06d09f274
  1. 22
      flow/compiler.js
  2. 11
      flow/weex.js
  3. 9
      src/platforms/weex/compiler/index.js
  4. 1
      src/platforms/weex/compiler/modules/recycle-list/component.js
  5. 1
      src/platforms/weex/compiler/modules/recycle-list/index.js
  6. 2
      src/platforms/weex/compiler/modules/recycle-list/text.js
  7. 2
      src/platforms/weex/compiler/modules/recycle-list/v-bind.js
  8. 2
      src/platforms/weex/compiler/modules/recycle-list/v-for.js
  9. 2
      src/platforms/weex/compiler/modules/recycle-list/v-if.js
  10. 2
      src/platforms/weex/compiler/modules/recycle-list/v-on.js

22
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<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

@ -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
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 <recycle-list>
recyclable?: boolean;
};
export type WeexCompiledResult = CompiledResult & {
'@render'?: string;
};
export const baseOptions: WeexCompilerOptions = {
modules,
directives,

1
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

1
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'

2
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 <text> can only contain text, so the parser
// always generates a single child.
if (el.children.length) {

2
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)

2
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

2
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 */)

2
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

Loading…
Cancel
Save