types: add types for new features and adjust tests

This commit is contained in:
Evan You 2017-10-06 17:41:54 -04:00
parent 6893499744
commit 96472be6f6
11 changed files with 119 additions and 278 deletions

View File

@ -15,13 +15,13 @@ jobs:
- v1-vue-{{ .Branch }}-{{ checksum "package-lock.json" }} - v1-vue-{{ .Branch }}-{{ checksum "package-lock.json" }}
- v1-vue-{{ .Branch }}- - v1-vue-{{ .Branch }}-
- v1-vue- - v1-vue-
- run: - run: npm install
name: Install Dependencies - run: cd packages/vue-server-renderer && npm install
command: npm install
- save_cache: - save_cache:
key: v1-vue-{{ .Branch }}-{{ checksum "package-lock.json" }} key: v1-vue-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths: paths:
- node_modules/ - node_modules/
- packages/vue-server-renderer/node_modules
- persist_to_workspace: - persist_to_workspace:
root: ~/project root: ~/project
paths: paths:
@ -33,7 +33,7 @@ jobs:
- attach_workspace: - attach_workspace:
at: ~/project at: ~/project
- run: npm run lint - run: npm run lint
- run: node_modules/.bin/flow check - run: npm run flow
- run: npm run test:types - run: npm run test:types
test-cover: test-cover:

View File

