Browse Source

upgrade flow

dev
Evan You 8 years ago
parent
commit
c994e5cf48
  1. 22
      flow/component.js
  2. 1
      flow/modules.js
  3. 6
      src/core/instance/render-helpers/render-list.js
  4. 2
      src/core/observer/index.js
  5. 4
      src/server/bundle-renderer/create-bundle-renderer.js
  6. 2
      src/server/create-renderer.js
  7. 2
      src/server/optimizing-compiler/codegen.js
  8. 9
      src/server/optimizing-compiler/runtime-helpers.js
  9. 2
      src/server/render-context.js
  10. 2
      src/server/render.js
  11. 6
      src/shared/util.js

22
flow/component.js

@ -69,16 +69,34 @@ declare interface Component {
_provided: ?Object; _provided: ?Object;
// private methods // private methods
// lifecycle // lifecycle
_init: Function; _init: Function;
_mount: (el?: Element | void, hydrating?: boolean) => Component; _mount: (el?: Element | void, hydrating?: boolean) => Component;
_update: (vnode: VNode, hydrating?: boolean) => void; _update: (vnode: VNode, hydrating?: boolean) => void;
// rendering // rendering
_render: () => VNode; _render: () => VNode;
__patch__: (a: Element | VNode | void, b: VNode) => any;
__patch__: (
a: Element | VNode | void,
b: VNode,
hydrating?: boolean,
removeOnly?: boolean,
parentElm?: any,
refElm?: any
) => any;
// createElement // createElement
// _c is internal that accepts `normalizationType` optimization hint // _c is internal that accepts `normalizationType` optimization hint
_c: (vnode?: VNode, data?: VNodeData, children?: VNodeChildren, normalizationType?: number) => VNode | void; _c: (
vnode?: VNode,
data?: VNodeData,
children?: VNodeChildren,
normalizationType?: number
) => VNode | void;
// renderStatic // renderStatic
_m: (index: number, isInFor?: boolean) => VNode | VNodeChildren; _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren;
// markOnce // markOnce

1
flow/modules.js

@ -10,6 +10,7 @@ declare module 'source-map' {
toString(): string; toString(): string;
} }
declare class SourceMapConsumer { declare class SourceMapConsumer {
constructor (map: Object): void;
originalPositionFor(position: { line: number; column: number; }): { originalPositionFor(position: { line: number; column: number; }): {
source: ?string; source: ?string;
line: ?number; line: ?number;

6
src/core/instance/render-helpers/render-list.js

@ -7,7 +7,11 @@ import { isObject, isDef } from 'core/util/index'
*/ */
export function renderList ( export function renderList (
val: any, val: any,
render: () => VNode render: (
val: any,
keyOrIndex: string | number,
index?: number
) => VNode
): ?Array<VNode> { ): ?Array<VNode> {
let ret: ?Array<VNode>, i, l, keys, key let ret: ?Array<VNode>, i, l, keys, key
if (Array.isArray(val) || typeof val === 'string') { if (Array.isArray(val) || typeof val === 'string') {

2
src/core/observer/index.js

@ -80,7 +80,7 @@ export class Observer {
* Augment an target Object or Array by intercepting * Augment an target Object or Array by intercepting
* the prototype chain using __proto__ * the prototype chain using __proto__
*/ */
function protoAugment (target, src: Object) { function protoAugment (target, src: Object, keys: any) {
/* eslint-disable no-proto */ /* eslint-disable no-proto */
target.__proto__ = src target.__proto__ = src
/* eslint-enable no-proto */ /* eslint-enable no-proto */

4
src/server/bundle-renderer/create-bundle-renderer.js

@ -27,7 +27,9 @@ type RenderBundle = {
modules?: { [filename: string]: Array<string> }; modules?: { [filename: string]: Array<string> };
}; };
export function createBundleRendererCreator (createRenderer: () => Renderer) { export function createBundleRendererCreator (
createRenderer: (options?: RenderOptions) => Renderer
) {
return function createBundleRenderer ( return function createBundleRenderer (
bundle: string | RenderBundle, bundle: string | RenderBundle,
rendererOptions?: RenderOptions = {} rendererOptions?: RenderOptions = {}

2
src/server/create-renderer.js

@ -18,7 +18,7 @@ type RenderCache = {
}; };
export type RenderOptions = { export type RenderOptions = {
modules?: Array<(vnode: VNode) => string>; modules?: Array<(vnode: VNode) => ?string>;
directives?: Object; directives?: Object;
isUnaryTag?: Function; isUnaryTag?: Function;
cache?: RenderCache; cache?: RenderCache;

2
src/server/optimizing-compiler/codegen.js

@ -97,7 +97,7 @@ function genSSRChildren (el, state, checkSkip) {
function genSSRNode (el, state) { function genSSRNode (el, state) {
return el.type === 1 return el.type === 1
? genSSRElement(el, state) ? genSSRElement(el, state)
: genText(el, state) : genText(el)
} }
function genChildrenAsStringNode (el, state) { function genChildrenAsStringNode (el, state) {

9
src/server/optimizing-compiler/runtime-helpers.js

@ -71,7 +71,14 @@ function renderStringNode (
return new StringNode(open, close, children, normalizationType) return new StringNode(open, close, children, normalizationType)
} }
function renderStringList (val: any, render: () => string): string { function renderStringList (
val: any,
render: (
val: any,
keyOrIndex: string | number,
index?: number
) => string
): string {
let ret = '' let ret = ''
let i, l, keys, key let i, l, keys, key
if (Array.isArray(val) || typeof val === 'string') { if (Array.isArray(val) || typeof val === 'string') {

2
src/server/render-context.js

@ -28,7 +28,7 @@ export class RenderContext {
next: () => void; next: () => void;
done: () => void; done: () => void;
modules: Array<() => ?string>; modules: Array<(node: VNode) => ?string>;
directives: Object; directives: Object;
isUnaryTag: (tag: string) => boolean; isUnaryTag: (tag: string) => boolean;

2
src/server/render.js

@ -343,7 +343,7 @@ function renderStartingTag (node: VNode, context) {
} }
export function createRenderFunction ( export function createRenderFunction (
modules: Array<Function>, modules: Array<(node: VNode) => ?string>,
directives: Object, directives: Object,
isUnaryTag: Function, isUnaryTag: Function,
cache: any cache: any

6
src/shared/util.js

@ -202,13 +202,15 @@ export function toObject (arr: Array<any>): Object {
/** /**
* Perform no operation. * Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
*/ */
export function noop () {} export function noop (a?: any, b?: any, c?: any) {}
/** /**
* Always return false. * Always return false.
*/ */
export const no = () => false export const no = (a?: any, b?: any, c?: any) => false
/** /**
* Return same value * Return same value

Loading…
Cancel
Save