@ -12,6 +12,8 @@ declare type InternalComponentOptions = {
staticRenderFns?: Array<Function> staticRenderFns?: Array<Function>
}; };
type InjectKey = string | Symbol;
declare type ComponentOptions = { declare type ComponentOptions = {
// data // data
data: Object | Function | void; data: Object | Function | void;
@ -45,6 +47,7 @@ declare type ComponentOptions = {
deactivated?: Function; deactivated?: Function;
beforeDestroy?: Function; beforeDestroy?: Function;
destroyed?: Function; destroyed?: Function;
errorCaptured?: () => boolean | void;
// assets // assets
directives?: { [key: string]: Object }; directives?: { [key: string]: Object };
@ -54,7 +57,7 @@ declare type ComponentOptions = {
// context // context
provide?: { [key: string | Symbol]: any } | () => { [key: string | Symbol]: any }; provide?: { [key: string | Symbol]: any } | () => { [key: string | Symbol]: any };
inject?: { [key: string]: string | Symbol } | Array<string>; inject?: { [key: string]: InjectKey | { from?: InjectKey, default?: any }} | Array<string>;
// component v-model customization // component v-model customization
model?: { model?: {

38
package-lock.json generated
View File

@ -4,6 +4,44 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@types/node": {
"version": "8.0.33",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.33.tgz",
"integrity": "sha512-vmCdO8Bm1ExT+FWfC9sd9r4jwqM7o97gGy2WBshkkXbf/2nLAJQUrZfIhw27yVOtLUev6kSZc4cav/46KbDd8A==",
"dev": true
},
"@types/source-map": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@types/source-map/-/source-map-0.5.1.tgz",
"integrity": "sha512-/GVAjL1Y8puvZab63n8tsuBiYwZt1bApMdx58/msQ9ID5T05ov+wm/ZV1DvYC/DKKEygpTJViqQvkh5Rhrl4CA==",
"dev": true
},
"@types/tapable": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-0.2.4.tgz",
"integrity": "sha512-pclMAvhPnXJcJu1ZZ8bQthuUcdDWzDuxDdbSf6l1U6s4fP6EBiZpPsOZYqFOrbqDV97sXGFSsb6AUpiLfv4xIA==",
"dev": true
},
"@types/uglify-js": {
"version": "2.6.29",
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-2.6.29.tgz",
"integrity": "sha512-BdFLCZW0GTl31AbqXSak8ss/MqEZ3DN2MH9rkAyGoTuzK7ifGUlX+u0nfbWeTsa7IPcZhtn8BlpYBXSV+vqGhQ==",
"dev": true,
"requires": {
"@types/source-map": "0.5.1"
}
},
"@types/webpack": {
"version": "3.0.13",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-3.0.13.tgz",
"integrity": "sha512-gWVIAVaGapOPHOrjUQalUqdJWdUIn8w5gpKzz2L14megpB1euvq4HxvGusp9nhtkYGjD/sIg20Zse42b7+7BDw==",
"dev": true,
"requires": {
"@types/node": "8.0.33",
"@types/tapable": "0.2.4",
"@types/uglify-js": "2.6.29"
}
},
"JSONStream": { "JSONStream": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz",

View File

@ -56,6 +56,8 @@
}, },
"homepage": "https://github.com/vuejs/vue#readme", "homepage": "https://github.com/vuejs/vue#readme",
"devDependencies": { "devDependencies": {
"@types/node": "^8.0.33",
"@types/webpack": "^3.0.13",
"babel-core": "^6.25.0", "babel-core": "^6.25.0",
"babel-eslint": "^7.2.3", "babel-eslint": "^7.2.3",
"babel-helper-vue-jsx-merge-props": "^2.0.2", "babel-helper-vue-jsx-merge-props": "^2.0.2",

View File

@ -4,44 +4,6 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@types/node": {
"version": "7.0.43",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.43.tgz",
"integrity": "sha512-7scYwwfHNppXvH/9JzakbVxk0o0QUILVk1Lv64GRaxwPuGpnF1QBiwdvhDpLcymb8BpomQL3KYoWKq3wUdDMhQ==",
"dev": true
},
"@types/source-map": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@types/source-map/-/source-map-0.5.1.tgz",
"integrity": "sha512-/GVAjL1Y8puvZab63n8tsuBiYwZt1bApMdx58/msQ9ID5T05ov+wm/ZV1DvYC/DKKEygpTJViqQvkh5Rhrl4CA==",
"dev": true
},
"@types/tapable": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-0.2.4.tgz",
"integrity": "sha512-pclMAvhPnXJcJu1ZZ8bQthuUcdDWzDuxDdbSf6l1U6s4fP6EBiZpPsOZYqFOrbqDV97sXGFSsb6AUpiLfv4xIA==",
"dev": true
},
"@types/uglify-js": {
"version": "2.6.29",
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-2.6.29.tgz",
"integrity": "sha512-BdFLCZW0GTl31AbqXSak8ss/MqEZ3DN2MH9rkAyGoTuzK7ifGUlX+u0nfbWeTsa7IPcZhtn8BlpYBXSV+vqGhQ==",
"dev": true,
"requires": {
"@types/source-map": "0.5.1"
}
},
"@types/webpack": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-3.0.10.tgz",
"integrity": "sha512-Xjv1QuWFCVwjxnpcgcdvtR6G4w0tCUpV1Mi5+LPN8w89a/qu8NVbTm1zhD7ZWzvvjE5fMtYNchFHcbjV3u2jyg==",
"dev": true,
"requires": {
"@types/node": "7.0.43",
"@types/tapable": "0.2.4",
"@types/uglify-js": "2.6.29"
}
},
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
@ -150,12 +112,6 @@
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
}, },
"typescript": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.2.tgz",
"integrity": "sha1-A4qV99m7tCCxvzW6MdTFwd0//jQ=",
"dev": true
},
"vue": { "vue": {
"version": "file:../..", "version": "file:../..",
"dev": true, "dev": true,
@ -180,10 +136,6 @@
"negotiator": "0.6.1" "negotiator": "0.6.1"
} }
}, },
"acorn": {
"version": "3.3.0",
"bundled": true
},
"acorn-dynamic-import": { "acorn-dynamic-import": {
"version": "2.0.2", "version": "2.0.2",
"bundled": true, "bundled": true,
@ -197,20 +149,6 @@
} }
} }
}, },
"acorn-jsx": {
"version": "3.0.1",
"bundled": true,
"requires": {
"acorn": "3.3.0"
}
},
"acorn-object-spread": {
"version": "1.0.0",
"bundled": true,
"requires": {
"acorn": "3.3.0"
}
},
"adm-zip": { "adm-zip": {
"version": "0.4.7", "version": "0.4.7",
"bundled": true "bundled": true
@ -262,14 +200,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true "bundled": true
}, },
"ansi-regex": {
"version": "2.1.1",
"bundled": true
},
"ansi-styles": {
"version": "2.2.1",
"bundled": true
},
"anymatch": { "anymatch": {
"version": "1.3.2", "version": "1.3.2",
"bundled": true, "bundled": true,
@ -423,7 +353,6 @@
"version": "6.26.0", "version": "6.26.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"chalk": "1.1.3",
"esutils": "2.0.2", "esutils": "2.0.2",
"js-tokens": "3.0.2" "js-tokens": "3.0.2"
} }
@ -446,7 +375,6 @@
"debug": "2.6.8", "debug": "2.6.8",
"json5": "0.5.1", "json5": "0.5.1",
"lodash": "4.17.4", "lodash": "4.17.4",
"minimatch": "3.0.4",
"path-is-absolute": "1.0.1", "path-is-absolute": "1.0.1",
"private": "0.1.7", "private": "0.1.7",
"slash": "1.0.0", "slash": "1.0.0",
@ -947,10 +875,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true "bundled": true
}, },
"balanced-match": {
"version": "1.0.0",
"bundled": true
},
"base64-arraybuffer": { "base64-arraybuffer": {
"version": "0.1.5", "version": "0.1.5",
"bundled": true "bundled": true
@ -1057,14 +981,6 @@
"hoek": "2.16.3" "hoek": "2.16.3"
} }
}, },
"brace-expansion": {
"version": "1.1.8",
"bundled": true,
"requires": {
"balanced-match": "1.0.0",
"concat-map": "0.0.1"
}
},
"braces": { "braces": {
"version": "1.8.5", "version": "1.8.5",
"bundled": true, "bundled": true,
@ -1152,25 +1068,6 @@
"pako": "0.2.9" "pako": "0.2.9"
} }
}, },
"buble": {
"version": "0.15.2",
"bundled": true,
"requires": {
"acorn": "3.3.0",
"acorn-jsx": "3.0.1",
"acorn-object-spread": "1.0.0",
"chalk": "1.1.3",
"magic-string": "0.14.0",
"minimist": "1.2.0",
"os-homedir": "1.0.2"
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"bundled": true
}
}
},
"buffer": { "buffer": {
"version": "4.9.1", "version": "4.9.1",
"bundled": true, "bundled": true,
@ -1202,10 +1099,7 @@
}, },
"cachedir": { "cachedir": {
"version": "1.1.1", "version": "1.1.1",
"bundled": true, "bundled": true
"requires": {
"os-homedir": "1.0.2"
}
}, },
"caller-path": { "caller-path": {
"version": "0.1.0", "version": "0.1.0",
@ -1254,17 +1148,6 @@
"deep-eql": "0.1.3" "deep-eql": "0.1.3"
} }
}, },
"chalk": {
"version": "1.1.3",
"bundled": true,
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
}
},
"chokidar": { "chokidar": {
"version": "1.7.0", "version": "1.7.0",
"bundled": true, "bundled": true,
@ -1521,7 +1404,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"cachedir": "1.1.1", "cachedir": "1.1.1",
"chalk": "1.1.3",
"cz-conventional-changelog": "1.2.0", "cz-conventional-changelog": "1.2.0",
"dedent": "0.6.0", "dedent": "0.6.0",
"detect-indent": "4.0.0", "detect-indent": "4.0.0",
@ -1556,7 +1438,6 @@
"fs.realpath": "1.0.0", "fs.realpath": "1.0.0",
"inflight": "1.0.6", "inflight": "1.0.6",
"inherits": "2.0.3", "inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0", "once": "1.4.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "1.0.1"
} }
@ -1621,10 +1502,6 @@
"readable-stream": "2.3.3" "readable-stream": "2.3.3"
} }
}, },
"concat-map": {
"version": "0.0.1",
"bundled": true
},
"concat-stream": { "concat-stream": {
"version": "1.6.0", "version": "1.6.0",
"bundled": true, "bundled": true,
@ -2383,10 +2260,6 @@
"version": "1.0.3", "version": "1.0.3",
"bundled": true "bundled": true
}, },
"escape-string-regexp": {
"version": "1.0.5",
"bundled": true
},
"escodegen": { "escodegen": {
"version": "1.8.1", "version": "1.8.1",
"bundled": true, "bundled": true,
@ -2431,7 +2304,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"babel-code-frame": "6.26.0", "babel-code-frame": "6.26.0",
"chalk": "1.1.3",
"concat-stream": "1.6.0", "concat-stream": "1.6.0",
"debug": "2.6.8", "debug": "2.6.8",
"doctrine": "2.0.0", "doctrine": "2.0.0",
@ -2472,8 +2344,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"ansi-escapes": "1.4.0", "ansi-escapes": "1.4.0",
"ansi-regex": "2.1.1",
"chalk": "1.1.3",
"cli-cursor": "1.0.2", "cli-cursor": "1.0.2",
"cli-width": "2.2.0", "cli-width": "2.2.0",
"figures": "1.7.0", "figures": "1.7.0",
@ -2482,7 +2352,6 @@
"run-async": "0.1.0", "run-async": "0.1.0",
"rx-lite": "3.1.2", "rx-lite": "3.1.2",
"string-width": "1.0.2", "string-width": "1.0.2",
"strip-ansi": "3.0.1",
"through": "2.3.8" "through": "2.3.8"
} }
}, },
@ -2539,8 +2408,7 @@
"version": "3.5.0", "version": "3.5.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"acorn": "5.1.1", "acorn": "5.1.1"
"acorn-jsx": "3.0.1"
}, },
"dependencies": { "dependencies": {
"acorn": { "acorn": {
@ -2572,10 +2440,6 @@
"version": "4.2.0", "version": "4.2.0",
"bundled": true "bundled": true
}, },
"estree-walker": {
"version": "0.2.1",
"bundled": true
},
"esutils": { "esutils": {
"version": "2.0.2", "version": "2.0.2",
"bundled": true "bundled": true
@ -2662,10 +2526,7 @@
}, },
"expand-tilde": { "expand-tilde": {
"version": "1.2.2", "version": "1.2.2",
"bundled": true, "bundled": true
"requires": {
"os-homedir": "1.0.2"
}
}, },
"extend": { "extend": {
"version": "3.0.1", "version": "3.0.1",
@ -2736,7 +2597,6 @@
"version": "1.7.0", "version": "1.7.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"escape-string-regexp": "1.0.5",
"object-assign": "4.1.1" "object-assign": "4.1.1"
} }
}, },
@ -2849,10 +2709,7 @@
"dependencies": { "dependencies": {
"magic-string": { "magic-string": {
"version": "0.16.0", "version": "0.16.0",
"bundled": true, "bundled": true
"requires": {
"vlq": "0.2.2"
}
} }
} }
}, },
@ -3812,7 +3669,6 @@
"fs.realpath": "1.0.0", "fs.realpath": "1.0.0",
"inflight": "1.0.6", "inflight": "1.0.6",
"inherits": "2.0.3", "inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0", "once": "1.4.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "1.0.1"
} }
@ -3930,13 +3786,6 @@
"har-schema": "1.0.5" "har-schema": "1.0.5"
} }
}, },
"has-ansi": {
"version": "2.0.0",
"bundled": true,
"requires": {
"ansi-regex": "2.1.1"
}
},
"has-binary": { "has-binary": {
"version": "0.1.7", "version": "0.1.7",
"bundled": true, "bundled": true,
@ -4016,7 +3865,6 @@
"version": "2.0.0", "version": "2.0.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"os-homedir": "1.0.2",
"os-tmpdir": "1.0.2" "os-tmpdir": "1.0.2"
} }
}, },
@ -4154,7 +4002,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"ansi-escapes": "1.4.0", "ansi-escapes": "1.4.0",
"chalk": "1.1.3",
"cli-cursor": "1.0.2", "cli-cursor": "1.0.2",
"cli-width": "2.2.0", "cli-width": "2.2.0",
"external-editor": "1.1.1", "external-editor": "1.1.1",
@ -4165,7 +4012,6 @@
"run-async": "2.3.0", "run-async": "2.3.0",
"rx": "4.1.0", "rx": "4.1.0",
"string-width": "1.0.2", "string-width": "1.0.2",
"strip-ansi": "3.0.1",
"through": "2.3.8" "through": "2.3.8"
} }
}, },
@ -4400,7 +4246,6 @@
"requires": { "requires": {
"inflight": "1.0.6", "inflight": "1.0.6",
"inherits": "2.0.3", "inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0", "once": "1.4.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "1.0.1"
} }
@ -4563,7 +4408,6 @@
"lodash": "3.10.1", "lodash": "3.10.1",
"log4js": "0.6.38", "log4js": "0.6.38",
"mime": "1.4.0", "mime": "1.4.0",
"minimatch": "3.0.4",
"optimist": "0.6.1", "optimist": "0.6.1",
"qjobs": "1.1.5", "qjobs": "1.1.5",
"range-parser": "1.2.0", "range-parser": "1.2.0",
@ -4611,7 +4455,6 @@
"dateformat": "1.0.12", "dateformat": "1.0.12",
"istanbul": "0.4.5", "istanbul": "0.4.5",
"lodash": "3.10.1", "lodash": "3.10.1",
"minimatch": "3.0.4",
"source-map": "0.5.7" "source-map": "0.5.7"
}, },
"dependencies": { "dependencies": {
@ -4654,7 +4497,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"ansi-styles": "3.2.0", "ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
"supports-color": "4.4.0" "supports-color": "4.4.0"
} }
}, },
@ -5033,7 +4875,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"ansi-styles": "3.2.0", "ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
"supports-color": "4.4.0" "supports-color": "4.4.0"
} }
}, },
@ -5109,13 +4950,6 @@
"yallist": "2.1.2" "yallist": "2.1.2"
} }
}, },
"magic-string": {
"version": "0.14.0",
"bundled": true,
"requires": {
"vlq": "0.2.2"
}
},
"make-dir": { "make-dir": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
@ -5233,13 +5067,6 @@
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true
}, },
"minimatch": {
"version": "3.0.4",
"bundled": true,
"requires": {
"brace-expansion": "1.1.8"
}
},
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true "bundled": true
@ -5263,7 +5090,6 @@
"commander": "2.9.0", "commander": "2.9.0",
"debug": "2.2.0", "debug": "2.2.0",
"diff": "1.4.0", "diff": "1.4.0",
"escape-string-regexp": "1.0.5",
"glob": "7.0.5", "glob": "7.0.5",
"growl": "1.9.2", "growl": "1.9.2",
"json3": "3.3.2", "json3": "3.3.2",
@ -5293,7 +5119,6 @@
"fs.realpath": "1.0.0", "fs.realpath": "1.0.0",
"inflight": "1.0.6", "inflight": "1.0.6",
"inherits": "2.0.3", "inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0", "once": "1.4.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "1.0.1"
} }
@ -5358,10 +5183,7 @@
"dependencies": { "dependencies": {
"minimatch": { "minimatch": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true
"requires": {
"brace-expansion": "1.1.8"
}
}, },
"q": { "q": {
"version": "1.4.1", "version": "1.4.1",
@ -5520,10 +5342,6 @@
"version": "0.2.1", "version": "0.2.1",
"bundled": true "bundled": true
}, },
"os-homedir": {
"version": "1.0.2",
"bundled": true
},
"os-locale": { "os-locale": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
@ -5963,7 +5781,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"graceful-fs": "4.1.11", "graceful-fs": "4.1.11",
"minimatch": "3.0.4",
"readable-stream": "2.3.3", "readable-stream": "2.3.3",
"set-immediate-shim": "1.0.1" "set-immediate-shim": "1.0.1"
} }
@ -6210,14 +6027,6 @@
"rollup-pluginutils": "1.5.2" "rollup-pluginutils": "1.5.2"
} }
}, },
"rollup-plugin-buble": {
"version": "0.15.0",
"bundled": true,
"requires": {
"buble": "0.15.2",
"rollup-pluginutils": "1.5.2"
}
},
"rollup-plugin-commonjs": { "rollup-plugin-commonjs": {
"version": "8.2.0", "version": "8.2.0",
"bundled": true, "bundled": true,
@ -6239,10 +6048,7 @@
}, },
"magic-string": { "magic-string": {
"version": "0.22.4", "version": "0.22.4",
"bundled": true, "bundled": true
"requires": {
"vlq": "0.2.2"
}
}, },
"rollup-pluginutils": { "rollup-pluginutils": {
"version": "2.0.1", "version": "2.0.1",
@ -6264,8 +6070,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"flow-remove-types-no-whitespace": "1.0.5", "flow-remove-types-no-whitespace": "1.0.5"
"rollup-pluginutils": "1.5.2"
} }
}, },
"rollup-plugin-node-resolve": { "rollup-plugin-node-resolve": {
@ -6278,32 +6083,6 @@
"resolve": "1.4.0" "resolve": "1.4.0"
} }
}, },
"rollup-plugin-replace": {
"version": "1.1.1",
"bundled": true,
"requires": {
"magic-string": "0.15.2",
"minimatch": "3.0.4",
"rollup-pluginutils": "1.5.2"
},
"dependencies": {
"magic-string": {
"version": "0.15.2",
"bundled": true,
"requires": {
"vlq": "0.2.2"
}
}
}
},
"rollup-pluginutils": {
"version": "1.5.2",
"bundled": true,
"requires": {
"estree-walker": "0.2.1",
"minimatch": "3.0.4"
}
},
"rollup-watch": { "rollup-watch": {
"version": "4.3.1", "version": "4.3.1",
"bundled": true, "bundled": true,
@ -6697,8 +6476,7 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"code-point-at": "1.1.0", "code-point-at": "1.1.0",
"is-fullwidth-code-point": "1.0.0", "is-fullwidth-code-point": "1.0.0"
"strip-ansi": "3.0.1"
} }
}, },
"string_decoder": { "string_decoder": {
@ -6712,13 +6490,6 @@
"version": "0.0.5", "version": "0.0.5",
"bundled": true "bundled": true
}, },
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"requires": {
"ansi-regex": "2.1.1"
}
},
"strip-bom": { "strip-bom": {
"version": "2.0.0", "version": "2.0.0",
"bundled": true, "bundled": true,
@ -6737,17 +6508,12 @@
"version": "2.0.1", "version": "2.0.1",
"bundled": true "bundled": true
}, },
"supports-color": {
"version": "2.0.0",
"bundled": true
},
"table": { "table": {
"version": "3.8.3", "version": "3.8.3",
"bundled": true, "bundled": true,
"requires": { "requires": {
"ajv": "4.11.8", "ajv": "4.11.8",
"ajv-keywords": "1.5.1", "ajv-keywords": "1.5.1",
"chalk": "1.1.3",
"lodash": "4.17.4", "lodash": "4.17.4",
"slice-ansi": "0.0.4", "slice-ansi": "0.0.4",
"string-width": "2.1.1" "string-width": "2.1.1"
@ -7019,10 +6785,7 @@
}, },
"user-home": { "user-home": {
"version": "2.0.0", "version": "2.0.0",
"bundled": true, "bundled": true
"requires": {
"os-homedir": "1.0.2"
}
}, },
"useragent": { "useragent": {
"version": "2.2.1", "version": "2.2.1",
@ -7090,10 +6853,6 @@
} }
} }
}, },
"vlq": {
"version": "0.2.2",
"bundled": true
},
"vm-browserify": { "vm-browserify": {
"version": "0.0.4", "version": "0.0.4",
"bundled": true, "bundled": true,
@ -7156,7 +6915,6 @@
"version": "2.0.6", "version": "2.0.6",
"bundled": true, "bundled": true,
"requires": { "requires": {
"chalk": "1.1.3",
"commander": "2.11.0", "commander": "2.11.0",
"is-my-json-valid": "2.16.1", "is-my-json-valid": "2.16.1",
"pinkie-promise": "2.0.1" "pinkie-promise": "2.0.1"
@ -7314,7 +7072,6 @@
"bundled": true, "bundled": true,
"requires": { "requires": {
"string-width": "1.0.2", "string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wrap-ansi": "2.1.0" "wrap-ansi": "2.1.0"
} }
} }
@ -7386,8 +7143,7 @@
"version": "2.1.0", "version": "2.1.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"string-width": "1.0.2", "string-width": "1.0.2"
"strip-ansi": "3.0.1"
} }
}, },
"wrappy": { "wrappy": {

View File

@ -18,9 +18,6 @@
"bugs": { "bugs": {
"url": "https://github.com/vuejs/vue/issues" "url": "https://github.com/vuejs/vue/issues"
}, },
"scripts": {
"test:types": "tsc -p types"
},
"dependencies": { "dependencies": {
"chalk": "^1.1.3", "chalk": "^1.1.3",
"hash-sum": "^1.0.2", "hash-sum": "^1.0.2",
@ -32,10 +29,7 @@
"source-map": "0.5.6" "source-map": "0.5.6"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^7.0.22", "vue": "file:../../"
"@types/webpack": "^3.0.6",
"typescript": "^2.4.2",
"vue": "file:../.."
}, },
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme" "homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme"
} }

View File

@ -1,4 +1,4 @@
import Vue = require('vue'); import Vue, { VNode, VNodeDirective } from 'vue';
import { Readable } from 'stream'; import { Readable } from 'stream';
export declare function createRenderer(options?: RendererOptions): Renderer; export declare function createRenderer(options?: RendererOptions): Renderer;
@ -10,6 +10,7 @@ type RenderCallback = (err: Error | null, html: string) => void;
interface Renderer { interface Renderer {
renderToString(vm: Vue, callback: RenderCallback): void; renderToString(vm: Vue, callback: RenderCallback): void;
renderToString(vm: Vue, context: object, callback: RenderCallback): void; renderToString(vm: Vue, context: object, callback: RenderCallback): void;
renderToString(vm: Vue): Promise<string>;
renderToStream(vm: Vue, context?: object): Readable; renderToStream(vm: Vue, context?: object): Readable;
} }
@ -25,9 +26,10 @@ interface RendererOptions {
template?: string; template?: string;
inject?: boolean; inject?: boolean;
shouldPreload?: (file: string, type: string) => boolean; shouldPreload?: (file: string, type: string) => boolean;
shouldPrefetch?: (file: string, type: string) => boolean;
cache?: RenderCache; cache?: RenderCache;
directives?: { directives?: {
[key: string]: (vnode: Vue.VNode, dir: Vue.VNodeDirective) => void [key: string]: (vnode: VNode, dir: VNodeDirective) => void
}; };
} }

11
types/options.d.ts vendored
View File

@ -80,6 +80,7 @@ export interface ComponentOptions<
updated?(): void; updated?(): void;
activated?(): void; activated?(): void;
deactivated?(): void; deactivated?(): void;
errorCaptured?(): boolean | void;
directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; directives?: { [key: string]: DirectiveFunction | DirectiveOptions };
components?: { [key: string]: Component<any, any, any, any> | AsyncComponent<any, any, any, any> }; components?: { [key: string]: Component<any, any, any, any> | AsyncComponent<any, any, any, any> };
@ -87,7 +88,7 @@ export interface ComponentOptions<
filters?: { [key: string]: Function }; filters?: { [key: string]: Function };
provide?: Object | (() => Object); provide?: Object | (() => Object);
inject?: { [key: string]: string | symbol } | string[]; inject?: InjectOptions;
model?: { model?: {
prop?: string; prop?: string;
@ -107,7 +108,7 @@ export interface ComponentOptions<
export interface FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> { export interface FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> {
name?: string; name?: string;
props?: PropDefs; props?: PropDefs;
inject?: { [key: string]: string | symbol } | string[]; inject?: InjectOptions;
functional: boolean; functional: boolean;
render(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode; render(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode;
} }
@ -169,3 +170,9 @@ export interface DirectiveOptions {
componentUpdated?: DirectiveFunction; componentUpdated?: DirectiveFunction;
unbind?: DirectiveFunction; unbind?: DirectiveFunction;
} }
export type InjectKey = string | symbol;
export type InjectOptions = {
[key: string]: InjectKey | { from?: InjectKey, default?: any }
} | string[];

View File

@ -187,6 +187,9 @@ Vue.component('component', {
updated() {}, updated() {},
activated() {}, activated() {},
deactivated() {}, deactivated() {},
errorCaptured() {
return true
},
directives: { directives: {
a: { a: {
@ -224,6 +227,25 @@ Vue.component('component', {
delimiters: ["${", "}"] delimiters: ["${", "}"]
}); });
Vue.component('provide-inject', {
provide: {
foo: 1
},
inject: {
injectFoo: 'foo',
injectBar: Symbol(),
injectBaz: { from: 'baz' },
injectQux: { default: 1 },
injectQuux: { from: 'quuz', default: () => ({ value: 1 })}
}
})
Vue.component('provide-function', {
provide: () => ({
foo: 1
})
})
Vue.component('component-with-scoped-slot', { Vue.component('component-with-scoped-slot', {
render (h) { render (h) {
interface ScopedSlotProps { interface ScopedSlotProps {
@ -272,8 +294,11 @@ Vue.component('functional-component', {
Vue.component('functional-component-object-inject', { Vue.component('functional-component-object-inject', {
functional: true, functional: true,
inject: { inject: {
foo: 'bar', foo: 'foo',
baz: Symbol() bar: Symbol(),
baz: { from: 'baz' },
qux: { default: 1 },
quux: { from: 'quuz', default: () => ({ value: 1 })}
}, },
render(h) { render(h) {
return h('div') return h('div')

View File

@ -1,9 +1,9 @@
import Vue = require('vue'); import Vue, { VNode, VNodeDirective } from '../index';
import VueSSRClientPlugin = require('../client-plugin'); import VueSSRClientPlugin = require('../../packages/vue-server-renderer/client-plugin');
import VueSSRServerPlugin = require('../server-plugin'); import VueSSRServerPlugin = require('../../packages/vue-server-renderer/server-plugin');
import webpack = require('webpack'); import webpack = require('webpack');
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import { createRenderer, createBundleRenderer } from '../'; import { createRenderer, createBundleRenderer } from '../../packages/vue-server-renderer';
function createApp (context: any) { function createApp (context: any) {
return new Vue({ return new Vue({
@ -28,11 +28,24 @@ const context = {
` `
}; };
renderer.renderToString(app, (err, html) => {
if (err) throw err;
const res: string = html;
});
renderer.renderToString(app, context, (err, html) => { renderer.renderToString(app, context, (err, html) => {
if (err) throw err; if (err) throw err;
const res: string = html; const res: string = html;
}); });
renderer.renderToString(app)
.then(html => {
const res: string = html;
})
.catch(err => {
throw err;
});
renderer.renderToStream(app, context).on('data', chunk => { renderer.renderToStream(app, context).on('data', chunk => {
const html = chunk.toString(); const html = chunk.toString();
}); });
@ -71,7 +84,7 @@ const bundleRenderer = createBundleRenderer('/path/to/vue-ssr-server-bundle.json
}, },
directives: { directives: {
example (vnode: Vue.VNode, directiveMeta: Vue.VNodeDirective) { example (vnode: VNode, directiveMeta: VNodeDirective) {
// transform vnode based on directive binding metadata // transform vnode based on directive binding metadata
} }
} }

View File

@ -18,7 +18,8 @@
"options-test.ts", "options-test.ts",
"plugin-test.ts", "plugin-test.ts",
"vue-test.ts", "vue-test.ts",
"augmentation-test.ts" "augmentation-test.ts",
"ssr-test.ts"
], ],
"compileOnSave": false "compileOnSave": false
} }